diff --git "a/all/amps_linear_algebra.json" "b/all/amps_linear_algebra.json" deleted file mode 100644--- "a/all/amps_linear_algebra.json" +++ /dev/null @@ -1,100014 +0,0 @@ -{ - "Source": [ - "AMPS.algebra.mathematica/linear_algebra/cross_product" - ], - "Categories": [ - { - "Math complexity": 4, - "Language complexity": 1, - "Domain knowledge complexity": 3 - } - ], - "Instances": [ - { - "Input": "Problem:\nFind the distance from the point ${\\frac{18}{5}, -3, \\frac{3}{5}}$ to the plane $-\\frac{6 x}{5}+\\frac{16 y}{5}-\\frac{6 z}{5}-\\frac{13}{5}=0$.", - "Output Answer": [ - "$\\frac{431}{10 \\sqrt{82}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (18/5), -3, (3/5)\nplane = Poly(-((6*x)/5)+((16*y)/5)-((6*z)/5)-(13/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 1 \\\\\n -6 \\\\\n 9 \\\\\n 0 \\\\\n -4 \\\\\n -4 \\\\\n 2 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -4 \\\\\n -8 \\\\\n 1 \\\\\n 8 \\\\\n -6 \\\\\n -4 \\\\\n -3 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{638}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [1],\n [-6],\n [9],\n [0],\n [-4],\n [-4],\n [2],\n [-6]])\nb = np.array([\n [-7],\n [-4],\n [-8],\n [1],\n [8],\n [-6],\n [-4],\n [-3],\n [10]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -3 \\\\\n 1 \\\\\n 2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 2 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{0,-2,0,0,1\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-3],\n [1],\n [2],\n [-1]]).squeeze()\nb = np.array([\n [0],\n [2],\n [0],\n [0],\n [-1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{25}{6} \\\\\n \\frac{7}{2} \\\\\n -\\frac{19}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{25}{6} \\\\\n \\frac{16}{3} \\\\\n \\frac{19}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{53}{6} \\\\\n -\\frac{19}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(25/6)],\n [(7/2)],\n [-(19/3)]])\nb = np.array([\n [-(25/6)],\n [(16/3)],\n [(19/6)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{4}{7}, \\frac{22}{7}}$ to the line $-\\frac{11 x}{7}-\\frac{15 y}{7}-\\frac{34}{7}=0$.", - "Output Answer": [ - "$\\frac{306 \\sqrt{\\frac{2}{173}}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (4/7), (22/7)\nline = Poly(-((11*x)/7)-((15*y)/7)-(34/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 9 & -2 & 9 & -8 & -5 \\\\\n -1 & -4 & 9 & 7 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & \\frac{9}{19} & -\\frac{23}{19} & -\\frac{10}{19} \\\\\n 0 & 1 & -\\frac{45}{19} & -\\frac{55}{38} & \\frac{5}{38} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, -2, 9, -8, -5],\n [-1, -4, 9, 7, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{5} & \\frac{23}{10} \\\\\n \\frac{8}{5} & \\frac{23}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -5 & \\frac{5}{2} \\\\\n \\frac{40}{23} & -\\frac{15}{23} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/5), (23/10)],\n [(8/5), (23/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 1 \\\\\n -3 \\\\\n -6 \\\\\n 2 \\\\\n 9 \\\\\n -9 \\\\\n -4 \\\\\n -7 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -7 \\\\\n 7 \\\\\n 3 \\\\\n -8 \\\\\n 6 \\\\\n 4 \\\\\n 5 \\\\\n -9 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$27$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [1],\n [-3],\n [-6],\n [2],\n [9],\n [-9],\n [-4],\n [-7],\n [3]])\nb = np.array([\n [6],\n [-7],\n [7],\n [3],\n [-8],\n [6],\n [4],\n [5],\n [-9],\n [-8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{3} \\\\\n -\\frac{11}{6} \\\\\n -\\frac{1}{3} \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2 \\sqrt{\\frac{2}{3}}}{5} \\\\\n -\\frac{11}{5 \\sqrt{6}} \\\\\n -\\frac{\\sqrt{\\frac{2}{3}}}{5} \\\\\n -\\frac{\\sqrt{\\frac{3}{2}}}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3)],\n [-(11/6)],\n [-(1/3)],\n [-(1/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{3} \\\\\n \\frac{29}{6} \\\\\n -\\frac{5}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{2} \\\\\n \\frac{16}{3} \\\\\n -\\frac{19}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{391}{36} \\\\\n \\frac{173}{36} \\\\\n \\frac{847}{36} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/3)],\n [(29/6)],\n [-(5/6)]])\nb = np.array([\n [-(9/2)],\n [(16/3)],\n [-(19/6)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 5 \\\\\n 10 \\\\\n -6 \\\\\n -8 \\\\\n -10 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 5 \\\\\n -8 \\\\\n 8 \\\\\n 8 \\\\\n -9 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{923}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [5],\n [10],\n [-6],\n [-8],\n [-10],\n [7]])\nb = np.array([\n [6],\n [5],\n [-8],\n [8],\n [8],\n [-9],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & -1 & -2 & 3 \\\\\n -3 & 1 & 0 & -2 \\\\\n 3 & 3 & 0 & 1 \\\\\n 0 & -2 & 3 & -2 \\\\\n -3 & 1 & 2 & 2 \\\\\n 2 & 0 & -1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.26 \\\\\n 2.5 \\\\\n 2.65 \\\\\n 1.66 \\\\\n 1.33 \\\\\n 1.94 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.033 \\\\\n 0.578 \\\\\n 0.511 \\\\\n 0.172 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1, -2, 3],\n [-3, 1, 0, -2],\n [3, 3, 0, 1],\n [0, -2, 3, -2],\n [-3, 1, 2, 2],\n [2, 0, -1, 3]])\nb = np.array([\n [-0.26],\n [2.5],\n [2.65],\n [1.66],\n [1.33],\n [1.94]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 2 & -1 & -3 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 3 \\\\\n 0 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1, -3, 0]])\nb = np.array([\n [1],\n [3],\n [0],\n [2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{25}{8} & \\frac{113}{16} \\\\\n \\frac{39}{16} & \\frac{1}{16} \\\\\n \\frac{47}{8} & \\frac{57}{16} \\\\\n \\frac{91}{16} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{113}{16} & \\frac{151}{16} \\\\\n \\frac{3}{2} & \\frac{19}{16} \\\\\n \\frac{119}{16} & \\frac{39}{8} \\\\\n -7 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{163}{16} & \\frac{33}{2} \\\\\n \\frac{63}{16} & \\frac{5}{4} \\\\\n \\frac{213}{16} & \\frac{135}{16} \\\\\n -\\frac{21}{16} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/8), (113/16)],\n [(39/16), (1/16)],\n [(47/8), (57/16)],\n [(91/16), (5/2)]])\nb = np.array([\n [-(113/16), (151/16)],\n [(3/2), (19/16)],\n [(119/16), (39/8)],\n [-7, -2]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{1}{2}, 3, \\frac{5}{2}}$ to the plane $\\frac{3 x}{2}-\\frac{3 y}{2}+\\frac{9 z}{2}+3=0$.", - "Output Answer": [ - "$\\frac{7}{\\sqrt{11}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (1/2), 3, (5/2)\nplane = Poly(((3*x)/2)-((3*y)/2)+((9*z)/2)+3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{106}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [3]])\nb = np.array([\n [-9],\n [-2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & 1 \\\\\n 5 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+6 x-12$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1],\n [5, -7]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{17}{2} & \\frac{1}{2} & 9 \\\\\n -9 & -\\frac{7}{2} & -4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -5 & -4 & -\\frac{13}{2} \\\\\n -\\frac{19}{2} & \\frac{17}{2} & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{27}{2} & \\frac{9}{2} & \\frac{31}{2} \\\\\n \\frac{1}{2} & -12 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/2), (1/2), 9],\n [-9, -(7/2), -4]])\nb = np.array([\n [-5, -4, -(13/2)],\n [-(19/2), (17/2), -2]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{11}{3} & \\frac{5}{6} & -\\frac{5}{6} \\\\\n -\\frac{14}{3} & -\\frac{19}{6} & -\\frac{3}{2} \\\\\n \\frac{17}{6} & \\frac{13}{3} & -\\frac{11}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{4733}{108}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/3), (5/6), -(5/6)],\n [-(14/3), -(19/6), -(3/2)],\n [(17/6), (13/3), -(11/6)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{3}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 6 & 3 & -2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 10 & 5 & -\\frac{10}{3} & \\frac{10}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 3, -2, 2]])\nprint(a * (5/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 0 \\\\\n -10 \\\\\n -6 \\\\\n 2 \\\\\n 1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 7 \\\\\n 6 \\\\\n -5 \\\\\n 9 \\\\\n 2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [0],\n [-10],\n [-6],\n [2],\n [1],\n [-2]])\nb = np.array([\n [6],\n [7],\n [6],\n [-5],\n [9],\n [2],\n [3]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2]])\nb = np.array([\n [2]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{2} & 2 & \\frac{1}{2} \\\\\n -1 & -\\frac{1}{2} & \\frac{3}{2} \\\\\n \\frac{1}{2} & -1 & -3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{33}{8} & \\frac{5}{2} & -\\frac{35}{4} \\\\\n -\\frac{15}{4} & \\frac{103}{8} & \\frac{55}{4} \\\\\n \\frac{5}{4} & -\\frac{25}{2} & -\\frac{137}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), 2, (1/2)],\n [-1, -(1/2), (3/2)],\n [(1/2), -1, -3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & 2 \\\\\n 3 & -3 \\\\\n 0 & -3 \\\\\n -1 & 1 \\\\\n 3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.3 \\\\\n -0.66 \\\\\n 2.37 \\\\\n 2.34 \\\\\n -1.19 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.817 \\\\\n -0.477 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2],\n [3, -3],\n [0, -3],\n [-1, 1],\n [3, -2]])\nb = np.array([\n [0.3],\n [-0.66],\n [2.37],\n [2.34],\n [-1.19]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -7 & -9 & 5 & -5 & 8 & -3 & 1 \\\\\n -4 & -3 & 2 & 7 & 5 & -10 & 0 \\\\\n 6 & 7 & -4 & 9 & -3 & -8 & -8 \\\\\n 2 & 7 & 6 & 10 & 2 & -3 & 0 \\\\\n 2 & 4 & 8 & -1 & 0 & 10 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & -\\frac{829}{996} & -\\frac{9827}{1992} \\\\\n 0 & 1 & 0 & 0 & 0 & \\frac{34}{83} & \\frac{621}{166} \\\\\n 0 & 0 & 1 & 0 & 0 & \\frac{385}{332} & -\\frac{753}{664} \\\\\n 0 & 0 & 0 & 1 & 0 & -\\frac{373}{498} & -\\frac{971}{996} \\\\\n 0 & 0 & 0 & 0 & 1 & -\\frac{457}{249} & \\frac{29}{249} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, -9, 5, -5, 8, -3, 1],\n [-4, -3, 2, 7, 5, -10, 0],\n [6, 7, -4, 9, -3, -8, -8],\n [2, 7, 6, 10, 2, -3, 0],\n [2, 4, 8, -1, 0, 10, -3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & -5 & -3 \\\\\n -5 & -7 & 3 \\\\\n -10 & 6 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-11.098,-8.698,6.796\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -5, -3],\n [-5, -7, 3],\n [-10, 6, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{10} & \\frac{3}{2} & -\\frac{41}{10} \\\\\n 2 & -\\frac{6}{5} & -\\frac{39}{10} \\\\\n \\frac{1}{2} & \\frac{41}{10} & -\\frac{31}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{9855}{21751} & \\frac{6080}{21751} & \\frac{5385}{21751} \\\\\n -\\frac{2125}{21751} & -\\frac{2110}{21751} & \\frac{5465}{21751} \\\\\n -\\frac{4400}{21751} & -\\frac{1810}{21751} & \\frac{1080}{21751} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/10), (3/2), -(41/10)],\n [2, -(6/5), -(39/10)],\n [(1/2), (41/10), -(31/10)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{327}{100} & \\frac{21}{100} & \\frac{979}{100} & -\\frac{247}{100} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{99}{50} & -\\frac{61}{10} & -\\frac{89}{10} & \\frac{93}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{129}{100} & -\\frac{589}{100} & \\frac{89}{100} & \\frac{5}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(327/100), (21/100), (979/100), -(247/100)]])\nb = np.array([\n [(99/50), -(61/10), -(89/10), (93/25)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -7 & -4 & 6 \\\\\n -6 & 10 & -5 \\\\\n 1 & 1 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-6 x^2+122 x+735$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -4, 6],\n [-6, 10, -5],\n [1, 1, -9]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -1 & 1 \\\\\n -1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{4}{5} & -\\frac{1}{5} \\\\\n \\frac{1}{5} & -\\frac{1}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1],\n [-1, -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{14}{3} \\\\\n 5 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 5 \\\\\n -\\frac{16}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{10}{3} \\\\\n -\\frac{710}{9} \\\\\n -\\frac{205}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(14/3)],\n [5],\n [-6]])\nb = np.array([\n [9],\n [5],\n [-(16/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -2 & 0 & -1 & 3 \\\\\n -1 & 3 & -2 & 2 \\\\\n 2 & -1 & -2 & 1 \\\\\n -3 & -3 & 2 & 0 \\\\\n 1 & 3 & 3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.47 \\\\\n 1.42 \\\\\n 2.28 \\\\\n -0.19 \\\\\n -1.1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.116 \\\\\n -0.278 \\\\\n -0.496 \\\\\n 0.52 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, -1, 3],\n [-1, 3, -2, 2],\n [2, -1, -2, 1],\n [-3, -3, 2, 0],\n [1, 3, 3, 2]])\nb = np.array([\n [1.47],\n [1.42],\n [2.28],\n [-0.19],\n [-1.1]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{13}{10}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 9 \\\\\n 1 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{13}{10} \\\\\n -\\frac{117}{10} \\\\\n -\\frac{13}{10} \\\\\n -\\frac{39}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [9],\n [1],\n [3]])\nprint(a * -(13/10))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -8 & 3 & 4 & 4 & -4 & -5 \\\\\n 4 & -8 & 2 & 2 & -5 & -3 \\\\\n 2 & -8 & -5 & 6 & -1 & -6 \\\\\n 5 & -2 & -3 & -10 & 0 & -9 \\\\\n 2 & 10 & 4 & -6 & 3 & 1 \\\\\n 2 & -8 & -3 & -4 & 4 & 7 \\\\\n -3 & 5 & -6 & 8 & 9 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-8, 3, 4, 4, -4, -5],\n [4, -8, 2, 2, -5, -3],\n [2, -8, -5, 6, -1, -6],\n [5, -2, -3, -10, 0, -9],\n [2, 10, 4, -6, 3, 1],\n [2, -8, -3, -4, 4, 7],\n [-3, 5, -6, 8, 9, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 6 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 7 \\\\\n 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 11 \\\\\n -3 \\\\\n 18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [6],\n [1]])\nb = np.array([\n [-3],\n [7],\n [3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{2} & -2 & \\frac{3}{2} \\\\\n \\frac{3}{2} & -\\frac{1}{2} & \\frac{5}{2} \\\\\n -\\frac{1}{2} & 3 & -2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & \\frac{21}{2} & -\\frac{47}{4} \\\\\n -\\frac{23}{4} & \\frac{19}{4} & -4 \\\\\n \\frac{27}{4} & -\\frac{13}{2} & \\frac{43}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), -2, (3/2)],\n [(3/2), -(1/2), (5/2)],\n [-(1/2), 3, -2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -1 & 3 & 2 & -2 \\\\\n -1 & -1 & -2 & 2 \\\\\n 1 & 2 & 0 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 0 & 0 \\\\\n 2 & 2 \\\\\n -1 & -2 \\\\\n -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 6 & -2 \\\\\n -2 & 6 \\\\\n 3 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, 2, -2],\n [-1, -1, -2, 2],\n [1, 2, 0, 1]])\nb = np.array([\n [0, 0],\n [2, 2],\n [-1, -2],\n [-1, 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -\\frac{37}{5} \\\\\n \\frac{83}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(37/5)],\n [(83/10)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{19}{7},-\\frac{16}{7},\\frac{15}{7}\\right\\}, \\left\\{\\frac{8}{7},\\frac{10}{7},-\\frac{17}{7}\\right\\}, \\left\\{\\frac{20}{7},\\frac{8}{7},\\frac{2}{7}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{19}{\\sqrt{842}},-8 \\sqrt{\\frac{2}{421}},\\frac{15}{\\sqrt{842}}\\right\\}, \\left\\{\\frac{11733}{\\sqrt{262920394}},2106 \\sqrt{\\frac{2}{131460197}},-\\frac{10369}{\\sqrt{262920394}}\\right\\}, \\left\\{\\frac{122}{\\sqrt{312257}},\\frac{443}{\\sqrt{312257}},\\frac{318}{\\sqrt{312257}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack((((19/7), -(16/7), (15/7)), ((8/7), (10/7), -(17/7)), ((20/7), (8/7), (2/7))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & 7 \\\\\n -5 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-i \\sqrt{34},i \\sqrt{34}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 7],\n [-5, -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n 7 & -8 & -8 \\\\\n 2 & -5 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -8, -8],\n [2, -5, 3]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{15}{2} \\\\\n -\\frac{5}{2} \\\\\n 2 \\\\\n \\frac{9}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{19}{2} \\\\\n -10 \\\\\n 6 \\\\\n -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{185}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/2)],\n [-(5/2)],\n [2],\n [(9/2)]])\nb = np.array([\n [(19/2)],\n [-10],\n [6],\n [-(7/2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 0],\n [-1, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 3 & -5 \\\\\n 7 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, -5],\n [7, -8]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0.3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3.6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-1.08$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0.3]])\nb = np.array([\n [-3.6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -7 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 0 \\\\\n -7 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{283}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-7],\n [0],\n [-1]])\nb = np.array([\n [7],\n [0],\n [-7],\n [3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & 9 \\\\\n -6 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(5-i \\sqrt{215}\\right),\\frac{1}{2} \\left(5+i \\sqrt{215}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 9],\n [-6, 3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & -\\frac{19}{4} & \\frac{31}{4} \\\\\n \\frac{13}{4} & 2 & -\\frac{29}{4} \\\\\n -\\frac{39}{4} & 10 & \\frac{19}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{5.199,4.987,1.\\}, \\{-0.337-0.68 i,-0.313+0.592 i,1.\\}, \\{-0.337+0.68 i,-0.313-0.592 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -(19/4), (31/4)],\n [(13/4), 2, -(29/4)],\n [-(39/4), 10, (19/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 7 & 7 \\\\\n -2 & 8 \\\\\n 10 & 10 \\\\\n -6 & -1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -6 & 6 \\\\\n -6 & 1 \\\\\n 1 & 9 \\\\\n -10 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 13 & 1 \\\\\n 4 & 7 \\\\\n 9 & 1 \\\\\n 4 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 7],\n [-2, 8],\n [10, 10],\n [-6, -1]])\nb = np.array([\n [-6, 6],\n [-6, 1],\n [1, 9],\n [-10, -2]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -\\frac{15}{4} & \\frac{21}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/4), (21/4)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{41}{16} \\\\\n \\frac{157}{16} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{77}{16} \\\\\n \\frac{11}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{59}{8} \\\\\n \\frac{73}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(41/16)],\n [(157/16)]])\nb = np.array([\n [-(77/16)],\n [(11/16)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 4 & -7 & -4 \\\\\n \\frac{13}{2} & -\\frac{15}{2} & 8 \\\\\n 7 & \\frac{7}{2} & \\frac{3}{2} \\\\\n -5 & -\\frac{15}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{15}{2} & 7 & -\\frac{17}{2} \\\\\n \\frac{13}{2} & 6 & -\\frac{3}{2} \\\\\n -\\frac{9}{2} & -\\frac{13}{2} & -\\frac{3}{2} \\\\\n -\\frac{7}{2} & 9 & -\\frac{19}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{2} & 0 & -\\frac{25}{2} \\\\\n 13 & -\\frac{3}{2} & \\frac{13}{2} \\\\\n \\frac{5}{2} & -3 & 0 \\\\\n -\\frac{17}{2} & \\frac{3}{2} & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -7, -4],\n [(13/2), -(15/2), 8],\n [7, (7/2), (3/2)],\n [-5, -(15/2), (5/2)]])\nb = np.array([\n [-(15/2), 7, -(17/2)],\n [(13/2), 6, -(3/2)],\n [-(9/2), -(13/2), -(3/2)],\n [-(7/2), 9, -(19/2)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{73}{8} & \\frac{33}{8} & \\frac{7}{2} & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{19}{4} & -\\frac{15}{2} & \\frac{25}{8} & -\\frac{11}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{111}{8} & -\\frac{27}{8} & \\frac{53}{8} & \\frac{7}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(73/8), (33/8), (7/2), (9/2)]])\nb = np.array([\n [(19/4), -(15/2), (25/8), -(11/4)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{2}{3}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & -3 & -10 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{2}{3} & -2 & -\\frac{20}{3} & -\\frac{20}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -3, -10, -10]])\nprint(a * (2/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2 & -3 & 0 \\\\\n 1 & -2 & -2 \\\\\n 0 & 2 & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 10 & -15 & -24 \\\\\n 5 & 26 & 6 \\\\\n -8 & -6 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, 0],\n [1, -2, -2],\n [0, 2, 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & 2 & -2 \\\\\n -1 & -3 & 4 \\\\\n 1 & -4 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-76$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2, -2],\n [-1, -3, 4],\n [1, -4, -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}+\\tan ^{-1}\\left(\\frac{9}{11}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2)],\n [5]]).squeeze()\nb = np.array([\n [2],\n [-2]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{2,-2,3\\}, \\{-1,-5,2\\}, \\{3,1,1\\}}$.", - "Output Answer": [ - "$9 x-7 y-6 z-14=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, -2, 3],\n [-1, -5, 2],\n [3, 1, 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -3 & -3 & -1 & 0 & 0 \\\\\n -1 & -3 & -3 & 1 & -2 \\\\\n 3 & 0 & -1 & 2 & -1 \\\\\n 1 & -1 & -2 & -3 & -2 \\\\\n 3 & 1 & -3 & 3 & 1 \\\\\n -1 & 3 & -1 & 2 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.03 \\\\\n -0.74 \\\\\n 0.47 \\\\\n 2.64 \\\\\n 0.88 \\\\\n -0.28 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.588 \\\\\n -0.349 \\\\\n -0.397 \\\\\n -0.733 \\\\\n 0.73 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3, -1, 0, 0],\n [-1, -3, -3, 1, -2],\n [3, 0, -1, 2, -1],\n [1, -1, -2, -3, -2],\n [3, 1, -3, 3, 1],\n [-1, 3, -1, 2, 3]])\nb = np.array([\n [-0.03],\n [-0.74],\n [0.47],\n [2.64],\n [0.88],\n [-0.28]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & -4 \\\\\n 4 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$32$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -4],\n [4, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{33}{4} & -8 & -\\frac{13}{4} \\\\\n -\\frac{17}{2} & \\frac{5}{2} & \\frac{13}{2} \\\\\n -\\frac{11}{4} & 9 & -\\frac{29}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-12.851,-10.858,10.71\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(33/4), -8, -(13/4)],\n [-(17/2), (5/2), (13/2)],\n [-(11/4), 9, -(29/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -9 \\\\\n 7 \\\\\n -3 \\\\\n -4 \\\\\n 2 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{241}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-9],\n [7],\n [-3],\n [-4],\n [2],\n [9]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1.3 \\\\\n -8.2 \\\\\n -3.8 \\\\\n 8. \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -0.2 \\\\\n 6.2 \\\\\n -8.5 \\\\\n 5. \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$21.72$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1.3],\n [-8.2],\n [-3.8],\n [8.]])\nb = np.array([\n [-0.2],\n [6.2],\n [-8.5],\n [5.]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n -2 & 14 & -3 & 34 \\\\\n -4 & 22 & -5 & 54 \\\\\n 5 & -51 & 12 & -126 \\\\\n 2 & -13 & 3 & -32 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{1}{2} & \\frac{19}{2} & -2 & 23 \\\\\n -\\frac{17}{6} & \\frac{33}{2} & -\\frac{11}{3} & \\frac{115}{3} \\\\\n \\frac{19}{3} & -67 & \\frac{50}{3} & -\\frac{496}{3} \\\\\n \\frac{5}{3} & -12 & \\frac{17}{6} & -\\frac{86}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [-2, 14, -3, 34],\n [-4, 22, -5, 54],\n [5, -51, 12, -126],\n [2, -13, 3, -32]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1.7 \\\\\n -8.1 \\\\\n 8.6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8.6 \\\\\n 9.9 \\\\\n 1.1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-85.35$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1.7],\n [-8.1],\n [8.6]])\nb = np.array([\n [-8.6],\n [9.9],\n [1.1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 7 & -2 \\\\\n 6 & 6 \\\\\n 7 & -6 \\\\\n -2 & -4 \\\\\n -3 & -10 \\\\\n 7 & 9 \\\\\n 10 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, -2],\n [6, 6],\n [7, -6],\n [-2, -4],\n [-3, -10],\n [7, 9],\n [10, -10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 5 & 4 \\\\\n -10 & 6 \\\\\n 2 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, 4],\n [-10, 6],\n [2, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 0 & 9 & -5 \\\\\n -7 & 6 & 6 \\\\\n -1 & -6 & -3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 3 & -8 & -7 \\\\\n 3 & -9 & 8 \\\\\n 7 & 6 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -3 & 17 & 2 \\\\\n -10 & 15 & -2 \\\\\n -8 & -12 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 9, -5],\n [-7, 6, 6],\n [-1, -6, -3]])\nb = np.array([\n [3, -8, -7],\n [3, -9, 8],\n [7, 6, -6]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{57}{10} & -\\frac{38}{5} \\\\\n \\frac{17}{10} & \\frac{61}{10} \\\\\n \\frac{4}{5} & \\frac{21}{10} \\\\\n -\\frac{26}{5} & -\\frac{1}{5} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -2 & -\\frac{11}{2} \\\\\n -\\frac{11}{10} & -\\frac{9}{10} \\\\\n \\frac{9}{5} & -\\frac{69}{10} \\\\\n -\\frac{59}{10} & \\frac{33}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{77}{10} & -\\frac{21}{10} \\\\\n \\frac{14}{5} & 7 \\\\\n -1 & 9 \\\\\n \\frac{7}{10} & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(57/10), -(38/5)],\n [(17/10), (61/10)],\n [(4/5), (21/10)],\n [-(26/5), -(1/5)]])\nb = np.array([\n [-2, -(11/2)],\n [-(11/10), -(9/10)],\n [(9/5), -(69/10)],\n [-(59/10), (33/10)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -5 \\\\\n -\\frac{32}{5} \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -\\frac{14}{5} \\\\\n -\\frac{49}{5} \\\\\n \\frac{4}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{1913}{2 \\sqrt{1499703}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-5],\n [-(32/5)],\n [-4]]).squeeze()\nb = np.array([\n [-1],\n [-(14/5)],\n [-(49/5)],\n [(4/5)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{4,4,-2\\}, \\{-5,2,-1\\}, \\{4,2,-3\\}}$.", - "Output Answer": [ - "$4 x-9 y+18 z+56=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, 4, -2],\n [-5, 2, -1],\n [4, 2, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{33}{5} & -\\frac{957}{100} & -\\frac{9}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{163}{100} & \\frac{53}{25} & -\\frac{157}{20} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{497}{100} & -\\frac{1169}{100} & \\frac{28}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(33/5), -(957/100), -(9/4)]])\nb = np.array([\n [(163/100), (53/25), -(157/20)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 0 & -10 & -5 & -9 \\\\\n -5 & 1 & 1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & -\\frac{1}{10} & \\frac{9}{50} \\\\\n 0 & 1 & \\frac{1}{2} & \\frac{9}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, -10, -5, -9],\n [-5, 1, 1, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 1 & 2 & 0 & 0 \\\\\n -3 & 2 & 0 & 2 \\\\\n -1 & 0 & 3 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -1 & 1 & 1 \\\\\n 3 & -3 & 0 \\\\\n 1 & 1 & -2 \\\\\n 1 & 3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 5 & -5 & 1 \\\\\n 11 & -3 & -1 \\\\\n 3 & -1 & -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, 0, 0],\n [-3, 2, 0, 2],\n [-1, 0, 3, -1]])\nb = np.array([\n [-1, 1, 1],\n [3, -3, 0],\n [1, 1, -2],\n [1, 3, 1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 9 & -3 & 1 \\\\\n -1 & 8 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{7.,44.,69.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, -3, 1],\n [-1, 8, -5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{2}{5}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [-1],\n [1],\n [-1],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [1],\n [0],\n [-1],\n [1],\n [1],\n [-1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 0 & -6 & -2 \\\\\n 1 & 3 & 7 \\\\\n 8 & -9 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.322,-0.967,1.\\}, \\{0.414\\, -0.308 i,-0.014+0.78 i,1.\\}, \\{0.414\\, +0.308 i,-0.014-0.78 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -6, -2],\n [1, 3, 7],\n [8, -9, -1]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{3,\\frac{3}{2},-\\frac{5}{2}\\right\\}, \\left\\{-\\frac{7}{2},2,5\\right\\}, \\left\\{1,1,\\frac{7}{2}\\right\\}}$.", - "Output Answer": [ - "$54 x+192 y+34 z-365=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, (3/2), -(5/2)],\n [-(7/2), 2, 5],\n [1, 1, (7/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n -1 \\\\\n 0 \\\\\n 3 \\\\\n 3 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 2 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{9},-\\frac{2}{9},-\\frac{1}{9},-\\frac{1}{9},-\\frac{1}{9},-\\frac{1}{9}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-2],\n [-1],\n [0],\n [3],\n [3]]).squeeze()\nb = np.array([\n [-1],\n [2],\n [1],\n [1],\n [1],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(\\sqrt{35}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [0],\n [0],\n [-1],\n [0],\n [-1],\n [1],\n [0],\n [1]]).squeeze()\nb = np.array([\n [1],\n [1],\n [0],\n [-1],\n [0],\n [1],\n [0],\n [-1],\n [-1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -2 \\\\\n -3 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{5}} \\\\\n -\\frac{1}{\\sqrt{5}} \\\\\n -\\frac{3}{2 \\sqrt{5}} \\\\\n -\\frac{1}{2 \\sqrt{5}} \\\\\n \\frac{1}{2 \\sqrt{5}} \\\\\n \\frac{1}{2 \\sqrt{5}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-2],\n [-3],\n [-1],\n [1],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -1 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -8 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 53 \\\\\n 15 \\\\\n -77 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-1],\n [6]])\nb = np.array([\n [-5],\n [-8],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -9 & 2 \\\\\n -1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-5-\\sqrt{14},\\sqrt{14}-5\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 2],\n [-1, -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{3} \\\\\n -\\frac{1}{6} \\\\\n \\frac{1}{2} \\\\\n -\\frac{5}{3} \\\\\n \\frac{1}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{13}{6} & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{13}{18} & \\frac{1}{3} \\\\\n \\frac{13}{36} & \\frac{1}{6} \\\\\n -\\frac{13}{12} & -\\frac{1}{2} \\\\\n \\frac{65}{18} & \\frac{5}{3} \\\\\n -\\frac{13}{18} & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/3)],\n [-(1/6)],\n [(1/2)],\n [-(5/3)],\n [(1/3)]])\nb = np.array([\n [-(13/6), -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 2 & -4 & -6 & 10 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-5.,0.,0.,1.,0.\\}, \\{-2.,0.,0.,0.,1.\\}, \\{2.,1.,0.,0.,0.\\}, \\{3.,0.,1.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, -4, -6, 10, 4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -5 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -7 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 49 \\\\\n -43 \\\\\n 64 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-5],\n [2]])\nb = np.array([\n [3],\n [-7],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & 1 & -1 \\\\\n -2 & 3 & 0 \\\\\n -1 & -2 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$13$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1, -1],\n [-2, 3, 0],\n [-1, -2, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{13}{3} & \\frac{1}{3} \\\\\n -\\frac{17}{3} & \\frac{20}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{6} \\left(33-i \\sqrt{19}\\right),\\frac{1}{6} \\left(33+i \\sqrt{19}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/3), (1/3)],\n [-(17/3), (20/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & \\frac{1}{2} \\\\\n -\\frac{17}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{-\\frac{1}{17}-\\frac{4 i}{17},1\\right\\}, \\left\\{-\\frac{1}{17}+\\frac{4 i}{17},1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), (1/2)],\n [-(17/2), -(1/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -14 \\log (2) \\\\\n -12 \\log (2) \\\\\n 13 \\log (2) \\\\\n -13 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -11 \\log (2) \\\\\n 11 \\log (2) \\\\\n -7 \\log (2) \\\\\n 11 \\log (2) \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-212 \\log ^2(2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-14*math.log(2)],\n [-12*math.log(2)],\n [13*math.log(2)],\n [-13*math.log(2)]])\nb = np.array([\n [-11*math.log(2)],\n [11*math.log(2)],\n [-7*math.log(2)],\n [11*math.log(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [0],\n [1],\n [-1],\n [0],\n [-1],\n [1],\n [1],\n [0]]).squeeze()\nb = np.array([\n [1],\n [0],\n [0],\n [1],\n [1],\n [1],\n [0],\n [-1],\n [1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 3 & 3 & 1 & -1 & 0 \\\\\n 3 & -3 & 3 & 2 & -3 \\\\\n -2 & -2 & -3 & 0 & -3 \\\\\n -1 & -2 & -1 & 3 & 2 \\\\\n 0 & 0 & -1 & 3 & -3 \\\\\n 1 & -1 & -1 & -2 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.62 \\\\\n -2.55 \\\\\n -2.26 \\\\\n 1.83 \\\\\n 2.63 \\\\\n -1.54 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.566 \\\\\n 0.599 \\\\\n 0.11 \\\\\n 0.883 \\\\\n 0.332 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3, 1, -1, 0],\n [3, -3, 3, 2, -3],\n [-2, -2, -3, 0, -3],\n [-1, -2, -1, 3, 2],\n [0, 0, -1, 3, -3],\n [1, -1, -1, -2, 2]])\nb = np.array([\n [-1.62],\n [-2.55],\n [-2.26],\n [1.83],\n [2.63],\n [-1.54]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{31}{9} & \\frac{8}{9} \\\\\n 5 & \\frac{50}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{19 x}{9}-\\frac{1910}{81}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(31/9), (8/9)],\n [5, (50/9)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2 & -3 & -2 \\\\\n 3 & 2 & \\frac{1}{2} \\\\\n -\\frac{5}{2} & -1 & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 2 & \\frac{9}{2} \\\\\n -\\frac{5}{4} & -\\frac{11}{2} & -\\frac{11}{2} \\\\\n \\frac{9}{2} & \\frac{13}{2} & \\frac{11}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, -2],\n [3, 2, (1/2)],\n [-(5/2), -1, -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{20}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 8 & -3 & 1 & 2 \\\\\n -8 & -3 & 10 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{6}{5} & -\\frac{9}{20} & \\frac{3}{20} & \\frac{3}{10} \\\\\n -\\frac{6}{5} & -\\frac{9}{20} & \\frac{3}{2} & \\frac{21}{20} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -3, 1, 2],\n [-8, -3, 10, 7]])\nprint(a * (3/20))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 8 \\\\\n -6 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [8],\n [-6],\n [3]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 4 & -1 & 3 & 5 & 0 \\\\\n 6 & -7 & -2 & -2 & -9 \\\\\n 9 & -8 & -2 & -3 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & -\\frac{27}{43} & \\frac{418}{43} \\\\\n 0 & 1 & 0 & -\\frac{38}{43} & \\frac{523}{43} \\\\\n 0 & 0 & 1 & \\frac{95}{43} & -\\frac{383}{43} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, -1, 3, 5, 0],\n [6, -7, -2, -2, -9],\n [9, -8, -2, -3, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & 2 & -2 \\\\\n -3 & -2 & -3 \\\\\n 3 & -2 & 1 \\\\\n -2 & 2 & -3 \\\\\n 0 & -1 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.98 \\\\\n 0.06 \\\\\n -2.39 \\\\\n 1.24 \\\\\n -1.82 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.427 \\\\\n 0.642 \\\\\n 0.093 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2, -2],\n [-3, -2, -3],\n [3, -2, 1],\n [-2, 2, -3],\n [0, -1, 0]])\nb = np.array([\n [1.98],\n [0.06],\n [-2.39],\n [1.24],\n [-1.82]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 9 & -3 & -6 & 10 & -8 & 4 & 0 \\\\\n -10 & -1 & -9 & -9 & 8 & 3 & -9 \\\\\n -4 & -10 & 3 & 10 & 3 & 0 & -9 \\\\\n 8 & -5 & 9 & -1 & -4 & 5 & 0 \\\\\n -9 & 4 & 8 & 9 & 8 & -6 & 8 \\\\\n 5 & -8 & 3 & 3 & 6 & 4 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & \\frac{2706647}{1904142} \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & \\frac{2114939}{1904142} \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & \\frac{40491}{317357} \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & \\frac{620539}{1904142} \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & \\frac{1317412}{952071} \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & -\\frac{70172}{317357} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, -3, -6, 10, -8, 4, 0],\n [-10, -1, -9, -9, 8, 3, -9],\n [-4, -10, 3, 10, 3, 0, -9],\n [8, -5, 9, -1, -4, 5, 0],\n [-9, 4, 8, 9, 8, -6, 8],\n [5, -8, 3, 3, 6, 4, 7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 10 & 7 & 8 & 5 & 6 & -2 & 10 \\\\\n 2 & -9 & 10 & -5 & 9 & -10 & -5 \\\\\n 6 & 5 & 0 & -1 & -4 & -1 & -6 \\\\\n 1 & 10 & 3 & 4 & -5 & -4 & 2 \\\\\n 0 & 4 & -10 & 5 & -10 & 7 & -7 \\\\\n -2 & 8 & -5 & -10 & 4 & -8 & 7 \\\\\n -8 & -5 & -6 & 9 & 1 & 6 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, 7, 8, 5, 6, -2, 10],\n [2, -9, 10, -5, 9, -10, -5],\n [6, 5, 0, -1, -4, -1, -6],\n [1, 10, 3, 4, -5, -4, 2],\n [0, 4, -10, 5, -10, 7, -7],\n [-2, 8, -5, -10, 4, -8, 7],\n [-8, -5, -6, 9, 1, 6, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,-1,-1\\}, \\{-4,5,-3\\}, \\{-3,3,-1\\}}$.", - "Output Answer": [ - "$2 x+2 y+z+1=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -1, -1],\n [-4, 5, -3],\n [-3, 3, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{14}{5} & \\frac{22}{5} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{14}{5} & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & -\\frac{18}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/5), (22/5)]])\nb = np.array([\n [(14/5), 8]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n 6 & 3 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 3, 9]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,1,4\\}, \\{0,-2,5\\}, \\{4,-5,5\\}}$.", - "Output Answer": [ - "$3 x+4 y+15 z-67=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, 1, 4],\n [0, -2, 5],\n [4, -5, 5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2}+2 i & \\frac{7}{2}-i \\\\\n -\\frac{1}{2}-4 i & \\frac{9}{2}-\\frac{i}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{19}{2}-\\frac{31 i}{2} & \\frac{31}{2}+\\frac{5 i}{4} \\\\\n 4-\\frac{67 i}{4} & \\frac{57}{4}-18 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2)+2j, (7/2)- 1j],\n [-(1/2)-4j, (9/2)-(1j/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{2}{5} & \\frac{23}{5} & \\frac{7}{5} \\\\\n \\frac{3}{5} & -\\frac{13}{5} & \\frac{7}{5} \\\\\n -1 & \\frac{16}{5} & -\\frac{7}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{399}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/5), (23/5), (7/5)],\n [(3/5), -(13/5), (7/5)],\n [-1, (16/5), -(7/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 1 & -5 & -6 & -1 & 0 \\\\\n 10 & 6 & -4 & -1 & -2 \\\\\n -3 & 4 & -7 & -10 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-475.,503.,-629.,784.,0.\\}, \\{-193.,277.,-263.,0.,392.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [1, -5, -6, -1, 0],\n [10, 6, -4, -1, -2],\n [-3, 4, -7, -10, -9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 6 \\\\\n -9 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [6],\n [-9],\n [-3]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & 1 & 3 \\\\\n -3 & 0 & 3 \\\\\n 3 & -1 & 2 \\\\\n -1 & 0 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.94 \\\\\n 2.63 \\\\\n 0.29 \\\\\n -1.96 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.134 \\\\\n 0.825 \\\\\n 0.734 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1, 3],\n [-3, 0, 3],\n [3, -1, 2],\n [-1, 0, -3]])\nb = np.array([\n [2.94],\n [2.63],\n [0.29],\n [-1.96]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{2,\\frac{2}{3},-\\frac{11}{3}\\right\\}, \\left\\{-3,-\\frac{1}{3},-\\frac{5}{3}\\right\\}, \\left\\{\\frac{1}{3},\\frac{10}{3},-\\frac{1}{3}\\right\\}}$.", - "Output Answer": [ - "$78 x-120 y+135 z+419=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, (2/3), -(11/3)],\n [-3, -(1/3), -(5/3)],\n [(1/3), (10/3), -(1/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & -\\frac{5}{2} \\\\\n \\frac{7}{2} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{11 x}{2}+\\frac{59}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -(5/2)],\n [(7/2), (3/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 \\\\\n 0 \\\\\n -3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{3}{\\sqrt{22}} \\\\\n 0 \\\\\n -\\frac{3}{\\sqrt{22}} \\\\\n -\\sqrt{\\frac{2}{11}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [3],\n [0],\n [-3],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{47}{10} & -\\frac{49}{10} \\\\\n -\\frac{11}{10} & -\\frac{21}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{112}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(47/10), -(49/10)],\n [-(11/10), -(21/10)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -2 & \\frac{13}{6} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{14}{3} & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{20}{3} & \\frac{14}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, (13/6)]])\nb = np.array([\n [(14/3), -(5/2)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{14}{3} & \\frac{1}{6} & 3 \\\\\n -1 & \\frac{5}{2} & \\frac{11}{3} \\\\\n -\\frac{7}{6} & \\frac{5}{6} & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{7727}{108}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(14/3), (1/6), 3],\n [-1, (5/2), (11/3)],\n [-(7/6), (5/6), -(9/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\pi \\\\\n 2 \\pi \\\\\n -\\pi \\\\\n 3 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\pi \\\\\n 2 \\pi \\\\\n 3 \\pi \\\\\n 0 \\\\\n -2 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4 \\sqrt{2} \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [math.pi],\n [2*math.pi],\n [-math.pi],\n [3*math.pi]])\nb = np.array([\n [-2*math.pi],\n [2*math.pi],\n [3*math.pi],\n [0],\n [-2*math.pi]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & 3 & -3 & 0 \\\\\n -1 & 2 & 2 & 3 \\\\\n 1 & 2 & 0 & 3 \\\\\n 2 & 0 & -3 & -1 \\\\\n 2 & 3 & 2 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.89 \\\\\n 0.81 \\\\\n 1.56 \\\\\n 2.53 \\\\\n -0.33 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.824 \\\\\n -0.429 \\\\\n -0.324 \\\\\n 0.752 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 3, -3, 0],\n [-1, 2, 2, 3],\n [1, 2, 0, 3],\n [2, 0, -3, -1],\n [2, 3, 2, 0]])\nb = np.array([\n [-2.89],\n [0.81],\n [1.56],\n [2.53],\n [-0.33]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-5, -1, -5}$ to the plane $-3 x-2 y-2 z+5=0$.", - "Output Answer": [ - "$\\frac{32}{\\sqrt{17}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -5, -1, -5\nplane = Poly(-3*x-2*y-2*z+5, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & 5 \\\\\n 3 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-5$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 5],\n [3, -5]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 10 & 4 & -9 & 7 \\\\\n 2 & 3 & 5 & 4 \\\\\n -7 & 4 & 2 & 3 \\\\\n -1 & -3 & -3 & 1 \\\\\n 6 & -1 & 3 & 8 \\\\\n 5 & -4 & 5 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, 4, -9, 7],\n [2, 3, 5, 4],\n [-7, 4, 2, 3],\n [-1, -3, -3, 1],\n [6, -1, 3, 8],\n [5, -4, 5, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -8 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -2 \\\\\n -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 54 \\\\\n -3 \\\\\n -80 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-8],\n [3]])\nb = np.array([\n [-9],\n [-2],\n [-6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 4 & -3 \\\\\n -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{2}{5} & \\frac{3}{5} \\\\\n \\frac{1}{5} & \\frac{4}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -3],\n [-1, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & -7 & 4 \\\\\n 5 & 7 & 2 \\\\\n 4 & -7 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-3.439,5.72\\, -6.68 i,5.72\\, +6.68 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -7, 4],\n [5, 7, 2],\n [4, -7, 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -8 \\\\\n -9 \\\\\n -2 \\\\\n 3 \\\\\n 8 \\\\\n -9 \\\\\n 9 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 2 \\\\\n 0 \\\\\n 5 \\\\\n 1 \\\\\n -9 \\\\\n -7 \\\\\n 6 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{597}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-8],\n [-9],\n [-2],\n [3],\n [8],\n [-9],\n [9],\n [6]])\nb = np.array([\n [5],\n [2],\n [0],\n [5],\n [1],\n [-9],\n [-7],\n [6],\n [1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{8}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -5 & 9 \\\\\n 6 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{5}{8} & -\\frac{9}{8} \\\\\n -\\frac{3}{4} & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 9],\n [6, -8]])\nprint(a * -(1/8))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{10}{3} \\\\\n -\\frac{8}{3} \\\\\n 3 \\\\\n -\\frac{7}{3} \\\\\n \\frac{20}{3} \\\\\n 8 \\\\\n 5 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{3} \\\\\n -\\frac{28}{3} \\\\\n -\\frac{20}{3} \\\\\n 2 \\\\\n -\\frac{1}{3} \\\\\n 7 \\\\\n 10 \\\\\n -\\frac{10}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{776}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(10/3)],\n [-(8/3)],\n [3],\n [-(7/3)],\n [(20/3)],\n [8],\n [5],\n [-1]])\nb = np.array([\n [-(19/3)],\n [-(28/3)],\n [-(20/3)],\n [2],\n [-(1/3)],\n [7],\n [10],\n [-(10/3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{36}{5} \\\\\n -\\frac{41}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{12}{5} \\\\\n -\\frac{33}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{48}{5} \\\\\n -\\frac{23}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(36/5)],\n [-(41/5)]])\nb = np.array([\n [-(12/5)],\n [-(33/10)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{11}{4}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 8 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 22 \\\\\n -22 \\\\\n -\\frac{55}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [8],\n [5]])\nprint(a * -(11/4))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-2,-\\frac{5}{3},-2\\right\\}, \\left\\{5,-\\frac{4}{3},-3\\right\\}, \\left\\{-\\frac{11}{3},1,3\\right\\}}$.", - "Output Answer": [ - "$39 x-300 y+173 z-76=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, -(5/3), -2],\n [5, -(4/3), -3],\n [-(11/3), 1, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 3 & 4 & -5 & 2 \\\\\n 3 & 10 & -10 & -6 \\\\\n -6 & 2 & -5 & -9 \\\\\n 4 & -1 & -2 & 5 \\\\\n 5 & 0 & 9 & -3 \\\\\n 0 & 8 & 7 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, 4, -5, 2],\n [3, 10, -10, -6],\n [-6, 2, -5, -9],\n [4, -1, -2, 5],\n [5, 0, 9, -3],\n [0, 8, 7, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -7 & -2 & 2 \\\\\n 1 & -7 & -7 \\\\\n 10 & 4 & -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -8 & 8 & 4 \\\\\n 2 & 3 & 4 \\\\\n 3 & 10 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -15 & 6 & 6 \\\\\n 3 & -4 & -3 \\\\\n 13 & 14 & -15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -2, 2],\n [1, -7, -7],\n [10, 4, -6]])\nb = np.array([\n [-8, 8, 4],\n [2, 3, 4],\n [3, 10, -9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -5 & 2 & -9 & -4 & 5 & -9 \\\\\n 7 & -1 & 0 & 1 & -4 & -8 \\\\\n 5 & 1 & 1 & -2 & -6 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & -\\frac{11}{117} & -\\frac{31}{39} & -\\frac{178}{117} \\\\\n 0 & 1 & 0 & -\\frac{194}{117} & -\\frac{61}{39} & -\\frac{310}{117} \\\\\n 0 & 0 & 1 & \\frac{5}{39} & -\\frac{6}{13} & \\frac{49}{39} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, 2, -9, -4, 5, -9],\n [7, -1, 0, 1, -4, -8],\n [5, 1, 1, -2, -6, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -8 & 3 & 2 & -2 & -5 & -6 \\\\\n -5 & -4 & 9 & 7 & 3 & -3 \\\\\n -2 & -7 & -3 & -2 & 5 & 7 \\\\\n -5 & 5 & -8 & -6 & 2 & 3 \\\\\n -9 & -8 & -2 & 7 & -4 & 2 \\\\\n 5 & -4 & -1 & -4 & 7 & 0 \\\\\n 6 & -3 & 6 & -4 & -2 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-8, 3, 2, -2, -5, -6],\n [-5, -4, 9, 7, 3, -3],\n [-2, -7, -3, -2, 5, 7],\n [-5, 5, -8, -6, 2, 3],\n [-9, -8, -2, 7, -4, 2],\n [5, -4, -1, -4, 7, 0],\n [6, -3, 6, -4, -2, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 3 & 1 & 8 \\\\\n 9 & 3 & 5 \\\\\n -8 & 5 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{1.831\\, -6.591 i,1.831\\, +6.591 i,9.337\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1, 8],\n [9, 3, 5],\n [-8, 5, 7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{11}{3} & \\frac{14}{3} \\\\\n \\frac{4}{3} & \\frac{10}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{15}{83} & \\frac{21}{83} \\\\\n \\frac{6}{83} & \\frac{33}{166} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/3), (14/3)],\n [(4/3), (10/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -6 & 4 & -8 \\\\\n 8 & -1 & -1 \\\\\n 5 & 7 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-13 x^2-63 x-394$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 4, -8],\n [8, -1, -1],\n [5, 7, -6]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -5 \\\\\n -7 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -8 \\\\\n 9 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-61$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-5],\n [-7],\n [-7]])\nb = np.array([\n [-4],\n [-8],\n [9],\n [2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & -4 & 8 \\\\\n -5 & -7 & -2 \\\\\n 7 & -6 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8.43-1.782 i,-8.43+1.782 i,9.86\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -4, 8],\n [-5, -7, -2],\n [7, -6, -2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 8 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 9 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -50 \\\\\n 14 \\\\\n 144 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [8],\n [2]])\nb = np.array([\n [-9],\n [9],\n [-4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -\\frac{25}{9} \\\\\n \\frac{19}{9} \\\\\n -\\frac{76}{9} \\\\\n -\\frac{11}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{2 \\sqrt{3361}}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-(25/9)],\n [(19/9)],\n [-(76/9)],\n [-(11/9)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -6 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -\\frac{15}{2} \\\\\n \\frac{15}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{75}{2} \\\\\n \\frac{63}{2} \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-6],\n [1]])\nb = np.array([\n [-6],\n [-(15/2)],\n [(15/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{42}{5} \\\\\n -3 \\\\\n \\frac{48}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{5} \\\\\n -\\frac{6}{5} \\\\\n -\\frac{2}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{318}{25} \\\\\n -\\frac{1308}{25} \\\\\n -\\frac{687}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(42/5)],\n [-3],\n [(48/5)]])\nb = np.array([\n [-(29/5)],\n [-(6/5)],\n [-(2/5)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{43}{9} \\\\\n \\frac{68}{9} \\\\\n -\\frac{41}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{9} \\\\\n -\\frac{65}{9} \\\\\n \\frac{86}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1061}{27} \\\\\n -\\frac{1178}{27} \\\\\n -\\frac{841}{27} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(43/9)],\n [(68/9)],\n [-(41/9)]])\nb = np.array([\n [-(4/9)],\n [-(65/9)],\n [(86/9)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 6 & 2 & 7 & 0 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-7.,0.,6.,0.,0.\\}, \\{-1.,3.,0.,0.,0.\\}, \\{0.,0.,0.,1.,0.\\}, \\{1.,0.,0.,0.,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [6, 2, 7, 0, -6]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,-5,1\\}, \\{-3,4,-2\\}, \\{-5,-4,-4\\}}$.", - "Output Answer": [ - "$21 x-2 y-13 z+45=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, -5, 1],\n [-3, 4, -2],\n [-5, -4, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 0 \\\\\n -6 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -4 \\\\\n -5 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{19}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [0],\n [-6],\n [-7]])\nb = np.array([\n [-3],\n [-4],\n [-5],\n [-8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & -1 \\\\\n 1 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{2} \\left(9-\\sqrt{77}\\right),1\\right\\}, \\left\\{\\frac{1}{2} \\left(9+\\sqrt{77}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1],\n [1, -6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{7}{3},\\frac{1}{3},3\\right\\}, \\left\\{-\\frac{4}{3},\\frac{4}{3},-\\frac{2}{3}\\right\\}, \\left\\{\\frac{4}{3},0,\\frac{14}{3}\\right\\}}$.", - "Output Answer": [ - "$3 x-102 y-27 z+122=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(7/3), (1/3), 3],\n [-(4/3), (4/3), -(2/3)],\n [(4/3), 0, (14/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & -\\frac{1}{2} & 0 \\\\\n \\frac{3}{2} & -2 & 1 \\\\\n -3 & -2 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{119}{8} & -\\frac{5}{4} & \\frac{1}{2} \\\\\n \\frac{27}{4} & \\frac{45}{8} & \\frac{13}{2} \\\\\n -3 & -\\frac{29}{2} & \\frac{65}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), -(1/2), 0],\n [(3/2), -2, 1],\n [-3, -2, -(3/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{21}{4} \\\\\n \\frac{13}{8} \\\\\n -\\frac{31}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{4} \\\\\n -\\frac{77}{8} \\\\\n \\frac{51}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{431}{16} \\\\\n 48 \\\\\n \\frac{453}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(21/4)],\n [(13/8)],\n [-(31/8)]])\nb = np.array([\n [-(15/4)],\n [-(77/8)],\n [(51/8)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -2 & -3 & -2 & -1 \\\\\n -2 & 0 & -2 & -2 \\\\\n 2 & 0 & 1 & 2 \\\\\n -1 & -3 & -1 & -3 \\\\\n 0 & -2 & 0 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 0 & 3 & -2 & 1 \\\\\n -1 & -1 & -2 & 1 \\\\\n 1 & 3 & 3 & -2 \\\\\n 3 & -3 & 2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -2 & -6 & 2 & 1 \\\\\n -8 & -6 & -6 & 6 \\\\\n 7 & 3 & 3 & -4 \\\\\n -7 & 6 & -1 & 4 \\\\\n -4 & 8 & 0 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, -2, -1],\n [-2, 0, -2, -2],\n [2, 0, 1, 2],\n [-1, -3, -1, -3],\n [0, -2, 0, -2]])\nb = np.array([\n [0, 3, -2, 1],\n [-1, -1, -2, 1],\n [1, 3, 3, -2],\n [3, -3, 2, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & \\frac{5}{3} \\\\\n \\frac{11}{3} & -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{127}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, (5/3)],\n [(11/3), -(8/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 6 \\\\\n 9 \\\\\n 5 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [6],\n [9],\n [5],\n [4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n -2 \\\\\n -3 \\\\\n 2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{2 \\sqrt{5}} \\\\\n -\\frac{1}{2 \\sqrt{5}} \\\\\n -\\frac{1}{\\sqrt{5}} \\\\\n -\\frac{3}{2 \\sqrt{5}} \\\\\n \\frac{1}{\\sqrt{5}} \\\\\n -\\frac{1}{2 \\sqrt{5}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [-2],\n [-3],\n [2],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 5 & 8 & 1 & 3 \\\\\n 6 & 1 & 3 & -3 \\\\\n -1 & -9 & -7 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & \\frac{57}{359} \\\\\n 0 & 1 & 0 & \\frac{165}{359} \\\\\n 0 & 0 & 1 & -\\frac{528}{359} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, 8, 1, 3],\n [6, 1, 3, -3],\n [-1, -9, -7, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & 1 \\\\\n -8 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-2 \\sqrt{2},2 \\sqrt{2}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 1],\n [-8, 4]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{14}{3} & \\frac{1}{3} \\\\\n \\frac{7}{3} & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{161}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/3), (1/3)],\n [(7/3), 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & 3 & -1 & 3 \\\\\n 0 & -1 & 0 & -2 \\\\\n -3 & 2 & 2 & -3 \\\\\n 2 & 0 & 2 & -3 \\\\\n 3 & 2 & -2 & 3 \\\\\n -3 & 2 & -1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.46 \\\\\n 2.88 \\\\\n 1.98 \\\\\n 1.73 \\\\\n 2.97 \\\\\n 2.84 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.363 \\\\\n 1.385 \\\\\n -2.891 \\\\\n -2.142 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 3, -1, 3],\n [0, -1, 0, -2],\n [-3, 2, 2, -3],\n [2, 0, 2, -3],\n [3, 2, -2, 3],\n [-3, 2, -1, 1]])\nb = np.array([\n [1.46],\n [2.88],\n [1.98],\n [1.73],\n [2.97],\n [2.84]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{83}{9} \\\\\n -\\frac{46}{9} \\\\\n -\\frac{16}{9} \\\\\n 1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{25}{3} \\\\\n -\\frac{8}{3} \\\\\n -\\frac{35}{9} \\\\\n -\\frac{35}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{158}{9} \\\\\n -\\frac{22}{9} \\\\\n \\frac{19}{9} \\\\\n \\frac{44}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(83/9)],\n [-(46/9)],\n [-(16/9)],\n [1]])\nb = np.array([\n [(25/3)],\n [-(8/3)],\n [-(35/9)],\n [-(35/9)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -\\frac{19}{5} & \\frac{13}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/5), (13/5)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{4} & \\frac{3}{4} & \\frac{7}{4} \\\\\n -\\frac{5}{2} & 1 & \\frac{3}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & \\frac{7}{4} \\\\\n \\frac{1}{2} & \\frac{9}{4} \\\\\n 0 & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{3}{4} & \\frac{55}{16} \\\\\n \\frac{17}{4} & -\\frac{31}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/4), (3/4), (7/4)],\n [-(5/2), 1, (3/4)]])\nb = np.array([\n [-(3/2), (7/4)],\n [(1/2), (9/4)],\n [0, (1/4)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{13}{5}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -4 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{52}{5} & -13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -5]])\nprint(a * (13/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{31}{5} \\\\\n -\\frac{47}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{8}{5} \\\\\n \\frac{17}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}+\\tan ^{-1}\\left(\\frac{1047}{151}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(31/5)],\n [-(47/5)]]).squeeze()\nb = np.array([\n [-(8/5)],\n [(17/5)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -3 & 2 \\\\\n -1 & -2 & -4 \\\\\n 2 & -3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$26$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3, 2],\n [-1, -2, -4],\n [2, -3, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${4, 3, 1}$ to the plane $5 x+y+4 z+1=0$.", - "Output Answer": [ - "$2 \\sqrt{\\frac{14}{3}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 4, 3, 1\nplane = Poly(5*x+y+4*z+1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 8 \\\\\n 9 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$21$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [8],\n [9],\n [2]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -5 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 9 \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -48 \\\\\n -54 \\\\\n 33 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-5],\n [2]])\nb = np.array([\n [-6],\n [9],\n [6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{47}{6} & \\frac{17}{3} \\\\\n -\\frac{28}{3} & -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{61 x}{6}+\\frac{427}{6}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(47/6), (17/3)],\n [-(28/3), -(7/3)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 4 & 7 \\\\\n -2 & -3 \\\\\n -3 & 6 \\\\\n -2 & -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -6 & 3 \\\\\n 10 & 5 \\\\\n -1 & 0 \\\\\n 8 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -2 & 10 \\\\\n 8 & 2 \\\\\n -4 & 6 \\\\\n 6 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 7],\n [-2, -3],\n [-3, 6],\n [-2, -8]])\nb = np.array([\n [-6, 3],\n [10, 5],\n [-1, 0],\n [8, 8]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{1}{2},-\\frac{5}{2},3\\right\\}, \\left\\{5,\\frac{5}{2},1\\right\\}, \\{3,-3,-1\\}}$.", - "Output Answer": [ - "$28 x-20 y+27 z-117=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(1/2), -(5/2), 3],\n [5, (5/2), 1],\n [3, -3, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{8}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & -3 \\\\\n -5 & -1 \\\\\n -3 & -4 \\\\\n 4 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & \\frac{21}{8} \\\\\n \\frac{35}{8} & \\frac{7}{8} \\\\\n \\frac{21}{8} & \\frac{7}{2} \\\\\n -\\frac{7}{2} & \\frac{21}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3],\n [-5, -1],\n [-3, -4],\n [4, -6]])\nprint(a * -(7/8))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{17}{10} & \\frac{1}{5} \\\\\n -\\frac{11}{10} & \\frac{14}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{140}{227} & \\frac{10}{227} \\\\\n -\\frac{55}{227} & \\frac{85}{227} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/10), (1/5)],\n [-(11/10), (14/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{1}{2}, -\\frac{9}{2}, \\frac{7}{2}}$ to the plane $-4 x-3 y+\\frac{9 z}{2}-2=0$.", - "Output Answer": [ - "$\\frac{117}{2 \\sqrt{181}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(1/2), -(9/2), (7/2)\nplane = Poly(-4*x-3*y+((9*z)/2)-2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 3 & -6 & 8 \\\\\n -6 & -8 & 9 \\\\\n 6 & -6 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1.733,-0.088,1.\\}, \\{0.179\\, -0.806 i,1.006\\, -1.618 i,1.\\}, \\{0.179\\, +0.806 i,1.006\\, +1.618 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -6, 8],\n [-6, -8, 9],\n [6, -6, -3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{2}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 9 & 9 \\\\\n -6 & -7 & 1 \\\\\n -6 & 6 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & \\frac{9}{2} & \\frac{9}{2} \\\\\n -3 & -\\frac{7}{2} & \\frac{1}{2} \\\\\n -3 & 3 & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 9, 9],\n [-6, -7, 1],\n [-6, 6, 9]])\nprint(a * (1/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -4 & -2 & -4 \\\\\n 3 & 3 & 1 \\\\\n 4 & -3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{6}{23} & \\frac{9}{23} & \\frac{5}{23} \\\\\n -\\frac{5}{46} & \\frac{2}{23} & -\\frac{4}{23} \\\\\n -\\frac{21}{46} & -\\frac{10}{23} & -\\frac{3}{23} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -2, -4],\n [3, 3, 1],\n [4, -3, 3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{8}{\\pi } \\\\\n -\\frac{25}{\\pi } \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{16}{\\pi } \\\\\n \\frac{16}{\\pi } \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{528}{\\pi ^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(8/math.pi)],\n [-(25/math.pi)]])\nb = np.array([\n [-(16/math.pi)],\n [(16/math.pi)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 0 & -\\frac{9}{2} & 6 & -\\frac{17}{2} \\\\\n -\\frac{19}{2} & -\\frac{7}{2} & \\frac{15}{2} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -10 & -\\frac{5}{2} & -\\frac{11}{2} & -\\frac{17}{2} \\\\\n -\\frac{17}{2} & -9 & -8 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 10 & -2 & \\frac{23}{2} & 0 \\\\\n -1 & \\frac{11}{2} & \\frac{31}{2} & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -(9/2), 6, -(17/2)],\n [-(19/2), -(7/2), (15/2), (3/2)]])\nb = np.array([\n [-10, -(5/2), -(11/2), -(17/2)],\n [-(17/2), -9, -8, 6]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{381}{50} & \\frac{581}{100} \\\\\n -\\frac{46}{25} & -\\frac{131}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{893 x}{100}+\\frac{103363}{5000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(381/50), (581/100)],\n [-(46/25), -(131/100)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -3 & -2 & 3 & 0 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 9 & 6 & -9 & 0 & 6 \\\\\n -9 & -6 & 9 & 0 & -6 \\\\\n 6 & 4 & -6 & 0 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [3],\n [-2]])\nb = np.array([\n [-3, -2, 3, 0, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{50}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & -4 & 1 & -6 \\\\\n 0 & 10 & 8 & -7 \\\\\n 10 & 8 & -8 & -5 \\\\\n 8 & -10 & 10 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{3}{25} & \\frac{6}{25} & -\\frac{3}{50} & \\frac{9}{25} \\\\\n 0 & -\\frac{3}{5} & -\\frac{12}{25} & \\frac{21}{50} \\\\\n -\\frac{3}{5} & -\\frac{12}{25} & \\frac{12}{25} & \\frac{3}{10} \\\\\n -\\frac{12}{25} & \\frac{3}{5} & -\\frac{3}{5} & \\frac{3}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -4, 1, -6],\n [0, 10, 8, -7],\n [10, 8, -8, -5],\n [8, -10, 10, -10]])\nprint(a * -(3/50))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n 8 & 8 & 4 \\\\\n -2 & -1 & -3 \\\\\n -5 & 8 & -4 \\\\\n -7 & -2 & -10 \\\\\n 4 & 3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 8, 4],\n [-2, -1, -3],\n [-5, 8, -4],\n [-7, -2, -10],\n [4, 3, 2]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{0,\\frac{5}{3},1\\right\\}, \\left\\{2,-\\frac{11}{3},2\\right\\}, \\left\\{\\frac{1}{3},\\frac{10}{3},2\\right\\}}$.", - "Output Answer": [ - "$63 x+15 y-46 z+21=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, (5/3), 1],\n [2, -(11/3), 2],\n [(1/3), (10/3), 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{4} \\\\\n 0 \\\\\n \\frac{1}{4} \\\\\n \\frac{1}{4} \\\\\n -\\frac{1}{4} \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [0],\n [1],\n [1],\n [-1],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{0,-2\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-2]]).squeeze()\nb = np.array([\n [0],\n [-1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{8}{5} & -\\frac{2}{5} \\\\\n 0 & -\\frac{14}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{112}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(8/5), -(2/5)],\n [0, -(14/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n -2 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{11}} \\\\\n -\\frac{1}{\\sqrt{11}} \\\\\n -\\frac{2}{\\sqrt{11}} \\\\\n \\frac{2}{\\sqrt{11}} \\\\\n \\frac{1}{\\sqrt{11}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [-2],\n [2],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{11}{2}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 4 \\\\\n -8 & -8 \\\\\n -6 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{33}{2} & 22 \\\\\n -44 & -44 \\\\\n -33 & \\frac{33}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 4],\n [-8, -8],\n [-6, 3]])\nprint(a * (11/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 8 & 8 & -7 & -5 \\\\\n -9 & 0 & -2 & 0 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -2 & 4 & -4 & -1 \\\\\n -8 & -2 & -4 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 10 & 4 & -3 & -4 \\\\\n -1 & 2 & 2 & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 8, -7, -5],\n [-9, 0, -2, 0]])\nb = np.array([\n [-2, 4, -4, -1],\n [-8, -2, -4, 6]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -4 & 0 & 8 & 7 & -1 & -9 & 10 \\\\\n -5 & 3 & 9 & -3 & -7 & -8 & -2 \\\\\n -9 & 3 & 4 & 1 & 6 & 1 & 0 \\\\\n 1 & -10 & -5 & -6 & -1 & -2 & 5 \\\\\n 1 & 4 & -1 & 1 & 5 & 2 & -4 \\\\\n 2 & 2 & 9 & 0 & -1 & -6 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & \\frac{41951}{302321} \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & -\\frac{405666}{302321} \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & \\frac{233645}{302321} \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & \\frac{219371}{302321} \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & \\frac{70787}{302321} \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & \\frac{15884}{302321} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-4, 0, 8, 7, -1, -9, 10],\n [-5, 3, 9, -3, -7, -8, -2],\n [-9, 3, 4, 1, 6, 1, 0],\n [1, -10, -5, -6, -1, -2, 5],\n [1, 4, -1, 1, 5, 2, -4],\n [2, 2, 9, 0, -1, -6, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & 3 & 3 & -3 & 0 \\\\\n -1 & 2 & -3 & -2 & -3 \\\\\n 2 & 1 & 0 & 0 & -1 \\\\\n 3 & 2 & -3 & 2 & -3 \\\\\n -1 & 3 & 2 & -3 & 1 \\\\\n -1 & -2 & -1 & 3 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.65 \\\\\n -0.75 \\\\\n 0.83 \\\\\n -2.83 \\\\\n -0.57 \\\\\n 0.88 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.267 \\\\\n -0.8 \\\\\n -0.389 \\\\\n -0.558 \\\\\n 0.493 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, 3, -3, 0],\n [-1, 2, -3, -2, -3],\n [2, 1, 0, 0, -1],\n [3, 2, -3, 2, -3],\n [-1, 3, 2, -3, 1],\n [-1, -2, -1, 3, 0]])\nb = np.array([\n [-2.65],\n [-0.75],\n [0.83],\n [-2.83],\n [-0.57],\n [0.88]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -0.73 \\\\\n -6.08 \\\\\n -5.16 \\\\\n 9.74 \\\\\n 3.46 \\\\\n 7.52 \\\\\n -9.92 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9.71 \\\\\n -9.33 \\\\\n -0.38 \\\\\n -7.26 \\\\\n -7.46 \\\\\n -0.01 \\\\\n 4.86 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-93.2115$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-0.73],\n [-6.08],\n [-5.16],\n [9.74],\n [3.46],\n [7.52],\n [-9.92]])\nb = np.array([\n [9.71],\n [-9.33],\n [-0.38],\n [-7.26],\n [-7.46],\n [-0.01],\n [4.86]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n -8 \\\\\n 7 \\\\\n -10 \\\\\n -6 \\\\\n -2 \\\\\n -9 \\\\\n -9 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -4 \\\\\n -8 \\\\\n 9 \\\\\n -8 \\\\\n 3 \\\\\n -5 \\\\\n 9 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4 \\sqrt{61}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [-8],\n [7],\n [-10],\n [-6],\n [-2],\n [-9],\n [-9],\n [-6]])\nb = np.array([\n [-9],\n [-4],\n [-8],\n [9],\n [-8],\n [3],\n [-5],\n [9],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & 2 \\\\\n -1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2],\n [-1, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -14 \\log (2) \\\\\n -4 \\log (2) \\\\\n 14 \\log (2) \\\\\n 6 \\log (2) \\\\\n -4 \\log (2) \\\\\n 10 \\log (2) \\\\\n -7 \\log (2) \\\\\n -9 \\log (2) \\\\\n 14 \\log (2) \\\\\n -7 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 12 \\log (2) \\\\\n -2 \\log (2) \\\\\n 4 \\log (2) \\\\\n -10 \\log (2) \\\\\n 14 \\log (2) \\\\\n 11 \\log (2) \\\\\n -8 \\log (2) \\\\\n 5 \\log (2) \\\\\n -5 \\log (2) \\\\\n -12 \\log (2) \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$18 \\sqrt{6} \\log (2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-14*math.log(2)],\n [-4*math.log(2)],\n [14*math.log(2)],\n [6*math.log(2)],\n [-4*math.log(2)],\n [10*math.log(2)],\n [-7*math.log(2)],\n [-9*math.log(2)],\n [14*math.log(2)],\n [-7*math.log(2)]])\nb = np.array([\n [12*math.log(2)],\n [-2*math.log(2)],\n [4*math.log(2)],\n [-10*math.log(2)],\n [14*math.log(2)],\n [11*math.log(2)],\n [-8*math.log(2)],\n [5*math.log(2)],\n [-5*math.log(2)],\n [-12*math.log(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-2$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 4 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -4]])\nprint(a * -2)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,2,0\\}, \\{-1,0,0\\}, \\{-5,-4,-2\\}}$.", - "Output Answer": [ - "$x-2 y+2 z+1=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, 2, 0],\n [-1, 0, 0],\n [-5, -4, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{46}{5} & -\\frac{6}{5} & -\\frac{9}{5} \\\\\n -\\frac{2}{5} & \\frac{32}{5} & -\\frac{23}{5} \\\\\n -\\frac{16}{5} & \\frac{1}{5} & -\\frac{29}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-4.791,-0.91,1.\\}, \\{-4.594,-11.282,1.\\}, \\{0.146,0.37,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(46/5), -(6/5), -(9/5)],\n [-(2/5), (32/5), -(23/5)],\n [-(16/5), (1/5), -(29/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & 2 & 3 & 1 & 3 \\\\\n -3 & 1 & 3 & 0 & -2 \\\\\n 3 & 1 & -2 & -2 & 1 \\\\\n 1 & 1 & 3 & 0 & 3 \\\\\n 0 & 0 & 3 & 2 & 3 \\\\\n -3 & 2 & 3 & 1 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.68 \\\\\n 0.12 \\\\\n 1. \\\\\n -0.16 \\\\\n -2.3 \\\\\n -2.23 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.331 \\\\\n -0.077 \\\\\n -0.584 \\\\\n -1.57 \\\\\n 0.935 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2, 3, 1, 3],\n [-3, 1, 3, 0, -2],\n [3, 1, -2, -2, 1],\n [1, 1, 3, 0, 3],\n [0, 0, 3, 2, 3],\n [-3, 2, 3, 1, -3]])\nb = np.array([\n [0.68],\n [0.12],\n [1.],\n [-0.16],\n [-2.3],\n [-2.23]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -10 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 8 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{470}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-10],\n [1]])\nb = np.array([\n [-3],\n [8],\n [6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 0 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -2 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 16 \\\\\n -74 \\\\\n -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [0],\n [8]])\nb = np.array([\n [-8],\n [-2],\n [5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{22}{9} & -\\frac{11}{9} & \\frac{41}{9} \\\\\n \\frac{5}{3} & \\frac{13}{9} & -\\frac{26}{9} \\\\\n -\\frac{28}{9} & -\\frac{34}{9} & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{3627}{15368} & \\frac{747}{1921} & \\frac{2223}{30736} \\\\\n -\\frac{2871}{15368} & -\\frac{720}{1921} & -\\frac{10683}{30736} \\\\\n \\frac{657}{15368} & -\\frac{594}{1921} & -\\frac{4059}{30736} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(22/9), -(11/9), (41/9)],\n [(5/3), (13/9), -(26/9)],\n [-(28/9), -(34/9), (2/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & 4 & -3 \\\\\n -2 & 4 & -3 \\\\\n 5 & 5 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{137}{2860} & -\\frac{137}{2860} & \\frac{159}{1430} \\\\\n \\frac{13}{220} & \\frac{13}{220} & \\frac{9}{110} \\\\\n -\\frac{8}{143} & -\\frac{8}{143} & \\frac{5}{143} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 4, -3],\n [-2, 4, -3],\n [5, 5, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{2}{3}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 10 & 0 & -3 & -8 \\\\\n -6 & -1 & -6 & -5 \\\\\n 2 & 2 & 0 & -9 \\\\\n -3 & 8 & -6 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{20}{3} & 0 & 2 & \\frac{16}{3} \\\\\n 4 & \\frac{2}{3} & 4 & \\frac{10}{3} \\\\\n -\\frac{4}{3} & -\\frac{4}{3} & 0 & 6 \\\\\n 2 & -\\frac{16}{3} & 4 & \\frac{14}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 0, -3, -8],\n [-6, -1, -6, -5],\n [2, 2, 0, -9],\n [-3, 8, -6, -7]])\nprint(a * -(2/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 2 \\\\\n 8 \\\\\n 0 \\\\\n -4 \\\\\n -9 \\\\\n -6 \\\\\n -10 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 0 \\\\\n 0 \\\\\n 10 \\\\\n 3 \\\\\n 2 \\\\\n -5 \\\\\n -9 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{390}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [2],\n [8],\n [0],\n [-4],\n [-9],\n [-6],\n [-10],\n [0]])\nb = np.array([\n [-6],\n [0],\n [0],\n [10],\n [3],\n [2],\n [-5],\n [-9],\n [7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 4 & -5 & -6 & -3 & 5 \\\\\n -7 & 6 & 10 & -6 & 6 \\\\\n 9 & -9 & -4 & 3 & 2 \\\\\n -7 & 5 & 7 & 7 & -5 \\\\\n 10 & -9 & 7 & 3 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, -5, -6, -3, 5],\n [-7, 6, 10, -6, 6],\n [9, -9, -4, 3, 2],\n [-7, 5, 7, 7, -5],\n [10, -9, 7, 3, -8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{1}{3} & -\\frac{31}{9} & \\frac{29}{9} & \\frac{28}{9} & -4 \\\\\n -\\frac{20}{3} & -\\frac{76}{9} & -\\frac{89}{9} & -\\frac{7}{9} & -\\frac{88}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/3), -(31/9), (29/9), (28/9), -4],\n [-(20/3), -(76/9), -(89/9), -(7/9), -(88/9)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 2 & 2 \\\\\n 2 & \\frac{3}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 30 & \\frac{53}{2} \\\\\n \\frac{53}{2} & \\frac{187}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2],\n [2, (3/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & \\frac{18}{5} \\\\\n \\frac{22}{5} & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{396}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, (18/5)],\n [(22/5), 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2}{\\sqrt{5}} \\\\\n \\frac{1}{\\sqrt{5}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\log (2) \\\\\n -3 \\log (2) \\\\\n -7 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -12 \\log (2) \\\\\n 5 \\log (2) \\\\\n 8 \\log (2) \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-119 \\log ^2(2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [4*math.log(2)],\n [-3*math.log(2)],\n [-7*math.log(2)]])\nb = np.array([\n [-12*math.log(2)],\n [5*math.log(2)],\n [8*math.log(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 6 \\\\\n -8 \\\\\n 7 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -2 \\\\\n 6 \\\\\n -8 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{17 \\sqrt{\\frac{5}{1391}}}{2}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [6],\n [-8],\n [7],\n [7]]).squeeze()\nb = np.array([\n [-1],\n [-2],\n [6],\n [-8],\n [5]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -1 \\\\\n 9 \\\\\n -1 \\\\\n -1 \\\\\n -8 \\\\\n -3 \\\\\n -9 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 0 \\\\\n -8 \\\\\n 1 \\\\\n -2 \\\\\n 5 \\\\\n 9 \\\\\n -10 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{805}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-1],\n [9],\n [-1],\n [-1],\n [-8],\n [-3],\n [-9],\n [8]])\nb = np.array([\n [-9],\n [0],\n [-8],\n [1],\n [-2],\n [5],\n [9],\n [-10],\n [-6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -\\frac{51}{8} \\\\\n -\\frac{37}{8} \\\\\n -6 \\\\\n -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(51/8)],\n [-(37/8)],\n [-6],\n [-(1/4)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 2+3 i & 5-5 i \\\\\n -2+3 i & -4+i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 37 i & 10+30 i \\\\\n -8-14 i & 20+17 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2+3j, 5-5j],\n [-2+3j, -4+ 1j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n \\frac{1}{2} \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2}{\\sqrt{41}} \\\\\n \\frac{1}{\\sqrt{41}} \\\\\n \\frac{6}{\\sqrt{41}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [(1/2)],\n [3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & 4 & 1 \\\\\n -1 & 1 & -3 \\\\\n 3 & -2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-76$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 4, 1],\n [-1, 1, -3],\n [3, -2, -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/4)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{1,2,-2\\}, \\{2,2,-2\\}, \\{1,2,-3\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{3},\\frac{2}{3},-\\frac{2}{3}\\right\\}, \\left\\{\\frac{2 \\sqrt{2}}{3},-\\frac{1}{3 \\sqrt{2}},\\frac{1}{3 \\sqrt{2}}\\right\\}, \\left\\{0,-\\frac{1}{\\sqrt{2}},-\\frac{1}{\\sqrt{2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((1, 2, -2), (2, 2, -2), (1, 2, -3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{25}{6} & -\\frac{19}{2} & -\\frac{5}{2} \\\\\n -9 & 6 & -\\frac{5}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{17}{6} & \\frac{1}{6} & -3 \\\\\n \\frac{7}{2} & \\frac{17}{3} & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -7 & -\\frac{28}{3} & -\\frac{11}{2} \\\\\n -\\frac{11}{2} & \\frac{35}{3} & \\frac{19}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/6), -(19/2), -(5/2)],\n [-9, 6, -(5/6)]])\nb = np.array([\n [-(17/6), (1/6), -3],\n [(7/2), (17/3), 4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -2 & -3 \\\\\n -4 & 4 & -2 \\\\\n 0 & -5 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-62$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, -3],\n [-4, 4, -2],\n [0, -5, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{71}{8} & 6 & \\frac{9}{8} \\\\\n \\frac{53}{8} & \\frac{11}{4} & -\\frac{77}{8} \\\\\n -\\frac{9}{4} & -\\frac{3}{8} & -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{117 x^2}{8}+\\frac{843 x}{64}+\\frac{182135}{256}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(71/8), 6, (9/8)],\n [(53/8), (11/4), -(77/8)],\n [-(9/4), -(3/8), -(17/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 3 \\\\\n -3 \\\\\n -1 \\\\\n 4 \\\\\n -3 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -3 \\\\\n 2 \\\\\n -7 \\\\\n 0 \\\\\n -6 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{211}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [3],\n [-3],\n [-1],\n [4],\n [-3],\n [0]])\nb = np.array([\n [-9],\n [-3],\n [2],\n [-7],\n [0],\n [-6],\n [-8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & -2 \\\\\n -2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2],\n [-2, 2]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -4 & 0 & -4 \\\\\n 1 & 4 & -8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -5 & 2 & -4 \\\\\n -8 & 4 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & -2 & 0 \\\\\n 9 & 0 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 0, -4],\n [1, 4, -8]])\nb = np.array([\n [-5, 2, -4],\n [-8, 4, -6]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{2}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -7 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{27}{2} \\\\\n -\\frac{21}{2} \\\\\n 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-7],\n [4]])\nprint(a * (3/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & -5 & -1 \\\\\n 4 & 2 & -1 \\\\\n -2 & 3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-69$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -5, -1],\n [4, 2, -1],\n [-2, 3, -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 4 & 4 & 10 & 0 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-5.,0.,2.,0.,0.\\}, \\{-1.,1.,0.,0.,0.\\}, \\{0.,0.,0.,1.,0.\\}, \\{1.,0.,0.,0.,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, 4, 10, 0, -4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -3 & 1 & 1 \\\\\n 1 & -2 & 2 \\\\\n -2 & 3 & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -24 & 9 & 4 \\\\\n 44 & -40 & 13 \\\\\n -43 & 37 & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1, 1],\n [1, -2, 2],\n [-2, 3, 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -5 & -4 & 1 \\\\\n -5 & 0 & -5 \\\\\n 0 & -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & -\\frac{7}{10} & -2 \\\\\n -1 & 1 & 3 \\\\\n -\\frac{1}{2} & \\frac{1}{2} & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -4, 1],\n [-5, 0, -5],\n [0, -1, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 1 \\\\\n 2 & -1 \\\\\n -1 & -1 \\\\\n 0 & -3 \\\\\n -2 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.31 \\\\\n -0.86 \\\\\n -1.11 \\\\\n -2.64 \\\\\n -1.97 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.464 \\\\\n 0.933 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1],\n [2, -1],\n [-1, -1],\n [0, -3],\n [-2, 0]])\nb = np.array([\n [1.31],\n [-0.86],\n [-1.11],\n [-2.64],\n [-1.97]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 3 & 9 & 4 & -10 & -5 & 3 & 7 \\\\\n -10 & -10 & 5 & -8 & -3 & 7 & -2 \\\\\n 10 & 3 & -6 & 0 & -5 & 0 & -5 \\\\\n -2 & -9 & 0 & 6 & 10 & 2 & 0 \\\\\n -9 & 9 & 8 & -9 & -9 & 3 & 5 \\\\\n 6 & 7 & 4 & -5 & 0 & 5 & -3 \\\\\n 8 & 1 & -10 & -8 & 3 & -2 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, 9, 4, -10, -5, 3, 7],\n [-10, -10, 5, -8, -3, 7, -2],\n [10, 3, -6, 0, -5, 0, -5],\n [-2, -9, 0, 6, 10, 2, 0],\n [-9, 9, 8, -9, -9, 3, 5],\n [6, 7, 4, -5, 0, 5, -3],\n [8, 1, -10, -8, 3, -2, 5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{0,0,0\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [2],\n [1],\n [-1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{0,0,0,0\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [2],\n [-1]]).squeeze()\nb = np.array([\n [-2],\n [0],\n [0],\n [0]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 8 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -31 \\\\\n -40 \\\\\n -24 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [8],\n [-3]])\nb = np.array([\n [0],\n [3],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 8 & -1 \\\\\n -4 & 5 \\\\\n 4 & 3 \\\\\n 6 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 3 & 2 \\\\\n -1 & 7 \\\\\n -5 & -1 \\\\\n -9 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 11 & 1 \\\\\n -5 & 12 \\\\\n -1 & 2 \\\\\n -3 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -1],\n [-4, 5],\n [4, 3],\n [6, 1]])\nb = np.array([\n [3, 2],\n [-1, 7],\n [-5, -1],\n [-9, 7]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -2 & -3 & 0 & -2 & -2 \\\\\n -1 & -2 & -1 & -3 & 2 \\\\\n -2 & -3 & -1 & -1 & -1 \\\\\n 1 & -2 & -1 & -3 & -2 \\\\\n 2 & 2 & -3 & 1 & 0 \\\\\n 2 & 0 & 2 & 3 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.75 \\\\\n -0.2 \\\\\n -2.86 \\\\\n -2.44 \\\\\n -1.36 \\\\\n -1.77 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.726 \\\\\n 1.261 \\\\\n 0.672 \\\\\n -0.634 \\\\\n 0.12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, 0, -2, -2],\n [-1, -2, -1, -3, 2],\n [-2, -3, -1, -1, -1],\n [1, -2, -1, -3, -2],\n [2, 2, -3, 1, 0],\n [2, 0, 2, 3, 1]])\nb = np.array([\n [-0.75],\n [-0.2],\n [-2.86],\n [-2.44],\n [-1.36],\n [-1.77]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{7}{3} & -2 & -\\frac{5}{3} \\\\\n -\\frac{4}{3} & -\\frac{19}{6} & -\\frac{25}{6} \\\\\n -\\frac{7}{2} & \\frac{11}{6} & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{131}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/3), -2, -(5/3)],\n [-(4/3), -(19/6), -(25/6)],\n [-(7/2), (11/6), -(1/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,0,-3\\}, \\{-2,-3,0\\}, \\{-4,-4,4\\}}$.", - "Output Answer": [ - "$3 x+2 (y+z+6)=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, 0, -3],\n [-2, -3, 0],\n [-4, -4, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & 10 \\\\\n 0 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{6,8\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 10],\n [0, 8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -3 \\\\\n -4 \\\\\n 5 \\\\\n -6 \\\\\n -9 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-3],\n [-4],\n [5],\n [-6],\n [-9],\n [3]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{14}{5}, -\\frac{17}{10}}$ to the line $-4 x-\\frac{7 y}{5}-\\frac{4}{5}=0$.", - "Output Answer": [ - "$\\frac{639}{10 \\sqrt{449}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(14/5), -(17/10)\nline = Poly(-4*x-((7*y)/5)-(4/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,1,1\\}, \\{-1,-1,0\\}, \\{1,1,3\\}}$", - "Output Answer": [ - "${\\left\\{0,\\frac{1}{\\sqrt{2}},\\frac{1}{\\sqrt{2}}\\right\\}, \\left\\{-\\sqrt{\\frac{2}{3}},-\\frac{1}{\\sqrt{6}},\\frac{1}{\\sqrt{6}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}},\\frac{1}{\\sqrt{3}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, 1, 1), (-1, -1, 0), (1, 1, 3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{3} & -\\frac{13}{6} & \\frac{8}{3} \\\\\n -\\frac{9}{2} & -\\frac{7}{2} & -\\frac{4}{3} \\\\\n -\\frac{13}{3} & -3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{1337}{108}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/3), -(13/6), (8/3)],\n [-(9/2), -(7/2), -(4/3)],\n [-(13/3), -3, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{3}{2} & 2 & -\\frac{1}{2} & -1 \\\\\n \\frac{5}{2} & \\frac{5}{2} & -\\frac{3}{2} & 3 \\\\\n -1 & -3 & \\frac{3}{2} & 0 \\\\\n -\\frac{5}{2} & \\frac{1}{2} & 3 & -2 \\\\\n -\\frac{3}{2} & \\frac{1}{2} & -\\frac{3}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -2 \\\\\n 1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{5}{2} \\\\\n -\\frac{25}{2} \\\\\n \\frac{15}{2} \\\\\n 6 \\\\\n -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), 2, -(1/2), -1],\n [(5/2), (5/2), -(3/2), 3],\n [-1, -3, (3/2), 0],\n [-(5/2), (1/2), 3, -2],\n [-(3/2), (1/2), -(3/2), (5/2)]])\nb = np.array([\n [0],\n [-2],\n [1],\n [-2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{133}{16} & \\frac{47}{16} & \\frac{29}{4} \\\\\n \\frac{1}{16} & \\frac{29}{8} & -\\frac{19}{16} \\\\\n \\frac{17}{4} & \\frac{25}{4} & \\frac{17}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(133/16), (47/16), (29/4)],\n [(1/16), (29/8), -(19/16)],\n [(17/4), (25/4), (17/8)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{46}{7} & -\\frac{48}{7} & -\\frac{69}{7} & 1 \\\\\n -\\frac{16}{7} & \\frac{32}{7} & -\\frac{15}{7} & -\\frac{11}{7} \\\\\n \\frac{48}{7} & -\\frac{6}{7} & \\frac{40}{7} & -\\frac{18}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n \\frac{16}{7} & -\\frac{33}{7} & 2 & -\\frac{6}{7} \\\\\n -\\frac{54}{7} & -\\frac{68}{7} & -\\frac{33}{7} & -\\frac{52}{7} \\\\\n \\frac{23}{7} & \\frac{59}{7} & -3 & \\frac{34}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{62}{7} & -\\frac{15}{7} & -\\frac{83}{7} & \\frac{13}{7} \\\\\n \\frac{38}{7} & \\frac{100}{7} & \\frac{18}{7} & \\frac{41}{7} \\\\\n \\frac{25}{7} & -\\frac{65}{7} & \\frac{61}{7} & -\\frac{52}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(46/7), -(48/7), -(69/7), 1],\n [-(16/7), (32/7), -(15/7), -(11/7)],\n [(48/7), -(6/7), (40/7), -(18/7)]])\nb = np.array([\n [(16/7), -(33/7), 2, -(6/7)],\n [-(54/7), -(68/7), -(33/7), -(52/7)],\n [(23/7), (59/7), -3, (34/7)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{37}{8} & \\frac{37}{8} & \\frac{21}{4} & -\\frac{145}{16} \\\\\n -\\frac{35}{4} & \\frac{1}{4} & -\\frac{21}{4} & \\frac{3}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n \\frac{25}{8} & \\frac{95}{16} & \\frac{3}{2} & -\\frac{67}{8} \\\\\n -\\frac{7}{16} & \\frac{33}{16} & -\\frac{13}{8} & \\frac{79}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{3}{2} & -\\frac{21}{16} & \\frac{15}{4} & -\\frac{11}{16} \\\\\n -\\frac{133}{16} & -\\frac{29}{16} & -\\frac{29}{8} & -\\frac{73}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/8), (37/8), (21/4), -(145/16)],\n [-(35/4), (1/4), -(21/4), (3/4)]])\nb = np.array([\n [(25/8), (95/16), (3/2), -(67/8)],\n [-(7/16), (33/16), -(13/8), (79/8)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{5} \\\\\n -\\frac{37}{5} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{5} \\\\\n \\frac{4}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{8}{5} \\\\\n -\\frac{41}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/5)],\n [-(37/5)]])\nb = np.array([\n [-(9/5)],\n [(4/5)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{1}{3},0,0\\right\\}, \\left\\{-\\frac{4}{3},-\\frac{10}{3},0\\right\\}, \\left\\{\\frac{1}{3},-1,-3\\right\\}}$.", - "Output Answer": [ - "$6 x-3 y+z-2=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(1/3), 0, 0],\n [-(4/3), -(10/3), 0],\n [(1/3), -1, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & -6 \\\\\n -2 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-13-\\sqrt{73}\\right),\\frac{1}{2} \\left(\\sqrt{73}-13\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -6],\n [-2, -9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -5 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -10 \\\\\n 25 \\\\\n 39 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-2],\n [0]])\nb = np.array([\n [7],\n [-5],\n [5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 3 \\\\\n -1 & 3 \\\\\n 2 & -2 \\\\\n -3 & 0 \\\\\n 1 & 2 \\\\\n -2 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.82 \\\\\n -2.22 \\\\\n 0.61 \\\\\n -2.63 \\\\\n -1.29 \\\\\n 2.31 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.02 \\\\\n -0.258 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3],\n [-1, 3],\n [2, -2],\n [-3, 0],\n [1, 2],\n [-2, 3]])\nb = np.array([\n [-1.82],\n [-2.22],\n [0.61],\n [-2.63],\n [-1.29],\n [2.31]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 5 & -6 & -8 \\\\\n -6 & 8 & 7 \\\\\n -8 & -9 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.017,-1.327,1.\\}, \\{0.429,-0.242,1.\\}, \\{5.053,-6.764,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -6, -8],\n [-6, 8, 7],\n [-8, -9, -9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 3 \\\\\n 1 \\\\\n -3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2}{3 \\sqrt{3}} \\\\\n \\frac{1}{\\sqrt{3}} \\\\\n \\frac{1}{3 \\sqrt{3}} \\\\\n -\\frac{1}{\\sqrt{3}} \\\\\n -\\frac{2}{3 \\sqrt{3}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [3],\n [1],\n [-3],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -1 \\\\\n 9 \\\\\n 9 \\\\\n 2 \\\\\n 6 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$36$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-1],\n [9],\n [9],\n [2],\n [6],\n [2]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 9 \\\\\n 8 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 8 \\\\\n 2 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$47$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [9],\n [8],\n [-8]])\nb = np.array([\n [1],\n [8],\n [2],\n [5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & -5 \\\\\n -4 & -5 & 3 \\\\\n -1 & 2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{9}{89} & -\\frac{13}{89} & -\\frac{28}{89} \\\\\n -\\frac{15}{89} & -\\frac{8}{89} & \\frac{17}{89} \\\\\n -\\frac{13}{89} & -\\frac{1}{89} & -\\frac{9}{89} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, -5],\n [-4, -5, 3],\n [-1, 2, -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & 4 & -1 \\\\\n 9 & 9 & -9 \\\\\n 0 & 4 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-4.922,-0.585,12.507\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 4, -1],\n [9, 9, -9],\n [0, 4, -8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 2 & 4 & -5 & -7 \\\\\n 8 & 1 & -4 & -2 \\\\\n 2 & 5 & 3 & 1 \\\\\n -6 & 1 & 4 & -1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -3 & -8 & 1 & -4 \\\\\n -5 & -1 & 4 & -9 \\\\\n 8 & -2 & 5 & 8 \\\\\n 8 & 5 & -3 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 5 & 12 & -6 & -3 \\\\\n 13 & 2 & -8 & 7 \\\\\n -6 & 7 & -2 & -7 \\\\\n -14 & -4 & 7 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 4, -5, -7],\n [8, 1, -4, -2],\n [2, 5, 3, 1],\n [-6, 1, 4, -1]])\nb = np.array([\n [-3, -8, 1, -4],\n [-5, -1, 4, -9],\n [8, -2, 5, 8],\n [8, 5, -3, 0]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 4 & -4 & 5 & 0 \\\\\n -5 & 5 & -9 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1.,1.,0.,0.\\}, \\{35.,0.,-28.,11.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, -4, 5, 0],\n [-5, 5, -9, -7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{50}{7} \\\\\n \\frac{31}{7} \\\\\n -\\frac{3}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{68}{7} \\\\\n -\\frac{8}{7} \\\\\n \\frac{3}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{69}{49} \\\\\n -\\frac{54}{49} \\\\\n -\\frac{244}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(50/7)],\n [(31/7)],\n [-(3/7)]])\nb = np.array([\n [(68/7)],\n [-(8/7)],\n [(3/7)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -1 & -2 & 8 & 7 & -9 & 2 & -4 \\\\\n -5 & -2 & 0 & 7 & -10 & 7 & -4 \\\\\n -8 & 8 & -6 & 7 & 8 & -4 & -1 \\\\\n 10 & -4 & -2 & 5 & 8 & 7 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & \\frac{283}{204} & -\\frac{71}{340} & -\\frac{83}{510} \\\\\n 0 & 1 & 0 & 0 & \\frac{15}{8} & -\\frac{59}{40} & \\frac{3}{10} \\\\\n 0 & 0 & 1 & 0 & -\\frac{29}{51} & -\\frac{177}{340} & \\frac{83}{1020} \\\\\n 0 & 0 & 0 & 1 & \\frac{5}{51} & \\frac{73}{170} & -\\frac{307}{510} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-1, -2, 8, 7, -9, 2, -4],\n [-5, -2, 0, 7, -10, 7, -4],\n [-8, 8, -6, 7, 8, -4, -1],\n [10, -4, -2, 5, 8, 7, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -1 & 2 & -4 \\\\\n -2 & 4 & 3 \\\\\n -2 & -5 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{99} & -\\frac{2}{11} & -\\frac{2}{9} \\\\\n \\frac{4}{99} & \\frac{1}{11} & -\\frac{1}{9} \\\\\n -\\frac{2}{11} & \\frac{1}{11} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2, -4],\n [-2, 4, 3],\n [-2, -5, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 9 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 5 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -55 \\\\\n 4 \\\\\n -73 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [9],\n [2]])\nb = np.array([\n [7],\n [5],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -5 & 7 & 4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -5 & 4 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 3 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 7, 4]])\nb = np.array([\n [-5, 4, 8]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -5 \\\\\n -5 \\\\\n 4 \\\\\n -6 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -4 \\\\\n 9 \\\\\n 7 \\\\\n -2 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-74$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-5],\n [-5],\n [4],\n [-6],\n [-7]])\nb = np.array([\n [-8],\n [-4],\n [9],\n [7],\n [-2],\n [7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 9 & 0 & -6 \\\\\n 3 & 10 & -1 \\\\\n -10 & -1 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, 0, -6],\n [3, 10, -1],\n [-10, -1, 5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [0],\n [1],\n [1]]).squeeze()\nb = np.array([\n [1],\n [-1],\n [0],\n [0],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -5 & -7 & -10 & 5 \\\\\n -8 & -9 & -6 & -4 \\\\\n -7 & 9 & 0 & 6 \\\\\n 2 & 4 & 5 & 4 \\\\\n 2 & -9 & -7 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, -7, -10, 5],\n [-8, -9, -6, -4],\n [-7, 9, 0, 6],\n [2, 4, 5, 4],\n [2, -9, -7, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{3}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & -4 & 7 \\\\\n 3 & -5 & -10 \\\\\n 9 & 4 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & \\frac{4}{3} & -\\frac{7}{3} \\\\\n -1 & \\frac{5}{3} & \\frac{10}{3} \\\\\n -3 & -\\frac{4}{3} & -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -4, 7],\n [3, -5, -10],\n [9, 4, 2]])\nprint(a * -(1/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -6 & 4 & -5 \\\\\n -2 & -5 & 6 \\\\\n 4 & 10 & 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-x^2+112 x+836$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 4, -5],\n [-2, -5, 6],\n [4, 10, 10]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{93}{10} & \\frac{69}{10} & -\\frac{7}{10} & -\\frac{38}{5} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n \\frac{13}{10} & -\\frac{13}{10} & -1 & \\frac{33}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{53}{5} & \\frac{41}{5} & \\frac{3}{10} & -\\frac{71}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(93/10), (69/10), -(7/10), -(38/5)]])\nb = np.array([\n [(13/10), -(13/10), -1, (33/5)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -9 & 6 \\\\\n -9 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{6} i \\left(\\sqrt{15}-3 i\\right),1\\right\\}, \\left\\{-\\frac{1}{6} i \\left(\\sqrt{15}+3 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 6],\n [-9, 0]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{251}{100} \\\\\n -\\frac{66}{25} \\\\\n \\frac{911}{100} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{557}{100} \\\\\n -2 \\\\\n -\\frac{839}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{25231}{625} \\\\\n \\frac{44876}{625} \\\\\n \\frac{6053}{625} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(251/100)],\n [-(66/25)],\n [(911/100)]])\nb = np.array([\n [(557/100)],\n [-2],\n [-(839/100)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -1 & 7 & \\frac{25}{6} & -\\frac{59}{6} \\\\\n -\\frac{59}{6} & \\frac{11}{2} & -\\frac{49}{6} & \\frac{9}{2} \\\\\n \\frac{31}{6} & -\\frac{11}{3} & \\frac{28}{3} & \\frac{20}{3} \\\\\n \\frac{17}{6} & 1 & \\frac{55}{6} & -\\frac{13}{6} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{49}{6} & \\frac{25}{3} & -\\frac{1}{6} & \\frac{41}{6} \\\\\n -\\frac{31}{6} & \\frac{43}{6} & \\frac{10}{3} & -3 \\\\\n -\\frac{9}{2} & -\\frac{35}{6} & -\\frac{31}{6} & -\\frac{13}{6} \\\\\n 9 & -\\frac{31}{6} & \\frac{11}{2} & -\\frac{7}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{43}{6} & -\\frac{4}{3} & \\frac{13}{3} & -\\frac{50}{3} \\\\\n -\\frac{14}{3} & -\\frac{5}{3} & -\\frac{23}{2} & \\frac{15}{2} \\\\\n \\frac{29}{3} & \\frac{13}{6} & \\frac{29}{2} & \\frac{53}{6} \\\\\n -\\frac{37}{6} & \\frac{37}{6} & \\frac{11}{3} & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 7, (25/6), -(59/6)],\n [-(59/6), (11/2), -(49/6), (9/2)],\n [(31/6), -(11/3), (28/3), (20/3)],\n [(17/6), 1, (55/6), -(13/6)]])\nb = np.array([\n [-(49/6), (25/3), -(1/6), (41/6)],\n [-(31/6), (43/6), (10/3), -3],\n [-(9/2), -(35/6), -(31/6), -(13/6)],\n [9, -(31/6), (11/2), -(7/6)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{4,-2,4\\}, \\{3,1,3\\}, \\{-2,2,4\\}}$.", - "Output Answer": [ - "$2 x+3 y+7 z-30=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, -2, 4],\n [3, 1, 3],\n [-2, 2, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -5 & \\frac{23}{9} & -\\frac{14}{9} & -\\frac{13}{3} \\\\\n -\\frac{2}{9} & -\\frac{80}{9} & -\\frac{67}{9} & \\frac{68}{9} \\\\\n -\\frac{10}{3} & \\frac{67}{9} & \\frac{86}{9} & -\\frac{43}{9} \\\\\n \\frac{23}{9} & -9 & -\\frac{19}{9} & \\frac{71}{9} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 1 & \\frac{11}{3} & -9 & -\\frac{29}{9} \\\\\n \\frac{85}{9} & -\\frac{14}{9} & \\frac{1}{3} & -\\frac{56}{9} \\\\\n 8 & -\\frac{14}{9} & \\frac{23}{3} & -\\frac{8}{3} \\\\\n -8 & -\\frac{11}{3} & -\\frac{82}{9} & -\\frac{73}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -6 & -\\frac{10}{9} & \\frac{67}{9} & -\\frac{10}{9} \\\\\n -\\frac{29}{3} & -\\frac{22}{3} & -\\frac{70}{9} & \\frac{124}{9} \\\\\n -\\frac{34}{3} & 9 & \\frac{17}{9} & -\\frac{19}{9} \\\\\n \\frac{95}{9} & -\\frac{16}{3} & 7 & 16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, (23/9), -(14/9), -(13/3)],\n [-(2/9), -(80/9), -(67/9), (68/9)],\n [-(10/3), (67/9), (86/9), -(43/9)],\n [(23/9), -9, -(19/9), (71/9)]])\nb = np.array([\n [1, (11/3), -9, -(29/9)],\n [(85/9), -(14/9), (1/3), -(56/9)],\n [8, -(14/9), (23/3), -(8/3)],\n [-8, -(11/3), -(82/9), -(73/9)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -7 & 3 \\\\\n -1 & 8 \\\\\n -3 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, 3],\n [-1, 8],\n [-3, 7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{39}{4} & 6 & \\frac{13}{4} & -\\frac{35}{16} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{47}{8} & -\\frac{129}{16} & -\\frac{37}{4} & -\\frac{37}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{31}{8} & \\frac{225}{16} & \\frac{25}{2} & \\frac{39}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(39/4), 6, (13/4), -(35/16)]])\nb = np.array([\n [-(47/8), -(129/16), -(37/4), -(37/8)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & 1 \\\\\n 8 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-1-\\sqrt{41}\\right),\\frac{1}{2} \\left(\\sqrt{41}-1\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1],\n [8, -2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 1 & -1 & 0 & 2 \\\\\n 0 & -2 & -1 & -2 \\\\\n -3 & -1 & 1 & 0 \\\\\n 1 & -2 & 0 & -2 \\\\\n -2 & 1 & -3 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 0 & 2 \\\\\n -1 & -2 \\\\\n -1 & 1 \\\\\n 3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 7 & 6 \\\\\n -3 & 1 \\\\\n 0 & -3 \\\\\n -4 & 4 \\\\\n 8 & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, 0, 2],\n [0, -2, -1, -2],\n [-3, -1, 1, 0],\n [1, -2, 0, -2],\n [-2, 1, -3, 2]])\nb = np.array([\n [0, 2],\n [-1, -2],\n [-1, 1],\n [3, 1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{16}{7} & -\\frac{9}{7} & \\frac{13}{7} & \\frac{12}{7} & \\frac{11}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{8}{7} & \\frac{15}{7} & \\frac{10}{7} & \\frac{3}{7} \\\\\n \\frac{13}{7} & -\\frac{11}{7} & -2 & \\frac{12}{7} \\\\\n \\frac{19}{7} & \\frac{2}{7} & 1 & \\frac{12}{7} \\\\\n -\\frac{5}{7} & -\\frac{19}{7} & \\frac{5}{7} & \\frac{12}{7} \\\\\n -\\frac{4}{7} & -1 & -\\frac{4}{7} & \\frac{16}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{102}{49} & -\\frac{60}{7} & \\frac{73}{49} & \\frac{320}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(16/7), -(9/7), (13/7), (12/7), (11/7)]])\nb = np.array([\n [(8/7), (15/7), (10/7), (3/7)],\n [(13/7), -(11/7), -2, (12/7)],\n [(19/7), (2/7), 1, (12/7)],\n [-(5/7), -(19/7), (5/7), (12/7)],\n [-(4/7), -1, -(4/7), (16/7)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{21}{\\pi } \\\\\n -\\frac{17}{\\pi } \\\\\n \\frac{16}{\\pi } \\\\\n -\\frac{3}{\\pi } \\\\\n -\\frac{8}{\\pi } \\\\\n \\frac{7}{\\pi } \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{\\pi } \\\\\n \\frac{8}{\\pi } \\\\\n -\\frac{7}{\\pi } \\\\\n -\\frac{16}{\\pi } \\\\\n \\frac{27}{\\pi } \\\\\n -\\frac{27}{\\pi } \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{878}{\\pi ^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(21/math.pi)],\n [-(17/math.pi)],\n [(16/math.pi)],\n [-(3/math.pi)],\n [-(8/math.pi)],\n [(7/math.pi)]])\nb = np.array([\n [-(13/math.pi)],\n [(8/math.pi)],\n [-(7/math.pi)],\n [-(16/math.pi)],\n [(27/math.pi)],\n [-(27/math.pi)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -2 \\\\\n 0 \\\\\n 2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{13}} \\\\\n -\\frac{2}{\\sqrt{13}} \\\\\n 0 \\\\\n \\frac{2}{\\sqrt{13}} \\\\\n -\\frac{2}{\\sqrt{13}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-2],\n [0],\n [2],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,-4,-4\\}, \\{-5,-2,3\\}, \\{4,-5,-2\\}}$.", - "Output Answer": [ - "$11 x+38 y-3 z+140=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, -4, -4],\n [-5, -2, 3],\n [4, -5, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 4 \\\\\n 5 \\\\\n 2 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{151}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [4],\n [5],\n [2],\n [-9]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 5 & -5 \\\\\n -2 & -6 \\\\\n 4 & 8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 0 & 1 \\\\\n 0 & -8 \\\\\n -6 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 5 & -6 \\\\\n -2 & 2 \\\\\n 10 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -5],\n [-2, -6],\n [4, 8]])\nb = np.array([\n [0, 1],\n [0, -8],\n [-6, 2]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{15}{4} & -\\frac{11}{4} \\\\\n -\\frac{15}{4} & \\frac{49}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{19 x}{8}-\\frac{1065}{32}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/4), -(11/4)],\n [-(15/4), (49/8)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{8}{3}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -2 & -2 \\\\\n -6 & 7 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{8}{3} & \\frac{16}{3} & \\frac{16}{3} \\\\\n 16 & -\\frac{56}{3} & \\frac{80}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, -2],\n [-6, 7, -10]])\nprint(a * -(8/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [1],\n [0]]).squeeze()\nb = np.array([\n [0],\n [0],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & -7 \\\\\n 7 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-16 x+112$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -7],\n [7, 9]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -9 & -3 & 8 & -10 \\\\\n 7 & 6 & -6 & 7 \\\\\n -5 & -6 & 10 & 9 \\\\\n 2 & -8 & 9 & 3 \\\\\n 8 & 9 & 9 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, -3, 8, -10],\n [7, 6, -6, 7],\n [-5, -6, 10, 9],\n [2, -8, 9, 3],\n [8, 9, 9, -3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{3} & -\\frac{13}{3} \\\\\n -4 & \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{3}{38} & -\\frac{39}{152} \\\\\n -\\frac{9}{38} & -\\frac{3}{152} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/3), -(13/3)],\n [-4, (4/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n \\frac{377}{100} & \\frac{849}{100} & \\frac{234}{25} \\\\\n \\frac{69}{20} & \\frac{77}{20} & -\\frac{41}{20} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{149}{20} & \\frac{69}{25} & \\frac{797}{100} \\\\\n \\frac{499}{50} & -\\frac{51}{20} & -\\frac{204}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{561}{50} & \\frac{45}{4} & \\frac{1733}{100} \\\\\n \\frac{1343}{100} & \\frac{13}{10} & -\\frac{1021}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(377/100), (849/100), (234/25)],\n [(69/20), (77/20), -(41/20)]])\nb = np.array([\n [(149/20), (69/25), (797/100)],\n [(499/50), -(51/20), -(204/25)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{91}{32}, \\frac{99}{32}}$ to the line $\\frac{125 x}{32}+\\frac{89 y}{32}-\\frac{27}{16}=0$.", - "Output Answer": [ - "$\\frac{1073}{8 \\sqrt{23546}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(91/32), (99/32)\nline = Poly(((125*x)/32)+((89*y)/32)-(27/16), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{13}{2} & \\frac{9}{2} \\\\\n -\\frac{15}{2} & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{4} \\left(23-3 i \\sqrt{59}\\right),\\frac{1}{4} \\left(23+3 i \\sqrt{59}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2), (9/2)],\n [-(15/2), 5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{23}{3} & 0 \\\\\n -\\frac{19}{3} & \\frac{17}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0,1\\}, \\left\\{\\frac{40}{19},1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/3), 0],\n [-(19/3), (17/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 0 & \\frac{3}{2} \\\\\n -\\frac{5}{2} & 0 \\\\\n -\\frac{1}{2} & -\\frac{3}{2} \\\\\n 3 & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{3}{2} & -1 & -3 & \\frac{5}{2} \\\\\n \\frac{5}{2} & -\\frac{5}{2} & \\frac{3}{2} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{15}{4} & -\\frac{15}{4} & \\frac{9}{4} & \\frac{9}{4} \\\\\n \\frac{15}{4} & \\frac{5}{2} & \\frac{15}{2} & -\\frac{25}{4} \\\\\n -3 & \\frac{17}{4} & -\\frac{3}{4} & -\\frac{7}{2} \\\\\n -\\frac{13}{4} & -\\frac{17}{4} & -\\frac{33}{4} & \\frac{33}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, (3/2)],\n [-(5/2), 0],\n [-(1/2), -(3/2)],\n [3, (1/2)]])\nb = np.array([\n [-(3/2), -1, -3, (5/2)],\n [(5/2), -(5/2), (3/2), (3/2)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n \\frac{11}{4} & -\\frac{3}{4} & \\frac{11}{4} & \\frac{3}{4} \\\\\n \\frac{9}{4} & \\frac{11}{4} & \\frac{3}{2} & -\\frac{3}{2} \\\\\n -\\frac{5}{4} & -\\frac{5}{4} & -2 & \\frac{11}{4} \\\\\n \\frac{1}{4} & \\frac{5}{4} & -\\frac{11}{4} & \\frac{5}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{3}{4} \\\\\n \\frac{1}{4} \\\\\n \\frac{3}{4} \\\\\n -\\frac{11}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{15}{8} \\\\\n \\frac{61}{8} \\\\\n -\\frac{165}{16} \\\\\n -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/4), -(3/4), (11/4), (3/4)],\n [(9/4), (11/4), (3/2), -(3/2)],\n [-(5/4), -(5/4), -2, (11/4)],\n [(1/4), (5/4), -(11/4), (5/4)]])\nb = np.array([\n [(3/4)],\n [(1/4)],\n [(3/4)],\n [-(11/4)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{155}{32}, \\frac{27}{32}}$ to the line $\\frac{67 x}{16}-\\frac{103 y}{32}+\\frac{47}{16}=0$.", - "Output Answer": [ - "$\\frac{20543}{32 \\sqrt{28565}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(155/32), (27/32)\nline = Poly(((67*x)/16)-((103*y)/32)+(47/16), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & -7 \\\\\n -8 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+x-76$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -7],\n [-8, -5]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 2 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -7 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-75$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [2],\n [7]])\nb = np.array([\n [-6],\n [-7],\n [-7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{3} \\\\\n -\\frac{28}{3} \\\\\n -1 \\\\\n 2 \\\\\n -8 \\\\\n \\frac{17}{3} \\\\\n \\frac{16}{3} \\\\\n \\frac{22}{3} \\\\\n \\frac{19}{3} \\\\\n -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{23}{3} \\\\\n -10 \\\\\n -\\frac{5}{3} \\\\\n -3 \\\\\n \\frac{16}{3} \\\\\n \\frac{19}{3} \\\\\n -\\frac{26}{3} \\\\\n 10 \\\\\n \\frac{17}{3} \\\\\n \\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{4378}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/3)],\n [-(28/3)],\n [-1],\n [2],\n [-8],\n [(17/3)],\n [(16/3)],\n [(22/3)],\n [(19/3)],\n [-(14/3)]])\nb = np.array([\n [-(23/3)],\n [-10],\n [-(5/3)],\n [-3],\n [(16/3)],\n [(19/3)],\n [-(26/3)],\n [10],\n [(17/3)],\n [(1/3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{15}{2} & \\frac{23}{8} & -\\frac{21}{4} \\\\\n -\\frac{53}{8} & \\frac{3}{2} & -\\frac{55}{8} \\\\\n -\\frac{25}{8} & -\\frac{41}{8} & \\frac{17}{8} \\\\\n \\frac{23}{8} & \\frac{33}{4} & -\\frac{73}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/2), (23/8), -(21/4)],\n [-(53/8), (3/2), -(55/8)],\n [-(25/8), -(41/8), (17/8)],\n [(23/8), (33/4), -(73/8)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 0 & -2 & 2 & -2 & -2 \\\\\n 1 & -3 & -1 & 0 & 0 \\\\\n 3 & 1 & -2 & -2 & 3 \\\\\n -2 & 1 & 3 & -3 & 0 \\\\\n 2 & 0 & -1 & -2 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -5 \\\\\n -4 \\\\\n 6 \\\\\n -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2, 2, -2, -2],\n [1, -3, -1, 0, 0],\n [3, 1, -2, -2, 3],\n [-2, 1, 3, -3, 0],\n [2, 0, -1, -2, -3]])\nb = np.array([\n [-1],\n [1],\n [1],\n [0],\n [0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n 1 \\\\\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{14}} \\\\\n -\\sqrt{\\frac{2}{7}} \\\\\n \\frac{1}{\\sqrt{14}} \\\\\n \\sqrt{\\frac{2}{7}} \\\\\n \\sqrt{\\frac{2}{7}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-2],\n [1],\n [2],\n [2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -7 \\\\\n 8 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 4 \\\\\n -3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-43$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-7],\n [8],\n [9]])\nb = np.array([\n [0],\n [4],\n [-3],\n [1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\pi \\\\\n 3 \\pi \\\\\n 2 \\pi \\\\\n 2 \\pi \\\\\n -\\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\pi \\\\\n -2 \\pi \\\\\n -2 \\pi \\\\\n -2 \\pi \\\\\n -2 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-14 \\pi ^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-2*math.pi],\n [3*math.pi],\n [2*math.pi],\n [2*math.pi],\n [-math.pi]])\nb = np.array([\n [math.pi],\n [-2*math.pi],\n [-2*math.pi],\n [-2*math.pi],\n [-2*math.pi]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 1 & 1 \\\\\n 1 & 1 & -3 \\\\\n -3 & -3 & -3 \\\\\n 1 & 0 & 3 \\\\\n -2 & -3 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.73 \\\\\n -2.1 \\\\\n 0.49 \\\\\n -0.28 \\\\\n 2.95 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.404 \\\\\n -1.811 \\\\\n 0.125 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, 1],\n [1, 1, -3],\n [-3, -3, -3],\n [1, 0, 3],\n [-2, -3, -1]])\nb = np.array([\n [2.73],\n [-2.1],\n [0.49],\n [-0.28],\n [2.95]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -3+2 i & -1-4 i & -4-i \\\\\n -3 i & 4-4 i & -5+2 i \\\\\n 4+4 i & 3-i & -1-5 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -19-29 i & -22-i & 26+34 i \\\\\n -34-15 i & -25-18 i & 63 i \\\\\n -7-37 i & 12-50 i & -49+i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3+2j, -1-4j, -4- 1j],\n [-3j, 4-4j, -5+2j],\n [4+4j, 3- 1j, -1-5j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{10}{3}, -\\frac{14}{3}, \\frac{13}{3}}$ to the plane $\\frac{5 x}{3}-\\frac{y}{3}+\\frac{10 z}{3}-\\frac{7}{3}=0$.", - "Output Answer": [ - "$\\frac{173}{9 \\sqrt{14}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (10/3), -(14/3), (13/3)\nplane = Poly(((5*x)/3)-(y/3)+((10*z)/3)-(7/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -3 \\\\\n -1 \\\\\n -2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{15}} \\\\\n -\\sqrt{\\frac{3}{5}} \\\\\n -\\frac{1}{\\sqrt{15}} \\\\\n -\\frac{2}{\\sqrt{15}} \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-3],\n [-1],\n [-2],\n [0]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{11}{4},-\\frac{3}{4},\\frac{1}{4}\\right\\}, \\left\\{\\frac{11}{4},\\frac{5}{2},\\frac{11}{4}\\right\\}, \\left\\{-\\frac{1}{4},\\frac{1}{4},-\\frac{9}{4}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{11}{\\sqrt{131}},-\\frac{3}{\\sqrt{131}},\\frac{1}{\\sqrt{131}}\\right\\}, \\left\\{\\frac{319}{21 \\sqrt{10218}},\\frac{808 \\sqrt{\\frac{2}{5109}}}{21},\\frac{103 \\sqrt{\\frac{13}{786}}}{21}\\right\\}, \\left\\{\\frac{43}{21 \\sqrt{78}},\\frac{55 \\sqrt{\\frac{2}{39}}}{21},-\\frac{11 \\sqrt{\\frac{13}{6}}}{21}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack((((11/4), -(3/4), (1/4)), ((11/4), (5/2), (11/4)), (-(1/4), (1/4), -(9/4))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{2}{3},-\\frac{14}{3},-\\frac{10}{3}\\right\\}, \\left\\{\\frac{8}{3},3,3\\right\\}, \\left\\{\\frac{13}{3},-\\frac{5}{3},\\frac{2}{3}\\right\\}}$.", - "Output Answer": [ - "$105 x+137 y-199 z-94=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(2/3), -(14/3), -(10/3)],\n [(8/3), 3, 3],\n [(13/3), -(5/3), (2/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 5 & 1 & 5 \\\\\n 7 & 2 & -4 \\\\\n -2 & -5 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, 1, 5],\n [7, 2, -4],\n [-2, -5, 0]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & -4 & 6 \\\\\n 8 & 9 & 6 \\\\\n -9 & -6 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{2.42,3.79\\, -8.264 i,3.79\\, +8.264 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -4, 6],\n [8, 9, 6],\n [-9, -6, -5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & 0 & -9 \\\\\n 10 & -7 & -10 \\\\\n -1 & -8 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.412,-1.245,1.\\}, \\{0.551,1.348,1.\\}, \\{1.119,0.24,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 0, -9],\n [10, -7, -10],\n [-1, -8, 1]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,-3,-3\\}, \\{-4,3,4\\}, \\{-4,-2,-2\\}}$.", - "Output Answer": [ - "$x+4=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, -3, -3],\n [-4, 3, 4],\n [-4, -2, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-1, -4}$ to the line $-2 x+\\frac{9 y}{2}+\\frac{7}{2}=0$.", - "Output Answer": [ - "$\\frac{25}{\\sqrt{97}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -1, -4\nline = Poly(-2*x+((9*y)/2)+(7/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-14$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [2]])\nb = np.array([\n [0],\n [-7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{317}{50} \\\\\n \\frac{9}{10} \\\\\n -\\frac{229}{50} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{169}{20} \\\\\n \\frac{191}{100} \\\\\n -\\frac{159}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{29429}{5000} \\\\\n \\frac{294311}{5000} \\\\\n \\frac{24643}{1250} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(317/50)],\n [(9/10)],\n [-(229/50)]])\nb = np.array([\n [-(169/20)],\n [(191/100)],\n [-(159/50)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n 9 & -10 & 5 & 5 \\\\\n -8 & -3 & 6 & -1 \\\\\n 2 & -5 & -5 & -10 \\\\\n 1 & 3 & -1 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -10, 5, 5],\n [-8, -3, 6, -1],\n [2, -5, -5, -10],\n [1, 3, -1, 6]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5. \\\\\n -8.2 \\\\\n 9.7 \\\\\n 8.4 \\\\\n 9.9 \\\\\n -9.2 \\\\\n -7.2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0.7 \\\\\n -3.8 \\\\\n -2.4 \\\\\n -5.5 \\\\\n 3.2 \\\\\n -4.8 \\\\\n -2.9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$21.7764$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5.],\n [-8.2],\n [9.7],\n [8.4],\n [9.9],\n [-9.2],\n [-7.2]])\nb = np.array([\n [0.7],\n [-3.8],\n [-2.4],\n [-5.5],\n [3.2],\n [-4.8],\n [-2.9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -1 & 7 & -2 \\\\\n 7 & -8 & 1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -6 & 0 & 6 \\\\\n 2 & -4 & -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 5 & 7 & -8 \\\\\n 5 & -4 & 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 7, -2],\n [7, -8, 1]])\nb = np.array([\n [-6, 0, 6],\n [2, -4, -10]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -2 & \\frac{3}{2} & -2 & 2 & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{5}{2} & -1 & -\\frac{3}{2} & -\\frac{3}{2} \\\\\n 2 & \\frac{1}{2} & -\\frac{5}{2} & \\frac{1}{2} \\\\\n -\\frac{1}{2} & -2 & -3 & 2 \\\\\n -\\frac{1}{2} & \\frac{3}{2} & 3 & -\\frac{1}{2} \\\\\n -\\frac{5}{2} & -1 & 1 & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{27}{4} & \\frac{37}{4} & \\frac{47}{4} & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, (3/2), -2, 2, (1/2)]])\nb = np.array([\n [-(5/2), -1, -(3/2), -(3/2)],\n [2, (1/2), -(5/2), (1/2)],\n [-(1/2), -2, -3, 2],\n [-(1/2), (3/2), 3, -(1/2)],\n [-(5/2), -1, 1, -(5/2)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 2 & -9 & -7 & 2 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.,0.,0.,1.,0.\\}, \\{4.,0.,0.,0.,1.\\}, \\{7.,0.,2.,0.,0.\\}, \\{9.,2.,0.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, -9, -7, 2, -8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & -6 \\\\\n -8 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{16} \\left(3-\\sqrt{201}\\right),1\\right\\}, \\left\\{\\frac{1}{16} \\left(3+\\sqrt{201}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -6],\n [-8, 6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{1}{8} & -\\frac{27}{8} & \\frac{47}{8} & -9 & -10 \\\\\n \\frac{55}{8} & -\\frac{27}{8} & -\\frac{25}{8} & -\\frac{55}{8} & -\\frac{7}{4} \\\\\n \\frac{27}{4} & \\frac{39}{8} & -2 & \\frac{1}{2} & -\\frac{3}{2} \\\\\n -\\frac{73}{8} & -\\frac{15}{4} & \\frac{13}{4} & 2 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/8), -(27/8), (47/8), -9, -10],\n [(55/8), -(27/8), -(25/8), -(55/8), -(7/4)],\n [(27/4), (39/8), -2, (1/2), -(3/2)],\n [-(73/8), -(15/4), (13/4), 2, 6]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -8 \\\\\n -3 \\\\\n 0 \\\\\n 5 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-8],\n [-3],\n [0],\n [5],\n [4]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{7}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & 2 & 4 \\\\\n 10 & 1 & 0 \\\\\n -2 & -8 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{4}{7} & \\frac{2}{7} & \\frac{4}{7} \\\\\n \\frac{10}{7} & \\frac{1}{7} & 0 \\\\\n -\\frac{2}{7} & -\\frac{8}{7} & -\\frac{3}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 2, 4],\n [10, 1, 0],\n [-2, -8, -3]])\nprint(a * (1/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -3 & -1 & 2 & 2 \\\\\n 0 & -2 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n -3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -3 \\\\\n 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1, 2, 2],\n [0, -2, -1, 2]])\nb = np.array([\n [0],\n [-1],\n [-3],\n [1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{5}{3}, -5}$ to the line $-\\frac{x}{3}-\\frac{7 y}{3}-\\frac{2}{3}=0$.", - "Output Answer": [ - "$\\frac{47 \\sqrt{2}}{15}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (5/3), -5\nline = Poly(-(x/3)-((7*y)/3)-(2/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -\\frac{19}{5} \\\\\n \\frac{39}{5} \\\\\n -1 \\\\\n -8 \\\\\n -\\frac{14}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n \\frac{1}{5} \\\\\n \\frac{4}{5} \\\\\n -\\frac{31}{5} \\\\\n \\frac{4}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1358}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-(19/5)],\n [(39/5)],\n [-1],\n [-8],\n [-(14/5)]])\nb = np.array([\n [1],\n [1],\n [(1/5)],\n [(4/5)],\n [-(31/5)],\n [(4/5)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -4 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -2 \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -18 \\\\\n -42 \\\\\n -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-4],\n [3]])\nb = np.array([\n [4],\n [-2],\n [6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 6 & 9 \\\\\n 1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 2 & 10 \\\\\n 2 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 8 & 19 \\\\\n 3 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 9],\n [1, 2]])\nb = np.array([\n [2, 10],\n [2, -4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{35}{6} \\\\\n \\frac{55}{6} \\\\\n -\\frac{37}{6} \\\\\n -\\frac{17}{2} \\\\\n 1 \\\\\n -6 \\\\\n -\\frac{47}{6} \\\\\n -\\frac{28}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{28}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(35/6)],\n [(55/6)],\n [-(37/6)],\n [-(17/2)],\n [1],\n [-6],\n [-(47/6)],\n [-(28/3)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{11}{8} & -\\frac{21}{16} & \\frac{5}{8} & -\\frac{15}{16} & -\\frac{23}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{11}{4} & 2 \\\\\n -\\frac{5}{8} & -\\frac{35}{16} \\\\\n 1 & -\\frac{15}{16} \\\\\n -\\frac{9}{8} & -\\frac{43}{16} \\\\\n -\\frac{23}{16} & \\frac{17}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{2137}{256} & \\frac{135}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/8), -(21/16), (5/8), -(15/16), -(23/16)]])\nb = np.array([\n [-(11/4), 2],\n [-(5/8), -(35/16)],\n [1, -(15/16)],\n [-(9/8), -(43/16)],\n [-(23/16), (17/16)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{4}{3},-\\frac{4}{3},-\\frac{4}{3}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [-2]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & -3 & 2 \\\\\n -5 & 5 & -4 \\\\\n 1 & 8 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, -3, 2],\n [-5, 5, -4],\n [1, 8, 0]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{27}{10} \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(27/10)],\n [-9]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{14}{9} \\\\\n \\frac{58}{9} \\\\\n -\\frac{38}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{110}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(14/9)],\n [(58/9)],\n [-(38/9)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{8}{7} & \\frac{43}{7} \\\\\n -\\frac{58}{7} & -\\frac{68}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{33}{7} & -\\frac{62}{7} \\\\\n \\frac{10}{7} & -\\frac{50}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{41}{7} & -\\frac{19}{7} \\\\\n -\\frac{48}{7} & -\\frac{118}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/7), (43/7)],\n [-(58/7), -(68/7)]])\nb = np.array([\n [-(33/7), -(62/7)],\n [(10/7), -(50/7)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{43}{5} \\\\\n -10 \\\\\n 7 \\\\\n -\\frac{14}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{\\frac{1154}{5}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(43/5)],\n [-10],\n [7],\n [-(14/5)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{11}{4} & \\frac{5}{2} & -3 \\\\\n \\frac{17}{4} & -\\frac{9}{4} & 0 \\\\\n -\\frac{1}{4} & -\\frac{17}{4} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{180}{443} & \\frac{208}{443} & -\\frac{216}{443} \\\\\n -\\frac{340}{443} & \\frac{196}{443} & -\\frac{408}{443} \\\\\n -\\frac{596}{443} & \\frac{354}{443} & -\\frac{538}{443} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/4), (5/2), -3],\n [(17/4), -(9/4), 0],\n [-(1/4), -(17/4), (5/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 9 \\\\\n 8 \\\\\n 5 \\\\\n 3 \\\\\n 8 \\\\\n 0 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$49$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [9],\n [8],\n [5],\n [3],\n [8],\n [0],\n [8]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 2 \\\\\n -2 \\\\\n 3 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{3}} \\\\\n \\frac{2}{3 \\sqrt{3}} \\\\\n -\\frac{2}{3 \\sqrt{3}} \\\\\n \\frac{1}{\\sqrt{3}} \\\\\n -\\frac{1}{3 \\sqrt{3}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [2],\n [-2],\n [3],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{20}{3} & -\\frac{17}{6} & \\frac{29}{6} & -\\frac{17}{6} \\\\\n -\\frac{37}{6} & -10 & \\frac{8}{3} & \\frac{35}{6} \\\\\n \\frac{3}{2} & \\frac{23}{3} & -\\frac{5}{6} & -\\frac{23}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{15}{2} & \\frac{29}{3} & -\\frac{55}{6} & \\frac{5}{3} \\\\\n \\frac{5}{2} & 10 & \\frac{1}{6} & \\frac{11}{6} \\\\\n -\\frac{35}{6} & \\frac{4}{3} & \\frac{13}{3} & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{5}{6} & \\frac{41}{6} & -\\frac{13}{3} & -\\frac{7}{6} \\\\\n -\\frac{11}{3} & 0 & \\frac{17}{6} & \\frac{23}{3} \\\\\n -\\frac{13}{3} & 9 & \\frac{7}{2} & -\\frac{25}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/3), -(17/6), (29/6), -(17/6)],\n [-(37/6), -10, (8/3), (35/6)],\n [(3/2), (23/3), -(5/6), -(23/6)]])\nb = np.array([\n [(15/2), (29/3), -(55/6), (5/3)],\n [(5/2), 10, (1/6), (11/6)],\n [-(35/6), (4/3), (13/3), -(9/2)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{4} \\\\\n \\frac{7}{4} \\\\\n \\frac{7}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{\\sqrt{107}} \\\\\n \\frac{7}{\\sqrt{107}} \\\\\n \\frac{7}{\\sqrt{107}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/4)],\n [(7/4)],\n [(7/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{29}{6} & \\frac{17}{2} \\\\\n \\frac{59}{6} & -\\frac{25}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{79 x}{6}-\\frac{1559}{36}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/6), (17/2)],\n [(59/6), -(25/3)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -9 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 9 \\\\\n -16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-9]])\nb = np.array([\n [1],\n [7]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & -1 & 0 \\\\\n -2 & 2 & -3 \\\\\n -2 & 2 & -2 \\\\\n -2 & 0 & 2 \\\\\n 2 & 2 & 3 \\\\\n -1 & -2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.91 \\\\\n -1.42 \\\\\n -0.69 \\\\\n -1.28 \\\\\n -1.21 \\\\\n 2.09 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.131 \\\\\n -0.673 \\\\\n -0.212 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1, 0],\n [-2, 2, -3],\n [-2, 2, -2],\n [-2, 0, 2],\n [2, 2, 3],\n [-1, -2, -3]])\nb = np.array([\n [0.91],\n [-1.42],\n [-0.69],\n [-1.28],\n [-1.21],\n [2.09]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{40}{9} \\\\\n -\\frac{34}{9} \\\\\n \\frac{19}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{83}{9} \\\\\n \\frac{4}{3} \\\\\n -\\frac{73}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1798}{81} \\\\\n \\frac{1811}{81} \\\\\n \\frac{2342}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(40/9)],\n [-(34/9)],\n [(19/3)]])\nb = np.array([\n [(83/9)],\n [(4/3)],\n [-(73/9)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,3,-4\\}, \\{-1,-5,3\\}, \\{-3,-4,-1\\}}$.", - "Output Answer": [ - "$25 x-22 y-18 z-31=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, 3, -4],\n [-1, -5, 3],\n [-3, -4, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -1 \\\\\n 4 \\\\\n -9 \\\\\n 6 \\\\\n -1 \\\\\n 6 \\\\\n 1 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 6 \\\\\n 4 \\\\\n 5 \\\\\n 3 \\\\\n -1 \\\\\n 3 \\\\\n -4 \\\\\n -10 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{562}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-1],\n [4],\n [-9],\n [6],\n [-1],\n [6],\n [1],\n [-3],\n [2]])\nb = np.array([\n [-3],\n [6],\n [4],\n [5],\n [3],\n [-1],\n [3],\n [-4],\n [-10],\n [-7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & -1 \\\\\n \\frac{3}{2} & 1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{3}{4} & \\frac{1}{2} \\\\\n -\\frac{3}{4} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), -1],\n [(3/2), 1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -7 & -7 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -8 & -7 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -15 & -14 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -7, 2]])\nb = np.array([\n [-8, -7, -4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -3 & 3+i & -4-2 i \\\\\n 4+2 i & -2+2 i & 2-2 i \\\\\n -2+3 i & 3+i & -3+5 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 33+2 i & -27-9 i & 42-12 i \\\\\n -22+8 i & 18-2 i & -8+8 i \\\\\n 7-18 i & -31+23 i & 6-42 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 3+ 1j, -4-2j],\n [4+2j, -2+2j, 2-2j],\n [-2+3j, 3+ 1j, -3+5j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -9 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 7 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1 \\\\\n -2 \\\\\n 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-9],\n [2]])\nb = np.array([\n [-7],\n [7],\n [8]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n 0 & \\frac{15}{2} & -6 & -5 & -9 \\\\\n 10 & -\\frac{7}{2} & -\\frac{17}{2} & -7 & -\\frac{15}{2} \\\\\n \\frac{13}{2} & 10 & 1 & -9 & -\\frac{13}{2} \\\\\n -\\frac{15}{2} & 1 & -\\frac{13}{2} & -\\frac{15}{2} & \\frac{1}{2} \\\\\n -2 & 8 & \\frac{9}{2} & -\\frac{15}{2} & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, (15/2), -6, -5, -9],\n [10, -(7/2), -(17/2), -7, -(15/2)],\n [(13/2), 10, 1, -9, -(13/2)],\n [-(15/2), 1, -(13/2), -(15/2), (1/2)],\n [-2, 8, (9/2), -(15/2), -8]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -6 & 9 & -6 & -9 & -6 \\\\\n 10 & 4 & 10 & -4 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 1 & 0 & -\\frac{2}{19} \\\\\n 0 & 1 & 0 & -1 & -\\frac{14}{19} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-6, 9, -6, -9, -6],\n [10, 4, 10, -4, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & -2 & -2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -2 & 2 & 2 & 2 \\\\\n 2 & -2 & -2 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1]])\nb = np.array([\n [2, -2, -2, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{ccc}\n 1 & 2 & 0 \\\\\n 0 & -1 & 0 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n e & \\frac{e^2-1}{e} & 0 \\\\\n 0 & \\frac{1}{e} & 0 \\\\\n 0 & 0 & e \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [1, 2, 0],\n [0, -1, 0],\n [0, 0, 1]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{25}{7}, -\\frac{33}{7}}$ to the line $-\\frac{32 x}{7}-\\frac{8 y}{7}-\\frac{1}{7}=0$.", - "Output Answer": [ - "$\\frac{151}{8 \\sqrt{17}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(25/7), -(33/7)\nline = Poly(-((32*x)/7)-((8*y)/7)-(1/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n \\frac{7}{4} & 1 & \\frac{5}{4} & \\frac{5}{2} \\\\\n -2 & \\frac{1}{2} & -1 & \\frac{5}{4} \\\\\n \\frac{3}{2} & \\frac{3}{2} & \\frac{3}{4} & -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{5}{4} \\\\\n 1 \\\\\n -2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{11}{16} \\\\\n 0 \\\\\n \\frac{15}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/4), 1, (5/4), (5/2)],\n [-2, (1/2), -1, (5/4)],\n [(3/2), (3/2), (3/4), -(3/4)]])\nb = np.array([\n [(5/4)],\n [1],\n [-2],\n [0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} \\\\\n -\\frac{3}{2} & -1 & \\frac{5}{2} \\\\\n 0 & 0 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & \\frac{1}{4} & -\\frac{7}{4} \\\\\n \\frac{3}{4} & \\frac{7}{4} & -7 \\\\\n 0 & 0 & \\frac{9}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), -(1/2), (1/2)],\n [-(3/2), -1, (5/2)],\n [0, 0, -(3/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -4 & -\\frac{1}{9} \\\\\n \\frac{20}{9} & -\\frac{25}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{45}{184} & \\frac{9}{920} \\\\\n -\\frac{9}{46} & -\\frac{81}{230} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -(1/9)],\n [(20/9), -(25/9)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 2 & \\frac{7}{3} & 2 & \\frac{2}{3} \\\\\n \\frac{5}{3} & -1 & -2 & 0 \\\\\n -\\frac{1}{3} & -\\frac{7}{3} & -1 & -\\frac{1}{3} \\\\\n -3 & \\frac{5}{3} & -\\frac{4}{3} & -\\frac{1}{3} \\\\\n \\frac{8}{3} & -\\frac{1}{3} & \\frac{5}{3} & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{8}{3} & 2 & \\frac{2}{3} & \\frac{5}{3} \\\\\n 0 & \\frac{2}{3} & -\\frac{8}{3} & \\frac{2}{3} \\\\\n 1 & \\frac{5}{3} & 3 & -\\frac{8}{3} \\\\\n \\frac{8}{3} & 2 & -1 & \\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{14}{9} & \\frac{92}{9} & \\frac{4}{9} & \\frac{10}{9} \\\\\n -\\frac{58}{9} & -\\frac{2}{3} & -\\frac{20}{9} & \\frac{67}{9} \\\\\n -1 & -\\frac{41}{9} & \\frac{10}{3} & -\\frac{2}{9} \\\\\n \\frac{52}{9} & -\\frac{70}{9} & -\\frac{91}{9} & -\\frac{10}{9} \\\\\n -\\frac{97}{9} & \\frac{35}{9} & \\frac{29}{3} & -\\frac{44}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, (7/3), 2, (2/3)],\n [(5/3), -1, -2, 0],\n [-(1/3), -(7/3), -1, -(1/3)],\n [-3, (5/3), -(4/3), -(1/3)],\n [(8/3), -(1/3), (5/3), -2]])\nb = np.array([\n [-(8/3), 2, (2/3), (5/3)],\n [0, (2/3), -(8/3), (2/3)],\n [1, (5/3), 3, -(8/3)],\n [(8/3), 2, -1, (7/3)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{2}-\\frac{9 i}{2} & -\\frac{i}{2} \\\\\n 4+\\frac{i}{2} & \\frac{1}{2}+i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{55}{4}+\\frac{41 i}{2} & -\\frac{7}{4}+i \\\\\n -\\frac{25}{4}-15 i & -\\frac{1}{2}-i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2)-((9j)/2), -(1j/2)],\n [4+(1j/2), (1/2)+ 1j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}+\\cot ^{-1}(8)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [9]]).squeeze()\nb = np.array([\n [4],\n [-4]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 2 \\\\\n 1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{11}} \\\\\n -\\frac{1}{\\sqrt{11}} \\\\\n \\frac{2}{\\sqrt{11}} \\\\\n \\frac{1}{\\sqrt{11}} \\\\\n -\\frac{2}{\\sqrt{11}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [2],\n [1],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{55}{8} \\\\\n -\\frac{13}{2} \\\\\n -\\frac{1}{4} \\\\\n \\frac{61}{8} \\\\\n -\\frac{35}{8} \\\\\n \\frac{53}{8} \\\\\n -\\frac{33}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{4461}}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(55/8)],\n [-(13/2)],\n [-(1/4)],\n [(61/8)],\n [-(35/8)],\n [(53/8)],\n [-(33/4)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 10 \\\\\n -7 \\\\\n 10 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 9 \\\\\n -9 \\\\\n -4 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{203}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [10],\n [-7],\n [10],\n [4]])\nb = np.array([\n [-2],\n [9],\n [-9],\n [-4],\n [3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(2 \\sqrt{3}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [-1],\n [0],\n [-1],\n [0]]).squeeze()\nb = np.array([\n [1],\n [0],\n [-1],\n [0],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n \\frac{35}{4} & -\\frac{87}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(35/4), -(87/16)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 2 & 0 \\\\\n -6 & 3 \\\\\n -7 & -4 \\\\\n 10 & 4 \\\\\n 8 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, 0],\n [-6, 3],\n [-7, -4],\n [10, 4],\n [8, -8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{8} \\\\\n -\\frac{23}{8} \\\\\n \\frac{15}{8} \\\\\n -\\frac{11}{4} \\\\\n -\\frac{21}{8} \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{\\sqrt{\\frac{3}{146}}}{2} \\\\\n -\\frac{23}{2 \\sqrt{438}} \\\\\n \\frac{5 \\sqrt{\\frac{3}{146}}}{2} \\\\\n -\\frac{11}{\\sqrt{438}} \\\\\n -\\frac{7 \\sqrt{\\frac{3}{146}}}{2} \\\\\n 2 \\sqrt{\\frac{2}{219}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/8)],\n [-(23/8)],\n [(15/8)],\n [-(11/4)],\n [-(21/8)],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -1 & 3 & -3 & 0 & 2 \\\\\n 3 & 1 & 0 & -2 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 1 & 1 & -2 & -2 & -1 \\\\\n 0 & -3 & 3 & -1 & 3 \\\\\n -1 & 0 & 0 & -2 & 0 \\\\\n -1 & -3 & 2 & 1 & -3 \\\\\n 1 & -2 & -1 & -1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 4 & -14 & 9 & 3 & 6 \\\\\n 7 & 2 & -9 & -11 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, -3, 0, 2],\n [3, 1, 0, -2, 2]])\nb = np.array([\n [1, 1, -2, -2, -1],\n [0, -3, 3, -1, 3],\n [-1, 0, 0, -2, 0],\n [-1, -3, 2, 1, -3],\n [1, -2, -1, -1, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 7 & -3 & -9 & -9 \\\\\n 1 & -2 & 9 & 4 \\\\\n 6 & 4 & 2 & -10 \\\\\n 9 & 10 & -1 & -9 \\\\\n -4 & -10 & 5 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, -3, -9, -9],\n [1, -2, 9, 4],\n [6, 4, 2, -10],\n [9, 10, -1, -9],\n [-4, -10, 5, 2]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 6 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 0 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 6 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -1]])\nb = np.array([\n [0, 7]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 8 \\\\\n 3 \\\\\n 0 \\\\\n -6 \\\\\n 8 \\\\\n 5 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [8],\n [3],\n [0],\n [-6],\n [8],\n [5],\n [7]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-3,-\\frac{7}{2},\\frac{1}{2}\\right\\}, \\left\\{4,\\frac{7}{2},\\frac{7}{2}\\right\\}, \\left\\{4,-\\frac{5}{2},2\\right\\}}$.", - "Output Answer": [ - "$10 x+14 y-56 z+107=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, -(7/2), (1/2)],\n [4, (7/2), (7/2)],\n [4, -(5/2), 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -\\frac{11}{3} \\\\\n -\\frac{28}{3} \\\\\n -6 \\\\\n -\\frac{28}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{\\frac{674}{3}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-(11/3)],\n [-(28/3)],\n [-6],\n [-(28/3)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -9 & 3 \\\\\n 5 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{5} \\left(-5-2 \\sqrt{10}\\right),1\\right\\}, \\left\\{\\frac{1}{5} \\left(2 \\sqrt{10}-5\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 3],\n [5, 1]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{64}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -10 & 5 & -7 & 3 \\\\\n 7 & -2 & 10 & -8 \\\\\n 2 & 1 & -2 & -9 \\\\\n -7 & -8 & -2 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{15}{32} & \\frac{15}{64} & -\\frac{21}{64} & \\frac{9}{64} \\\\\n \\frac{21}{64} & -\\frac{3}{32} & \\frac{15}{32} & -\\frac{3}{8} \\\\\n \\frac{3}{32} & \\frac{3}{64} & -\\frac{3}{32} & -\\frac{27}{64} \\\\\n -\\frac{21}{64} & -\\frac{3}{8} & -\\frac{3}{32} & -\\frac{15}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 5, -7, 3],\n [7, -2, 10, -8],\n [2, 1, -2, -9],\n [-7, -8, -2, -5]])\nprint(a * (3/64))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{24}{7} & -\\frac{50}{7} & \\frac{5}{7} \\\\\n \\frac{69}{7} & \\frac{39}{7} & \\frac{34}{7} \\\\\n \\frac{32}{7} & 2 & \\frac{16}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{31 x^2}{7}-\\frac{2118 x}{49}-\\frac{4162}{343}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(24/7), -(50/7), (5/7)],\n [(69/7), (39/7), (34/7)],\n [(32/7), 2, (16/7)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{2}{7}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [1],\n [0],\n [1],\n [1],\n [0],\n [1],\n [-1]]).squeeze()\nb = np.array([\n [-1],\n [-1],\n [1],\n [-1],\n [-1],\n [-1],\n [0],\n [1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{11}{5},-\\frac{7}{5},\\frac{2}{5}\\right\\}, \\left\\{-\\frac{11}{5},\\frac{4}{5},-\\frac{7}{5}\\right\\}, \\left\\{\\frac{13}{5},-3,\\frac{6}{5}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{11}{\\sqrt{174}},-\\frac{7}{\\sqrt{174}},\\sqrt{\\frac{2}{87}}\\right\\}, \\left\\{-\\frac{1045}{\\sqrt{4545402}},\\frac{1249}{\\sqrt{4545402}},-688 \\sqrt{\\frac{2}{2272701}}\\right\\}, \\left\\{\\frac{41}{\\sqrt{26123}},-\\frac{99}{\\sqrt{26123}},-\\frac{121}{\\sqrt{26123}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-(11/5), -(7/5), (2/5)), (-(11/5), (4/5), -(7/5)), ((13/5), -3, (6/5))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 0 & 0 \\\\\n -3 & 1 & -2 \\\\\n -3 & -2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0, 0],\n [-3, 1, -2],\n [-3, -2, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{4,-4,5\\}, \\{3,-1,3\\}, \\{5,-4,1\\}}$.", - "Output Answer": [ - "$4 x+2 y+z-13=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, -4, 5],\n [3, -1, 3],\n [5, -4, 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{2} \\\\\n -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/2)],\n [-(17/2)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 2 & 2 & 0 & 1 & 2 \\\\\n -1 & 3 & 0 & -3 & 1 \\\\\n 0 & 3 & -2 & 0 & -2 \\\\\n -2 & -3 & -2 & 1 & -3 \\\\\n 0 & 3 & 2 & -3 & -2 \\\\\n 3 & -3 & 1 & -2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.75 \\\\\n 0.58 \\\\\n -0.73 \\\\\n 2.92 \\\\\n 2.36 \\\\\n 2.96 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.2 \\\\\n -0.211 \\\\\n -0.006 \\\\\n -0.44 \\\\\n -0.45 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, 0, 1, 2],\n [-1, 3, 0, -3, 1],\n [0, 3, -2, 0, -2],\n [-2, -3, -2, 1, -3],\n [0, 3, 2, -3, -2],\n [3, -3, 1, -2, -2]])\nb = np.array([\n [0.75],\n [0.58],\n [-0.73],\n [2.92],\n [2.36],\n [2.96]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -4 & -\\frac{3}{2} & -1 \\\\\n \\frac{5}{2} & -\\frac{7}{2} & \\frac{3}{2} \\\\\n 1 & 1 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{10}{77} & \\frac{26}{231} & \\frac{46}{231} \\\\\n -\\frac{2}{11} & -\\frac{8}{33} & -\\frac{4}{33} \\\\\n -\\frac{16}{77} & -\\frac{20}{231} & -\\frac{142}{231} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -(3/2), -1],\n [(5/2), -(7/2), (3/2)],\n [1, 1, -(3/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -4 & -7 & 3 \\\\\n -4 & -7 & 7 \\\\\n 9 & 7 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-18.361,0.18\\, -2.755 i,0.18\\, +2.755 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -7, 3],\n [-4, -7, 7],\n [9, 7, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -7 & 5 & -8 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 5, -8, 0]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{2} \\\\\n -3 \\\\\n \\frac{17}{2} \\\\\n 3 \\\\\n 9 \\\\\n -8 \\\\\n \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{1255}}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/2)],\n [-3],\n [(17/2)],\n [3],\n [9],\n [-8],\n [(5/2)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n \\frac{53}{7} & \\frac{18}{7} & -\\frac{34}{7} & \\frac{10}{7} & \\frac{23}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(53/7), (18/7), -(34/7), (10/7), (23/7)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{29}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-2]])\nb = np.array([\n [-6],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 7 & -2 & 9 & -3 & -10 \\\\\n -7 & -10 & 2 & 7 & -10 \\\\\n -3 & -3 & 7 & 4 & 2 \\\\\n 5 & 1 & 4 & 0 & 7 \\\\\n 6 & 1 & -4 & 7 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, -2, 9, -3, -10],\n [-7, -10, 2, 7, -10],\n [-3, -3, 7, 4, 2],\n [5, 1, 4, 0, 7],\n [6, 1, -4, 7, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{4} \\\\\n \\frac{125}{16} \\\\\n \\frac{31}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{255}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/4)],\n [(125/16)],\n [(31/8)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 8 \\\\\n 5 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [8],\n [5],\n [-5]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & -7 & -9 \\\\\n 8 & 4 & -2 \\\\\n -4 & -2 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.584,-0.207,1.\\}, \\{-1.375-2.363 i,-3.23+1.566 i,1.\\}, \\{-1.375+2.363 i,-3.23-1.566 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -7, -9],\n [8, 4, -2],\n [-4, -2, -7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & -3 & -3 \\\\\n -4 & 0 & 1 \\\\\n 0 & -2 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$20$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, -3],\n [-4, 0, 1],\n [0, -2, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -4 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 4 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{74}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-4],\n [-5]])\nb = np.array([\n [0],\n [4],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -3 & 6 & -9 \\\\\n 0 & 3 & 1 \\\\\n 7 & -8 & 1 \\\\\n 1 & -9 & -5 \\\\\n -3 & 3 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 6, -9],\n [0, 3, 1],\n [7, -8, 1],\n [1, -9, -5],\n [-3, 3, 5]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{13}{5} & -\\frac{3}{2} \\\\\n \\frac{19}{10} & \\frac{7}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{103}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/5), -(3/2)],\n [(19/10), (7/10)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & -2 & -2 & -2 \\\\\n -1 & 0 & -2 & -3 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & -2 & 1 & 0 \\\\\n 2 & 2 & -3 & 2 \\\\\n 2 & 3 & 0 & -1 \\\\\n 2 & -3 & -1 & -2 \\\\\n 0 & -2 & 2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -6 & 2 & -1 & 4 \\\\\n -12 & 9 & -2 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 0, -2, -2, -2],\n [-1, 0, -2, -3, -2]])\nb = np.array([\n [2, -2, 1, 0],\n [2, 2, -3, 2],\n [2, 3, 0, -1],\n [2, -3, -1, -2],\n [0, -2, 2, 1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{10}{3} & \\frac{1}{3} & -7 \\\\\n -4 & \\frac{10}{3} & \\frac{17}{3} \\\\\n 9 & \\frac{14}{3} & -\\frac{10}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-1.175-6.225 i,-1.175+6.225 i,5.683\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(10/3), (1/3), -7],\n [-4, (10/3), (17/3)],\n [9, (14/3), -(10/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{11}{4} \\\\\n -\\frac{5}{2} \\\\\n -\\frac{1}{2} \\\\\n -\\frac{11}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{11}{\\sqrt{346}} \\\\\n -5 \\sqrt{\\frac{2}{173}} \\\\\n -\\sqrt{\\frac{2}{173}} \\\\\n -\\frac{11}{\\sqrt{346}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/4)],\n [-(5/2)],\n [-(1/2)],\n [-(11/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{20}{9} \\\\\n \\frac{13}{9} \\\\\n -\\frac{8}{3} \\\\\n \\frac{10}{9} \\\\\n \\frac{26}{9} \\\\\n \\frac{20}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{20}{\\sqrt{2321}} \\\\\n \\frac{13}{\\sqrt{2321}} \\\\\n -\\frac{24}{\\sqrt{2321}} \\\\\n \\frac{10}{\\sqrt{2321}} \\\\\n \\frac{26}{\\sqrt{2321}} \\\\\n \\frac{20}{\\sqrt{2321}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/9)],\n [(13/9)],\n [-(8/3)],\n [(10/9)],\n [(26/9)],\n [(20/9)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 7 \\\\\n 9 \\\\\n 8 \\\\\n 3 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -1 \\\\\n -8 \\\\\n 6 \\\\\n 8 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [7],\n [9],\n [8],\n [3],\n [3]])\nb = np.array([\n [2],\n [-1],\n [-8],\n [6],\n [8],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{11}{3}, \\frac{14}{3}, 4}$ to the plane $\\frac{4 x}{3}+y+\\frac{7 z}{3}+\\frac{13}{3}=0$.", - "Output Answer": [ - "$\\frac{209}{3 \\sqrt{74}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (11/3), (14/3), 4\nplane = Poly(((4*x)/3)+y+((7*z)/3)+(13/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & \\frac{1}{2} & \\frac{1}{2} \\\\\n -\\frac{3}{2} & 0 & -1 \\\\\n -\\frac{1}{2} & 3 & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{69}{8} & \\frac{39}{8} & -\\frac{1}{8} \\\\\n -\\frac{17}{8} & -\\frac{31}{8} & \\frac{17}{8} \\\\\n -\\frac{99}{8} & -\\frac{101}{8} & -\\frac{21}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), (1/2), (1/2)],\n [-(3/2), 0, -1],\n [-(1/2), 3, 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & \\frac{9}{2} \\\\\n -\\frac{1}{2} & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{33}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, (9/2)],\n [-(1/2), -(7/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{9}{4} \\\\\n 4 \\\\\n -\\frac{5}{2} \\\\\n -\\frac{21}{4} \\\\\n -\\frac{33}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{89}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/4)],\n [4],\n [-(5/2)],\n [-(21/4)],\n [-(33/4)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\text{Indeterminate}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [0]]).squeeze()\nb = np.array([\n [0],\n [1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & -\\frac{9}{2} \\\\\n 2 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -(9/2)],\n [2, -(3/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 3 \\\\\n -6 \\\\\n 2 \\\\\n -7 \\\\\n -8 \\\\\n -7 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -6 \\\\\n 7 \\\\\n 1 \\\\\n -3 \\\\\n 8 \\\\\n 7 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-120$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [3],\n [-6],\n [2],\n [-7],\n [-8],\n [-7],\n [-10]])\nb = np.array([\n [10],\n [-6],\n [7],\n [1],\n [-3],\n [8],\n [7],\n [3]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{545}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-7]])\nb = np.array([\n [-8],\n [9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 1 \\\\\n -3 & -2 & 0 & -1 \\\\\n -4 & -2 & 0 & 2 \\\\\n -1 & 0 & 0 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 0 & 0 & 0 & e^2 \\\\\n \\frac{1}{e^2} & \\frac{1}{e^2} & 0 & -e^2 \\\\\n \\frac{1-e^4}{e^2} & \\frac{1-e^2}{e^2} & 1 & e^2-1 \\\\\n -e^2 & 0 & 0 & 2 e^2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [1, 0, 0, 1],\n [-3, -2, 0, -1],\n [-4, -2, 0, 2],\n [-1, 0, 0, 3]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & -8 \\\\\n 10 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{10} \\left(-1-i \\sqrt{79}\\right),1\\right\\}, \\left\\{\\frac{1}{10} \\left(-1+i \\sqrt{79}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -8],\n [10, 8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{10}{3} & \\frac{17}{3} \\\\\n \\frac{17}{3} & \\frac{23}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{34} \\left(-33-\\sqrt{2245}\\right),1\\right\\}, \\left\\{\\frac{1}{34} \\left(\\sqrt{2245}-33\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(10/3), (17/3)],\n [(17/3), (23/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -9 & 1 & 0 \\\\\n -5 & 7 & -4 \\\\\n 3 & 5 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-3 x^2+36 x-134$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 1, 0],\n [-5, 7, -4],\n [3, 5, -1]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-5$ and the matrix\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 30 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6]])\nprint(a * -5)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-45$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9]])\nb = np.array([\n [-5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & 0 & 6 \\\\\n 9 & -2 & 4 \\\\\n 9 & -7 & -5 \\\\\n -3 & -5 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, 0, 6],\n [9, -2, 4],\n [9, -7, -5],\n [-3, -5, 4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{9}{2}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 9 & -8 \\\\\n -10 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{81}{2} & 36 \\\\\n 45 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -8],\n [-10, 0]])\nprint(a * -(9/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & -2 \\\\\n 1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2],\n [1, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n 9 & \\frac{13}{2} & 5 & -\\frac{11}{2} & \\frac{7}{2} \\\\\n 4 & \\frac{5}{2} & \\frac{7}{2} & -6 & -\\frac{1}{2} \\\\\n -3 & -8 & -\\frac{13}{2} & -\\frac{7}{2} & \\frac{1}{2} \\\\\n \\frac{7}{2} & -3 & \\frac{17}{2} & \\frac{5}{2} & -\\frac{13}{2} \\\\\n -6 & -\\frac{11}{2} & -\\frac{1}{2} & 4 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, (13/2), 5, -(11/2), (7/2)],\n [4, (5/2), (7/2), -6, -(1/2)],\n [-3, -8, -(13/2), -(7/2), (1/2)],\n [(7/2), -3, (17/2), (5/2), -(13/2)],\n [-6, -(11/2), -(1/2), 4, 1]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 0 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -7 \\\\\n -10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [0]])\nb = np.array([\n [1],\n [10]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -12 \\log (2) \\\\\n -9 \\log (2) \\\\\n 0 \\\\\n 4 \\log (2) \\\\\n -9 \\log (2) \\\\\n -14 \\log (2) \\\\\n 7 \\log (2) \\\\\n -6 \\log (2) \\\\\n -13 \\log (2) \\\\\n 9 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -11 \\log (2) \\\\\n 5 \\log (2) \\\\\n -8 \\log (2) \\\\\n 14 \\log (2) \\\\\n 7 \\log (2) \\\\\n -11 \\log (2) \\\\\n -5 \\log (2) \\\\\n -13 \\log (2) \\\\\n -\\log (2) \\\\\n -7 \\log (2) \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{1219} \\log (2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-12*math.log(2)],\n [-9*math.log(2)],\n [0],\n [4*math.log(2)],\n [-9*math.log(2)],\n [-14*math.log(2)],\n [7*math.log(2)],\n [-6*math.log(2)],\n [-13*math.log(2)],\n [9*math.log(2)]])\nb = np.array([\n [-11*math.log(2)],\n [5*math.log(2)],\n [-8*math.log(2)],\n [14*math.log(2)],\n [7*math.log(2)],\n [-11*math.log(2)],\n [-5*math.log(2)],\n [-13*math.log(2)],\n [-math.log(2)],\n [-7*math.log(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\sqrt{2} \\\\\n -3 \\sqrt{2} \\\\\n -6 \\sqrt{2} \\\\\n -4 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\sqrt{2} \\\\\n 2 \\sqrt{2} \\\\\n -5 \\sqrt{2} \\\\\n 3 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{122}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-7*math.sqrt(2)],\n [-3*math.sqrt(2)],\n [-6*math.sqrt(2)],\n [-4*math.sqrt(2)]])\nb = np.array([\n [6*math.sqrt(2)],\n [2*math.sqrt(2)],\n [-5*math.sqrt(2)],\n [3*math.sqrt(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 1 \\\\\n 8 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(7-\\sqrt{113}\\right),\\frac{1}{2} \\left(7+\\sqrt{113}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 1],\n [8, -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 8 \\\\\n -6 \\\\\n 9 \\\\\n 2 \\\\\n 7 \\\\\n 6 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{94}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [8],\n [-6],\n [9],\n [2],\n [7],\n [6],\n [-5]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & -4 \\\\\n 3 & -3 & 9 \\\\\n -8 & -8 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.68,0.588,1.\\}, \\{0.324\\, -0.212 i,-0.279+1.19 i,1.\\}, \\{0.324\\, +0.212 i,-0.279-1.19 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, -4],\n [3, -3, 9],\n [-8, -8, -5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2 \\\\\n -13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-3]])\nb = np.array([\n [-1],\n [10]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & -\\frac{7}{2} \\\\\n \\frac{3}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{11}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -(7/2)],\n [(3/2), (5/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 1 \\\\\n -3 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{2}{3},-\\frac{4}{3},-\\frac{4}{3}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [1],\n [-3]]).squeeze()\nb = np.array([\n [-1],\n [-2],\n [-2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{27}{100} & -\\frac{7}{20} \\\\\n \\frac{223}{50} & \\frac{811}{100} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{283}{50} & -\\frac{631}{100} \\\\\n -\\frac{389}{100} & \\frac{62}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{539}{100} & -\\frac{333}{50} \\\\\n \\frac{57}{100} & \\frac{1059}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(27/100), -(7/20)],\n [(223/50), (811/100)]])\nb = np.array([\n [-(283/50), -(631/100)],\n [-(389/100), (62/25)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & -1 \\\\\n 3 & -2 \\\\\n -1 & -3 \\\\\n 1 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.57 \\\\\n 2.11 \\\\\n -0.33 \\\\\n -1.99 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.498 \\\\\n 0.184 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1],\n [3, -2],\n [-1, -3],\n [1, -2]])\nb = np.array([\n [-0.57],\n [2.11],\n [-0.33],\n [-1.99]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n \\frac{25}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{61}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-(5/2)]])\nb = np.array([\n [4],\n [(25/4)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,-4,5\\}, \\left\\{\\frac{3}{2},-3,\\frac{7}{2}\\right\\}, \\left\\{-\\frac{5}{2},4,-1\\right\\}}$.", - "Output Answer": [ - "$24 x+51 y+58 z-86=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, -4, 5],\n [(3/2), -3, (7/2)],\n [-(5/2), 4, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -7 \\\\\n 6 \\\\\n 2 \\\\\n 5 \\\\\n -10 \\\\\n 8 \\\\\n -9 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -8 \\\\\n 4 \\\\\n 6 \\\\\n -1 \\\\\n -5 \\\\\n -1 \\\\\n -8 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10 \\sqrt{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-7],\n [6],\n [2],\n [5],\n [-10],\n [8],\n [-9],\n [4]])\nb = np.array([\n [4],\n [-8],\n [4],\n [6],\n [-1],\n [-5],\n [-1],\n [-8],\n [4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & 8 & 1 \\\\\n -6 & 3 & 1 \\\\\n 4 & 4 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{4.718\\, -6.113 i,4.718\\, +6.113 i,7.564\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 8, 1],\n [-6, 3, 1],\n [4, 4, 7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 10 & 1 & 0 & 10 \\\\\n 6 & 7 & 5 & -2 \\\\\n -10 & -4 & 3 & -9 \\\\\n -10 & 8 & -10 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [10, 1, 0, 10],\n [6, 7, 5, -2],\n [-10, -4, 3, -9],\n [-10, 8, -10, -7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{9}{2} \\\\\n \\frac{27}{8} \\\\\n \\frac{73}{8} \\\\\n -\\frac{73}{8} \\\\\n \\frac{37}{8} \\\\\n -\\frac{67}{8} \\\\\n \\frac{71}{8} \\\\\n \\frac{33}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{417}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/2)],\n [(27/8)],\n [(73/8)],\n [-(73/8)],\n [(37/8)],\n [-(67/8)],\n [(71/8)],\n [(33/8)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & -\\frac{16}{3} \\\\\n -\\frac{17}{3} & -\\frac{13}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{34} \\left(-25-\\sqrt{1713}\\right),1\\right\\}, \\left\\{\\frac{1}{34} \\left(\\sqrt{1713}-25\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -(16/3)],\n [-(17/3), -(13/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{2} \\\\\n \\frac{3}{2} \\\\\n \\frac{11}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -\\frac{5}{2} \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{379}{\\sqrt{173323}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/2)],\n [(3/2)],\n [(11/2)]]).squeeze()\nb = np.array([\n [9],\n [-(5/2)],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{303}{50} \\\\\n \\frac{513}{100} \\\\\n \\frac{21}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{3 \\sqrt{\\frac{10067}{10}}}{10}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(303/50)],\n [(513/100)],\n [(21/4)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{\\pi } \\\\\n \\frac{23}{\\pi } \\\\\n \\frac{1}{\\pi } \\\\\n -\\frac{24}{\\pi } \\\\\n \\frac{15}{\\pi } \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{22}{\\pi } \\\\\n -\\frac{18}{\\pi } \\\\\n -\\frac{12}{\\pi } \\\\\n \\frac{21}{\\pi } \\\\\n \\frac{10}{\\pi } \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{1066}{\\pi ^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(13/math.pi)],\n [(23/math.pi)],\n [(1/math.pi)],\n [-(24/math.pi)],\n [(15/math.pi)]])\nb = np.array([\n [-(22/math.pi)],\n [-(18/math.pi)],\n [-(12/math.pi)],\n [(21/math.pi)],\n [(10/math.pi)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 2 & \\frac{14}{5} & -\\frac{2}{5} & \\frac{3}{5} & -\\frac{11}{5} \\\\\n -\\frac{8}{5} & 3 & \\frac{11}{5} & -3 & \\frac{8}{5} \\\\\n 2 & \\frac{1}{5} & \\frac{6}{5} & -\\frac{3}{5} & -\\frac{3}{5} \\\\\n \\frac{3}{5} & -\\frac{6}{5} & \\frac{8}{5} & \\frac{1}{5} & -\\frac{12}{5} \\\\\n 0 & \\frac{13}{5} & \\frac{4}{5} & \\frac{7}{5} & -\\frac{11}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -1 & \\frac{13}{5} \\\\\n -\\frac{12}{5} & \\frac{2}{5} \\\\\n -2 & \\frac{8}{5} \\\\\n \\frac{13}{5} & -1 \\\\\n \\frac{13}{5} & \\frac{11}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{302}{25} & \\frac{6}{25} \\\\\n -\\frac{341}{25} & \\frac{177}{25} \\\\\n -8 & \\frac{162}{25} \\\\\n -\\frac{166}{25} & -\\frac{46}{25} \\\\\n -\\frac{248}{25} & -\\frac{98}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, (14/5), -(2/5), (3/5), -(11/5)],\n [-(8/5), 3, (11/5), -3, (8/5)],\n [2, (1/5), (6/5), -(3/5), -(3/5)],\n [(3/5), -(6/5), (8/5), (1/5), -(12/5)],\n [0, (13/5), (4/5), (7/5), -(11/5)]])\nb = np.array([\n [-1, (13/5)],\n [-(12/5), (2/5)],\n [-2, (8/5)],\n [(13/5), -1],\n [(13/5), (11/5)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -4 & 1 & -1 \\\\\n 0 & 4 & 2 \\\\\n 0 & -5 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{4} & -\\frac{1}{104} & -\\frac{3}{52} \\\\\n 0 & \\frac{2}{13} & -\\frac{1}{13} \\\\\n 0 & \\frac{5}{26} & \\frac{2}{13} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 1, -1],\n [0, 4, 2],\n [0, -5, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -6 & -\\frac{2}{3} & -\\frac{13}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -8 & -\\frac{2}{3} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 2 & 0 & -\\frac{29}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -(2/3), -(13/3)]])\nb = np.array([\n [-8, -(2/3), (1/2)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & \\frac{7}{2} \\\\\n 3 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{15}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, (7/2)],\n [3, -(3/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{21}{8} \\\\\n -\\frac{69}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{69}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(21/8)],\n [-(69/8)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n \\frac{55}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(55/9)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 9 & -5 & 1 & -9 & -2 \\\\\n -4 & 6 & 10 & 10 & -5 \\\\\n 4 & 3 & -8 & 8 & 4 \\\\\n -10 & -10 & -6 & -9 & -2 \\\\\n -9 & 5 & 0 & 0 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, -5, 1, -9, -2],\n [-4, 6, 10, 10, -5],\n [4, 3, -8, 8, 4],\n [-10, -10, -6, -9, -2],\n [-9, 5, 0, 0, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 3 & 1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -5 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 8 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1]])\nb = np.array([\n [-5, 2]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{51}{7} \\\\\n \\frac{44}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{51}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(51/7)],\n [(44/7)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{9}{2} & -\\frac{13}{4} & \\frac{3}{2} \\\\\n -\\frac{5}{4} & 4 & -5 \\\\\n \\frac{7}{4} & \\frac{9}{2} & -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1248}{6419} & \\frac{276}{6419} & \\frac{656}{6419} \\\\\n -\\frac{620}{6419} & -\\frac{384}{6419} & \\frac{1320}{6419} \\\\\n -\\frac{808}{6419} & -\\frac{1660}{6419} & \\frac{892}{6419} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/2), -(13/4), (3/2)],\n [-(5/4), 4, -5],\n [(7/4), (9/2), -(3/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cc}\n 2 & 0 \\\\\n -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n e^2 & 0 \\\\\n -e^2 & e^2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [2, 0],\n [-1, 2]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{6} \\\\\n -\\frac{17}{6} \\\\\n -\\frac{19}{6} \\\\\n \\frac{19}{3} \\\\\n \\frac{10}{3} \\\\\n -4 \\\\\n -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{\\frac{1085}{3}}}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/6)],\n [-(17/6)],\n [-(19/6)],\n [(19/3)],\n [(10/3)],\n [-4],\n [-(2/3)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -2 & -3 & -3 & 3 \\\\\n 2 & -2 & -1 & 1 \\\\\n -2 & 0 & -3 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -1 & 0 & 2 & -1 & 0 \\\\\n -1 & 2 & 2 & 1 & 2 \\\\\n -2 & 1 & 2 & 1 & 0 \\\\\n -1 & 0 & -1 & 3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 8 & -9 & -19 & 5 & -12 \\\\\n 1 & -5 & -3 & -2 & -6 \\\\\n 9 & -3 & -9 & -4 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, -3, 3],\n [2, -2, -1, 1],\n [-2, 0, -3, -1]])\nb = np.array([\n [-1, 0, 2, -1, 0],\n [-1, 2, 2, 1, 2],\n [-2, 1, 2, 1, 0],\n [-1, 0, -1, 3, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & -3 & 10 \\\\\n 5 & -10 & -9 \\\\\n -7 & -9 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.195,2.119,1.\\}, \\{0.27\\, -1.21 i,-0.527-0.077 i,1.\\}, \\{0.27\\, +1.21 i,-0.527+0.077 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -3, 10],\n [5, -10, -9],\n [-7, -9, 3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{2} \\\\\n \\frac{1}{2} \\\\\n -1 \\\\\n \\frac{15}{2} \\\\\n 5 \\\\\n -7 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -6 \\\\\n -4 \\\\\n 1 \\\\\n -\\frac{13}{2} \\\\\n -1 \\\\\n -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{19}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/2)],\n [(1/2)],\n [-1],\n [(15/2)],\n [5],\n [-7],\n [-10]])\nb = np.array([\n [-1],\n [-6],\n [-4],\n [1],\n [-(13/2)],\n [-1],\n [-(7/2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & 1 & 0 & 3 \\\\\n 0 & -3 & -1 & -3 \\\\\n -3 & -1 & 0 & -3 \\\\\n 3 & -1 & 1 & -3 \\\\\n -1 & 1 & -1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.88 \\\\\n 2.9 \\\\\n 1.68 \\\\\n -1.18 \\\\\n -2.3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.866 \\\\\n -3.175 \\\\\n 2.14 \\\\\n 1.561 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 0, 3],\n [0, -3, -1, -3],\n [-3, -1, 0, -3],\n [3, -1, 1, -3],\n [-1, 1, -1, 1]])\nb = np.array([\n [2.88],\n [2.9],\n [1.68],\n [-1.18],\n [-2.3]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{4}{3},\\frac{4}{3},-\\frac{8}{3}\\right\\}, \\left\\{-\\frac{7}{3},\\frac{2}{3},1\\right\\}, \\left\\{-3,\\frac{7}{3},\\frac{1}{3}\\right\\}}$.", - "Output Answer": [ - "$153 x+132 y+177 z+92=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(4/3), (4/3), -(8/3)],\n [-(7/3), (2/3), 1],\n [-3, (7/3), (1/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 9 & -\\frac{20}{3} & \\frac{13}{3} \\\\\n \\frac{20}{3} & -\\frac{8}{3} & -4 \\\\\n 3 & \\frac{2}{3} & -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-0.9-4.303 i,-0.9+4.303 i,7.466\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -(20/3), (13/3)],\n [(20/3), -(8/3), -4],\n [3, (2/3), -(2/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 5 & 3 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-4.,0.,5.\\}, \\{-3.,5.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, 3, 4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & -8 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.,0.,7.\\}, \\{8.,7.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, -8, 1]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 0 & -3 \\\\\n -2 & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & -18 \\\\\n -12 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3],\n [-2, 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 0 & 8 & 5 \\\\\n -1 & -5 & 10 \\\\\n -9 & 1 & 1 \\\\\n -9 & 1 & -8 \\\\\n 1 & 0 & -3 \\\\\n 4 & 3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, 8, 5],\n [-1, -5, 10],\n [-9, 1, 1],\n [-9, 1, -8],\n [1, 0, -3],\n [4, 3, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 6 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 3 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3 \\\\\n 37 \\\\\n 24 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [6],\n [-9]])\nb = np.array([\n [-5],\n [3],\n [-4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{23}{4} & -10 \\\\\n 3 & 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{11}{4} & -6 \\\\\n -\\frac{13}{2} & -\\frac{31}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{17}{2} & -16 \\\\\n -\\frac{7}{2} & \\frac{5}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/4), -10],\n [3, 9]])\nb = np.array([\n [(11/4), -6],\n [-(13/2), -(31/4)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & 2 & -1 & 2 \\\\\n -1 & 1 & 0 & -1 \\\\\n 2 & 3 & -1 & 1 \\\\\n -3 & 1 & 1 & 2 \\\\\n -1 & 2 & -1 & -2 \\\\\n 1 & 3 & 1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.03 \\\\\n 2.86 \\\\\n -1.54 \\\\\n 1.68 \\\\\n 0.69 \\\\\n -0.44 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.775 \\\\\n 0.179 \\\\\n -0.301 \\\\\n -0.007 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, -1, 2],\n [-1, 1, 0, -1],\n [2, 3, -1, 1],\n [-3, 1, 1, 2],\n [-1, 2, -1, -2],\n [1, 3, 1, -1]])\nb = np.array([\n [1.03],\n [2.86],\n [-1.54],\n [1.68],\n [0.69],\n [-0.44]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, 4}$ to the line $-3 x-2 y-4=0$.", - "Output Answer": [ - "$\\frac{21}{\\sqrt{13}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, 4\nline = Poly(-3*x-2*y-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -10 & 2 \\\\\n -4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{8} \\left(7-\\sqrt{17}\\right),1\\right\\}, \\left\\{\\frac{1}{8} \\left(7+\\sqrt{17}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 2],\n [-4, -3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 3 & \\frac{3}{2} & -2 \\\\\n -3 & 0 & -\\frac{9}{2} \\\\\n -5 & -\\frac{5}{2} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{15}{11} & -\\frac{1}{3} & \\frac{9}{11} \\\\\n -\\frac{36}{11} & \\frac{2}{3} & -\\frac{26}{11} \\\\\n -\\frac{10}{11} & 0 & -\\frac{6}{11} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, (3/2), -2],\n [-3, 0, -(9/2)],\n [-5, -(5/2), (3/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, -\\frac{13}{5}}$ to the line $-5 x+\\frac{6 y}{5}-\\frac{19}{5}=0$.", - "Output Answer": [ - "$\\frac{548}{5 \\sqrt{661}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, -(13/5)\nline = Poly(-5*x+((6*y)/5)-(19/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{18}{5} \\\\\n -\\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{26}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(18/5)],\n [-(8/5)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{2} & \\frac{11}{2} & \\frac{55}{8} \\\\\n \\frac{13}{2} & -\\frac{71}{8} & -\\frac{17}{2} \\\\\n -\\frac{13}{8} & -\\frac{43}{8} & -\\frac{33}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{33 x^2}{2}-\\frac{379 x}{32}-\\frac{43077}{512}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), (11/2), (55/8)],\n [(13/2), -(71/8), -(17/2)],\n [-(13/8), -(43/8), -(33/8)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & -4 \\\\\n 5 & 4 & -5 \\\\\n -4 & -\\frac{9}{2} & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{33}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, -4],\n [5, 4, -5],\n [-4, -(9/2), 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -3 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{6}{5} \\\\\n \\frac{7}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3]])\nb = np.array([\n [-(6/5)],\n [(7/5)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, -\\frac{9}{2}, -\\frac{9}{2}}$ to the plane $\\frac{x}{2}-\\frac{7 z}{2}-4=0$.", - "Output Answer": [ - "$\\frac{41}{10 \\sqrt{2}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, -(9/2), -(9/2)\nplane = Poly((x/2)-((7*z)/2)-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n -3 \\\\\n -3 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{2}{7},\\frac{2}{7},\\frac{6}{7},\\frac{6}{7},\\frac{2}{7}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [-1],\n [2],\n [3]]).squeeze()\nb = np.array([\n [-1],\n [-1],\n [-3],\n [-3],\n [-1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -9 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 4 \\\\\n 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 31 \\\\\n 78 \\\\\n -95 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-9],\n [-10]])\nb = np.array([\n [-7],\n [4],\n [1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{4}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 6 & 10 \\\\\n -2 & 5 \\\\\n -10 & -6 \\\\\n 5 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{21}{2} & \\frac{35}{2} \\\\\n -\\frac{7}{2} & \\frac{35}{4} \\\\\n -\\frac{35}{2} & -\\frac{21}{2} \\\\\n \\frac{35}{4} & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 10],\n [-2, 5],\n [-10, -6],\n [5, -2]])\nprint(a * (7/4))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{64}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{9}{64} & \\frac{9}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 6]])\nprint(a * (3/64))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & 8 & -4 \\\\\n 8 & -\\frac{15}{2} & \\frac{1}{2} \\\\\n \\frac{15}{2} & 1 & \\frac{11}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-11.283,6.641\\, -4.691 i,6.641\\, +4.691 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 8, -4],\n [8, -(15/2), (1/2)],\n [(15/2), 1, (11/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -6 & 1 \\\\\n 7 & 0 \\\\\n 8 & -6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 8 & -5 \\\\\n -2 & 7 \\\\\n 3 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -14 & 6 \\\\\n 9 & -7 \\\\\n 5 & -11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 1],\n [7, 0],\n [8, -6]])\nb = np.array([\n [8, -5],\n [-2, 7],\n [3, 5]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{469}{50} & -\\frac{161}{50} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{581}{100} & \\frac{601}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{357}{100} & \\frac{279}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(469/50), -(161/50)]])\nb = np.array([\n [-(581/100), (601/100)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7.4 \\\\\n -5. \\\\\n -7.7 \\\\\n 5.3 \\\\\n 8.4 \\\\\n -2. \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3.3 \\\\\n -0.1 \\\\\n 3. \\\\\n -1.6 \\\\\n -2.2 \\\\\n -1.2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$17.7741$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7.4],\n [-5.],\n [-7.7],\n [5.3],\n [8.4],\n [-2.]])\nb = np.array([\n [-3.3],\n [-0.1],\n [3.],\n [-1.6],\n [-2.2],\n [-1.2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -6 & -10 & -4 & -2 & 7 & -9 & 4 \\\\\n 3 & 10 & 1 & -1 & 5 & -2 & 6 \\\\\n 5 & 8 & 3 & 10 & 2 & 8 & -5 \\\\\n 7 & 6 & 7 & 4 & 4 & -5 & 1 \\\\\n 1 & 6 & 1 & 3 & 0 & 1 & 0 \\\\\n 3 & 10 & 7 & 2 & -7 & -5 & -7 \\\\\n -3 & 0 & 10 & 6 & -2 & -8 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-6, -10, -4, -2, 7, -9, 4],\n [3, 10, 1, -1, 5, -2, 6],\n [5, 8, 3, 10, 2, 8, -5],\n [7, 6, 7, 4, 4, -5, 1],\n [1, 6, 1, 3, 0, 1, 0],\n [3, 10, 7, 2, -7, -5, -7],\n [-3, 0, 10, 6, -2, -8, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{10}{3} & -\\frac{7}{2} & \\frac{13}{6} \\\\\n -1 & \\frac{5}{6} & \\frac{3}{2} \\\\\n \\frac{8}{3} & -\\frac{3}{2} & -\\frac{10}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{77}{36}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(10/3), -(7/2), (13/6)],\n [-1, (5/6), (3/2)],\n [(8/3), -(3/2), -(10/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$35$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-7]])\nb = np.array([\n [-3],\n [-8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & -4 \\\\\n -\\frac{11}{3} & \\frac{5}{3} & -\\frac{4}{3} \\\\\n \\frac{2}{3} & -\\frac{5}{3} & -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-12$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, -4],\n [-(11/3), (5/3), -(4/3)],\n [(2/3), -(5/3), -(14/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n 0 & -\\frac{17}{2} & -\\frac{11}{2} & -\\frac{17}{2} & -\\frac{11}{4} \\\\\n -\\frac{7}{4} & -\\frac{3}{2} & -3 & -\\frac{29}{4} & \\frac{25}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -(17/2), -(11/2), -(17/2), -(11/4)],\n [-(7/4), -(3/2), -3, -(29/4), (25/4)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & 4 & 0 \\\\\n -3 & 0 & 1 \\\\\n 3 & -3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & \\frac{2}{3} & \\frac{2}{3} \\\\\n 0 & -\\frac{1}{3} & -\\frac{1}{3} \\\\\n \\frac{3}{2} & 3 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 4, 0],\n [-3, 0, 1],\n [3, -3, -1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n 3 & 3 & 2 & -4 \\\\\n 1 & 2 & 2 & -1 \\\\\n 0 & 0 & 2 & 0 \\\\\n 1 & 3 & 2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 2 e^2 & \\frac{e^3-1}{e} & 2 e^2 & \\frac{1-2 e^3}{e} \\\\\n e^2 & e^2 & 2 e^2 & -e^2 \\\\\n 0 & 0 & e^2 & 0 \\\\\n e^2 & \\frac{e^3-1}{e} & 2 e^2 & \\frac{1-e^3}{e} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [3, 3, 2, -4],\n [1, 2, 2, -1],\n [0, 0, 2, 0],\n [1, 3, 2, -2]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{18}{5} \\\\\n -\\frac{19}{5} \\\\\n \\frac{33}{5} \\\\\n -9 \\\\\n \\frac{47}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{41}{5} \\\\\n -\\frac{32}{5} \\\\\n -5 \\\\\n 6 \\\\\n -\\frac{41}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-689 \\sqrt{\\frac{2}{4439161}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(18/5)],\n [-(19/5)],\n [(33/5)],\n [-9],\n [(47/5)]]).squeeze()\nb = np.array([\n [-(41/5)],\n [-(32/5)],\n [-5],\n [6],\n [-(41/5)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -5 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-5],\n [1]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{47}{6} & -\\frac{13}{3} & 10 \\\\\n \\frac{10}{3} & -\\frac{19}{6} & -\\frac{10}{3} \\\\\n -\\frac{5}{2} & -\\frac{11}{3} & 5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & -5 & -\\frac{43}{6} \\\\\n \\frac{11}{6} & \\frac{7}{6} & \\frac{31}{6} \\\\\n \\frac{1}{2} & -\\frac{17}{6} & -\\frac{47}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{22}{3} & \\frac{2}{3} & \\frac{103}{6} \\\\\n \\frac{3}{2} & -\\frac{13}{3} & -\\frac{17}{2} \\\\\n -3 & -\\frac{5}{6} & \\frac{77}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(47/6), -(13/3), 10],\n [(10/3), -(19/6), -(10/3)],\n [-(5/2), -(11/3), 5]])\nb = np.array([\n [(1/2), -5, -(43/6)],\n [(11/6), (7/6), (31/6)],\n [(1/2), -(17/6), -(47/6)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -1 & \\frac{2}{5} & 1 & -\\frac{14}{5} \\\\\n \\frac{4}{5} & -\\frac{11}{5} & \\frac{1}{5} & -3 \\\\\n \\frac{14}{5} & 0 & \\frac{12}{5} & -\\frac{2}{5} \\\\\n -\\frac{9}{5} & \\frac{12}{5} & \\frac{14}{5} & -\\frac{1}{5} \\\\\n \\frac{6}{5} & -\\frac{13}{5} & \\frac{4}{5} & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{14}{5} \\\\\n \\frac{3}{5} \\\\\n \\frac{1}{5} \\\\\n \\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{171}{25} \\\\\n -\\frac{96}{25} \\\\\n \\frac{192}{25} \\\\\n -\\frac{84}{25} \\\\\n \\frac{89}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, (2/5), 1, -(14/5)],\n [(4/5), -(11/5), (1/5), -3],\n [(14/5), 0, (12/5), -(2/5)],\n [-(9/5), (12/5), (14/5), -(1/5)],\n [(6/5), -(13/5), (4/5), 1]])\nb = np.array([\n [(14/5)],\n [(3/5)],\n [(1/5)],\n [(8/5)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & 4 \\\\\n \\frac{3}{2} & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+2 x-\\frac{29}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), 4],\n [(3/2), -(5/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -5 & 4 & 2 \\\\\n 2 & 4 & 0 \\\\\n 2 & -2 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-136$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 4, 2],\n [2, 4, 0],\n [2, -2, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n 2 & 1 & 5 \\\\\n -4 & -2 & -2 \\\\\n -1 & 2 & 5 \\\\\n -8 & -2 & 7 \\\\\n 10 & -9 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, 5],\n [-4, -2, -2],\n [-1, 2, 5],\n [-8, -2, 7],\n [10, -9, 2]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & 2 \\\\\n 4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-5$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2],\n [4, -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{21}{5} & -\\frac{16}{5} \\\\\n \\frac{9}{5} & -\\frac{4}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{228}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(21/5), -(16/5)],\n [(9/5), -(4/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 5 & 5 \\\\\n 0 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{5} & -\\frac{1}{4} \\\\\n 0 & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 5],\n [0, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 0 & 1 & 8 & -5 & 8 \\\\\n -6 & -2 & 7 & 2 & -1 \\\\\n -2 & 9 & 2 & 10 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-257.,-112.,-219.,0.,233.\\}, \\{705.,-438.,346.,466.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, 1, 8, -5, 8],\n [-6, -2, 7, 2, -1],\n [-2, 9, 2, 10, 4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n 6 & -2 & -1 & 1 \\\\\n -9 & -4 & 2 & 4 \\\\\n -6 & -1 & -1 & -7 \\\\\n -9 & 8 & 4 & -4 \\\\\n -3 & 8 & -9 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -2, -1, 1],\n [-9, -4, 2, 4],\n [-6, -1, -1, -7],\n [-9, 8, 4, -4],\n [-3, 8, -9, 4]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & -2 & 0 & 3 \\\\\n -3 & 3 & 0 & 2 \\\\\n 3 & 3 & 3 & -2 \\\\\n -1 & 0 & -2 & 3 \\\\\n -2 & -1 & -3 & 3 \\\\\n -2 & -2 & 3 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.82 \\\\\n -0.63 \\\\\n 0.08 \\\\\n -2.78 \\\\\n 0.3 \\\\\n 2.72 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.057 \\\\\n -0.512 \\\\\n 0.653 \\\\\n 0.145 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2, 0, 3],\n [-3, 3, 0, 2],\n [3, 3, 3, -2],\n [-1, 0, -2, 3],\n [-2, -1, -3, 3],\n [-2, -2, 3, -1]])\nb = np.array([\n [1.82],\n [-0.63],\n [0.08],\n [-2.78],\n [0.3],\n [2.72]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 0 & 5 & 9 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.,-9.,5.,0.\\}, \\{0.,4.,0.,5.\\}, \\{1.,0.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, 5, 9, -4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{9}{7}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -6 & -2 \\\\\n 5 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{54}{7} & \\frac{18}{7} \\\\\n -\\frac{45}{7} & -\\frac{90}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -2],\n [5, 10]])\nprint(a * -(9/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -8 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 3 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 37 \\\\\n -8 \\\\\n 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-8],\n [1]])\nb = np.array([\n [2],\n [3],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{3}{2 \\sqrt{5}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [1],\n [0],\n [-1],\n [-1],\n [-1]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [1],\n [0],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 5 & 2 \\\\\n -10 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, 2],\n [-10, -9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{14}{3}, \\frac{14}{3}, -3}$ to the plane $-\\frac{14 x}{3}-\\frac{7 y}{3}-\\frac{z}{3}-\\frac{5}{3}=0$.", - "Output Answer": [ - "$50 \\sqrt{\\frac{2}{123}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (14/3), (14/3), -3\nplane = Poly(-((14*x)/3)-((7*y)/3)-(z/3)-(5/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -3 \\\\\n 3 \\\\\n -10 \\\\\n 7 \\\\\n 1 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -8 \\\\\n -9 \\\\\n -2 \\\\\n -7 \\\\\n -6 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{479}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-3],\n [3],\n [-10],\n [7],\n [1],\n [-6]])\nb = np.array([\n [-1],\n [-8],\n [-9],\n [-2],\n [-7],\n [-6],\n [-7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{29}{4} \\\\\n \\frac{27}{4} \\\\\n -\\frac{37}{4} \\\\\n -\\frac{29}{4} \\\\\n -\\frac{31}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{4741}}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/4)],\n [(27/4)],\n [-(37/4)],\n [-(29/4)],\n [-(31/4)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-64$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-9]])\nb = np.array([\n [7],\n [4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{14}{5}, -\\frac{16}{5}, -\\frac{14}{5}}$ to the plane $\\frac{18 x}{5}-\\frac{19 y}{5}+z-\\frac{6}{5}=0$.", - "Output Answer": [ - "$\\frac{228 \\sqrt{\\frac{2}{355}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (14/5), -(16/5), -(14/5)\nplane = Poly(((18*x)/5)-((19*y)/5)+z-(6/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-4$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 8 & -4 & 3 \\\\\n 6 & 7 & 1 \\\\\n -2 & 9 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -32 & 16 & -12 \\\\\n -24 & -28 & -4 \\\\\n 8 & -36 & -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -4, 3],\n [6, 7, 1],\n [-2, 9, 3]])\nprint(a * -4)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\sqrt{3} \\\\\n \\frac{14}{\\sqrt{3}} \\\\\n -\\frac{7}{\\sqrt{3}} \\\\\n \\frac{11}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\sqrt{3} \\\\\n -\\frac{13}{\\sqrt{3}} \\\\\n \\sqrt{3} \\\\\n 5 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{20}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [2*math.sqrt(3)],\n [(14/(math.sqrt(3)))],\n [-(7/(math.sqrt(3)))],\n [(11/(math.sqrt(3)))]])\nb = np.array([\n [math.sqrt(3)],\n [-(13/(math.sqrt(3)))],\n [math.sqrt(3)],\n [5*math.sqrt(3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -\\frac{1}{2} \\\\\n \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3 \\sqrt{\\frac{2}{31}} \\\\\n -\\frac{1}{\\sqrt{62}} \\\\\n \\frac{5}{\\sqrt{62}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-(1/2)],\n [(5/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 9 & -4 & -7 & -9 & -3 \\\\\n 1 & -10 & -7 & -4 & -2 \\\\\n 2 & -5 & -9 & 7 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & -\\frac{157}{82} & \\frac{131}{410} \\\\\n 0 & 1 & 0 & \\frac{141}{82} & -\\frac{243}{410} \\\\\n 0 & 0 & 1 & -\\frac{177}{82} & \\frac{483}{410} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, -4, -7, -9, -3],\n [1, -10, -7, -4, -2],\n [2, -5, -9, 7, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -6 \\\\\n 5 \\\\\n -3 \\\\\n -5 \\\\\n 9 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -3 \\\\\n -5 \\\\\n 3 \\\\\n 3 \\\\\n 5 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-6],\n [5],\n [-3],\n [-5],\n [9],\n [-5]])\nb = np.array([\n [1],\n [-3],\n [-5],\n [3],\n [3],\n [5],\n [3]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $1$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -9 & -7 & 6 & 7 \\\\\n 7 & 10 & -2 & -4 \\\\\n 7 & 8 & -8 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -9 & -7 & 6 & 7 \\\\\n 7 & 10 & -2 & -4 \\\\\n 7 & 8 & -8 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -7, 6, 7],\n [7, 10, -2, -4],\n [7, 8, -8, 5]])\nprint(a * 1)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 3 & 0 \\\\\n -\\frac{1}{2} & -3 \\\\\n -\\frac{3}{2} & -\\frac{3}{2} \\\\\n \\frac{1}{2} & -\\frac{3}{2} \\\\\n 1 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & -1 & \\frac{3}{2} \\\\\n \\frac{3}{2} & -3 & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{15}{2} & -3 & \\frac{9}{2} \\\\\n -\\frac{23}{4} & \\frac{19}{2} & -\\frac{33}{4} \\\\\n -6 & 6 & -6 \\\\\n -1 & 4 & -3 \\\\\n \\frac{5}{2} & -1 & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 0],\n [-(1/2), -3],\n [-(3/2), -(3/2)],\n [(1/2), -(3/2)],\n [1, 0]])\nb = np.array([\n [(5/2), -1, (3/2)],\n [(3/2), -3, (5/2)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -9 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -6 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 6 \\\\\n -22 \\\\\n 78 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-9],\n [-2]])\nb = np.array([\n [4],\n [-6],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{38}{5} & 1 & -\\frac{24}{5} & -2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n \\frac{28}{5} & \\frac{32}{5} & \\frac{3}{5} & \\frac{14}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{66}{5} & -\\frac{27}{5} & -\\frac{27}{5} & -\\frac{24}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(38/5), 1, -(24/5), -2]])\nb = np.array([\n [(28/5), (32/5), (3/5), (14/5)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{15}{2} \\\\\n \\frac{11}{3} \\\\\n \\frac{25}{6} \\\\\n -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{15}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/2)],\n [(11/3)],\n [(25/6)],\n [-(8/3)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{113}{16} \\\\\n \\frac{121}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{121}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(113/16)],\n [(121/16)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{3}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9]])\nprint(a * (1/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n 1 & -3 & -9 \\\\\n 4 & -6 & -9 \\\\\n 10 & -8 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3, -9],\n [4, -6, -9],\n [10, -8, 4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{\\sqrt{3}} \\\\\n \\frac{2}{\\sqrt{3}} \\\\\n \\frac{11}{\\sqrt{3}} \\\\\n 3 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n -\\frac{10}{\\sqrt{3}} \\\\\n \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\sqrt{3} \\\\\n -\\frac{4}{\\sqrt{3}} \\\\\n \\frac{14}{\\sqrt{3}} \\\\\n -\\frac{1}{\\sqrt{3}} \\\\\n \\frac{5}{\\sqrt{3}} \\\\\n -2 \\sqrt{3} \\\\\n -\\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{143}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(7/(math.sqrt(3)))],\n [(2/(math.sqrt(3)))],\n [(11/(math.sqrt(3)))],\n [3*math.sqrt(3)],\n [4*math.sqrt(3)],\n [-(10/(math.sqrt(3)))],\n [math.sqrt(3)]])\nb = np.array([\n [-5*math.sqrt(3)],\n [-(4/(math.sqrt(3)))],\n [(14/(math.sqrt(3)))],\n [-(1/(math.sqrt(3)))],\n [(5/(math.sqrt(3)))],\n [-2*math.sqrt(3)],\n [-math.sqrt(3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & -1 \\\\\n 2 & -3 \\\\\n 1 & -3 \\\\\n 3 & -1 \\\\\n 3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.27 \\\\\n 0.86 \\\\\n 2.18 \\\\\n 2.66 \\\\\n -2.43 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.046 \\\\\n -0.752 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1],\n [2, -3],\n [1, -3],\n [3, -1],\n [3, 2]])\nb = np.array([\n [1.27],\n [0.86],\n [2.18],\n [2.66],\n [-2.43]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{6}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -5 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{15}{2} \\\\\n -\\frac{25}{6} \\\\\n \\frac{15}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-5],\n [9]])\nprint(a * (5/6))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & 9 \\\\\n 1 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+x-21$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 9],\n [1, -4]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{6} \\\\\n -\\frac{16}{3} \\\\\n \\frac{19}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{6} \\\\\n -\\frac{2}{3} \\\\\n -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 27 \\\\\n \\frac{457}{36} \\\\\n -\\frac{25}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/6)],\n [-(16/3)],\n [(19/6)]])\nb = np.array([\n [-(1/6)],\n [-(2/3)],\n [-(14/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 4 & 3 & -4 & 5 & -9 & -10 & -1 \\\\\n -4 & 3 & 8 & -7 & 2 & 4 & -3 \\\\\n -8 & -8 & 7 & -3 & 4 & 1 & 2 \\\\\n 1 & -2 & -6 & 8 & 8 & -2 & 9 \\\\\n 4 & 9 & -8 & -10 & -10 & 3 & -8 \\\\\n 8 & -10 & -4 & 5 & -4 & 4 & 9 \\\\\n -4 & 10 & 7 & -1 & 9 & -1 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, 3, -4, 5, -9, -10, -1],\n [-4, 3, 8, -7, 2, 4, -3],\n [-8, -8, 7, -3, 4, 1, 2],\n [1, -2, -6, 8, 8, -2, 9],\n [4, 9, -8, -10, -10, 3, -8],\n [8, -10, -4, 5, -4, 4, 9],\n [-4, 10, 7, -1, 9, -1, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{2} & 0 & \\frac{5}{2} \\\\\n 1 & 2 & 1 \\\\\n -\\frac{5}{2} & 2 & 1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -6 & 5 & \\frac{5}{4} \\\\\n -1 & 6 & \\frac{11}{2} \\\\\n \\frac{3}{4} & 6 & -\\frac{13}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), 0, (5/2)],\n [1, 2, 1],\n [-(5/2), 2, 1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & -3 \\\\\n -1 & -1 \\\\\n -1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.94 \\\\\n -2.89 \\\\\n 0.17 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.052 \\\\\n 0.059 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3],\n [-1, -1],\n [-1, 2]])\nb = np.array([\n [0.94],\n [-2.89],\n [0.17]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 6 & 4 \\\\\n -8 & 0 \\\\\n 8 & -4 \\\\\n 7 & -4 \\\\\n 5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [6, 4],\n [-8, 0],\n [8, -4],\n [7, -4],\n [5, -4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -7 & 8 \\\\\n -7 & -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -6 & -7 \\\\\n -6 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -13 & 1 \\\\\n -13 & -10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 8],\n [-7, -7]])\nb = np.array([\n [-6, -7],\n [-6, -3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & 7 & -7 \\\\\n 4 & -2 & -4 \\\\\n 0 & -6 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8.703,-2.766,10.469\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 7, -7],\n [4, -2, -4],\n [0, -6, -6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 3 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 5 \\\\\n 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 35 \\\\\n 70 \\\\\n -10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [3],\n [-7]])\nb = np.array([\n [-10],\n [5],\n [0]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{21}{4} & -\\frac{35}{4} & \\frac{1}{4} \\\\\n \\frac{37}{4} & -\\frac{5}{4} & \\frac{5}{4} \\\\\n -\\frac{17}{2} & -\\frac{3}{4} & -\\frac{7}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-0.51,1.38\\, -8.363 i,1.38\\, +8.363 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(21/4), -(35/4), (1/4)],\n [(37/4), -(5/4), (5/4)],\n [-(17/2), -(3/4), -(7/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -3 & 0 \\\\\n -6 & 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -7 & 2 \\\\\n -5 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -10 & 2 \\\\\n -11 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0],\n [-6, 4]])\nb = np.array([\n [-7, 2],\n [-5, 1]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -7 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 8 \\\\\n 0 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 4 \\\\\n -15 \\\\\n -2 \\\\\n 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-7],\n [-2],\n [1]])\nb = np.array([\n [-3],\n [8],\n [0],\n [-5]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{16}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{7}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2]])\nprint(a * -(7/16))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{6}{5}, -\\frac{23}{5}}$ to the line $\\frac{17 x}{5}-5 y+\\frac{2}{5}=0$.", - "Output Answer": [ - "$\\frac{687}{5 \\sqrt{914}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (6/5), -(23/5)\nline = Poly(((17*x)/5)-5*y+(2/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 10 & 0 \\\\\n -8 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 7 & 3 \\\\\n -4 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 17 & 3 \\\\\n -12 & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 0],\n [-8, 2]])\nb = np.array([\n [7, 3],\n [-4, -9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 0 & -2 & 3 & 3 \\\\\n -1 & -2 & -6 & -3 \\\\\n -5 & -3 & 0 & 3 \\\\\n 9 & -1 & -1 & 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 9 & -5 & 4 & 5 \\\\\n 0 & 9 & -10 & -4 \\\\\n 4 & 8 & 5 & -3 \\\\\n 5 & 7 & 7 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 9 & -7 & 7 & 8 \\\\\n -1 & 7 & -16 & -7 \\\\\n -1 & 5 & 5 & 0 \\\\\n 14 & 6 & 6 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2, 3, 3],\n [-1, -2, -6, -3],\n [-5, -3, 0, 3],\n [9, -1, -1, 5]])\nb = np.array([\n [9, -5, 4, 5],\n [0, 9, -10, -4],\n [4, 8, 5, -3],\n [5, 7, 7, -3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & 1 & -3 \\\\\n 0 & -2 & -3 \\\\\n -3 & -1 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{53} & -\\frac{2}{53} & -\\frac{9}{53} \\\\\n \\frac{9}{53} & -\\frac{19}{53} & -\\frac{6}{53} \\\\\n -\\frac{6}{53} & -\\frac{5}{53} & \\frac{4}{53} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 1, -3],\n [0, -2, -3],\n [-3, -1, 5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -2 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 9 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -73 \\\\\n 23 \\\\\n 90 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-2],\n [7]])\nb = np.array([\n [9],\n [9],\n [5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{9}{4} & 1 & \\frac{27}{4} \\\\\n \\frac{33}{4} & -5 & -\\frac{7}{4} \\\\\n -\\frac{9}{4} & -\\frac{21}{4} & -\\frac{25}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.877,1.379,1.\\}, \\{0.117\\, -1.005 i,-1.052-0.621 i,1.\\}, \\{0.117\\, +1.005 i,-1.052+0.621 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/4), 1, (27/4)],\n [(33/4), -5, -(7/4)],\n [-(9/4), -(21/4), -(25/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -2 & -2 \\\\\n 1 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -1 & 2 \\\\\n -1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 4 & -4 \\\\\n 0 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2],\n [1, -1]])\nb = np.array([\n [-1, 2],\n [-1, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -\\frac{14}{3} \\\\\n -\\frac{16}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 10 \\\\\n -\\frac{29}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{46}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-(14/3)],\n [-(16/3)]])\nb = np.array([\n [-5],\n [10],\n [-(29/3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 9 \\\\\n 8 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -5 \\\\\n -3 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{26}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [9],\n [8],\n [-10]])\nb = np.array([\n [-2],\n [-5],\n [-3],\n [8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -4 & \\frac{3}{2} \\\\\n \\frac{7}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{13}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, (3/2)],\n [(7/2), -(1/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 5 \\\\\n -6 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [5],\n [-6],\n [3]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -10 & -9 & -1 & -10 & -6 & -2 & 0 \\\\\n -1 & 0 & 10 & -5 & -2 & 2 & 2 \\\\\n 6 & -3 & 10 & 6 & -2 & -1 & -3 \\\\\n 4 & 1 & 6 & 7 & 2 & 10 & 3 \\\\\n 1 & 5 & -9 & 9 & 8 & -10 & 8 \\\\\n 10 & -8 & 0 & -5 & -7 & -9 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & \\frac{106625}{317983} \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & -\\frac{583046}{317983} \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & \\frac{141050}{317983} \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & -\\frac{364031}{317983} \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & \\frac{1271061}{317983} \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & \\frac{27029}{317983} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, -9, -1, -10, -6, -2, 0],\n [-1, 0, 10, -5, -2, 2, 2],\n [6, -3, 10, 6, -2, -1, -3],\n [4, 1, 6, 7, 2, 10, 3],\n [1, 5, -9, 9, 8, -10, 8],\n [10, -8, 0, -5, -7, -9, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{6}{5}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 4 & 2 & -1 & 3 \\\\\n -3 & 0 & -9 & 9 \\\\\n 10 & 1 & 10 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{24}{5} & -\\frac{12}{5} & \\frac{6}{5} & -\\frac{18}{5} \\\\\n \\frac{18}{5} & 0 & \\frac{54}{5} & -\\frac{54}{5} \\\\\n -12 & -\\frac{6}{5} & -12 & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 2, -1, 3],\n [-3, 0, -9, 9],\n [10, 1, 10, 5]])\nprint(a * -(6/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{1}{3},\\frac{7}{3},\\frac{11}{3}\\right\\}, \\left\\{-3,5,\\frac{5}{3}\\right\\}, \\left\\{2,2,\\frac{11}{3}\\right\\}}$.", - "Output Answer": [ - "$3 (x+5 (y+z))-91=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(1/3), (7/3), (11/3)],\n [-3, 5, (5/3)],\n [2, 2, (11/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 10 & -5 & \\frac{13}{2} \\\\\n \\frac{7}{2} & -9 & 6 \\\\\n \\frac{19}{2} & \\frac{13}{2} & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-11.191,2.283,15.908\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -5, (13/2)],\n [(7/2), -9, 6],\n [(19/2), (13/2), 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{50}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -7 & 4 & 8 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{7}{50} & -\\frac{2}{25} & -\\frac{4}{25} & \\frac{7}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 4, 8, -7]])\nprint(a * -(1/50))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6.5 \\\\\n 0.8 \\\\\n 2.8 \\\\\n 3.7 \\\\\n -9.2 \\\\\n 7.4 \\\\\n -0.9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6.7 \\\\\n -2.8 \\\\\n -3.3 \\\\\n 1.2 \\\\\n 8.9 \\\\\n 3.3 \\\\\n -2.2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-106.07$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6.5],\n [0.8],\n [2.8],\n [3.7],\n [-9.2],\n [7.4],\n [-0.9]])\nb = np.array([\n [6.7],\n [-2.8],\n [-3.3],\n [1.2],\n [8.9],\n [3.3],\n [-2.2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-2$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 6 & 5 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -12 & -10 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 5, -3]])\nprint(a * -2)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -2 & -1 \\\\\n -3 & 3 \\\\\n -1 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 1 & 2 & -2 & 0 & 0 \\\\\n 1 & 2 & -1 & 2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -3 & -6 & 5 & -2 & 2 \\\\\n 0 & 0 & 3 & 6 & -6 \\\\\n 0 & 0 & 1 & 2 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1],\n [-3, 3],\n [-1, 1]])\nb = np.array([\n [1, 2, -2, 0, 0],\n [1, 2, -1, 2, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 0 & 3 \\\\\n 0 & -3 \\\\\n 5 & 0 \\\\\n 0 & -8 \\\\\n 9 & 0 \\\\\n -6 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, 3],\n [0, -3],\n [5, 0],\n [0, -8],\n [9, 0],\n [-6, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -2 \\\\\n -6 \\\\\n -9 \\\\\n 6 \\\\\n 1 \\\\\n 5 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -4 \\\\\n 4 \\\\\n -4 \\\\\n 8 \\\\\n 6 \\\\\n -2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$86$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-2],\n [-6],\n [-9],\n [6],\n [1],\n [5],\n [9]])\nb = np.array([\n [-8],\n [-4],\n [4],\n [-4],\n [8],\n [6],\n [-2],\n [-2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,3,-2\\}, \\{-1,2,2\\}, \\{3,1,1\\}}$", - "Output Answer": [ - "${\\left\\{0,\\frac{3}{\\sqrt{13}},-\\frac{2}{\\sqrt{13}}\\right\\}, \\left\\{-\\sqrt{\\frac{13}{113}},\\frac{20}{\\sqrt{1469}},\\frac{30}{\\sqrt{1469}}\\right\\}, \\left\\{\\frac{10}{\\sqrt{113}},\\frac{2}{\\sqrt{113}},\\frac{3}{\\sqrt{113}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, 3, -2), (-1, 2, 2), (3, 1, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -1 & -1 & -1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n -2 & -2 & -2 & -2 \\\\\n -3 & -3 & -3 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [2],\n [3]])\nb = np.array([\n [-1, -1, -1, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{3} \\\\\n \\frac{25}{3} \\\\\n \\frac{22}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{26}{3} \\\\\n -8 \\\\\n -\\frac{28}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{\\frac{1954}{3}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3)],\n [(25/3)],\n [(22/3)]])\nb = np.array([\n [-(26/3)],\n [-8],\n [-(28/3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & -5 \\\\\n -5 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-3 x-53$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -5],\n [-5, -4]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -5 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -9 \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -28 \\\\\n 6 \\\\\n -43 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-5],\n [-2]])\nb = np.array([\n [-5],\n [-9],\n [2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2 & \\frac{1}{2} & \\frac{1}{2} \\\\\n -1 & \\frac{5}{2} & 0 \\\\\n -\\frac{5}{2} & -3 & 1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{9}{4} & -\\frac{5}{4} & -\\frac{1}{2} \\\\\n -\\frac{1}{2} & \\frac{23}{4} & -\\frac{1}{2} \\\\\n \\frac{11}{2} & -\\frac{47}{4} & -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, (1/2), (1/2)],\n [-1, (5/2), 0],\n [-(5/2), -3, 1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{5}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10]])\nprint(a * (1/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 1 & -\\frac{1}{3} & \\frac{8}{3} & -\\frac{4}{3} & \\frac{5}{3} \\\\\n 2 & -\\frac{2}{3} & -\\frac{1}{3} & -2 & 2 \\\\\n -2 & -\\frac{1}{3} & -\\frac{4}{3} & \\frac{4}{3} & -\\frac{5}{3} \\\\\n \\frac{2}{3} & \\frac{8}{3} & -1 & \\frac{4}{3} & -\\frac{1}{3} \\\\\n 2 & -2 & -\\frac{2}{3} & \\frac{1}{3} & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 0 & -2 & 1 & \\frac{8}{3} \\\\\n -\\frac{1}{3} & 1 & -\\frac{7}{3} & \\frac{2}{3} \\\\\n \\frac{7}{3} & -\\frac{5}{3} & 1 & -\\frac{2}{3} \\\\\n \\frac{4}{3} & 0 & -\\frac{8}{3} & -\\frac{1}{3} \\\\\n 3 & \\frac{5}{3} & -1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{86}{9} & -4 & \\frac{19}{3} & -\\frac{20}{9} \\\\\n \\frac{25}{9} & -\\frac{7}{9} & \\frac{59}{9} & \\frac{16}{9} \\\\\n -\\frac{56}{9} & \\frac{28}{9} & -\\frac{40}{9} & -\\frac{16}{9} \\\\\n -\\frac{22}{9} & \\frac{22}{9} & -\\frac{88}{9} & \\frac{40}{9} \\\\\n \\frac{23}{9} & -\\frac{29}{9} & \\frac{37}{9} & \\frac{7}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(1/3), (8/3), -(4/3), (5/3)],\n [2, -(2/3), -(1/3), -2, 2],\n [-2, -(1/3), -(4/3), (4/3), -(5/3)],\n [(2/3), (8/3), -1, (4/3), -(1/3)],\n [2, -2, -(2/3), (1/3), 1]])\nb = np.array([\n [0, -2, 1, (8/3)],\n [-(1/3), 1, -(7/3), (2/3)],\n [(7/3), -(5/3), 1, -(2/3)],\n [(4/3), 0, -(8/3), -(1/3)],\n [3, (5/3), -1, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n 6 & 7 \\\\\n 4 & 5 \\\\\n 9 & -4 \\\\\n -4 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 7],\n [4, 5],\n [9, -4],\n [-4, 6]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 3 \\\\\n 1 & 0 \\\\\n -3 & 0 \\\\\n -2 & 2 \\\\\n 0 & -3 \\\\\n -1 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.97 \\\\\n -1.4 \\\\\n 2.95 \\\\\n 2.16 \\\\\n -0.51 \\\\\n -1.27 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.028 \\\\\n 0.091 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3],\n [1, 0],\n [-3, 0],\n [-2, 2],\n [0, -3],\n [-1, -3]])\nb = np.array([\n [-2.97],\n [-1.4],\n [2.95],\n [2.16],\n [-0.51],\n [-1.27]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{3} & \\frac{19}{3} & 9 \\\\\n \\frac{23}{6} & \\frac{23}{6} & -\\frac{55}{6} \\\\\n -\\frac{23}{3} & -\\frac{3}{2} & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{2} & \\frac{53}{6} & 9 \\\\\n -9 & 7 & \\frac{22}{3} \\\\\n \\frac{55}{6} & \\frac{11}{6} & -\\frac{25}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{6} & \\frac{91}{6} & 18 \\\\\n -\\frac{31}{6} & \\frac{65}{6} & -\\frac{11}{6} \\\\\n \\frac{3}{2} & \\frac{1}{3} & -\\frac{26}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/3), (19/3), 9],\n [(23/6), (23/6), -(55/6)],\n [-(23/3), -(3/2), -(1/3)]])\nb = np.array([\n [(3/2), (53/6), 9],\n [-9, 7, (22/3)],\n [(55/6), (11/6), -(25/3)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{28}{3} \\\\\n 4 \\\\\n -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{2} \\\\\n -\\frac{25}{3} \\\\\n -\\frac{19}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{6} \\\\\n \\frac{37}{3} \\\\\n \\frac{47}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(28/3)],\n [4],\n [-(5/3)]])\nb = np.array([\n [-(19/2)],\n [-(25/3)],\n [-(19/2)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${4, -4, -5}$ to the plane $x+4 y+4 z-4=0$.", - "Output Answer": [ - "$12 \\sqrt{\\frac{3}{11}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 4, -4, -5\nplane = Poly(x+4*y+4*z-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -8 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 6 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{206}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-8],\n [-4]])\nb = np.array([\n [-6],\n [6],\n [-1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 1 \\\\\n 1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1],\n [1, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & 4 \\\\\n -4 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{3}{2} \\left(1-i \\sqrt{7}\\right),\\frac{3}{2} \\left(1+i \\sqrt{7}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 4],\n [-4, 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n -\\frac{3}{2} \\\\\n \\frac{1}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{15}{8} \\\\\n \\frac{15}{8} \\\\\n -\\frac{5}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2)],\n [-(3/2)],\n [(1/8)]])\nb = np.array([\n [-(5/4)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -3 & -1 \\\\\n 4 & 1 & -2 \\\\\n 0 & -1 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-49$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -3, -1],\n [4, 1, -2],\n [0, -1, -5]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${5, 4, -\\frac{1}{2}}$ to the plane $-\\frac{x}{2}+y-\\frac{5 z}{2}+3=0$.", - "Output Answer": [ - "$\\frac{23}{2 \\sqrt{30}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 5, 4, -(1/2)\nplane = Poly(-(x/2)+y-((5*z)/2)+3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 4 & \\frac{73}{8} & -\\frac{19}{2} & -\\frac{19}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -3 & -\\frac{27}{4} & \\frac{13}{8} & -\\frac{59}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 7 & \\frac{127}{8} & -\\frac{89}{8} & \\frac{21}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, (73/8), -(19/2), -(19/4)]])\nb = np.array([\n [-3, -(27/4), (13/8), -(59/8)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -\\frac{43}{7} & 4 \\\\\n \\frac{43}{7} & \\frac{53}{7} \\\\\n \\frac{55}{7} & -\\frac{16}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(43/7), 4],\n [(43/7), (53/7)],\n [(55/7), -(16/7)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-5,1,0\\}, \\{0,2,5\\}, \\{1,2,-1\\}}$.", - "Output Answer": [ - "$6 x-35 y+z+65=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-5, 1, 0],\n [0, 2, 5],\n [1, 2, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{5} & \\frac{7}{5} \\\\\n -5 & \\frac{22}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{21}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/5), (7/5)],\n [-5, (22/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -2 & 0 & -2 \\\\\n 1 & 3 & -2 \\\\\n 1 & -3 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 1 & -2 \\\\\n 0 & 1 \\\\\n 1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -4 & 4 \\\\\n -1 & 1 \\\\\n 2 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, -2],\n [1, 3, -2],\n [1, -3, 1]])\nb = np.array([\n [1, -2],\n [0, 1],\n [1, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,-3,3\\}, \\left\\{2,\\frac{9}{2},0\\right\\}, \\left\\{\\frac{7}{2},\\frac{1}{2},\\frac{1}{2}\\right\\}}$.", - "Output Answer": [ - "$33 x+28 y+125 z-192=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, -3, 3],\n [2, (9/2), 0],\n [(7/2), (1/2), (1/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\sqrt{2} \\\\\n -5 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\sqrt{2} \\\\\n 5 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{202}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [5*math.sqrt(2)],\n [-5*math.sqrt(2)]])\nb = np.array([\n [6*math.sqrt(2)],\n [5*math.sqrt(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{2} & -\\frac{1}{2} & \\frac{11}{2} \\\\\n 8 & 1 & -\\frac{7}{2} \\\\\n -2 & -9 & -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{2} & -2 & 10 \\\\\n -8 & -4 & -\\frac{15}{2} \\\\\n \\frac{15}{2} & \\frac{11}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -5 & -\\frac{5}{2} & \\frac{31}{2} \\\\\n 0 & -3 & -11 \\\\\n \\frac{11}{2} & -\\frac{7}{2} & -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), -(1/2), (11/2)],\n [8, 1, -(7/2)],\n [-2, -9, -8]])\nb = np.array([\n [-(5/2), -2, 10],\n [-8, -4, -(15/2)],\n [(15/2), (11/2), -(1/2)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & -3 & 3 \\\\\n 3 & -1 & 2 \\\\\n 2 & -1 & 2 \\\\\n -2 & 1 & -2 \\\\\n 2 & -1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.15 \\\\\n 1.87 \\\\\n -0.63 \\\\\n 0.07 \\\\\n -0.83 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.308 \\\\\n 0.414 \\\\\n 0.761 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3, 3],\n [3, -1, 2],\n [2, -1, 2],\n [-2, 1, -2],\n [2, -1, 1]])\nb = np.array([\n [2.15],\n [1.87],\n [-0.63],\n [0.07],\n [-0.83]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -10 & 6 & -5 & -5 \\\\\n -7 & 7 & -1 & -4 \\\\\n 4 & -9 & 1 & -5 \\\\\n 8 & 1 & -5 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 6, -5, -5],\n [-7, 7, -1, -4],\n [4, -9, 1, -5],\n [8, 1, -5, -8]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n \\frac{11}{3} & 6 & \\frac{22}{3} & \\frac{28}{3} \\\\\n \\frac{26}{3} & \\frac{28}{3} & \\frac{19}{3} & -\\frac{17}{3} \\\\\n \\frac{29}{3} & \\frac{1}{3} & \\frac{11}{3} & -\\frac{17}{3} \\\\\n \\frac{19}{3} & -8 & \\frac{4}{3} & 2 \\\\\n 5 & 4 & \\frac{1}{3} & \\frac{20}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/3), 6, (22/3), (28/3)],\n [(26/3), (28/3), (19/3), -(17/3)],\n [(29/3), (1/3), (11/3), -(17/3)],\n [(19/3), -8, (4/3), 2],\n [5, 4, (1/3), (20/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 8 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -6 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -32 \\\\\n -28 \\\\\n 50 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [8],\n [0]])\nb = np.array([\n [-1],\n [-6],\n [-4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -2 & -6 & 6 \\\\\n 1 & -4 & 9 \\\\\n -2 & -7 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, -6, 6],\n [1, -4, 9],\n [-2, -7, -4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 0 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 0 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -45 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [0],\n [-5]])\nb = np.array([\n [2],\n [0],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{1}{2},-2,-2\\right\\}, \\left\\{3,-\\frac{9}{2},5\\right\\}, \\left\\{-5,3,\\frac{7}{2}\\right\\}}$.", - "Output Answer": [ - "$390 x+406 y-50 z+907=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(1/2), -2, -2],\n [3, -(9/2), 5],\n [-5, 3, (7/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & -1 & 2 \\\\\n 0 & -1 & 0 \\\\\n -1 & -3 & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & -7 & 4 \\\\\n 0 & -1 & 0 \\\\\n -2 & 4 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1, 2],\n [0, -1, 0],\n [-1, -3, 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{23}{5} & \\frac{32}{5} & \\frac{43}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{23}{5} & -\\frac{36}{5} & -\\frac{48}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & -\\frac{4}{5} & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/5), (32/5), (43/5)]])\nb = np.array([\n [(23/5), -(36/5), -(48/5)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,-2,-2\\}, \\{1,2,-2\\}, \\{-2,0,-2\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}}\\right\\}, \\left\\{\\sqrt{\\frac{2}{39}},\\frac{7}{\\sqrt{78}},-\\frac{5}{\\sqrt{78}}\\right\\}, \\left\\{-2 \\sqrt{\\frac{2}{13}},-\\frac{1}{\\sqrt{26}},-\\frac{3}{\\sqrt{26}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, -2, -2), (1, 2, -2), (-2, 0, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -3 & 3 & 0 \\\\\n 0 & 3 & -2 \\\\\n 0 & -2 & -2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -27 & 39 & 12 \\\\\n 0 & 43 & -22 \\\\\n 0 & -22 & -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 3, 0],\n [0, 3, -2],\n [0, -2, -2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n \\frac{23}{10} & 2 \\\\\n \\frac{5}{2} & 0 \\\\\n \\frac{1}{2} & \\frac{7}{10} \\\\\n \\frac{1}{2} & -\\frac{1}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{11}{5} & -\\frac{3}{2} & \\frac{19}{10} \\\\\n -\\frac{7}{10} & \\frac{1}{10} & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{183}{50} & -\\frac{13}{4} & \\frac{237}{100} \\\\\n \\frac{11}{2} & -\\frac{15}{4} & \\frac{19}{4} \\\\\n \\frac{61}{100} & -\\frac{17}{25} & \\frac{1}{4} \\\\\n \\frac{117}{100} & -\\frac{19}{25} & \\frac{21}{20} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/10), 2],\n [(5/2), 0],\n [(1/2), (7/10)],\n [(1/2), -(1/10)]])\nb = np.array([\n [(11/5), -(3/2), (19/10)],\n [-(7/10), (1/10), -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 9 & 4 & 10 & -8 & -6 & -4 \\\\\n 8 & -4 & -1 & -6 & 3 & -8 \\\\\n 3 & -4 & 4 & -10 & -8 & 3 \\\\\n 9 & 4 & -4 & 5 & -7 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & \\frac{465}{121} & -\\frac{931}{242} \\\\\n 0 & 1 & 0 & 0 & -\\frac{6899}{484} & \\frac{11397}{968} \\\\\n 0 & 0 & 1 & 0 & \\frac{1382}{121} & -\\frac{2341}{242} \\\\\n 0 & 0 & 0 & 1 & \\frac{1479}{121} & -\\frac{1214}{121} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, 4, 10, -8, -6, -4],\n [8, -4, -1, -6, 3, -8],\n [3, -4, 4, -10, -8, 3],\n [9, 4, -4, 5, -7, 1]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{31}{7}, \\frac{20}{7}}$ to the line $-\\frac{30 x}{7}+3 y-\\frac{24}{7}=0$.", - "Output Answer": [ - "$\\frac{394}{7 \\sqrt{149}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(31/7), (20/7)\nline = Poly(-((30*x)/7)+3*y-(24/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{4,-\\frac{1}{3},\\frac{11}{3}\\right\\}, \\left\\{-1,-\\frac{5}{3},\\frac{14}{3}\\right\\}, \\left\\{-4,\\frac{14}{3},\\frac{7}{3}\\right\\}}$.", - "Output Answer": [ - "$29 x+132 y+321 z-1249=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, -(1/3), (11/3)],\n [-1, -(5/3), (14/3)],\n [-4, (14/3), (7/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & -3 & 3 \\\\\n 3 & 1 & -3 \\\\\n -2 & -2 & 3 \\\\\n 0 & -1 & 1 \\\\\n 1 & 3 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.87 \\\\\n -0.74 \\\\\n 1.88 \\\\\n 0.35 \\\\\n 1.03 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.477 \\\\\n 0.373 \\\\\n 0.199 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3, 3],\n [3, 1, -3],\n [-2, -2, 3],\n [0, -1, 1],\n [1, 3, 1]])\nb = np.array([\n [-1.87],\n [-0.74],\n [1.88],\n [0.35],\n [1.03]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -7 & 7 & -2 & 1 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-8.,0.,0.,0.,7.\\}, \\{-2.,0.,7.,0.,0.\\}, \\{1.,0.,0.,7.,0.\\}, \\{1.,1.,0.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, 7, -2, 1, -8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 2 & -1 & -3 & -1 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -1 & 1 & -2 \\\\\n 1 & 1 & 3 \\\\\n -3 & 3 & -2 \\\\\n -3 & 0 & 3 \\\\\n 0 & 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 9 & -8 & -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1, -3, -1, -2]])\nb = np.array([\n [-1, 1, -2],\n [1, 1, 3],\n [-3, 3, -2],\n [-3, 0, 3],\n [0, 0, 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n -5 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -3 \\\\\n -8 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9 \\sqrt{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [-5],\n [-4]])\nb = np.array([\n [10],\n [-3],\n [-8],\n [0]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,-3,3\\}, \\{4,-3,2\\}, \\{-3,4,-3\\}}$.", - "Output Answer": [ - "$7 x+32 y+35 z-2=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, -3, 3],\n [4, -3, 2],\n [-3, 4, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{2}{5}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & 0 & -1 & 4 \\\\\n 4 & 9 & 9 & -6 \\\\\n 3 & 8 & 4 & -7 \\\\\n 0 & -8 & 4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{6}{5} & 0 & \\frac{2}{5} & -\\frac{8}{5} \\\\\n -\\frac{8}{5} & -\\frac{18}{5} & -\\frac{18}{5} & \\frac{12}{5} \\\\\n -\\frac{6}{5} & -\\frac{16}{5} & -\\frac{8}{5} & \\frac{14}{5} \\\\\n 0 & \\frac{16}{5} & -\\frac{8}{5} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, -1, 4],\n [4, 9, 9, -6],\n [3, 8, 4, -7],\n [0, -8, 4, 0]])\nprint(a * -(2/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 5 & -4 & 7 & -8 \\\\\n -8 & 6 & -7 & 9 \\\\\n -4 & -6 & -2 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 0 & 4 & -1 & -5 \\\\\n -4 & 3 & 1 & -6 \\\\\n -1 & 0 & -4 & -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 5 & 0 & 6 & -13 \\\\\n -12 & 9 & -6 & 3 \\\\\n -5 & -6 & -6 & -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -4, 7, -8],\n [-8, 6, -7, 9],\n [-4, -6, -2, -2]])\nb = np.array([\n [0, 4, -1, -5],\n [-4, 3, 1, -6],\n [-1, 0, -4, -10]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 6 & -3 & 2 & 7 & -6 & -7 & -1 \\\\\n 0 & 10 & -10 & -4 & -2 & 8 & 8 \\\\\n 9 & 9 & 0 & -7 & -4 & 8 & -10 \\\\\n -4 & -6 & 7 & 6 & 6 & 1 & 1 \\\\\n 5 & -2 & -8 & -4 & 7 & -3 & 8 \\\\\n -10 & -2 & 8 & -2 & -9 & -8 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & -\\frac{20415}{20567} \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & \\frac{277892}{20567} \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & \\frac{61405}{20567} \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & \\frac{71913}{20567} \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & \\frac{153445}{20567} \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & -\\frac{175724}{20567} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, -3, 2, 7, -6, -7, -1],\n [0, 10, -10, -4, -2, 8, 8],\n [9, 9, 0, -7, -4, 8, -10],\n [-4, -6, 7, 6, 6, 1, 1],\n [5, -2, -8, -4, 7, -3, 8],\n [-10, -2, 8, -2, -9, -8, 1]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 3 & 4 & -9 \\\\\n -6 & -5 & -5 \\\\\n 9 & 1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.768,3.805,1.\\}, \\{0.372\\, -1.104 i,-0.798-0.274 i,1.\\}, \\{0.372\\, +1.104 i,-0.798+0.274 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 4, -9],\n [-6, -5, -5],\n [9, 1, -2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n \\frac{47}{16} \\\\\n -\\frac{19}{16} \\\\\n -1 \\\\\n -\\frac{69}{16} \\\\\n \\frac{3}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{171}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2)],\n [(47/16)],\n [-(19/16)],\n [-1],\n [-(69/16)],\n [(3/4)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 7 & 8 & 3 \\\\\n -10 & 8 & 2 \\\\\n 4 & 9 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+10 x^2-31 x-1108$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 8, 3],\n [-10, 8, 2],\n [4, 9, -5]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-5,-4,-4\\}, \\{0,-2,-1\\}, \\{0,1,2\\}}$.", - "Output Answer": [ - "$x+5 y-5 z+5=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-5, -4, -4],\n [0, -2, -1],\n [0, 1, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 3 \\\\\n -2 \\\\\n 0 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -2 & 2 & 1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -4 & 4 & 2 & 0 \\\\\n -6 & 6 & 3 & 0 \\\\\n 4 & -4 & -2 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n -4 & 4 & 2 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [3],\n [-2],\n [0],\n [2]])\nb = np.array([\n [-2, 2, 1, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{2}{3} & \\frac{10}{3} \\\\\n -10 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{30} \\left(-13-i \\sqrt{131}\\right),1\\right\\}, \\left\\{\\frac{1}{30} \\left(-13+i \\sqrt{131}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/3), (10/3)],\n [-10, -8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{8} \\\\\n -\\frac{5}{2} \\\\\n -\\frac{9}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{17}{\\sqrt{770}} \\\\\n -2 \\sqrt{\\frac{10}{77}} \\\\\n -\\frac{9}{\\sqrt{770}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/8)],\n [-(5/2)],\n [-(9/8)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -6 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-6],\n [9]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{131}{16} & \\frac{37}{8} & \\frac{127}{16} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{8} & -\\frac{37}{4} & -\\frac{41}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{141}{16} & \\frac{111}{8} & \\frac{21}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(131/16), (37/8), (127/16)]])\nb = np.array([\n [-(5/8), -(37/4), -(41/16)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -8 \\\\\n -6 \\\\\n -5 \\\\\n 9 \\\\\n 0 \\\\\n -3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -6 \\\\\n 9 \\\\\n -2 \\\\\n -1 \\\\\n -1 \\\\\n 8 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{494}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-8],\n [-6],\n [-5],\n [9],\n [0],\n [-3],\n [1]])\nb = np.array([\n [-4],\n [-6],\n [9],\n [-2],\n [-1],\n [-1],\n [8],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -10 & -4 \\\\\n 7 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+15 x+78$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -4],\n [7, -5]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{12}{7} & -8 & \\frac{18}{7} \\\\\n \\frac{3}{7} & -\\frac{30}{7} & \\frac{55}{7} \\\\\n \\frac{8}{7} & \\frac{16}{7} & \\frac{46}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+4 x^2+\\frac{292 x}{7}-\\frac{38848}{343}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(12/7), -8, (18/7)],\n [(3/7), -(30/7), (55/7)],\n [(8/7), (16/7), (46/7)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 3 \\\\\n -2 & 2 \\\\\n -3 & -1 \\\\\n 0 & 3 \\\\\n 3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.18 \\\\\n 1.96 \\\\\n 0.81 \\\\\n -0.78 \\\\\n 0.33 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.28 \\\\\n -0.106 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3],\n [-2, 2],\n [-3, -1],\n [0, 3],\n [3, -2]])\nb = np.array([\n [-1.18],\n [1.96],\n [0.81],\n [-0.78],\n [0.33]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{15}{8} \\\\\n \\frac{21}{8} \\\\\n 1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{15}{\\sqrt{986}} \\\\\n \\frac{21}{\\sqrt{986}} \\\\\n 4 \\sqrt{\\frac{2}{493}} \\\\\n -8 \\sqrt{\\frac{2}{493}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/8)],\n [(21/8)],\n [1],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 2 \\\\\n 1 \\\\\n 2 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n -2 \\\\\n -1 \\\\\n 0 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{9}{11},\\frac{9}{11},\\frac{9}{11},\\frac{9}{22},0,\\frac{27}{22}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [2],\n [1],\n [2],\n [0],\n [-1]]).squeeze()\nb = np.array([\n [2],\n [-2],\n [-2],\n [-1],\n [0],\n [-3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 3 & 1 & -1 \\\\\n -2 & -1 & -1 \\\\\n -3 & -3 & 2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 10 & 5 & -6 \\\\\n -1 & 2 & 1 \\\\\n -9 & -6 & 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1, -1],\n [-2, -1, -1],\n [-3, -3, 2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2.231 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5.639 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-12.5806$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2.231]])\nb = np.array([\n [-5.639]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{2} & 1 \\\\\n \\frac{9}{2} & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{9}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2), 1],\n [(9/2), 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 8 \\\\\n 3 \\\\\n 8 \\\\\n -5 \\\\\n 9 \\\\\n 7 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 2 \\\\\n -1 \\\\\n -4 \\\\\n -4 \\\\\n 10 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$160$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [8],\n [3],\n [8],\n [-5],\n [9],\n [7],\n [-6]])\nb = np.array([\n [-8],\n [2],\n [-1],\n [-4],\n [-4],\n [10],\n [1],\n [-1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{24}{5}, -\\frac{13}{5}, 3}$ to the plane $-\\frac{21 x}{5}-\\frac{16 y}{5}-\\frac{17 z}{5}+4=0$.", - "Output Answer": [ - "$\\frac{557}{5 \\sqrt{986}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(24/5), -(13/5), 3\nplane = Poly(-((21*x)/5)-((16*y)/5)-((17*z)/5)+4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 3 & -1 & 2 \\\\\n -1 & -2 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 0 & 1 & -3 \\\\\n -3 & -1 & 0 \\\\\n 2 & -2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 7 & 0 & -9 \\\\\n 8 & -1 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, 2],\n [-1, -2, 1]])\nb = np.array([\n [0, 1, -3],\n [-3, -1, 0],\n [2, -2, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 5 & 7 \\\\\n -2 & 6 \\\\\n 7 & 6 \\\\\n -10 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, 7],\n [-2, 6],\n [7, 6],\n [-10, -5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 5 & 8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -7 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 12 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 8]])\nb = np.array([\n [-7, 6]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{9}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{23}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8]])\nb = np.array([\n [(9/4)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 6 \\\\\n -8 \\\\\n -1 \\\\\n -5 \\\\\n -9 \\\\\n 10 \\\\\n -6 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 6 \\\\\n 0 \\\\\n 3 \\\\\n 10 \\\\\n -7 \\\\\n -5 \\\\\n -4 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{237}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [6],\n [-8],\n [-1],\n [-5],\n [-9],\n [10],\n [-6],\n [-8]])\nb = np.array([\n [-9],\n [6],\n [0],\n [3],\n [10],\n [-7],\n [-5],\n [-4],\n [3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 7 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 5 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 11 \\\\\n 43 \\\\\n -31 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [7],\n [9]])\nb = np.array([\n [3],\n [5],\n [8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{15}{7}, \\frac{30}{7}}$ to the line $\\frac{29 x}{7}-\\frac{24 y}{7}+\\frac{17}{7}=0$.", - "Output Answer": [ - "$\\frac{166}{7 \\sqrt{1417}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (15/7), (30/7)\nline = Poly(((29*x)/7)-((24*y)/7)+(17/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -6 & -\\frac{18}{5} \\\\\n -\\frac{4}{5} & -\\frac{22}{5} \\\\\n 5 & -\\frac{2}{5} \\\\\n -\\frac{42}{5} & -\\frac{48}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{2}{5} & -\\frac{4}{5} \\\\\n \\frac{34}{5} & 6 \\\\\n -\\frac{32}{5} & -\\frac{3}{5} \\\\\n 9 & \\frac{27}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{28}{5} & -\\frac{22}{5} \\\\\n 6 & \\frac{8}{5} \\\\\n -\\frac{7}{5} & -1 \\\\\n \\frac{3}{5} & -\\frac{21}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -(18/5)],\n [-(4/5), -(22/5)],\n [5, -(2/5)],\n [-(42/5), -(48/5)]])\nb = np.array([\n [(2/5), -(4/5)],\n [(34/5), 6],\n [-(32/5), -(3/5)],\n [9, (27/5)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n \\frac{19}{2} \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{11}{2} \\\\\n -\\frac{13}{2} \\\\\n \\frac{17}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{203}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [(19/2)],\n [(1/2)]])\nb = np.array([\n [(11/2)],\n [-(13/2)],\n [(17/2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & -\\frac{5}{2} & 0 \\\\\n -\\frac{1}{2} & -2 & \\frac{5}{2} \\\\\n 3 & -\\frac{1}{2} & 3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{71}{4} & -\\frac{15}{2} & -\\frac{25}{2} \\\\\n \\frac{27}{2} & -\\frac{117}{4} & \\frac{35}{2} \\\\\n \\frac{79}{2} & -\\frac{37}{2} & \\frac{13}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(5/2), 0],\n [-(1/2), -2, (5/2)],\n [3, -(1/2), 3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, \\frac{7}{3}, \\frac{5}{3}}$ to the plane $\\frac{13 x}{3}+\\frac{2 y}{3}+\\frac{11 z}{3}-4=0$.", - "Output Answer": [ - "$\\frac{5 \\sqrt{\\frac{3}{2}}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, (7/3), (5/3)\nplane = Poly(((13*x)/3)+((2*y)/3)+((11*z)/3)-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 2 & 1 & -6 & 5 & -7 \\\\\n 6 & -6 & 1 & 10 & 3 \\\\\n 1 & 4 & 6 & 3 & 1 \\\\\n -5 & 1 & -1 & 2 & -6 \\\\\n 3 & 1 & -3 & 10 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, 1, -6, 5, -7],\n [6, -6, 1, 10, 3],\n [1, 4, 6, 3, 1],\n [-5, 1, -1, 2, -6],\n [3, 1, -3, 10, 7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{9}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 10 & -4 & -10 & -6 \\\\\n 8 & -2 & -2 & 5 \\\\\n -4 & -1 & 7 & -1 \\\\\n 2 & 3 & 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{10}{9} & -\\frac{4}{9} & -\\frac{10}{9} & -\\frac{2}{3} \\\\\n \\frac{8}{9} & -\\frac{2}{9} & -\\frac{2}{9} & \\frac{5}{9} \\\\\n -\\frac{4}{9} & -\\frac{1}{9} & \\frac{7}{9} & -\\frac{1}{9} \\\\\n \\frac{2}{9} & \\frac{1}{3} & 0 & \\frac{2}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -4, -10, -6],\n [8, -2, -2, 5],\n [-4, -1, 7, -1],\n [2, 3, 0, 2]])\nprint(a * (1/9))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & -8 \\\\\n 8 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-7-3 i \\sqrt{7},-7+3 i \\sqrt{7}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -8],\n [8, -8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -\\frac{93}{16} \\\\\n \\frac{143}{16} \\\\\n \\frac{35}{4} \\\\\n \\frac{149}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(93/16)],\n [(143/16)],\n [(35/4)],\n [(149/16)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{10}{3} & 3 \\\\\n 3 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{19 x}{3}+1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(10/3), 3],\n [3, -3]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -1 & 1 & 1 & 2 \\\\\n 0 & 1 & 0 & -3 \\\\\n -3 & -1 & 0 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -3 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -3 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, 1, 2],\n [0, 1, 0, -3],\n [-3, -1, 0, -2]])\nb = np.array([\n [0],\n [0],\n [-3],\n [0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -10 & 8 & 9 \\\\\n 5 & -9 & 5 \\\\\n -6 & 6 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.834,-1.613,1.\\}, \\{1.166\\, -2.582 i,0.807\\, -2.175 i,1.\\}, \\{1.166\\, +2.582 i,0.807\\, +2.175 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 8, 9],\n [5, -9, 5],\n [-6, 6, 0]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & 7 \\\\\n 5 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-15 x+19$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 7],\n [5, 6]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-9]])\nb = np.array([\n [1],\n [1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 1 & -4 & 1 \\\\\n 5 & 2 & -3 \\\\\n 2 & -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{34} & \\frac{3}{34} & \\frac{5}{17} \\\\\n -\\frac{11}{34} & -\\frac{1}{34} & \\frac{4}{17} \\\\\n -\\frac{9}{34} & -\\frac{7}{34} & \\frac{11}{17} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -4, 1],\n [5, 2, -3],\n [2, -1, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{51}{8} \\\\\n \\frac{33}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{49}{8} \\\\\n -\\frac{9}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{25}{2} \\\\\n \\frac{21}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(51/8)],\n [(33/8)]])\nb = np.array([\n [(49/8)],\n [-(9/8)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 4 & 9 & 9 & -9 & 10 & -4 \\\\\n 10 & 2 & 8 & 10 & -3 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & \\frac{27}{41} & \\frac{54}{41} & -\\frac{47}{82} & -\\frac{73}{82} \\\\\n 0 & 1 & \\frac{29}{41} & -\\frac{65}{41} & \\frac{56}{41} & -\\frac{2}{41} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, 9, 9, -9, 10, -4],\n [10, 2, 8, 10, -3, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -3 & -4 & 2 & 7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 1 & -3 & -1 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -4 & -1 & 3 & 15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -4, 2, 7]])\nb = np.array([\n [1, -3, -1, -8]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -5 & -6 & -8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 9 & -3 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -14 & -3 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -6, -8]])\nb = np.array([\n [9, -3, -9]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{27}{8} & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{45}{16} & \\frac{15}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{9}{16} & -\\frac{13}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(27/8), (1/4)]])\nb = np.array([\n [(45/16), (15/8)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{17}{3} & -\\frac{3}{2} & -\\frac{22}{3} & -\\frac{7}{6} \\\\\n 5 & \\frac{11}{3} & -\\frac{19}{6} & \\frac{15}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{17}{2} & \\frac{7}{6} & -6 & -\\frac{10}{3} \\\\\n -8 & -\\frac{16}{3} & \\frac{7}{6} & -\\frac{10}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{17}{6} & -\\frac{1}{3} & -\\frac{40}{3} & -\\frac{9}{2} \\\\\n -3 & -\\frac{5}{3} & -2 & \\frac{25}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/3), -(3/2), -(22/3), -(7/6)],\n [5, (11/3), -(19/6), (15/2)]])\nb = np.array([\n [-(17/2), (7/6), -6, -(10/3)],\n [-8, -(16/3), (7/6), -(10/3)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -5 & 7 & -7 \\\\\n -4 & 2 & -3 \\\\\n 7 & 2 & -2 \\\\\n -5 & -4 & 2 \\\\\n -4 & 8 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, 7, -7],\n [-4, 2, -3],\n [7, 2, -2],\n [-5, -4, 2],\n [-4, 8, -5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & 6 & -4 \\\\\n 8 & -7 & 5 \\\\\n 2 & 9 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-15.92,-0.917,3.837\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 6, -4],\n [8, -7, 5],\n [2, 9, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{17}{16}, -\\frac{99}{32}}$ to the line $-\\frac{159 x}{32}-\\frac{7 y}{16}+\\frac{3}{32}=0$.", - "Output Answer": [ - "$\\frac{981}{8 \\sqrt{25477}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (17/16), -(99/32)\nline = Poly(-((159*x)/32)-((7*y)/16)+(3/32), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 10 & 3 \\\\\n 8 & 8 \\\\\n -10 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [10, 3],\n [8, 8],\n [-10, 5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0.995 \\\\\n -2.557 \\\\\n -3.217 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3.247 \\\\\n 2.056 \\\\\n -6.487 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6.08639$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0.995],\n [-2.557],\n [-3.217]])\nb = np.array([\n [3.247],\n [2.056],\n [-6.487]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 1 & 3 & -2 \\\\\n 3 & 3 & -1 & 1 & -3 \\\\\n 0 & 0 & 3 & 3 & 3 \\\\\n -3 & -3 & 1 & 1 & 2 \\\\\n -2 & 2 & 0 & -2 & -3 \\\\\n -3 & 3 & -3 & 3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.51 \\\\\n -2.92 \\\\\n 1.3 \\\\\n 0.94 \\\\\n 2.88 \\\\\n 2.08 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.911 \\\\\n 0.403 \\\\\n 0.571 \\\\\n -0.003 \\\\\n -0.089 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 0, 1, 3, -2],\n [3, 3, -1, 1, -3],\n [0, 0, 3, 3, 3],\n [-3, -3, 1, 1, 2],\n [-2, 2, 0, -2, -3],\n [-3, 3, -3, 3, 3]])\nb = np.array([\n [0.51],\n [-2.92],\n [1.3],\n [0.94],\n [2.88],\n [2.08]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{25}{4} & \\frac{33}{4} \\\\\n \\frac{13}{4} & -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{8} \\left(-9-\\sqrt{5197}\\right),\\frac{1}{8} \\left(\\sqrt{5197}-9\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(25/4), (33/4)],\n [(13/4), -(17/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{9}{2} \\\\\n \\frac{7}{2} \\\\\n \\frac{23}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{6} \\\\\n -\\frac{7}{6} \\\\\n -\\frac{49}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{707}{36} \\\\\n \\frac{449}{36} \\\\\n \\frac{35}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/2)],\n [(7/2)],\n [(23/3)]])\nb = np.array([\n [-(19/6)],\n [-(7/6)],\n [-(49/6)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-1, 1}$ to the line $5 x+4 y-3=0$.", - "Output Answer": [ - "$\\frac{4}{\\sqrt{41}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -1, 1\nline = Poly(5*x+4*y-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 \\\\\n -9 \\\\\n -7 \\\\\n 8 \\\\\n 5 \\\\\n 3 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -7 \\\\\n -6 \\\\\n 0 \\\\\n 9 \\\\\n 6 \\\\\n 8 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{21}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [3],\n [-9],\n [-7],\n [8],\n [5],\n [3],\n [10]])\nb = np.array([\n [-4],\n [-7],\n [-6],\n [0],\n [9],\n [6],\n [8],\n [-8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & -1 \\\\\n 5 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(3-\\sqrt{61}\\right),\\frac{1}{2} \\left(3+\\sqrt{61}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -1],\n [5, -3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 3 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 1 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -12 \\\\\n 12 \\\\\n -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [3],\n [0]])\nb = np.array([\n [2],\n [1],\n [-4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{523}{100} \\\\\n -\\frac{61}{50} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{62}{25} \\\\\n -\\frac{267}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{771}{100} \\\\\n \\frac{103}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(523/100)],\n [-(61/50)]])\nb = np.array([\n [(62/25)],\n [-(267/50)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{5}{2},-3,-1\\right\\}, \\left\\{4,\\frac{7}{2},\\frac{5}{2}\\right\\}, \\left\\{\\frac{9}{2},-1,\\frac{9}{2}\\right\\}}$.", - "Output Answer": [ - "$46 x-2 y-16 z-137=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(5/2), -3, -1],\n [4, (7/2), (5/2)],\n [(9/2), -1, (9/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{57}{8} \\\\\n -\\frac{5}{2} \\\\\n \\frac{43}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{57}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(57/8)],\n [-(5/2)],\n [(43/16)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 3+4 i & -2-3 i & -5+2 i \\\\\n 1-2 i & -5+2 i & -3 \\\\\n 3 & -3 & -1-3 i \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -219-89 i & 10+138 i & 7-169 i \\\\\n -2+16 i & -95+71 i & -63-57 i \\\\\n -69+45 i & 15-9 i & -19+9 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3+4j, -2-3j, -5+2j],\n [1-2j, -5+2j, -3],\n [3, -3, -1-3j]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{2} & \\frac{7}{2} \\\\\n \\frac{5}{2} & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -1 & -\\frac{7}{5} \\\\\n -1 & -\\frac{9}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2), (7/2)],\n [(5/2), -(5/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1+3 i & -4+i & -2 \\\\\n 4-3 i & -2-3 i & 5+i \\\\\n 1+i & -2-i & -3-2 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -23+8 i & 16-i & -13-i \\\\\n -8+15 i & -27+21 i & -28-24 i \\\\\n -16-i & 12 i & -6+3 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1+3j, -4+ 1j, -2],\n [4-3j, -2-3j, 5+ 1j],\n [1+ 1j, -2- 1j, -3-2j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -2 & -3 \\\\\n 2 & 3 \\\\\n -2 & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 1 & 2 \\\\\n -2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 4 & -1 \\\\\n -4 & 1 \\\\\n -8 & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3],\n [2, 3],\n [-2, 3]])\nb = np.array([\n [1, 2],\n [-2, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 3 & 0 & 2 & 1 \\\\\n 1 & 1 & 2 & -3 \\\\\n 3 & -1 & 2 & -2 \\\\\n -1 & -2 & 3 & 2 \\\\\n 0 & 3 & 3 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.84 \\\\\n 1.67 \\\\\n 1.78 \\\\\n 0.76 \\\\\n 2.72 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.549 \\\\\n 0.229 \\\\\n 0.652 \\\\\n -0.566 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 0, 2, 1],\n [1, 1, 2, -3],\n [3, -1, 2, -2],\n [-1, -2, 3, 2],\n [0, 3, 3, 1]])\nb = np.array([\n [-1.84],\n [1.67],\n [1.78],\n [0.76],\n [2.72]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n \\frac{37}{8} & -\\frac{63}{16} & -7 & \\frac{41}{16} \\\\\n -\\frac{119}{16} & \\frac{27}{8} & \\frac{31}{4} & -\\frac{69}{16} \\\\\n \\frac{85}{16} & \\frac{23}{4} & -\\frac{95}{16} & -\\frac{159}{16} \\\\\n \\frac{35}{4} & \\frac{119}{16} & -\\frac{157}{16} & \\frac{35}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/8), -(63/16), -7, (41/16)],\n [-(119/16), (27/8), (31/4), -(69/16)],\n [(85/16), (23/4), -(95/16), -(159/16)],\n [(35/4), (119/16), -(157/16), (35/8)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -6 & 8 \\\\\n -7 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 8],\n [-7, 10]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -7 & 9 & 7 \\\\\n -5 & 4 & 0 \\\\\n -3 & -4 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.239,-0.409,1.\\}, \\{1.077\\, -1.856 i,1.182\\, -0.252 i,1.\\}, \\{1.077\\, +1.856 i,1.182\\, +0.252 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 9, 7],\n [-5, 4, 0],\n [-3, -4, 6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -1 & -10 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 0 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -1 & -17 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -10]])\nb = np.array([\n [0, 7]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, \\frac{1}{2}, -\\frac{5}{2}}$ to the plane $-2 x+y-\\frac{5 z}{2}+\\frac{9}{2}=0$.", - "Output Answer": [ - "$\\frac{23}{2 \\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, (1/2), -(5/2)\nplane = Poly(-2*x+y-((5*z)/2)+(9/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -9 & \\frac{39}{8} & \\frac{11}{4} \\\\\n -\\frac{47}{8} & 10 & \\frac{39}{4} \\\\\n -\\frac{21}{4} & -\\frac{7}{8} & -\\frac{33}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{29 x^2}{4}+\\frac{2985 x}{64}+\\frac{10829}{32}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, (39/8), (11/4)],\n [-(47/8), 10, (39/4)],\n [-(21/4), -(7/8), -(33/4)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & 5 \\\\\n 7 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+15 x+19$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 5],\n [7, -9]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n \\frac{4}{3} \\\\\n \\frac{14}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 3 \\\\\n 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -14 \\\\\n \\frac{14}{3} \\\\\n \\frac{5}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [(4/3)],\n [(14/3)]])\nb = np.array([\n [1],\n [3],\n [0]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 0 & -3 & 1 & 3 & -1 \\\\\n -1 & 2 & -1 & 3 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 2 & -1 \\\\\n 0 & 0 \\\\\n 0 & 2 \\\\\n 3 & 0 \\\\\n 2 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 7 & -1 \\\\\n 3 & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3, 1, 3, -1],\n [-1, 2, -1, 3, -2]])\nb = np.array([\n [2, -1],\n [0, 0],\n [0, 2],\n [3, 0],\n [2, 3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & -2 \\\\\n -1 & 0 \\\\\n 3 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.88 \\\\\n -0.38 \\\\\n -0.67 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.307 \\\\\n 0.525 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2],\n [-1, 0],\n [3, 1]])\nb = np.array([\n [-0.88],\n [-0.38],\n [-0.67]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{111}{20} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{23}{20} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{67}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(111/20)]])\nb = np.array([\n [(23/20)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 0 & 2 \\\\\n 3 & 0 & 1 \\\\\n -3 & -1 & -2 \\\\\n 3 & -3 & 0 \\\\\n -2 & 1 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.19 \\\\\n -2.32 \\\\\n 0.57 \\\\\n 1.31 \\\\\n -2.83 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.151 \\\\\n -0.416 \\\\\n -0.774 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, 2],\n [3, 0, 1],\n [-3, -1, -2],\n [3, -3, 0],\n [-2, 1, 0]])\nb = np.array([\n [-1.19],\n [-2.32],\n [0.57],\n [1.31],\n [-2.83]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -2 \\\\\n 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -17 \\\\\n 4 \\\\\n -11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-3],\n [2]])\nb = np.array([\n [-5],\n [-2],\n [7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & 1 \\\\\n -4 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 1],\n [-4, -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -5 & -8 & 6 & -8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 2 & 9 & -10 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -7 & -17 & 16 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -8, 6, -8]])\nb = np.array([\n [2, 9, -10, -6]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{5}{3} & -2 & -\\frac{13}{3} & \\frac{20}{3} \\\\\n -\\frac{1}{3} & -\\frac{7}{3} & -8 & \\frac{28}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{11}{3} & \\frac{10}{3} & -\\frac{4}{3} & -1 \\\\\n \\frac{8}{3} & \\frac{20}{3} & -3 & \\frac{22}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -2 & \\frac{4}{3} & -\\frac{17}{3} & \\frac{17}{3} \\\\\n \\frac{7}{3} & \\frac{13}{3} & -11 & \\frac{50}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3), -2, -(13/3), (20/3)],\n [-(1/3), -(7/3), -8, (28/3)]])\nb = np.array([\n [-(11/3), (10/3), -(4/3), -1],\n [(8/3), (20/3), -3, (22/3)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -4 & -1 \\\\\n 1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -1],\n [1, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 0 & 0 & -2 & 10 \\\\\n -4 & 6 & 4 & -2 \\\\\n 8 & -7 & 3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-54.,-51.,25.,5.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, 0, -2, 10],\n [-4, 6, 4, -2],\n [8, -7, 3, 0]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{19}{5}, -\\frac{24}{5}, -\\frac{19}{5}}$ to the plane $-\\frac{12 x}{5}-\\frac{18 y}{5}+\\frac{22 z}{5}+3=0$.", - "Output Answer": [ - "$\\frac{139}{10 \\sqrt{238}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (19/5), -(24/5), -(19/5)\nplane = Poly(-((12*x)/5)-((18*y)/5)+((22*z)/5)+3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n 0 & -\\frac{33}{4} & \\frac{9}{4} & -1 & -\\frac{15}{4} \\\\\n 9 & -\\frac{1}{2} & \\frac{33}{4} & 3 & -\\frac{9}{4} \\\\\n -\\frac{3}{4} & -\\frac{7}{4} & \\frac{13}{4} & -\\frac{31}{4} & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -(33/4), (9/4), -1, -(15/4)],\n [9, -(1/2), (33/4), 3, -(9/4)],\n [-(3/4), -(7/4), (13/4), -(31/4), (1/4)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,0,4\\}, \\{-1,-1,-2\\}, \\{-1,-3,-3\\}}$.", - "Output Answer": [ - "$11 x-y+2 (z+7)=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, 0, 4],\n [-1, -1, -2],\n [-1, -3, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{24}{5}, 4, \\frac{2}{5}}$ to the plane $\\frac{12 x}{5}-\\frac{14 y}{5}-\\frac{z}{5}+\\frac{2}{5}=0$.", - "Output Answer": [ - "$\\frac{112}{\\sqrt{341}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(24/5), 4, (2/5)\nplane = Poly(((12*x)/5)-((14*y)/5)-(z/5)+(2/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 8 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -24 \\\\\n 50 \\\\\n -58 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-2],\n [2]])\nb = np.array([\n [7],\n [8],\n [4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & 1 & -5 \\\\\n -2 & 2 & 8 \\\\\n 3 & 7 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-5.341-3.245 i,-5.341+3.245 i,7.682\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1, -5],\n [-2, 2, 8],\n [3, 7, -2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{22}{25} \\\\\n -\\frac{307}{100} \\\\\n -\\frac{813}{100} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{653}{100} \\\\\n -\\frac{979}{100} \\\\\n -\\frac{122}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{646111}{10000} \\\\\n \\frac{97589}{2000} \\\\\n -\\frac{114319}{10000} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(22/25)],\n [-(307/100)],\n [-(813/100)]])\nb = np.array([\n [-(653/100)],\n [-(979/100)],\n [-(122/25)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 3 & 10 & -7 & 10 & 3 \\\\\n 2 & 0 & 5 & -3 & 0 \\\\\n 7 & -2 & -5 & -10 & -10 \\\\\n 5 & -10 & 9 & 0 & 5 \\\\\n -7 & -8 & -3 & -6 & 1 \\\\\n -2 & -7 & -2 & 4 & 9 \\\\\n 9 & -1 & -7 & -10 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, 10, -7, 10, 3],\n [2, 0, 5, -3, 0],\n [7, -2, -5, -10, -10],\n [5, -10, 9, 0, 5],\n [-7, -8, -3, -6, 1],\n [-2, -7, -2, 4, 9],\n [9, -1, -7, -10, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 3 \\\\\n 3 \\\\\n 2 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{6}{11},0,\\frac{3}{11},-\\frac{3}{11},-\\frac{6}{11},\\frac{3}{11}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [3],\n [3],\n [2],\n [1],\n [0]]).squeeze()\nb = np.array([\n [-2],\n [0],\n [1],\n [-1],\n [-2],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -9 & 5 \\\\\n 0 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1,0\\}, \\{5,17\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 5],\n [0, 8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{40}{7} & \\frac{1}{7} & -\\frac{2}{7} & \\frac{10}{7} \\\\\n 9 & -5 & -\\frac{39}{7} & \\frac{2}{7} \\\\\n -\\frac{9}{7} & -\\frac{19}{7} & 10 & \\frac{16}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{30}{7} & \\frac{24}{7} & \\frac{48}{7} & -\\frac{54}{7} \\\\\n -\\frac{61}{7} & -6 & -\\frac{11}{7} & -\\frac{69}{7} \\\\\n -\\frac{47}{7} & 7 & -\\frac{10}{7} & -\\frac{36}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{10}{7} & -\\frac{23}{7} & -\\frac{50}{7} & \\frac{64}{7} \\\\\n \\frac{124}{7} & 1 & -4 & \\frac{71}{7} \\\\\n \\frac{38}{7} & -\\frac{68}{7} & \\frac{80}{7} & \\frac{52}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(40/7), (1/7), -(2/7), (10/7)],\n [9, -5, -(39/7), (2/7)],\n [-(9/7), -(19/7), 10, (16/7)]])\nb = np.array([\n [-(30/7), (24/7), (48/7), -(54/7)],\n [-(61/7), -6, -(11/7), -(69/7)],\n [-(47/7), 7, -(10/7), -(36/7)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & 5 \\\\\n -2 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+7 x+16$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 5],\n [-2, -1]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n \\frac{43}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(43/5)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & 1 & -1 & -1 & -2 \\\\\n 3 & 3 & -1 & -1 & 2 \\\\\n -3 & -1 & 2 & -3 & 0 \\\\\n 3 & -3 & -2 & -2 & -2 \\\\\n 2 & 2 & -2 & 2 & 3 \\\\\n -2 & -1 & -1 & -1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.95 \\\\\n 0.06 \\\\\n -0.32 \\\\\n 0.2 \\\\\n -1.59 \\\\\n 0.52 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.351 \\\\\n 0.535 \\\\\n -0.548 \\\\\n -0.204 \\\\\n -0.734 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, -1, -1, -2],\n [3, 3, -1, -1, 2],\n [-3, -1, 2, -3, 0],\n [3, -3, -2, -2, -2],\n [2, 2, -2, 2, 3],\n [-2, -1, -1, -1, 1]])\nb = np.array([\n [2.95],\n [0.06],\n [-0.32],\n [0.2],\n [-1.59],\n [0.52]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{29}{3} & \\frac{14}{3} & -\\frac{28}{3} \\\\\n 2 & -\\frac{17}{3} & \\frac{5}{3} \\\\\n \\frac{5}{3} & 5 & \\frac{14}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.995,-0.863,1.\\}, \\{-0.689,0.031,1.\\}, \\{166.834,-58.818,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/3), (14/3), -(28/3)],\n [2, -(17/3), (5/3)],\n [(5/3), 5, (14/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -2 \\\\\n -8 \\\\\n 6 \\\\\n 8 \\\\\n 1 \\\\\n -7 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$41$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-2],\n [-8],\n [6],\n [8],\n [1],\n [-7],\n [-1]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -9 \\\\\n 0 \\\\\n -10 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{239}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-9],\n [0],\n [-10],\n [-7]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{13}{16}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -7 & 9 & -2 \\\\\n -9 & -9 & 4 \\\\\n 5 & -2 & -7 \\\\\n -8 & -7 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{91}{16} & -\\frac{117}{16} & \\frac{13}{8} \\\\\n \\frac{117}{16} & \\frac{117}{16} & -\\frac{13}{4} \\\\\n -\\frac{65}{16} & \\frac{13}{8} & \\frac{91}{16} \\\\\n \\frac{13}{2} & \\frac{91}{16} & \\frac{13}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 9, -2],\n [-9, -9, 4],\n [5, -2, -7],\n [-8, -7, -4]])\nprint(a * -(13/16))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & 4 & -4 \\\\\n 3 & -1 & 1 \\\\\n 4 & 2 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{10} & \\frac{2}{5} & 0 \\\\\n \\frac{11}{70} & -\\frac{3}{35} & \\frac{1}{7} \\\\\n -\\frac{1}{7} & -\\frac{2}{7} & \\frac{1}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 4, -4],\n [3, -1, 1],\n [4, 2, 5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,2,3\\}, \\{0,-1,2\\}, \\{1,-1,0\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{2}{\\sqrt{17}},\\frac{2}{\\sqrt{17}},\\frac{3}{\\sqrt{17}}\\right\\}, \\left\\{-\\frac{8}{\\sqrt{1173}},-\\frac{25}{\\sqrt{1173}},\\frac{22}{\\sqrt{1173}}\\right\\}, \\left\\{\\frac{7}{\\sqrt{69}},-\\frac{4}{\\sqrt{69}},-\\frac{2}{\\sqrt{69}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, 2, 3), (0, -1, 2), (1, -1, 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{1,\\frac{2}{7},\\frac{9}{7}\\right\\}, \\left\\{-\\frac{9}{7},-\\frac{20}{7},\\frac{18}{7}\\right\\}, \\left\\{1,\\frac{3}{7},2\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{7}{\\sqrt{134}},\\sqrt{\\frac{2}{67}},\\frac{9}{\\sqrt{134}}\\right\\}, \\left\\{-\\frac{1619}{\\sqrt{13988126}},-1399 \\sqrt{\\frac{2}{6994063}},\\frac{1881}{\\sqrt{13988126}}\\right\\}, \\left\\{-\\frac{216}{\\sqrt{104389}},\\frac{207}{\\sqrt{104389}},\\frac{122}{\\sqrt{104389}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((1, (2/7), (9/7)), (-(9/7), -(20/7), (18/7)), (1, (3/7), 2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-1, \\frac{3}{2}, 3}$ to the plane $-x-y+\\frac{9 z}{2}-4=0$.", - "Output Answer": [ - "$\\frac{18}{\\sqrt{89}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -1, (3/2), 3\nplane = Poly(-x-y+((9*z)/2)-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & 0 & -1 \\\\\n -1 & -3 & -3 \\\\\n 1 & 0 & 0 \\\\\n -3 & 2 & 3 \\\\\n -1 & -2 & -3 \\\\\n -1 & -2 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.81 \\\\\n -0.61 \\\\\n -2.44 \\\\\n 2.29 \\\\\n -0.52 \\\\\n 1.1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.379 \\\\\n -0.544 \\\\\n 0.812 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, -1],\n [-1, -3, -3],\n [1, 0, 0],\n [-3, 2, 3],\n [-1, -2, -3],\n [-1, -2, 0]])\nb = np.array([\n [-1.81],\n [-0.61],\n [-2.44],\n [2.29],\n [-0.52],\n [1.1]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -1 & -2 \\\\\n 1 & 1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 2 \\\\\n -1 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2],\n [1, 1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -2 \\\\\n 2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -3 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{27}{20},-\\frac{27}{20},-\\frac{9}{20},\\frac{9}{20}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-2],\n [2],\n [-1]]).squeeze()\nb = np.array([\n [-3],\n [-3],\n [-1],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & -\\frac{11}{2} \\\\\n 5 & \\frac{15}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{20} \\left(-15-i \\sqrt{215}\\right),1\\right\\}, \\left\\{\\frac{1}{20} \\left(-15+i \\sqrt{215}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -(11/2)],\n [5, (15/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 16 \\\\\n -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-3]])\nb = np.array([\n [-10],\n [4]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -8 & -4 & 3 \\\\\n 7 & 1 & -9 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 10 & 4 & -9 \\\\\n 8 & -5 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -18 & -8 & 12 \\\\\n -1 & 6 & -13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -4, 3],\n [7, 1, -9]])\nb = np.array([\n [10, 4, -9],\n [8, -5, 4]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & 2 & 3 \\\\\n -3 & -4 & -2 \\\\\n -1 & -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-23$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2, 3],\n [-3, -4, -2],\n [-1, -1, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{5} & \\frac{23}{10} & -2 \\\\\n \\frac{11}{10} & \\frac{31}{10} & 4 \\\\\n -\\frac{13}{5} & 5 & -\\frac{16}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{6116}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/5), (23/10), -2],\n [(11/10), (31/10), 4],\n [-(13/5), 5, -(16/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -2 & 7 & -\\frac{22}{3} \\\\\n \\frac{8}{3} & \\frac{4}{3} & -\\frac{13}{3} \\\\\n -\\frac{11}{3} & -\\frac{7}{3} & \\frac{25}{3} \\\\\n 7 & 3 & \\frac{19}{3} \\\\\n 10 & \\frac{11}{3} & \\frac{13}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 7, -(22/3)],\n [(8/3), (4/3), -(13/3)],\n [-(11/3), -(7/3), (25/3)],\n [7, 3, (19/3)],\n [10, (11/3), (13/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 3 \\\\\n -2 & 0 & -2 \\\\\n -1 & -1 & 3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -8 & -12 & 36 \\\\\n 8 & 12 & -40 \\\\\n -4 & -8 & 24 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 0, 3],\n [-2, 0, -2],\n [-1, -1, 3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{31}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{66}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7]])\nb = np.array([\n [-(31/5)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [1],\n [-1],\n [0],\n [-1],\n [1],\n [0],\n [0]]).squeeze()\nb = np.array([\n [0],\n [1],\n [1],\n [1],\n [0],\n [-1],\n [0],\n [-1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,4,5\\}, \\{-3,4,4\\}, \\{2,0,2\\}}$.", - "Output Answer": [ - "$4 x+13 y-16 z+24=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, 4, 5],\n [-3, 4, 4],\n [2, 0, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & 5 \\\\\n -4 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1-2 i,2\\}, \\{-1+2 i,2\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 5],\n [-4, -6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\log (2) \\\\\n 12 \\log (2) \\\\\n 13 \\log (2) \\\\\n 2 \\log (2) \\\\\n 2 \\log (2) \\\\\n 4 \\log (2) \\\\\n -6 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\log (2) \\\\\n -12 \\log (2) \\\\\n -14 \\log (2) \\\\\n -2 \\log (2) \\\\\n 2 \\log (2) \\\\\n -3 \\log (2) \\\\\n 11 \\log (2) \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-374 \\log ^2(2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [3*math.log(2)],\n [12*math.log(2)],\n [13*math.log(2)],\n [2*math.log(2)],\n [2*math.log(2)],\n [4*math.log(2)],\n [-6*math.log(2)]])\nb = np.array([\n [10*math.log(2)],\n [-12*math.log(2)],\n [-14*math.log(2)],\n [-2*math.log(2)],\n [2*math.log(2)],\n [-3*math.log(2)],\n [11*math.log(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{3} \\\\\n \\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{2}} \\\\\n \\frac{1}{\\sqrt{2}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3)],\n [(2/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -9 \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -1 \\\\\n \\frac{15}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -69 \\\\\n -18 \\\\\n -30 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-9],\n [-(3/2)]])\nb = np.array([\n [-3],\n [-1],\n [(15/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(\\sqrt{6}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [0],\n [1],\n [0],\n [1],\n [-1],\n [1],\n [0],\n [0]]).squeeze()\nb = np.array([\n [-1],\n [-1],\n [0],\n [0],\n [-1],\n [0],\n [0],\n [0],\n [0],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -\\frac{4}{3} \\\\\n 0 \\\\\n -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{5}{3} \\\\\n \\frac{1}{3} \\\\\n \\frac{1}{3} \\\\\n -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{10}{91},\\frac{2}{91},\\frac{2}{91},-\\frac{16}{91}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-(4/3)],\n [0],\n [-(5/3)]]).squeeze()\nb = np.array([\n [(5/3)],\n [(1/3)],\n [(1/3)],\n [-(8/3)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{7}{3},5,-\\frac{8}{3}\\right\\}, \\left\\{1,-3,\\frac{5}{3}\\right\\}, \\left\\{-5,\\frac{1}{3},-\\frac{5}{3}\\right\\}}$.", - "Output Answer": [ - "$165 x-411 y-708 z-218=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(7/3), 5, -(8/3)],\n [1, -3, (5/3)],\n [-5, (1/3), -(5/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{17}{2} & -\\frac{11}{4} & \\frac{3}{4} \\\\\n -\\frac{17}{4} & \\frac{13}{4} & \\frac{15}{4} \\\\\n \\frac{9}{4} & \\frac{35}{4} & \\frac{15}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-10.057,-0.796,9.353\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/2), -(11/4), (3/4)],\n [-(17/4), (13/4), (15/4)],\n [(9/4), (35/4), (15/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 3 & -4 & -10 \\\\\n 9 & -5 & 7 \\\\\n 1 & 6 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-9.82,4.41\\, -7.36 i,4.41\\, +7.36 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -4, -10],\n [9, -5, 7],\n [1, 6, 1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 5 & -6 & -9 & 10 & -10 \\\\\n 4 & 3 & -4 & -2 & 4 \\\\\n 4 & 7 & -3 & -4 & 1 \\\\\n 9 & -2 & 8 & 0 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1444.,5022.,1122.,7089.,2344.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, -6, -9, 10, -10],\n [4, 3, -4, -2, 4],\n [4, 7, -3, -4, 1],\n [9, -2, 8, 0, 6]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & \\frac{1}{3} \\\\\n -\\frac{2}{3} & -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{130}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, (1/3)],\n [-(2/3), -(11/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 4 & 3 \\\\\n 1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{4}{19} & \\frac{3}{19} \\\\\n \\frac{1}{19} & -\\frac{4}{19} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 3],\n [1, -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${1, -4, -1}$ to the plane $2 x-2 y+z+3=0$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 1, -4, -1\nplane = Poly(2*x-2*y+z+3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{3}{2},3,\\frac{9}{2}\\right\\}, \\{4,-3,2\\}, \\left\\{-2,-\\frac{5}{2},-4\\right\\}}$.", - "Output Answer": [ - "$149 x+120 y-139 z+42=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(3/2), 3, (9/2)],\n [4, -3, 2],\n [-2, -(5/2), -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -6 & 4 & -7 \\\\\n 8 & -9 & -8 \\\\\n 4 & -6 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-13.808,-9.7,0.508\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 4, -7],\n [8, -9, -8],\n [4, -6, -8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{100}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 6 & 0 & -8 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{9}{50} & 0 & -\\frac{6}{25} & \\frac{27}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 0, -8, 9]])\nprint(a * (3/100))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,-2,1\\}, \\{-2,1,-1\\}, \\{2,-2,1\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{2}{3},-\\frac{2}{3},\\frac{1}{3}\\right\\}, \\left\\{-\\frac{4}{3 \\sqrt{5}},-\\frac{\\sqrt{5}}{3},-\\frac{2}{3 \\sqrt{5}}\\right\\}, \\{0,0,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, -2, 1), (-2, 1, -1), (2, -2, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 8 & -2 \\\\\n -2 & 7 \\\\\n -9 & 3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 7 & -4 \\\\\n 6 & 5 \\\\\n 8 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 2 \\\\\n -8 & 2 \\\\\n -17 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -2],\n [-2, 7],\n [-9, 3]])\nb = np.array([\n [7, -4],\n [6, 5],\n [8, 6]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -2 & 9 & 0 & 2 & 6 & 3 \\\\\n 8 & 2 & -6 & 1 & 3 & 3 \\\\\n 4 & 10 & -2 & -9 & -4 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & -\\frac{77}{23} & -\\frac{303}{92} & -\\frac{123}{46} \\\\\n 0 & 1 & 0 & -\\frac{12}{23} & -\\frac{3}{46} & -\\frac{6}{23} \\\\\n 0 & 0 & 1 & -\\frac{221}{46} & -\\frac{113}{23} & -\\frac{191}{46} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, 9, 0, 2, 6, 3],\n [8, 2, -6, 1, 3, 3],\n [4, 10, -2, -9, -4, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 3 & 1 \\\\\n -8 & -7 \\\\\n 0 & 4 \\\\\n -10 & 10 \\\\\n 8 & 10 \\\\\n -3 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, 1],\n [-8, -7],\n [0, 4],\n [-10, 10],\n [8, 10],\n [-3, 7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -4 & 2 \\\\\n 3 & 1 \\\\\n 2 & -10 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 6 & 9 \\\\\n -2 & 6 \\\\\n 7 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -10 & -7 \\\\\n 5 & -5 \\\\\n -5 & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 2],\n [3, 1],\n [2, -10]])\nb = np.array([\n [6, 9],\n [-2, 6],\n [7, -3]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -3 \\\\\n -8 \\\\\n -4 \\\\\n 0 \\\\\n 4 \\\\\n 1 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -5 \\\\\n 0 \\\\\n 3 \\\\\n 8 \\\\\n 5 \\\\\n -7 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$73$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-3],\n [-8],\n [-4],\n [0],\n [4],\n [1],\n [5]])\nb = np.array([\n [8],\n [-5],\n [0],\n [3],\n [8],\n [5],\n [-7],\n [5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{10}{3}, \\frac{8}{3}}$ to the line $-\\frac{8 x}{3}-\\frac{11 y}{3}-\\frac{2}{3}=0$.", - "Output Answer": [ - "$\\frac{14}{3 \\sqrt{185}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(10/3), (8/3)\nline = Poly(-((8*x)/3)-((11*y)/3)-(2/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -6 & -2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.,0.,3.\\}, \\{-1.,3.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-6, -2, -2]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 7 & -6 & -6 & 10 \\\\\n 1 & 8 & -9 & 8 \\\\\n 7 & 5 & -1 & -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & 0 & 7 & 8 \\\\\n -2 & 3 & -4 & -3 \\\\\n -1 & 0 & -7 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 9 & -6 & 1 & 18 \\\\\n -1 & 11 & -13 & 5 \\\\\n 6 & 5 & -8 & -10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -6, -6, 10],\n [1, 8, -9, 8],\n [7, 5, -1, -6]])\nb = np.array([\n [2, 0, 7, 8],\n [-2, 3, -4, -3],\n [-1, 0, -7, -4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{15}{2} & \\frac{19}{2} \\\\\n -\\frac{3}{2} & -2 \\\\\n -\\frac{13}{2} & 0 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -6 & -\\frac{17}{2} \\\\\n -9 & 1 \\\\\n -8 & -\\frac{19}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & 18 \\\\\n \\frac{15}{2} & -3 \\\\\n \\frac{3}{2} & \\frac{19}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/2), (19/2)],\n [-(3/2), -2],\n [-(13/2), 0]])\nb = np.array([\n [-6, -(17/2)],\n [-9, 1],\n [-8, -(19/2)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, -3, 3}$ to the plane $2 x-4 y-5 z-2=0$.", - "Output Answer": [ - "$\\frac{3}{\\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, -3, 3\nplane = Poly(2*x-4*y-5*z-2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 10 & 9 & 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 5 & -4 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 15 & 5 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 9, 5]])\nb = np.array([\n [5, -4, -6]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -4+3 i & 2-i & 0 \\\\\n 2-i & 5 & 3 i \\\\\n 1 & -3+4 i & 1+4 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 10-28 i & 5+5 i & 3+6 i \\\\\n 5+8 i & 16-13 i & -12+18 i \\\\\n -5+18 i & -32+11 i & -27-i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4+3j, 2- 1j, 0],\n [2- 1j, 5, 3j],\n [1, -3+4j, 1+4j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -4 & \\frac{9}{2} & \\frac{9}{2} \\\\\n -\\frac{1}{2} & -4 & -\\frac{3}{2} \\\\\n \\frac{7}{2} & 4 & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{135}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, (9/2), (9/2)],\n [-(1/2), -4, -(3/2)],\n [(7/2), 4, (3/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{2} & -\\frac{7}{2} \\\\\n -\\frac{5}{2} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{3}{31} & -\\frac{7}{31} \\\\\n -\\frac{5}{31} & \\frac{9}{31} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2), -(7/2)],\n [-(5/2), (3/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -2 & 2 \\\\\n 1 & \\frac{5}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 6 & 1 \\\\\n \\frac{1}{2} & \\frac{33}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2],\n [1, (5/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{4}{3} \\\\\n -\\frac{7}{3} \\\\\n -1 \\\\\n -\\frac{5}{3} \\\\\n 2 \\\\\n \\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{10}} \\\\\n -\\frac{7}{4 \\sqrt{10}} \\\\\n -\\frac{3}{4 \\sqrt{10}} \\\\\n -\\frac{\\sqrt{\\frac{5}{2}}}{4} \\\\\n \\frac{3}{2 \\sqrt{10}} \\\\\n \\frac{\\sqrt{\\frac{5}{2}}}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3)],\n [-(7/3)],\n [-1],\n [-(5/3)],\n [2],\n [(5/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & 2 \\\\\n -8 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{16} \\left(-13-\\sqrt{105}\\right),1\\right\\}, \\left\\{\\frac{1}{16} \\left(\\sqrt{105}-13\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 2],\n [-8, -6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{3} \\\\\n -\\frac{8}{3} \\\\\n -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2}{\\sqrt{93}} \\\\\n -\\frac{8}{\\sqrt{93}} \\\\\n -\\frac{5}{\\sqrt{93}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3)],\n [-(8/3)],\n [-(5/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -3 & -1 \\\\\n -1 & 9 \\\\\n -2 & 4 \\\\\n 2 & 7 \\\\\n 3 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1],\n [-1, 9],\n [-2, 4],\n [2, 7],\n [3, -6]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 4 & -2 \\\\\n -2 & 1 \\\\\n -4 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [1],\n [2]])\nb = np.array([\n [-2, 1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{49}{5} & \\frac{18}{5} \\\\\n -\\frac{29}{5} & -\\frac{38}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{13}{5} & -\\frac{1}{5} \\\\\n \\frac{36}{5} & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{36}{5} & \\frac{17}{5} \\\\\n \\frac{7}{5} & -\\frac{68}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(49/5), (18/5)],\n [-(29/5), -(38/5)]])\nb = np.array([\n [-(13/5), -(1/5)],\n [(36/5), -6]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n \\frac{37}{6} & \\frac{55}{6} & \\frac{31}{6} & -\\frac{11}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/6), (55/6), (31/6), -(11/6)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{65}{7} \\\\\n -6 \\\\\n -\\frac{6}{7} \\\\\n \\frac{50}{7} \\\\\n \\frac{69}{7} \\\\\n \\frac{53}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{16095}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(65/7)],\n [-6],\n [-(6/7)],\n [(50/7)],\n [(69/7)],\n [(53/7)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 7 & 0 & 0 & -2 \\\\\n 9 & 3 & -10 & 8 \\\\\n -10 & -3 & 8 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{6.,476.,165.,21.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, 0, 0, -2],\n [9, 3, -10, 8],\n [-10, -3, 8, 8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & -7 & -1 \\\\\n 6 & 10 & -6 \\\\\n 7 & 9 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, -7, -1],\n [6, 10, -6],\n [7, 9, -6]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -7 & -8 & 6 \\\\\n -8 & 9 & 10 \\\\\n 9 & 0 & 6 \\\\\n -9 & 8 & -8 \\\\\n -7 & 2 & -9 \\\\\n 0 & -2 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, -8, 6],\n [-8, 9, 10],\n [9, 0, 6],\n [-9, 8, -8],\n [-7, 2, -9],\n [0, -2, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{25}{4} & \\frac{9}{2} & 3 \\\\\n \\frac{35}{4} & -\\frac{33}{4} & \\frac{19}{4} \\\\\n -\\frac{3}{2} & -\\frac{13}{2} & -6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 8 & -2 & -3 \\\\\n \\frac{9}{2} & 5 & -6 \\\\\n \\frac{7}{2} & 1 & -\\frac{17}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{4} & \\frac{13}{2} & 6 \\\\\n \\frac{17}{4} & -\\frac{53}{4} & \\frac{43}{4} \\\\\n -5 & -\\frac{15}{2} & -\\frac{7}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(25/4), (9/2), 3],\n [(35/4), -(33/4), (19/4)],\n [-(3/2), -(13/2), -6]])\nb = np.array([\n [8, -2, -3],\n [(9/2), 5, -6],\n [(7/2), 1, -(17/4)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 9 & -10 \\\\\n -5 & 1 \\\\\n -7 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, -10],\n [-5, 1],\n [-7, 7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -3 & 8 & 5 & 2 \\\\\n -9 & -9 & 9 & -4 \\\\\n -2 & 6 & -8 & 5 \\\\\n 5 & 3 & 7 & 2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 1 & 5 & 8 & -5 \\\\\n -5 & -8 & 6 & 8 \\\\\n -3 & 4 & -8 & -5 \\\\\n 1 & -3 & -1 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -4 & 3 & -3 & 7 \\\\\n -4 & -1 & 3 & -12 \\\\\n 1 & 2 & 0 & 10 \\\\\n 4 & 6 & 8 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 8, 5, 2],\n [-9, -9, 9, -4],\n [-2, 6, -8, 5],\n [5, 3, 7, 2]])\nb = np.array([\n [1, 5, 8, -5],\n [-5, -8, 6, 8],\n [-3, 4, -8, -5],\n [1, -3, -1, -1]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{13}{8}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -2 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 13 \\\\\n -\\frac{13}{4} \\\\\n \\frac{91}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-2],\n [7]])\nprint(a * (13/8))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{5} & \\frac{31}{5} & -\\frac{17}{5} \\\\\n -\\frac{3}{5} & -\\frac{1}{5} & -\\frac{4}{5} \\\\\n -\\frac{22}{5} & \\frac{11}{5} & \\frac{41}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{41 x^2}{5}+\\frac{238 x}{25}+\\frac{7479}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/5), (31/5), -(17/5)],\n [-(3/5), -(1/5), -(4/5)],\n [-(22/5), (11/5), (41/5)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -8 & -1 & 1 & 0 & -1 & -8 & 3 \\\\\n 2 & -4 & 7 & -9 & -7 & 2 & -2 \\\\\n 4 & -1 & -10 & -1 & -8 & -2 & 1 \\\\\n -2 & -8 & -1 & -5 & -6 & 1 & 3 \\\\\n -8 & -10 & 4 & 10 & -1 & 8 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & \\frac{47261}{41624} & -\\frac{22375}{41624} \\\\\n 0 & 1 & 0 & 0 & 0 & -\\frac{44617}{41624} & -\\frac{1773}{41624} \\\\\n 0 & 0 & 1 & 0 & 0 & \\frac{16627}{41624} & -\\frac{29897}{41624} \\\\\n 0 & 0 & 0 & 1 & 0 & \\frac{21455}{41624} & -\\frac{38413}{41624} \\\\\n 0 & 0 & 0 & 0 & 1 & \\frac{367}{946} & \\frac{591}{946} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-8, -1, 1, 0, -1, -8, 3],\n [2, -4, 7, -9, -7, 2, -2],\n [4, -1, -10, -1, -8, -2, 1],\n [-2, -8, -1, -5, -6, 1, 3],\n [-8, -10, 4, 10, -1, 8, -8]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{20}{9} \\\\\n -\\frac{28}{9} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{10}{3} \\\\\n \\frac{77}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{10}{9} \\\\\n -\\frac{35}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(20/9)],\n [-(28/9)]])\nb = np.array([\n [(10/3)],\n [(77/9)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 0 & -5 \\\\\n 3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & \\frac{1}{3} \\\\\n -\\frac{1}{5} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -5],\n [3, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -7 & 0 & 6 & -1 \\\\\n -2 & 6 & 0 & 5 \\\\\n 3 & -2 & -8 & 6 \\\\\n 10 & 7 & 8 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, 0, 6, -1],\n [-2, 6, 0, 5],\n [3, -2, -8, 6],\n [10, 7, 8, 2]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -10 & -7 \\\\\n -1 & 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-107$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -7],\n [-1, 10]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 6 \\\\\n -7 \\\\\n 0 \\\\\n 7 \\\\\n -1 \\\\\n 5 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$43$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [6],\n [-7],\n [0],\n [7],\n [-1],\n [5],\n [8]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -5 \\\\\n -6 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-5],\n [-6],\n [-3]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-1$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -2 & -6 & 6 & 6 \\\\\n 9 & 8 & 2 & 0 \\\\\n 2 & -10 & 8 & 9 \\\\\n 4 & 10 & 4 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 2 & 6 & -6 & -6 \\\\\n -9 & -8 & -2 & 0 \\\\\n -2 & 10 & -8 & -9 \\\\\n -4 & -10 & -4 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -6, 6, 6],\n [9, 8, 2, 0],\n [2, -10, 8, 9],\n [4, 10, 4, 3]])\nprint(a * -1)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -2 & 1 & 2 & 3 & -2 \\\\\n -3 & -1 & 1 & 0 & 0 \\\\\n -3 & 1 & 2 & -2 & 2 \\\\\n 1 & 2 & -2 & -1 & 1 \\\\\n -2 & 0 & 1 & 2 & 0 \\\\\n -2 & 3 & -1 & -2 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.95 \\\\\n -2. \\\\\n -0.08 \\\\\n 2.19 \\\\\n 2.21 \\\\\n 2.13 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.1 \\\\\n 1.082 \\\\\n -0.511 \\\\\n 0.816 \\\\\n 0.602 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 1, 2, 3, -2],\n [-3, -1, 1, 0, 0],\n [-3, 1, 2, -2, 2],\n [1, 2, -2, -1, 1],\n [-2, 0, 1, 2, 0],\n [-2, 3, -1, -2, -1]])\nb = np.array([\n [0.95],\n [-2.],\n [-0.08],\n [2.19],\n [2.21],\n [2.13]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{5} \\\\\n \\frac{16}{5} \\\\\n -\\frac{12}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{5} \\\\\n \\frac{27}{5} \\\\\n -\\frac{29}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{28}{5} \\\\\n \\frac{8}{5} \\\\\n 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/5)],\n [(16/5)],\n [-(12/5)]])\nb = np.array([\n [-(13/5)],\n [(27/5)],\n [-(29/5)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 4 \\\\\n 6 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 5 \\\\\n -4 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-32$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [4],\n [6],\n [4]])\nb = np.array([\n [-8],\n [5],\n [-4],\n [-5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 1 & -\\frac{19}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{2} & 7 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{3}{2} & -\\frac{33}{2} & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(19/2), (5/2)]])\nb = np.array([\n [-(1/2), 7, -2]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 7 & 0 & -10 \\\\\n -7 & -6 & 10 \\\\\n 9 & 8 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-x^2+34 x-456$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 0, -10],\n [-7, -6, 10],\n [9, 8, -2]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & -1 \\\\\n -7 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-x-49$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -1],\n [-7, 7]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-3$ and the matrix\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 6 \\\\\n -9 \\\\\n -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [3],\n [1]])\nprint(a * -3)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{3} \\\\\n -\\frac{38}{9} \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{13}{3} \\\\\n -\\frac{32}{9} \\\\\n -\\frac{17}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{8}{3} \\\\\n -\\frac{70}{9} \\\\\n \\frac{4}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/3)],\n [-(38/9)],\n [7]])\nb = np.array([\n [(13/3)],\n [-(32/9)],\n [-(17/3)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{1,-\\frac{3}{2},-\\frac{3}{2}\\right\\}, \\left\\{3,-\\frac{7}{2},-\\frac{1}{2}\\right\\}, \\left\\{\\frac{7}{2},\\frac{1}{2},-\\frac{3}{2}\\right\\}}$.", - "Output Answer": [ - "$8 x-10 y-36 z-77=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -(3/2), -(3/2)],\n [3, -(7/2), -(1/2)],\n [(7/2), (1/2), -(3/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{13}{4} & \\frac{9}{2} \\\\\n -\\frac{19}{8} & \\frac{3}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{11} & -\\frac{6}{11} \\\\\n \\frac{19}{66} & -\\frac{13}{33} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/4), (9/2)],\n [-(19/8), (3/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\sqrt{\\frac{2}{3}} \\\\\n \\frac{1}{\\sqrt{6}} \\\\\n 0 \\\\\n \\frac{1}{\\sqrt{6}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [1],\n [0],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{3} & -3 & 1 \\\\\n \\frac{8}{3} & -3 & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{3} & -\\frac{5}{3} & -\\frac{1}{3} \\\\\n \\frac{8}{3} & -1 & \\frac{7}{3} \\\\\n -\\frac{2}{3} & \\frac{2}{3} & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{71}{9} & \\frac{68}{9} & -\\frac{83}{9} \\\\\n -\\frac{26}{3} & -\\frac{5}{3} & -\\frac{62}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/3), -3, 1],\n [(8/3), -3, -(1/3)]])\nb = np.array([\n [-(1/3), -(5/3), -(1/3)],\n [(8/3), -1, (7/3)],\n [-(2/3), (2/3), -3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}(-4)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [0],\n [1],\n [1],\n [0]]).squeeze()\nb = np.array([\n [0],\n [1],\n [1],\n [-1],\n [1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 4 \\sqrt{5} \\\\\n 3 \\sqrt{5} \\\\\n -3 \\sqrt{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\sqrt{5} \\\\\n -\\sqrt{5} \\\\\n 0 \\\\\n -3 \\sqrt{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$25$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [4*math.sqrt(5)],\n [3*math.sqrt(5)],\n [-3*math.sqrt(5)]])\nb = np.array([\n [-3*math.sqrt(5)],\n [-math.sqrt(5)],\n [0],\n [-3*math.sqrt(5)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{3} & -\\frac{4}{3} & -\\frac{8}{3} \\\\\n -1 & -3 & -\\frac{10}{3} \\\\\n -3 & -3 & -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{107}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/3), -(4/3), -(8/3)],\n [-1, -3, -(10/3)],\n [-3, -3, -(11/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 9 & -5 & -8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 9 & -7 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 2 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -5, -8]])\nb = np.array([\n [9, -7, -6]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{1}{8} & -1 & \\frac{7}{4} & \\frac{3}{2} & -\\frac{11}{4} \\\\\n -\\frac{5}{8} & \\frac{3}{2} & -\\frac{3}{8} & -\\frac{9}{4} & -\\frac{21}{8} \\\\\n -3 & -\\frac{1}{4} & -\\frac{9}{4} & -\\frac{13}{8} & \\frac{5}{2} \\\\\n -\\frac{7}{8} & \\frac{5}{8} & -\\frac{5}{2} & -3 & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{11}{8} & -\\frac{17}{8} & \\frac{1}{4} & \\frac{3}{4} \\\\\n \\frac{19}{8} & -\\frac{7}{4} & -2 & -\\frac{5}{2} \\\\\n -\\frac{21}{8} & -\\frac{1}{4} & -\\frac{11}{8} & -\\frac{21}{8} \\\\\n -\\frac{11}{4} & -\\frac{1}{4} & -\\frac{21}{8} & -\\frac{5}{8} \\\\\n \\frac{21}{8} & -\\frac{23}{8} & \\frac{3}{2} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{1183}{64} & \\frac{583}{64} & -\\frac{17}{2} & 1 \\\\\n \\frac{191}{64} & \\frac{221}{32} & -\\frac{43}{64} & \\frac{135}{64} \\\\\n \\frac{391}{32} & \\frac{19}{32} & \\frac{695}{64} & \\frac{99}{64} \\\\\n \\frac{273}{32} & \\frac{597}{64} & \\frac{195}{32} & \\frac{319}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/8), -1, (7/4), (3/2), -(11/4)],\n [-(5/8), (3/2), -(3/8), -(9/4), -(21/8)],\n [-3, -(1/4), -(9/4), -(13/8), (5/2)],\n [-(7/8), (5/8), -(5/2), -3, -(5/2)]])\nb = np.array([\n [(11/8), -(17/8), (1/4), (3/4)],\n [(19/8), -(7/4), -2, -(5/2)],\n [-(21/8), -(1/4), -(11/8), -(21/8)],\n [-(11/4), -(1/4), -(21/8), -(5/8)],\n [(21/8), -(23/8), (3/2), -(3/2)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{4}{3},-\\frac{8}{3},\\frac{8}{3}\\right\\}, \\left\\{\\frac{13}{3},-\\frac{4}{3},\\frac{7}{3}\\right\\}, \\left\\{\\frac{4}{3},3,-\\frac{8}{3}\\right\\}}$.", - "Output Answer": [ - "$47 x-264 y-257 z+44=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(4/3), -(8/3), (8/3)],\n [(13/3), -(4/3), (7/3)],\n [(4/3), 3, -(8/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $2$ and the matrix\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 18 \\\\\n 18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [9]])\nprint(a * 2)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{2}{3}, 2}$ to the line $\\frac{8 x}{3}+4 y-2=0$.", - "Output Answer": [ - "$\\frac{19}{6 \\sqrt{13}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(2/3), 2\nline = Poly(((8*x)/3)+4*y-2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -2 & 0 & -2 \\\\\n 0 & 1 & 3 \\\\\n 0 & 1 & 1 \\\\\n 1 & 0 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & -1 \\\\\n -2 & 1 & 0 \\\\\n -2 & -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 2 & 4 & 0 \\\\\n -8 & -2 & 3 \\\\\n -4 & 0 & 1 \\\\\n -3 & -3 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, -2],\n [0, 1, 3],\n [0, 1, 1],\n [1, 0, 2]])\nb = np.array([\n [1, -1, -1],\n [-2, 1, 0],\n [-2, -1, 1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{13}{4} & -\\frac{9}{4} \\\\\n 5 & -\\frac{13}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{52}{11} & \\frac{36}{11} \\\\\n -\\frac{80}{11} & \\frac{52}{11} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/4), -(9/4)],\n [5, -(13/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 1 \\\\\n 2 \\\\\n 2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\sqrt{\\frac{2}{11}} \\\\\n \\frac{1}{\\sqrt{22}} \\\\\n \\sqrt{\\frac{2}{11}} \\\\\n \\sqrt{\\frac{2}{11}} \\\\\n \\frac{3}{\\sqrt{22}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [1],\n [2],\n [2],\n [3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{37}{4} \\\\\n 5 \\\\\n -\\frac{23}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{21}{4} \\\\\n -\\frac{3}{4} \\\\\n -\\frac{19}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{37}{2 \\sqrt{1088103}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(37/4)],\n [5],\n [-(23/4)]]).squeeze()\nb = np.array([\n [(21/4)],\n [-(3/4)],\n [-(19/2)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 7 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [2],\n [1]])\nb = np.array([\n [9],\n [7],\n [-6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{3}{5} & \\frac{13}{5} & \\frac{36}{5} & -\\frac{1}{5} \\\\\n \\frac{27}{5} & -\\frac{39}{5} & -2 & \\frac{23}{5} \\\\\n -\\frac{41}{5} & 4 & \\frac{48}{5} & \\frac{27}{5} \\\\\n 7 & \\frac{19}{5} & \\frac{14}{5} & \\frac{38}{5} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{31}{5} & \\frac{21}{5} & -1 & \\frac{14}{5} \\\\\n 1 & \\frac{39}{5} & -\\frac{31}{5} & -\\frac{48}{5} \\\\\n \\frac{36}{5} & 8 & -2 & -\\frac{28}{5} \\\\\n -\\frac{22}{5} & \\frac{17}{5} & \\frac{17}{5} & -\\frac{2}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{28}{5} & -\\frac{8}{5} & \\frac{41}{5} & -3 \\\\\n \\frac{22}{5} & -\\frac{78}{5} & \\frac{21}{5} & \\frac{71}{5} \\\\\n -\\frac{77}{5} & -4 & \\frac{58}{5} & 11 \\\\\n \\frac{57}{5} & \\frac{2}{5} & -\\frac{3}{5} & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/5), (13/5), (36/5), -(1/5)],\n [(27/5), -(39/5), -2, (23/5)],\n [-(41/5), 4, (48/5), (27/5)],\n [7, (19/5), (14/5), (38/5)]])\nb = np.array([\n [-(31/5), (21/5), -1, (14/5)],\n [1, (39/5), -(31/5), -(48/5)],\n [(36/5), 8, -2, -(28/5)],\n [-(22/5), (17/5), (17/5), -(2/5)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{31}{16} & \\frac{11}{8} & \\frac{49}{16} \\\\\n \\frac{55}{16} & -4 & \\frac{1}{16} \\\\\n 2 & -\\frac{51}{16} & -\\frac{75}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{19404}{24005} & \\frac{3396}{24005} & -\\frac{12632}{24005} \\\\\n -\\frac{16628}{24005} & -\\frac{3028}{24005} & -\\frac{10904}{24005} \\\\\n \\frac{3028}{24005} & \\frac{3508}{24005} & -\\frac{3096}{24005} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(31/16), (11/8), (49/16)],\n [(55/16), -4, (1/16)],\n [2, -(51/16), -(75/16)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 6 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -4 \\\\\n -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2 \\\\\n 12 \\\\\n -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [6],\n [5]])\nb = np.array([\n [6],\n [-4],\n [-3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & 2 & 2 \\\\\n 3 & 0 & -1 \\\\\n 2 & 4 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, 2],\n [3, 0, -1],\n [2, 4, 5]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2} & -\\frac{15}{4} \\\\\n -\\frac{11}{4} & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{24}{67} & -\\frac{20}{67} \\\\\n -\\frac{44}{201} & \\frac{8}{201} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), -(15/4)],\n [-(11/4), (9/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 6 \\\\\n 1 \\\\\n -9 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{159}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [6],\n [1],\n [-9],\n [-5]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{6}{5} \\\\\n -\\frac{34}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{6}{5} \\\\\n \\frac{44}{5} \\\\\n 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1796}{25} \\\\\n -\\frac{704}{25} \\\\\n \\frac{404}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [(6/5)],\n [-(34/5)]])\nb = np.array([\n [(6/5)],\n [(44/5)],\n [10]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & 2 \\\\\n -2 & -1 & 2 \\\\\n 1 & -2 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -1 & 0 \\\\\n -1 & -2 \\\\\n 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & 6 \\\\\n 3 & 6 \\\\\n 1 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, 2],\n [-2, -1, 2],\n [1, -2, -1]])\nb = np.array([\n [-1, 0],\n [-1, -2],\n [0, 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{14}{3} & 5 & \\frac{8}{3} \\\\\n -\\frac{20}{3} & -\\frac{4}{3} & -\\frac{25}{3} \\\\\n 0 & -8 & \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-5.666,3.36,6.972\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/3), 5, (8/3)],\n [-(20/3), -(4/3), -(25/3)],\n [0, -8, (4/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{39}{8} \\\\\n \\frac{57}{8} \\\\\n -\\frac{21}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{47}{8} \\\\\n -\\frac{19}{2} \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{171}{8} \\\\\n \\frac{831}{64} \\\\\n -\\frac{285}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(39/8)],\n [(57/8)],\n [-(21/8)]])\nb = np.array([\n [-(47/8)],\n [-(19/2)],\n [(1/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 0 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -9 \\\\\n -50 \\\\\n -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [0],\n [9]])\nb = np.array([\n [-5],\n [1],\n [-1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & \\frac{24}{5} & 0 \\\\\n -1 & -1 & \\frac{14}{5} \\\\\n -\\frac{12}{5} & -2 & -\\frac{18}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{3892}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, (24/5), 0],\n [-1, -1, (14/5)],\n [-(12/5), -2, -(18/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{24}{5} \\\\\n -\\frac{67}{10} \\\\\n \\frac{28}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{171}{10}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(24/5)],\n [-(67/10)],\n [(28/5)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n \\frac{4}{9} \\\\\n \\frac{4}{3} \\\\\n \\frac{1}{3} \\\\\n \\frac{25}{9} \\\\\n \\frac{7}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{26}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{104}{81} \\\\\n -\\frac{104}{27} \\\\\n -\\frac{26}{27} \\\\\n -\\frac{650}{81} \\\\\n -\\frac{182}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/9)],\n [(4/3)],\n [(1/3)],\n [(25/9)],\n [(7/9)]])\nb = np.array([\n [-(26/9)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3]])\nb = np.array([\n [-(1/2)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{19}{2} \\\\\n -\\frac{29}{4} \\\\\n \\frac{25}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n \\frac{15}{2} \\\\\n \\frac{1}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{779}{16} \\\\\n 7 \\\\\n \\frac{657}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/2)],\n [-(29/4)],\n [(25/4)]])\nb = np.array([\n [(3/2)],\n [(15/2)],\n [(1/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{4} & \\frac{7}{8} \\\\\n -\\frac{79}{8} & -\\frac{33}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{15 x}{8}-\\frac{41}{64}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/4), (7/8)],\n [-(79/8), -(33/8)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 6 \\\\\n 10 \\\\\n 5 \\\\\n 7 \\\\\n -7 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -9 \\\\\n -6 \\\\\n -4 \\\\\n 6 \\\\\n 5 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{759}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [6],\n [10],\n [5],\n [7],\n [-7],\n [-3]])\nb = np.array([\n [-2],\n [-9],\n [-6],\n [-4],\n [6],\n [5],\n [-7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -2 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -1 \\\\\n -1 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$67$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-2],\n [0],\n [1]])\nb = np.array([\n [6],\n [-1],\n [-1],\n [5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 4 & -6 & -8 \\\\\n 1 & -2 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & -29 \\\\\n 0 & 1 & -18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, -6, -8],\n [1, -2, 7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & -4 \\\\\n 6 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{3} \\left(-4-\\sqrt{10}\\right),1\\right\\}, \\left\\{\\frac{1}{3} \\left(\\sqrt{10}-4\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -4],\n [6, 9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 2 & 7 & 4 & -1 & 1 & 2 & -3 \\\\\n 6 & -8 & -8 & -7 & 10 & 1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & -\\frac{12}{29} & -\\frac{57}{58} & \\frac{39}{29} & \\frac{23}{58} & \\frac{2}{29} \\\\\n 0 & 1 & \\frac{20}{29} & \\frac{4}{29} & -\\frac{7}{29} & \\frac{5}{29} & -\\frac{13}{29} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, 7, 4, -1, 1, 2, -3],\n [6, -8, -8, -7, 10, 1, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$40$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4]])\nb = np.array([\n [10]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & 9 \\\\\n -3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-1-3 i \\sqrt{11}\\right),\\frac{1}{2} \\left(-1+3 i \\sqrt{11}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 9],\n [-3, -2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 6 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 6 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{58}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [6],\n [7]])\nb = np.array([\n [3],\n [6],\n [0]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -5 & 3 & -9 & -8 \\\\\n 9 & 4 & 7 & 3 \\\\\n 0 & 4 & 9 & -10 \\\\\n -6 & -6 & 5 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 3, -9, -8],\n [9, 4, 7, 3],\n [0, 4, 9, -10],\n [-6, -6, 5, -6]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 8 & 10 & -3 & -10 & 6 \\\\\n 10 & -7 & -10 & -2 & -5 \\\\\n 6 & 7 & 5 & 0 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & \\frac{52}{289} & -\\frac{1049}{1156} \\\\\n 0 & 1 & 0 & -\\frac{246}{289} & \\frac{575}{578} \\\\\n 0 & 0 & 1 & \\frac{282}{289} & -\\frac{319}{289} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, 10, -3, -10, 6],\n [10, -7, -10, -2, -5],\n [6, 7, 5, 0, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -3 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{83}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-3],\n [5]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -1 & 8 & -3 & -6 & 10 \\\\\n 6 & -10 & 5 & 7 & -8 \\\\\n -4 & 4 & -1 & 5 & -9 \\\\\n -4 & 7 & 4 & -1 & 3 \\\\\n 2 & -8 & 4 & 1 & -3 \\\\\n -4 & 6 & 8 & -4 & -1 \\\\\n -8 & -1 & 9 & -9 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-1, 8, -3, -6, 10],\n [6, -10, 5, 7, -8],\n [-4, 4, -1, 5, -9],\n [-4, 7, 4, -1, 3],\n [2, -8, 4, 1, -3],\n [-4, 6, 8, -4, -1],\n [-8, -1, 9, -9, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{1}{3},\\frac{1}{3},\\frac{2}{3}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [1],\n [-1]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,-2,-4\\}, \\{4,1,3\\}, \\{5,3,4\\}}$.", - "Output Answer": [ - "$11 x-4 y-3 z-31=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -2, -4],\n [4, 1, 3],\n [5, 3, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{16} \\\\\n -\\frac{93}{16} \\\\\n \\frac{63}{16} \\\\\n -\\frac{11}{8} \\\\\n \\frac{13}{8} \\\\\n -\\frac{101}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{6015}}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/16)],\n [-(93/16)],\n [(63/16)],\n [-(11/8)],\n [(13/8)],\n [-(101/16)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{3,0,\\frac{5}{3}\\right\\}, \\left\\{\\frac{13}{3},-\\frac{5}{3},0\\right\\}, \\left\\{1,-\\frac{14}{3},-\\frac{1}{3}\\right\\}}$.", - "Output Answer": [ - "$60 x-81 y+129 z-395=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, 0, (5/3)],\n [(13/3), -(5/3), 0],\n [1, -(14/3), -(1/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -6 \\\\\n -1 \\\\\n 7 \\\\\n 3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-6],\n [-1],\n [7],\n [3],\n [2]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 3 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 8 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$119$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [3],\n [9]])\nb = np.array([\n [-4],\n [8],\n [7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{47}{10}, -\\frac{12}{5}}$ to the line $\\frac{47 x}{10}-\\frac{3 y}{10}-\\frac{21}{10}=0$.", - "Output Answer": [ - "$\\frac{2347}{10 \\sqrt{2218}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(47/10), -(12/5)\nline = Poly(((47*x)/10)-((3*y)/10)-(21/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & -2 & -1 \\\\\n 2 & 1 & -3 \\\\\n -2 & 3 & 0 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & -7 & 5 \\\\\n 10 & -12 & -5 \\\\\n 4 & 7 & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2, -1],\n [2, 1, -3],\n [-2, 3, 0]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{9} & \\frac{44}{9} & \\frac{4}{9} \\\\\n -\\frac{11}{9} & \\frac{1}{3} & \\frac{13}{3} \\\\\n -\\frac{4}{3} & \\frac{13}{3} & -\\frac{11}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{6993}{14521} & -\\frac{2880}{14521} & -\\frac{7668}{14521} \\\\\n \\frac{5301}{29042} & -\\frac{333}{29042} & \\frac{747}{29042} \\\\\n \\frac{3537}{29042} & \\frac{5103}{29042} & -\\frac{4383}{29042} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/9), (44/9), (4/9)],\n [-(11/9), (1/3), (13/3)],\n [-(4/3), (13/3), -(11/9)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -2 & -9 & 4 & -6 \\\\\n 6 & 1 & 6 & 1 \\\\\n -3 & 7 & 10 & -4 \\\\\n 4 & 3 & -8 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, -9, 4, -6],\n [6, 1, 6, 1],\n [-3, 7, 10, -4],\n [4, 3, -8, 8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 0 & 0 & 3 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0, 3, -1]])\nb = np.array([\n [-2],\n [0],\n [-1],\n [1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{15}{4} & 2 \\\\\n \\frac{23}{4} & \\frac{3}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{9 x}{2}-\\frac{139}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/4), 2],\n [(23/4), (3/4)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 3 \\\\\n -10 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-3,2\\}, \\{-1,5\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 3],\n [-10, -9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{188}{25} & \\frac{803}{100} & \\frac{23}{25} & -\\frac{513}{100} \\\\\n \\frac{37}{20} & -\\frac{37}{10} & -\\frac{2}{5} & -\\frac{181}{25} \\\\\n -\\frac{123}{100} & \\frac{391}{50} & \\frac{174}{25} & -\\frac{124}{25} \\\\\n -\\frac{993}{100} & \\frac{243}{50} & -\\frac{143}{100} & \\frac{917}{100} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n \\frac{939}{100} & \\frac{167}{50} & -\\frac{9}{50} & \\frac{121}{100} \\\\\n -\\frac{443}{100} & -\\frac{817}{100} & \\frac{203}{100} & \\frac{449}{50} \\\\\n -\\frac{174}{25} & \\frac{791}{100} & -\\frac{991}{100} & \\frac{124}{25} \\\\\n \\frac{1}{20} & -\\frac{787}{100} & -\\frac{353}{50} & \\frac{127}{20} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{187}{100} & \\frac{469}{100} & \\frac{11}{10} & -\\frac{317}{50} \\\\\n \\frac{157}{25} & \\frac{447}{100} & -\\frac{243}{100} & -\\frac{811}{50} \\\\\n \\frac{573}{100} & -\\frac{9}{100} & \\frac{1687}{100} & -\\frac{248}{25} \\\\\n -\\frac{499}{50} & \\frac{1273}{100} & \\frac{563}{100} & \\frac{141}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(188/25), (803/100), (23/25), -(513/100)],\n [(37/20), -(37/10), -(2/5), -(181/25)],\n [-(123/100), (391/50), (174/25), -(124/25)],\n [-(993/100), (243/50), -(143/100), (917/100)]])\nb = np.array([\n [(939/100), (167/50), -(9/50), (121/100)],\n [-(443/100), -(817/100), (203/100), (449/50)],\n [-(174/25), (791/100), -(991/100), (124/25)],\n [(1/20), -(787/100), -(353/50), (127/20)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 2 & 6 & 10 & 9 & -4 \\\\\n 10 & 4 & 2 & -9 & 4 \\\\\n -9 & -3 & -3 & 5 & 1 \\\\\n -6 & 9 & -8 & 8 & -2 \\\\\n 9 & -8 & 3 & 3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, 6, 10, 9, -4],\n [10, 4, 2, -9, 4],\n [-9, -3, -3, 5, 1],\n [-6, 9, -8, 8, -2],\n [9, -8, 3, 3, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{8}{7},-\\frac{4}{7},-\\frac{4}{7},\\frac{4}{7}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [-1],\n [2]]).squeeze()\nb = np.array([\n [-2],\n [-1],\n [-1],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 2 & 3 \\\\\n -3 & -2 & 1 \\\\\n -3 & 2 & 3 \\\\\n -1 & 2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.29 \\\\\n -0.41 \\\\\n 0.86 \\\\\n 2.87 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.311 \\\\\n 0.76 \\\\\n -0.32 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, 3],\n [-3, -2, 1],\n [-3, 2, 3],\n [-1, 2, -2]])\nb = np.array([\n [1.29],\n [-0.41],\n [0.86],\n [2.87]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{23}{5} \\\\\n \\frac{32}{5} \\\\\n \\frac{71}{10} \\\\\n -\\frac{17}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{26}{5} \\\\\n -\\frac{51}{10} \\\\\n -\\frac{79}{10} \\\\\n -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{49}{5} \\\\\n \\frac{13}{10} \\\\\n -\\frac{4}{5} \\\\\n -\\frac{26}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/5)],\n [(32/5)],\n [(71/10)],\n [-(17/10)]])\nb = np.array([\n [(26/5)],\n [-(51/10)],\n [-(79/10)],\n [-(7/2)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n -3 & -1 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1, 6]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 4 & -\\frac{10}{7} & \\frac{31}{7} \\\\\n \\frac{3}{7} & -1 & \\frac{18}{7} \\\\\n \\frac{11}{7} & 1 & \\frac{4}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{539}{1567} & -\\frac{1799}{3134} & -\\frac{259}{3134} \\\\\n -\\frac{651}{1567} & \\frac{1603}{3134} & \\frac{2877}{3134} \\\\\n -\\frac{343}{1567} & \\frac{1071}{1567} & \\frac{581}{1567} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -(10/7), (31/7)],\n [(3/7), -1, (18/7)],\n [(11/7), 1, (4/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -1 & 9 & 3 & 5 & -3 & -9 \\\\\n -8 & -7 & -6 & 4 & -4 & 7 \\\\\n 9 & 5 & 9 & 2 & -5 & 5 \\\\\n -1 & 3 & 3 & -8 & -7 & 0 \\\\\n 6 & -9 & 10 & 4 & -9 & -4 \\\\\n -7 & -2 & 3 & 7 & -9 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-1, 9, 3, 5, -3, -9],\n [-8, -7, -6, 4, -4, 7],\n [9, 5, 9, 2, -5, 5],\n [-1, 3, 3, -8, -7, 0],\n [6, -9, 10, 4, -9, -4],\n [-7, -2, 3, 7, -9, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 5 & -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 5 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 10 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -7]])\nb = np.array([\n [5, 4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{2} & \\frac{3}{2} & 2 \\\\\n -\\frac{1}{2} & 1 & -1 \\\\\n -3 & 2 & -3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{293}{8} & -\\frac{49}{2} & \\frac{77}{4} \\\\\n -7 & \\frac{41}{8} & \\frac{21}{4} \\\\\n -\\frac{35}{2} & \\frac{49}{4} & \\frac{61}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), (3/2), 2],\n [-(1/2), 1, -1],\n [-3, 2, -3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -1 & -3 & -8 & -2 \\\\\n -7 & 2 & -5 & 1 \\\\\n 1 & 10 & 8 & 7 \\\\\n -9 & 2 & 1 & -9 \\\\\n -3 & 4 & 6 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, -3, -8, -2],\n [-7, 2, -5, 1],\n [1, 10, 8, 7],\n [-9, 2, 1, -9],\n [-3, 4, 6, 0]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 5 \\\\\n -3 \\\\\n -7 \\\\\n -6 \\\\\n -9 \\\\\n 5 \\\\\n 9 \\\\\n 0 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 0 \\\\\n 0 \\\\\n 8 \\\\\n 3 \\\\\n -9 \\\\\n -8 \\\\\n 6 \\\\\n 8 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{602}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [5],\n [-3],\n [-7],\n [-6],\n [-9],\n [5],\n [9],\n [0],\n [-2]])\nb = np.array([\n [-6],\n [0],\n [0],\n [8],\n [3],\n [-9],\n [-8],\n [6],\n [8],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,2,-1\\}, \\left\\{\\frac{3}{2},\\frac{5}{2},-2\\right\\}, \\left\\{-3,\\frac{1}{2},\\frac{3}{2}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{2}{3},\\frac{2}{3},-\\frac{1}{3}\\right\\}, \\left\\{\\frac{43}{3 \\sqrt{386}},\\frac{29}{3 \\sqrt{386}},-\\frac{14 \\sqrt{\\frac{2}{193}}}{3}\\right\\}, \\left\\{\\frac{3}{\\sqrt{386}},\\frac{11}{\\sqrt{386}},8 \\sqrt{\\frac{2}{193}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, 2, -1), ((3/2), (5/2), -2), (-3, (1/2), (3/2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{87}{10} \\\\\n -1 \\\\\n \\frac{39}{10} \\\\\n \\frac{5}{2} \\\\\n \\frac{14}{5} \\\\\n -\\frac{14}{5} \\\\\n -2 \\\\\n -\\frac{23}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{283}{10}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(87/10)],\n [-1],\n [(39/10)],\n [(5/2)],\n [(14/5)],\n [-(14/5)],\n [-2],\n [-(23/5)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & -2 & 0 \\\\\n -3 & 0 & -2 \\\\\n 3 & 2 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-18$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2, 0],\n [-3, 0, -2],\n [3, 2, 5]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{12}{5} & -\\frac{18}{5} & \\frac{3}{5} \\\\\n \\frac{13}{5} & \\frac{24}{5} & -\\frac{23}{5} \\\\\n -\\frac{4}{5} & -5 & -\\frac{16}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{959}{3519} & \\frac{121}{1173} & -\\frac{38}{391} \\\\\n -\\frac{100}{1173} & \\frac{20}{391} & -\\frac{35}{391} \\\\\n \\frac{229}{3519} & -\\frac{124}{1173} & -\\frac{58}{391} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(12/5), -(18/5), (3/5)],\n [(13/5), (24/5), -(23/5)],\n [-(4/5), -5, -(16/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -7 & 7 & -1 & 3 & 3 \\\\\n -3 & -5 & 10 & -8 & 1 \\\\\n 0 & -10 & 2 & -10 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & \\frac{58}{103} & \\frac{64}{103} \\\\\n 0 & 1 & 0 & \\frac{100}{103} & \\frac{121}{103} \\\\\n 0 & 0 & 1 & -\\frac{15}{103} & \\frac{90}{103} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, 7, -1, 3, 3],\n [-3, -5, 10, -8, 1],\n [0, -10, 2, -10, -10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{144}{25} & \\frac{118}{25} & \\frac{849}{100} \\\\\n \\frac{9}{25} & -\\frac{423}{100} & -\\frac{389}{50} \\\\\n \\frac{141}{50} & \\frac{4}{25} & \\frac{219}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{1029 x^2}{100}+\\frac{176791 x}{5000}-\\frac{111471333}{500000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(144/25), (118/25), (849/100)],\n [(9/25), -(423/100), -(389/50)],\n [(141/50), (4/25), (219/25)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{2} \\\\\n \\frac{46}{5} \\\\\n \\frac{1}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 1 \\\\\n \\frac{7}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{317}{50} \\\\\n -\\frac{129}{20} \\\\\n \\frac{109}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/2)],\n [(46/5)],\n [(1/10)]])\nb = np.array([\n [-5],\n [1],\n [(7/10)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 8 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 9 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 41 \\\\\n -20 \\\\\n -36 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [8],\n [-9]])\nb = np.array([\n [0],\n [9],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{21}{10} & -\\frac{1}{2} & -\\frac{49}{10} \\\\\n -\\frac{18}{5} & \\frac{47}{10} & -\\frac{23}{5} \\\\\n -\\frac{6}{5} & -\\frac{3}{5} & -\\frac{43}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{22970}{14997} & \\frac{790}{14997} & \\frac{25330}{14997} \\\\\n -\\frac{3320}{4999} & \\frac{1050}{4999} & \\frac{2660}{4999} \\\\\n \\frac{2600}{4999} & -\\frac{220}{4999} & -\\frac{3890}{4999} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(21/10), -(1/2), -(49/10)],\n [-(18/5), (47/10), -(23/5)],\n [-(6/5), -(3/5), -(43/10)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 9 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 9 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$97$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [9],\n [-6]])\nb = np.array([\n [-4],\n [9],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{2} & -4 \\\\\n -\\frac{15}{2} & -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{15} \\left(-5-\\sqrt{145}\\right),1\\right\\}, \\left\\{\\frac{1}{15} \\left(\\sqrt{145}-5\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), -4],\n [-(15/2), -(17/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{3} \\\\\n -4 \\\\\n -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{2}{3} \\\\\n -4 \\\\\n 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{92}{3} \\\\\n \\frac{143}{9} \\\\\n 28 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/3)],\n [-4],\n [-(14/3)]])\nb = np.array([\n [(2/3)],\n [-4],\n [3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 4 & -7 & -2 \\\\\n -4 & -5 & -10 \\\\\n 5 & 7 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, -7, -2],\n [-4, -5, -10],\n [5, 7, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 3 & -3 \\\\\n 3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{2}{15} & \\frac{1}{5} \\\\\n -\\frac{1}{5} & \\frac{1}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -3],\n [3, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & -3 \\\\\n -4 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3],\n [-4, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(-2 \\sqrt{14}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [-1],\n [1],\n [0],\n [1],\n [-1],\n [1],\n [1],\n [0]]).squeeze()\nb = np.array([\n [1],\n [-1],\n [-1],\n [-1],\n [1],\n [0],\n [-1],\n [0],\n [-1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n \\frac{13}{3} \\\\\n -\\frac{13}{3} \\\\\n -\\frac{26}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [(13/3)],\n [-(13/3)],\n [-(26/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -9 & -4 \\\\\n -5 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{-\\frac{2}{\\sqrt{5}},1\\right\\}, \\left\\{\\frac{2}{\\sqrt{5}},1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -4],\n [-5, -9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{5} & -\\frac{11}{5} \\\\\n -\\frac{8}{5} & -\\frac{21}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{8} \\left(-15-\\sqrt{313}\\right),1\\right\\}, \\left\\{\\frac{1}{8} \\left(\\sqrt{313}-15\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/5), -(11/5)],\n [-(8/5), -(21/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{4}{3},1,-\\frac{11}{3}\\right\\}, \\left\\{\\frac{1}{3},-\\frac{4}{3},0\\right\\}, \\left\\{0,\\frac{2}{3},-\\frac{1}{3}\\right\\}}$.", - "Output Answer": [ - "$59 x+14 y+25 z-1=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(4/3), 1, -(11/3)],\n [(1/3), -(4/3), 0],\n [0, (2/3), -(1/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -3 & -2 & 3 & -1 & 2 \\\\\n 3 & -2 & -1 & -3 & 2 \\\\\n 2 & -3 & -3 & 2 & -3 \\\\\n 2 & -3 & -2 & 2 & 0 \\\\\n -2 & -2 & -3 & 2 & 2 \\\\\n 0 & 3 & -3 & 3 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.06 \\\\\n -1.69 \\\\\n 1.79 \\\\\n 1.4 \\\\\n 1.74 \\\\\n -2.71 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.397 \\\\\n -0.49 \\\\\n -0.178 \\\\\n -0.092 \\\\\n -0.595 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2, 3, -1, 2],\n [3, -2, -1, -3, 2],\n [2, -3, -3, 2, -3],\n [2, -3, -2, 2, 0],\n [-2, -2, -3, 2, 2],\n [0, 3, -3, 3, 0]])\nb = np.array([\n [-1.06],\n [-1.69],\n [1.79],\n [1.4],\n [1.74],\n [-2.71]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{10}{3}, 1}$ to the line $x-\\frac{7 y}{3}=0$.", - "Output Answer": [ - "$\\frac{17}{\\sqrt{58}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(10/3), 1\nline = Poly(x-((7*y)/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{17}{5} & 1 & -\\frac{19}{5} \\\\\n \\frac{8}{5} & -5 & 1 \\\\\n \\frac{6}{5} & \\frac{12}{5} & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{894}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/5), 1, -(19/5)],\n [(8/5), -5, 1],\n [(6/5), (12/5), -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 1 & -3 & -1 \\\\\n 0 & -1 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 1 & -2 & 1 & 3 & -2 \\\\\n -1 & -2 & -2 & -3 & -1 \\\\\n -1 & 1 & -2 & 1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 5 & 3 & 9 & 11 & 4 \\\\\n 4 & -1 & 8 & 0 & 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3, -1],\n [0, -1, -3]])\nb = np.array([\n [1, -2, 1, 3, -2],\n [-1, -2, -2, -3, -1],\n [-1, 1, -2, 1, -3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -5 \\\\\n -5 \\\\\n 4 \\\\\n 6 \\\\\n -7 \\\\\n -6 \\\\\n -8 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -9 \\\\\n -5 \\\\\n -5 \\\\\n -8 \\\\\n 2 \\\\\n -9 \\\\\n 10 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{779}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-5],\n [-5],\n [4],\n [6],\n [-7],\n [-6],\n [-8],\n [-2]])\nb = np.array([\n [1],\n [-9],\n [-5],\n [-5],\n [-8],\n [2],\n [-9],\n [10],\n [-8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 6 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 5 \\\\\n -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -68 \\\\\n \\frac{73}{2} \\\\\n -41 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [6],\n [7]])\nb = np.array([\n [6],\n [5],\n [-(11/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{7}{2},-2,\\frac{1}{2}\\right\\}, \\left\\{-2,-\\frac{1}{2},-\\frac{7}{2}\\right\\}, \\left\\{0,3,\\frac{5}{2}\\right\\}}$.", - "Output Answer": [ - "$184 x+200 y-178 z-155=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(7/2), -2, (1/2)],\n [-2, -(1/2), -(7/2)],\n [0, 3, (5/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{18}{5}, 5}$ to the line $-\\frac{3 x}{5}+\\frac{4 y}{5}-\\frac{4}{5}=0$.", - "Output Answer": [ - "$\\frac{26}{25}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (18/5), 5\nline = Poly(-((3*x)/5)+((4*y)/5)-(4/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{9}{5} & \\frac{3}{5} & 2 \\\\\n -\\frac{6}{5} & \\frac{24}{5} & -\\frac{14}{5} \\\\\n -\\frac{24}{5} & \\frac{19}{5} & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1254}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/5), (3/5), 2],\n [-(6/5), (24/5), -(14/5)],\n [-(24/5), (19/5), 2]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 4 \\\\\n 6 \\\\\n 6 \\\\\n 6 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -1 \\\\\n -4 \\\\\n -3 \\\\\n -5 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{155}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [4],\n [6],\n [6],\n [6],\n [-8]])\nb = np.array([\n [7],\n [-1],\n [-4],\n [-3],\n [-5],\n [9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & -\\frac{11}{3} & -\\frac{5}{3} \\\\\n -3 & \\frac{2}{3} & \\frac{10}{3} \\\\\n -2 & -\\frac{2}{3} & -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{529}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(11/3), -(5/3)],\n [-3, (2/3), (10/3)],\n [-2, -(2/3), -(11/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n \\frac{35}{6} & \\frac{13}{6} \\\\\n \\frac{23}{3} & \\frac{8}{3} \\\\\n -1 & \\frac{5}{3} \\\\\n \\frac{37}{6} & -\\frac{19}{2} \\\\\n -\\frac{3}{2} & -\\frac{25}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(35/6), (13/6)],\n [(23/3), (8/3)],\n [-1, (5/3)],\n [(37/6), -(19/2)],\n [-(3/2), -(25/6)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 10 & -9 & -2 & 3 & -1 & 4 \\\\\n 3 & 8 & 0 & -3 & 8 & 7 \\\\\n 0 & -1 & 0 & 6 & -3 & -6 \\\\\n 4 & -9 & 1 & -5 & 7 & -10 \\\\\n -1 & 5 & -3 & 8 & -4 & -3 \\\\\n -1 & 7 & -2 & -10 & -8 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, -9, -2, 3, -1, 4],\n [3, 8, 0, -3, 8, 7],\n [0, -1, 0, 6, -3, -6],\n [4, -9, 1, -5, 7, -10],\n [-1, 5, -3, 8, -4, -3],\n [-1, 7, -2, -10, -8, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n \\frac{16}{7} & \\frac{4}{7} & -\\frac{6}{7} & \\frac{1}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n \\frac{17}{7} & -\\frac{5}{7} & -\\frac{16}{7} & -\\frac{4}{7} & \\frac{18}{7} \\\\\n -\\frac{8}{7} & 2 & 3 & -\\frac{4}{7} & -3 \\\\\n \\frac{15}{7} & \\frac{19}{7} & \\frac{11}{7} & -\\frac{2}{7} & -\\frac{15}{7} \\\\\n -\\frac{2}{7} & -\\frac{17}{7} & \\frac{4}{7} & \\frac{10}{7} & -\\frac{5}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n \\frac{148}{49} & -\\frac{155}{49} & -\\frac{234}{49} & -\\frac{58}{49} & \\frac{289}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(16/7), (4/7), -(6/7), (1/7)]])\nb = np.array([\n [(17/7), -(5/7), -(16/7), -(4/7), (18/7)],\n [-(8/7), 2, 3, -(4/7), -3],\n [(15/7), (19/7), (11/7), -(2/7), -(15/7)],\n [-(2/7), -(17/7), (4/7), (10/7), -(5/7)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\log (2) \\\\\n -\\log (2) \\\\\n 2 \\log (2) \\\\\n -10 \\log (2) \\\\\n 13 \\log (2) \\\\\n -5 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 11 \\log (2) \\\\\n 10 \\log (2) \\\\\n 7 \\log (2) \\\\\n 6 \\log (2) \\\\\n -12 \\log (2) \\\\\n -3 \\log (2) \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4 \\sqrt{66} \\log (2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [6*math.log(2)],\n [-math.log(2)],\n [2*math.log(2)],\n [-10*math.log(2)],\n [13*math.log(2)],\n [-5*math.log(2)]])\nb = np.array([\n [11*math.log(2)],\n [10*math.log(2)],\n [7*math.log(2)],\n [6*math.log(2)],\n [-12*math.log(2)],\n [-3*math.log(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & \\frac{3}{2} & -1 \\\\\n -2 & 3 & -\\frac{3}{2} \\\\\n \\frac{1}{2} & 3 & \\frac{1}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{4} & \\frac{9}{4} & -\\frac{13}{4} \\\\\n -\\frac{31}{4} & \\frac{3}{2} & -\\frac{13}{4} \\\\\n -\\frac{11}{2} & \\frac{45}{4} & -\\frac{19}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), (3/2), -1],\n [-2, 3, -(3/2)],\n [(1/2), 3, (1/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & \\frac{13}{3} \\\\\n 0 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{-\\frac{13}{18},1\\right\\}, \\{1,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, (13/3)],\n [0, -2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7.5 \\\\\n -5.2 \\\\\n 9.6 \\\\\n -3.6 \\\\\n -7.6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1.9 \\\\\n 3.5 \\\\\n 1.8 \\\\\n -1.1 \\\\\n 8.5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$22.1438$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7.5],\n [-5.2],\n [9.6],\n [-3.6],\n [-7.6]])\nb = np.array([\n [-1.9],\n [3.5],\n [1.8],\n [-1.1],\n [8.5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & 1 & 2 \\\\\n 3 & -1 & -1 \\\\\n 1 & 1 & 1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 6 & 0 & -1 \\\\\n -7 & 3 & 6 \\\\\n 3 & 1 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, 2],\n [3, -1, -1],\n [1, 1, 1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -7 & 4 & 4 & -2 \\\\\n 8 & 8 & -10 & -10 \\\\\n 10 & -9 & 4 & -7 \\\\\n -1 & 5 & -4 & -5 \\\\\n -7 & -8 & 7 & 4 \\\\\n -2 & -6 & 10 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, 4, 4, -2],\n [8, 8, -10, -10],\n [10, -9, 4, -7],\n [-1, 5, -4, -5],\n [-7, -8, 7, 4],\n [-2, -6, 10, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 6 & -3 & -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -3 & -2 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 3 & -5 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -3, -8]])\nb = np.array([\n [-3, -2, 7]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -\\frac{11}{2} & 0 & 5 & -\\frac{13}{2} \\\\\n -\\frac{5}{2} & 7 & 1 & \\frac{3}{2} \\\\\n -\\frac{13}{2} & \\frac{17}{2} & -7 & -\\frac{7}{2} \\\\\n -8 & -\\frac{9}{2} & 4 & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/2), 0, 5, -(13/2)],\n [-(5/2), 7, 1, (3/2)],\n [-(13/2), (17/2), -7, -(7/2)],\n [-8, -(9/2), 4, -(5/2)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{4} & \\frac{17}{16} \\\\\n \\frac{29}{16} & -\\frac{41}{16} \\\\\n -\\frac{35}{16} & -\\frac{21}{8} \\\\\n \\frac{41}{16} & -\\frac{23}{8} \\\\\n -\\frac{17}{16} & -\\frac{39}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & -3 \\\\\n \\frac{1}{16} & \\frac{45}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{305}{256} & -\\frac{963}{256} \\\\\n \\frac{191}{256} & -\\frac{3237}{256} \\\\\n -\\frac{161}{128} & -\\frac{105}{128} \\\\\n \\frac{141}{128} & -\\frac{2019}{128} \\\\\n -\\frac{175}{256} & -\\frac{939}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/4), (17/16)],\n [(29/16), -(41/16)],\n [-(35/16), -(21/8)],\n [(41/16), -(23/8)],\n [-(17/16), -(39/16)]])\nb = np.array([\n [(1/2), -3],\n [(1/16), (45/16)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{103}{20} \\\\\n \\frac{57}{50} \\\\\n -\\frac{93}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{757}{100} \\\\\n -\\frac{19}{5} \\\\\n \\frac{949}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{122607}{5000} \\\\\n -\\frac{238549}{2000} \\\\\n -\\frac{140999}{5000} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(103/20)],\n [(57/50)],\n [-(93/10)]])\nb = np.array([\n [(757/100)],\n [-(19/5)],\n [(949/100)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{2}{3}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -10 & 3 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{20}{3} & 2 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 3, -3]])\nprint(a * (2/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2-4 i & -1-i & -3 i \\\\\n -4-5 i & i & -4+3 i \\\\\n 4-4 i & -2+4 i & 1+i \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -159-25 i & 35+59 i & -100+58 i \\\\\n -47+378 i & 92-123 i & 121+97 i \\\\\n -184-146 i & 102-16 i & -2-186 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2-4j, -1- 1j, -3j],\n [-4-5j, 1j, -4+3j],\n [4-4j, -2+4j, 1+ 1j]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 4 & -2 & 1 & 1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 1 & -5 & 1 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 3 & 3 & 0 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -2, 1, 1]])\nb = np.array([\n [1, -5, 1, -5]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{29}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{11}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/3)]])\nb = np.array([\n [6]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -6 \\\\\n 5 \\\\\n -2 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 7 \\\\\n 5 \\\\\n 8 \\\\\n 2 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{391}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-6],\n [5],\n [-2],\n [-1],\n [-1]])\nb = np.array([\n [-1],\n [7],\n [5],\n [8],\n [2],\n [-8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{100}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 6 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{100} \\\\\n \\frac{3}{50} \\\\\n \\frac{1}{20} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [6],\n [5]])\nprint(a * (1/100))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 3 & -\\frac{3}{2} & \\frac{15}{2} \\\\\n \\frac{15}{2} & -8 & 1 \\\\\n -7 & \\frac{17}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-10.512,-8.591,1.\\}, \\{-0.872-0.794 i,-1.104-0.043 i,1.\\}, \\{-0.872+0.794 i,-1.104+0.043 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -(3/2), (15/2)],\n [(15/2), -8, 1],\n [-7, (17/2), (1/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{69}{8} & \\frac{7}{8} \\\\\n \\frac{49}{8} & \\frac{7}{8} \\\\\n \\frac{49}{8} & \\frac{31}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{37}{4} & -1 \\\\\n -6 & \\frac{79}{8} \\\\\n \\frac{73}{8} & \\frac{23}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{143}{8} & -\\frac{1}{8} \\\\\n \\frac{1}{8} & \\frac{43}{4} \\\\\n \\frac{61}{4} & \\frac{27}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(69/8), (7/8)],\n [(49/8), (7/8)],\n [(49/8), (31/4)]])\nb = np.array([\n [(37/4), -1],\n [-6, (79/8)],\n [(73/8), (23/4)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & 6 \\\\\n 8 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{8} \\left(5-\\sqrt{73}\\right),1\\right\\}, \\left\\{\\frac{1}{8} \\left(5+\\sqrt{73}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 6],\n [8, -9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2 \\\\\n -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [0]])\nb = np.array([\n [-6],\n [-7]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{22}{e} \\\\\n \\frac{14}{e} \\\\\n \\frac{22}{e} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{23}{e} \\\\\n \\frac{2}{e} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{366}{e^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(22/math.e)],\n [(14/math.e)],\n [(22/math.e)]])\nb = np.array([\n [0],\n [(23/math.e)],\n [(2/math.e)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 2 & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{3} & -\\frac{4}{3} & -\\frac{3}{2} \\\\\n 2 & \\frac{17}{6} & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{7}{3} & -\\frac{49}{12} & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(1/2)]])\nb = np.array([\n [(5/3), -(4/3), -(3/2)],\n [2, (17/6), 1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & 2 & 0 & 2 \\\\\n 0 & -3 & 2 & 3 \\\\\n -2 & 2 & -2 & -1 \\\\\n 3 & -2 & -3 & -3 \\\\\n -3 & -3 & 1 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.73 \\\\\n -2. \\\\\n -1.58 \\\\\n -2.93 \\\\\n 2.88 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.401 \\\\\n 0.519 \\\\\n 1.117 \\\\\n -0.631 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2, 0, 2],\n [0, -3, 2, 3],\n [-2, 2, -2, -1],\n [3, -2, -3, -3],\n [-3, -3, 1, -3]])\nb = np.array([\n [2.73],\n [-2.],\n [-1.58],\n [-2.93],\n [2.88]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $3$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -9 & -7 \\\\\n 3 & -6 \\\\\n 8 & -2 \\\\\n 5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -27 & -21 \\\\\n 9 & -18 \\\\\n 24 & -6 \\\\\n 15 & -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -7],\n [3, -6],\n [8, -2],\n [5, -4]])\nprint(a * 3)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 2 e \\\\\n -4 e \\\\\n 3 e \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 e \\\\\n -e \\\\\n 3 e \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{10} e$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [2*math.e],\n [-4*math.e],\n [3*math.e]])\nb = np.array([\n [0],\n [3*math.e],\n [-math.e],\n [3*math.e]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -2 \\\\\n 0 & 1 \\\\\n -2 & -2 \\\\\n 3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.51 \\\\\n 1.6 \\\\\n -2.63 \\\\\n 1.59 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.608 \\\\\n 1.813 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2],\n [0, 1],\n [-2, -2],\n [3, 2]])\nb = np.array([\n [-2.51],\n [1.6],\n [-2.63],\n [1.59]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, \\frac{2}{5}}$ to the line $-\\frac{22 x}{5}+\\frac{2 y}{5}+\\frac{21}{5}=0$.", - "Output Answer": [ - "$\\frac{439}{10 \\sqrt{122}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, (2/5)\nline = Poly(-((22*x)/5)+((2*y)/5)+(21/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{26}{3} & -\\frac{8}{3} & \\frac{22}{3} \\\\\n -4 & -\\frac{5}{3} & -\\frac{23}{3} \\\\\n \\frac{11}{3} & -\\frac{10}{3} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8.308,-0.948,12.256\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/3), -(8/3), (22/3)],\n [-4, -(5/3), -(23/3)],\n [(11/3), -(10/3), -4]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -2 & -1 \\\\\n -8 & 7 \\\\\n 8 & 1 \\\\\n -1 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1],\n [-8, 7],\n [8, 1],\n [-1, 5]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -1 & 2 & 2 \\\\\n 0 & -1 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 0 & 0 & 3 \\\\\n 1 & 0 & -3 \\\\\n 0 & -3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 2 & -6 & -9 \\\\\n -1 & 0 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2, 2],\n [0, -1, 0]])\nb = np.array([\n [0, 0, 3],\n [1, 0, -3],\n [0, -3, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -5 & -\\frac{1}{5} \\\\\n -\\frac{6}{5} & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-3 x-\\frac{1006}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -(1/5)],\n [-(6/5), 8]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{3}{\\sqrt{2}},-2 \\sqrt{2},-\\frac{1}{\\sqrt{2}}\\right\\}, \\left\\{-\\sqrt{2},0,-\\frac{3}{\\sqrt{2}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{2}},-\\frac{1}{\\sqrt{2}},-\\frac{3}{\\sqrt{2}}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{3}{\\sqrt{26}},-2 \\sqrt{\\frac{2}{13}},-\\frac{1}{\\sqrt{26}}\\right\\}, \\left\\{\\frac{\\frac{27}{26 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{\\frac{6057}{1352}+\\left(\\sqrt{2}-\\frac{27}{26 \\sqrt{2}}\\right)^2}},\\frac{9}{13} \\sqrt{\\frac{2}{\\frac{6057}{1352}+\\left(\\sqrt{2}-\\frac{27}{26 \\sqrt{2}}\\right)^2}},-\\frac{69}{26 \\sqrt{2 \\left(\\frac{6057}{1352}+\\left(\\sqrt{2}-\\frac{27}{26 \\sqrt{2}}\\right)^2\\right)}}\\right\\}, \\left\\{\\frac{\\frac{\\sqrt{2}}{13}-\\frac{\\left(\\frac{27}{26 \\sqrt{2}}-\\sqrt{2}\\right) \\left(\\frac{171}{52}-\\frac{\\frac{27}{26 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{\\frac{6057}{1352}+\\left(-\\frac{27}{26 \\sqrt{2}}+\\sqrt{2}\\right)^2}}{\\sqrt{\\left(\\frac{17 \\sqrt{2}}{13}-\\frac{69 \\left(\\frac{171}{52}-\\frac{\\frac{27}{26 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{26 \\sqrt{2} \\left(\\frac{6057}{1352}+\\left(-\\frac{27}{26 \\sqrt{2}}+\\sqrt{2}\\right)^2\\right)}\\right)^2+\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{13}+\\frac{9 \\sqrt{2} \\left(\\frac{171}{52}-\\frac{\\frac{27}{26 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{13 \\left(\\frac{6057}{1352}+\\left(-\\frac{27}{26 \\sqrt{2}}+\\sqrt{2}\\right)^2\\right)}\\right)^2+\\left(\\frac{\\sqrt{2}}{13}+\\frac{\\left(-\\frac{27}{26 \\sqrt{2}}+\\sqrt{2}\\right) \\left(\\frac{171}{52}-\\frac{\\frac{27}{26 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{\\frac{6057}{1352}+\\left(-\\frac{27}{26 \\sqrt{2}}+\\sqrt{2}\\right)^2}\\right)^2}},\\frac{-\\frac{1}{\\sqrt{2}}+\\frac{10 \\sqrt{2}}{13}-\\frac{9 \\sqrt{2} \\left(\\frac{171}{52}-\\frac{\\frac{27}{26 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{13 \\left(\\frac{6057}{1352}+\\left(-\\frac{27}{26 \\sqrt{2}}+\\sqrt{2}\\right)^2\\right)}}{\\sqrt{\\left(\\frac{17 \\sqrt{2}}{13}-\\frac{69 \\left(\\frac{171}{52}-\\frac{\\frac{27}{26 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{26 \\sqrt{2} \\left(\\frac{6057}{1352}+\\left(-\\frac{27}{26 \\sqrt{2}}+\\sqrt{2}\\right)^2\\right)}\\right)^2+\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{13}+\\frac{9 \\sqrt{2} \\left(\\frac{171}{52}-\\frac{\\frac{27}{26 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{13 \\left(\\frac{6057}{1352}+\\left(-\\frac{27}{26 \\sqrt{2}}+\\sqrt{2}\\right)^2\\right)}\\right)^2+\\left(\\frac{\\sqrt{2}}{13}+\\frac{\\left(-\\frac{27}{26 \\sqrt{2}}+\\sqrt{2}\\right) \\left(\\frac{171}{52}-\\frac{\\frac{27}{26 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{\\frac{6057}{1352}+\\left(-\\frac{27}{26 \\sqrt{2}}+\\sqrt{2}\\right)^2}\\right)^2}},\\frac{-\\frac{17 \\sqrt{2}}{13}+\\frac{69 \\left(\\frac{171}{52}-\\frac{\\frac{27}{26 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{26 \\sqrt{2} \\left(\\frac{6057}{1352}+\\left(-\\frac{27}{26 \\sqrt{2}}+\\sqrt{2}\\right)^2\\right)}}{\\sqrt{\\left(\\frac{17 \\sqrt{2}}{13}-\\frac{69 \\left(\\frac{171}{52}-\\frac{\\frac{27}{26 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{26 \\sqrt{2} \\left(\\frac{6057}{1352}+\\left(-\\frac{27}{26 \\sqrt{2}}+\\sqrt{2}\\right)^2\\right)}\\right)^2+\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{13}+\\frac{9 \\sqrt{2} \\left(\\frac{171}{52}-\\frac{\\frac{27}{26 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{13 \\left(\\frac{6057}{1352}+\\left(-\\frac{27}{26 \\sqrt{2}}+\\sqrt{2}\\right)^2\\right)}\\right)^2+\\left(\\frac{\\sqrt{2}}{13}+\\frac{\\left(-\\frac{27}{26 \\sqrt{2}}+\\sqrt{2}\\right) \\left(\\frac{171}{52}-\\frac{\\frac{27}{26 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{\\frac{6057}{1352}+\\left(-\\frac{27}{26 \\sqrt{2}}+\\sqrt{2}\\right)^2}\\right)^2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-(3/(math.sqrt(2))), -2*math.sqrt(2), -(1/(math.sqrt(2)))), (-math.sqrt(2), 0, -(3/(math.sqrt(2)))), (-(1/(math.sqrt(2))), -(1/(math.sqrt(2))), -(3/(math.sqrt(2))))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -2 & -1 & -3 & -3 & 2 \\\\\n 2 & -2 & 1 & 2 & 3 \\\\\n -1 & 1 & 3 & 1 & -1 \\\\\n -3 & 2 & 2 & 1 & 1 \\\\\n -2 & -2 & 0 & 3 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -2 \\\\\n 2 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -6 \\\\\n 11 \\\\\n 6 \\\\\n 6 \\\\\n 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1, -3, -3, 2],\n [2, -2, 1, 2, 3],\n [-1, 1, 3, 1, -1],\n [-3, 2, 2, 1, 1],\n [-2, -2, 0, 3, 0]])\nb = np.array([\n [-1],\n [-2],\n [2],\n [2],\n [1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,3,1\\}, \\{2,-2,0\\}, \\{2,-1,1\\}}$", - "Output Answer": [ - "${\\left\\{0,\\frac{3}{\\sqrt{10}},\\frac{1}{\\sqrt{10}}\\right\\}, \\left\\{\\sqrt{\\frac{10}{11}},-\\frac{1}{\\sqrt{110}},\\frac{3}{\\sqrt{110}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{11}},-\\frac{1}{\\sqrt{11}},\\frac{3}{\\sqrt{11}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, 3, 1), (2, -2, 0), (2, -1, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{9}{2}, 4}$ to the line $y-\\frac{x}{2}=0$.", - "Output Answer": [ - "$\\frac{5 \\sqrt{5}}{2}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(9/2), 4\nline = Poly(y-(x/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{6} \\\\\n \\frac{22}{3} \\\\\n -\\frac{17}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{\\frac{5}{2}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/6)],\n [(22/3)],\n [-(17/6)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 0 & -5 \\\\\n 3 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{4}{15} & \\frac{1}{3} \\\\\n -\\frac{1}{5} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -5],\n [3, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 9 & -1 & -2 & 1 & -5 & 3 & -8 \\\\\n -5 & 4 & -1 & 1 & -8 & 1 & 0 \\\\\n -6 & 1 & 8 & 8 & 9 & 4 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & \\frac{37}{71} & -\\frac{44}{71} & \\frac{47}{71} & -\\frac{58}{71} \\\\\n 0 & 1 & 0 & \\frac{86}{71} & -\\frac{539}{213} & \\frac{274}{213} & -\\frac{178}{213} \\\\\n 0 & 0 & 1 & \\frac{88}{71} & \\frac{208}{213} & \\frac{178}{213} & \\frac{158}{213} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, -1, -2, 1, -5, 3, -8],\n [-5, 4, -1, 1, -8, 1, 0],\n [-6, 1, 8, 8, 9, 4, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & 4 & 0 \\\\\n 0 & 0 & -3 \\\\\n 1 & 3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{3}{2} & \\frac{2}{3} & -2 \\\\\n -\\frac{1}{2} & -\\frac{1}{3} & 1 \\\\\n 0 & -\\frac{1}{3} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 4, 0],\n [0, 0, -3],\n [1, 3, -1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n \\frac{8}{3} \\\\\n -2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{1}{3} \\\\\n -\\frac{7}{3} \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{83}{177},\\frac{581}{177},-\\frac{83}{59}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [(8/3)],\n [-2]]).squeeze()\nb = np.array([\n [(1/3)],\n [-(7/3)],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & 5 & -10 \\\\\n -9 & -6 & 2 \\\\\n 4 & 0 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-1.321,2.66\\, -6.996 i,2.66\\, +6.996 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 5, -10],\n [-9, -6, 2],\n [4, 0, 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{11}{6} & \\frac{14}{3} & \\frac{11}{3} \\\\\n 1 & 2 & -\\frac{13}{6} \\\\\n -\\frac{2}{3} & \\frac{13}{6} & \\frac{17}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1825}{72}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/6), (14/3), (11/3)],\n [1, 2, -(13/6)],\n [-(2/3), (13/6), (17/6)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1.7 \\\\\n 6.6 \\\\\n -8.5 \\\\\n 8.4 \\\\\n 4.5 \\\\\n 8.8 \\\\\n -0.1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -0.7 \\\\\n 6.9 \\\\\n 5.5 \\\\\n 6.4 \\\\\n 0.3 \\\\\n 3.9 \\\\\n -9.1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$18.1246$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1.7],\n [6.6],\n [-8.5],\n [8.4],\n [4.5],\n [8.8],\n [-0.1]])\nb = np.array([\n [-0.7],\n [6.9],\n [5.5],\n [6.4],\n [0.3],\n [3.9],\n [-9.1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-3$ and the matrix\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -6 \\\\\n 6 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -30 \\\\\n 18 \\\\\n -18 \\\\\n 24 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-6],\n [6],\n [-8]])\nprint(a * -3)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 5 & -9 & -4 & -4 \\\\\n 7 & -7 & -1 & 7 \\\\\n -9 & 10 & -5 & -2 \\\\\n -6 & -1 & 5 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -10 & -6 & -7 & 4 \\\\\n 8 & 1 & -4 & -3 \\\\\n 6 & 3 & -6 & 6 \\\\\n 0 & 6 & 1 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -5 & -15 & -11 & 0 \\\\\n 15 & -6 & -5 & 4 \\\\\n -3 & 13 & -11 & 4 \\\\\n -6 & 5 & 6 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -9, -4, -4],\n [7, -7, -1, 7],\n [-9, 10, -5, -2],\n [-6, -1, 5, -3]])\nb = np.array([\n [-10, -6, -7, 4],\n [8, 1, -4, -3],\n [6, 3, -6, 6],\n [0, 6, 1, -1]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 10 & 0 & 1 & -7 \\\\\n 8 & -8 & -4 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.,-6.,10.,0.\\}, \\{28.,43.,0.,40.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [10, 0, 1, -7],\n [8, -8, -4, 3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{2}{\\pi } \\\\\n \\frac{23}{\\pi } \\\\\n \\frac{10}{\\pi } \\\\\n \\frac{8}{\\pi } \\\\\n -\\frac{21}{\\pi } \\\\\n -\\frac{1}{\\pi } \\\\\n \\frac{2}{\\pi } \\\\\n \\frac{9}{\\pi } \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{\\pi } \\\\\n -\\frac{28}{\\pi } \\\\\n \\frac{14}{\\pi } \\\\\n \\frac{7}{\\pi } \\\\\n -\\frac{25}{\\pi } \\\\\n -\\frac{2}{\\pi } \\\\\n -\\frac{13}{\\pi } \\\\\n \\frac{10}{\\pi } \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{133}{\\pi ^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(2/math.pi)],\n [(23/math.pi)],\n [(10/math.pi)],\n [(8/math.pi)],\n [-(21/math.pi)],\n [-(1/math.pi)],\n [(2/math.pi)],\n [(9/math.pi)]])\nb = np.array([\n [-(5/math.pi)],\n [-(28/math.pi)],\n [(14/math.pi)],\n [(7/math.pi)],\n [-(25/math.pi)],\n [-(2/math.pi)],\n [-(13/math.pi)],\n [(10/math.pi)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n 1 \\\\\n \\frac{3}{2} \\\\\n \\frac{3}{2} \\\\\n 0 \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{4 \\sqrt{2}} \\\\\n \\frac{1}{2 \\sqrt{2}} \\\\\n \\frac{3}{4 \\sqrt{2}} \\\\\n \\frac{3}{4 \\sqrt{2}} \\\\\n 0 \\\\\n -\\frac{1}{4 \\sqrt{2}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2)],\n [1],\n [(3/2)],\n [(3/2)],\n [0],\n [-(1/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{25}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -1 \\\\\n -9 & 4 \\\\\n 9 & -1 \\\\\n -3 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{6}{25} & \\frac{3}{25} \\\\\n \\frac{27}{25} & -\\frac{12}{25} \\\\\n -\\frac{27}{25} & \\frac{3}{25} \\\\\n \\frac{9}{25} & \\frac{21}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1],\n [-9, 4],\n [9, -1],\n [-3, -7]])\nprint(a * -(3/25))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{887}{100} \\\\\n -\\frac{693}{100} \\\\\n -\\frac{301}{50} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{21}{50} \\\\\n \\frac{13}{10} \\\\\n -\\frac{14}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{2723}{100} \\\\\n -\\frac{68411}{2500} \\\\\n -\\frac{21551}{2500} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(887/100)],\n [-(693/100)],\n [-(301/50)]])\nb = np.array([\n [(21/50)],\n [(13/10)],\n [-(14/5)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{7}{3} & \\frac{25}{3} & -\\frac{29}{3} & \\frac{1}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{47}{6} & \\frac{17}{6} & \\frac{1}{2} & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{11}{2} & \\frac{11}{2} & -\\frac{61}{6} & \\frac{23}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/3), (25/3), -(29/3), (1/3)]])\nb = np.array([\n [-(47/6), (17/6), (1/2), -(7/2)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-1,-\\frac{2}{3},\\frac{11}{3}\\right\\}, \\left\\{-\\frac{5}{3},1,\\frac{13}{3}\\right\\}, \\left\\{-4,1,-\\frac{2}{3}\\right\\}}$.", - "Output Answer": [ - "$225 x+132 y-105 z+698=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, -(2/3), (11/3)],\n [-(5/3), 1, (13/3)],\n [-4, 1, -(2/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3.004 \\\\\n -8.979 \\\\\n 5.942 \\\\\n -5.737 \\\\\n 0.089 \\\\\n -2.52 \\\\\n -5.524 \\\\\n 8.307 \\\\\n 2.261 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1.418 \\\\\n 1.49 \\\\\n 9.031 \\\\\n 8.209 \\\\\n -3.274 \\\\\n -8.092 \\\\\n 7.763 \\\\\n -3.219 \\\\\n -9.649 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$28.7539$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3.004],\n [-8.979],\n [5.942],\n [-5.737],\n [0.089],\n [-2.52],\n [-5.524],\n [8.307],\n [2.261]])\nb = np.array([\n [1.418],\n [1.49],\n [9.031],\n [8.209],\n [-3.274],\n [-8.092],\n [7.763],\n [-3.219],\n [-9.649]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -8 & \\frac{15}{2} & \\frac{9}{2} & -7 \\\\\n 7 & -9 & \\frac{7}{2} & -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 7 & 0 & -1 & \\frac{7}{2} \\\\\n 4 & 0 & -5 & \\frac{17}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -1 & \\frac{15}{2} & \\frac{7}{2} & -\\frac{7}{2} \\\\\n 11 & -9 & -\\frac{3}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, (15/2), (9/2), -7],\n [7, -9, (7/2), -9]])\nb = np.array([\n [7, 0, -1, (7/2)],\n [4, 0, -5, (17/2)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{9}{2} & \\frac{5}{2} & 5 \\\\\n -4 & \\frac{5}{2} & -\\frac{5}{2} \\\\\n -\\frac{3}{2} & \\frac{3}{2} & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{13} & -\\frac{10}{13} & \\frac{15}{13} \\\\\n \\frac{17}{65} & -\\frac{66}{65} & \\frac{25}{13} \\\\\n \\frac{9}{65} & -\\frac{12}{65} & \\frac{1}{13} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2), (5/2), 5],\n [-4, (5/2), -(5/2)],\n [-(3/2), (3/2), -2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -2 & 3 \\\\\n -1 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 1 & 3 \\\\\n 9 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -1 & 6 \\\\\n 8 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 3],\n [-1, -3]])\nb = np.array([\n [1, 3],\n [9, -1]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -3 & -3 & 0 & -10 \\\\\n -6 & 4 & 10 & -1 \\\\\n 5 & -5 & 6 & -2 \\\\\n -5 & 0 & 4 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, -3, 0, -10],\n [-6, 4, 10, -1],\n [5, -5, 6, -2],\n [-5, 0, 4, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,-1,2\\}, \\{-2,-2,2\\}, \\{2,-3,1\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{2}{3},-\\frac{1}{3},\\frac{2}{3}\\right\\}, \\left\\{-\\frac{11}{3 \\sqrt{26}},-\\frac{4 \\sqrt{\\frac{2}{13}}}{3},\\frac{7}{3 \\sqrt{26}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{26}},-2 \\sqrt{\\frac{2}{13}},-\\frac{3}{\\sqrt{26}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, -1, 2), (-2, -2, 2), (2, -3, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{5} \\\\\n \\frac{36}{5} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{5} \\\\\n \\frac{29}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{26}{5} \\\\\n \\frac{7}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/5)],\n [(36/5)]])\nb = np.array([\n [-(29/5)],\n [(29/5)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{43}{6} \\\\\n 3 \\\\\n -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -\\frac{19}{3} \\\\\n -\\frac{10}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{356}{9} \\\\\n \\frac{299}{9} \\\\\n -\\frac{709}{18} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(43/6)],\n [3],\n [-(14/3)]])\nb = np.array([\n [-2],\n [-(19/3)],\n [-(10/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{32}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 4 & 3 & 8 & -8 \\\\\n -8 & 6 & -10 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{3}{8} & -\\frac{9}{32} & -\\frac{3}{4} & \\frac{3}{4} \\\\\n \\frac{3}{4} & -\\frac{9}{16} & \\frac{15}{16} & -\\frac{27}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 3, 8, -8],\n [-8, 6, -10, 9]])\nprint(a * -(3/32))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{3,-3,1\\}, \\{-1,-1,3\\}, \\{0,-1,1\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{3}{\\sqrt{19}},-\\frac{3}{\\sqrt{19}},\\frac{1}{\\sqrt{19}}\\right\\}, \\left\\{-\\frac{7 \\sqrt{\\frac{2}{19}}}{5},-\\frac{1}{\\sqrt{38}},\\frac{27}{5 \\sqrt{38}}\\right\\}, \\left\\{-\\frac{2 \\sqrt{2}}{5},-\\frac{1}{\\sqrt{2}},-\\frac{3}{5 \\sqrt{2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((3, -3, 1), (-1, -1, 3), (0, -1, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n 6 & -\\frac{17}{7} & \\frac{2}{7} & -\\frac{69}{7} \\\\\n -\\frac{25}{7} & \\frac{46}{7} & -\\frac{61}{7} & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -(17/7), (2/7), -(69/7)],\n [-(25/7), (46/7), -(61/7), -1]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 3 & -1 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -1 & -3 & -2 & -3 & -3 \\\\\n -1 & -2 & -3 & 0 & 2 \\\\\n 2 & -1 & 2 & 3 & 2 \\\\\n 0 & 1 & 2 & -2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -4 & -4 & -1 & -16 & -13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, -1, 2]])\nb = np.array([\n [-1, -3, -2, -3, -3],\n [-1, -2, -3, 0, 2],\n [2, -1, 2, 3, 2],\n [0, 1, 2, -2, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -4 \\\\\n 3 \\\\\n 4 \\\\\n 8 \\\\\n 8 \\\\\n 9 \\\\\n -6 \\\\\n -3 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -1 \\\\\n -3 \\\\\n -5 \\\\\n -10 \\\\\n -6 \\\\\n -6 \\\\\n 7 \\\\\n -1 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{1094}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-4],\n [3],\n [4],\n [8],\n [8],\n [9],\n [-6],\n [-3],\n [8]])\nb = np.array([\n [2],\n [-1],\n [-3],\n [-5],\n [-10],\n [-6],\n [-6],\n [7],\n [-1],\n [9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 5 & 1 & 9 \\\\\n 8 & 8 & 3 \\\\\n -4 & 6 & -9 \\\\\n 2 & -4 & 6 \\\\\n 4 & -1 & 9 \\\\\n 5 & 1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, 1, 9],\n [8, 8, 3],\n [-4, 6, -9],\n [2, -4, 6],\n [4, -1, 9],\n [5, 1, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{\\sqrt{3}} \\\\\n 3 \\sqrt{3} \\\\\n -\\frac{7}{\\sqrt{3}} \\\\\n \\frac{5}{\\sqrt{3}} \\\\\n \\frac{16}{\\sqrt{3}} \\\\\n -2 \\sqrt{3} \\\\\n -\\frac{16}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{13}{\\sqrt{3}} \\\\\n -5 \\sqrt{3} \\\\\n \\frac{11}{\\sqrt{3}} \\\\\n -\\frac{10}{\\sqrt{3}} \\\\\n -2 \\sqrt{3} \\\\\n -\\frac{16}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{175}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(13/(math.sqrt(3)))],\n [3*math.sqrt(3)],\n [-(7/(math.sqrt(3)))],\n [(5/(math.sqrt(3)))],\n [(16/(math.sqrt(3)))],\n [-2*math.sqrt(3)],\n [-(16/(math.sqrt(3)))]])\nb = np.array([\n [0],\n [-(13/(math.sqrt(3)))],\n [-5*math.sqrt(3)],\n [(11/(math.sqrt(3)))],\n [-(10/(math.sqrt(3)))],\n [-2*math.sqrt(3)],\n [-(16/(math.sqrt(3)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{5} & -\\frac{44}{5} & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/5), -(44/5), 10]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{63}{8} \\\\\n -\\frac{65}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{65}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(63/8)],\n [-(65/8)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -7 \\\\\n -10 \\\\\n -9 \\\\\n -9 \\\\\n 9 \\\\\n -4 \\\\\n -1 \\\\\n 6 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 8 \\\\\n -5 \\\\\n 4 \\\\\n 5 \\\\\n 1 \\\\\n -1 \\\\\n 10 \\\\\n 8 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{830}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-7],\n [-10],\n [-9],\n [-9],\n [9],\n [-4],\n [-1],\n [6],\n [3]])\nb = np.array([\n [-3],\n [8],\n [-5],\n [4],\n [5],\n [1],\n [-1],\n [10],\n [8],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1.994 \\\\\n 4.127 \\\\\n -6.195 \\\\\n -9.466 \\\\\n 9.468 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3.626 \\\\\n 2.647 \\\\\n 8.956 \\\\\n -1.753 \\\\\n 8.984 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$17.9737$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1.994],\n [4.127],\n [-6.195],\n [-9.466],\n [9.468]])\nb = np.array([\n [-3.626],\n [2.647],\n [8.956],\n [-1.753],\n [8.984]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{3} \\\\\n 2 \\\\\n -\\frac{8}{3} \\\\\n \\frac{13}{3} \\\\\n \\frac{2}{3} \\\\\n -10 \\\\\n \\frac{10}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -\\frac{1}{3} \\\\\n \\frac{14}{3} \\\\\n 6 \\\\\n \\frac{19}{3} \\\\\n -\\frac{20}{3} \\\\\n -\\frac{16}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{2 \\sqrt{478}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/3)],\n [2],\n [-(8/3)],\n [(13/3)],\n [(2/3)],\n [-10],\n [(10/3)]])\nb = np.array([\n [-6],\n [-(1/3)],\n [(14/3)],\n [6],\n [(19/3)],\n [-(20/3)],\n [-(16/3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{23}{8} & \\frac{31}{8} \\\\\n \\frac{33}{8} & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & \\frac{8}{33} \\\\\n \\frac{8}{31} & -\\frac{184}{1023} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/8), (31/8)],\n [(33/8), 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n 3 & 8 & 7 & -6 & -6 \\\\\n 3 & 8 & 8 & 2 & 2 \\\\\n -2 & -7 & 5 & 1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 8, 7, -6, -6],\n [3, 8, 8, 2, 2],\n [-2, -7, 5, 1, -3]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{4,5,5\\}, \\{-3,1,-4\\}, \\{2,-2,-1\\}}$.", - "Output Answer": [ - "$39 x+24 y-41 z-71=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, 5, 5],\n [-3, 1, -4],\n [2, -2, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{68}{7} \\\\\n \\frac{13}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{68}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(68/7)],\n [(13/7)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{22}{5}, -\\frac{7}{10}}$ to the line $-\\frac{3 x}{5}-\\frac{33 y}{10}+\\frac{3}{5}=0$.", - "Output Answer": [ - "$\\frac{37}{10 \\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(22/5), -(7/10)\nline = Poly(-((3*x)/5)-((33*y)/10)+(3/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-1,2,2\\}, \\{-1,-3,0\\}, \\{-2,0,0\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{3},\\frac{2}{3},\\frac{2}{3}\\right\\}, \\left\\{-\\frac{14}{3 \\sqrt{65}},-\\frac{17}{3 \\sqrt{65}},\\frac{2 \\sqrt{\\frac{5}{13}}}{3}\\right\\}, \\left\\{-\\frac{6}{\\sqrt{65}},\\frac{2}{\\sqrt{65}},-\\sqrt{\\frac{5}{13}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, 2, 2), (-1, -3, 0), (-2, 0, 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n -\\frac{1}{4} \\\\\n -\\frac{11}{4} \\\\\n -\\frac{5}{4} \\\\\n \\frac{1}{4} \\\\\n \\frac{37}{4} \\\\\n \\frac{27}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{37}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2)],\n [-(1/4)],\n [-(11/4)],\n [-(5/4)],\n [(1/4)],\n [(37/4)],\n [(27/4)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -8 & -7 & -3 & 2 \\\\\n -6 & 1 & -9 & 2 \\\\\n -9 & -7 & 9 & -4 \\\\\n -2 & 4 & -6 & -3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 4 & 5 & 3 & -6 \\\\\n -7 & 2 & 3 & -9 \\\\\n -4 & 5 & 6 & -2 \\\\\n -9 & -6 & 6 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -12 & -12 & -6 & 8 \\\\\n 1 & -1 & -12 & 11 \\\\\n -5 & -12 & 3 & -2 \\\\\n 7 & 10 & -12 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -7, -3, 2],\n [-6, 1, -9, 2],\n [-9, -7, 9, -4],\n [-2, 4, -6, -3]])\nb = np.array([\n [4, 5, 3, -6],\n [-7, 2, 3, -9],\n [-4, 5, 6, -2],\n [-9, -6, 6, -9]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 e \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -e \\\\\n -2 e \\\\\n -2 e \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{3} e$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-3*math.e],\n [0],\n [0],\n [0]])\nb = np.array([\n [-math.e],\n [-2*math.e],\n [-2*math.e],\n [0]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 0 & 2 \\\\\n 0 & -2 & -1 \\\\\n -2 & -2 & -2 \\\\\n -3 & -2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.46 \\\\\n -1.49 \\\\\n 0.51 \\\\\n 2.94 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2.814 \\\\\n -1.325 \\\\\n 4.012 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, 2],\n [0, -2, -1],\n [-2, -2, -2],\n [-3, -2, -2]])\nb = np.array([\n [2.46],\n [-1.49],\n [0.51],\n [2.94]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & -2 \\\\\n 3 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{6} i \\left(\\sqrt{15}-3 i\\right),1\\right\\}, \\left\\{-\\frac{1}{6} i \\left(\\sqrt{15}+3 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -2],\n [3, 6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n \\frac{66}{7} & -\\frac{5}{7} \\\\\n -\\frac{2}{7} & -\\frac{30}{7} \\\\\n -\\frac{1}{7} & -\\frac{44}{7} \\\\\n -\\frac{23}{7} & 7 \\\\\n -\\frac{2}{7} & -\\frac{23}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(66/7), -(5/7)],\n [-(2/7), -(30/7)],\n [-(1/7), -(44/7)],\n [-(23/7), 7],\n [-(2/7), -(23/7)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5.1 \\\\\n 7.2 \\\\\n -2. \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1.2 \\\\\n 0.9 \\\\\n -0.4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$13.4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5.1],\n [7.2],\n [-2.]])\nb = np.array([\n [1.2],\n [0.9],\n [-0.4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 1 & 5 & 0 \\\\\n -1 & -3 & -7 \\\\\n 0 & 0 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-8 x^2-14 x-12$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 5, 0],\n [-1, -3, -7],\n [0, 0, -6]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 2 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{74}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [2],\n [10]])\nb = np.array([\n [7],\n [-1],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 3 & -2 & -3 & 2 & -1 \\\\\n 3 & -2 & -1 & -1 & -3 \\\\\n -2 & -3 & 3 & 3 & 2 \\\\\n 0 & 0 & 3 & 1 & -1 \\\\\n 0 & 3 & -2 & -2 & 2 \\\\\n 2 & 2 & -2 & 2 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.28 \\\\\n -2.79 \\\\\n 0.89 \\\\\n -0.02 \\\\\n 0.76 \\\\\n -1.8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.632 \\\\\n 0.084 \\\\\n 0.023 \\\\\n -0.117 \\\\\n 0.186 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2, -3, 2, -1],\n [3, -2, -1, -1, -3],\n [-2, -3, 3, 3, 2],\n [0, 0, 3, 1, -1],\n [0, 3, -2, -2, 2],\n [2, 2, -2, 2, -1]])\nb = np.array([\n [-2.28],\n [-2.79],\n [0.89],\n [-0.02],\n [0.76],\n [-1.8]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{10}{3} & -10 & -\\frac{19}{3} \\\\\n \\frac{8}{3} & -6 & -7 \\\\\n -\\frac{22}{3} & -\\frac{4}{3} & -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-12.189,2.428\\, -4.076 i,2.428\\, +4.076 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(10/3), -10, -(19/3)],\n [(8/3), -6, -7],\n [-(22/3), -(4/3), -(14/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 1 & 6 & -5 & -5 & 6 \\\\\n -9 & 0 & -5 & -4 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & \\frac{5}{9} & \\frac{4}{9} & \\frac{1}{9} \\\\\n 0 & 1 & -\\frac{25}{27} & -\\frac{49}{54} & \\frac{53}{54} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, 6, -5, -5, 6],\n [-9, 0, -5, -4, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{e} \\\\\n -\\frac{13}{e} \\\\\n \\frac{9}{e} \\\\\n \\frac{18}{e} \\\\\n \\frac{15}{e} \\\\\n -\\frac{7}{e} \\\\\n -\\frac{18}{e} \\\\\n \\frac{18}{e} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{21}{e} \\\\\n -\\frac{5}{e} \\\\\n -\\frac{16}{e} \\\\\n \\frac{5}{e} \\\\\n \\frac{20}{e} \\\\\n -\\frac{24}{e} \\\\\n \\frac{25}{e} \\\\\n \\frac{2}{e} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{3953}}{e}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(5/math.e)],\n [-(13/math.e)],\n [(9/math.e)],\n [(18/math.e)],\n [(15/math.e)],\n [-(7/math.e)],\n [-(18/math.e)],\n [(18/math.e)]])\nb = np.array([\n [-(21/math.e)],\n [-(5/math.e)],\n [-(16/math.e)],\n [(5/math.e)],\n [(20/math.e)],\n [-(24/math.e)],\n [(25/math.e)],\n [(2/math.e)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & 0 & -8 \\\\\n -2 & 2 & 2 \\\\\n -1 & 3 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{2.588\\, -1.448 i,2.588\\, +1.448 i,11.824\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 0, -8],\n [-2, 2, 2],\n [-1, 3, 9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 3-i & -3 & -1 \\\\\n 2+3 i & -5-3 i & 1+2 i \\\\\n 2 i & 4+4 i & -5 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 2-17 i & 2+8 i & -1-5 i \\\\\n 4-12 i & 6+33 i & -6-26 i \\\\\n -2+16 i & -28-58 i & 21+10 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3- 1j, -3, -1],\n [2+3j, -5-3j, 1+2j],\n [2j, 4+4j, -5]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\pi \\\\\n 0 \\\\\n -3 \\pi \\\\\n 3 \\pi \\\\\n -\\pi \\\\\n -\\pi \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\pi \\\\\n -2 \\pi \\\\\n 0 \\\\\n 0 \\\\\n -2 \\pi \\\\\n -3 \\pi \\\\\n 2 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$11 \\pi ^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [2*math.pi],\n [0],\n [-3*math.pi],\n [3*math.pi],\n [-math.pi],\n [-math.pi],\n [0]])\nb = np.array([\n [3*math.pi],\n [-2*math.pi],\n [0],\n [0],\n [-2*math.pi],\n [-3*math.pi],\n [2*math.pi]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, 0, 1}$ to the plane $-x+5 y-3 z=0$.", - "Output Answer": [ - "$\\frac{6}{\\sqrt{35}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, 0, 1\nplane = Poly(-x+5*y-3*z, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{27}{4} & \\frac{49}{8} & -\\frac{77}{8} \\\\\n \\frac{39}{8} & \\frac{59}{8} & -\\frac{31}{4} \\\\\n 8 & \\frac{13}{4} & \\frac{47}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{13 x^2}{2}-\\frac{839 x}{32}-\\frac{308365}{512}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(27/4), (49/8), -(77/8)],\n [(39/8), (59/8), -(31/4)],\n [8, (13/4), (47/8)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & 0 & 3 \\\\\n 1 & -3 & 0 \\\\\n -2 & -3 & -2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -6 & -9 & -6 \\\\\n -3 & 9 & 3 \\\\\n 1 & 15 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0, 3],\n [1, -3, 0],\n [-2, -3, -2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 2 \\\\\n 10 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [2],\n [10],\n [4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -9 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -36 \\\\\n 31 \\\\\n 51 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-9],\n [9]])\nb = np.array([\n [4],\n [3],\n [1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{25}{3} & -\\frac{16}{3} & -\\frac{49}{6} \\\\\n \\frac{17}{2} & -\\frac{31}{6} & -\\frac{1}{2} \\\\\n -\\frac{17}{6} & \\frac{29}{6} & -\\frac{7}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+2 x^2+\\frac{797 x}{36}-\\frac{5563}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(25/3), -(16/3), -(49/6)],\n [(17/2), -(31/6), -(1/2)],\n [-(17/6), (29/6), -(7/6)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n e \\\\\n -e \\\\\n -3 e \\\\\n -e \\\\\n -2 e \\\\\n 3 e \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 2 e \\\\\n 3 e \\\\\n 0 \\\\\n 0 \\\\\n 3 e \\\\\n -3 e \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-2 e^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.e],\n [-math.e],\n [-3*math.e],\n [-math.e],\n [-2*math.e],\n [3*math.e],\n [0],\n [0]])\nb = np.array([\n [0],\n [2*math.e],\n [3*math.e],\n [0],\n [0],\n [3*math.e],\n [-3*math.e],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n \\frac{5}{3} & -2 & -\\frac{4}{3} & \\frac{5}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{1}{3} & -1 & 0 & -\\frac{5}{3} \\\\\n \\frac{5}{3} & \\frac{8}{3} & -\\frac{1}{3} & \\frac{7}{3} \\\\\n \\frac{1}{3} & -2 & -\\frac{8}{3} & \\frac{5}{3} \\\\\n \\frac{8}{3} & 0 & -1 & \\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{11}{9} & -\\frac{13}{3} & \\frac{23}{9} & -\\frac{47}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3), -2, -(4/3), (5/3)]])\nb = np.array([\n [(1/3), -1, 0, -(5/3)],\n [(5/3), (8/3), -(1/3), (7/3)],\n [(1/3), -2, -(8/3), (5/3)],\n [(8/3), 0, -1, (8/3)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{28}{3} & \\frac{25}{3} & \\frac{29}{3} \\\\\n \\frac{1}{3} & -\\frac{4}{3} & -\\frac{29}{3} \\\\\n \\frac{4}{3} & -\\frac{19}{3} & \\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-12.525,-4.655,8.18\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(28/3), (25/3), (29/3)],\n [(1/3), -(4/3), -(29/3)],\n [(4/3), -(19/3), (5/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -2 & -3 & -3 \\\\\n 0 & -1 & -3 \\\\\n 0 & 3 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 1 & -1 & 2 & -2 & 2 \\\\\n -2 & 2 & 0 & 0 & 2 \\\\\n 0 & 2 & 2 & -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 4 & -10 & -10 & 7 & -19 \\\\\n 2 & -8 & -6 & 3 & -11 \\\\\n -6 & 8 & 2 & -1 & 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, -3],\n [0, -1, -3],\n [0, 3, 1]])\nb = np.array([\n [1, -1, 2, -2, 2],\n [-2, 2, 0, 0, 2],\n [0, 2, 2, -1, 3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 9 \\\\\n -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -\\frac{3}{2} \\\\\n -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{219}{4} \\\\\n -2 \\\\\n \\frac{21}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [9],\n [-(7/2)]])\nb = np.array([\n [-1],\n [-(3/2)],\n [-(11/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 3 & -1 & 2 & -2 & 2 \\\\\n -1 & -3 & -2 & -2 & 0 \\\\\n -1 & 2 & 2 & -2 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 0 & -2 \\\\\n 2 & -1 \\\\\n -2 & -1 \\\\\n -1 & 2 \\\\\n -2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -8 & -17 \\\\\n 0 & 3 \\\\\n 2 & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, 2, -2, 2],\n [-1, -3, -2, -2, 0],\n [-1, 2, 2, -2, 0]])\nb = np.array([\n [0, -2],\n [2, -1],\n [-2, -1],\n [-1, 2],\n [-2, -3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${5, 4, 1}$ to the plane $5 x+5 y+3 z+5=0$.", - "Output Answer": [ - "$\\frac{53}{\\sqrt{59}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 5, 4, 1\nplane = Poly(5*x+5*y+3*z+5, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 0 \\\\\n -3 \\\\\n -6 \\\\\n 7 \\\\\n 9 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 \\\\\n 0 \\\\\n 5 \\\\\n -2 \\\\\n -9 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-143$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [0],\n [-3],\n [-6],\n [7],\n [9],\n [-3]])\nb = np.array([\n [0],\n [3],\n [0],\n [5],\n [-2],\n [-9],\n [6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & -2 & -2 \\\\\n -1 & 0 & 2 \\\\\n 1 & 1 & 0 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & -2 \\\\\n 3 & 4 & 2 \\\\\n -2 & -2 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, -2],\n [-1, 0, 2],\n [1, 1, 0]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,-2,-2\\}, \\{-2,3,2\\}, \\{-2,1,-1\\}}$", - "Output Answer": [ - "${\\left\\{0,-\\frac{1}{\\sqrt{2}},-\\frac{1}{\\sqrt{2}}\\right\\}, \\left\\{-\\frac{2 \\sqrt{2}}{3},\\frac{1}{3 \\sqrt{2}},-\\frac{1}{3 \\sqrt{2}}\\right\\}, \\left\\{\\frac{1}{3},\\frac{2}{3},-\\frac{2}{3}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, -2, -2), (-2, 3, 2), (-2, 1, -1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & 2 & 2 & 2 \\\\\n 1 & -1 & -2 & 3 \\\\\n 3 & 2 & 1 & 0 \\\\\n 0 & 2 & 3 & -2 \\\\\n 3 & 2 & 1 & -2 \\\\\n -2 & 1 & -1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.02 \\\\\n 2.52 \\\\\n 1.15 \\\\\n 1.58 \\\\\n 0. \\\\\n 0.73 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.301 \\\\\n 0.005 \\\\\n 0.162 \\\\\n 0.382 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, 2, 2],\n [1, -1, -2, 3],\n [3, 2, 1, 0],\n [0, 2, 3, -2],\n [3, 2, 1, -2],\n [-2, 1, -1, 3]])\nb = np.array([\n [0.02],\n [2.52],\n [1.15],\n [1.58],\n [0.],\n [0.73]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{13}{3},-\\frac{5}{3},-\\frac{7}{3}\\right\\}, \\{-4,3,0\\}, \\left\\{-4,-\\frac{1}{3},\\frac{13}{3}\\right\\}}$.", - "Output Answer": [ - "$252 x+325 y+250 z+33=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(13/3), -(5/3), -(7/3)],\n [-4, 3, 0],\n [-4, -(1/3), (13/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & -7 & 2 \\\\\n 10 & 3 & 3 \\\\\n -6 & 10 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-1.819-8.137 i,-1.819+8.137 i,5.639\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -7, 2],\n [10, 3, 3],\n [-6, 10, 0]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & \\frac{29}{7} & 1 \\\\\n \\frac{9}{7} & -\\frac{11}{7} & -\\frac{8}{7} \\\\\n \\frac{16}{7} & \\frac{12}{7} & \\frac{17}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{637}{7435} & \\frac{2863}{7435} & \\frac{217}{1487} \\\\\n \\frac{1967}{7435} & -\\frac{882}{7435} & -\\frac{245}{1487} \\\\\n -\\frac{1988}{7435} & -\\frac{2072}{7435} & \\frac{581}{1487} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, (29/7), 1],\n [(9/7), -(11/7), -(8/7)],\n [(16/7), (12/7), (17/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{21}{\\pi } \\\\\n -\\frac{4}{\\pi } \\\\\n \\frac{19}{\\pi } \\\\\n -\\frac{11}{\\pi } \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{22}{\\pi } \\\\\n \\frac{7}{\\pi } \\\\\n \\frac{8}{\\pi } \\\\\n -\\frac{10}{\\pi } \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{228}{\\pi ^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(21/math.pi)],\n [-(4/math.pi)],\n [(19/math.pi)],\n [-(11/math.pi)]])\nb = np.array([\n [(22/math.pi)],\n [(7/math.pi)],\n [(8/math.pi)],\n [-(10/math.pi)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{13}{3},\\frac{5}{3},-3\\right\\}, \\left\\{\\frac{8}{3},\\frac{8}{3},-\\frac{4}{3}\\right\\}, \\left\\{2,-\\frac{5}{3},-5\\right\\}}$.", - "Output Answer": [ - "$96 x+663 y-801 z-3092=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(13/3), (5/3), -3],\n [(8/3), (8/3), -(4/3)],\n [2, -(5/3), -5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -7 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -6 \\\\\n -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 40 \\\\\n 70 \\\\\n -58 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-7],\n [-5]])\nb = np.array([\n [-4],\n [-6],\n [-10]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 3 & -1 & -10 \\\\\n 5 & -2 & 3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 9 & -1 & -9 \\\\\n 0 & -2 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -6 & 0 & -1 \\\\\n 5 & 0 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, -10],\n [5, -2, 3]])\nb = np.array([\n [9, -1, -9],\n [0, -2, 0]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -7 & 9 \\\\\n 8 & -8 \\\\\n -7 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, 9],\n [8, -8],\n [-7, -7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 4 & 3 & 4 \\\\\n -2 & -2 & -1 \\\\\n -5 & 1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{7} & \\frac{1}{7} & -\\frac{1}{7} \\\\\n -\\frac{11}{35} & -\\frac{32}{35} & \\frac{4}{35} \\\\\n \\frac{12}{35} & \\frac{19}{35} & \\frac{2}{35} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 3, 4],\n [-2, -2, -1],\n [-5, 1, 3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{18}{5} \\\\\n -\\frac{37}{5} \\\\\n -\\frac{21}{10} \\\\\n \\frac{69}{10} \\\\\n 0 \\\\\n -\\frac{1}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{\\frac{5989}{2}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(18/5)],\n [-(37/5)],\n [-(21/10)],\n [(69/10)],\n [0],\n [-(1/5)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & 2 & -3 \\\\\n -3 & 1 & 3 \\\\\n 3 & 0 & -3 \\\\\n -3 & 0 & -2 \\\\\n -2 & 3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.03 \\\\\n -0.73 \\\\\n 1.01 \\\\\n -1.35 \\\\\n 1.85 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.425 \\\\\n 0.453 \\\\\n 0.233 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, -3],\n [-3, 1, 3],\n [3, 0, -3],\n [-3, 0, -2],\n [-2, 3, 3]])\nb = np.array([\n [-0.03],\n [-0.73],\n [1.01],\n [-1.35],\n [1.85]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{8} & -\\frac{19}{4} \\\\\n -\\frac{3}{2} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{17 x}{8}-\\frac{99}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/8), -(19/4)],\n [-(3/2), -(3/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -9 \\\\\n -2 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 5 \\\\\n 6 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-68$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-9],\n [-2],\n [7]])\nb = np.array([\n [3],\n [5],\n [6],\n [1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & 2 \\\\\n -1 & -2 \\\\\n 2 & 3 \\\\\n -3 & 0 \\\\\n 2 & -1 \\\\\n 0 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.95 \\\\\n -1.48 \\\\\n 2.61 \\\\\n -2.41 \\\\\n 1.89 \\\\\n 0.78 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.761 \\\\\n 0.327 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2],\n [-1, -2],\n [2, 3],\n [-3, 0],\n [2, -1],\n [0, -1]])\nb = np.array([\n [-0.95],\n [-1.48],\n [2.61],\n [-2.41],\n [1.89],\n [0.78]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -6 \\\\\n 2 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{26}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-6],\n [2],\n [8]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & -1 \\\\\n -6 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{6} \\left(5-\\sqrt{31}\\right),1\\right\\}, \\left\\{\\frac{1}{6} \\left(5+\\sqrt{31}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -1],\n [-6, 2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\pi \\\\\n -2 \\pi \\\\\n -2 \\pi \\\\\n 2 \\pi \\\\\n \\pi \\\\\n -3 \\pi \\\\\n -2 \\pi \\\\\n -3 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\pi \\\\\n -2 \\pi \\\\\n -3 \\pi \\\\\n 2 \\pi \\\\\n -2 \\pi \\\\\n -3 \\pi \\\\\n -2 \\pi \\\\\n 3 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{2} \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-math.pi],\n [-2*math.pi],\n [-2*math.pi],\n [2*math.pi],\n [math.pi],\n [-3*math.pi],\n [-2*math.pi],\n [-3*math.pi]])\nb = np.array([\n [math.pi],\n [-2*math.pi],\n [-3*math.pi],\n [2*math.pi],\n [-2*math.pi],\n [-3*math.pi],\n [-2*math.pi],\n [3*math.pi]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -4 & 7 & -8 \\\\\n 9 & -7 & -4 \\\\\n 8 & -2 & 10 \\\\\n 0 & 9 & -4 \\\\\n 0 & 8 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, 7, -8],\n [9, -7, -4],\n [8, -2, 10],\n [0, 9, -4],\n [0, 8, -9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [3],\n [-8]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -2 \\\\\n 0 \\\\\n -2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{\\sqrt{26}} \\\\\n -\\sqrt{\\frac{2}{13}} \\\\\n 0 \\\\\n -\\sqrt{\\frac{2}{13}} \\\\\n \\frac{3}{\\sqrt{26}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-2],\n [0],\n [-2],\n [3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{19}{7}, \\frac{4}{7}}$ to the line $\\frac{15 x}{7}-\\frac{2 y}{7}+\\frac{33}{7}=0$.", - "Output Answer": [ - "$\\frac{62}{7 \\sqrt{229}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(19/7), (4/7)\nline = Poly(((15*x)/7)-((2*y)/7)+(33/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -3 & 3 & 9 \\\\\n 6 & -3 & 2 \\\\\n -5 & 2 & -5 \\\\\n -7 & -5 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -3 & 5 & -3 \\\\\n -9 & 9 & 8 \\\\\n 1 & -4 & -2 \\\\\n -7 & -3 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -6 & 8 & 6 \\\\\n -3 & 6 & 10 \\\\\n -4 & -2 & -7 \\\\\n -14 & -8 & 15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 3, 9],\n [6, -3, 2],\n [-5, 2, -5],\n [-7, -5, 8]])\nb = np.array([\n [-3, 5, -3],\n [-9, 9, 8],\n [1, -4, -2],\n [-7, -3, 7]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [-1],\n [1],\n [1],\n [1]]).squeeze()\nb = np.array([\n [0],\n [1],\n [1],\n [1],\n [1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{3}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{39}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/5)]])\nb = np.array([\n [(3/5)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{15}{7} & \\frac{31}{7} \\\\\n -\\frac{20}{7} & -\\frac{47}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{62 x}{7}+\\frac{1325}{49}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/7), (31/7)],\n [-(20/7), -(47/7)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & 6 \\\\\n 7 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{7} \\left(7-\\sqrt{91}\\right),1\\right\\}, \\left\\{\\frac{1}{7} \\left(7+\\sqrt{91}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 6],\n [7, -10]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{17}{5} & \\frac{9}{5} \\\\\n -\\frac{27}{10} & -\\frac{29}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{29}{50} & \\frac{9}{25} \\\\\n -\\frac{27}{50} & -\\frac{17}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/5), (9/5)],\n [-(27/10), -(29/10)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 0 & -2 & 3 \\\\\n 4 & -2 & 1 \\\\\n -1 & 0 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{2}{9} & \\frac{2}{9} & -\\frac{1}{9} \\\\\n -\\frac{5}{12} & -\\frac{1}{12} & -\\frac{1}{3} \\\\\n \\frac{1}{18} & -\\frac{1}{18} & -\\frac{2}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2, 3],\n [4, -2, 1],\n [-1, 0, -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{31}{7} & \\frac{22}{7} & -\\frac{2}{7} \\\\\n \\frac{34}{7} & 4 & -\\frac{8}{7} \\\\\n -\\frac{34}{7} & -\\frac{25}{7} & \\frac{8}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{14}{45} & -\\frac{49}{30} & -\\frac{14}{9} \\\\\n 0 & \\frac{7}{3} & \\frac{7}{3} \\\\\n \\frac{119}{90} & \\frac{7}{20} & \\frac{14}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(31/7), (22/7), -(2/7)],\n [(34/7), 4, -(8/7)],\n [-(34/7), -(25/7), (8/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,3,-2\\}, \\{0,-2,-1\\}, \\{0,-1,1\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{2}{\\sqrt{17}},\\frac{3}{\\sqrt{17}},-\\frac{2}{\\sqrt{17}}\\right\\}, \\left\\{-\\frac{8}{\\sqrt{1173}},-\\frac{22}{\\sqrt{1173}},-\\frac{25}{\\sqrt{1173}}\\right\\}, \\left\\{-\\frac{7}{\\sqrt{69}},-\\frac{2}{\\sqrt{69}},\\frac{4}{\\sqrt{69}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, 3, -2), (0, -2, -1), (0, -1, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -1 \\\\\n 1 \\\\\n -2 \\\\\n -1 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 1 \\\\\n -3 \\\\\n 6 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{359}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-1],\n [1],\n [-2],\n [-1],\n [8]])\nb = np.array([\n [7],\n [1],\n [-3],\n [6],\n [-2],\n [1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 5 & -4 \\\\\n -5 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{5}{82} & -\\frac{5}{82} \\\\\n -\\frac{2}{41} & \\frac{2}{41} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -4],\n [-5, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -1 & 8 & -5 \\\\\n 5 & -8 & -4 \\\\\n 7 & 1 & -4 \\\\\n -1 & 3 & -2 \\\\\n -5 & 3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 8, -5],\n [5, -8, -4],\n [7, 1, -4],\n [-1, 3, -2],\n [-5, 3, 2]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -1 & 0 \\\\\n -1 & -\\frac{3}{2} \\\\\n -\\frac{5}{2} & -\\frac{11}{4} \\\\\n 1 & -\\frac{5}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{4} & \\frac{1}{4} \\\\\n \\frac{1}{2} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{7}{4} & -\\frac{1}{4} \\\\\n -\\frac{5}{2} & 2 \\\\\n -\\frac{23}{4} & \\frac{7}{2} \\\\\n \\frac{9}{8} & \\frac{17}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0],\n [-1, -(3/2)],\n [-(5/2), -(11/4)],\n [1, -(5/4)]])\nb = np.array([\n [(7/4), (1/4)],\n [(1/2), -(3/2)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{31}{4} & -\\frac{15}{4} & -\\frac{15}{4} \\\\\n \\frac{9}{2} & -2 & \\frac{11}{4} \\\\\n \\frac{1}{4} & \\frac{31}{4} & -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{69 x^2}{4}-\\frac{681 x}{8}-\\frac{1703}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(31/4), -(15/4), -(15/4)],\n [(9/2), -2, (11/4)],\n [(1/4), (31/4), -(15/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 0 \\\\\n 2 \\\\\n -2 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [0],\n [2],\n [-2],\n [-3]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{2} \\\\\n 1 \\\\\n -4 \\\\\n -\\frac{27}{4} \\\\\n \\frac{13}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{27}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2)],\n [1],\n [-4],\n [-(27/4)],\n [(13/4)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -6 \\\\\n 1 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 4 \\\\\n -7 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{19}{3 \\sqrt{2822}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-6],\n [1],\n [-10]]).squeeze()\nb = np.array([\n [10],\n [4],\n [-7],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & -2 & -1 \\\\\n 2 & 3 & -1 \\\\\n 3 & 1 & -2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -3 & -11 & 2 \\\\\n 7 & 4 & -3 \\\\\n 2 & -5 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2, -1],\n [2, 3, -1],\n [3, 1, -2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n 4 & -2 \\\\\n -5 & -8 \\\\\n 0 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -2],\n [-5, -8],\n [0, -8]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{39}{32}, -\\frac{73}{32}}$ to the line $-\\frac{59 x}{16}+\\frac{9 y}{32}+\\frac{13}{4}=0$.", - "Output Answer": [ - "$\\frac{7273}{32 \\sqrt{14005}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(39/32), -(73/32)\nline = Poly(-((59*x)/16)+((9*y)/32)+(13/4), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{9} \\\\\n -\\frac{20}{9} \\\\\n \\frac{17}{9} \\\\\n -\\frac{1}{9} \\\\\n -\\frac{26}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\sqrt{\\frac{2}{685}} \\\\\n -2 \\sqrt{\\frac{10}{137}} \\\\\n \\frac{17}{\\sqrt{1370}} \\\\\n -\\frac{1}{\\sqrt{1370}} \\\\\n -13 \\sqrt{\\frac{2}{685}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/9)],\n [-(20/9)],\n [(17/9)],\n [-(1/9)],\n [-(26/9)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 4 \\\\\n 8 \\\\\n 3 \\\\\n -2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -10 \\\\\n 7 \\\\\n -4 \\\\\n 8 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{407}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [4],\n [8],\n [3],\n [-2],\n [0]])\nb = np.array([\n [9],\n [-10],\n [7],\n [-4],\n [8],\n [5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-3,\\frac{9}{2},-\\frac{5}{2}\\right\\}, \\left\\{-\\frac{7}{2},4,2\\right\\}, \\left\\{-\\frac{5}{2},0,\\frac{5}{2}\\right\\}}$.", - "Output Answer": [ - "$142 x+38 y+20 z+305=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, (9/2), -(5/2)],\n [-(7/2), 4, 2],\n [-(5/2), 0, (5/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & 2 \\\\\n -8 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-1-i \\sqrt{7},-1+i \\sqrt{7}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 2],\n [-8, 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & -4 \\\\\n 3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$15$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -4],\n [3, -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -5 & 0 \\\\\n -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-5$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 0],\n [-1, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{14}{5}, -\\frac{17}{10}}$ to the line $-\\frac{3 x}{2}-\\frac{11 y}{10}+\\frac{1}{2}=0$.", - "Output Answer": [ - "$\\frac{657}{10 \\sqrt{346}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(14/5), -(17/10)\nline = Poly(-((3*x)/2)-((11*y)/10)+(1/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{9}{4} \\\\\n -\\frac{9}{4} \\\\\n -\\frac{7}{4} \\\\\n -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{9}{2 \\sqrt{55}} \\\\\n -\\frac{9}{2 \\sqrt{55}} \\\\\n -\\frac{7}{2 \\sqrt{55}} \\\\\n -\\frac{3}{2 \\sqrt{55}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/4)],\n [-(9/4)],\n [-(7/4)],\n [-(3/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -3 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n 6 \\\\\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-3],\n [-1],\n [-1]])\nb = np.array([\n [-2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & 2 & 0 \\\\\n 2 & 3 & 4 \\\\\n 3 & -1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-24$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2, 0],\n [2, 3, 4],\n [3, -1, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\pi \\\\\n 3 \\pi \\\\\n -2 \\pi \\\\\n -2 \\pi \\\\\n 3 \\pi \\\\\n 0 \\\\\n -3 \\pi \\\\\n -3 \\pi \\\\\n 2 \\pi \\\\\n \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\pi \\\\\n -\\pi \\\\\n -\\pi \\\\\n 2 \\pi \\\\\n -2 \\pi \\\\\n -3 \\pi \\\\\n 3 \\pi \\\\\n 3 \\pi \\\\\n 2 \\pi \\\\\n -2 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{149} \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-2*math.pi],\n [3*math.pi],\n [-2*math.pi],\n [-2*math.pi],\n [3*math.pi],\n [0],\n [-3*math.pi],\n [-3*math.pi],\n [2*math.pi],\n [math.pi]])\nb = np.array([\n [-math.pi],\n [-math.pi],\n [-math.pi],\n [2*math.pi],\n [-2*math.pi],\n [-3*math.pi],\n [3*math.pi],\n [3*math.pi],\n [2*math.pi],\n [-2*math.pi]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -2 & -1 & -2 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -2 & 0 & 2 & 3 \\\\\n -3 & 3 & -2 & 0 \\\\\n -3 & 1 & -2 & -2 \\\\\n 0 & 2 & -3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 13 & -1 & -4 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1, -2, 2]])\nb = np.array([\n [-2, 0, 2, 3],\n [-3, 3, -2, 0],\n [-3, 1, -2, -2],\n [0, 2, -3, 3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & -9 \\\\\n -6 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{3 \\left(2-\\sqrt{7}\\right),3 \\left(2+\\sqrt{7}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -9],\n [-6, 9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -5 & -10 & -5 \\\\\n -4 & -3 & 4 \\\\\n 9 & -4 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-14 x^2-84 x-505$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -10, -5],\n [-4, -3, 4],\n [9, -4, -6]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{34}{7} \\\\\n \\frac{60}{7} \\\\\n \\frac{64}{7} \\\\\n -\\frac{29}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{187}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(34/7)],\n [(60/7)],\n [(64/7)],\n [-(29/7)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{3}{e},-\\frac{5}{e},-\\frac{2}{e}\\right\\}, \\left\\{-\\frac{2}{e},\\frac{1}{e},-\\frac{1}{e}\\right\\}, \\left\\{\\frac{3}{e},-\\frac{2}{e},-\\frac{6}{e}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{3}{\\sqrt{38}},-\\frac{5}{\\sqrt{38}},-\\sqrt{\\frac{2}{19}}\\right\\}, \\left\\{-\\frac{67}{\\sqrt{8322}},\\frac{53}{\\sqrt{8322}},-16 \\sqrt{\\frac{2}{4161}}\\right\\}, \\left\\{\\frac{7}{\\sqrt{219}},\\frac{1}{\\sqrt{219}},-\\frac{13}{\\sqrt{219}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-(3/math.e), -(5/math.e), -(2/math.e)), (-(2/math.e), (1/math.e), -(1/math.e)), ((3/math.e), -(2/math.e), -(6/math.e))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -\\frac{9}{2} \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n -8 \\\\\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{33}{2} \\\\\n -\\frac{135}{2} \\\\\n -\\frac{251}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-(9/2)],\n [3]])\nb = np.array([\n [-(3/2)],\n [-8],\n [9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 2 & -1 & 2 & 0 \\\\\n 1 & 3 & 1 & 0 \\\\\n -2 & 1 & -1 & 3 \\\\\n -2 & 3 & 0 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -2 & 1 & 2 & 2 \\\\\n 2 & 1 & -3 & -2 \\\\\n -2 & 1 & 1 & 1 \\\\\n -3 & 1 & 2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -10 & 3 & 9 & 8 \\\\\n 2 & 5 & -6 & -3 \\\\\n -1 & 1 & -2 & -7 \\\\\n 10 & 1 & -13 & -10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1, 2, 0],\n [1, 3, 1, 0],\n [-2, 1, -1, 3],\n [-2, 3, 0, 0]])\nb = np.array([\n [-2, 1, 2, 2],\n [2, 1, -3, -2],\n [-2, 1, 1, 1],\n [-3, 1, 2, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 2 & 0 & 2 \\\\\n 3 & 0 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -1 & -3 & 0 & 1 \\\\\n -3 & -1 & -2 & 0 \\\\\n 1 & -2 & 0 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 0 & -10 & 0 & 2 \\\\\n -3 & -9 & 0 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, 2],\n [3, 0, 0]])\nb = np.array([\n [-1, -3, 0, 1],\n [-3, -1, -2, 0],\n [1, -2, 0, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -7 & 5 & 9 \\\\\n -7 & 3 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -8 & -2 & -1 \\\\\n -1 & 7 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -15 & 3 & 8 \\\\\n -8 & 10 & 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 5, 9],\n [-7, 3, 1]])\nb = np.array([\n [-8, -2, -1],\n [-1, 7, 8]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{61}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-10]])\nb = np.array([\n [8],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & \\frac{5}{2} & -\\frac{3}{2} \\\\\n -\\frac{3}{2} & -\\frac{5}{2} & 0 \\\\\n -\\frac{1}{2} & -2 & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & \\frac{7}{4} & -\\frac{3}{2} \\\\\n \\frac{3}{4} & \\frac{5}{2} & \\frac{9}{4} \\\\\n \\frac{5}{2} & \\frac{23}{4} & \\frac{7}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, (5/2), -(3/2)],\n [-(3/2), -(5/2), 0],\n [-(1/2), -2, -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, -3, 4}$ to the plane $-4 x+2 y+4 z+2=0$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, -3, 4\nplane = Poly(-4*x+2*y+4*z+2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{34}{9} & \\frac{11}{3} \\\\\n \\frac{7}{3} & -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{72}{41} & -\\frac{99}{41} \\\\\n -\\frac{63}{41} & -\\frac{102}{41} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(34/9), (11/3)],\n [(7/3), -(8/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4]])\nb = np.array([\n [9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -5 & 1 \\\\\n -3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{2}{7} & \\frac{1}{7} \\\\\n -\\frac{3}{7} & \\frac{5}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 1],\n [-3, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & -6 \\\\\n 8 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-3-2 i \\sqrt{3},-3+2 i \\sqrt{3}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -6],\n [8, -9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{13}{3}, \\frac{4}{3}, -\\frac{11}{3}}$ to the plane $4 x+\\frac{11 y}{3}-\\frac{z}{3}+\\frac{11}{3}=0$.", - "Output Answer": [ - "$\\frac{34 \\sqrt{\\frac{2}{133}}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(13/3), (4/3), -(11/3)\nplane = Poly(4*x+((11*y)/3)-(z/3)+(11/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 6 \\\\\n -10 \\\\\n 5 \\\\\n 6 \\\\\n -3 \\\\\n 2 \\\\\n -1 \\\\\n 10 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -8 \\\\\n 6 \\\\\n -2 \\\\\n 8 \\\\\n 2 \\\\\n -10 \\\\\n -8 \\\\\n 8 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{231}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [6],\n [-10],\n [5],\n [6],\n [-3],\n [2],\n [-1],\n [10],\n [9]])\nb = np.array([\n [-2],\n [-8],\n [6],\n [-2],\n [8],\n [2],\n [-10],\n [-8],\n [8],\n [-5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -5 \\\\\n -7 \\\\\n -1 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 10 \\\\\n -6 \\\\\n 2 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{39}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-5],\n [-7],\n [-1],\n [6]])\nb = np.array([\n [-7],\n [10],\n [-6],\n [2],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{17}{8} & \\frac{3}{4} & -\\frac{21}{8} & -\\frac{9}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{8} \\\\\n -\\frac{1}{4} \\\\\n \\frac{1}{4} \\\\\n \\frac{7}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{35}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/8), (3/4), -(21/8), -(9/8)]])\nb = np.array([\n [-(11/8)],\n [-(1/4)],\n [(1/4)],\n [(7/8)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 1 \\\\\n -\\frac{15}{2} \\\\\n \\frac{3}{2} \\\\\n \\frac{7}{2} \\\\\n \\frac{15}{2} \\\\\n \\frac{11}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{7}{2} \\\\\n -10 \\\\\n -3 \\\\\n -\\frac{7}{2} \\\\\n -\\frac{15}{2} \\\\\n \\frac{3}{2} \\\\\n -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{33}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [1],\n [-(15/2)],\n [(3/2)],\n [(7/2)],\n [(15/2)],\n [(11/2)]])\nb = np.array([\n [(7/2)],\n [-10],\n [-3],\n [-(7/2)],\n [-(15/2)],\n [(3/2)],\n [-(7/2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{14}{5}, -\\frac{3}{5}, -\\frac{22}{5}}$ to the plane $\\frac{4 x}{5}+\\frac{11 y}{5}+\\frac{16 z}{5}+\\frac{22}{5}=0$.", - "Output Answer": [ - "$\\frac{73 \\sqrt{\\frac{3}{131}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (14/5), -(3/5), -(22/5)\nplane = Poly(((4*x)/5)+((11*y)/5)+((16*z)/5)+(22/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 10 & -6 & -7 & 4 & 3 & 1 & 8 \\\\\n 6 & 9 & -5 & -5 & 0 & -4 & 6 \\\\\n -3 & -10 & -5 & -9 & -8 & 10 & 8 \\\\\n -7 & 1 & -6 & 2 & -10 & 3 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & \\frac{283}{356} & -\\frac{7613}{23496} & \\frac{227}{5874} \\\\\n 0 & 1 & 0 & 0 & \\frac{3}{356} & -\\frac{12469}{23496} & -\\frac{497}{5874} \\\\\n 0 & 0 & 1 & 0 & \\frac{71}{89} & -\\frac{863}{2937} & -\\frac{3292}{2937} \\\\\n 0 & 0 & 0 & 1 & \\frac{61}{356} & -\\frac{5879}{23496} & -\\frac{1087}{5874} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, -6, -7, 4, 3, 1, 8],\n [6, 9, -5, -5, 0, -4, 6],\n [-3, -10, -5, -9, -8, 10, 8],\n [-7, 1, -6, 2, -10, 3, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -5 \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -34 \\\\\n 78 \\\\\n 42 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [3],\n [-8]])\nb = np.array([\n [-9],\n [-5],\n [2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -8 & -6 & -4 & 7 & -7 & -10 & 7 \\\\\n 4 & 1 & 9 & -3 & 7 & 2 & 9 \\\\\n -7 & 8 & 0 & 0 & -9 & 10 & 8 \\\\\n 6 & -9 & -1 & -2 & -10 & 0 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & \\frac{1591}{401} & -\\frac{710}{401} & -\\frac{1544}{401} \\\\\n 0 & 1 & 0 & 0 & \\frac{941}{401} & -\\frac{120}{401} & -\\frac{950}{401} \\\\\n 0 & 0 & 1 & 0 & \\frac{895}{1203} & -\\frac{96}{401} & \\frac{1730}{1203} \\\\\n 0 & 0 & 0 & 1 & \\frac{7183}{1203} & -\\frac{1542}{401} & -\\frac{5545}{1203} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-8, -6, -4, 7, -7, -10, 7],\n [4, 1, 9, -3, 7, 2, 9],\n [-7, 8, 0, 0, -9, 10, 8],\n [6, -9, -1, -2, -10, 0, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,3,-3\\}, \\{-4,1,-5\\}, \\{2,-2,-3\\}}$.", - "Output Answer": [ - "$5 x+6 y-6 z-16=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, 3, -3],\n [-4, 1, -5],\n [2, -2, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{29}{7}, -2}$ to the line $\\frac{8 x}{7}+4 y=0$.", - "Output Answer": [ - "$\\frac{40}{7 \\sqrt{53}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (29/7), -2\nline = Poly(((8*x)/7)+4*y, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [0],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -\\frac{7}{2} & \\frac{11}{3} & \\frac{2}{3} & \\frac{25}{3} \\\\\n \\frac{13}{3} & \\frac{9}{2} & 10 & \\frac{35}{6} \\\\\n -8 & -3 & \\frac{19}{2} & -\\frac{3}{2} \\\\\n -\\frac{29}{3} & -\\frac{1}{6} & -7 & -\\frac{49}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), (11/3), (2/3), (25/3)],\n [(13/3), (9/2), 10, (35/6)],\n [-8, -3, (19/2), -(3/2)],\n [-(29/3), -(1/6), -7, -(49/6)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -7 \\\\\n -8 \\\\\n 10 \\\\\n 6 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 6 \\\\\n -4 \\\\\n -9 \\\\\n -10 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{251}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-7],\n [-8],\n [10],\n [6],\n [-10]])\nb = np.array([\n [1],\n [6],\n [-4],\n [-9],\n [-10],\n [1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & 2 \\\\\n -1 & \\frac{3}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{4} & 0 \\\\\n 0 & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), 2],\n [-1, (3/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 2 & 5 & 5 & 0 \\\\\n 10 & -9 & -10 & 1 \\\\\n -2 & 8 & 4 & 8 \\\\\n -5 & 9 & -1 & 7 \\\\\n 9 & 6 & 7 & 7 \\\\\n -5 & 9 & 3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, 5, 5, 0],\n [10, -9, -10, 1],\n [-2, 8, 4, 8],\n [-5, 9, -1, 7],\n [9, 6, 7, 7],\n [-5, 9, 3, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{23}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{15}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2]])\nb = np.array([\n [(23/4)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & 8 \\\\\n -6 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{2 \\left(1-2 i \\sqrt{2}\\right),2 \\left(1+2 i \\sqrt{2}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 8],\n [-6, 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{4}{5}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{12}{5} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0]])\nprint(a * -(4/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -5 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -10 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 5 \\\\\n 25 \\\\\n -45 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-5],\n [-2]])\nb = np.array([\n [5],\n [-10],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{37}{8} \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{25}{4} \\\\\n -\\frac{11}{2} \\\\\n \\frac{29}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{193}{32} \\\\\n -\\frac{125}{4} \\\\\n -\\frac{925}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-(37/8)],\n [5]])\nb = np.array([\n [-(25/4)],\n [-(11/2)],\n [(29/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{121}{32}, \\frac{33}{32}}$ to the line $\\frac{19 x}{32}-\\frac{71 y}{16}+\\frac{5}{16}=0$.", - "Output Answer": [ - "$\\frac{2067}{160 \\sqrt{821}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (121/32), (33/32)\nline = Poly(((19*x)/32)-((71*y)/16)+(5/16), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -3 & 1 \\\\\n \\frac{5}{2} & \\frac{1}{2} \\\\\n -3 & 1 \\\\\n -3 & 0 \\\\\n 1 & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1 \\\\\n \\frac{1}{2} \\\\\n 1 \\\\\n 0 \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1],\n [(5/2), (1/2)],\n [-3, 1],\n [-3, 0],\n [1, (3/2)]])\nb = np.array([\n [0],\n [1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -10 & -3 & 0 \\\\\n -1 & 0 & 9 \\\\\n 9 & 7 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-12.45,-3.738,8.187\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -3, 0],\n [-1, 0, 9],\n [9, 7, 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -5 & -1 & 9 & -4 \\\\\n 3 & 4 & -4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-19.,27.,0.,17.\\}, \\{32.,-7.,17.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, -1, 9, -4],\n [3, 4, -4, -3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{21}{5} & \\frac{2}{5} & -\\frac{18}{5} \\\\\n -2 & 2 & -\\frac{17}{5} \\\\\n -\\frac{13}{5} & -\\frac{23}{5} & -\\frac{1}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{14479}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(21/5), (2/5), -(18/5)],\n [-2, 2, -(17/5)],\n [-(13/5), -(23/5), -(1/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -9 & -4 \\\\\n -8 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, -4],\n [-8, -10]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 1 & -3 \\\\\n -3 & -3 & 3 \\\\\n -3 & 3 & 0 \\\\\n -1 & 1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.85 \\\\\n 1.81 \\\\\n 1.31 \\\\\n -0.01 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.201 \\\\\n 0.119 \\\\\n 0.54 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, -3],\n [-3, -3, 3],\n [-3, 3, 0],\n [-1, 1, 1]])\nb = np.array([\n [-1.85],\n [1.81],\n [1.31],\n [-0.01]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -2 \\\\\n -9 \\\\\n -5 \\\\\n -1 \\\\\n -7 \\\\\n 5 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -3 \\\\\n -10 \\\\\n -5 \\\\\n 2 \\\\\n -3 \\\\\n -10 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$94$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-2],\n [-9],\n [-5],\n [-1],\n [-7],\n [5],\n [-1]])\nb = np.array([\n [2],\n [-3],\n [-10],\n [-5],\n [2],\n [-3],\n [-10],\n [8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 2 & 1 \\\\\n -1 & -2 \\\\\n -1 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1],\n [-1, -2],\n [-1, 1]])\nb = np.array([\n [1],\n [0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{2} & -\\frac{19}{2} \\\\\n -\\frac{3}{2} & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{6} \\left(-5-\\sqrt{253}\\right),1\\right\\}, \\left\\{\\frac{1}{6} \\left(\\sqrt{253}-5\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2), -(19/2)],\n [-(3/2), 1]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{2}{3} & -\\frac{11}{3} \\\\\n \\frac{1}{3} & \\frac{26}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{3} \\left(14-\\sqrt{133}\\right),\\frac{1}{3} \\left(14+\\sqrt{133}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/3), -(11/3)],\n [(1/3), (26/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 0 \\\\\n -3 \\\\\n 4 \\\\\n -5 \\\\\n 2 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -4 \\\\\n -2 \\\\\n 7 \\\\\n 5 \\\\\n 8 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-19$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [0],\n [-3],\n [4],\n [-5],\n [2],\n [-6]])\nb = np.array([\n [-4],\n [-4],\n [-2],\n [7],\n [5],\n [8],\n [2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & 2 & 0 & -1 & 0 \\\\\n 1 & 3 & 0 & -1 & 1 \\\\\n 3 & -2 & -2 & 3 & -3 \\\\\n 2 & 1 & -1 & 3 & 3 \\\\\n 1 & 3 & 0 & -3 & -2 \\\\\n 3 & 3 & 2 & 0 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.33 \\\\\n -1.97 \\\\\n -1.96 \\\\\n 1.86 \\\\\n 0.92 \\\\\n -0.86 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.829 \\\\\n -0.9 \\\\\n -0.364 \\\\\n -1.149 \\\\\n 1.009 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2, 0, -1, 0],\n [1, 3, 0, -1, 1],\n [3, -2, -2, 3, -3],\n [2, 1, -1, 3, 3],\n [1, 3, 0, -3, -2],\n [3, 3, 2, 0, 0]])\nb = np.array([\n [-1.33],\n [-1.97],\n [-1.96],\n [1.86],\n [0.92],\n [-0.86]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & 0 \\\\\n -2 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0,1\\}, \\{1,1\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 0],\n [-2, 9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 12 \\log (2) \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-48 \\log ^2(2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-4*math.log(2)]])\nb = np.array([\n [12*math.log(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 6 \\\\\n -7 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [6],\n [-7],\n [-6]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{113}{16} \\\\\n \\frac{15}{4} \\\\\n -\\frac{97}{16} \\\\\n \\frac{23}{16} \\\\\n -\\frac{45}{8} \\\\\n \\frac{43}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{41803}}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(113/16)],\n [(15/4)],\n [-(97/16)],\n [(23/16)],\n [-(45/8)],\n [(43/8)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -3 & 5 \\\\\n 6 & 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-7 x-60$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 5],\n [6, 10]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{8}{5},-\\frac{7}{5},-\\frac{14}{5}\\right\\}, \\left\\{-\\frac{3}{5},-\\frac{7}{5},-\\frac{8}{5}\\right\\}, \\left\\{\\frac{2}{5},\\frac{11}{5},3\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{8}{\\sqrt{309}},-\\frac{7}{\\sqrt{309}},-\\frac{14}{\\sqrt{309}}\\right\\}, \\left\\{\\frac{553}{\\sqrt{1073157}},-\\frac{868}{\\sqrt{1073157}},\\frac{118}{\\sqrt{1073157}}\\right\\}, \\left\\{-\\frac{42}{\\sqrt{3473}},-\\frac{22}{\\sqrt{3473}},\\frac{35}{\\sqrt{3473}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-(8/5), -(7/5), -(14/5)), (-(3/5), -(7/5), -(8/5)), ((2/5), (11/5), 3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -7 & 8 & 5 \\\\\n 6 & -8 & -1 \\\\\n -7 & 10 & 0 \\\\\n 3 & -9 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 6 & -9 & 8 \\\\\n 5 & 7 & 7 \\\\\n 5 & 9 & 1 \\\\\n 4 & 6 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & -1 & 13 \\\\\n 11 & -1 & 6 \\\\\n -2 & 19 & 1 \\\\\n 7 & -3 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 8, 5],\n [6, -8, -1],\n [-7, 10, 0],\n [3, -9, -3]])\nb = np.array([\n [6, -9, 8],\n [5, 7, 7],\n [5, 9, 1],\n [4, 6, -1]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [1],\n [-1],\n [0]]).squeeze()\nb = np.array([\n [1],\n [0],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{16}{3} \\\\\n -4 \\\\\n \\frac{13}{3} \\\\\n 5 \\\\\n \\frac{13}{3} \\\\\n \\frac{4}{3} \\\\\n -\\frac{4}{3} \\\\\n -\\frac{7}{3} \\\\\n -\\frac{23}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -\\frac{10}{3} \\\\\n -9 \\\\\n 7 \\\\\n \\frac{29}{3} \\\\\n \\frac{25}{3} \\\\\n -\\frac{10}{3} \\\\\n 5 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{\\frac{1178}{3}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(16/3)],\n [-4],\n [(13/3)],\n [5],\n [(13/3)],\n [(4/3)],\n [-(4/3)],\n [-(7/3)],\n [-(23/3)]])\nb = np.array([\n [5],\n [-(10/3)],\n [-9],\n [7],\n [(29/3)],\n [(25/3)],\n [-(10/3)],\n [5],\n [1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, \\frac{3}{2}}$ to the line $2 x-\\frac{3 y}{2}+\\frac{5}{2}=0$.", - "Output Answer": [ - "$\\frac{3}{2}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, (3/2)\nline = Poly(2*x-((3*y)/2)+(5/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 0 & -5 \\\\\n 0 & 10 \\\\\n -6 & 6 \\\\\n 8 & 5 \\\\\n -2 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, -5],\n [0, 10],\n [-6, 6],\n [8, 5],\n [-2, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{20}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & -6 \\\\\n 6 & -6 \\\\\n 5 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{3}{10} & \\frac{9}{10} \\\\\n -\\frac{9}{10} & \\frac{9}{10} \\\\\n -\\frac{3}{4} & -\\frac{3}{20} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -6],\n [6, -6],\n [5, 1]])\nprint(a * -(3/20))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & -1 \\\\\n 2 & -1 \\\\\n 0 & -2 \\\\\n -3 & 3 \\\\\n -1 & 0 \\\\\n 1 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.03 \\\\\n 1.29 \\\\\n -2.86 \\\\\n -0.38 \\\\\n -0.48 \\\\\n -0.21 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.587 \\\\\n 0.864 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1],\n [2, -1],\n [0, -2],\n [-3, 3],\n [-1, 0],\n [1, 0]])\nb = np.array([\n [-2.03],\n [1.29],\n [-2.86],\n [-0.38],\n [-0.48],\n [-0.21]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 3 & -10 \\\\\n 5 & -9 \\\\\n -5 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 8 & 4 \\\\\n 7 & 0 \\\\\n 0 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 11 & -6 \\\\\n 12 & -9 \\\\\n -5 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -10],\n [5, -9],\n [-5, -1]])\nb = np.array([\n [8, 4],\n [7, 0],\n [0, 6]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $7$ and the matrix\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 9 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 42 \\\\\n 63 \\\\\n 14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [9],\n [2]])\nprint(a * 7)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & -1 & -1 \\\\\n 1 & 2 & -3 \\\\\n 1 & -3 & -1 \\\\\n -2 & -1 & -3 \\\\\n -3 & -2 & 2 \\\\\n 2 & 2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.26 \\\\\n -2.72 \\\\\n -2.31 \\\\\n -2.57 \\\\\n 2.99 \\\\\n -0.08 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.274 \\\\\n -0.012 \\\\\n 0.892 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, -1],\n [1, 2, -3],\n [1, -3, -1],\n [-2, -1, -3],\n [-3, -2, 2],\n [2, 2, -2]])\nb = np.array([\n [2.26],\n [-2.72],\n [-2.31],\n [-2.57],\n [2.99],\n [-0.08]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & -1 & -2 & 1 \\\\\n -3 & -3 & -3 & 3 \\\\\n -1 & 2 & 3 & 1 \\\\\n 0 & 2 & -2 & -2 \\\\\n -3 & -1 & 0 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.77 \\\\\n -1.65 \\\\\n 1.49 \\\\\n -0.93 \\\\\n 2.61 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3.219 \\\\\n 2.652 \\\\\n -1.334 \\\\\n 4.451 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, -2, 1],\n [-3, -3, -3, 3],\n [-1, 2, 3, 1],\n [0, 2, -2, -2],\n [-3, -1, 0, 3]])\nb = np.array([\n [1.77],\n [-1.65],\n [1.49],\n [-0.93],\n [2.61]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -6 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -1 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 23 \\\\\n -72 \\\\\n 42 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-6],\n [-7]])\nb = np.array([\n [6],\n [-1],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & 3 & 1 & -3 \\\\\n -1 & -1 & 0 & -3 \\\\\n -1 & -2 & 1 & 0 \\\\\n 3 & -1 & 0 & -2 \\\\\n -2 & -1 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.34 \\\\\n -2.92 \\\\\n -0.95 \\\\\n -1.38 \\\\\n -0.24 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.227 \\\\\n 0.597 \\\\\n 0.507 \\\\\n 0.708 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3, 1, -3],\n [-1, -1, 0, -3],\n [-1, -2, 1, 0],\n [3, -1, 0, -2],\n [-2, -1, -1, 2]])\nb = np.array([\n [0.34],\n [-2.92],\n [-0.95],\n [-1.38],\n [-0.24]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 0 & -\\frac{3}{2} & 10 \\\\\n \\frac{33}{4} & 7 & -\\frac{39}{4} \\\\\n \\frac{3}{4} & 10 & \\frac{13}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{41 x^2}{4}-\\frac{1001 x}{8}+\\frac{13179}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -(3/2), 10],\n [(33/4), 7, -(39/4)],\n [(3/4), 10, (13/4)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & -2 & 4 \\\\\n -4 & 0 & -4 \\\\\n -3 & 2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{6} & -\\frac{5}{24} & -\\frac{1}{6} \\\\\n -\\frac{1}{3} & -\\frac{7}{24} & \\frac{1}{6} \\\\\n \\frac{1}{6} & -\\frac{1}{24} & \\frac{1}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2, 4],\n [-4, 0, -4],\n [-3, 2, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{25}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & -2 \\\\\n 1 & 7 \\\\\n 7 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{12}{25} & -\\frac{6}{25} \\\\\n \\frac{3}{25} & \\frac{21}{25} \\\\\n \\frac{21}{25} & \\frac{3}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -2],\n [1, 7],\n [7, 1]])\nprint(a * (3/25))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & -7 \\\\\n -4 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-3 x-56$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -7],\n [-4, -4]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{20}{e} \\\\\n \\frac{10}{e} \\\\\n -\\frac{8}{e} \\\\\n -\\frac{19}{e} \\\\\n \\frac{25}{e} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{4}{e} \\\\\n -\\frac{27}{e} \\\\\n \\frac{5}{e} \\\\\n -\\frac{6}{e} \\\\\n \\frac{19}{e} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{199}{e^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(20/math.e)],\n [(10/math.e)],\n [-(8/math.e)],\n [-(19/math.e)],\n [(25/math.e)]])\nb = np.array([\n [(4/math.e)],\n [-(27/math.e)],\n [(5/math.e)],\n [-(6/math.e)],\n [(19/math.e)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & -\\frac{13}{3} & -\\frac{13}{3} \\\\\n \\frac{25}{6} & \\frac{5}{3} & \\frac{13}{3} \\\\\n -5 & \\frac{5}{6} & -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{775}{36}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(13/3), -(13/3)],\n [(25/6), (5/3), (13/3)],\n [-5, (5/6), -(8/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & 3 & -1 \\\\\n -4 & -2 & 3 \\\\\n -3 & -3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 3, -1],\n [-4, -2, 3],\n [-3, -3, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1}{\\sqrt{6}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [1],\n [0]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [0],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & -2 & -1 \\\\\n 3 & 0 & 1 \\\\\n -2 & -2 & 2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 7 & 16 & -7 \\\\\n -21 & 0 & -11 \\\\\n -20 & 16 & 20 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2, -1],\n [3, 0, 1],\n [-2, -2, 2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -3 \\\\\n -3 \\\\\n 1 \\\\\n 2 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-3],\n [-3],\n [1],\n [2],\n [7]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 0 & -10 & 6 & -4 \\\\\n -2 & -2 & -6 & -5 \\\\\n 0 & 3 & 2 & -6 \\\\\n -8 & 1 & -10 & 1 \\\\\n 5 & 3 & -5 & 5 \\\\\n -10 & 1 & 9 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, -10, 6, -4],\n [-2, -2, -6, -5],\n [0, 3, 2, -6],\n [-8, 1, -10, 1],\n [5, 3, -5, 5],\n [-10, 1, 9, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n 5 & 5 & 9 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 5, 9, 7]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 0 & 1 & -1 & 1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 0 & -2 & 2 & -2 & 4 \\\\\n 0 & -3 & 3 & -3 & 6 \\\\\n 0 & 1 & -1 & 1 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-3],\n [1]])\nb = np.array([\n [0, 1, -1, 1, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -4 & 10 \\\\\n -3 & -1 \\\\\n 2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, 10],\n [-3, -1],\n [2, 2]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{2}{3} & -\\frac{4}{3} & -\\frac{20}{3} \\\\\n -\\frac{8}{3} & 2 & -2 \\\\\n -\\frac{17}{3} & 6 & \\frac{17}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-0.719-0.806 i,-0.719+0.806 i,9.772\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/3), -(4/3), -(20/3)],\n [-(8/3), 2, -2],\n [-(17/3), 6, (17/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{33}{8} & \\frac{33}{8} & -\\frac{7}{4} \\\\\n -\\frac{19}{4} & \\frac{29}{8} & -2 \\\\\n \\frac{1}{8} & -5 & -\\frac{9}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{7208}{62421} & -\\frac{6856}{62421} & \\frac{976}{62421} \\\\\n \\frac{2864}{62421} & \\frac{2264}{62421} & -\\frac{8480}{62421} \\\\\n -\\frac{3976}{20807} & -\\frac{3608}{20807} & -\\frac{5896}{20807} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(33/8), (33/8), -(7/4)],\n [-(19/4), (29/8), -2],\n [(1/8), -5, -(9/8)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -3 & -2 \\\\\n -1 & -1 & 2 \\\\\n 3 & -1 & -1 \\\\\n -2 & -1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.82 \\\\\n -2.78 \\\\\n 0.29 \\\\\n 0.51 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.055 \\\\\n 0.384 \\\\\n -0.164 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -3, -2],\n [-1, -1, 2],\n [3, -1, -1],\n [-2, -1, 3]])\nb = np.array([\n [-0.82],\n [-2.78],\n [0.29],\n [0.51]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 6 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -18 \\\\\n -60 \\\\\n 42 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [6],\n [6]])\nb = np.array([\n [-9],\n [2],\n [-1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 3 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 1 \\\\\n 0 \\\\\n 2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{3}{5},\\frac{1}{5},0,\\frac{2}{5},-\\frac{1}{5}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [3],\n [1],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [-3],\n [1],\n [0],\n [2],\n [-1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & -1 \\\\\n -3 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1],\n [-3, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{1}{3} & -\\frac{7}{3} & \\frac{8}{3} & -\\frac{4}{3} \\\\\n \\frac{7}{3} & 1 & \\frac{4}{3} & -\\frac{5}{3} \\\\\n -1 & -\\frac{5}{3} & \\frac{1}{3} & \\frac{7}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{3} \\\\\n \\frac{8}{3} \\\\\n -\\frac{8}{3} \\\\\n -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{95}{9} \\\\\n -2 \\\\\n -\\frac{68}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/3), -(7/3), (8/3), -(4/3)],\n [(7/3), 1, (4/3), -(5/3)],\n [-1, -(5/3), (1/3), (7/3)]])\nb = np.array([\n [-(5/3)],\n [(8/3)],\n [-(8/3)],\n [-(5/3)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -3 & 0 & 9 & 4 & -3 & -9 \\\\\n -3 & -8 & -1 & 9 & 9 & -9 \\\\\n 10 & -4 & 0 & -9 & 9 & -7 \\\\\n 4 & -4 & 6 & -3 & 9 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & -\\frac{43}{16} & -\\frac{1609}{288} \\\\\n 0 & 1 & 0 & 0 & -\\frac{49}{16} & -\\frac{535}{288} \\\\\n 0 & 0 & 1 & 0 & -\\frac{1}{16} & -\\frac{235}{288} \\\\\n 0 & 0 & 0 & 1 & -\\frac{21}{8} & -\\frac{221}{48} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 0, 9, 4, -3, -9],\n [-3, -8, -1, 9, 9, -9],\n [10, -4, 0, -9, 9, -7],\n [4, -4, 6, -3, 9, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -4 & -4 & 0 \\\\\n 3 & 9 & 2 \\\\\n 8 & 8 & -6 \\\\\n 1 & 6 & 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -5 & 5 & -6 \\\\\n -5 & -2 & 1 \\\\\n 1 & 5 & 1 \\\\\n -1 & 4 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -9 & 1 & -6 \\\\\n -2 & 7 & 3 \\\\\n 9 & 13 & -5 \\\\\n 0 & 10 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -4, 0],\n [3, 9, 2],\n [8, 8, -6],\n [1, 6, 6]])\nb = np.array([\n [-5, 5, -6],\n [-5, -2, 1],\n [1, 5, 1],\n [-1, 4, -4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -6 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 9 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-6],\n [-6]])\nb = np.array([\n [2],\n [9],\n [-8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{2}{\\sqrt{\\pi }} \\\\\n -\\frac{4}{\\sqrt{\\pi }} \\\\\n \\frac{1}{\\sqrt{\\pi }} \\\\\n -\\frac{9}{\\sqrt{\\pi }} \\\\\n \\frac{3}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{14}{\\sqrt{\\pi }} \\\\\n \\frac{15}{\\sqrt{\\pi }} \\\\\n \\frac{17}{\\sqrt{\\pi }} \\\\\n \\frac{13}{\\sqrt{\\pi }} \\\\\n \\frac{11}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{99}{\\pi }$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(2/(math.sqrt(math.pi)))],\n [-(4/(math.sqrt(math.pi)))],\n [(1/(math.sqrt(math.pi)))],\n [-(9/(math.sqrt(math.pi)))],\n [(3/(math.sqrt(math.pi)))]])\nb = np.array([\n [(14/(math.sqrt(math.pi)))],\n [(15/(math.sqrt(math.pi)))],\n [(17/(math.sqrt(math.pi)))],\n [(13/(math.sqrt(math.pi)))],\n [(11/(math.sqrt(math.pi)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{7}{3} & -4 & \\frac{23}{3} \\\\\n -\\frac{2}{3} & \\frac{2}{3} & 2 \\\\\n -\\frac{8}{3} & 5 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.836,-0.288,1.\\}, \\{-0.626,1.859,1.\\}, \\{6.314,5.216,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/3), -4, (23/3)],\n [-(2/3), (2/3), 2],\n [-(8/3), 5, -9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{9}{8} & 0 & \\frac{1}{2} & -\\frac{5}{4} & \\frac{17}{8} \\\\\n \\frac{9}{4} & \\frac{9}{4} & -\\frac{13}{8} & -\\frac{19}{8} & \\frac{9}{8} \\\\\n -\\frac{1}{8} & -\\frac{17}{8} & \\frac{1}{4} & -\\frac{5}{4} & \\frac{15}{8} \\\\\n \\frac{11}{8} & -\\frac{11}{4} & -\\frac{11}{8} & -\\frac{9}{8} & -\\frac{9}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{8} & \\frac{19}{8} & \\frac{11}{4} \\\\\n \\frac{5}{4} & \\frac{5}{8} & \\frac{11}{4} \\\\\n \\frac{7}{8} & -\\frac{9}{4} & -\\frac{13}{8} \\\\\n 0 & -\\frac{1}{4} & \\frac{11}{8} \\\\\n -\\frac{1}{4} & \\frac{3}{4} & -\\frac{19}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{3}{64} & -\\frac{121}{64} & -\\frac{683}{64} \\\\\n \\frac{53}{64} & \\frac{379}{32} & \\frac{581}{64} \\\\\n -\\frac{185}{64} & -\\frac{15}{32} & -\\frac{817}{64} \\\\\n -\\frac{17}{4} & \\frac{207}{64} & \\frac{9}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/8), 0, (1/2), -(5/4), (17/8)],\n [(9/4), (9/4), -(13/8), -(19/8), (9/8)],\n [-(1/8), -(17/8), (1/4), -(5/4), (15/8)],\n [(11/8), -(11/4), -(11/8), -(9/8), -(9/4)]])\nb = np.array([\n [-(1/8), (19/8), (11/4)],\n [(5/4), (5/8), (11/4)],\n [(7/8), -(9/4), -(13/8)],\n [0, -(1/4), (11/8)],\n [-(1/4), (3/4), -(19/8)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & 3 & 2 & 2 \\\\\n 2 & -2 & 1 & -1 \\\\\n -2 & -1 & -3 & -2 \\\\\n -2 & -1 & -1 & -1 \\\\\n 0 & 2 & -3 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.4 \\\\\n -0.95 \\\\\n -1.54 \\\\\n 1.86 \\\\\n -0.84 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.745 \\\\\n -0.161 \\\\\n 0.37 \\\\\n 0.653 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, 2, 2],\n [2, -2, 1, -1],\n [-2, -1, -3, -2],\n [-2, -1, -1, -1],\n [0, 2, -3, 0]])\nb = np.array([\n [2.4],\n [-0.95],\n [-1.54],\n [1.86],\n [-0.84]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -3 & -1 & 3 \\\\\n -1 & -2 & 1 \\\\\n 0 & -2 & -3 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 10 & -1 & -19 \\\\\n 5 & 3 & -8 \\\\\n 2 & 10 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1, 3],\n [-1, -2, 1],\n [0, -2, -3]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -8 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -9 \\\\\n 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -78 \\\\\n -54 \\\\\n 20 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-8],\n [-6]])\nb = np.array([\n [7],\n [-9],\n [3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{5}{e},\\frac{8}{e},-\\frac{8}{e}\\right\\}, \\left\\{\\frac{2}{e},\\frac{4}{e},\\frac{4}{e}\\right\\}, \\left\\{0,\\frac{3}{e},-\\frac{1}{e}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{5}{3 \\sqrt{17}},\\frac{8}{3 \\sqrt{17}},-\\frac{8}{3 \\sqrt{17}}\\right\\}, \\left\\{\\frac{32 \\sqrt{\\frac{2}{17}}}{39},\\frac{173}{39 \\sqrt{34}},\\frac{133}{39 \\sqrt{34}}\\right\\}, \\left\\{\\frac{8 \\sqrt{2}}{13},\\frac{1}{13 \\sqrt{2}},-\\frac{9}{13 \\sqrt{2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-(5/math.e), (8/math.e), -(8/math.e)), ((2/math.e), (4/math.e), (4/math.e)), (0, (3/math.e), -(1/math.e))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{2} & \\frac{5}{2} & -4 \\\\\n -\\frac{1}{2} & 1 & -10 \\\\\n -\\frac{7}{2} & \\frac{17}{2} & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{4.38,1.629,1.\\}, \\{0.103\\, -0.438 i,0.395\\, -1.115 i,1.\\}, \\{0.103\\, +0.438 i,0.395\\, +1.115 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/2), (5/2), -4],\n [-(1/2), 1, -10],\n [-(7/2), (17/2), -5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -3 & 5 & -7 & -9 & 5 & 2 \\\\\n -9 & -4 & -8 & 2 & -3 & 3 \\\\\n 4 & 3 & 2 & -5 & -7 & -1 \\\\\n -9 & 8 & -5 & 6 & 7 & -4 \\\\\n -1 & 0 & 0 & -1 & 5 & -8 \\\\\n 10 & 4 & 0 & -2 & -1 & 0 \\\\\n 0 & -10 & 8 & -1 & -3 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 5, -7, -9, 5, 2],\n [-9, -4, -8, 2, -3, 3],\n [4, 3, 2, -5, -7, -1],\n [-9, 8, -5, 6, 7, -4],\n [-1, 0, 0, -1, 5, -8],\n [10, 4, 0, -2, -1, 0],\n [0, -10, 8, -1, -3, 5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,-3,3\\}, \\{0,1,-1\\}, \\{-1,-1,1\\}}$.", - "Output Answer": [ - "$y+z=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -3, 3],\n [0, 1, -1],\n [-1, -1, 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{2} & -3 & -\\frac{3}{2} \\\\\n -1 & \\frac{5}{2} & -2 \\\\\n -3 & 0 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{117}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), -3, -(3/2)],\n [-1, (5/2), -2],\n [-3, 0, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{6} \\\\\n 2 \\\\\n -\\frac{5}{2} \\\\\n \\frac{7}{6} \\\\\n \\frac{1}{2} \\\\\n -\\frac{11}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{13}{\\sqrt{717}} \\\\\n 4 \\sqrt{\\frac{3}{239}} \\\\\n -5 \\sqrt{\\frac{3}{239}} \\\\\n \\frac{7}{\\sqrt{717}} \\\\\n \\sqrt{\\frac{3}{239}} \\\\\n -\\frac{11}{\\sqrt{717}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/6)],\n [2],\n [-(5/2)],\n [(7/6)],\n [(1/2)],\n [-(11/6)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & -5 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -5],\n [0, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 2 & -\\frac{3}{2} \\\\\n \\frac{5}{2} & 2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{4} & -6 \\\\\n 10 & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(3/2)],\n [(5/2), 2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -9 \\\\\n 5 \\\\\n -1 \\\\\n -3 \\\\\n 8 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 7 \\\\\n -2 \\\\\n 9 \\\\\n -8 \\\\\n -3 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$24$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-9],\n [5],\n [-1],\n [-3],\n [8],\n [0]])\nb = np.array([\n [4],\n [7],\n [-2],\n [9],\n [-8],\n [-3],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{2} \\\\\n \\frac{13}{16} \\\\\n -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -8 \\sqrt{\\frac{5}{357}} \\\\\n \\frac{13}{\\sqrt{1785}} \\\\\n -\\frac{4}{\\sqrt{1785}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2)],\n [(13/16)],\n [-(1/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, 0, \\frac{4}{3}}$ to the plane $\\frac{x}{3}-\\frac{4 y}{3}+\\frac{14 z}{3}-\\frac{1}{3}=0$.", - "Output Answer": [ - "$\\frac{47}{3 \\sqrt{213}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, 0, (4/3)\nplane = Poly((x/3)-((4*y)/3)+((14*z)/3)-(1/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{8}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 4 & -6 \\\\\n -7 & 4 & -5 \\\\\n 10 & -3 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{4} & -\\frac{7}{2} & \\frac{21}{4} \\\\\n \\frac{49}{8} & -\\frac{7}{2} & \\frac{35}{8} \\\\\n -\\frac{35}{4} & \\frac{21}{8} & -\\frac{49}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 4, -6],\n [-7, 4, -5],\n [10, -3, 7]])\nprint(a * -(7/8))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 1 \\\\\n 3 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-15 x+53$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 1],\n [3, 7]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-4, \\frac{11}{3}, -4}$ to the plane $-\\frac{5 x}{3}-\\frac{4 y}{3}+\\frac{13 z}{3}+\\frac{2}{3}=0$.", - "Output Answer": [ - "$\\frac{67 \\sqrt{\\frac{2}{105}}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -4, (11/3), -4\nplane = Poly(-((5*x)/3)-((4*y)/3)+((13*z)/3)+(2/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -7 & \\frac{3}{2} & 1 \\\\\n -\\frac{15}{2} & -\\frac{3}{2} & -1 \\\\\n -8 & 1 & -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6.25-3.419 i,-6.25+3.419 i,-3.5\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, (3/2), 1],\n [-(15/2), -(3/2), -1],\n [-8, 1, -(15/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -4 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -18 \\\\\n 21 \\\\\n -42 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [2],\n [-2]])\nb = np.array([\n [7],\n [-4],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -3 & 1 & -3 & 3 & 1 \\\\\n 0 & -3 & 0 & -1 & 1 \\\\\n 1 & 0 & -1 & -3 & -2 \\\\\n -1 & 0 & -1 & -1 & 1 \\\\\n -2 & -2 & -3 & 3 & 2 \\\\\n -3 & -1 & 3 & -1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.68 \\\\\n 1.2 \\\\\n 0.6 \\\\\n -1.49 \\\\\n -1.91 \\\\\n 0.92 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.175 \\\\\n -0.136 \\\\\n 0.006 \\\\\n 0.155 \\\\\n -0.714 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1, -3, 3, 1],\n [0, -3, 0, -1, 1],\n [1, 0, -1, -3, -2],\n [-1, 0, -1, -1, 1],\n [-2, -2, -3, 3, 2],\n [-3, -1, 3, -1, -1]])\nb = np.array([\n [1.68],\n [1.2],\n [0.6],\n [-1.49],\n [-1.91],\n [0.92]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{8}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 5 \\\\\n \\frac{5}{8} \\\\\n \\frac{5}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [1],\n [1]])\nprint(a * (5/8))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{3} & -\\frac{7}{6} \\\\\n \\frac{8}{3} & \\frac{1}{6} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{3} & -\\frac{8}{3} \\\\\n \\frac{28}{3} & \\frac{47}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{2}{3} & \\frac{3}{2} \\\\\n -\\frac{20}{3} & -\\frac{23}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/3), -(7/6)],\n [(8/3), (1/6)]])\nb = np.array([\n [-(5/3), -(8/3)],\n [(28/3), (47/6)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{22}{9} & \\frac{29}{9} & -\\frac{23}{9} \\\\\n -\\frac{4}{3} & \\frac{1}{9} & -\\frac{17}{9} \\\\\n -\\frac{17}{9} & -\\frac{23}{9} & \\frac{14}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1047}{2860} & -\\frac{159}{220} & -\\frac{141}{286} \\\\\n \\frac{183}{220} & \\frac{123}{220} & \\frac{15}{22} \\\\\n \\frac{879}{2860} & \\frac{3}{220} & \\frac{111}{286} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(22/9), (29/9), -(23/9)],\n [-(4/3), (1/9), -(17/9)],\n [-(17/9), -(23/9), (14/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$144$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [8]])\nb = np.array([\n [9],\n [9]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{9}{7} \\\\\n -\\frac{5}{7} \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{9}{\\sqrt{302}} \\\\\n -\\frac{5}{\\sqrt{302}} \\\\\n 7 \\sqrt{\\frac{2}{151}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/7)],\n [-(5/7)],\n [2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{29}{8} & -\\frac{23}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{61}{8} & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -4 & -\\frac{39}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/8), -(23/4)]])\nb = np.array([\n [(61/8), 4]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n \\frac{15}{2} \\\\\n -3 \\\\\n -6 \\\\\n -\\frac{13}{2} \\\\\n -\\frac{5}{2} \\\\\n \\frac{9}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{2} \\\\\n 9 \\\\\n \\frac{15}{2} \\\\\n 6 \\\\\n \\frac{3}{2} \\\\\n 6 \\\\\n -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{231}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2)],\n [(15/2)],\n [-3],\n [-6],\n [-(13/2)],\n [-(5/2)],\n [(9/2)]])\nb = np.array([\n [-(11/2)],\n [9],\n [(15/2)],\n [6],\n [(3/2)],\n [6],\n [-(15/2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -9 & -5 & -7 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-7.,0.,9.,0.\\}, \\{-5.,9.,0.,0.\\}, \\{-1.,0.,0.,3.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, -5, -7, -3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -\\frac{7}{3} \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3 \\sqrt{\\frac{2}{47}} \\\\\n -\\frac{7}{\\sqrt{94}} \\\\\n \\frac{3}{\\sqrt{94}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-(7/3)],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{2}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 4 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 5 \\\\\n 2 \\\\\n -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [4],\n [-9]])\nprint(a * (1/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{4} \\\\\n -2 \\\\\n -\\frac{11}{4} \\\\\n \\frac{3}{4} \\\\\n \\frac{7}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{5}{2 \\sqrt{67}} \\\\\n -\\frac{4}{\\sqrt{67}} \\\\\n -\\frac{11}{2 \\sqrt{67}} \\\\\n \\frac{3}{2 \\sqrt{67}} \\\\\n \\frac{7}{2 \\sqrt{67}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/4)],\n [-2],\n [-(11/4)],\n [(3/4)],\n [(7/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{1}{2},\\frac{1}{2}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [2]]).squeeze()\nb = np.array([\n [-2],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 2 \\\\\n -1 \\\\\n 2 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{3 \\sqrt{2}} \\\\\n \\frac{\\sqrt{2}}{3} \\\\\n -\\frac{1}{3 \\sqrt{2}} \\\\\n \\frac{\\sqrt{2}}{3} \\\\\n -\\frac{\\sqrt{2}}{3} \\\\\n \\frac{\\sqrt{2}}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [2],\n [-1],\n [2],\n [-2],\n [2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n -3 \\\\\n 2 \\\\\n 0 \\\\\n -2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -2 \\\\\n -1 \\\\\n 0 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{0,0,0,0,0,0\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [-3],\n [2],\n [0],\n [-2]]).squeeze()\nb = np.array([\n [-1],\n [-2],\n [-1],\n [0],\n [-2],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n \\frac{9}{2} \\\\\n -7 \\\\\n \\frac{11}{2} \\\\\n 8 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -10 \\\\\n -\\frac{1}{2} \\\\\n 3 \\\\\n -10 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{496}{\\sqrt{1159703}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2)],\n [(9/2)],\n [-7],\n [(11/2)],\n [8],\n [-8]]).squeeze()\nb = np.array([\n [10],\n [-10],\n [-(1/2)],\n [3],\n [-10],\n [3]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -2 \\\\\n 2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{2}} \\\\\n -\\frac{\\sqrt{2}}{3} \\\\\n \\frac{\\sqrt{2}}{3} \\\\\n -\\frac{1}{3 \\sqrt{2}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-2],\n [2],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{63}{8} \\\\\n \\frac{7}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{61}{8} \\\\\n \\frac{109}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{31}{2} \\\\\n \\frac{29}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(63/8)],\n [(7/16)]])\nb = np.array([\n [(61/8)],\n [(109/16)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -1 \\\\\n -\\frac{15}{2} \\\\\n -\\frac{7}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-1],\n [-(15/2)],\n [-(7/4)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,3,-4\\}, \\{3,4,5\\}, \\{1,-1,-2\\}}$.", - "Output Answer": [ - "$38 x+3 y-13 z-61=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, 3, -4],\n [3, 4, 5],\n [1, -1, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{4}{9} & -\\frac{82}{9} & -\\frac{67}{9} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{4}{9} & -\\frac{32}{9} & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{8}{9} & -\\frac{50}{9} & -\\frac{85}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/9), -(82/9), -(67/9)]])\nb = np.array([\n [-(4/9), -(32/9), 2]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{39}{4} \\\\\n \\frac{33}{4} \\\\\n -\\frac{21}{4} \\\\\n \\frac{13}{4} \\\\\n \\frac{27}{4} \\\\\n -\\frac{15}{2} \\\\\n \\frac{15}{4} \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{13}{2} \\\\\n \\frac{21}{4} \\\\\n -\\frac{5}{4} \\\\\n \\frac{3}{4} \\\\\n -\\frac{7}{4} \\\\\n -\\frac{7}{4} \\\\\n -5 \\\\\n -\\frac{15}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{1915}}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(39/4)],\n [(33/4)],\n [-(21/4)],\n [(13/4)],\n [(27/4)],\n [-(15/2)],\n [(15/4)],\n [-(5/2)]])\nb = np.array([\n [(13/2)],\n [(21/4)],\n [-(5/4)],\n [(3/4)],\n [-(7/4)],\n [-(7/4)],\n [-5],\n [-(15/4)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 0 & -2 \\\\\n -1 & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & -4 \\\\\n -2 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2],\n [-1, 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & -4 & 4 \\\\\n -8 & -7 & -7 \\\\\n 2 & -1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.819,-0.128,1.\\}, \\{3.032,-2.333,1.\\}, \\{7.087,22.061,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -4, 4],\n [-8, -7, -7],\n [2, -1, -2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -3 & 10 & 1 \\\\\n -8 & 2 & 1 \\\\\n 10 & 9 & 9 \\\\\n -5 & 8 & 4 \\\\\n -10 & -8 & 8 \\\\\n 6 & 9 & 1 \\\\\n 7 & -8 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 10, 1],\n [-8, 2, 1],\n [10, 9, 9],\n [-5, 8, 4],\n [-10, -8, 8],\n [6, 9, 1],\n [7, -8, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -2 \\\\\n -4 \\\\\n 6 \\\\\n -5 \\\\\n 5 \\\\\n -9 \\\\\n -6 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 7 \\\\\n 5 \\\\\n 0 \\\\\n -9 \\\\\n -1 \\\\\n -7 \\\\\n 1 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{367}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-2],\n [-4],\n [6],\n [-5],\n [5],\n [-9],\n [-6],\n [-4]])\nb = np.array([\n [-2],\n [7],\n [5],\n [0],\n [-9],\n [-1],\n [-7],\n [1],\n [4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{5}{3}, -\\frac{11}{3}, 1}$ to the plane $-\\frac{7 x}{3}-\\frac{8 y}{3}-\\frac{8 z}{3}-\\frac{5}{3}=0$.", - "Output Answer": [ - "$\\frac{14}{3 \\sqrt{177}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (5/3), -(11/3), 1\nplane = Poly(-((7*x)/3)-((8*y)/3)-((8*z)/3)-(5/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 8 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 7 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -51 \\\\\n 28 \\\\\n -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [8],\n [5]])\nb = np.array([\n [4],\n [7],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 10 & -2 & -4 & -2 \\\\\n 0 & -3 & 5 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1.,0.,0.,5.\\}, \\{11.,25.,15.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [10, -2, -4, -2],\n [0, -3, 5, 0]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,-4 \\log (2),3 \\log (2)\\}, \\{2 \\log (2),-4 \\log (2),0\\}, \\{-2 \\log (2),\\log (2),-3 \\log (2)\\}}$", - "Output Answer": [ - "${\\left\\{0,-\\frac{4}{5},\\frac{3}{5}\\right\\}, \\left\\{\\frac{5}{\\sqrt{61}},-\\frac{18}{5 \\sqrt{61}},-\\frac{24}{5 \\sqrt{61}}\\right\\}, \\left\\{-\\frac{6}{\\sqrt{61}},-\\frac{3}{\\sqrt{61}},-\\frac{4}{\\sqrt{61}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((0, -4*math.log(2), 3*math.log(2)), (2*math.log(2), -4*math.log(2), 0), (-2*math.log(2), math.log(2), -3*math.log(2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{8}{5}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -6 & 10 & 1 & 2 \\\\\n 4 & 7 & 5 & 5 \\\\\n -6 & 6 & 5 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{48}{5} & -16 & -\\frac{8}{5} & -\\frac{16}{5} \\\\\n -\\frac{32}{5} & -\\frac{56}{5} & -8 & -8 \\\\\n \\frac{48}{5} & -\\frac{48}{5} & -8 & \\frac{48}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 10, 1, 2],\n [4, 7, 5, 5],\n [-6, 6, 5, -6]])\nprint(a * -(8/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(\\sqrt{35}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [1],\n [-1],\n [-1],\n [0],\n [-1],\n [0],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [0],\n [-1],\n [1],\n [0],\n [-1],\n [0],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 4 & -9 & -9 & 10 \\\\\n 6 & -7 & 9 & -2 \\\\\n -6 & -5 & -10 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-548.,-79.,421.,527.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, -9, -9, 10],\n [6, -7, 9, -2],\n [-6, -5, -10, 1]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & 3 & -1 \\\\\n 2 & 3 & -2 \\\\\n -1 & 1 & 3 \\\\\n -2 & -1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.5 \\\\\n 0.88 \\\\\n -2.16 \\\\\n 0.1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -3.586 \\\\\n 1.056 \\\\\n -2.18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3, -1],\n [2, 3, -2],\n [-1, 1, 3],\n [-2, -1, 3]])\nb = np.array([\n [1.5],\n [0.88],\n [-2.16],\n [0.1]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & -\\frac{29}{3} & \\frac{16}{3} \\\\\n -7 & -\\frac{29}{3} & \\frac{28}{3} \\\\\n \\frac{25}{3} & \\frac{5}{3} & -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-18.533,3.1\\, -2.253 i,3.1\\, +2.253 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -(29/3), (16/3)],\n [-7, -(29/3), (28/3)],\n [(25/3), (5/3), -(5/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & 3 & 0 & 0 & 2 \\\\\n -1 & 2 & 1 & -1 & 1 \\\\\n -1 & -2 & -1 & 2 & 0 \\\\\n 0 & 2 & -2 & -2 & 0 \\\\\n 2 & -1 & 3 & 0 & 3 \\\\\n 2 & -3 & 0 & -1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.95 \\\\\n 2.09 \\\\\n 2.02 \\\\\n -1.32 \\\\\n -2.04 \\\\\n 1.38 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2.483 \\\\\n -1.295 \\\\\n 0.168 \\\\\n -1.347 \\\\\n 0.644 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, 0, 0, 2],\n [-1, 2, 1, -1, 1],\n [-1, -2, -1, 2, 0],\n [0, 2, -2, -2, 0],\n [2, -1, 3, 0, 3],\n [2, -3, 0, -1, -1]])\nb = np.array([\n [1.95],\n [2.09],\n [2.02],\n [-1.32],\n [-2.04],\n [1.38]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -3 & -2 & 2 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -2 & -2 \\\\\n -1 & -2 \\\\\n 1 & 0 \\\\\n 0 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 10 & 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2, 2, 0]])\nb = np.array([\n [-2, -2],\n [-1, -2],\n [1, 0],\n [0, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & 2 & 2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 4 & 4 & 4 & 0 \\\\\n -4 & -4 & -4 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-2]])\nb = np.array([\n [2, 2, 2, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{9} \\\\\n \\frac{13}{9} \\\\\n -\\frac{20}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{7}{\\sqrt{618}} \\\\\n \\frac{13}{\\sqrt{618}} \\\\\n -10 \\sqrt{\\frac{2}{309}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/9)],\n [(13/9)],\n [-(20/9)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -4 & 1 & -1 & -7 & -4 \\\\\n -4 & 1 & -3 & -8 & -5 \\\\\n 0 & 8 & 9 & -1 & -10 \\\\\n 9 & 7 & 8 & -1 & 8 \\\\\n 6 & -10 & -3 & -4 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, 1, -1, -7, -4],\n [-4, 1, -3, -8, -5],\n [0, 8, 9, -1, -10],\n [9, 7, 8, -1, 8],\n [6, -10, -3, -4, -7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -6 & -4 \\\\\n 5 & -9 \\\\\n -8 & 6 \\\\\n 7 & 9 \\\\\n 8 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -4],\n [5, -9],\n [-8, 6],\n [7, 9],\n [8, 7]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,1,-2\\}, \\{-4,4,-2\\}, \\{-3,1,1\\}}$.", - "Output Answer": [ - "$3 x+5 y+4 z=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, 1, -2],\n [-4, 4, -2],\n [-3, 1, 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & 4 & -4 \\\\\n -1 & 5 & 1 \\\\\n 2 & 1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$36$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 4, -4],\n [-1, 5, 1],\n [2, 1, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${2, -4, 4}$ to the plane $x-4 y-3 z+4=0$.", - "Output Answer": [ - "$5 \\sqrt{\\frac{2}{13}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 2, -4, 4\nplane = Poly(x-4*y-3*z+4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $3$ and the matrix\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 5 \\\\\n 4 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 24 \\\\\n 15 \\\\\n 12 \\\\\n 18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [5],\n [4],\n [6]])\nprint(a * 3)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{3} & \\frac{10}{3} & -4 \\\\\n \\frac{8}{3} & -\\frac{7}{3} & \\frac{4}{3} \\\\\n -\\frac{11}{3} & 0 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-4.377,2.088,10.622\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3), (10/3), -4],\n [(8/3), -(7/3), (4/3)],\n [-(11/3), 0, 9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -9 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-9],\n [2]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${4, 3, 2}$ to the plane $-5 x+2 y+5 z+3=0$.", - "Output Answer": [ - "$\\frac{1}{3 \\sqrt{6}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 4, 3, 2\nplane = Poly(-5*x+2*y+5*z+3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$16$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-2]])\nb = np.array([\n [3],\n [-8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -1 & \\frac{17}{3} & -\\frac{26}{3} & -\\frac{1}{3} \\\\\n \\frac{13}{2} & \\frac{1}{2} & -\\frac{2}{3} & -\\frac{17}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{25}{3} & -\\frac{13}{6} & 3 & -\\frac{11}{2} \\\\\n \\frac{28}{3} & \\frac{8}{3} & \\frac{29}{3} & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{22}{3} & \\frac{7}{2} & -\\frac{17}{3} & -\\frac{35}{6} \\\\\n \\frac{95}{6} & \\frac{19}{6} & 9 & -\\frac{13}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, (17/3), -(26/3), -(1/3)],\n [(13/2), (1/2), -(2/3), -(17/6)]])\nb = np.array([\n [(25/3), -(13/6), 3, -(11/2)],\n [(28/3), (8/3), (29/3), (2/3)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 3 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -17 \\\\\n 4 \\\\\n 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [2],\n [1]])\nb = np.array([\n [-3],\n [3],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & 1 \\\\\n -2 & -1 \\\\\n 3 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.02 \\\\\n -1.16 \\\\\n 2.64 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.713 \\\\\n 0.233 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1],\n [-2, -1],\n [3, 0]])\nb = np.array([\n [0.02],\n [-1.16],\n [2.64]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & -4 & 5 \\\\\n -5 & 5 & 1 \\\\\n 7 & 1 & -3 \\\\\n 10 & -2 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, -4, 5],\n [-5, 5, 1],\n [7, 1, -3],\n [10, -2, 3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 3 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -2 \\\\\n 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 20 \\\\\n 50 \\\\\n 14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [3],\n [-5]])\nb = np.array([\n [-2],\n [-2],\n [10]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4.291 \\\\\n 9.369 \\\\\n 9.457 \\\\\n -9.64 \\\\\n 9.878 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1.643 \\\\\n -7.325 \\\\\n -1.961 \\\\\n -1.591 \\\\\n 8.655 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$22.5955$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4.291],\n [9.369],\n [9.457],\n [-9.64],\n [9.878]])\nb = np.array([\n [1.643],\n [-7.325],\n [-1.961],\n [-1.591],\n [8.655]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 1 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{\\sqrt{2}}{3} \\\\\n \\frac{1}{3 \\sqrt{2}} \\\\\n -\\frac{1}{\\sqrt{2}} \\\\\n \\frac{\\sqrt{2}}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [1],\n [-3],\n [2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & -\\frac{28}{5} \\\\\n \\frac{17}{5} & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{34} i \\left(\\sqrt{1879}-5 i\\right),1\\right\\}, \\left\\{-\\frac{1}{34} i \\left(\\sqrt{1879}+5 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -(28/5)],\n [(17/5), -3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & -3 & -1 & -1 & 2 \\\\\n 3 & -2 & 1 & -2 & -1 \\\\\n 2 & 3 & 1 & 0 & 2 \\\\\n 0 & 0 & -1 & 0 & 0 \\\\\n -1 & 2 & -2 & 1 & -1 \\\\\n 1 & -1 & -1 & 0 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.37 \\\\\n 2.25 \\\\\n 2.59 \\\\\n -1.27 \\\\\n -1.37 \\\\\n -1.34 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.058 \\\\\n 0.309 \\\\\n 0.009 \\\\\n -1.661 \\\\\n 0.681 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -3, -1, -1, 2],\n [3, -2, 1, -2, -1],\n [2, 3, 1, 0, 2],\n [0, 0, -1, 0, 0],\n [-1, 2, -2, 1, -1],\n [1, -1, -1, 0, -2]])\nb = np.array([\n [2.37],\n [2.25],\n [2.59],\n [-1.27],\n [-1.37],\n [-1.34]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{11}{3}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 5 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{55}{3} & \\frac{22}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 2]])\nprint(a * (11/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -9 & 5 & 0 \\\\\n 8 & -5 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{10.,18.,5.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, 5, 0],\n [8, -5, 2]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n \\frac{20}{3} & \\frac{23}{3} & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(20/3), (23/3), -9]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{3}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & 6 & -4 & 7 \\\\\n 1 & 1 & 2 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -5 & 10 & -\\frac{20}{3} & \\frac{35}{3} \\\\\n \\frac{5}{3} & \\frac{5}{3} & \\frac{10}{3} & \\frac{50}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 6, -4, 7],\n [1, 1, 2, 10]])\nprint(a * (5/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 7 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 20 \\\\\n 90 \\\\\n -79 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [7],\n [10]])\nb = np.array([\n [9],\n [-2],\n [0]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & 8 & 2 \\\\\n 7 & -8 & 6 \\\\\n -4 & 8 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-7.337,-3.588,1.\\}, \\{0.845,-1.873,1.\\}, \\{2.742,1.711,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 8, 2],\n [7, -8, 6],\n [-4, 8, 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & 3 & -2 \\\\\n 1 & -2 & -4 \\\\\n -4 & -3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{18}{97} & -\\frac{3}{97} & -\\frac{16}{97} \\\\\n \\frac{13}{97} & -\\frac{14}{97} & -\\frac{10}{97} \\\\\n -\\frac{11}{97} & -\\frac{18}{97} & \\frac{1}{97} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 3, -2],\n [1, -2, -4],\n [-4, -3, 3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -6 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-28$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-6],\n [1]])\nb = np.array([\n [-3],\n [3],\n [2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n \\frac{19}{7} \\\\\n -\\frac{11}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{16}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{304}{49} \\\\\n \\frac{176}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/7)],\n [-(11/7)]])\nb = np.array([\n [-(16/7)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 9 \\\\\n 1 \\\\\n 6 \\\\\n -3 \\\\\n -5 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [9],\n [1],\n [6],\n [-3],\n [-5],\n [-5]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n \\frac{1}{3} & -\\frac{25}{6} & -\\frac{26}{3} & -\\frac{13}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/3), -(25/6), -(26/3), -(13/6)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{19}{16} \\\\\n -\\frac{113}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{37}{8} \\\\\n \\frac{29}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{55}{16} \\\\\n \\frac{3}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/16)],\n [-(113/16)]])\nb = np.array([\n [-(37/8)],\n [(29/4)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -2 & 4 & -8 \\\\\n -7 & -2 & 8 \\\\\n 5 & -8 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-5.096,-2.452-11.358 i,-2.452+11.358 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 4, -8],\n [-7, -2, 8],\n [5, -8, -6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 9 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 0 \\\\\n -3 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$40$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [9],\n [-2],\n [2]])\nb = np.array([\n [8],\n [0],\n [-3],\n [9]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{2}{7}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -6 & -3 & 7 & 2 \\\\\n -2 & -7 & -9 & 7 \\\\\n 2 & -7 & -9 & -10 \\\\\n 8 & 0 & 2 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{12}{7} & -\\frac{6}{7} & 2 & \\frac{4}{7} \\\\\n -\\frac{4}{7} & -2 & -\\frac{18}{7} & 2 \\\\\n \\frac{4}{7} & -2 & -\\frac{18}{7} & -\\frac{20}{7} \\\\\n \\frac{16}{7} & 0 & \\frac{4}{7} & \\frac{16}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -3, 7, 2],\n [-2, -7, -9, 7],\n [2, -7, -9, -10],\n [8, 0, 2, 8]])\nprint(a * (2/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 4 & 7 \\\\\n -3 & \\frac{15}{2} \\\\\n \\frac{1}{2} & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{2} & \\frac{19}{2} \\\\\n -5 & 7 \\\\\n -\\frac{7}{2} & \\frac{17}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2} & \\frac{33}{2} \\\\\n -8 & \\frac{29}{2} \\\\\n -3 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 7],\n [-3, (15/2)],\n [(1/2), -(7/2)]])\nb = np.array([\n [-(9/2), (19/2)],\n [-5, 7],\n [-(7/2), (17/2)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -3 & 8 & 8 & -2 \\\\\n -9 & -2 & 4 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{8.,-10.,13.,0.\\}, \\{12.,11.,0.,26.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, 8, 8, -2],\n [-9, -2, 4, 5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{5}{8} & \\frac{11}{16} & \\frac{21}{8} & -\\frac{27}{16} & -\\frac{5}{8} \\\\\n -\\frac{35}{16} & \\frac{45}{16} & \\frac{5}{4} & \\frac{5}{16} & \\frac{1}{4} \\\\\n \\frac{17}{16} & \\frac{9}{8} & -\\frac{21}{16} & \\frac{33}{16} & -\\frac{35}{16} \\\\\n \\frac{9}{4} & \\frac{5}{8} & -\\frac{1}{8} & \\frac{17}{16} & -\\frac{7}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{4} \\\\\n \\frac{33}{16} \\\\\n \\frac{5}{2} \\\\\n -\\frac{41}{16} \\\\\n \\frac{23}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{45}{4} \\\\\n \\frac{289}{32} \\\\\n -\\frac{309}{32} \\\\\n -\\frac{47}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/8), (11/16), (21/8), -(27/16), -(5/8)],\n [-(35/16), (45/16), (5/4), (5/16), (1/4)],\n [(17/16), (9/8), -(21/16), (33/16), -(35/16)],\n [(9/4), (5/8), -(1/8), (17/16), -(7/16)]])\nb = np.array([\n [-(1/4)],\n [(33/16)],\n [(5/2)],\n [-(41/16)],\n [(23/16)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{5} \\\\\n -\\frac{12}{5} \\\\\n \\frac{2}{5} \\\\\n \\frac{3}{5} \\\\\n \\frac{9}{5} \\\\\n \\frac{14}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{5} \\\\\n -2 \\\\\n \\frac{2}{5} \\\\\n \\frac{11}{5} \\\\\n -\\frac{7}{5} \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{81}{65},-\\frac{18}{13},\\frac{18}{65},\\frac{99}{65},-\\frac{63}{65},\\frac{18}{13}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/5)],\n [-(12/5)],\n [(2/5)],\n [(3/5)],\n [(9/5)],\n [(14/5)]]).squeeze()\nb = np.array([\n [-(9/5)],\n [-2],\n [(2/5)],\n [(11/5)],\n [-(7/5)],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{7}{3}, \\frac{14}{3}, 4}$ to the plane $\\frac{8 x}{3}+2 y+\\frac{2}{3}=0$.", - "Output Answer": [ - "$\\frac{73}{15}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (7/3), (14/3), 4\nplane = Poly(((8*x)/3)+2*y+(2/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{13}{7}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{26}{7} & \\frac{39}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3]])\nprint(a * -(13/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & -2 & -1 \\\\\n 6 & -5 & 0 \\\\\n -6 & -8 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-3.44-3.502 i,-3.44+3.502 i,8.88\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, -1],\n [6, -5, 0],\n [-6, -8, 8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{22}{5} & \\frac{17}{5} & \\frac{23}{5} \\\\\n \\frac{16}{5} & -\\frac{12}{5} & -\\frac{21}{5} \\\\\n -\\frac{11}{5} & \\frac{19}{5} & \\frac{7}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{525}{4303} & \\frac{530}{4303} & -\\frac{135}{4303} \\\\\n \\frac{595}{12909} & \\frac{2035}{12909} & \\frac{4150}{12909} \\\\\n \\frac{860}{12909} & -\\frac{3025}{12909} & -\\frac{2680}{12909} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(22/5), (17/5), (23/5)],\n [(16/5), -(12/5), -(21/5)],\n [-(11/5), (19/5), (7/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 \\\\\n -10 \\\\\n 9 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -6 \\\\\n 8 \\\\\n -7 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{87}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [3],\n [-10],\n [9],\n [-5]])\nb = np.array([\n [-1],\n [-6],\n [8],\n [-7],\n [6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & -8 & 7 \\\\\n 8 & -10 & -5 \\\\\n -10 & 8 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{2.688,3.142,1.\\}, \\{-0.64-0.87 i,-0.815+0.383 i,1.\\}, \\{-0.64+0.87 i,-0.815-0.383 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -8, 7],\n [8, -10, -5],\n [-10, 8, -3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{37}{5} & -\\frac{8}{5} & -8 \\\\\n \\frac{37}{5} & -\\frac{33}{5} & -\\frac{1}{5} \\\\\n \\frac{39}{5} & \\frac{34}{5} & \\frac{12}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-7.791,5.496\\, -9.171 i,5.496\\, +9.171 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/5), -(8/5), -8],\n [(37/5), -(33/5), -(1/5)],\n [(39/5), (34/5), (12/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -5 \\\\\n -9 \\\\\n -6 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-5],\n [-9],\n [-6],\n [-8]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,2,0\\}, \\{-2,2,0\\}, \\{3,0,-2\\}}$", - "Output Answer": [ - "${\\{0,1,0\\}, \\{-1,0,0\\}, \\{0,0,-1\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, 2, 0), (-2, 2, 0), (3, 0, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 6 & -2 \\\\\n 9 & -2 \\\\\n 6 & 1 \\\\\n -9 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [6, -2],\n [9, -2],\n [6, 1],\n [-9, -5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 1 & 3 \\\\\n 3 & -2 & 0 \\\\\n 1 & -1 & 0 \\\\\n 3 & 2 & -2 \\\\\n 3 & -3 & -3 \\\\\n 2 & -1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.98 \\\\\n -1.48 \\\\\n -0.55 \\\\\n -2.38 \\\\\n 0.42 \\\\\n -0.75 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.701 \\\\\n -0.567 \\\\\n -0.36 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 3],\n [3, -2, 0],\n [1, -1, 0],\n [3, 2, -2],\n [3, -3, -3],\n [2, -1, 3]])\nb = np.array([\n [-2.98],\n [-1.48],\n [-0.55],\n [-2.38],\n [0.42],\n [-0.75]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 4 \\log (2) \\\\\n -6 \\log (2) \\\\\n -6 \\log (2) \\\\\n 10 \\log (2) \\\\\n 5 \\log (2) \\\\\n 8 \\log (2) \\\\\n 3 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\log (2) \\\\\n -13 \\log (2) \\\\\n -4 \\log (2) \\\\\n -14 \\log (2) \\\\\n -10 \\log (2) \\\\\n -11 \\log (2) \\\\\n 8 \\log (2) \\\\\n 12 \\log (2) \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{1119} \\log (2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [4*math.log(2)],\n [-6*math.log(2)],\n [-6*math.log(2)],\n [10*math.log(2)],\n [5*math.log(2)],\n [8*math.log(2)],\n [3*math.log(2)]])\nb = np.array([\n [-5*math.log(2)],\n [-13*math.log(2)],\n [-4*math.log(2)],\n [-14*math.log(2)],\n [-10*math.log(2)],\n [-11*math.log(2)],\n [8*math.log(2)],\n [12*math.log(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 1 & 3 & 3 \\\\\n -6 & 6 & 2 \\\\\n 4 & -3 & -3 \\\\\n -6 & 6 & -9 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 1 & 8 & -7 \\\\\n 0 & -7 & -4 \\\\\n -3 & -7 & 3 \\\\\n 5 & 2 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & -5 & 10 \\\\\n -6 & 13 & 6 \\\\\n 7 & 4 & -6 \\\\\n -11 & 4 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3, 3],\n [-6, 6, 2],\n [4, -3, -3],\n [-6, 6, -9]])\nb = np.array([\n [1, 8, -7],\n [0, -7, -4],\n [-3, -7, 3],\n [5, 2, -7]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{2,-4,-\\frac{9}{2}\\right\\}, \\left\\{1,-5,-\\frac{7}{2}\\right\\}, \\left\\{-1,\\frac{3}{2},\\frac{1}{2}\\right\\}}$.", - "Output Answer": [ - "$42 x-8 y+34 z+37=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, -4, -(9/2)],\n [1, -5, -(7/2)],\n [-1, (3/2), (1/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -4 & -9 & -7 \\\\\n -1 & 4 & -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 6 & -2 & -9 \\\\\n 2 & 4 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 2 & -11 & -16 \\\\\n 1 & 8 & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -9, -7],\n [-1, 4, -5]])\nb = np.array([\n [6, -2, -9],\n [2, 4, -1]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n \\frac{9}{4} \\\\\n -\\frac{9}{2} \\\\\n -\\frac{3}{4} \\\\\n -\\frac{1}{4} \\\\\n -\\frac{39}{4} \\\\\n -\\frac{11}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{13}{2} \\\\\n \\frac{9}{2} \\\\\n \\frac{39}{4} \\\\\n \\frac{7}{2} \\\\\n -\\frac{33}{4} \\\\\n -\\frac{5}{2} \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{8609}}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [(9/4)],\n [-(9/2)],\n [-(3/4)],\n [-(1/4)],\n [-(39/4)],\n [-(11/4)]])\nb = np.array([\n [(13/2)],\n [(9/2)],\n [(39/4)],\n [(7/2)],\n [-(33/4)],\n [-(5/2)],\n [-9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 0 & 4 & 4 & 4 & 10 \\\\\n 1 & 6 & -2 & -9 & -7 \\\\\n 10 & -4 & 4 & 5 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{48.,5.,-115.,0.,44.\\}, \\{48.,71.,-159.,88.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, 4, 4, 4, 10],\n [1, 6, -2, -9, -7],\n [10, -4, 4, 5, 0]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 8 & -7 & 6 & 8 & -2 \\\\\n -8 & 1 & -7 & 0 & -7 \\\\\n 1 & -6 & 5 & -7 & -1 \\\\\n -5 & -2 & -2 & -9 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-629.,-104.,439.,275.,265.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [8, -7, 6, 8, -2],\n [-8, 1, -7, 0, -7],\n [1, -6, 5, -7, -1],\n [-5, -2, -2, -9, 0]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{2}{3}, -\\frac{1}{3}, -\\frac{10}{3}}$ to the plane $\\frac{8 x}{3}-y-\\frac{13 z}{3}-\\frac{14}{3}=0$.", - "Output Answer": [ - "$\\frac{107}{33 \\sqrt{2}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (2/3), -(1/3), -(10/3)\nplane = Poly(((8*x)/3)-y-((13*z)/3)-(14/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{21}{4} & \\frac{3}{4} \\\\\n \\frac{39}{4} & \\frac{35}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{4} \\left(7-\\sqrt{901}\\right),\\frac{1}{4} \\left(7+\\sqrt{901}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(21/4), (3/4)],\n [(39/4), (35/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0.21 \\\\\n 6.06 \\\\\n 0.3 \\\\\n -7.65 \\\\\n -1.82 \\\\\n 0.69 \\\\\n 1.06 \\\\\n 7.93 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6.93 \\\\\n -2.89 \\\\\n -6.56 \\\\\n -4.47 \\\\\n -6.68 \\\\\n -4.3 \\\\\n -3.86 \\\\\n 3.37 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$16.7861$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0.21],\n [6.06],\n [0.3],\n [-7.65],\n [-1.82],\n [0.69],\n [1.06],\n [7.93]])\nb = np.array([\n [-6.93],\n [-2.89],\n [-6.56],\n [-4.47],\n [-6.68],\n [-4.3],\n [-3.86],\n [3.37]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{2} & -2 & -\\frac{3}{2} \\\\\n -\\frac{1}{2} & \\frac{5}{2} & \\frac{1}{2} \\\\\n 3 & -\\frac{5}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{11}{4} & \\frac{15}{4} & \\frac{7}{2} \\\\\n \\frac{3}{2} & 6 & \\frac{7}{4} \\\\\n -\\frac{31}{4} & -11 & -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), -2, -(3/2)],\n [-(1/2), (5/2), (1/2)],\n [3, -(5/2), -(1/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,4,-2\\}, \\{4,1,-3\\}, \\{-3,1,3\\}}$.", - "Output Answer": [ - "$18 x+17 y+21 z-26=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, 4, -2],\n [4, 1, -3],\n [-3, 1, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{9}{2},4,\\frac{9}{2}\\right\\}, \\left\\{-\\frac{9}{2},-\\frac{7}{2},-\\frac{3}{2}\\right\\}, \\left\\{-\\frac{1}{2},4,-2\\right\\}}$.", - "Output Answer": [ - "$130 x-76 y-100 z+169=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(9/2), 4, (9/2)],\n [-(9/2), -(7/2), -(3/2)],\n [-(1/2), 4, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & -10 \\\\\n 6 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+3 x+20$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -10],\n [6, 5]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -8 & -3 & -8 & 1 & 1 \\\\\n 3 & 3 & 4 & 7 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -3, -8, 1, 1],\n [3, 3, 4, 7, -8]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 1 \\\\\n 3 \\\\\n 0 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 3 \\\\\n -3 \\\\\n -2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{118}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [1],\n [3],\n [0],\n [-5]])\nb = np.array([\n [-1],\n [3],\n [-3],\n [-2],\n [0]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5.2 \\\\\n 2.5 \\\\\n -9.5 \\\\\n 0. \\\\\n -3.7 \\\\\n 1.2 \\\\\n 5.3 \\\\\n -4.1 \\\\\n -7.7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3.6 \\\\\n -5.3 \\\\\n -9.7 \\\\\n -7.6 \\\\\n -7. \\\\\n -4. \\\\\n 1.5 \\\\\n -8.7 \\\\\n -9.8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$16.5535$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5.2],\n [2.5],\n [-9.5],\n [0.],\n [-3.7],\n [1.2],\n [5.3],\n [-4.1],\n [-7.7]])\nb = np.array([\n [3.6],\n [-5.3],\n [-9.7],\n [-7.6],\n [-7.],\n [-4.],\n [1.5],\n [-8.7],\n [-9.8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 4 & -\\frac{2}{3} & -\\frac{2}{3} \\\\\n \\frac{14}{3} & -\\frac{5}{3} & \\frac{5}{3} \\\\\n -\\frac{10}{3} & \\frac{11}{3} & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{24} & \\frac{13}{24} & \\frac{5}{24} \\\\\n -\\frac{5}{3} & \\frac{25}{12} & \\frac{11}{12} \\\\\n -\\frac{13}{12} & \\frac{7}{6} & \\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -(2/3), -(2/3)],\n [(14/3), -(5/3), (5/3)],\n [-(10/3), (11/3), -5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -1 & -5 & -2 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-5.,1.,0.,0.\\}, \\{-2.,0.,1.,0.\\}, \\{7.,0.,0.,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, -5, -2, 7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{2} \\\\\n \\frac{11}{4} \\\\\n \\frac{17}{8} \\\\\n -\\frac{1}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -10 \\sqrt{\\frac{2}{587}} \\\\\n 11 \\sqrt{\\frac{2}{587}} \\\\\n \\frac{17}{\\sqrt{1174}} \\\\\n -\\frac{1}{\\sqrt{1174}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2)],\n [(11/4)],\n [(17/8)],\n [-(1/8)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{8} & -\\frac{31}{16} & -\\frac{11}{16} \\\\\n \\frac{25}{16} & -\\frac{45}{16} & -\\frac{35}{16} \\\\\n -\\frac{19}{16} & \\frac{27}{16} & -\\frac{5}{8} \\\\\n \\frac{19}{16} & \\frac{5}{4} & -\\frac{31}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n \\frac{9}{16} & -\\frac{5}{2} & -\\frac{9}{8} & -\\frac{31}{16} & -\\frac{9}{16} \\\\\n -\\frac{21}{16} & -\\frac{35}{16} & -\\frac{13}{16} & 2 & \\frac{23}{8} \\\\\n \\frac{11}{8} & -\\frac{23}{16} & \\frac{35}{16} & \\frac{27}{16} & \\frac{41}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n \\frac{499}{256} & \\frac{469}{128} & -\\frac{81}{128} & -\\frac{1599}{256} & -\\frac{1967}{256} \\\\\n \\frac{25}{16} & \\frac{345}{64} & -\\frac{545}{128} & -\\frac{395}{32} & -\\frac{1865}{128} \\\\\n -\\frac{479}{128} & \\frac{45}{256} & -\\frac{359}{256} & \\frac{1183}{256} & \\frac{1003}{256} \\\\\n -\\frac{931}{256} & -\\frac{747}{256} & -\\frac{1687}{256} & -\\frac{393}{128} & -\\frac{261}{128} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/8), -(31/16), -(11/16)],\n [(25/16), -(45/16), -(35/16)],\n [-(19/16), (27/16), -(5/8)],\n [(19/16), (5/4), -(31/16)]])\nb = np.array([\n [(9/16), -(5/2), -(9/8), -(31/16), -(9/16)],\n [-(21/16), -(35/16), -(13/16), 2, (23/8)],\n [(11/8), -(23/16), (35/16), (27/16), (41/16)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -9 & -7 & -3 \\\\\n -1 & 2 & 7 \\\\\n 4 & -6 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-9.882,1.441\\, -7.443 i,1.441\\, +7.443 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -7, -3],\n [-1, 2, 7],\n [4, -6, 0]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{15}{32}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 8 & -9 & -5 & -2 \\\\\n 9 & -10 & 1 & -6 \\\\\n -5 & 3 & -10 & -1 \\\\\n 4 & 1 & -4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{15}{4} & -\\frac{135}{32} & -\\frac{75}{32} & -\\frac{15}{16} \\\\\n \\frac{135}{32} & -\\frac{75}{16} & \\frac{15}{32} & -\\frac{45}{16} \\\\\n -\\frac{75}{32} & \\frac{45}{32} & -\\frac{75}{16} & -\\frac{15}{32} \\\\\n \\frac{15}{8} & \\frac{15}{32} & -\\frac{15}{8} & -\\frac{45}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -9, -5, -2],\n [9, -10, 1, -6],\n [-5, 3, -10, -1],\n [4, 1, -4, -3]])\nprint(a * (15/32))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,3,5\\}, \\left\\{-\\frac{5}{2},-\\frac{1}{2},\\frac{5}{2}\\right\\}, \\left\\{-1,-\\frac{7}{2},0\\right\\}}$.", - "Output Answer": [ - "$5 x-50 y+63 z-170=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, 3, 5],\n [-(5/2), -(1/2), (5/2)],\n [-1, -(7/2), 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{3}{2}, 3, \\frac{7}{2}}$ to the plane $\\frac{x}{2}+4 y+z+4=0$.", - "Output Answer": [ - "$\\frac{27 \\sqrt{\\frac{3}{23}}}{2}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (3/2), 3, (7/2)\nplane = Poly((x/2)+4*y+z+4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, \\frac{1}{3}, 4}$ to the plane $x-\\frac{10 y}{3}-z-\\frac{2}{3}=0$.", - "Output Answer": [ - "$\\frac{25}{3 \\sqrt{118}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, (1/3), 4\nplane = Poly(x-((10*y)/3)-z-(2/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -5 & 4 & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 2 & 1 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -3 & 5 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 4, 3]])\nb = np.array([\n [2, 1, -3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{2}{3} & -\\frac{1}{3} & -\\frac{1}{3} \\\\\n 3 & -4 & -\\frac{13}{3} \\\\\n -2 & \\frac{14}{3} & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{397}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3), -(1/3), -(1/3)],\n [3, -4, -(13/3)],\n [-2, (14/3), 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -4 & 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 5 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 6]])\nb = np.array([\n [5, -6]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 3 & -2 & 1 & -3 \\\\\n 2 & 2 & 2 & 3 \\\\\n 3 & 3 & -3 & 1 \\\\\n 1 & -2 & -3 & 3 \\\\\n -3 & -2 & -3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.12 \\\\\n -2.78 \\\\\n 2.14 \\\\\n 1.97 \\\\\n 2.75 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.048 \\\\\n -0.118 \\\\\n -0.925 \\\\\n -0.243 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2, 1, -3],\n [2, 2, 2, 3],\n [3, 3, -3, 1],\n [1, -2, -3, 3],\n [-3, -2, -3, 3]])\nb = np.array([\n [0.12],\n [-2.78],\n [2.14],\n [1.97],\n [2.75]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{2} & \\frac{1}{2} \\\\\n -\\frac{3}{4} & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{32}{115} & -\\frac{4}{115} \\\\\n \\frac{6}{115} & \\frac{28}{115} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2), (1/2)],\n [-(3/4), 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{7}{e},\\frac{4}{e},0\\right\\}, \\left\\{\\frac{1}{e},-\\frac{3}{e},0\\right\\}, \\left\\{-\\frac{7}{e},-\\frac{6}{e},-\\frac{6}{e}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{7}{\\sqrt{65}},\\frac{4}{\\sqrt{65}},0\\right\\}, \\left\\{-\\frac{4}{\\sqrt{65}},-\\frac{7}{\\sqrt{65}},0\\right\\}, \\{0,0,-1\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-(7/math.e), (4/math.e), 0), ((1/math.e), -(3/math.e), 0), (-(7/math.e), -(6/math.e), -(6/math.e))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 2 \\\\\n 1 \\\\\n -1 \\\\\n -2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\sqrt{\\frac{2}{5}} \\\\\n \\frac{1}{\\sqrt{10}} \\\\\n -\\frac{1}{\\sqrt{10}} \\\\\n -\\sqrt{\\frac{2}{5}} \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [2],\n [1],\n [-1],\n [-2],\n [0]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{202}{25} \\\\\n \\frac{189}{100} \\\\\n \\frac{779}{100} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{913}{100} \\\\\n -\\frac{453}{50} \\\\\n \\frac{114}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{395979}{5000} \\\\\n \\frac{43187}{400} \\\\\n \\frac{559491}{10000} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(202/25)],\n [(189/100)],\n [(779/100)]])\nb = np.array([\n [(913/100)],\n [-(453/50)],\n [(114/25)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 1 & -1 & -1 & 3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & -1 & -1 & 3 & -2 \\\\\n -2 & 2 & 2 & -6 & 4 \\\\\n 2 & -2 & -2 & 6 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-2],\n [2]])\nb = np.array([\n [1, -1, -1, 3, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{20}{3} \\\\\n \\frac{29}{3} \\\\\n 7 \\\\\n -\\frac{1}{3} \\\\\n -\\frac{25}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n \\frac{25}{3} \\\\\n -\\frac{26}{3} \\\\\n -\\frac{17}{3} \\\\\n -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{921}{2 \\sqrt{1451155}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/3)],\n [(29/3)],\n [7],\n [-(1/3)],\n [-(25/3)]]).squeeze()\nb = np.array([\n [-10],\n [(25/3)],\n [-(26/3)],\n [-(17/3)],\n [-(5/3)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{4} \\\\\n -\\frac{31}{4} \\\\\n -\\frac{13}{4} \\\\\n -\\frac{13}{4} \\\\\n \\frac{1}{4} \\\\\n \\frac{27}{4} \\\\\n -\\frac{3}{2} \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/4)],\n [-(31/4)],\n [-(13/4)],\n [-(13/4)],\n [(1/4)],\n [(27/4)],\n [-(3/2)],\n [8]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,3,-1\\}, \\{2,-3,-2\\}, \\{3,-2,-1\\}}$", - "Output Answer": [ - "${\\left\\{0,\\frac{3}{\\sqrt{10}},-\\frac{1}{\\sqrt{10}}\\right\\}, \\left\\{\\frac{2 \\sqrt{10}}{11},-\\frac{9}{11 \\sqrt{10}},-\\frac{27}{11 \\sqrt{10}}\\right\\}, \\left\\{\\frac{9}{11},\\frac{2}{11},\\frac{6}{11}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, 3, -1), (2, -3, -2), (3, -2, -1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{17}{\\sqrt{1378}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [6]]).squeeze()\nb = np.array([\n [5],\n [9]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 10 & 3 \\\\\n 0 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-9,10\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 3],\n [0, -9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 7 & 8 & 0 \\\\\n -3 & 8 & 0 \\\\\n -1 & 8 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, 8, 0],\n [-3, 8, 0],\n [-1, 8, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & -8 & -4 \\\\\n 0 & -7 & -9 \\\\\n 1 & 3 & 5 \\\\\n -8 & 2 & -4 \\\\\n -1 & 10 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [6, -8, -4],\n [0, -7, -9],\n [1, 3, 5],\n [-8, 2, -4],\n [-1, 10, -8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,0,4\\}, \\{4,4,-5\\}, \\{-5,0,-5\\}}$.", - "Output Answer": [ - "$36 x-81 y-4 z+160=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, 0, 4],\n [4, 4, -5],\n [-5, 0, -5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -4 & 5 & -4 \\\\\n 7 & 9 & 7 \\\\\n -9 & 9 & 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+15 x^2+120 x-1349$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 5, -4],\n [7, 9, 7],\n [-9, 9, 10]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -2 & -4 & 6 & -2 & 9 \\\\\n 10 & -2 & -9 & -1 & 7 \\\\\n 7 & 10 & 4 & 5 & -4 \\\\\n 4 & -7 & 3 & 10 & -4 \\\\\n -9 & 0 & 1 & -6 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, -4, 6, -2, 9],\n [10, -2, -9, -1, 7],\n [7, 10, 4, 5, -4],\n [4, -7, 3, 10, -4],\n [-9, 0, 1, -6, 4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -5 & 5 & 0 \\\\\n -9 & -2 & 4 \\\\\n -4 & -8 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-10 x^2-108 x-405$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 5, 0],\n [-9, -2, 4],\n [-4, -8, -3]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & 7 & 1 \\\\\n 0 & -2 & -5 \\\\\n -1 & -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-2.222,0.613,6.61\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 7, 1],\n [0, -2, -5],\n [-1, -1, 1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{3} \\\\\n -\\frac{2}{3} \\\\\n -\\frac{13}{6} \\\\\n -\\frac{1}{6} \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2 \\sqrt{\\frac{2}{119}} \\\\\n -2 \\sqrt{\\frac{2}{119}} \\\\\n -\\frac{13}{\\sqrt{238}} \\\\\n -\\frac{1}{\\sqrt{238}} \\\\\n -3 \\sqrt{\\frac{2}{119}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3)],\n [-(2/3)],\n [-(13/6)],\n [-(1/6)],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${0, 1, -5}$ to the plane $\\frac{x}{2}-\\frac{y}{2}+4 z+5=0$.", - "Output Answer": [ - "$\\frac{31}{\\sqrt{66}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 0, 1, -5\nplane = Poly((x/2)-(y/2)+4*z+5, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & 4 & 4 \\\\\n -6 & 0 & -9 \\\\\n 9 & 8 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8.326,1.663\\, -9.535 i,1.663\\, +9.535 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 4, 4],\n [-6, 0, -9],\n [9, 8, -2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -6 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -8 \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -4 \\\\\n -23 \\\\\n -102 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-6],\n [1]])\nb = np.array([\n [-5],\n [-8],\n [2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{20}{3} \\\\\n -9 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{13}{3} \\\\\n -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{7}{3} \\\\\n 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(20/3)],\n [-9]])\nb = np.array([\n [(13/3)],\n [-10]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 8 & 1 & 8 & 3 & 10 \\\\\n -2 & 2 & -3 & -9 & -6 \\\\\n -4 & 3 & 7 & -5 & -8 \\\\\n -10 & 1 & 0 & -4 & -10 \\\\\n 2 & -10 & 5 & -8 & -5 \\\\\n -1 & -3 & 5 & -1 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, 1, 8, 3, 10],\n [-2, 2, -3, -9, -6],\n [-4, 3, 7, -5, -8],\n [-10, 1, 0, -4, -10],\n [2, -10, 5, -8, -5],\n [-1, -3, 5, -1, -10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-5, -2, -1}$ to the plane $2 x-\\frac{z}{2}+\\frac{1}{2}=0$.", - "Output Answer": [ - "$\\frac{18}{\\sqrt{17}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -5, -2, -1\nplane = Poly(2*x-(z/2)+(1/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -3 & 0 \\\\\n 1 & 0 & -1 \\\\\n 0 & 0 & 1 \\\\\n 3 & 3 & 1 \\\\\n -3 & 2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.92 \\\\\n 2.7 \\\\\n 1.63 \\\\\n 0.23 \\\\\n -2.34 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.983 \\\\\n -0.791 \\\\\n -0.583 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -3, 0],\n [1, 0, -1],\n [0, 0, 1],\n [3, 3, 1],\n [-3, 2, -3]])\nb = np.array([\n [1.92],\n [2.7],\n [1.63],\n [0.23],\n [-2.34]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -10 & 9 & 8 \\\\\n 1 & -8 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & -\\frac{19}{71} \\\\\n 0 & 1 & \\frac{42}{71} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, 9, 8],\n [1, -8, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\sqrt{2} \\\\\n \\sqrt{2} \\\\\n 2 \\sqrt{2} \\\\\n 4 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\sqrt{2} \\\\\n -7 \\sqrt{2} \\\\\n 0 \\\\\n 2 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-12$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-7*math.sqrt(2)],\n [math.sqrt(2)],\n [2*math.sqrt(2)],\n [4*math.sqrt(2)]])\nb = np.array([\n [math.sqrt(2)],\n [-7*math.sqrt(2)],\n [0],\n [2*math.sqrt(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 2 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 9 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 91 \\\\\n -67 \\\\\n -25 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [2],\n [-9]])\nb = np.array([\n [8],\n [9],\n [5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-3$ and the matrix\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -10 \\\\\n 9 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -30 \\\\\n 30 \\\\\n -27 \\\\\n 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-10],\n [9],\n [-2]])\nprint(a * -3)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -6 & 2 & -3 \\\\\n 7 & -9 & -3 \\\\\n -3 & -2 & 9 \\\\\n -4 & -5 & -3 \\\\\n 5 & 1 & 0 \\\\\n 1 & -7 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-6, 2, -3],\n [7, -9, -3],\n [-3, -2, 9],\n [-4, -5, -3],\n [5, 1, 0],\n [1, -7, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{7} \\\\\n -\\frac{38}{7} \\\\\n -\\frac{44}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{58}{7} \\\\\n -\\frac{40}{7} \\\\\n \\frac{9}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2102}{49} \\\\\n -\\frac{2516}{49} \\\\\n \\frac{2364}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/7)],\n [-(38/7)],\n [-(44/7)]])\nb = np.array([\n [(58/7)],\n [-(40/7)],\n [(9/7)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 5 \\\\\n 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -53 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [1],\n [0]])\nb = np.array([\n [3],\n [5],\n [0]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -3 & 4 & 1 \\\\\n 3 & -3 & 4 \\\\\n 2 & -1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{7}{26} & \\frac{3}{26} & \\frac{19}{26} \\\\\n \\frac{11}{26} & \\frac{1}{26} & \\frac{15}{26} \\\\\n \\frac{3}{26} & \\frac{5}{26} & -\\frac{3}{26} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 4, 1],\n [3, -3, 4],\n [2, -1, -1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,-1,-2\\}, \\{-5,5,3\\}, \\{-3,2,-5\\}}$.", - "Output Answer": [ - "$11 x+10 y-z+8=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, -1, -2],\n [-5, 5, 3],\n [-3, 2, -5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & 5 \\\\\n 3 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{6-\\sqrt{15},6+\\sqrt{15}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 5],\n [3, 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -2 & -2 & 7 \\\\\n 8 & -6 & -4 \\\\\n 3 & 4 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 3 & -2 & 6 \\\\\n -3 & 7 & 5 \\\\\n 0 & 0 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & -4 & 13 \\\\\n 5 & 1 & 1 \\\\\n 3 & 4 & 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2, 7],\n [8, -6, -4],\n [3, 4, 0]])\nb = np.array([\n [3, -2, 6],\n [-3, 7, 5],\n [0, 0, 9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{141}{16} \\\\\n -\\frac{43}{16} \\\\\n \\frac{77}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{141}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(141/16)],\n [-(43/16)],\n [(77/16)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -6 & -2 & -5 & -6 & 4 \\\\\n -8 & 0 & -4 & 9 & 10 \\\\\n 7 & -3 & 4 & -4 & 2 \\\\\n 9 & 6 & 9 & 4 & 10 \\\\\n 10 & -2 & -8 & -1 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-6, -2, -5, -6, 4],\n [-8, 0, -4, 9, 10],\n [7, -3, 4, -4, 2],\n [9, 6, 9, 4, 10],\n [10, -2, -8, -1, -10]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-4]])\nb = np.array([\n [-3],\n [-5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -1 & -9 & -8 & 2 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-9.,1.,0.,0.,0.\\}, \\{-8.,0.,1.,0.,0.\\}, \\{2.,0.,0.,1.,0.\\}, \\{7.,0.,0.,0.,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, -9, -8, 2, 7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -4 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -8 \\\\\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -36 \\\\\n 81 \\\\\n 64 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-4],\n [0]])\nb = np.array([\n [-2],\n [-8],\n [9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{14}{3} & -\\frac{14}{3} \\\\\n -2 & \\frac{13}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{266}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(14/3), -(14/3)],\n [-2, (13/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n 1 \\\\\n \\frac{7}{4} \\\\\n 1 \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2}{\\sqrt{185}} \\\\\n \\frac{4}{\\sqrt{185}} \\\\\n \\frac{7}{\\sqrt{185}} \\\\\n \\frac{4}{\\sqrt{185}} \\\\\n -2 \\sqrt{\\frac{5}{37}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2)],\n [1],\n [(7/4)],\n [1],\n [-(5/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\log (2) \\\\\n 8 \\log (2) \\\\\n -8 \\log (2) \\\\\n -7 \\log (2) \\\\\n 12 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\log (2) \\\\\n -5 \\log (2) \\\\\n 6 \\log (2) \\\\\n 3 \\log (2) \\\\\n -10 \\log (2) \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-256 \\log ^2(2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-9*math.log(2)],\n [8*math.log(2)],\n [-8*math.log(2)],\n [-7*math.log(2)],\n [12*math.log(2)]])\nb = np.array([\n [3*math.log(2)],\n [-5*math.log(2)],\n [6*math.log(2)],\n [3*math.log(2)],\n [-10*math.log(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -4 & -8 & -5 \\\\\n 9 & 9 & 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 9 & 4 & -5 \\\\\n 1 & -4 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 5 & -4 & -10 \\\\\n 10 & 5 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -8, -5],\n [9, 9, 9]])\nb = np.array([\n [9, 4, -5],\n [1, -4, -4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{8} \\\\\n -\\frac{5}{8} \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{8} \\\\\n -\\frac{23}{8} \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{63}{16} \\\\\n -\\frac{13}{16} \\\\\n -\\frac{31}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/8)],\n [-(5/8)],\n [-(1/2)]])\nb = np.array([\n [-(11/8)],\n [-(23/8)],\n [4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -3 \\\\\n 8 \\\\\n -4 \\\\\n 5 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 1 \\\\\n 6 \\\\\n -7 \\\\\n 4 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{69}{\\sqrt{11407}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-3],\n [8],\n [-4],\n [5],\n [-7]]).squeeze()\nb = np.array([\n [2],\n [1],\n [6],\n [-7],\n [4],\n [-9]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,2,3\\}, \\{-2,3,-4\\}, \\{-5,4,-4\\}}$.", - "Output Answer": [ - "$7 x+21 y+3 z-37=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, 2, 3],\n [-2, 3, -4],\n [-5, 4, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 10 & -2 & -3 & 1 \\\\\n 3 & -8 & 0 & -1 \\\\\n -10 & 2 & 0 & -5 \\\\\n 8 & -3 & 5 & 5 \\\\\n 1 & 8 & 4 & -1 \\\\\n 2 & -7 & 4 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, -2, -3, 1],\n [3, -8, 0, -1],\n [-10, 2, 0, -5],\n [8, -3, 5, 5],\n [1, 8, 4, -1],\n [2, -7, 4, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -10 & 1 & 10 & 3 \\\\\n 0 & 7 & 4 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{2.,5.,0.,5.\\}, \\{33.,-20.,35.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, 1, 10, 3],\n [0, 7, 4, -7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{10} & \\frac{49}{10} \\\\\n -\\frac{17}{5} & \\frac{1}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{5}{418} & -\\frac{245}{836} \\\\\n \\frac{85}{418} & \\frac{15}{836} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/10), (49/10)],\n [-(17/5), (1/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [0],\n [1]]).squeeze()\nb = np.array([\n [1],\n [1],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{33}{8} & -\\frac{25}{4} & \\frac{39}{4} \\\\\n -7 & -\\frac{25}{4} & \\frac{17}{8} \\\\\n \\frac{73}{8} & -\\frac{37}{8} & \\frac{25}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{23}{4} & -\\frac{61}{8} & \\frac{25}{4} \\\\\n -\\frac{33}{8} & -\\frac{29}{4} & -\\frac{5}{8} \\\\\n -\\frac{35}{4} & 1 & -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{13}{8} & \\frac{11}{8} & \\frac{7}{2} \\\\\n -\\frac{23}{8} & 1 & \\frac{11}{4} \\\\\n \\frac{143}{8} & -\\frac{45}{8} & \\frac{85}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(33/8), -(25/4), (39/4)],\n [-7, -(25/4), (17/8)],\n [(73/8), -(37/8), (25/8)]])\nb = np.array([\n [-(23/4), -(61/8), (25/4)],\n [-(33/8), -(29/4), -(5/8)],\n [-(35/4), 1, -(15/2)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{23}{9} \\\\\n -3 \\\\\n \\frac{16}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{23}{\\sqrt{1514}} \\\\\n -\\frac{27}{\\sqrt{1514}} \\\\\n 8 \\sqrt{\\frac{2}{757}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/9)],\n [-3],\n [(16/9)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 7 & -7 & -4 \\\\\n -4 & -5 & -6 \\\\\n -4 & -3 & 6 \\\\\n -1 & -4 & -4 \\\\\n 4 & -5 & -2 \\\\\n -6 & -2 & -6 \\\\\n -3 & 0 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, -7, -4],\n [-4, -5, -6],\n [-4, -3, 6],\n [-1, -4, -4],\n [4, -5, -2],\n [-6, -2, -6],\n [-3, 0, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{\\sqrt{2}} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-5$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.sqrt(2)]])\nb = np.array([\n [-(5/(math.sqrt(2)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{1}{\\sqrt{5}},\\frac{3}{\\sqrt{5}},-\\frac{4}{\\sqrt{5}}\\right\\}, \\left\\{\\frac{3}{\\sqrt{5}},-\\frac{1}{\\sqrt{5}},\\frac{1}{\\sqrt{5}}\\right\\}, \\left\\{-\\frac{3}{\\sqrt{5}},0,\\frac{1}{\\sqrt{5}}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{26}},\\frac{3}{\\sqrt{26}},-2 \\sqrt{\\frac{2}{13}}\\right\\}, \\left\\{\\frac{41}{3 \\sqrt{195}},-\\frac{7}{3 \\sqrt{195}},\\frac{\\sqrt{\\frac{5}{39}}}{3}\\right\\}, \\left\\{\\frac{1}{3 \\sqrt{30}},\\frac{13}{3 \\sqrt{30}},\\frac{\\sqrt{\\frac{10}{3}}}{3}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((1/(math.sqrt(5))), (3/(math.sqrt(5))), -(4/(math.sqrt(5)))), ((3/(math.sqrt(5))), -(1/(math.sqrt(5))), (1/(math.sqrt(5)))), (-(3/(math.sqrt(5))), 0, (1/(math.sqrt(5))))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{61}{10} & -\\frac{11}{10} & -\\frac{21}{10} \\\\\n -7 & -\\frac{37}{10} & -\\frac{73}{10} \\\\\n \\frac{5}{2} & \\frac{33}{10} & 0 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{26}{5} & \\frac{31}{5} & \\frac{31}{10} \\\\\n -\\frac{9}{5} & -8 & -\\frac{7}{2} \\\\\n -\\frac{11}{5} & -5 & -\\frac{87}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{113}{10} & -\\frac{73}{10} & -\\frac{26}{5} \\\\\n -\\frac{26}{5} & \\frac{43}{10} & -\\frac{19}{5} \\\\\n \\frac{47}{10} & \\frac{83}{10} & \\frac{87}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(61/10), -(11/10), -(21/10)],\n [-7, -(37/10), -(73/10)],\n [(5/2), (33/10), 0]])\nb = np.array([\n [(26/5), (31/5), (31/10)],\n [-(9/5), -8, -(7/2)],\n [-(11/5), -5, -(87/10)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -7 & 9 & 0 \\\\\n 4 & -6 & 6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -6 & 7 & 10 \\\\\n -9 & 0 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & 2 & -10 \\\\\n 13 & -6 & 15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 9, 0],\n [4, -6, 6]])\nb = np.array([\n [-6, 7, 10],\n [-9, 0, -9]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\sqrt{3} \\\\\n -3 \\sqrt{3} \\\\\n -4 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n 2 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n 0 \\\\\n 3 \\sqrt{3} \\\\\n 5 \\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n -\\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-141$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [4*math.sqrt(3)],\n [-3*math.sqrt(3)],\n [-4*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [2*math.sqrt(3)],\n [4*math.sqrt(3)]])\nb = np.array([\n [math.sqrt(3)],\n [math.sqrt(3)],\n [0],\n [3*math.sqrt(3)],\n [5*math.sqrt(3)],\n [-2*math.sqrt(3)],\n [-math.sqrt(3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{9}{4} \\\\\n -\\frac{5}{4} \\\\\n \\frac{9}{4} \\\\\n -\\frac{7}{4} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n \\frac{5}{4} \\\\\n -\\frac{5}{4} \\\\\n -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{9}{13},\\frac{15}{52},-\\frac{15}{52},-\\frac{3}{52}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/4)],\n [-(5/4)],\n [(9/4)],\n [-(7/4)]]).squeeze()\nb = np.array([\n [3],\n [(5/4)],\n [-(5/4)],\n [-(1/4)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{10}{9} \\\\\n \\frac{11}{9} \\\\\n 3 \\\\\n -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{10}{\\sqrt{959}} \\\\\n \\frac{11}{\\sqrt{959}} \\\\\n \\frac{27}{\\sqrt{959}} \\\\\n -\\frac{3}{\\sqrt{959}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(10/9)],\n [(11/9)],\n [3],\n [-(1/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -1 \\\\\n 1 & 2 \\\\\n 3 & -1 \\\\\n 0 & 2 \\\\\n 0 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.28 \\\\\n -2.33 \\\\\n -1.57 \\\\\n -2.73 \\\\\n -0.1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.293 \\\\\n -0.383 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1],\n [1, 2],\n [3, -1],\n [0, 2],\n [0, 3]])\nb = np.array([\n [-1.28],\n [-2.33],\n [-1.57],\n [-2.73],\n [-0.1]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -9 & 4 \\\\\n 5 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+14 x+25$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 4],\n [5, -5]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 0 & -6 & 6 & -7 \\\\\n -2 & 0 & 7 & -2 \\\\\n -5 & -2 & 9 & 1 \\\\\n -2 & -8 & 10 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, -6, 6, -7],\n [-2, 0, 7, -2],\n [-5, -2, 9, 1],\n [-2, -8, 10, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [5]])\nb = np.array([\n [5],\n [5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -3 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{2 \\sqrt{5}} \\\\\n -\\frac{3}{2 \\sqrt{5}} \\\\\n \\frac{1}{2 \\sqrt{5}} \\\\\n 0 \\\\\n 0 \\\\\n \\frac{1}{2 \\sqrt{5}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-3],\n [1],\n [0],\n [0],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{2,3,-2\\}, \\{1,1,2\\}, \\{1,-5,4\\}}$.", - "Output Answer": [ - "$10 x+y+3 z-17=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, 3, -2],\n [1, 1, 2],\n [1, -5, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{2}{5}, \\frac{22}{5}, \\frac{9}{5}}$ to the plane $-\\frac{21 x}{5}-\\frac{24 y}{5}-\\frac{23 z}{5}-\\frac{9}{5}=0$.", - "Output Answer": [ - "$\\frac{411 \\sqrt{\\frac{2}{773}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (2/5), (22/5), (9/5)\nplane = Poly(-((21*x)/5)-((24*y)/5)-((23*z)/5)-(9/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -8 \\\\\n 8 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -5 \\\\\n 5 \\\\\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1 \\\\\n -13 \\\\\n 13 \\\\\n 18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-8],\n [8],\n [9]])\nb = np.array([\n [-4],\n [-5],\n [5],\n [9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 9 & -5 & 4 & -8 \\\\\n -6 & 10 & 9 & -7 \\\\\n 10 & 9 & -1 & -2 \\\\\n 7 & -6 & 0 & 6 \\\\\n 10 & -5 & 9 & 2 \\\\\n -7 & 9 & 9 & 4 \\\\\n -6 & -7 & -5 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, -5, 4, -8],\n [-6, 10, 9, -7],\n [10, 9, -1, -2],\n [7, -6, 0, 6],\n [10, -5, 9, 2],\n [-7, 9, 9, 4],\n [-6, -7, -5, 7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{8}{\\pi },\\frac{1}{\\pi },-\\frac{5}{\\pi }\\right\\}, \\left\\{-\\frac{9}{\\pi },\\frac{5}{\\pi },-\\frac{2}{\\pi }\\right\\}, \\left\\{\\frac{4}{\\pi },\\frac{3}{\\pi },\\frac{5}{\\pi }\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{4 \\sqrt{\\frac{2}{5}}}{3},\\frac{1}{3 \\sqrt{10}},-\\frac{\\sqrt{\\frac{5}{2}}}{3}\\right\\}, \\left\\{-\\frac{59 \\sqrt{\\frac{2}{3695}}}{3},\\frac{169}{3 \\sqrt{7390}},-\\frac{31 \\sqrt{\\frac{5}{1478}}}{3}\\right\\}, \\left\\{\\frac{23}{3 \\sqrt{739}},\\frac{61}{3 \\sqrt{739}},\\frac{49}{3 \\sqrt{739}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((8/math.pi), (1/math.pi), -(5/math.pi)), (-(9/math.pi), (5/math.pi), -(2/math.pi)), ((4/math.pi), (3/math.pi), (5/math.pi))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 10 & 9 \\\\\n -9 & 4 \\\\\n -7 & 4 \\\\\n -5 & 9 \\\\\n 3 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [10, 9],\n [-9, 4],\n [-7, 4],\n [-5, 9],\n [3, 4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-45$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [5*math.sqrt(3)]])\nb = np.array([\n [-3*math.sqrt(3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & 3 & 0 \\\\\n 4 & 4 & -3 \\\\\n 0 & 1 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-106$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 3, 0],\n [4, 4, -3],\n [0, 1, 5]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{55}{7} & -\\frac{36}{7} & -\\frac{2}{7} & \\frac{51}{7} \\\\\n -\\frac{64}{7} & -\\frac{57}{7} & \\frac{26}{7} & -\\frac{52}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{12}{7} & \\frac{37}{7} & \\frac{30}{7} & \\frac{51}{7} \\\\\n -\\frac{15}{7} & -\\frac{33}{7} & \\frac{55}{7} & -\\frac{52}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{43}{7} & \\frac{1}{7} & 4 & \\frac{102}{7} \\\\\n -\\frac{79}{7} & -\\frac{90}{7} & \\frac{81}{7} & -\\frac{104}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(55/7), -(36/7), -(2/7), (51/7)],\n [-(64/7), -(57/7), (26/7), -(52/7)]])\nb = np.array([\n [(12/7), (37/7), (30/7), (51/7)],\n [-(15/7), -(33/7), (55/7), -(52/7)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 5 & 9 \\\\\n 2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(5-\\sqrt{97}\\right),\\frac{1}{2} \\left(5+\\sqrt{97}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 9],\n [2, 0]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 0 & 1 & 7 \\\\\n -2 & 3 & 1 \\\\\n -8 & 6 & -10 \\\\\n -6 & -5 & 2 \\\\\n 0 & -10 & 1 \\\\\n 0 & -8 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, 1, 7],\n [-2, 3, 1],\n [-8, 6, -10],\n [-6, -5, 2],\n [0, -10, 1],\n [0, -8, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -6 & -9 \\\\\n -6 & -2 \\\\\n 3 & 5 \\\\\n -10 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-6, -9],\n [-6, -2],\n [3, 5],\n [-10, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-1,2,-1\\}, \\{-3,1,1\\}, \\{0,-3,1\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{6}},\\sqrt{\\frac{2}{3}},-\\frac{1}{\\sqrt{6}}\\right\\}, \\left\\{-\\frac{7}{5 \\sqrt{3}},-\\frac{1}{5 \\sqrt{3}},\\frac{1}{\\sqrt{3}}\\right\\}, \\left\\{-\\frac{3}{5 \\sqrt{2}},-\\frac{2 \\sqrt{2}}{5},-\\frac{1}{\\sqrt{2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, 2, -1), (-3, 1, 1), (0, -3, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -10 & 9 & -6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -7 & -7 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -3 & 16 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 9, -6]])\nb = np.array([\n [-7, -7, -2]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 2 & 0 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -4 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2]])\nb = np.array([\n [2, 0, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{5} & \\frac{18}{5} & -4 \\\\\n \\frac{18}{5} & \\frac{24}{5} & -\\frac{14}{5} \\\\\n -\\frac{23}{5} & -\\frac{23}{5} & -\\frac{13}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{14222}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/5), (18/5), -4],\n [(18/5), (24/5), -(14/5)],\n [-(23/5), -(23/5), -(13/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n \\frac{17}{3} & \\frac{20}{3} & \\frac{28}{3} & -\\frac{1}{3} & -\\frac{5}{3} \\\\\n \\frac{22}{3} & -\\frac{28}{3} & -\\frac{7}{3} & -\\frac{17}{3} & -\\frac{16}{3} \\\\\n -6 & \\frac{16}{3} & \\frac{13}{3} & -\\frac{4}{3} & -7 \\\\\n \\frac{26}{3} & -\\frac{13}{3} & -1 & -4 & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/3), (20/3), (28/3), -(1/3), -(5/3)],\n [(22/3), -(28/3), -(7/3), -(17/3), -(16/3)],\n [-6, (16/3), (13/3), -(4/3), -7],\n [(26/3), -(13/3), -1, -4, -(1/3)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, -\\frac{17}{5}, 0}$ to the plane $\\frac{22 x}{5}-\\frac{16 y}{5}+\\frac{14 z}{5}+\\frac{14}{5}=0$.", - "Output Answer": [ - "$\\frac{61}{15 \\sqrt{26}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, -(17/5), 0\nplane = Poly(((22*x)/5)-((16*y)/5)+((14*z)/5)+(14/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -10 & -8 & 5 & -2 \\\\\n -10 & 6 & -9 & -4 \\\\\n -6 & 1 & 3 & -8 \\\\\n 6 & 7 & -2 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, -8, 5, -2],\n [-10, 6, -9, -4],\n [-6, 1, 3, -8],\n [6, 7, -2, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & 2 \\\\\n -9 & \\frac{19}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{6},1\\right\\}, \\left\\{\\frac{4}{3},1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 2],\n [-9, (19/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{5}{2} & 1 & -1 & 0 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{2} \\\\\n -1 \\\\\n -\\frac{5}{2} \\\\\n -\\frac{3}{2} \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), 1, -1, 0, -(3/2)]])\nb = np.array([\n [-(5/2)],\n [-1],\n [-(5/2)],\n [-(3/2)],\n [-(1/2)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${1, \\frac{7}{3}, \\frac{4}{3}}$ to the plane $\\frac{8 x}{3}-\\frac{5 y}{3}+\\frac{13 z}{3}-\\frac{10}{3}=0$.", - "Output Answer": [ - "$\\frac{11}{3 \\sqrt{258}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 1, (7/3), (4/3)\nplane = Poly(((8*x)/3)-((5*y)/3)+((13*z)/3)-(10/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(2 \\sqrt{14}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [1],\n [-1],\n [-1],\n [-1],\n [-1],\n [0],\n [1],\n [0]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [1],\n [-1],\n [0],\n [-1],\n [1],\n [0],\n [-1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & -\\frac{36}{5} \\\\\n 7 & \\frac{14}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(29-i \\sqrt{5039}\\right),\\frac{1}{10} \\left(29+i \\sqrt{5039}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -(36/5)],\n [7, (14/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -8 & -2 & -4 & 9 \\\\\n 3 & -10 & 3 & 6 \\\\\n -7 & 5 & -10 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -2, -4, 9],\n [3, -10, 3, 6],\n [-7, 5, -10, 5]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 1 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -8 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 65 \\\\\n 35 \\\\\n -40 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [1],\n [9]])\nb = np.array([\n [0],\n [-8],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 3 & -4 \\\\\n -3 & 0 \\\\\n -3 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 8 & 7 \\\\\n 7 & -9 \\\\\n -5 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 11 & 3 \\\\\n 4 & -9 \\\\\n -8 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -4],\n [-3, 0],\n [-3, -2]])\nb = np.array([\n [8, 7],\n [7, -9],\n [-5, 9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 8 \\\\\n -9 \\\\\n 9 \\\\\n 2 \\\\\n -3 \\\\\n 5 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -6 \\\\\n 2 \\\\\n -3 \\\\\n -6 \\\\\n 2 \\\\\n 0 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-33$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [8],\n [-9],\n [9],\n [2],\n [-3],\n [5],\n [6]])\nb = np.array([\n [-3],\n [-6],\n [2],\n [-3],\n [-6],\n [2],\n [0],\n [8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{15}{2} \\\\\n \\frac{9}{2} \\\\\n -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{2} \\\\\n -\\frac{3}{2} \\\\\n -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{57}{4} \\\\\n \\frac{225}{4} \\\\\n \\frac{45}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/2)],\n [(9/2)],\n [-(13/2)]])\nb = np.array([\n [-(15/2)],\n [-(3/2)],\n [-1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{5}{2}, 4}$ to the line $\\frac{3 x}{2}+\\frac{5 y}{2}-1=0$.", - "Output Answer": [ - "$\\frac{21}{2 \\sqrt{34}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(5/2), 4\nline = Poly(((3*x)/2)+((5*y)/2)-1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{2}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -4 & 0 & 4 & -8 \\\\\n 4 & -2 & 5 & -6 \\\\\n -5 & -8 & -5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 6 & 0 & -6 & 12 \\\\\n -6 & 3 & -\\frac{15}{2} & 9 \\\\\n \\frac{15}{2} & 12 & \\frac{15}{2} & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 0, 4, -8],\n [4, -2, 5, -6],\n [-5, -8, -5, -4]])\nprint(a * -(3/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n 1 & 2 & -1 & -9 \\\\\n -3 & 8 & -8 & 6 \\\\\n 6 & -8 & 1 & -5 \\\\\n -10 & -2 & 3 & -2 \\\\\n 2 & 7 & 6 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, -1, -9],\n [-3, 8, -8, 6],\n [6, -8, 1, -5],\n [-10, -2, 3, -2],\n [2, 7, 6, 8]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 5 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 4 \\\\\n 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 13 \\\\\n -11 \\\\\n -47 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [5],\n [-2]])\nb = np.array([\n [7],\n [4],\n [1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -\\frac{1}{4} \\\\\n \\frac{1}{4} \\\\\n \\frac{7}{4} \\\\\n \\frac{7}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & -\\frac{5}{2} \\\\\n \\frac{1}{8} & -\\frac{5}{8} \\\\\n -\\frac{1}{8} & \\frac{5}{8} \\\\\n -\\frac{7}{8} & \\frac{35}{8} \\\\\n -\\frac{7}{8} & \\frac{35}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-(1/4)],\n [(1/4)],\n [(7/4)],\n [(7/4)]])\nb = np.array([\n [-(1/2), (5/2)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -\\frac{47}{5} & -\\frac{13}{5} & \\frac{27}{5} & \\frac{49}{5} \\\\\n -\\frac{31}{5} & -\\frac{47}{5} & \\frac{36}{5} & \\frac{28}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(47/5), -(13/5), (27/5), (49/5)],\n [-(31/5), -(47/5), (36/5), (28/5)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,2,-4\\}, \\{-1,-4,1\\}, \\{3,3,1\\}}$.", - "Output Answer": [ - "$35 x-20 y-31 z-14=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, 2, -4],\n [-1, -4, 1],\n [3, 3, 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -4 & -\\frac{5}{2} & \\frac{17}{2} \\\\\n \\frac{1}{2} & -\\frac{11}{2} & -3 \\\\\n -\\frac{19}{2} & 1 & -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6.329,-5.836-8.935 i,-5.836+8.935 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -(5/2), (17/2)],\n [(1/2), -(11/2), -3],\n [-(19/2), 1, -(17/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & 5 \\\\\n -6 & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{24} i \\left(\\sqrt{471}-3 i\\right),1\\right\\}, \\left\\{-\\frac{1}{24} i \\left(\\sqrt{471}+3 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 5],\n [-6, -(5/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & 10 & 8 \\\\\n \\frac{3}{2} & \\frac{19}{2} & \\frac{17}{2} \\\\\n -\\frac{1}{2} & -\\frac{5}{2} & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+19 x^2-118 x+\\frac{639}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), 10, 8],\n [(3/2), (19/2), (17/2)],\n [-(1/2), -(5/2), 7]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [0],\n [1],\n [1],\n [1],\n [-1]]).squeeze()\nb = np.array([\n [1],\n [-1],\n [0],\n [-1],\n [0],\n [0],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{2,-1,0\\}, \\{1,3,-2\\}, \\{3,2,-1\\}}$.", - "Output Answer": [ - "$2 x-3 y-7 z-7=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, -1, 0],\n [1, 3, -2],\n [3, 2, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -9 & 1 \\\\\n -\\frac{23}{4} & -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{29 x}{2}+\\frac{221}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 1],\n [-(23/4), -(11/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 3 & 3 & 1 & 2 \\\\\n -1 & -2 & -1 & 0 \\\\\n 3 & 1 & -1 & 3 \\\\\n -3 & 3 & 1 & -1 \\\\\n 3 & -3 & -1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.66 \\\\\n -2.29 \\\\\n -2.91 \\\\\n 1.8 \\\\\n 1.79 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2.391 \\\\\n 1.943 \\\\\n -3.986 \\\\\n -5.338 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3, 1, 2],\n [-1, -2, -1, 0],\n [3, 1, -1, 3],\n [-3, 3, 1, -1],\n [3, -3, -1, 1]])\nb = np.array([\n [-1.66],\n [-2.29],\n [-2.91],\n [1.8],\n [1.79]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -8 & -\\frac{9}{2} & -9 \\\\\n -\\frac{13}{2} & 8 & -1 \\\\\n 0 & -\\frac{11}{2} & -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{17 x^2}{2}+\\frac{395 x}{4}+\\frac{4119}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -(9/2), -9],\n [-(13/2), 8, -1],\n [0, -(11/2), -(17/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{7}{5}, -\\frac{12}{5}, -\\frac{14}{5}}$ to the plane $\\frac{2 x}{5}+\\frac{16 y}{5}-\\frac{16 z}{5}-\\frac{7}{5}=0$.", - "Output Answer": [ - "$\\frac{11}{10 \\sqrt{129}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (7/5), -(12/5), -(14/5)\nplane = Poly(((2*x)/5)+((16*y)/5)-((16*z)/5)-(7/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 2 \\\\\n -3 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{1-\\sqrt{43},1+\\sqrt{43}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 2],\n [-3, -6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 5+i & -3 i \\\\\n 2-2 i & 5+5 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 18+4 i & 18-30 i \\\\\n 32-8 i & -6+44 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5+ 1j, -3j],\n [2-2j, 5+5j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -1 & 9 \\\\\n -\\frac{36}{5} & -\\frac{44}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(-49-3 i \\sqrt{551}\\right),\\frac{1}{10} \\left(-49+3 i \\sqrt{551}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 9],\n [-(36/5), -(44/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,3,3\\}, \\{-5,3,2\\}, \\{0,0,1\\}}$.", - "Output Answer": [ - "$x+3 y-4 z+4=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, 3, 3],\n [-5, 3, 2],\n [0, 0, 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -2 & 4 & -5 \\\\\n -2 & -2 & 10 \\\\\n 1 & 5 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{5.,0.,1.\\}, \\{0.64,1.961,1.\\}, \\{0.897,-0.869,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 4, -5],\n [-2, -2, 10],\n [1, 5, -8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & 0 \\\\\n -3 & 2 \\\\\n -2 & 2 \\\\\n 1 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.36 \\\\\n -2.32 \\\\\n -1.54 \\\\\n -2.59 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.095 \\\\\n -0.847 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0],\n [-3, 2],\n [-2, 2],\n [1, 0]])\nb = np.array([\n [-1.36],\n [-2.32],\n [-1.54],\n [-2.59]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-1$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 7 & 8 & -7 \\\\\n -3 & -2 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -7 & -8 & 7 \\\\\n 3 & 2 & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 8, -7],\n [-3, -2, 6]])\nprint(a * -1)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & 4 & -2 \\\\\n -4 & 2 & -2 \\\\\n 0 & 1 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-64$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 4, -2],\n [-4, 2, -2],\n [0, 1, -5]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{39}{8} & \\frac{3}{16} & \\frac{17}{16} \\\\\n \\frac{9}{8} & \\frac{9}{8} & -\\frac{11}{4} \\\\\n \\frac{53}{16} & \\frac{5}{2} & \\frac{7}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{18112}{94539} & -\\frac{4768}{94539} & \\frac{1168}{31513} \\\\\n \\frac{22688}{94539} & \\frac{24680}{94539} & \\frac{8336}{31513} \\\\\n \\frac{624}{31513} & -\\frac{8744}{31513} & \\frac{3888}{31513} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(39/8), (3/16), (17/16)],\n [(9/8), (9/8), -(11/4)],\n [(53/16), (5/2), (7/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 0 & 9 & 0 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -6 & -1 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 6 & 10 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 9, 0]])\nb = np.array([\n [-6, -1, -1]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 3 \\\\\n -3 \\\\\n -1 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\sqrt{\\frac{3}{11}} \\\\\n \\sqrt{\\frac{3}{11}} \\\\\n -\\sqrt{\\frac{3}{11}} \\\\\n -\\frac{1}{\\sqrt{33}} \\\\\n -\\frac{2}{\\sqrt{33}} \\\\\n \\frac{1}{\\sqrt{33}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [3],\n [-3],\n [-1],\n [-2],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{16}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -8 & 4 & -9 \\\\\n -3 & 1 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{2} & \\frac{1}{4} & -\\frac{9}{16} \\\\\n -\\frac{3}{16} & \\frac{1}{16} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 4, -9],\n [-3, 1, 8]])\nprint(a * (1/16))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 3 & -\\frac{43}{6} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{28}{3} & -\\frac{29}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{37}{3} & -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -(43/6)]])\nb = np.array([\n [-(28/3), -(29/6)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 10 & 6 & -1 & 1 \\\\\n 0 & -1 & -9 & -3 \\\\\n 4 & -5 & -1 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & -\\frac{3}{10} \\\\\n 0 & 1 & 0 & \\frac{39}{55} \\\\\n 0 & 0 & 1 & \\frac{14}{55} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, 6, -1, 1],\n [0, -1, -9, -3],\n [4, -5, -1, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(2 \\sqrt{3}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [1],\n [1],\n [0],\n [0],\n [0],\n [0],\n [0]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [1],\n [0],\n [0],\n [-1],\n [0],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 4 & -2 & -1 & -3 \\\\\n 0 & 9 & -3 & 4 \\\\\n 4 & 4 & 7 & -8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 2 & 6 & -9 & -8 \\\\\n -2 & -2 & -3 & -6 \\\\\n 4 & -4 & 9 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 2 & -8 & 8 & 5 \\\\\n 2 & 11 & 0 & 10 \\\\\n 0 & 8 & -2 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -2, -1, -3],\n [0, 9, -3, 4],\n [4, 4, 7, -8]])\nb = np.array([\n [2, 6, -9, -8],\n [-2, -2, -3, -6],\n [4, -4, 9, -6]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 0 \\\\\n -3 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6,8\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 0],\n [-3, -6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{59}{7} \\\\\n \\frac{9}{7} \\\\\n 6 \\\\\n -\\frac{3}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{5335}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(59/7)],\n [(9/7)],\n [6],\n [-(3/7)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -3 & -7 & -9 & 0 \\\\\n 6 & -7 & -5 & 4 \\\\\n 3 & -2 & -8 & 7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 4 & -4 & -9 & -3 \\\\\n 2 & 6 & 6 & 2 \\\\\n 6 & -5 & -8 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -7 & -3 & 0 & 3 \\\\\n 4 & -13 & -11 & 2 \\\\\n -3 & 3 & 0 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -7, -9, 0],\n [6, -7, -5, 4],\n [3, -2, -8, 7]])\nb = np.array([\n [4, -4, -9, -3],\n [2, 6, 6, 2],\n [6, -5, -8, 9]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(\\sqrt{37}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [5]]).squeeze()\nb = np.array([\n [7],\n [-7]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -1 & 7 \\\\\n 5 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+2 x-34$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 7],\n [5, -1]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -2 & 3 & 8 \\\\\n 10 & 9 & -5 \\\\\n -3 & 9 & -3 \\\\\n 5 & -7 & 2 \\\\\n -6 & 0 & 9 \\\\\n 2 & -6 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, 3, 8],\n [10, 9, -5],\n [-3, 9, -3],\n [5, -7, 2],\n [-6, 0, 9],\n [2, -6, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & -7 \\\\\n 4 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+8 x+44$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -7],\n [4, -4]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{19}{7} \\\\\n \\frac{12}{7} \\\\\n -\\frac{6}{7} \\\\\n -\\frac{5}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{19}{\\sqrt{566}} \\\\\n 6 \\sqrt{\\frac{2}{283}} \\\\\n -3 \\sqrt{\\frac{2}{283}} \\\\\n -\\frac{5}{\\sqrt{566}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/7)],\n [(12/7)],\n [-(6/7)],\n [-(5/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 10 & 5 & -2 \\\\\n -3 & \\frac{26}{3} & \\frac{26}{3} \\\\\n \\frac{16}{3} & \\frac{8}{3} & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.425,-0.662,1.\\}, \\{2.203,0.863,1.\\}, \\{2.384,-0.976,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 5, -2],\n [-3, (26/3), (26/3)],\n [(16/3), (8/3), -3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & 2 & 0 \\\\\n -2 & -2 & -1 \\\\\n 2 & -3 & -2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 4 & 6 & 8 \\\\\n 2 & -14 & -11 \\\\\n -18 & -49 & -30 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, 0],\n [-2, -2, -1],\n [2, -3, -2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -1 \\\\\n 4 \\\\\n 3 \\\\\n -5 \\\\\n -2 \\\\\n 0 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-1],\n [4],\n [3],\n [-5],\n [-2],\n [0],\n [-4]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7.5 \\\\\n -3.6 \\\\\n -2.7 \\\\\n -6.4 \\\\\n -7.3 \\\\\n 2.7 \\\\\n -5. \\\\\n 6.9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8.1 \\\\\n 2.1 \\\\\n -0.2 \\\\\n 3.6 \\\\\n -3.4 \\\\\n -6.7 \\\\\n 8.7 \\\\\n 2.5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-110.33$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7.5],\n [-3.6],\n [-2.7],\n [-6.4],\n [-7.3],\n [2.7],\n [-5.],\n [6.9]])\nb = np.array([\n [8.1],\n [2.1],\n [-0.2],\n [3.6],\n [-3.4],\n [-6.7],\n [8.7],\n [2.5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-1,-3,-2\\}, \\{-1,1,3\\}, \\{-1,-2,3\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{14}},-\\frac{3}{\\sqrt{14}},-\\sqrt{\\frac{2}{7}}\\right\\}, \\left\\{-\\frac{11}{3 \\sqrt{35}},-\\frac{\\sqrt{\\frac{5}{7}}}{3},\\frac{13}{3 \\sqrt{35}}\\right\\}, \\left\\{\\frac{7}{3 \\sqrt{10}},-\\frac{\\sqrt{\\frac{5}{2}}}{3},\\frac{2 \\sqrt{\\frac{2}{5}}}{3}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, -3, -2), (-1, 1, 3), (-1, -2, 3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 4 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 2 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -24 \\\\\n -50 \\\\\n 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [4],\n [2]])\nb = np.array([\n [-5],\n [2],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -\\frac{13}{5} & -\\frac{8}{5} \\\\\n -\\frac{2}{5} & \\frac{8}{5} \\\\\n -2 & \\frac{8}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{4}{5} & -\\frac{11}{5} & -1 \\\\\n -\\frac{4}{5} & -\\frac{13}{5} & -\\frac{7}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{84}{25} & \\frac{247}{25} & \\frac{121}{25} \\\\\n -\\frac{24}{25} & -\\frac{82}{25} & -\\frac{46}{25} \\\\\n \\frac{8}{25} & \\frac{6}{25} & -\\frac{6}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/5), -(8/5)],\n [-(2/5), (8/5)],\n [-2, (8/5)]])\nb = np.array([\n [-(4/5), -(11/5), -1],\n [-(4/5), -(13/5), -(7/5)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 9 & 5 & -6 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-5.,9.,0.,0.\\}, \\{-1.,0.,0.,1.\\}, \\{2.,0.,3.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, 5, -6, 9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -3 & 2 & \\frac{1}{2} \\\\\n \\frac{5}{2} & -3 & 1 \\\\\n -2 & -\\frac{3}{2} & 1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 13 & -\\frac{51}{4} & 1 \\\\\n -17 & \\frac{25}{2} & -\\frac{3}{4} \\\\\n \\frac{1}{4} & -1 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2, (1/2)],\n [(5/2), -3, 1],\n [-2, -(3/2), 1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\sqrt{3} \\\\\n -\\frac{7}{\\sqrt{3}} \\\\\n -4 \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n \\frac{13}{\\sqrt{3}} \\\\\n -\\frac{2}{\\sqrt{3}} \\\\\n -\\frac{10}{\\sqrt{3}} \\\\\n -\\frac{10}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{\\sqrt{3}} \\\\\n -\\sqrt{3} \\\\\n -\\frac{7}{\\sqrt{3}} \\\\\n \\frac{8}{\\sqrt{3}} \\\\\n -4 \\sqrt{3} \\\\\n -\\frac{4}{\\sqrt{3}} \\\\\n -\\frac{1}{\\sqrt{3}} \\\\\n -\\frac{2}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{4}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.sqrt(3)],\n [-(7/(math.sqrt(3)))],\n [-4*math.sqrt(3)],\n [math.sqrt(3)],\n [(13/(math.sqrt(3)))],\n [-(2/(math.sqrt(3)))],\n [-(10/(math.sqrt(3)))],\n [-(10/(math.sqrt(3)))]])\nb = np.array([\n [-(5/(math.sqrt(3)))],\n [-math.sqrt(3)],\n [-(7/(math.sqrt(3)))],\n [(8/(math.sqrt(3)))],\n [-4*math.sqrt(3)],\n [-(4/(math.sqrt(3)))],\n [-(1/(math.sqrt(3)))],\n [-(2/(math.sqrt(3)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -4 & -3 & 0 \\\\\n 0 & 1 & 1 \\\\\n 0 & -5 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-32$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -3, 0],\n [0, 1, 1],\n [0, -5, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\pi \\\\\n 0 \\\\\n -3 \\pi \\\\\n \\pi \\\\\n 3 \\pi \\\\\n -\\pi \\\\\n -\\pi \\\\\n -\\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\pi \\\\\n -3 \\pi \\\\\n 0 \\\\\n 0 \\\\\n 2 \\pi \\\\\n -3 \\pi \\\\\n -\\pi \\\\\n 2 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{37} \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-math.pi],\n [0],\n [-3*math.pi],\n [math.pi],\n [3*math.pi],\n [-math.pi],\n [-math.pi],\n [-math.pi]])\nb = np.array([\n [-3*math.pi],\n [-3*math.pi],\n [0],\n [0],\n [2*math.pi],\n [-3*math.pi],\n [-math.pi],\n [2*math.pi]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & 2 & -1 & 2 \\\\\n -3 & -1 & -3 & 2 \\\\\n 3 & -1 & 3 & -2 \\\\\n -2 & 2 & 3 & 2 \\\\\n -3 & 3 & -3 & 1 \\\\\n 3 & 1 & 0 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.57 \\\\\n -1.29 \\\\\n 0.89 \\\\\n 0.97 \\\\\n 0.58 \\\\\n 2.5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.464 \\\\\n 0.583 \\\\\n 0.058 \\\\\n 0.301 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2, -1, 2],\n [-3, -1, -3, 2],\n [3, -1, 3, -2],\n [-2, 2, 3, 2],\n [-3, 3, -3, 1],\n [3, 1, 0, 2]])\nb = np.array([\n [1.57],\n [-1.29],\n [0.89],\n [0.97],\n [0.58],\n [2.5]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{2}-\\frac{7 i}{2} & 2+\\frac{7 i}{2} \\\\\n -1+\\frac{7 i}{2} & -3+\\frac{5 i}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 261-\\frac{1181 i}{8} & -\\frac{239}{8}+\\frac{833 i}{8} \\\\\n -\\frac{689}{8}+\\frac{371 i}{8} & \\frac{1389}{8}-\\frac{25 i}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2)-((7j)/2), 2+((7j)/2)],\n [-1+((7j)/2), -3+((5j)/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 3 & -2 & -3 & 3 \\\\\n -3 & 3 & 3 & -2 \\\\\n 2 & 1 & 1 & 1 \\\\\n -3 & 1 & 0 & 3 \\\\\n -2 & 1 & 3 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.33 \\\\\n -0.13 \\\\\n -0.81 \\\\\n 0.75 \\\\\n -1.42 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.095 \\\\\n 0.479 \\\\\n -0.799 \\\\\n 0.091 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2, -3, 3],\n [-3, 3, 3, -2],\n [2, 1, 1, 1],\n [-3, 1, 0, 3],\n [-2, 1, 3, 0]])\nb = np.array([\n [2.33],\n [-0.13],\n [-0.81],\n [0.75],\n [-1.42]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,-5,-4\\}, \\{2,-5,-5\\}, \\{-4,1,-4\\}}$.", - "Output Answer": [ - "$3 x+2 y+6 z+34=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, -5, -4],\n [2, -5, -5],\n [-4, 1, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 2 & 1 & \\frac{5}{3} & 0 & -\\frac{5}{3} \\\\\n -\\frac{1}{3} & -\\frac{8}{3} & \\frac{5}{3} & \\frac{5}{3} & \\frac{8}{3} \\\\\n -\\frac{1}{3} & -3 & \\frac{1}{3} & -\\frac{2}{3} & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{2}{3} & -2 & -\\frac{4}{3} & 1 \\\\\n 0 & 1 & 1 & -2 \\\\\n 2 & \\frac{2}{3} & \\frac{2}{3} & -\\frac{5}{3} \\\\\n -\\frac{4}{3} & -3 & \\frac{1}{3} & \\frac{8}{3} \\\\\n \\frac{2}{3} & \\frac{1}{3} & -\\frac{2}{3} & \\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{8}{9} & -\\frac{22}{9} & \\frac{5}{9} & -\\frac{65}{9} \\\\\n \\frac{28}{9} & -5 & -\\frac{7}{3} & \\frac{124}{9} \\\\\n \\frac{20}{9} & \\frac{1}{9} & -3 & \\frac{46}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, (5/3), 0, -(5/3)],\n [-(1/3), -(8/3), (5/3), (5/3), (8/3)],\n [-(1/3), -3, (1/3), -(2/3), (2/3)]])\nb = np.array([\n [-(2/3), -2, -(4/3), 1],\n [0, 1, 1, -2],\n [2, (2/3), (2/3), -(5/3)],\n [-(4/3), -3, (1/3), (8/3)],\n [(2/3), (1/3), -(2/3), (8/3)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{5} & -\\frac{33}{5} \\\\\n -\\frac{41}{5} & -\\frac{26}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{17 x}{5}-\\frac{1587}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/5), -(33/5)],\n [-(41/5), -(26/5)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{4} \\\\\n \\frac{9}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{11}{\\sqrt{202}} \\\\\n \\frac{9}{\\sqrt{202}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/4)],\n [(9/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{35}{32}, \\frac{101}{32}}$ to the line $-\\frac{17 x}{4}+\\frac{43 y}{32}-\\frac{55}{32}=0$.", - "Output Answer": [ - "$\\frac{2177}{32 \\sqrt{20345}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (35/32), (101/32)\nline = Poly(-((17*x)/4)+((43*y)/32)-(55/32), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n \\frac{12}{5} \\\\\n 0 \\\\\n -\\frac{2}{5} \\\\\n \\frac{4}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{14}{5} & \\frac{7}{5} & -\\frac{13}{5} & \\frac{13}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{168}{25} & \\frac{84}{25} & -\\frac{156}{25} & \\frac{156}{25} \\\\\n 0 & 0 & 0 & 0 \\\\\n \\frac{28}{25} & -\\frac{14}{25} & \\frac{26}{25} & -\\frac{26}{25} \\\\\n -\\frac{56}{25} & \\frac{28}{25} & -\\frac{52}{25} & \\frac{52}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(12/5)],\n [0],\n [-(2/5)],\n [(4/5)]])\nb = np.array([\n [-(14/5), (7/5), -(13/5), (13/5)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{100}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 8 & 5 & 9 & -1 \\\\\n -7 & 2 & 5 & 1 \\\\\n 4 & 2 & -4 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{6}{25} & \\frac{3}{20} & \\frac{27}{100} & -\\frac{3}{100} \\\\\n -\\frac{21}{100} & \\frac{3}{50} & \\frac{3}{20} & \\frac{3}{100} \\\\\n \\frac{3}{25} & \\frac{3}{50} & -\\frac{3}{25} & \\frac{3}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 5, 9, -1],\n [-7, 2, 5, 1],\n [4, 2, -4, 2]])\nprint(a * (3/100))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{15}{2} & -\\frac{5}{2} \\\\\n -6 & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{12} \\left(7-\\sqrt{109}\\right),1\\right\\}, \\left\\{\\frac{1}{12} \\left(7+\\sqrt{109}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/2), -(5/2)],\n [-6, -(1/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,5,-1\\}, \\left\\{2,-\\frac{1}{2},\\frac{3}{2}\\right\\}, \\left\\{-\\frac{3}{2},-\\frac{9}{2},4\\right\\}}$.", - "Output Answer": [ - "$15 x+55 y+109 z-166=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, 5, -1],\n [2, -(1/2), (3/2)],\n [-(3/2), -(9/2), 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & \\frac{5}{6} \\\\\n \\frac{10}{3} & \\frac{29}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{112}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, (5/6)],\n [(10/3), (29/6)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -8 \\\\\n -3 \\\\\n 7 \\\\\n -8 \\\\\n -1 \\\\\n 2 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 2 \\\\\n 5 \\\\\n 9 \\\\\n 3 \\\\\n 5 \\\\\n 4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$23$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-8],\n [-3],\n [7],\n [-8],\n [-1],\n [2],\n [8]])\nb = np.array([\n [-4],\n [2],\n [5],\n [9],\n [3],\n [5],\n [4],\n [-2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 8 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -10 \\\\\n -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 12 \\\\\n -18 \\\\\n 34 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [8],\n [6]])\nb = np.array([\n [2],\n [-10],\n [-6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 4 & 4 & -2 \\\\\n 0 & 0 & 2 \\\\\n 0 & 0 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{8} & \\frac{1}{58} & \\frac{5}{116} \\\\\n \\frac{1}{8} & \\frac{1}{58} & \\frac{5}{116} \\\\\n 0 & \\frac{2}{29} & \\frac{5}{29} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 4, -2],\n [0, 0, 2],\n [0, 0, 5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{153}{16} \\\\\n \\frac{75}{16} \\\\\n -\\frac{53}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{51}{8} \\\\\n -\\frac{17}{2} \\\\\n \\frac{3}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{6983}{256} \\\\\n \\frac{4947}{256} \\\\\n -\\frac{6579}{128} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(153/16)],\n [(75/16)],\n [-(53/16)]])\nb = np.array([\n [-(51/8)],\n [-(17/2)],\n [(3/16)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{8} & \\frac{15}{8} \\\\\n 2 & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{8}{61} & \\frac{30}{61} \\\\\n \\frac{32}{61} & -\\frac{2}{61} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/8), (15/8)],\n [2, -(1/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{2} & -3 & \\frac{3}{2} \\\\\n 3 & 3 & 0 \\\\\n 1 & 2 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{13}{8} & -\\frac{15}{4} & \\frac{57}{8} \\\\\n \\frac{3}{4} & \\frac{9}{2} & -\\frac{9}{2} \\\\\n -\\frac{5}{4} & \\frac{3}{2} & -\\frac{21}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), -3, (3/2)],\n [3, 3, 0],\n [1, 2, -(3/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -2 & -3 & -1 & \\frac{15}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{15}{2} & -4 & 3 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{11}{2} & -7 & 2 & \\frac{17}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, -1, (15/2)]])\nb = np.array([\n [(15/2), -4, 3, 1]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{6} & 9 & -\\frac{17}{3} \\\\\n -\\frac{15}{2} & \\frac{5}{2} & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{17}{3} & -\\frac{11}{2} & \\frac{43}{6} \\\\\n \\frac{23}{3} & -\\frac{19}{3} & \\frac{59}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{11}{2} & \\frac{7}{2} & \\frac{3}{2} \\\\\n \\frac{1}{6} & -\\frac{23}{6} & \\frac{19}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/6), 9, -(17/3)],\n [-(15/2), (5/2), -(1/3)]])\nb = np.array([\n [(17/3), -(11/2), (43/6)],\n [(23/3), -(19/3), (59/6)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -4 & -1 & 4 & 3 & 9 & -6 & 7 \\\\\n 2 & -1 & 3 & -3 & 8 & 10 & 4 \\\\\n -1 & 2 & 3 & 2 & 0 & -10 & -5 \\\\\n -7 & -9 & 10 & 7 & -9 & 9 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & -\\frac{1380}{193} & \\frac{235}{193} & -\\frac{1139}{193} \\\\\n 0 & 1 & 0 & 0 & \\frac{809}{386} & -\\frac{1165}{386} & \\frac{29}{386} \\\\\n 0 & 0 & 1 & 0 & \\frac{190}{193} & \\frac{11}{193} & -\\frac{18}{193} \\\\\n 0 & 0 & 0 & 1 & -\\frac{2759}{386} & -\\frac{563}{386} & -\\frac{2079}{386} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-4, -1, 4, 3, 9, -6, 7],\n [2, -1, 3, -3, 8, 10, 4],\n [-1, 2, 3, 2, 0, -10, -5],\n [-7, -9, 10, 7, -9, 9, 2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -3 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 5 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-77$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-3],\n [10]])\nb = np.array([\n [3],\n [5],\n [-8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -2 & 2 & 1 & 2 & 0 \\\\\n -2 & -1 & 3 & -1 & -3 \\\\\n 2 & -3 & 1 & -1 & -2 \\\\\n 0 & -1 & 1 & -2 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 2 & -3 \\\\\n 2 & 0 \\\\\n 2 & 1 \\\\\n 0 & 2 \\\\\n -1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 2 & 11 \\\\\n 3 & 16 \\\\\n 2 & -1 \\\\\n 1 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2, 1, 2, 0],\n [-2, -1, 3, -1, -3],\n [2, -3, 1, -1, -2],\n [0, -1, 1, -2, -1]])\nb = np.array([\n [2, -3],\n [2, 0],\n [2, 1],\n [0, 2],\n [-1, -3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & -\\frac{9}{2} \\\\\n -\\frac{9}{2} & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{18} \\left(7-\\sqrt{373}\\right),1\\right\\}, \\left\\{\\frac{1}{18} \\left(7+\\sqrt{373}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -(9/2)],\n [-(9/2), -(5/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{8} & -\\frac{63}{16} \\\\\n -\\frac{39}{16} & \\frac{25}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{400}{2807} & -\\frac{144}{401} \\\\\n -\\frac{624}{2807} & \\frac{32}{401} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/8), -(63/16)],\n [-(39/16), (25/16)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,3 \\log (2),-3 \\log (2)\\}, \\{-2 \\log (2),-3 \\log (2),2 \\log (2)\\}, \\{-4 \\log (2),3 \\log (2),4 \\log (2)\\}}$", - "Output Answer": [ - "${\\left\\{0,\\frac{1}{\\sqrt{2}},-\\frac{1}{\\sqrt{2}}\\right\\}, \\left\\{-\\frac{2 \\sqrt{2}}{3},-\\frac{1}{3 \\sqrt{2}},-\\frac{1}{3 \\sqrt{2}}\\right\\}, \\left\\{-\\frac{1}{3},\\frac{2}{3},\\frac{2}{3}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((0, 3*math.log(2), -3*math.log(2)), (-2*math.log(2), -3*math.log(2), 2*math.log(2)), (-4*math.log(2), 3*math.log(2), 4*math.log(2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{15}{2} & 0 \\\\\n \\frac{13}{2} & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{-\\frac{3}{13},1\\right\\}, \\{0,1\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/2), 0],\n [(13/2), -6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -7 & -6 & 6 & 4 \\\\\n 5 & 6 & 4 & 6 \\\\\n -1 & 9 & 7 & -2 \\\\\n -1 & -5 & -5 & -6 \\\\\n -9 & 6 & -8 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, -6, 6, 4],\n [5, 6, 4, 6],\n [-1, 9, 7, -2],\n [-1, -5, -5, -6],\n [-9, 6, -8, 10]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 2 \\\\\n \\frac{5}{2} \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2 \\sqrt{\\frac{2}{33}} \\\\\n 2 \\sqrt{\\frac{2}{33}} \\\\\n \\frac{5}{\\sqrt{66}} \\\\\n \\sqrt{\\frac{3}{22}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [2],\n [(5/2)],\n [(3/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -5 & 4 \\\\\n -1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$24$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 4],\n [-1, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -3 & -2 & -5 & 3 & 2 & -2 & 4 \\\\\n 1 & 4 & -9 & -8 & 7 & 8 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & \\frac{19}{5} & \\frac{2}{5} & -\\frac{11}{5} & -\\frac{4}{5} & -\\frac{8}{5} \\\\\n 0 & 1 & -\\frac{16}{5} & -\\frac{21}{10} & \\frac{23}{10} & \\frac{11}{5} & \\frac{2}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, -2, -5, 3, 2, -2, 4],\n [1, 4, -9, -8, 7, 8, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & -3 & -3 \\\\\n 3 & -1 & -1 \\\\\n 2 & -3 & 3 \\\\\n -2 & -1 & -2 \\\\\n 1 & -2 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.57 \\\\\n -2.53 \\\\\n -2.25 \\\\\n 2.99 \\\\\n 0.94 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.992 \\\\\n -0.312 \\\\\n -0.347 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3, -3],\n [3, -1, -1],\n [2, -3, 3],\n [-2, -1, -2],\n [1, -2, -1]])\nb = np.array([\n [1.57],\n [-2.53],\n [-2.25],\n [2.99],\n [0.94]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-4,\\frac{11}{3},-3\\right\\}, \\left\\{\\frac{4}{3},-1,\\frac{11}{3}\\right\\}, \\left\\{4,-\\frac{10}{3},-1\\right\\}}$.", - "Output Answer": [ - "$21 x+24 y-4=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, (11/3), -3],\n [(4/3), -1, (11/3)],\n [4, -(10/3), -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -10 & 2 & 10 & 10 & 6 & -10 & -3 \\\\\n 7 & -2 & -4 & 5 & 6 & 8 & -3 \\\\\n 6 & 6 & 1 & 2 & -3 & 9 & -6 \\\\\n 7 & 6 & 7 & -3 & 0 & 3 & -4 \\\\\n 9 & -10 & 7 & 5 & 2 & 6 & -4 \\\\\n -1 & -6 & -10 & -5 & 4 & 9 & 10 \\\\\n -10 & -3 & 4 & -7 & 3 & 4 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, 2, 10, 10, 6, -10, -3],\n [7, -2, -4, 5, 6, 8, -3],\n [6, 6, 1, 2, -3, 9, -6],\n [7, 6, 7, -3, 0, 3, -4],\n [9, -10, 7, 5, 2, 6, -4],\n [-1, -6, -10, -5, 4, 9, 10],\n [-10, -3, 4, -7, 3, 4, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{9}{2} \\\\\n \\frac{5}{4} \\\\\n -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{2} \\\\\n -\\frac{145}{16} \\\\\n -\\frac{141}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2735}{64} \\\\\n \\frac{1661}{32} \\\\\n -\\frac{1165}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/2)],\n [(5/4)],\n [-(7/2)]])\nb = np.array([\n [-(7/2)],\n [-(145/16)],\n [-(141/16)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 9 \\\\\n 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -22 \\\\\n -26 \\\\\n 30 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-4],\n [-2]])\nb = np.array([\n [3],\n [9],\n [10]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{3} \\\\\n -\\frac{2}{3} \\\\\n \\frac{53}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{14}{3} \\\\\n \\frac{4}{3} \\\\\n \\frac{76}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{364}{27} \\\\\n -\\frac{146}{9} \\\\\n -\\frac{44}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/3)],\n [-(2/3)],\n [(53/9)]])\nb = np.array([\n [-(14/3)],\n [(4/3)],\n [(76/9)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{17}{4} & \\frac{5}{2} & -3 \\\\\n \\frac{7}{2} & \\frac{7}{4} & \\frac{1}{4} \\\\\n -\\frac{7}{2} & \\frac{3}{4} & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{572}{3411} & \\frac{656}{3411} & \\frac{376}{3411} \\\\\n \\frac{1064}{3411} & \\frac{688}{3411} & -\\frac{604}{3411} \\\\\n \\frac{560}{3411} & -\\frac{356}{3411} & -\\frac{1036}{3411} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/4), (5/2), -3],\n [(7/2), (7/4), (1/4)],\n [-(7/2), (3/4), -5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -6 & 10 & 7 & 0 \\\\\n 6 & 5 & 6 & 1 \\\\\n 1 & -5 & -6 & 7 \\\\\n -8 & -5 & 3 & 9 \\\\\n 0 & 10 & -9 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-6, 10, 7, 0],\n [6, 5, 6, 1],\n [1, -5, -6, 7],\n [-8, -5, 3, 9],\n [0, 10, -9, 5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{9} & -\\frac{28}{9} & -\\frac{4}{3} \\\\\n -\\frac{44}{9} & \\frac{41}{9} & -\\frac{7}{9} \\\\\n \\frac{41}{9} & -\\frac{5}{3} & \\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{702}{883} & -\\frac{621}{883} & -\\frac{387}{883} \\\\\n -\\frac{10485}{14128} & -\\frac{5913}{14128} & -\\frac{5067}{14128} \\\\\n \\frac{9189}{14128} & \\frac{9657}{14128} & \\frac{9243}{14128} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/9), -(28/9), -(4/3)],\n [-(44/9), (41/9), -(7/9)],\n [(41/9), -(5/3), (11/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{67}{7} \\\\\n 3 \\\\\n -\\frac{4}{7} \\\\\n -\\frac{34}{7} \\\\\n \\frac{48}{7} \\\\\n -\\frac{5}{7} \\\\\n -\\frac{9}{7} \\\\\n -\\frac{39}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{10033}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(67/7)],\n [3],\n [-(4/7)],\n [-(34/7)],\n [(48/7)],\n [-(5/7)],\n [-(9/7)],\n [-(39/7)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & 0 & 0 \\\\\n 1 & 2 & -2 \\\\\n 3 & -1 & 1 \\\\\n 3 & 0 & 1 \\\\\n -2 & 2 & -1 \\\\\n 3 & 2 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.84 \\\\\n 2.85 \\\\\n -2.95 \\\\\n 1.33 \\\\\n -0.02 \\\\\n -1.73 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.049 \\\\\n 0.165 \\\\\n -0.986 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, 0],\n [1, 2, -2],\n [3, -1, 1],\n [3, 0, 1],\n [-2, 2, -1],\n [3, 2, 2]])\nb = np.array([\n [0.84],\n [2.85],\n [-2.95],\n [1.33],\n [-0.02],\n [-1.73]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{2} & 0 & -3 \\\\\n -1 & -\\frac{1}{2} & \\frac{5}{2} \\\\\n -3 & -\\frac{1}{2} & -3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{713}{8} & -9 & -\\frac{183}{2} \\\\\n \\frac{59}{2} & \\frac{27}{8} & \\frac{113}{4} \\\\\n -\\frac{189}{2} & -\\frac{37}{4} & -\\frac{775}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), 0, -3],\n [-1, -(1/2), (5/2)],\n [-3, -(1/2), -3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{9}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -3 \\\\\n -5 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{49}{9} \\\\\n -\\frac{7}{3} \\\\\n -\\frac{35}{9} \\\\\n \\frac{14}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-3],\n [-5],\n [2]])\nprint(a * (7/9))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{57}{8} & \\frac{19}{4} & 6 \\\\\n -\\frac{3}{8} & -\\frac{75}{8} & 9 \\\\\n -\\frac{79}{8} & \\frac{15}{8} & \\frac{19}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{113 x^2}{8}-\\frac{4593 x}{64}-\\frac{357753}{512}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(57/8), (19/4), 6],\n [-(3/8), -(75/8), 9],\n [-(79/8), (15/8), (19/8)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & -3 & 1 \\\\\n 2 & 2 & 0 \\\\\n -3 & 1 & 0 \\\\\n -1 & 2 & -3 \\\\\n 0 & 0 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.7 \\\\\n -1.46 \\\\\n -0.08 \\\\\n 1.23 \\\\\n -1.09 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.079 \\\\\n -0.637 \\\\\n -0.56 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -3, 1],\n [2, 2, 0],\n [-3, 1, 0],\n [-1, 2, -3],\n [0, 0, -1]])\nb = np.array([\n [1.7],\n [-1.46],\n [-0.08],\n [1.23],\n [-1.09]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & -2 & 1 \\\\\n 1 & -1 & -2 \\\\\n -1 & -2 & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -2 & 2 & 2 \\\\\n 0 & 3 & 5 \\\\\n 0 & 6 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, 1],\n [1, -1, -2],\n [-1, -2, -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -\\frac{13}{2} \\\\\n \\frac{11}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{13}{2} \\\\\n -\\frac{19}{4} \\\\\n \\frac{9}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{259}{16} \\\\\n \\frac{467}{8} \\\\\n 85 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-(13/2)],\n [(11/4)]])\nb = np.array([\n [(13/2)],\n [-(19/4)],\n [(9/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 3 & -3 & \\frac{14}{3} \\\\\n -\\frac{10}{3} & -5 & 1 \\\\\n 2 & \\frac{5}{3} & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & \\frac{3}{8} & \\frac{9}{8} \\\\\n \\frac{3}{61} & -\\frac{279}{488} & -\\frac{501}{488} \\\\\n \\frac{15}{61} & -\\frac{297}{488} & -\\frac{675}{488} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -3, (14/3)],\n [-(10/3), -5, 1],\n [2, (5/3), -(1/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -1 \\\\\n 9 \\\\\n 4 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -7 \\\\\n -10 \\\\\n -4 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-117$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-1],\n [9],\n [4],\n [6]])\nb = np.array([\n [-8],\n [-7],\n [-10],\n [-4],\n [-7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & -5 & 1 \\\\\n -2 & -3 & 6 \\\\\n 6 & 6 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.629,-1.119,1.\\}, \\{-0.186-0.865 i,0.726\\, +0.474 i,1.\\}, \\{-0.186+0.865 i,0.726\\, -0.474 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -5, 1],\n [-2, -3, 6],\n [6, 6, 1]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\sqrt{\\frac{2}{7}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [-1],\n [-1],\n [0],\n [1],\n [0],\n [-1],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [1],\n [-1],\n [0],\n [-1],\n [1],\n [-1],\n [0],\n [-1],\n [-1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{29}{4} & -\\frac{7}{4} \\\\\n \\frac{7}{2} & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{28} \\left(-43-\\sqrt{1457}\\right),1\\right\\}, \\left\\{\\frac{1}{28} \\left(\\sqrt{1457}-43\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/4), -(7/4)],\n [(7/2), (7/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{11}{5} & -5 \\\\\n \\frac{1}{2} & \\frac{53}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{31 x}{10}-\\frac{229}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/5), -5],\n [(1/2), (53/10)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 8 \\\\\n 2 \\\\\n -7 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 1 \\\\\n 0 \\\\\n -8 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{23}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [8],\n [2],\n [-7],\n [-1]])\nb = np.array([\n [4],\n [1],\n [0],\n [-8],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & -3 \\\\\n 0 & -1 \\\\\n 2 & -3 \\\\\n 1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.31 \\\\\n 2.82 \\\\\n -0.67 \\\\\n 1.02 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.176 \\\\\n -0.186 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3],\n [0, -1],\n [2, -3],\n [1, 3]])\nb = np.array([\n [2.31],\n [2.82],\n [-0.67],\n [1.02]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{11}{64}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 8 & 10 & 6 \\\\\n 7 & -9 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{8} & -\\frac{55}{32} & -\\frac{33}{32} \\\\\n -\\frac{77}{64} & \\frac{99}{64} & -\\frac{55}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 10, 6],\n [7, -9, 10]])\nprint(a * -(11/64))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1}{\\sqrt{3}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [0],\n [-1],\n [0],\n [1]]).squeeze()\nb = np.array([\n [1],\n [1],\n [1],\n [0],\n [0],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{5} & 5 & \\frac{34}{5} \\\\\n -\\frac{47}{5} & -\\frac{29}{5} & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{31}{5} & \\frac{44}{5} & \\frac{2}{5} \\\\\n -\\frac{39}{5} & 8 & \\frac{19}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{44}{5} & \\frac{69}{5} & \\frac{36}{5} \\\\\n -\\frac{86}{5} & \\frac{11}{5} & \\frac{19}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/5), 5, (34/5)],\n [-(47/5), -(29/5), 0]])\nb = np.array([\n [-(31/5), (44/5), (2/5)],\n [-(39/5), 8, (19/5)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{5}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 4 & -7 & -1 & 8 \\\\\n 7 & 8 & 1 & 7 \\\\\n -9 & 9 & 10 & -6 \\\\\n -8 & -7 & -6 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{4}{5} & \\frac{7}{5} & \\frac{1}{5} & -\\frac{8}{5} \\\\\n -\\frac{7}{5} & -\\frac{8}{5} & -\\frac{1}{5} & -\\frac{7}{5} \\\\\n \\frac{9}{5} & -\\frac{9}{5} & -2 & \\frac{6}{5} \\\\\n \\frac{8}{5} & \\frac{7}{5} & \\frac{6}{5} & \\frac{8}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -7, -1, 8],\n [7, 8, 1, 7],\n [-9, 9, 10, -6],\n [-8, -7, -6, -8]])\nprint(a * -(1/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{4} & \\frac{5}{4} \\\\\n -\\frac{23}{4} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{8} \\left(3-i \\sqrt{235}\\right),\\frac{1}{8} \\left(3+i \\sqrt{235}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/4), (5/4)],\n [-(23/4), -(3/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$24$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-4*math.sqrt(3)]])\nb = np.array([\n [-2*math.sqrt(3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -2 & 0 & -3 \\\\\n 0 & 0 & 0 \\\\\n -2 & -3 & -1 \\\\\n -2 & 0 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 0 & 1 & 2 & 0 & 0 \\\\\n 2 & -2 & -2 & -1 & 1 \\\\\n 2 & -2 & -1 & 1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -6 & 4 & -1 & -3 & -9 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n -8 & 6 & 3 & 2 & -6 \\\\\n 4 & -6 & -6 & 2 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, -3],\n [0, 0, 0],\n [-2, -3, -1],\n [-2, 0, 2]])\nb = np.array([\n [0, 1, 2, 0, 0],\n [2, -2, -2, -1, 1],\n [2, -2, -1, 1, 3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -4 & -\\frac{19}{3} \\\\\n -\\frac{10}{3} & -\\frac{7}{3} \\\\\n 1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -(19/3)],\n [-(10/3), -(7/3)],\n [1, -3]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{4} \\\\\n \\frac{1}{2} \\\\\n -8 \\\\\n \\frac{19}{4} \\\\\n -\\frac{1}{4} \\\\\n \\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{37}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/4)],\n [(1/2)],\n [-8],\n [(19/4)],\n [-(1/4)],\n [(1/4)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{2} & -4 \\\\\n -\\frac{9}{2} & \\frac{29}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{36} \\left(43-\\sqrt{3001}\\right),1\\right\\}, \\left\\{\\frac{1}{36} \\left(43+\\sqrt{3001}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), -4],\n [-(9/2), (29/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 3 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 6 \\\\\n 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -30 \\\\\n 35 \\\\\n 27 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [3],\n [5]])\nb = np.array([\n [7],\n [6],\n [0]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -9 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 9 \\\\\n 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 63 \\\\\n -104 \\\\\n 144 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-9],\n [-10]])\nb = np.array([\n [8],\n [9],\n [3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{4} \\\\\n 7 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n \\frac{5}{2} \\\\\n -\\frac{53}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{471}{8} \\\\\n -\\frac{211}{32} \\\\\n -\\frac{91}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/4)],\n [7],\n [5]])\nb = np.array([\n [1],\n [(5/2)],\n [-(53/8)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 5 & 10 & -4 \\\\\n 0 & 4 & 9 \\\\\n 9 & 4 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+7 x^2-2 x+734$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 10, -4],\n [0, 4, 9],\n [9, 4, -2]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{8} & \\frac{17}{8} & -\\frac{33}{16} \\\\\n -\\frac{35}{16} & \\frac{1}{16} & \\frac{1}{2} \\\\\n \\frac{1}{2} & \\frac{1}{16} & \\frac{23}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n \\frac{3}{16} & -\\frac{19}{16} & \\frac{33}{16} & -\\frac{29}{16} & \\frac{5}{2} \\\\\n -\\frac{15}{16} & -\\frac{31}{16} & \\frac{29}{16} & \\frac{9}{4} & -\\frac{11}{8} \\\\\n \\frac{5}{8} & \\frac{13}{8} & -\\frac{35}{16} & \\frac{15}{8} & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -\\frac{423}{128} & -\\frac{937}{128} & \\frac{2075}{256} & \\frac{73}{64} & \\frac{189}{64} \\\\\n -\\frac{5}{32} & \\frac{421}{128} & -\\frac{703}{128} & \\frac{1291}{256} & -\\frac{903}{128} \\\\\n \\frac{239}{256} & \\frac{415}{256} & -2 & \\frac{247}{128} & -\\frac{403}{128} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/8), (17/8), -(33/16)],\n [-(35/16), (1/16), (1/2)],\n [(1/2), (1/16), (23/16)]])\nb = np.array([\n [(3/16), -(19/16), (33/16), -(29/16), (5/2)],\n [-(15/16), -(31/16), (29/16), (9/4), -(11/8)],\n [(5/8), (13/8), -(35/16), (15/8), -3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\sqrt{3},\\frac{2}{\\sqrt{3}},-\\frac{2}{\\sqrt{3}}\\right\\}, \\left\\{\\frac{5}{\\sqrt{3}},\\sqrt{3},-\\frac{1}{\\sqrt{3}}\\right\\}, \\left\\{-\\frac{5}{\\sqrt{3}},\\sqrt{3},\\frac{5}{\\sqrt{3}}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{3}{\\sqrt{17}},\\frac{2}{\\sqrt{17}},-\\frac{2}{\\sqrt{17}}\\right\\}, \\left\\{\\frac{\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}}{\\sqrt{\\frac{841}{867}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)^2+\\left(\\sqrt{3}-\\frac{46}{17 \\sqrt{3}}\\right)^2}},\\frac{\\sqrt{3}-\\frac{46}{17 \\sqrt{3}}}{\\sqrt{\\frac{841}{867}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)^2+\\left(\\sqrt{3}-\\frac{46}{17 \\sqrt{3}}\\right)^2}},\\frac{29}{17 \\sqrt{3 \\left(\\frac{841}{867}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)^2+\\left(\\sqrt{3}-\\frac{46}{17 \\sqrt{3}}\\right)^2\\right)}}\\right\\}, \\left\\{\\frac{-\\frac{5}{\\sqrt{3}}+\\frac{19 \\sqrt{3}}{17}-\\frac{\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right) \\left(\\frac{145}{51}-\\frac{5 \\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)}{\\sqrt{3}}+\\sqrt{3} \\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{\\frac{841}{867}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)^2+\\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)^2}}{\\sqrt{\\left(\\frac{47}{17 \\sqrt{3}}-\\frac{29 \\left(\\frac{145}{51}-\\frac{5 \\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)}{\\sqrt{3}}+\\sqrt{3} \\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{17 \\sqrt{3} \\left(\\frac{841}{867}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)^2+\\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)^2\\right)}\\right)^2+\\left(\\frac{38}{17 \\sqrt{3}}+\\sqrt{3}+\\frac{\\left(\\frac{46}{17 \\sqrt{3}}-\\sqrt{3}\\right) \\left(\\frac{145}{51}-\\frac{5 \\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)}{\\sqrt{3}}+\\sqrt{3} \\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{\\frac{841}{867}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)^2+\\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)^2}\\right)^2+\\left(\\frac{5}{\\sqrt{3}}-\\frac{19 \\sqrt{3}}{17}-\\frac{\\left(-\\frac{5}{\\sqrt{3}}+\\frac{23 \\sqrt{3}}{17}\\right) \\left(\\frac{145}{51}-\\frac{5 \\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)}{\\sqrt{3}}+\\sqrt{3} \\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{\\frac{841}{867}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)^2+\\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)^2}\\right)^2}},\\frac{\\frac{38}{17 \\sqrt{3}}+\\sqrt{3}-\\frac{\\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right) \\left(\\frac{145}{51}-\\frac{5 \\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)}{\\sqrt{3}}+\\sqrt{3} \\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{\\frac{841}{867}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)^2+\\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)^2}}{\\sqrt{\\left(\\frac{47}{17 \\sqrt{3}}-\\frac{29 \\left(\\frac{145}{51}-\\frac{5 \\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)}{\\sqrt{3}}+\\sqrt{3} \\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{17 \\sqrt{3} \\left(\\frac{841}{867}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)^2+\\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)^2\\right)}\\right)^2+\\left(\\frac{38}{17 \\sqrt{3}}+\\sqrt{3}+\\frac{\\left(\\frac{46}{17 \\sqrt{3}}-\\sqrt{3}\\right) \\left(\\frac{145}{51}-\\frac{5 \\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)}{\\sqrt{3}}+\\sqrt{3} \\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{\\frac{841}{867}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)^2+\\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)^2}\\right)^2+\\left(\\frac{5}{\\sqrt{3}}-\\frac{19 \\sqrt{3}}{17}-\\frac{\\left(-\\frac{5}{\\sqrt{3}}+\\frac{23 \\sqrt{3}}{17}\\right) \\left(\\frac{145}{51}-\\frac{5 \\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)}{\\sqrt{3}}+\\sqrt{3} \\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{\\frac{841}{867}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)^2+\\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)^2}\\right)^2}},\\frac{\\frac{47}{17 \\sqrt{3}}-\\frac{29 \\left(\\frac{145}{51}-\\frac{5 \\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)}{\\sqrt{3}}+\\sqrt{3} \\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{17 \\sqrt{3} \\left(\\frac{841}{867}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)^2+\\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)^2\\right)}}{\\sqrt{\\left(\\frac{47}{17 \\sqrt{3}}-\\frac{29 \\left(\\frac{145}{51}-\\frac{5 \\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)}{\\sqrt{3}}+\\sqrt{3} \\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{17 \\sqrt{3} \\left(\\frac{841}{867}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)^2+\\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)^2\\right)}\\right)^2+\\left(\\frac{38}{17 \\sqrt{3}}+\\sqrt{3}+\\frac{\\left(\\frac{46}{17 \\sqrt{3}}-\\sqrt{3}\\right) \\left(\\frac{145}{51}-\\frac{5 \\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)}{\\sqrt{3}}+\\sqrt{3} \\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{\\frac{841}{867}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)^2+\\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)^2}\\right)^2+\\left(\\frac{5}{\\sqrt{3}}-\\frac{19 \\sqrt{3}}{17}-\\frac{\\left(-\\frac{5}{\\sqrt{3}}+\\frac{23 \\sqrt{3}}{17}\\right) \\left(\\frac{145}{51}-\\frac{5 \\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)}{\\sqrt{3}}+\\sqrt{3} \\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{\\frac{841}{867}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{17}\\right)^2+\\left(-\\frac{46}{17 \\sqrt{3}}+\\sqrt{3}\\right)^2}\\right)^2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((math.sqrt(3), (2/(math.sqrt(3))), -(2/(math.sqrt(3)))), ((5/(math.sqrt(3))), math.sqrt(3), -(1/(math.sqrt(3)))), (-(5/(math.sqrt(3))), math.sqrt(3), (5/(math.sqrt(3))))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{4} & -\\frac{19}{4} & \\frac{9}{2} \\\\\n -\\frac{13}{4} & 2 & 3 \\\\\n 0 & \\frac{1}{4} & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{72}{689} & -\\frac{140}{689} & -\\frac{248}{689} \\\\\n -\\frac{8}{53} & \\frac{8}{53} & -\\frac{4}{53} \\\\\n -\\frac{2}{159} & \\frac{2}{159} & -\\frac{18}{53} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/4), -(19/4), (9/2)],\n [-(13/4), 2, 3],\n [0, (1/4), -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & -\\frac{18}{5} & 2 \\\\\n -\\frac{38}{5} & -\\frac{17}{5} & -\\frac{3}{5} \\\\\n 10 & \\frac{32}{5} & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8.261,2.731,11.131\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -(18/5), 2],\n [-(38/5), -(17/5), -(3/5)],\n [10, (32/5), 10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 9 & 6 \\\\\n -8 & 10 \\\\\n -8 & 4 \\\\\n -9 & 7 \\\\\n 8 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, 6],\n [-8, 10],\n [-8, 4],\n [-9, 7],\n [8, -4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 0 & -2 & 1 & 2 \\\\\n -3 & -3 & 2 & -2 \\\\\n 1 & 3 & 2 & 1 \\\\\n 3 & 2 & 1 & 1 \\\\\n -3 & -2 & 0 & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -1 & -1 & -1 & 3 \\\\\n -1 & -2 & 1 & 0 \\\\\n -2 & -1 & 2 & 0 \\\\\n 1 & 3 & 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 2 & 9 & 2 & -2 \\\\\n 0 & 1 & 2 & -7 \\\\\n -7 & -6 & 7 & 2 \\\\\n -6 & -5 & 2 & 8 \\\\\n 8 & 16 & 4 & -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2, 1, 2],\n [-3, -3, 2, -2],\n [1, 3, 2, 1],\n [3, 2, 1, 1],\n [-3, -2, 0, 3]])\nb = np.array([\n [-1, -1, -1, 3],\n [-1, -2, 1, 0],\n [-2, -1, 2, 0],\n [1, 3, 1, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{5}{2} & 4 & -\\frac{3}{2} & \\frac{19}{2} \\\\\n 7 & -\\frac{19}{2} & \\frac{19}{2} & -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -5 & 6 & -\\frac{15}{2} & -1 \\\\\n \\frac{15}{2} & \\frac{3}{2} & \\frac{9}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{15}{2} & 10 & -9 & \\frac{17}{2} \\\\\n \\frac{29}{2} & -8 & 14 & -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), 4, -(3/2), (19/2)],\n [7, -(19/2), (19/2), -8]])\nb = np.array([\n [-5, 6, -(15/2), -1],\n [(15/2), (3/2), (9/2), (1/2)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & -8 \\\\\n -6 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-5-\\sqrt{57},\\sqrt{57}-5\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -8],\n [-6, -8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{4} \\\\\n \\frac{17}{4} \\\\\n \\frac{9}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{2} \\\\\n \\frac{11}{4} \\\\\n -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{109}{4} \\\\\n -\\frac{43}{8} \\\\\n \\frac{493}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/4)],\n [(17/4)],\n [(9/2)]])\nb = np.array([\n [-(9/2)],\n [(11/4)],\n [-(7/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{5} \\\\\n -\\frac{12}{5} \\\\\n \\frac{27}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{99}{10} \\\\\n -\\frac{99}{10} \\\\\n \\frac{16}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{381}{20} \\\\\n -\\frac{817}{100} \\\\\n \\frac{1683}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/5)],\n [-(12/5)],\n [(27/10)]])\nb = np.array([\n [-(99/10)],\n [-(99/10)],\n [(16/5)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -2 & 1 & 1 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -2 & -2 \\\\\n -2 & 3 \\\\\n -1 & 2 \\\\\n -2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 3 & 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 1, 1, -1]])\nb = np.array([\n [-2, -2],\n [-2, 3],\n [-1, 2],\n [-2, -3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5.95 \\\\\n 0.08 \\\\\n 3.38 \\\\\n -1.75 \\\\\n -0.94 \\\\\n 7.55 \\\\\n 8.86 \\\\\n -9.07 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3.46 \\\\\n 5.87 \\\\\n -6.51 \\\\\n 5.59 \\\\\n 6.25 \\\\\n 9.71 \\\\\n -0.49 \\\\\n -7.38 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$78.127$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5.95],\n [0.08],\n [3.38],\n [-1.75],\n [-0.94],\n [7.55],\n [8.86],\n [-9.07]])\nb = np.array([\n [3.46],\n [5.87],\n [-6.51],\n [5.59],\n [6.25],\n [9.71],\n [-0.49],\n [-7.38]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\sqrt{2} \\\\\n -4 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\sqrt{2} \\\\\n -3 \\sqrt{2} \\\\\n -4 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$26$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [math.sqrt(2)],\n [-4*math.sqrt(2)]])\nb = np.array([\n [4*math.sqrt(2)],\n [-3*math.sqrt(2)],\n [-4*math.sqrt(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\sqrt{3} \\\\\n 2 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n 0 \\\\\n -\\sqrt{3} \\\\\n -4 \\sqrt{3} \\\\\n -\\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n 0 \\\\\n 4 \\sqrt{3} \\\\\n 5 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6 \\sqrt{11}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [2*math.sqrt(3)],\n [2*math.sqrt(3)],\n [4*math.sqrt(3)],\n [0],\n [-math.sqrt(3)],\n [-4*math.sqrt(3)],\n [-math.sqrt(3)]])\nb = np.array([\n [4*math.sqrt(3)],\n [math.sqrt(3)],\n [3*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [0],\n [4*math.sqrt(3)],\n [5*math.sqrt(3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{2}{3}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{4}{3} \\\\\n -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-7]])\nprint(a * (2/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{20}{3} \\\\\n \\frac{8}{3} \\\\\n 2 \\\\\n -4 \\\\\n -9 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{88}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(20/3)],\n [(8/3)],\n [2],\n [-4],\n [-9],\n [-5]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & 4 \\\\\n 9 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{7-\\sqrt{37},7+\\sqrt{37}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 4],\n [9, 8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n -\\frac{11}{4} \\\\\n \\frac{1}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{3}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{3}{4} \\\\\n -\\frac{33}{16} \\\\\n \\frac{3}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [-(11/4)],\n [(1/4)]])\nb = np.array([\n [(3/4)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{2,2,4\\}, \\{2,4,1\\}, \\{-5,-2,-4\\}}$.", - "Output Answer": [ - "$4 x-3 y-2 z+6=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, 2, 4],\n [2, 4, 1],\n [-5, -2, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & \\frac{3}{10} \\\\\n -\\frac{9}{5} & \\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{53}{50}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, (3/10)],\n [-(9/5), (8/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{16}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 10 & 6 \\\\\n -6 & 9 \\\\\n -10 & 4 \\\\\n 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{5}{8} & \\frac{3}{8} \\\\\n -\\frac{3}{8} & \\frac{9}{16} \\\\\n -\\frac{5}{8} & \\frac{1}{4} \\\\\n 0 & \\frac{1}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 6],\n [-6, 9],\n [-10, 4],\n [0, 2]])\nprint(a * (1/16))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 9 & 6 & 2 & -3 & 6 & 7 \\\\\n -6 & -10 & 2 & -1 & -3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & \\frac{16}{27} & -\\frac{2}{3} & \\frac{7}{9} & \\frac{38}{27} \\\\\n 0 & 1 & -\\frac{5}{9} & \\frac{1}{2} & -\\frac{1}{6} & -\\frac{17}{18} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, 6, 2, -3, 6, 7],\n [-6, -10, 2, -1, -3, 1]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & 1 \\\\\n 2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-9-\\sqrt{57}\\right),\\frac{1}{2} \\left(\\sqrt{57}-9\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 1],\n [2, -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -6 & 0 & -7 \\\\\n 8 & -8 & 9 \\\\\n 4 & -7 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6.481-9.197 i,-6.481+9.197 i,-2.038\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 0, -7],\n [8, -8, 9],\n [4, -7, -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, -3, -1}$ to the plane $-\\frac{9 x}{2}+2 y+2 z-\\frac{3}{2}=0$.", - "Output Answer": [ - "$\\frac{46}{\\sqrt{113}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, -3, -1\nplane = Poly(-((9*x)/2)+2*y+2*z-(3/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{14}{5} & -\\frac{44}{5} \\\\\n \\frac{14}{5} & -\\frac{38}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{7} \\left(13-\\sqrt{15}\\right),1\\right\\}, \\left\\{\\frac{1}{7} \\left(13+\\sqrt{15}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/5), -(44/5)],\n [(14/5), -(38/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 3 & \\frac{3}{4} & 2 & -\\frac{1}{2} \\\\\n -\\frac{5}{2} & -\\frac{5}{4} & -2 & -\\frac{5}{2} \\\\\n -2 & -\\frac{1}{2} & \\frac{5}{2} & \\frac{1}{2} \\\\\n \\frac{5}{4} & \\frac{1}{4} & 0 & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{9}{4} & \\frac{3}{2} & -2 & -\\frac{11}{4} \\\\\n -\\frac{3}{4} & \\frac{1}{2} & -\\frac{7}{4} & -3 \\\\\n -\\frac{11}{4} & -\\frac{3}{2} & -\\frac{3}{2} & \\frac{1}{4} \\\\\n -\\frac{3}{4} & 0 & \\frac{3}{2} & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{17}{16} & \\frac{15}{8} & -\\frac{177}{16} & -\\frac{17}{2} \\\\\n \\frac{43}{16} & -\\frac{11}{8} & \\frac{103}{16} & \\frac{141}{8} \\\\\n -\\frac{91}{8} & -7 & \\frac{15}{8} & \\frac{49}{8} \\\\\n \\frac{9}{2} & 2 & -\\frac{107}{16} & \\frac{53}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, (3/4), 2, -(1/2)],\n [-(5/2), -(5/4), -2, -(5/2)],\n [-2, -(1/2), (5/2), (1/2)],\n [(5/4), (1/4), 0, -(5/2)]])\nb = np.array([\n [(9/4), (3/2), -2, -(11/4)],\n [-(3/4), (1/2), -(7/4), -3],\n [-(11/4), -(3/2), -(3/2), (1/4)],\n [-(3/4), 0, (3/2), -3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & -3 & 1 \\\\\n -3 & 4 & 3 \\\\\n 5 & -2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-47$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3, 1],\n [-3, 4, 3],\n [5, -2, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & -1 \\\\\n 8 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-3-2 \\sqrt{2},2 \\sqrt{2}-3\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1],\n [8, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{43}{10} & \\frac{13}{2} & \\frac{61}{10} \\\\\n -\\frac{79}{10} & -\\frac{22}{5} & -\\frac{21}{5} \\\\\n -\\frac{17}{2} & \\frac{32}{5} & -\\frac{17}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{9 x^2}{5}-\\frac{11133 x}{100}-\\frac{244053}{1000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(43/10), (13/2), (61/10)],\n [-(79/10), -(22/5), -(21/5)],\n [-(17/2), (32/5), -(17/10)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & 4 \\\\\n -6 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+13 x+60$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 4],\n [-6, -9]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{24}{5} & -5 \\\\\n -\\frac{4}{5} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{116}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(24/5), -5],\n [-(4/5), -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8.87 \\\\\n -5.548 \\\\\n 1.823 \\\\\n 6.997 \\\\\n -9.845 \\\\\n -5.864 \\\\\n 3.14 \\\\\n -9.54 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1.913 \\\\\n -6.705 \\\\\n -7.194 \\\\\n 9.792 \\\\\n -3.397 \\\\\n -4.76 \\\\\n 1.432 \\\\\n -3.143 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$171.468$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8.87],\n [-5.548],\n [1.823],\n [6.997],\n [-9.845],\n [-5.864],\n [3.14],\n [-9.54]])\nb = np.array([\n [-1.913],\n [-6.705],\n [-7.194],\n [9.792],\n [-3.397],\n [-4.76],\n [1.432],\n [-3.143]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & 0 & 0 \\\\\n 2 & 0 & 2 \\\\\n 2 & 1 & 0 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 2 & 2 & 0 \\\\\n 0 & 0 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, 0],\n [2, 0, 2],\n [2, 1, 0]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -\\frac{19}{4} & \\frac{5}{2} & \\frac{7}{8} & \\frac{27}{4} \\\\\n \\frac{5}{8} & -\\frac{27}{8} & -\\frac{45}{8} & -\\frac{59}{8} \\\\\n -\\frac{33}{4} & -\\frac{3}{8} & \\frac{1}{4} & -\\frac{7}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/4), (5/2), (7/8), (27/4)],\n [(5/8), -(27/8), -(45/8), -(59/8)],\n [-(33/4), -(3/8), (1/4), -(7/4)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2-4 i & -4-4 i & -1+3 i \\\\\n -1+3 i & -4-4 i & 2-3 i \\\\\n -2+2 i & 4+i & -3-4 i \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -198-88 i & 367-211 i & 132+152 i \\\\\n -39-151 i & -363-342 i & 198+230 i \\\\\n 139-95 i & -154+52 i & -171-44 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2-4j, -4-4j, -1+3j],\n [-1+3j, -4-4j, 2-3j],\n [-2+2j, 4+ 1j, -3-4j]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [2]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -3 & 10 & 8 & 1 & 4 & 9 & 10 \\\\\n -3 & -9 & -10 & 9 & -3 & -3 & -1 \\\\\n 5 & -10 & 1 & -2 & -4 & -10 & -9 \\\\\n 10 & 2 & -5 & -6 & -7 & -6 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & -\\frac{2119}{2415} & -\\frac{4376}{7245} & \\frac{8408}{7245} \\\\\n 0 & 1 & 0 & 0 & \\frac{137}{2415} & \\frac{4828}{7245} & \\frac{8591}{7245} \\\\\n 0 & 0 & 1 & 0 & \\frac{121}{805} & \\frac{104}{2415} & \\frac{43}{2415} \\\\\n 0 & 0 & 0 & 1 & -\\frac{971}{2415} & \\frac{1301}{7245} & \\frac{10732}{7245} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 10, 8, 1, 4, 9, 10],\n [-3, -9, -10, 9, -3, -3, -1],\n [5, -10, 1, -2, -4, -10, -9],\n [10, 2, -5, -6, -7, -6, 5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{10}{3} \\\\\n \\frac{8}{3} \\\\\n 2 \\\\\n \\frac{26}{3} \\\\\n \\frac{17}{3} \\\\\n \\frac{16}{3} \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{1457}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(10/3)],\n [(8/3)],\n [2],\n [(26/3)],\n [(17/3)],\n [(16/3)],\n [-2]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 5 & -2 \\\\\n 9 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-3 x+8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -2],\n [9, -2]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,-1,-2\\}, \\{2,-2,2\\}, \\{2,1,3\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{2}{3},-\\frac{1}{3},-\\frac{2}{3}\\right\\}, \\left\\{\\frac{1}{3 \\sqrt{2}},-\\frac{2 \\sqrt{2}}{3},\\frac{1}{3 \\sqrt{2}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{2}},0,\\frac{1}{\\sqrt{2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, -1, -2), (2, -2, 2), (2, 1, 3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n \\frac{19}{8} & \\frac{1}{4} & \\frac{39}{16} & -\\frac{159}{16} & -\\frac{3}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/8), (1/4), (39/16), -(159/16), -(3/8)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{1}{5} & \\frac{6}{5} & \\frac{19}{5} & -\\frac{26}{5} & \\frac{29}{5} \\\\\n \\frac{18}{5} & \\frac{6}{5} & \\frac{43}{5} & \\frac{47}{5} & -\\frac{17}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/5), (6/5), (19/5), -(26/5), (29/5)],\n [(18/5), (6/5), (43/5), (47/5), -(17/5)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{9} \\\\\n \\frac{80}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/9)],\n [(80/9)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -6 & 9 & 0 & 2 \\\\\n 7 & -6 & -6 & 3 \\\\\n 3 & 9 & 9 & 7 \\\\\n -5 & -4 & -10 & -3 \\\\\n 7 & -5 & 10 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-6, 9, 0, 2],\n [7, -6, -6, 3],\n [3, 9, 9, 7],\n [-5, -4, -10, -3],\n [7, -5, 10, 5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & -1 \\\\\n -1 & 3 \\\\\n -1 & 1 \\\\\n 0 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.5 \\\\\n 0.33 \\\\\n -0.1 \\\\\n -0.92 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.148 \\\\\n 0.097 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1],\n [-1, 3],\n [-1, 1],\n [0, -1]])\nb = np.array([\n [0.5],\n [0.33],\n [-0.1],\n [-0.92]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{41}{5} \\\\\n \\frac{36}{5} \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{2}{5} \\\\\n 10 \\\\\n -\\frac{46}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3906}{25} \\\\\n -\\frac{1796}{25} \\\\\n -\\frac{2122}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(41/5)],\n [(36/5)],\n [9]])\nb = np.array([\n [(2/5)],\n [10],\n [-(46/5)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{14}{3},\\frac{10}{3},-\\frac{5}{3}\\right\\}, \\left\\{\\frac{11}{3},5,\\frac{1}{3}\\right\\}, \\left\\{\\frac{14}{3},-\\frac{4}{3},-\\frac{7}{3}\\right\\}}$.", - "Output Answer": [ - "$111 x-9 y+63 z-383=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(14/3), (10/3), -(5/3)],\n [(11/3), 5, (1/3)],\n [(14/3), -(4/3), -(7/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{3}{8} & \\frac{23}{16} & \\frac{9}{4} & -\\frac{3}{16} & -\\frac{19}{8} \\\\\n -\\frac{41}{16} & -\\frac{3}{2} & -\\frac{33}{16} & -\\frac{1}{2} & \\frac{31}{16} \\\\\n -\\frac{3}{4} & -\\frac{43}{16} & -\\frac{27}{16} & \\frac{41}{16} & -\\frac{11}{4} \\\\\n -\\frac{27}{16} & -\\frac{47}{16} & \\frac{3}{2} & -\\frac{1}{4} & \\frac{3}{2} \\\\\n \\frac{9}{16} & -\\frac{23}{16} & \\frac{15}{8} & -\\frac{1}{16} & \\frac{15}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{16} & -\\frac{19}{8} \\\\\n -\\frac{7}{4} & \\frac{17}{16} \\\\\n \\frac{5}{4} & \\frac{7}{8} \\\\\n -\\frac{45}{16} & -\\frac{1}{4} \\\\\n \\frac{3}{2} & -\\frac{1}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{671}{256} & \\frac{1173}{256} \\\\\n \\frac{1321}{256} & \\frac{689}{256} \\\\\n -\\frac{2177}{256} & -\\frac{773}{256} \\\\\n \\frac{2687}{256} & \\frac{555}{256} \\\\\n \\frac{401}{64} & -\\frac{81}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/8), (23/16), (9/4), -(3/16), -(19/8)],\n [-(41/16), -(3/2), -(33/16), -(1/2), (31/16)],\n [-(3/4), -(43/16), -(27/16), (41/16), -(11/4)],\n [-(27/16), -(47/16), (3/2), -(1/4), (3/2)],\n [(9/16), -(23/16), (15/8), -(1/16), (15/16)]])\nb = np.array([\n [-(5/16), -(19/8)],\n [-(7/4), (17/16)],\n [(5/4), (7/8)],\n [-(45/16), -(1/4)],\n [(3/2), -(1/16)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2 & 2 & -\\frac{1}{2} \\\\\n -1 & -\\frac{3}{2} & \\frac{5}{2} \\\\\n -\\frac{1}{2} & -2 & 1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{4} & \\frac{5}{2} & -\\frac{85}{8} \\\\\n \\frac{5}{8} & \\frac{105}{8} & -\\frac{55}{4} \\\\\n -\\frac{25}{8} & \\frac{25}{2} & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2, -(1/2)],\n [-1, -(3/2), (5/2)],\n [-(1/2), -2, 1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 7 & -2 & 1 & 8 & 0 & 0 & 6 \\\\\n 7 & -2 & 6 & -9 & -9 & -8 & 6 \\\\\n -9 & 2 & -9 & -6 & 1 & 6 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & \\frac{63}{5} & \\frac{67}{10} & \\frac{17}{5} & 0 \\\\\n 0 & 1 & 0 & \\frac{192}{5} & \\frac{451}{20} & \\frac{111}{10} & -3 \\\\\n 0 & 0 & 1 & -\\frac{17}{5} & -\\frac{9}{5} & -\\frac{8}{5} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, -2, 1, 8, 0, 0, 6],\n [7, -2, 6, -9, -9, -8, 6],\n [-9, 2, -9, -6, 1, 6, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 3 & -8 \\\\\n 0 & -6 \\\\\n 9 & -9 \\\\\n 3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, -8],\n [0, -6],\n [9, -9],\n [3, 1]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 8 & 2 & 10 \\\\\n 9 & -5 & 3 \\\\\n -9 & -8 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+11 x^2-80 x-1496$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 2, 10],\n [9, -5, 3],\n [-9, -8, 8]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{59}{6} & 2 \\\\\n \\frac{5}{2} & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{5 x}{6}-\\frac{187}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(59/6), 2],\n [(5/2), 9]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 3 & 0 & -8 & -7 & 5 \\\\\n 2 & 5 & 0 & 1 & 7 \\\\\n -2 & -4 & -3 & -1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & -\\frac{97}{61} & -\\frac{69}{61} \\\\\n 0 & 1 & 0 & \\frac{51}{61} & \\frac{113}{61} \\\\\n 0 & 0 & 1 & \\frac{17}{61} & -\\frac{64}{61} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, 0, -8, -7, 5],\n [2, 5, 0, 1, 7],\n [-2, -4, -3, -1, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{7} \\\\\n -\\frac{24}{7} \\\\\n \\frac{19}{7} \\\\\n \\frac{65}{7} \\\\\n \\frac{6}{7} \\\\\n \\frac{60}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{177}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/7)],\n [-(24/7)],\n [(19/7)],\n [(65/7)],\n [(6/7)],\n [(60/7)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{2}{5}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 9 & -6 \\\\\n -7 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{18}{5} & \\frac{12}{5} \\\\\n \\frac{14}{5} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -6],\n [-7, 0]])\nprint(a * -(2/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -3 & -3 & -3 \\\\\n 4 & 0 & -8 \\\\\n 1 & 9 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-11 x^2-111 x-396$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3, -3],\n [4, 0, -8],\n [1, 9, -8]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{2} \\\\\n -6 \\\\\n -\\frac{17}{4} \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{13}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2)],\n [-6],\n [-(17/4)],\n [3]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & 1 & -3 \\\\\n -2 & -1 & -2 \\\\\n -1 & 3 & -1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 19 & 14 & 16 \\\\\n 4 & 41 & -8 \\\\\n 16 & -4 & 31 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, -3],\n [-2, -1, -2],\n [-1, 3, -1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{4,2,-2\\}, \\{-1,3,-5\\}, \\{-3,-1,2\\}}$.", - "Output Answer": [ - "$5 x-41 y-22 z+18=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, 2, -2],\n [-1, 3, -5],\n [-3, -1, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0.2 \\\\\n 3.9 \\\\\n -9.3 \\\\\n -9.8 \\\\\n -0.3 \\\\\n 5. \\\\\n 0.7 \\\\\n -4.5 \\\\\n -9.6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8.9 \\\\\n -0.3 \\\\\n 5.2 \\\\\n -2.3 \\\\\n 0.3 \\\\\n -5.6 \\\\\n 6.5 \\\\\n 1.7 \\\\\n -3.2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$24.199$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0.2],\n [3.9],\n [-9.3],\n [-9.8],\n [-0.3],\n [5.],\n [0.7],\n [-4.5],\n [-9.6]])\nb = np.array([\n [8.9],\n [-0.3],\n [5.2],\n [-2.3],\n [0.3],\n [-5.6],\n [6.5],\n [1.7],\n [-3.2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & 2 \\\\\n 0 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-10,3\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2],\n [0, -10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -2 \\\\\n -9 \\\\\n -2 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -2 \\\\\n -2 \\\\\n 4 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$28$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-2],\n [-9],\n [-2],\n [7]])\nb = np.array([\n [-1],\n [-2],\n [-2],\n [4],\n [3]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{27}{10} & -\\frac{9}{5} \\\\\n -\\frac{13}{10} & -\\frac{6}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{4}{3} & 2 \\\\\n \\frac{13}{9} & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(27/10), -(9/5)],\n [-(13/10), -(6/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 8 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [8],\n [3]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{15}{8} \\\\\n \\frac{11}{8} \\\\\n \\frac{5}{8} \\\\\n -\\frac{5}{2} \\\\\n -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{\\sqrt{31}} \\\\\n \\frac{11}{5 \\sqrt{31}} \\\\\n \\frac{1}{\\sqrt{31}} \\\\\n -\\frac{4}{\\sqrt{31}} \\\\\n -\\frac{2}{5 \\sqrt{31}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/8)],\n [(11/8)],\n [(5/8)],\n [-(5/2)],\n [-(1/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{8}{7}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -5 & -7 & -8 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{40}{7} & -8 & -\\frac{64}{7} & \\frac{40}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -7, -8, 5]])\nprint(a * (8/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4.258 \\\\\n 6.652 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5.573 \\\\\n -1.304 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$12.647$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4.258],\n [6.652]])\nb = np.array([\n [5.573],\n [-1.304]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n 1 & -\\frac{27}{4} & -\\frac{17}{2} & \\frac{41}{8} & \\frac{29}{8} \\\\\n \\frac{15}{4} & 0 & -\\frac{7}{8} & -\\frac{71}{8} & \\frac{19}{2} \\\\\n \\frac{79}{8} & 2 & \\frac{15}{2} & -\\frac{13}{4} & 0 \\\\\n \\frac{15}{8} & \\frac{11}{4} & \\frac{39}{8} & -\\frac{21}{8} & -\\frac{41}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(27/4), -(17/2), (41/8), (29/8)],\n [(15/4), 0, -(7/8), -(71/8), (19/2)],\n [(79/8), 2, (15/2), -(13/4), 0],\n [(15/8), (11/4), (39/8), -(21/8), -(41/8)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{2} & -2 & \\frac{16}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), -2, (16/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & -5 & 5 \\\\\n 3 & -3 & -2 \\\\\n 1 & -1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-20$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -5, 5],\n [3, -3, -2],\n [1, -1, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -6 & -9 & -3 \\\\\n -6 & 6 & 3 \\\\\n 7 & -1 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-7.613,-5.608,8.221\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -9, -3],\n [-6, 6, 3],\n [7, -1, -5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{6}{\\pi },-\\frac{7}{\\pi },-\\frac{1}{\\pi }\\right\\}, \\left\\{\\frac{5}{\\pi },-\\frac{2}{\\pi },\\frac{5}{\\pi }\\right\\}, \\left\\{\\frac{4}{\\pi },\\frac{7}{\\pi },\\frac{9}{\\pi }\\right\\}}$", - "Output Answer": [ - "${\\left\\{3 \\sqrt{\\frac{2}{43}},-\\frac{7}{\\sqrt{86}},-\\frac{1}{\\sqrt{86}}\\right\\}, \\left\\{\\frac{98 \\sqrt{\\frac{2}{14921}}}{3},\\frac{101}{3 \\sqrt{29842}},\\frac{469}{3 \\sqrt{29842}}\\right\\}, \\left\\{\\frac{37}{3 \\sqrt{347}},\\frac{35}{3 \\sqrt{347}},-\\frac{23}{3 \\sqrt{347}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((6/math.pi), -(7/math.pi), -(1/math.pi)), ((5/math.pi), -(2/math.pi), (5/math.pi)), ((4/math.pi), (7/math.pi), (9/math.pi))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -10 & 8 & 7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -1 & 9 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -9 & -1 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 8, 7]])\nb = np.array([\n [-1, 9, 5]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{3} \\\\\n \\frac{2}{3} \\\\\n \\frac{4}{3} \\\\\n \\frac{5}{3} \\\\\n -\\frac{4}{3} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -\\frac{1}{3} \\\\\n \\frac{4}{3} \\\\\n 0 \\\\\n -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{56}{57},-\\frac{28}{171},\\frac{112}{171},0,-\\frac{56}{171}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/3)],\n [(2/3)],\n [(4/3)],\n [(5/3)],\n [-(4/3)]]).squeeze()\nb = np.array([\n [2],\n [-(1/3)],\n [(4/3)],\n [0],\n [-(2/3)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{143}{16} & -\\frac{25}{16} & \\frac{69}{8} & \\frac{1}{8} \\\\\n -5 & \\frac{107}{16} & -\\frac{25}{4} & -\\frac{13}{8} \\\\\n \\frac{13}{16} & -\\frac{43}{8} & -5 & -\\frac{43}{16} \\\\\n -\\frac{39}{16} & \\frac{75}{8} & -\\frac{121}{16} & \\frac{141}{16} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{63}{16} & \\frac{59}{8} & \\frac{7}{16} & \\frac{135}{16} \\\\\n \\frac{41}{8} & \\frac{131}{16} & \\frac{67}{16} & -\\frac{13}{4} \\\\\n \\frac{21}{4} & \\frac{145}{16} & -\\frac{97}{16} & \\frac{13}{8} \\\\\n \\frac{43}{16} & 7 & -7 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -5 & -\\frac{143}{16} & \\frac{131}{16} & -\\frac{133}{16} \\\\\n -\\frac{81}{8} & -\\frac{3}{2} & -\\frac{167}{16} & \\frac{13}{8} \\\\\n -\\frac{71}{16} & -\\frac{231}{16} & \\frac{17}{16} & -\\frac{69}{16} \\\\\n -\\frac{41}{8} & \\frac{19}{8} & -\\frac{9}{16} & \\frac{77}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(143/16), -(25/16), (69/8), (1/8)],\n [-5, (107/16), -(25/4), -(13/8)],\n [(13/16), -(43/8), -5, -(43/16)],\n [-(39/16), (75/8), -(121/16), (141/16)]])\nb = np.array([\n [-(63/16), (59/8), (7/16), (135/16)],\n [(41/8), (131/16), (67/16), -(13/4)],\n [(21/4), (145/16), -(97/16), (13/8)],\n [(43/16), 7, -7, 4]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -7 & 7 & -3 & 5 \\\\\n 3 & 8 & 6 & -5 \\\\\n -10 & -10 & 7 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{873.,89.,719.,1529.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, 7, -3, 5],\n [3, 8, 6, -5],\n [-10, -10, 7, 3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n -6 \\\\\n 6 \\\\\n -3 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 10 \\\\\n -10 \\\\\n -8 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-14$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [-6],\n [6],\n [-3],\n [8]])\nb = np.array([\n [-9],\n [10],\n [-10],\n [-8],\n [-1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{75}{16} & -\\frac{3}{4} \\\\\n -\\frac{69}{16} & -\\frac{75}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{75 x}{8}+\\frac{4797}{256}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(75/16), -(3/4)],\n [-(69/16), -(75/16)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{19}{3} & -\\frac{8}{3} & \\frac{8}{3} & \\frac{53}{9} \\\\\n \\frac{23}{9} & -6 & \\frac{71}{9} & -\\frac{65}{9} \\\\\n \\frac{28}{9} & \\frac{34}{9} & -\\frac{76}{9} & \\frac{49}{9} \\\\\n \\frac{29}{3} & -\\frac{16}{9} & -\\frac{89}{9} & -\\frac{82}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 0 & -\\frac{76}{9} & \\frac{17}{9} & \\frac{4}{9} \\\\\n \\frac{83}{9} & 4 & \\frac{5}{9} & \\frac{11}{9} \\\\\n -\\frac{44}{9} & -6 & -\\frac{67}{9} & -\\frac{7}{3} \\\\\n -\\frac{76}{9} & \\frac{62}{9} & \\frac{28}{3} & -\\frac{68}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{19}{3} & -\\frac{100}{9} & \\frac{41}{9} & \\frac{19}{3} \\\\\n \\frac{106}{9} & -2 & \\frac{76}{9} & -6 \\\\\n -\\frac{16}{9} & -\\frac{20}{9} & -\\frac{143}{9} & \\frac{28}{9} \\\\\n \\frac{11}{9} & \\frac{46}{9} & -\\frac{5}{9} & -\\frac{50}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/3), -(8/3), (8/3), (53/9)],\n [(23/9), -6, (71/9), -(65/9)],\n [(28/9), (34/9), -(76/9), (49/9)],\n [(29/3), -(16/9), -(89/9), -(82/9)]])\nb = np.array([\n [0, -(76/9), (17/9), (4/9)],\n [(83/9), 4, (5/9), (11/9)],\n [-(44/9), -6, -(67/9), -(7/3)],\n [-(76/9), (62/9), (28/3), -(68/9)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 3 & 8 & 8 \\\\\n -6 & 4 & 3 \\\\\n 1 & 4 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+2 x^2-5 x-536$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 8, 8],\n [-6, 4, 3],\n [1, 4, -5]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -6 & 2 & -4 \\\\\n -5 & 0 & 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 2 & 8 & -1 \\\\\n -3 & 5 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -4 & 10 & -5 \\\\\n -8 & 5 & 18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 2, -4],\n [-5, 0, 9]])\nb = np.array([\n [2, 8, -1],\n [-3, 5, 9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -2 & -2 & 1 & 3 \\\\\n 3 & -1 & -2 & 3 \\\\\n -1 & 3 & -3 & -3 \\\\\n -2 & 2 & -2 & 1 \\\\\n -3 & -3 & -2 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.29 \\\\\n 1.23 \\\\\n 1.47 \\\\\n -1.26 \\\\\n -1.01 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.358 \\\\\n -0.049 \\\\\n -0.201 \\\\\n -0.164 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2, 1, 3],\n [3, -1, -2, 3],\n [-1, 3, -3, -3],\n [-2, 2, -2, 1],\n [-3, -3, -2, 1]])\nb = np.array([\n [-0.29],\n [1.23],\n [1.47],\n [-1.26],\n [-1.01]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{32}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 9 & -2 & 3 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{27}{32} & -\\frac{3}{16} & \\frac{9}{32} & \\frac{15}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -2, 3, 5]])\nprint(a * (3/32))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{59}{6} & \\frac{25}{6} \\\\\n \\frac{23}{3} & \\frac{11}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{27 x}{2}+\\frac{37}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(59/6), (25/6)],\n [(23/3), (11/3)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{2} \\\\\n \\frac{17}{2} \\\\\n 4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n \\frac{1}{2} \\\\\n -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{19}{2} \\\\\n 8 \\\\\n \\frac{17}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2)],\n [(17/2)],\n [4]])\nb = np.array([\n [-3],\n [(1/2)],\n [-(9/2)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -2 & -7 & -8 & 7 & -7 \\\\\n 1 & -1 & -1 & 5 & 3 \\\\\n 10 & 5 & -9 & -7 & -10 \\\\\n -9 & -4 & 10 & 8 & -3 \\\\\n -8 & 4 & 8 & -4 & 1 \\\\\n -7 & -2 & 1 & 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, -7, -8, 7, -7],\n [1, -1, -1, 5, 3],\n [10, 5, -9, -7, -10],\n [-9, -4, 10, 8, -3],\n [-8, 4, 8, -4, 1],\n [-7, -2, 1, 1, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -10 \\\\\n -\\frac{10}{3} \\\\\n -\\frac{26}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{19}{3} \\\\\n \\frac{2}{3} \\\\\n -1 \\\\\n \\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{122}{3 \\sqrt{26461}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-10],\n [-(10/3)],\n [-(26/3)]]).squeeze()\nb = np.array([\n [(19/3)],\n [(2/3)],\n [-1],\n [(7/3)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{29}{3} & \\frac{17}{3} & 6 \\\\\n -\\frac{13}{3} & -8 & -\\frac{4}{3} \\\\\n -\\frac{22}{3} & \\frac{25}{3} & \\frac{19}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.392,-0.357,1.\\}, \\{0.785\\, -0.341 i,-0.778-0.779 i,1.\\}, \\{0.785\\, +0.341 i,-0.778+0.779 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/3), (17/3), 6],\n [-(13/3), -8, -(4/3)],\n [-(22/3), (25/3), (19/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{17}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-2],\n [3]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{3} \\\\\n -\\frac{10}{9} \\\\\n \\frac{59}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{70}{9} \\\\\n \\frac{80}{9} \\\\\n -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{4480}{81} \\\\\n \\frac{3338}{81} \\\\\n -\\frac{1940}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/3)],\n [-(10/9)],\n [(59/9)]])\nb = np.array([\n [(70/9)],\n [(80/9)],\n [-(8/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & 1 & 4 \\\\\n -1 & -3 & -7 \\\\\n -1 & -7 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-20.294,1.366,1.\\}, \\{-0.869,-0.945,1.\\}, \\{-0.286,0.93,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 1, 4],\n [-1, -3, -7],\n [-1, -7, -4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & -2 \\\\\n 1 & 2 \\\\\n -3 & -2 \\\\\n -2 & 1 \\\\\n 3 & -2 \\\\\n -3 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.1 \\\\\n 1.43 \\\\\n -2.96 \\\\\n -0.49 \\\\\n 1.89 \\\\\n -1.88 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.706 \\\\\n 0.432 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2],\n [1, 2],\n [-3, -2],\n [-2, 1],\n [3, -2],\n [-3, 1]])\nb = np.array([\n [-0.1],\n [1.43],\n [-2.96],\n [-0.49],\n [1.89],\n [-1.88]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{11}{2} \\\\\n -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{3} \\\\\n -\\frac{26}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{41}{6} \\\\\n \\frac{19}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/2)],\n [-(11/2)]])\nb = np.array([\n [-(4/3)],\n [-(26/3)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,2,-3\\}, \\{3,-1,-2\\}, \\{4,-3,0\\}}$.", - "Output Answer": [ - "$4 x+13 y+11 z+23=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, 2, -3],\n [3, -1, -2],\n [4, -3, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{32}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -5 & 6 & -3 \\\\\n 4 & -8 & -6 \\\\\n -9 & 8 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{35}{32} & \\frac{21}{16} & -\\frac{21}{32} \\\\\n \\frac{7}{8} & -\\frac{7}{4} & -\\frac{21}{16} \\\\\n -\\frac{63}{32} & \\frac{7}{4} & -\\frac{7}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 6, -3],\n [4, -8, -6],\n [-9, 8, -1]])\nprint(a * (7/32))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -8 & -6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -5 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -3 & -15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -6]])\nb = np.array([\n [-5, 9]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{26}{9} \\\\\n -\\frac{89}{9} \\\\\n \\frac{31}{9} \\\\\n -\\frac{1}{3} \\\\\n -\\frac{85}{9} \\\\\n \\frac{14}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{2 \\sqrt{4639}}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/9)],\n [-(89/9)],\n [(31/9)],\n [-(1/3)],\n [-(85/9)],\n [(14/3)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & 3 & -1 \\\\\n 4 & -4 & 3 \\\\\n 2 & 4 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{16}{65} & \\frac{19}{130} & -\\frac{1}{26} \\\\\n \\frac{7}{65} & -\\frac{6}{65} & \\frac{1}{13} \\\\\n -\\frac{12}{65} & \\frac{1}{65} & \\frac{2}{13} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 3, -1],\n [4, -4, 3],\n [2, 4, 5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & -3 \\\\\n 3 & -3 \\\\\n -3 & -1 \\\\\n 3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.4 \\\\\n -0.44 \\\\\n -2.39 \\\\\n -0.45 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.521 \\\\\n 0.421 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3],\n [3, -3],\n [-3, -1],\n [3, -3]])\nb = np.array([\n [1.4],\n [-0.44],\n [-2.39],\n [-0.45]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -2 \\\\\n 7 \\\\\n 7 \\\\\n -8 \\\\\n -9 \\\\\n -6 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$52$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-2],\n [7],\n [7],\n [-8],\n [-9],\n [-6],\n [-4]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{13}{3},-\\frac{7}{3},-4\\right\\}, \\left\\{\\frac{8}{3},\\frac{1}{3},-3\\right\\}, \\left\\{5,-\\frac{10}{3},0\\right\\}}$.", - "Output Answer": [ - "$15 x-24 y-41 z-155=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(13/3), -(7/3), -4],\n [(8/3), (1/3), -3],\n [5, -(10/3), 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 3 & -1 & 1 & -1 \\\\\n -1 & -1 & -2 & 2 \\\\\n 2 & -1 & -1 & -1 \\\\\n 0 & 1 & 1 & -1 \\\\\n 1 & -2 & 1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 8 \\\\\n -6 \\\\\n 4 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, 1, -1],\n [-1, -1, -2, 2],\n [2, -1, -1, -1],\n [0, 1, 1, -1],\n [1, -2, 1, 2]])\nb = np.array([\n [2],\n [0],\n [1],\n [-1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{11}{5} & -\\frac{42}{5} & -10 & \\frac{7}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{36}{5} & -\\frac{24}{5} & -\\frac{33}{5} & -\\frac{27}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{47}{5} & -\\frac{66}{5} & -\\frac{83}{5} & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/5), -(42/5), -10, (7/5)]])\nb = np.array([\n [-(36/5), -(24/5), -(33/5), -(27/5)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & -9 \\\\\n 6 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-2-5 i \\sqrt{2},-2+5 i \\sqrt{2}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -9],\n [6, 0]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\sqrt{\\frac{2}{15}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [0],\n [-1],\n [1],\n [-1],\n [0],\n [1],\n [1],\n [0]]).squeeze()\nb = np.array([\n [0],\n [0],\n [0],\n [1],\n [-1],\n [-1],\n [-1],\n [-1],\n [0],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & 1 & 5 \\\\\n 7 & -4 & -8 \\\\\n 8 & -5 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-9.343,3.37,11.973\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 1, 5],\n [7, -4, -8],\n [8, -5, 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -5 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -6 \\\\\n 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -20 \\\\\n -5 \\\\\n -13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-5],\n [5]])\nb = np.array([\n [-5],\n [-6],\n [10]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -10 & 7 & 4 \\\\\n 4 & -10 & 0 \\\\\n 9 & -3 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.,-2.,3.\\}, \\{0.741,0.343,1.\\}, \\{-1.006,0.527,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 7, 4],\n [4, -10, 0],\n [9, -3, -7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n 7 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -7 \\\\\n -3 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-25$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [2],\n [7],\n [2]])\nb = np.array([\n [2],\n [-7],\n [-3],\n [4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{1,-2,0\\}, \\{3,-2,-1\\}, \\{1,-1,-1\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{5}},-\\frac{2}{\\sqrt{5}},0\\right\\}, \\left\\{\\frac{8}{\\sqrt{105}},\\frac{4}{\\sqrt{105}},-\\sqrt{\\frac{5}{21}}\\right\\}, \\left\\{-\\frac{2}{\\sqrt{21}},-\\frac{1}{\\sqrt{21}},-\\frac{4}{\\sqrt{21}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((1, -2, 0), (3, -2, -1), (1, -1, -1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -10 & 6 & -1 & 6 & -1 \\\\\n 7 & -5 & 5 & 1 & 3 \\\\\n 6 & 9 & -7 & -2 & 8 \\\\\n 9 & 2 & 5 & 7 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & \\frac{277}{104} \\\\\n 0 & 1 & 0 & 0 & -\\frac{145}{13} \\\\\n 0 & 0 & 1 & 0 & -\\frac{437}{26} \\\\\n 0 & 0 & 0 & 1 & \\frac{101}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, 6, -1, 6, -1],\n [7, -5, 5, 1, 3],\n [6, 9, -7, -2, 8],\n [9, 2, 5, 7, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$12 \\sqrt{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-6]])\nb = np.array([\n [7],\n [6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{8} \\\\\n -\\frac{39}{4} \\\\\n -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{8} \\\\\n \\frac{17}{4} \\\\\n -\\frac{1}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{787}{32} \\\\\n \\frac{657}{64} \\\\\n -\\frac{159}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/8)],\n [-(39/4)],\n [-(11/2)]])\nb = np.array([\n [-(15/8)],\n [(17/4)],\n [-(1/8)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{36}{5} \\\\\n \\frac{46}{5} \\\\\n -\\frac{33}{5} \\\\\n \\frac{27}{5} \\\\\n -\\frac{41}{5} \\\\\n \\frac{24}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{11}{5} \\\\\n \\frac{43}{5} \\\\\n 1 \\\\\n -4 \\\\\n -\\frac{13}{5} \\\\\n \\frac{2}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$90$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(36/5)],\n [(46/5)],\n [-(33/5)],\n [(27/5)],\n [-(41/5)],\n [(24/5)]])\nb = np.array([\n [(11/5)],\n [(43/5)],\n [1],\n [-4],\n [-(13/5)],\n [(2/5)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{8} \\\\\n \\frac{1}{2} \\\\\n \\frac{69}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{4} \\\\\n 2 \\\\\n -\\frac{63}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{339}{16} \\\\\n -\\frac{2031}{64} \\\\\n \\frac{27}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/8)],\n [(1/2)],\n [(69/8)]])\nb = np.array([\n [-(17/4)],\n [2],\n [-(63/8)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -2 & -3 & -2 \\\\\n 0 & 1 & -2 \\\\\n -3 & 3 & 0 \\\\\n -1 & 1 & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & 2 & 1 & 3 \\\\\n -1 & -1 & -1 & 2 \\\\\n -2 & 0 & 2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 3 & -1 & -3 & -10 \\\\\n 3 & -1 & -5 & 4 \\\\\n -9 & -9 & -6 & -3 \\\\\n -9 & -3 & 4 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, -2],\n [0, 1, -2],\n [-3, 3, 0],\n [-1, 1, 3]])\nb = np.array([\n [2, 2, 1, 3],\n [-1, -1, -1, 2],\n [-2, 0, 2, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{2}{5} & \\frac{5}{2} & -\\frac{9}{2} \\\\\n -3 & \\frac{18}{5} & \\frac{21}{10} \\\\\n -\\frac{1}{2} & -\\frac{17}{10} & -\\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{730}{15517} & -\\frac{11650}{46551} & -\\frac{7150}{15517} \\\\\n \\frac{1950}{15517} & \\frac{2890}{46551} & -\\frac{4220}{15517} \\\\\n -\\frac{2300}{15517} & \\frac{190}{15517} & -\\frac{2980}{15517} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/5), (5/2), -(9/2)],\n [-3, (18/5), (21/10)],\n [-(1/2), -(17/10), -(8/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -8 & \\frac{13}{3} & -1 & -\\frac{23}{3} \\\\\n -8 & \\frac{20}{3} & \\frac{20}{3} & -\\frac{7}{3} \\\\\n 4 & -2 & \\frac{22}{3} & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, (13/3), -1, -(23/3)],\n [-8, (20/3), (20/3), -(7/3)],\n [4, -2, (22/3), -6]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 5 & -4 & -5 \\\\\n -2 & 8 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{52.,25.,32.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, -4, -5],\n [-2, 8, -3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & 1 & -4 \\\\\n -2 & 4 & -4 \\\\\n -2 & 0 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{10}{37} & -\\frac{5}{74} & -\\frac{6}{37} \\\\\n \\frac{1}{37} & \\frac{9}{37} & -\\frac{8}{37} \\\\\n -\\frac{4}{37} & \\frac{1}{37} & -\\frac{5}{37} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, -4],\n [-2, 4, -4],\n [-2, 0, -5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{58}{\\sqrt{8989}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [8]]).squeeze()\nb = np.array([\n [10],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{4}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 6 & 1 \\\\\n 7 & -10 \\\\\n -7 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & -\\frac{1}{4} \\\\\n -\\frac{7}{4} & \\frac{5}{2} \\\\\n \\frac{7}{4} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 1],\n [7, -10],\n [-7, -10]])\nprint(a * -(1/4))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{4}{3},-\\frac{4}{3},-1\\right\\}, \\left\\{-2,\\frac{2}{3},\\frac{4}{3}\\right\\}, \\left\\{\\frac{4}{3},\\frac{4}{3},3\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{4}{\\sqrt{41}},-\\frac{4}{\\sqrt{41}},-\\frac{3}{\\sqrt{41}}\\right\\}, \\left\\{-23 \\sqrt{\\frac{5}{4674}},\\frac{49}{\\sqrt{23370}},44 \\sqrt{\\frac{2}{11685}}\\right\\}, \\left\\{\\sqrt{\\frac{5}{114}},-\\frac{17}{\\sqrt{570}},8 \\sqrt{\\frac{2}{285}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-(4/3), -(4/3), -1), (-2, (2/3), (4/3)), ((4/3), (4/3), 3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 0 & 3 \\\\\n -3 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 0 & 3 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & 0 \\\\\n 0 & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 3],\n [-3, 0]])\nb = np.array([\n [0, 3],\n [0, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -4 & 5 \\\\\n 0 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$16$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 5],\n [0, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 9 & 9 & 2 & 0 \\\\\n -3 & -4 & -7 & 5 \\\\\n -10 & -10 & -3 & -6 \\\\\n -6 & -1 & 4 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, 9, 2, 0],\n [-3, -4, -7, 5],\n [-10, -10, -3, -6],\n [-6, -1, 4, 7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3.185 \\\\\n 8.134 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1.911 \\\\\n 6.701 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5.29365$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3.185],\n [8.134]])\nb = np.array([\n [-1.911],\n [6.701]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{11}{6} \\\\\n \\frac{11}{6} \\\\\n -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{11}{\\sqrt{246}} \\\\\n \\frac{11}{\\sqrt{246}} \\\\\n -\\sqrt{\\frac{2}{123}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [(11/6)],\n [(11/6)],\n [-(1/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 3 \\\\\n -2 & 3 \\\\\n 3 & -3 \\\\\n -3 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.53 \\\\\n 1.63 \\\\\n -0.75 \\\\\n 1.98 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.134 \\\\\n 0.486 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3],\n [-2, 3],\n [3, -3],\n [-3, 0]])\nb = np.array([\n [2.53],\n [1.63],\n [-0.75],\n [1.98]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{3} \\\\\n \\frac{7}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{16}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{95}{\\sqrt{15914}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/3)],\n [(7/3)]]).squeeze()\nb = np.array([\n [2],\n [(16/3)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 2 & -2 & -1 & 0 \\\\\n -2 & 0 & -1 & 0 \\\\\n 4 & 0 & 3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n e & 0 & 0 & 0 \\\\\n e-\\frac{1}{e} & \\frac{1}{e^2} & \\frac{1}{e^2}-\\frac{1}{e} & 0 \\\\\n \\frac{1}{e}-e & 0 & \\frac{1}{e} & 0 \\\\\n -\\frac{1}{e}-e+2 e^2 & 0 & e^2-\\frac{1}{e} & e^2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [1, 0, 0, 0],\n [2, -2, -1, 0],\n [-2, 0, -1, 0],\n [4, 0, 3, 2]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{13}{3},-\\frac{4}{3},3\\right\\}, \\left\\{2,-\\frac{14}{3},4\\right\\}, \\left\\{-\\frac{13}{3},3,-4\\right\\}}$.", - "Output Answer": [ - "$9 x+21 y+13 z+28=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(13/3), -(4/3), 3],\n [2, -(14/3), 4],\n [-(13/3), 3, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0.6 \\\\\n -9.1 \\\\\n -3.9 \\\\\n 9.4 \\\\\n 0.9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6.3 \\\\\n -7.4 \\\\\n 9.8 \\\\\n -4. \\\\\n -7.6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$21.7917$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0.6],\n [-9.1],\n [-3.9],\n [9.4],\n [0.9]])\nb = np.array([\n [6.3],\n [-7.4],\n [9.8],\n [-4.],\n [-7.6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 10 & 7 & -4 & 6 \\\\\n 6 & -2 & 2 & 10 \\\\\n -10 & -2 & -4 & -10 \\\\\n -1 & -6 & 8 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, 7, -4, 6],\n [6, -2, 2, 10],\n [-10, -2, -4, -10],\n [-1, -6, 8, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{3} \\\\\n -\\frac{22}{3} \\\\\n 2 \\\\\n \\frac{28}{3} \\\\\n 7 \\\\\n \\frac{14}{3} \\\\\n -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{16}{3} \\\\\n -\\frac{7}{3} \\\\\n -6 \\\\\n -4 \\\\\n 4 \\\\\n \\frac{10}{3} \\\\\n \\frac{23}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{\\frac{1198}{3}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3)],\n [-(22/3)],\n [2],\n [(28/3)],\n [7],\n [(14/3)],\n [-(7/3)]])\nb = np.array([\n [-(16/3)],\n [-(7/3)],\n [-6],\n [-4],\n [4],\n [(10/3)],\n [(23/3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & -\\frac{4}{5} \\\\\n -\\frac{8}{5} & \\frac{2}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{12}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(4/5)],\n [-(8/5), (2/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -7 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{69}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-7],\n [4]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{14}{\\sqrt{3}} \\\\\n -\\sqrt{3} \\\\\n -\\frac{14}{\\sqrt{3}} \\\\\n \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{13}{\\sqrt{3}} \\\\\n -\\sqrt{3} \\\\\n -\\frac{5}{\\sqrt{3}} \\\\\n \\frac{13}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$100$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(14/(math.sqrt(3)))],\n [-math.sqrt(3)],\n [-(14/(math.sqrt(3)))],\n [math.sqrt(3)]])\nb = np.array([\n [(13/(math.sqrt(3)))],\n [-math.sqrt(3)],\n [-(5/(math.sqrt(3)))],\n [(13/(math.sqrt(3)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 5 \\\\\n 7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 2 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -10 \\\\\n 3 \\\\\n 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [5],\n [7]])\nb = np.array([\n [9],\n [2],\n [-4]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & -9 \\\\\n 7 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-2-i \\sqrt{59},-2+i \\sqrt{59}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -9],\n [7, -4]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{3} \\\\\n 0 \\\\\n -\\frac{8}{3} \\\\\n \\frac{8}{3} \\\\\n -\\frac{4}{3} \\\\\n -2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n \\frac{7}{3} \\\\\n \\frac{2}{3} \\\\\n 2 \\\\\n -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{0,0,-\\frac{119}{171},-\\frac{34}{171},-\\frac{34}{57},\\frac{85}{171}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/3)],\n [0],\n [-(8/3)],\n [(8/3)],\n [-(4/3)],\n [-2]]).squeeze()\nb = np.array([\n [0],\n [0],\n [(7/3)],\n [(2/3)],\n [2],\n [-(5/3)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 7 \\\\\n -8 \\\\\n -7 \\\\\n 0 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$11 \\sqrt{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [7],\n [-8],\n [-7],\n [0],\n [-4]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -2 & 2 & -2 & -2 & -2 \\\\\n 1 & -2 & 2 & -3 & 3 \\\\\n -2 & -1 & -1 & 0 & -3 \\\\\n 2 & 2 & 1 & -3 & 2 \\\\\n 0 & 0 & 1 & -1 & 0 \\\\\n -1 & -3 & 2 & 1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.99 \\\\\n 2.51 \\\\\n 1.42 \\\\\n 1.32 \\\\\n 1.69 \\\\\n -2.12 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.576 \\\\\n -0.829 \\\\\n 0.508 \\\\\n -0.881 \\\\\n -1.501 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2, -2, -2, -2],\n [1, -2, 2, -3, 3],\n [-2, -1, -1, 0, -3],\n [2, 2, 1, -3, 2],\n [0, 0, 1, -1, 0],\n [-1, -3, 2, 1, 2]])\nb = np.array([\n [-0.99],\n [2.51],\n [1.42],\n [1.32],\n [1.69],\n [-2.12]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -5 & -1 & \\frac{7}{2} \\\\\n -\\frac{9}{2} & \\frac{3}{2} & -\\frac{5}{2} \\\\\n 0 & -\\frac{7}{2} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{647}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -1, (7/2)],\n [-(9/2), (3/2), -(5/2)],\n [0, -(7/2), (3/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{9}{5}, \\frac{4}{5}, -\\frac{6}{5}}$ to the plane $4 x-\\frac{7 y}{5}-3 z-\\frac{6}{5}=0$.", - "Output Answer": [ - "$\\frac{106 \\sqrt{\\frac{2}{337}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (9/5), (4/5), -(6/5)\nplane = Poly(4*x-((7*y)/5)-3*z-(6/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{9}{7}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{27}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3]])\nprint(a * -(9/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, -\\frac{1}{2}}$ to the line $\\frac{9 x}{2}+y+\\frac{7}{2}=0$.", - "Output Answer": [ - "$\\frac{21}{\\sqrt{85}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, -(1/2)\nline = Poly(((9*x)/2)+y+(7/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 2 & -3 & 0 & -3 & 1 \\\\\n -3 & -3 & 3 & 2 & -2 \\\\\n 1 & 0 & -2 & 1 & -2 \\\\\n 3 & 2 & -3 & 2 & 3 \\\\\n -3 & 2 & 3 & -1 & -1 \\\\\n 0 & 0 & 1 & 3 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.18 \\\\\n -1.12 \\\\\n 2.7 \\\\\n 0.42 \\\\\n 2.78 \\\\\n 1.23 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.309 \\\\\n 0.881 \\\\\n 0.864 \\\\\n -0.113 \\\\\n -1.171 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3, 0, -3, 1],\n [-3, -3, 3, 2, -2],\n [1, 0, -2, 1, -2],\n [3, 2, -3, 2, 3],\n [-3, 2, 3, -1, -1],\n [0, 0, 1, 3, -1]])\nb = np.array([\n [-0.18],\n [-1.12],\n [2.7],\n [0.42],\n [2.78],\n [1.23]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,-2,2\\}, \\{-1,-2,-2\\}, \\{-3,0,0\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}},\\frac{1}{\\sqrt{3}}\\right\\}, \\left\\{-\\sqrt{\\frac{2}{39}},-\\frac{5}{\\sqrt{78}},-\\frac{7}{\\sqrt{78}}\\right\\}, \\left\\{-2 \\sqrt{\\frac{2}{13}},\\frac{3}{\\sqrt{26}},-\\frac{1}{\\sqrt{26}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, -2, 2), (-1, -2, -2), (-3, 0, 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 1 \\\\\n -5 \\\\\n 6 \\\\\n -7 \\\\\n 1 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$26$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [1],\n [-5],\n [6],\n [-7],\n [1],\n [3]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{46}{5} & -\\frac{23}{5} \\\\\n \\frac{33}{5} & \\frac{31}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(-15-\\sqrt{2893}\\right),\\frac{1}{10} \\left(\\sqrt{2893}-15\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(46/5), -(23/5)],\n [(33/5), (31/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -\\frac{5}{3} \\\\\n \\frac{3}{2} \\\\\n \\frac{11}{6} \\\\\n -\\frac{1}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 4 \\sqrt{\\frac{3}{149}} \\\\\n -\\frac{10}{\\sqrt{447}} \\\\\n 3 \\sqrt{\\frac{3}{149}} \\\\\n \\frac{11}{\\sqrt{447}} \\\\\n -\\frac{1}{\\sqrt{447}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-(5/3)],\n [(3/2)],\n [(11/6)],\n [-(1/6)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{2}+\\frac{i}{2} & 3 i & \\frac{5}{2}-i \\\\\n \\frac{5}{2}+i & -2-4 i & 2-\\frac{7 i}{2} \\\\\n -\\frac{7}{2}+3 i & \\frac{7}{2}-4 i & \\frac{7}{2}+\\frac{3 i}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{145}{2}+\\frac{467 i}{8} & -39-\\frac{521 i}{4} & \\frac{477}{8}+\\frac{255 i}{8} \\\\\n -\\frac{229}{8}+\\frac{343 i}{8} & -\\frac{23}{4}+\\frac{455 i}{8} & \\frac{91}{8}+\\frac{533 i}{8} \\\\\n -\\frac{161}{8}-\\frac{741 i}{8} & -\\frac{661}{8}+\\frac{709 i}{8} & -\\frac{611}{4}+\\frac{99 i}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2)+(1j/2), 3j, (5/2)- 1j],\n [(5/2)+ 1j, -2-4j, 2-((7j)/2)],\n [-(7/2)+3j, (7/2)-4j, (7/2)+((3j)/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -4 & -1 \\\\\n 3 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{4}{13} & -\\frac{1}{13} \\\\\n \\frac{3}{13} & \\frac{4}{13} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -1],\n [3, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-4, -\\frac{1}{3}, -1}$ to the plane $-2 x-2 y-\\frac{13 z}{3}+\\frac{5}{3}=0$.", - "Output Answer": [ - "$\\frac{44}{\\sqrt{241}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -4, -(1/3), -1\nplane = Poly(-2*x-2*y-((13*z)/3)+(5/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 0 & 1 & -2 \\\\\n 1 & -2 & -2 \\\\\n -4 & -4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{2}{35} & \\frac{11}{35} & -\\frac{6}{35} \\\\\n \\frac{11}{35} & -\\frac{8}{35} & -\\frac{2}{35} \\\\\n -\\frac{12}{35} & -\\frac{4}{35} & -\\frac{1}{35} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, -2],\n [1, -2, -2],\n [-4, -4, -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -1 & -9 & -4 & 6 & -1 \\\\\n 5 & 7 & -1 & -7 & -10 \\\\\n -7 & 0 & 9 & 7 & -4 \\\\\n -2 & -9 & 2 & -3 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{14117.,-3284.,8837.,3550.,1391.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, -9, -4, 6, -1],\n [5, 7, -1, -7, -10],\n [-7, 0, 9, 7, -4],\n [-2, -9, 2, -3, -6]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & \\frac{3}{2} & -\\frac{11}{6} \\\\\n -\\frac{13}{6} & -\\frac{7}{3} & \\frac{13}{6} \\\\\n \\frac{3}{2} & \\frac{7}{3} & \\frac{14}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{8389}{216}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, (3/2), -(11/6)],\n [-(13/6), -(7/3), (13/6)],\n [(3/2), (7/3), (14/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{25}{6} & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & \\frac{13}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{17}{3} & \\frac{19}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/6), 1]])\nb = np.array([\n [-(3/2), (13/6)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -8 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 6 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 34 \\\\\n -10 \\\\\n 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-8],\n [-3]])\nb = np.array([\n [2],\n [6],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{25}{4} & -2 & 8 \\\\\n \\frac{63}{16} & \\frac{133}{16} & -10 \\\\\n \\frac{135}{16} & \\frac{53}{8} & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{17 x^2}{16}+\\frac{3033 x}{64}-\\frac{35433}{64}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/4), -2, 8],\n [(63/16), (133/16), -10],\n [(135/16), (53/8), -1]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{11}{7} & -\\frac{30}{7} \\\\\n \\frac{6}{7} & \\frac{31}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{217}{521} & \\frac{210}{521} \\\\\n -\\frac{42}{521} & \\frac{77}{521} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/7), -(30/7)],\n [(6/7), (31/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 0 & 3 \\\\\n -5 & -2 & -1 \\\\\n 1 & 2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-24$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0, 3],\n [-5, -2, -1],\n [1, 2, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{3} \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{3} \\\\\n \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{3},-\\frac{4}{3}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3)],\n [-1]]).squeeze()\nb = np.array([\n [-(1/3)],\n [(4/3)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-1,1,0\\}, \\{2,-2,0\\}, \\{1,-1,1\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{2}},\\frac{1}{\\sqrt{2}},0\\right\\}, \\{0,0,0\\}, \\{0,0,1\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, 1, 0), (2, -2, 0), (1, -1, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{2} \\\\\n \\frac{3}{2} \\\\\n 0 \\\\\n -\\frac{7}{2} \\\\\n 4 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n \\frac{13}{2} \\\\\n -3 \\\\\n -\\frac{1}{2} \\\\\n \\frac{15}{2} \\\\\n -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{247}}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/2)],\n [(3/2)],\n [0],\n [-(7/2)],\n [4],\n [-6]])\nb = np.array([\n [-7],\n [(13/2)],\n [-3],\n [-(1/2)],\n [(15/2)],\n [-(7/2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -5 & -3 \\\\\n -4 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-17$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -3],\n [-4, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 5 & -1 & 9 & -1 & 10 \\\\\n 2 & -7 & 8 & -4 & -2 \\\\\n -7 & -10 & 0 & 3 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & -\\frac{89}{33} & -\\frac{97}{33} \\\\\n 0 & 1 & 0 & \\frac{262}{165} & \\frac{488}{165} \\\\\n 0 & 0 & 1 & \\frac{86}{55} & \\frac{169}{55} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, -1, 9, -1, 10],\n [2, -7, 8, -4, -2],\n [-7, -10, 0, 3, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{2} & -\\frac{5}{2} & -\\frac{5}{2} \\\\\n -1 & \\frac{3}{2} & \\frac{5}{2} \\\\\n \\frac{7}{2} & 3 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{27}{85} & -\\frac{7}{17} & -\\frac{1}{17} \\\\\n \\frac{19}{170} & \\frac{15}{34} & \\frac{7}{34} \\\\\n -\\frac{33}{170} & -\\frac{1}{34} & -\\frac{5}{34} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), -(5/2), -(5/2)],\n [-1, (3/2), (5/2)],\n [(7/2), 3, -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 2 & -5 & -3 \\\\\n 9 & 3 & -3 \\\\\n -3 & 3 & -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-5 x^2-x-645$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -5, -3],\n [9, 3, -3],\n [-3, 3, -10]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -1+\\frac{3 i}{2} & 2+4 i \\\\\n -\\frac{5}{2} & 4-\\frac{5 i}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{3}{4}-\\frac{171 i}{8} & \\frac{209}{2}-36 i \\\\\n -\\frac{65}{8}+\\frac{245 i}{4} & -81-\\frac{1255 i}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1+((3j)/2), 2+4j],\n [-(5/2), 4-((5j)/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -3 & -2 \\\\\n 0 & -2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 9 & 10 \\\\\n 0 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2],\n [0, -2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 0 \\\\\n 5 \\\\\n -3 \\\\\n -1 \\\\\n -7 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -1 \\\\\n 5 \\\\\n 7 \\\\\n 1 \\\\\n -7 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{365}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [0],\n [5],\n [-3],\n [-1],\n [-7],\n [-9]])\nb = np.array([\n [4],\n [-1],\n [5],\n [7],\n [1],\n [-7],\n [7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{3} & -\\frac{40}{9} \\\\\n -\\frac{5}{3} & \\frac{10}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{9} & -\\frac{4}{9} \\\\\n -\\frac{1}{6} & \\frac{7}{30} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/3), -(40/9)],\n [-(5/3), (10/9)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-24$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [3]])\nb = np.array([\n [3],\n [-5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{20}{7} \\\\\n -7 \\\\\n -\\frac{6}{7} \\\\\n \\frac{20}{7} \\\\\n -\\frac{39}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{4758}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/7)],\n [-7],\n [-(6/7)],\n [(20/7)],\n [-(39/7)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{2,\\frac{14}{3},-\\frac{8}{3}\\right\\}, \\left\\{-4,-\\frac{8}{3},-4\\right\\}, \\left\\{-\\frac{8}{3},\\frac{5}{3},-\\frac{5}{3}\\right\\}}$.", - "Output Answer": [ - "$153 x-165 y+219 z+1048=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, (14/3), -(8/3)],\n [-4, -(8/3), -4],\n [-(8/3), (5/3), -(5/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{13}{6}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 10 & -5 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{65}{3} & \\frac{65}{6} & -13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -5, 6]])\nprint(a * -(13/6))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 1 & -9 & 3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -9 & 10 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 10 & -19 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -9, 3]])\nb = np.array([\n [-9, 10, 5]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 0 & 10 & 3 \\\\\n 5 & 2 & -6 \\\\\n -7 & -6 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-3 x^2+75 x+622$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 10, 3],\n [5, 2, -6],\n [-7, -6, -5]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{4}{5} & \\frac{46}{5} \\\\\n -\\frac{11}{5} & -\\frac{37}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(-41-i \\sqrt{935}\\right),\\frac{1}{10} \\left(-41+i \\sqrt{935}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/5), (46/5)],\n [-(11/5), -(37/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & -2 \\\\\n -6 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-14 x+33$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -2],\n [-6, 5]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -7 & -4 & 0 \\\\\n -8 & -6 & -1 \\\\\n -3 & 2 & 10 \\\\\n 10 & -3 & -7 \\\\\n -8 & -2 & 3 \\\\\n -9 & 4 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, -4, 0],\n [-8, -6, -1],\n [-3, 2, 10],\n [10, -3, -7],\n [-8, -2, 3],\n [-9, 4, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{11}{3}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{11}{3} & -\\frac{11}{3} & \\frac{11}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, -1]])\nprint(a * -(11/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n \\frac{1}{\\sqrt{3}} \\\\\n -3 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{10}{\\sqrt{3}} \\\\\n \\frac{16}{\\sqrt{3}} \\\\\n 4 \\sqrt{3} \\\\\n -\\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-69$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [5*math.sqrt(3)],\n [-2*math.sqrt(3)],\n [(1/(math.sqrt(3)))],\n [-3*math.sqrt(3)]])\nb = np.array([\n [-(10/(math.sqrt(3)))],\n [(16/(math.sqrt(3)))],\n [4*math.sqrt(3)],\n [-math.sqrt(3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -1 & -8 & -9 & -10 \\\\\n 0 & -6 & -4 & -1 \\\\\n 2 & 0 & 10 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-315.,-46.,67.,8.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, -8, -9, -10],\n [0, -6, -4, -1],\n [2, 0, 10, -5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & 4 & 0 \\\\\n -1 & -5 & -3 \\\\\n -1 & -3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 4, 0],\n [-1, -5, -3],\n [-1, -3, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -1 & 1 & -2 & -1 & -1 \\\\\n -1 & -2 & -3 & 2 & -1 \\\\\n 2 & -2 & -2 & 0 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 3 & 1 & 2 & 0 \\\\\n -2 & 1 & 2 & 1 \\\\\n -1 & -1 & -1 & -1 \\\\\n 1 & 0 & 0 & -3 \\\\\n 1 & 2 & 2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -5 & 0 & 0 & 8 \\\\\n 5 & -2 & -5 & -3 \\\\\n 13 & 4 & 4 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, -2, -1, -1],\n [-1, -2, -3, 2, -1],\n [2, -2, -2, 0, 1]])\nb = np.array([\n [3, 1, 2, 0],\n [-2, 1, 2, 1],\n [-1, -1, -1, -1],\n [1, 0, 0, -3],\n [1, 2, 2, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $3$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 10 & 6 & 10 \\\\\n 7 & 0 & 2 \\\\\n 5 & 0 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 30 & 18 & 30 \\\\\n 21 & 0 & 6 \\\\\n 15 & 0 & -27 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 6, 10],\n [7, 0, 2],\n [5, 0, -9]])\nprint(a * 3)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -6 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 0 \\\\\n 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -42 \\\\\n -39 \\\\\n 36 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-6],\n [4]])\nb = np.array([\n [6],\n [0],\n [7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n 7 & 6 & 3 & -4 \\\\\n 5 & -3 & -9 & 8 \\\\\n -5 & -6 & 5 & -5 \\\\\n -9 & 8 & -6 & 5 \\\\\n -7 & 4 & 7 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 6, 3, -4],\n [5, -3, -9, 8],\n [-5, -6, 5, -5],\n [-9, 8, -6, 5],\n [-7, 4, 7, 10]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & 8 & 7 \\\\\n 5 & 9 & -9 \\\\\n 9 & -8 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-16.163,6.958,13.204\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 8, 7],\n [5, 9, -9],\n [9, -8, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 8 & 7 \\\\\n -6 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 3 & -1 \\\\\n 8 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 11 & 6 \\\\\n 2 & 14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 7],\n [-6, 8]])\nb = np.array([\n [3, -1],\n [8, 6]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 8 & -6 & -9 \\\\\n 4 & 8 & 1 \\\\\n -6 & -1 & 8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 3 & -9 & 0 \\\\\n -8 & -7 & 5 \\\\\n 9 & -5 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 5 & 3 & -9 \\\\\n 12 & 15 & -4 \\\\\n -15 & 4 & 14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -6, -9],\n [4, 8, 1],\n [-6, -1, 8]])\nb = np.array([\n [3, -9, 0],\n [-8, -7, 5],\n [9, -5, -6]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n \\frac{15}{8} & -\\frac{11}{8} & \\frac{1}{8} \\\\\n \\frac{7}{4} & \\frac{5}{4} & \\frac{11}{16} \\\\\n -\\frac{45}{16} & \\frac{7}{16} & \\frac{23}{16} \\\\\n -\\frac{3}{8} & -\\frac{3}{4} & -2 \\\\\n \\frac{17}{16} & \\frac{7}{4} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n \\frac{41}{16} & -\\frac{23}{16} & \\frac{41}{16} & -\\frac{47}{16} & \\frac{45}{16} \\\\\n -\\frac{45}{16} & -\\frac{21}{8} & 0 & \\frac{17}{16} & \\frac{23}{16} \\\\\n -\\frac{31}{16} & \\frac{17}{16} & \\frac{1}{8} & -\\frac{19}{8} & -\\frac{33}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n \\frac{1079}{128} & \\frac{67}{64} & \\frac{617}{128} & -\\frac{465}{64} & \\frac{389}{128} \\\\\n -\\frac{93}{256} & -\\frac{1297}{256} & \\frac{585}{128} & -\\frac{697}{128} & \\frac{1357}{256} \\\\\n -\\frac{2873}{256} & \\frac{283}{64} & -\\frac{1799}{256} & \\frac{85}{16} & -\\frac{2623}{256} \\\\\n \\frac{643}{128} & \\frac{49}{128} & -\\frac{155}{128} & \\frac{647}{128} & \\frac{255}{128} \\\\\n -\\frac{811}{256} & -\\frac{1431}{256} & \\frac{713}{256} & -\\frac{627}{256} & \\frac{1145}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/8), -(11/8), (1/8)],\n [(7/4), (5/4), (11/16)],\n [-(45/16), (7/16), (23/16)],\n [-(3/8), -(3/4), -2],\n [(17/16), (7/4), (1/2)]])\nb = np.array([\n [(41/16), -(23/16), (41/16), -(47/16), (45/16)],\n [-(45/16), -(21/8), 0, (17/16), (23/16)],\n [-(31/16), (17/16), (1/8), -(19/8), -(33/16)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n \\frac{65}{8} & -\\frac{27}{8} & \\frac{51}{8} & \\frac{27}{4} \\\\\n -\\frac{31}{4} & -\\frac{25}{4} & \\frac{29}{16} & \\frac{33}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(65/8), -(27/8), (51/8), (27/4)],\n [-(31/4), -(25/4), (29/16), (33/8)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{3} \\\\\n -2 \\\\\n -\\frac{5}{3} \\\\\n -3 \\\\\n \\frac{7}{3} \\\\\n \\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{193}} \\\\\n -\\frac{6}{\\sqrt{193}} \\\\\n -\\frac{5}{\\sqrt{193}} \\\\\n -\\frac{9}{\\sqrt{193}} \\\\\n \\frac{7}{\\sqrt{193}} \\\\\n \\frac{1}{\\sqrt{193}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/3)],\n [-2],\n [-(5/3)],\n [-3],\n [(7/3)],\n [(1/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{2}{3},-\\frac{2}{3},\\frac{1}{3}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-3],\n [1]]).squeeze()\nb = np.array([\n [2],\n [-2],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & -1 \\\\\n 0 & -3 \\\\\n -1 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.55 \\\\\n -2.45 \\\\\n -0.48 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.462 \\\\\n 0.852 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1],\n [0, -3],\n [-1, 0]])\nb = np.array([\n [-2.55],\n [-2.45],\n [-0.48]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n -2 \\\\\n -\\frac{5}{2} \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{2} \\\\\n \\frac{3}{2} \\\\\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{145}{132},-\\frac{29}{44},-\\frac{29}{33},-\\frac{29}{33}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2)],\n [-2],\n [-(5/2)],\n [1]]).squeeze()\nb = np.array([\n [-(5/2)],\n [(3/2)],\n [2],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -7 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 10 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -25 \\\\\n 4 \\\\\n -53 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-7],\n [-1]])\nb = np.array([\n [-9],\n [10],\n [5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{1}{2} & -\\frac{11}{2} & -\\frac{11}{2} & -5 & \\frac{9}{2} \\\\\n 6 & -6 & -\\frac{11}{2} & -\\frac{19}{2} & -\\frac{7}{2} \\\\\n \\frac{17}{2} & -1 & -8 & 9 & \\frac{7}{2} \\\\\n -5 & -\\frac{19}{2} & \\frac{3}{2} & -\\frac{3}{2} & \\frac{17}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), -(11/2), -(11/2), -5, (9/2)],\n [6, -6, -(11/2), -(19/2), -(7/2)],\n [(17/2), -1, -8, 9, (7/2)],\n [-5, -(19/2), (3/2), -(3/2), (17/2)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 0 & 2 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 0 & -1 & -2 & -2 & -3 \\\\\n 1 & -1 & 0 & -2 & -1 \\\\\n 0 & 2 & 1 & 2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 2 & -2 & 0 & -4 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, 0]])\nb = np.array([\n [0, -1, -2, -2, -3],\n [1, -1, 0, -2, -1],\n [0, 2, 1, 2, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{9}{16}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{27}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6]])\nprint(a * (9/16))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -10 & -8 & 7 & 2 & -2 & 0 & -5 \\\\\n -2 & 4 & 2 & 1 & 5 & -7 & 5 \\\\\n 6 & -8 & 10 & 5 & -3 & 0 & 7 \\\\\n 7 & 5 & 6 & 0 & 1 & 6 & -6 \\\\\n -4 & 4 & 4 & 5 & -9 & -1 & 0 \\\\\n 5 & -2 & -2 & 1 & -2 & -5 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & \\frac{54773}{280792} \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & -\\frac{25109}{70198} \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & -\\frac{261569}{140396} \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & \\frac{1530713}{280792} \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & \\frac{529589}{280792} \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & \\frac{43469}{70198} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, -8, 7, 2, -2, 0, -5],\n [-2, 4, 2, 1, 5, -7, 5],\n [6, -8, 10, 5, -3, 0, 7],\n [7, 5, 6, 0, 1, 6, -6],\n [-4, 4, 4, 5, -9, -1, 0],\n [5, -2, -2, 1, -2, -5, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{5,2,-1\\}, \\{2,-5,5\\}, \\{0,-5,-1\\}}$.", - "Output Answer": [ - "$21 x-15 y-7 z-82=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [5, 2, -1],\n [2, -5, 5],\n [0, -5, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -5 \\\\\n 5 \\\\\n 9 \\\\\n 6 \\\\\n 4 \\\\\n 1 \\\\\n 6 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 5 \\\\\n 6 \\\\\n -4 \\\\\n -7 \\\\\n 8 \\\\\n -4 \\\\\n 7 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{494}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-5],\n [5],\n [9],\n [6],\n [4],\n [1],\n [6],\n [4]])\nb = np.array([\n [-3],\n [5],\n [6],\n [-4],\n [-7],\n [8],\n [-4],\n [7],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & 3 & 0 & 3 & 1 \\\\\n -3 & -3 & -1 & 3 & 1 \\\\\n -3 & -2 & 0 & 0 & 2 \\\\\n -1 & 1 & 1 & -1 & -3 \\\\\n 0 & -1 & -1 & 3 & -3 \\\\\n 3 & -2 & -2 & 1 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.93 \\\\\n 0.36 \\\\\n 0.27 \\\\\n 2.58 \\\\\n -0.18 \\\\\n 0.12 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.807 \\\\\n 0.309 \\\\\n -1.079 \\\\\n -0.712 \\\\\n -0.541 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, 0, 3, 1],\n [-3, -3, -1, 3, 1],\n [-3, -2, 0, 0, 2],\n [-1, 1, 1, -1, -3],\n [0, -1, -1, 3, -3],\n [3, -2, -2, 1, -3]])\nb = np.array([\n [-0.93],\n [0.36],\n [0.27],\n [2.58],\n [-0.18],\n [0.12]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 5 & 7 \\\\\n 9 & 4 \\\\\n 3 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, 7],\n [9, 4],\n [3, -10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -3 & 0 \\\\\n 0 & 2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -27 & 0 \\\\\n 0 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0],\n [0, 2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{43}{5} & -\\frac{7}{5} & \\frac{38}{5} \\\\\n \\frac{19}{5} & \\frac{2}{5} & \\frac{12}{5} \\\\\n \\frac{4}{5} & -6 & -\\frac{49}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-6.651,-3.636,1.\\}, \\{-1.665,-2.217,1.\\}, \\{-0.422,-0.079,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(43/5), -(7/5), (38/5)],\n [(19/5), (2/5), (12/5)],\n [(4/5), -6, -(49/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{ccc}\n -3 & 7 & 6 \\\\\n -1 & 3 & 2 \\\\\n 0 & -1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & 4 & 4 \\\\\n -1 & 4 & 2 \\\\\n \\frac{1}{2} & -\\frac{5}{2} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [-3, 7, 6],\n [-1, 3, 2],\n [0, -1, 0]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{3} \\\\\n \\frac{64}{9} \\\\\n -\\frac{11}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{5}{3} \\\\\n \\frac{55}{9} \\\\\n -\\frac{13}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{227}{81} \\\\\n \\frac{38}{9} \\\\\n \\frac{395}{27} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/3)],\n [(64/9)],\n [-(11/9)]])\nb = np.array([\n [(5/3)],\n [(55/9)],\n [-(13/9)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 1 & 4 & -1 & -8 \\\\\n -6 & -1 & 3 & -7 \\\\\n 0 & 0 & -2 & -9 \\\\\n 6 & -4 & -2 & 9 \\\\\n -1 & 8 & 8 & 9 \\\\\n 4 & 6 & 7 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, 4, -1, -8],\n [-6, -1, 3, -7],\n [0, 0, -2, -9],\n [6, -4, -2, 9],\n [-1, 8, 8, 9],\n [4, 6, 7, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -6 \\\\\n 0 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{61}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-6],\n [0],\n [-5]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\log (2) \\\\\n -7 \\log (2) \\\\\n 12 \\log (2) \\\\\n 14 \\log (2) \\\\\n 5 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\log (2) \\\\\n -13 \\log (2) \\\\\n 2 \\log (2) \\\\\n -5 \\log (2) \\\\\n -4 \\log (2) \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{699} \\log (2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-8*math.log(2)],\n [-7*math.log(2)],\n [12*math.log(2)],\n [14*math.log(2)],\n [5*math.log(2)]])\nb = np.array([\n [3*math.log(2)],\n [-13*math.log(2)],\n [2*math.log(2)],\n [-5*math.log(2)],\n [-4*math.log(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n -2 \\\\\n 2 \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{42}} \\\\\n -2 \\sqrt{\\frac{2}{21}} \\\\\n 2 \\sqrt{\\frac{2}{21}} \\\\\n -\\sqrt{\\frac{3}{14}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2)],\n [-2],\n [2],\n [-(3/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{21}{5} & -\\frac{31}{10} & -3 \\\\\n -\\frac{17}{10} & \\frac{41}{10} & \\frac{3}{5} \\\\\n -\\frac{16}{5} & -\\frac{7}{10} & \\frac{12}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{3267}{500}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(21/5), -(31/10), -3],\n [-(17/10), (41/10), (3/5)],\n [-(16/5), -(7/10), (12/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 3 & 2 & 0 & -2 \\\\\n 1 & 0 & -3 & -1 \\\\\n 0 & 2 & 2 & 0 \\\\\n 3 & -2 & -3 & -1 \\\\\n -2 & -2 & -1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.15 \\\\\n -2.07 \\\\\n 1.08 \\\\\n -2. \\\\\n -2.09 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.16 \\\\\n 0.97 \\\\\n 0.033 \\\\\n 3.131 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2, 0, -2],\n [1, 0, -3, -1],\n [0, 2, 2, 0],\n [3, -2, -3, -1],\n [-2, -2, -1, 1]])\nb = np.array([\n [-1.15],\n [-2.07],\n [1.08],\n [-2.],\n [-2.09]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n 2 & 6 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 6, 9]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{4}{5} & -\\frac{33}{10} & \\frac{7}{5} \\\\\n \\frac{7}{10} & \\frac{18}{5} & \\frac{93}{10} \\\\\n \\frac{31}{5} & \\frac{29}{5} & \\frac{59}{10} \\\\\n -\\frac{12}{5} & -\\frac{44}{5} & \\frac{53}{10} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{19}{2} & -\\frac{29}{5} & \\frac{11}{5} \\\\\n \\frac{33}{5} & -\\frac{18}{5} & \\frac{28}{5} \\\\\n -\\frac{91}{10} & -\\frac{26}{5} & -\\frac{13}{2} \\\\\n -\\frac{3}{10} & -\\frac{61}{10} & -\\frac{38}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{87}{10} & \\frac{5}{2} & -\\frac{4}{5} \\\\\n -\\frac{59}{10} & \\frac{36}{5} & \\frac{37}{10} \\\\\n \\frac{153}{10} & 11 & \\frac{62}{5} \\\\\n -\\frac{21}{10} & -\\frac{27}{10} & \\frac{129}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/5), -(33/10), (7/5)],\n [(7/10), (18/5), (93/10)],\n [(31/5), (29/5), (59/10)],\n [-(12/5), -(44/5), (53/10)]])\nb = np.array([\n [(19/2), -(29/5), (11/5)],\n [(33/5), -(18/5), (28/5)],\n [-(91/10), -(26/5), -(13/2)],\n [-(3/10), -(61/10), -(38/5)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{16} \\\\\n \\frac{1}{2} \\\\\n \\frac{7}{16} \\\\\n \\frac{13}{8} \\\\\n \\frac{31}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{19}{\\sqrt{2111}} \\\\\n \\frac{8}{\\sqrt{2111}} \\\\\n \\frac{7}{\\sqrt{2111}} \\\\\n \\frac{26}{\\sqrt{2111}} \\\\\n \\frac{31}{\\sqrt{2111}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/16)],\n [(1/2)],\n [(7/16)],\n [(13/8)],\n [(31/16)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{2} \\\\\n -\\frac{5}{2} \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -3 \\\\\n \\frac{9}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{9}{4} \\\\\n -\\frac{237}{4} \\\\\n -43 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/2)],\n [-(5/2)],\n [3]])\nb = np.array([\n [-7],\n [-3],\n [(9/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{16}{5}, \\frac{1}{2}}$ to the line $-\\frac{5 x}{2}-\\frac{13 y}{5}+\\frac{2}{5}=0$.", - "Output Answer": [ - "$\\frac{89}{\\sqrt{1301}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (16/5), (1/2)\nline = Poly(-((5*x)/2)-((13*y)/5)+(2/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{5}{6},-\\frac{5}{3},-\\frac{5}{6}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-2],\n [1]]).squeeze()\nb = np.array([\n [1],\n [2],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & 2 & 2 & -3 & 1 \\\\\n 3 & -3 & -2 & -1 & -3 \\\\\n -3 & 1 & -1 & 2 & 0 \\\\\n 2 & -1 & -3 & -1 & 3 \\\\\n 0 & 1 & -2 & -1 & 2 \\\\\n 3 & 1 & 0 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.35 \\\\\n -1.12 \\\\\n 1.35 \\\\\n -2.82 \\\\\n 1.03 \\\\\n -0.33 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.259 \\\\\n 1.359 \\\\\n -0.42 \\\\\n 0.587 \\\\\n -0.735 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2, 2, -3, 1],\n [3, -3, -2, -1, -3],\n [-3, 1, -1, 2, 0],\n [2, -1, -3, -1, 3],\n [0, 1, -2, -1, 2],\n [3, 1, 0, -1, 2]])\nb = np.array([\n [-1.35],\n [-1.12],\n [1.35],\n [-2.82],\n [1.03],\n [-0.33]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{26}{3} & \\frac{1}{2} \\\\\n -\\frac{5}{2} & -\\frac{4}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{23}{6} & \\frac{16}{3} \\\\\n \\frac{5}{6} & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{25}{2} & \\frac{35}{6} \\\\\n -\\frac{5}{3} & -\\frac{10}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/3), (1/2)],\n [-(5/2), -(4/3)]])\nb = np.array([\n [(23/6), (16/3)],\n [(5/6), -2]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-1,3,0\\}, \\{-2,3,2\\}, \\{3,2,1\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{10}},\\frac{3}{\\sqrt{10}},0\\right\\}, \\left\\{-\\frac{9}{7 \\sqrt{10}},-\\frac{3}{7 \\sqrt{10}},\\frac{2 \\sqrt{10}}{7}\\right\\}, \\left\\{\\frac{6}{7},\\frac{2}{7},\\frac{3}{7}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, 3, 0), (-2, 3, 2), (3, 2, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -1 & -1 & -2 \\\\\n 2 & -3 & 0 \\\\\n 0 & -2 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -4 \\\\\n 5 \\\\\n 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, -2],\n [2, -3, 0],\n [0, -2, 0]])\nb = np.array([\n [1],\n [-1],\n [2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{3} \\\\\n -\\frac{7}{3} \\\\\n -\\frac{2}{3} \\\\\n \\frac{1}{3} \\\\\n -\\frac{1}{3} \\\\\n \\frac{8}{3} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -\\frac{2}{3} \\\\\n \\frac{7}{3} \\\\\n -3 \\\\\n -\\frac{5}{3} \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{65}{249},-\\frac{130}{747},\\frac{455}{747},-\\frac{65}{83},-\\frac{325}{747},\\frac{65}{83}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/3)],\n [-(7/3)],\n [-(2/3)],\n [(1/3)],\n [-(1/3)],\n [(8/3)]]).squeeze()\nb = np.array([\n [-1],\n [-(2/3)],\n [(7/3)],\n [-3],\n [-(5/3)],\n [3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 9 & 0 \\\\\n 1 & 7 \\\\\n -2 & 10 \\\\\n -7 & -9 \\\\\n 4 & 1 \\\\\n -4 & -3 \\\\\n 7 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, 0],\n [1, 7],\n [-2, 10],\n [-7, -9],\n [4, 1],\n [-4, -3],\n [7, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8.533 \\\\\n -4.194 \\\\\n -9.538 \\\\\n 7.708 \\\\\n -5.065 \\\\\n -4.149 \\\\\n 4.624 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2.096 \\\\\n -3.166 \\\\\n 2.703 \\\\\n -3.065 \\\\\n 5.65 \\\\\n -6.374 \\\\\n -8. \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$25.6721$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8.533],\n [-4.194],\n [-9.538],\n [7.708],\n [-5.065],\n [-4.149],\n [4.624]])\nb = np.array([\n [-2.096],\n [-3.166],\n [2.703],\n [-3.065],\n [5.65],\n [-6.374],\n [-8.]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{5} \\\\\n -\\frac{7}{5} \\\\\n -\\frac{11}{5} \\\\\n 1 \\\\\n \\frac{13}{5} \\\\\n \\frac{7}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{5} \\\\\n -1 \\\\\n \\frac{9}{5} \\\\\n 2 \\\\\n \\frac{8}{5} \\\\\n \\frac{3}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{508}{1475},-\\frac{127}{295},\\frac{1143}{1475},\\frac{254}{295},\\frac{1016}{1475},\\frac{381}{1475}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/5)],\n [-(7/5)],\n [-(11/5)],\n [1],\n [(13/5)],\n [(7/5)]]).squeeze()\nb = np.array([\n [-(4/5)],\n [-1],\n [(9/5)],\n [2],\n [(8/5)],\n [(3/5)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n \\frac{14}{3} \\\\\n -\\frac{25}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{1}{3} \\\\\n \\frac{23}{3} \\\\\n \\frac{22}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{883}{9} \\\\\n -\\frac{553}{9} \\\\\n \\frac{538}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [(14/3)],\n [-(25/3)]])\nb = np.array([\n [(1/3)],\n [(23/3)],\n [(22/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{6} & -\\frac{4}{3} & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{5}{3} & \\frac{2}{3} & -\\frac{4}{3} & -\\frac{5}{6} \\\\\n -\\frac{11}{6} & -\\frac{1}{3} & -\\frac{17}{6} & -\\frac{1}{6} \\\\\n -\\frac{1}{3} & \\frac{1}{3} & -\\frac{4}{3} & -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{1}{6} & \\frac{1}{3} & \\frac{8}{3} & -\\frac{149}{36} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/6), -(4/3), 2]])\nb = np.array([\n [(5/3), (2/3), -(4/3), -(5/6)],\n [-(11/6), -(1/3), -(17/6), -(1/6)],\n [-(1/3), (1/3), -(4/3), -(8/3)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-1]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 3 & 2 & -3 & 1 \\\\\n 3 & -2 & -3 & -1 \\\\\n 0 & 2 & 3 & 1 \\\\\n 1 & 3 & -3 & -3 \\\\\n -3 & 0 & -2 & 1 \\\\\n 1 & 0 & -3 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.27 \\\\\n -2.72 \\\\\n -1.47 \\\\\n -0.37 \\\\\n 0.09 \\\\\n 2.89 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.27 \\\\\n 0.161 \\\\\n -0.254 \\\\\n 0.466 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2, -3, 1],\n [3, -2, -3, -1],\n [0, 2, 3, 1],\n [1, 3, -3, -3],\n [-3, 0, -2, 1],\n [1, 0, -3, 1]])\nb = np.array([\n [0.27],\n [-2.72],\n [-1.47],\n [-0.37],\n [0.09],\n [2.89]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{3} \\\\\n \\frac{14}{9} \\\\\n \\frac{11}{9} \\\\\n -\\frac{10}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2 \\sqrt{\\frac{3}{151}} \\\\\n \\frac{14}{\\sqrt{453}} \\\\\n \\frac{11}{\\sqrt{453}} \\\\\n -\\frac{10}{\\sqrt{453}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3)],\n [(14/9)],\n [(11/9)],\n [-(10/9)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{27}{4} & \\frac{31}{4} & -\\frac{17}{2} \\\\\n 5 & -\\frac{19}{2} & \\frac{3}{4} \\\\\n -\\frac{17}{2} & -\\frac{19}{2} & -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.858,-0.381,1.\\}, \\{0.311\\, -0.377 i,0.204\\, +0.721 i,1.\\}, \\{0.311\\, +0.377 i,0.204\\, -0.721 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(27/4), (31/4), -(17/2)],\n [5, -(19/2), (3/4)],\n [-(17/2), -(19/2), -(13/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & -3 & 2 & -2 \\\\\n 1 & 1 & 0 & 0 \\\\\n 0 & -2 & -3 & -2 \\\\\n 2 & -2 & 1 & -2 \\\\\n -2 & 0 & 1 & 0 \\\\\n 2 & -2 & 3 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.38 \\\\\n -1.58 \\\\\n 0.78 \\\\\n -0.81 \\\\\n -0.86 \\\\\n -2.02 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.352 \\\\\n -0.341 \\\\\n -0.443 \\\\\n 0.281 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -3, 2, -2],\n [1, 1, 0, 0],\n [0, -2, -3, -2],\n [2, -2, 1, -2],\n [-2, 0, 1, 0],\n [2, -2, 3, 0]])\nb = np.array([\n [0.38],\n [-1.58],\n [0.78],\n [-0.81],\n [-0.86],\n [-2.02]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 2 & -7 & 6 & 10 & -3 \\\\\n -8 & -5 & -6 & -5 & -4 \\\\\n 1 & 0 & -9 & 6 & 7 \\\\\n 2 & 4 & 10 & 0 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & -\\frac{4933}{4220} \\\\\n 0 & 1 & 0 & 0 & \\frac{1746}{1055} \\\\\n 0 & 0 & 1 & 0 & -\\frac{541}{4220} \\\\\n 0 & 0 & 0 & 1 & \\frac{2467}{2110} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, -7, 6, 10, -3],\n [-8, -5, -6, -5, -4],\n [1, 0, -9, 6, 7],\n [2, 4, 10, 0, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n 6 & 10 & 0 \\\\\n 9 & -7 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 10, 0],\n [9, -7, 3]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 2 & -\\frac{1}{4} & \\frac{9}{4} & -\\frac{5}{2} \\\\\n -\\frac{9}{4} & -\\frac{3}{4} & -\\frac{1}{2} & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n -\\frac{5}{4} \\\\\n \\frac{1}{4} \\\\\n -\\frac{9}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{7}{2} \\\\\n \\frac{103}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(1/4), (9/4), -(5/2)],\n [-(9/4), -(3/4), -(1/2), -1]])\nb = np.array([\n [-(3/2)],\n [-(5/4)],\n [(1/4)],\n [-(9/4)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & 2 \\\\\n -2 & 0 & 2 \\\\\n -3 & 0 & 1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -3 & -1 & 2 \\\\\n -8 & 2 & -2 \\\\\n -6 & 3 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, 2],\n [-2, 0, 2],\n [-3, 0, 1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -1 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-1],\n [6]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8.1 \\\\\n 8.8 \\\\\n -9.3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4.3 \\\\\n -7.4 \\\\\n -8.8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$16.6472$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8.1],\n [8.8],\n [-9.3]])\nb = np.array([\n [4.3],\n [-7.4],\n [-8.8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & -7 & -5 \\\\\n -1 & 2 & -6 \\\\\n 4 & -8 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, -7, -5],\n [-1, 2, -6],\n [4, -8, -7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{2}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -10 & 10 & -4 \\\\\n -2 & -9 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 25 & -25 & 10 \\\\\n 5 & \\frac{45}{2} & -15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 10, -4],\n [-2, -9, 6]])\nprint(a * -(5/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{4}{3}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -7 & 7 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{28}{3} & \\frac{28}{3} & \\frac{32}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 7, 8]])\nprint(a * (4/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n -10 & -2 & -6 \\\\\n -4 & 5 & -2 \\\\\n -5 & -6 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -2, -6],\n [-4, 5, -2],\n [-5, -6, 7]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 10 \\\\\n -6 \\\\\n 7 \\\\\n -1 \\\\\n 4 \\\\\n 10 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -2 \\\\\n -4 \\\\\n 6 \\\\\n -9 \\\\\n -5 \\\\\n 9 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$177$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [10],\n [-6],\n [7],\n [-1],\n [4],\n [10],\n [7]])\nb = np.array([\n [-4],\n [-2],\n [-4],\n [6],\n [-9],\n [-5],\n [9],\n [4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{49}{10} & -\\frac{4}{5} & -5 \\\\\n -\\frac{12}{5} & -\\frac{3}{2} & -\\frac{11}{10} \\\\\n -5 & -\\frac{1}{2} & \\frac{14}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{4750}{44999} & \\frac{4740}{44999} & -\\frac{6620}{44999} \\\\\n \\frac{12220}{44999} & -\\frac{38720}{44999} & \\frac{6610}{44999} \\\\\n -\\frac{6300}{44999} & \\frac{1550}{44999} & \\frac{5430}{44999} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(49/10), -(4/5), -5],\n [-(12/5), -(3/2), -(11/10)],\n [-5, -(1/2), (14/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{29}{7} \\\\\n -\\frac{66}{7} \\\\\n -\\frac{41}{7} \\\\\n -\\frac{47}{7} \\\\\n -\\frac{23}{7} \\\\\n \\frac{5}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{69}{7} \\\\\n -4 \\\\\n \\frac{38}{7} \\\\\n -8 \\\\\n -6 \\\\\n -\\frac{43}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{20035}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/7)],\n [-(66/7)],\n [-(41/7)],\n [-(47/7)],\n [-(23/7)],\n [(5/7)]])\nb = np.array([\n [-(69/7)],\n [-4],\n [(38/7)],\n [-8],\n [-6],\n [-(43/7)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{26}{3} \\\\\n -2 \\\\\n -\\frac{16}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{8}{3} \\\\\n -\\frac{13}{3} \\\\\n \\frac{19}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{322}{9} \\\\\n -\\frac{622}{9} \\\\\n -\\frac{290}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/3)],\n [-2],\n [-(16/3)]])\nb = np.array([\n [(8/3)],\n [-(13/3)],\n [(19/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & -2 \\\\\n 3 & 0 \\\\\n -1 & -1 \\\\\n -1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.14 \\\\\n -2.36 \\\\\n -1.97 \\\\\n -2.43 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.351 \\\\\n -0.593 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2],\n [3, 0],\n [-1, -1],\n [-1, 3]])\nb = np.array([\n [1.14],\n [-2.36],\n [-1.97],\n [-2.43]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2 & 2 & -3 \\\\\n -2 & 0 & -1 \\\\\n -1 & -1 & 2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 3 & -1 & -2 \\\\\n 5 & -3 & 4 \\\\\n 2 & -4 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2, -3],\n [-2, 0, -1],\n [-1, -1, 2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & -1 \\\\\n -9 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+4 x-30$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1],\n [-9, -7]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-1, 5}$ to the line $3 y-2 x=0$.", - "Output Answer": [ - "$\\frac{17}{\\sqrt{13}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -1, 5\nline = Poly(3*y-2*x, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 3 & -10 & 0 & -5 \\\\\n 9 & 8 & 10 & 1 \\\\\n 8 & -9 & -8 & -7 \\\\\n 8 & -9 & -10 & -8 \\\\\n 0 & -2 & 1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, -10, 0, -5],\n [9, 8, 10, 1],\n [8, -9, -8, -7],\n [8, -9, -10, -8],\n [0, -2, 1, -3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -3 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 15 \\\\\n 0 \\\\\n -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [5]])\nb = np.array([\n [1],\n [-3],\n [5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{3} & -2 & 7 \\\\\n 1 & -1 & -5 \\\\\n \\frac{25}{3} & -6 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6.792,-0.622,12.08\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3), -2, 7],\n [1, -1, -5],\n [(25/3), -6, 4]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -\\frac{29}{16} & \\frac{13}{2} & \\frac{157}{16} & \\frac{43}{8} \\\\\n \\frac{29}{8} & -\\frac{3}{4} & -\\frac{7}{4} & \\frac{43}{16} \\\\\n -\\frac{37}{16} & \\frac{97}{16} & -\\frac{133}{16} & -\\frac{11}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/16), (13/2), (157/16), (43/8)],\n [(29/8), -(3/4), -(7/4), (43/16)],\n [-(37/16), (97/16), -(133/16), -(11/16)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 10 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -9 \\\\\n 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -72 \\\\\n 40 \\\\\n -31 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [10],\n [-8]])\nb = np.array([\n [-5],\n [-9],\n [0]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -7 & -8 & 4 & 1 & -4 \\\\\n 4 & -8 & -9 & 4 & 3 \\\\\n 3 & -2 & -1 & -4 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -8, 4, 1, -4],\n [4, -8, -9, 4, 3],\n [3, -2, -1, -4, 6]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,-4,-2\\}, \\{-3,-3,-3\\}, \\{0,-4,-2\\}}$.", - "Output Answer": [ - "$y+z+6=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, -4, -2],\n [-3, -3, -3],\n [0, -4, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -4 & 2 & -2 \\\\\n 3 & 0 & 1 \\\\\n -2 & 4 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{2}{9} & \\frac{5}{9} & -\\frac{1}{9} \\\\\n \\frac{5}{18} & \\frac{4}{9} & \\frac{1}{9} \\\\\n -\\frac{2}{3} & -\\frac{2}{3} & \\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 2, -2],\n [3, 0, 1],\n [-2, 4, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 4 \\sqrt{3} \\\\\n 5 \\sqrt{3} \\\\\n -3 \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-51$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [4*math.sqrt(3)],\n [5*math.sqrt(3)],\n [-3*math.sqrt(3)],\n [math.sqrt(3)]])\nb = np.array([\n [2*math.sqrt(3)],\n [4*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [math.sqrt(3)],\n [-5*math.sqrt(3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & 10 & 0 \\\\\n -5 & -8 & 7 \\\\\n 6 & 2 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-5.362-7.097 i,-5.362+7.097 i,6.724\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 10, 0],\n [-5, -8, 7],\n [6, 2, 3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{17}{5}, \\frac{18}{5}, \\frac{1}{5}}$ to the plane $-\\frac{22 x}{5}-\\frac{7 y}{5}+\\frac{9 z}{5}-\\frac{18}{5}=0$.", - "Output Answer": [ - "$\\frac{581}{5 \\sqrt{614}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (17/5), (18/5), (1/5)\nplane = Poly(-((22*x)/5)-((7*y)/5)+((9*z)/5)-(18/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 3 & 5 & 8 \\\\\n -3 & 3 & -6 \\\\\n -1 & -3 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+12 x^2-50 x+216$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 5, 8],\n [-3, 3, -6],\n [-1, -3, 6]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & 4 \\\\\n 4 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+3 x-34$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 4],\n [4, -6]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -5 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -9 \\\\\n -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 94 \\\\\n -14 \\\\\n -90 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-5],\n [6]])\nb = np.array([\n [-9],\n [-9],\n [-8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 3 \\\\\n -2 \\\\\n -3 \\\\\n 1 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{3} \\\\\n \\frac{1}{2} \\\\\n -\\frac{1}{3} \\\\\n -\\frac{1}{2} \\\\\n \\frac{1}{6} \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [3],\n [-2],\n [-3],\n [1],\n [3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -6 & -1 & 10 \\\\\n -7 & -3 & 6 \\\\\n -4 & 6 & 7 \\\\\n 0 & 7 & -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -4 & -3 & -7 \\\\\n 8 & 8 & -7 \\\\\n -5 & -8 & -7 \\\\\n 1 & -6 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -10 & -4 & 3 \\\\\n 1 & 5 & -1 \\\\\n -9 & -2 & 0 \\\\\n 1 & 1 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -1, 10],\n [-7, -3, 6],\n [-4, 6, 7],\n [0, 7, -8]])\nb = np.array([\n [-4, -3, -7],\n [8, 8, -7],\n [-5, -8, -7],\n [1, -6, 4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -2 & 1 \\\\\n 1 & 5 & 4 \\\\\n 0 & -1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-11$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2, 1],\n [1, 5, 4],\n [0, -1, -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{6} & \\frac{5}{2} & -\\frac{3}{2} \\\\\n -\\frac{19}{6} & -\\frac{1}{6} & -\\frac{7}{3} \\\\\n -\\frac{14}{3} & -\\frac{29}{6} & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{4015}{216}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/6), (5/2), -(3/2)],\n [-(19/6), -(1/6), -(7/3)],\n [-(14/3), -(29/6), 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -4 & 0 & 4 \\\\\n 5 & -4 & 5 \\\\\n 0 & 2 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$128$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 0, 4],\n [5, -4, 5],\n [0, 2, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -1 & -2 & -1 & -2 \\\\\n -1 & 0 & 1 & -1 \\\\\n -1 & -2 & -2 & 0 \\\\\n 2 & 3 & -2 & -2 \\\\\n 0 & 0 & -2 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 0 & 2 \\\\\n -1 & -1 \\\\\n 3 & 1 \\\\\n -2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 3 & -3 \\\\\n 5 & -2 \\\\\n -4 & -2 \\\\\n -5 & -3 \\\\\n -2 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, -1, -2],\n [-1, 0, 1, -1],\n [-1, -2, -2, 0],\n [2, 3, -2, -2],\n [0, 0, -2, -2]])\nb = np.array([\n [0, 2],\n [-1, -1],\n [3, 1],\n [-2, 1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -5 & -8 \\\\\n 0 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-25$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -8],\n [0, 5]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{10}{7} \\\\\n 2 \\\\\n 0 \\\\\n \\frac{4}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{5}{\\sqrt{78}} \\\\\n \\frac{7}{\\sqrt{78}} \\\\\n 0 \\\\\n \\sqrt{\\frac{2}{39}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(10/7)],\n [2],\n [0],\n [(4/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -0.7 \\\\\n 8.445 \\\\\n 0.282 \\\\\n 4.987 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2.31 \\\\\n 5.956 \\\\\n 1.655 \\\\\n 1.385 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$56.0551$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-0.7],\n [8.445],\n [0.282],\n [4.987]])\nb = np.array([\n [2.31],\n [5.956],\n [1.655],\n [1.385]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -4 & 1 & -8 & -1 \\\\\n -10 & -7 & -1 & -8 \\\\\n 7 & -5 & -10 & 2 \\\\\n -5 & 2 & -5 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-4, 1, -8, -1],\n [-10, -7, -1, -8],\n [7, -5, -10, 2],\n [-5, 2, -5, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{14}{5} & \\frac{11}{5} \\\\\n \\frac{27}{5} & \\frac{3}{10} \\\\\n \\frac{99}{10} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{12}{5} & \\frac{1}{2} \\\\\n \\frac{37}{5} & \\frac{11}{10} \\\\\n \\frac{6}{5} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{26}{5} & \\frac{17}{10} \\\\\n -2 & -\\frac{4}{5} \\\\\n \\frac{87}{10} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(14/5), (11/5)],\n [(27/5), (3/10)],\n [(99/10), -(1/2)]])\nb = np.array([\n [(12/5), (1/2)],\n [(37/5), (11/10)],\n [(6/5), -(1/2)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{8}{5} & -\\frac{12}{5} & \\frac{16}{5} \\\\\n \\frac{23}{5} & -\\frac{4}{5} & \\frac{23}{5} \\\\\n -\\frac{18}{5} & -\\frac{7}{5} & -\\frac{19}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1185}{2108} & \\frac{25}{31} & \\frac{265}{527} \\\\\n -\\frac{115}{2108} & -\\frac{10}{31} & -\\frac{230}{527} \\\\\n \\frac{1165}{2108} & -\\frac{20}{31} & -\\frac{305}{527} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(8/5), -(12/5), (16/5)],\n [(23/5), -(4/5), (23/5)],\n [-(18/5), -(7/5), -(19/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{26}{5} \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{16}{5} \\\\\n -\\frac{3}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2 \\\\\n \\frac{7}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(26/5)],\n [2]])\nb = np.array([\n [(16/5)],\n [-(3/5)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -8 \\\\\n 3 \\\\\n -6 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -8 \\\\\n -2 \\\\\n 10 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{570}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-8],\n [3],\n [-6],\n [9]])\nb = np.array([\n [7],\n [-8],\n [-2],\n [10],\n [-6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 0 \\\\\n 8 \\\\\n -6 \\\\\n 1 \\\\\n -1 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -8 \\\\\n 1 \\\\\n 7 \\\\\n -3 \\\\\n -5 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-25$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [0],\n [8],\n [-6],\n [1],\n [-1],\n [9]])\nb = np.array([\n [8],\n [-8],\n [1],\n [7],\n [-3],\n [-5],\n [7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{43}{7} \\\\\n -\\frac{17}{7} \\\\\n -4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{2}{7} \\\\\n -\\frac{48}{7} \\\\\n -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{41}{7} \\\\\n \\frac{31}{7} \\\\\n -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(43/7)],\n [-(17/7)],\n [-4]])\nb = np.array([\n [(2/7)],\n [-(48/7)],\n [-3]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & -6 \\\\\n -5 & -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+3 x-100$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -6],\n [-5, -10]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 1 & 9 & -7 \\\\\n 4 & 3 & -2 \\\\\n 10 & 6 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+8 x^2-65 x-258$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 9, -7],\n [4, 3, -2],\n [10, 6, 4]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -3 & -2 & 0 & 1 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -1 & -1 & -2 & 1 \\\\\n 3 & 2 & -3 & -1 \\\\\n 3 & 3 & 0 & 2 \\\\\n -2 & 2 & -1 & 1 \\\\\n 1 & -2 & -1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -5 & 1 & 11 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2, 0, 1, 0]])\nb = np.array([\n [-1, -1, -2, 1],\n [3, 2, -3, -1],\n [3, 3, 0, 2],\n [-2, 2, -1, 1],\n [1, -2, -1, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{2} \\\\\n \\frac{7}{2} \\\\\n -\\frac{3}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2)],\n [(7/2)],\n [-(3/5)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{4} \\\\\n \\frac{25}{4} \\\\\n 8 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{2} \\\\\n -\\frac{13}{4} \\\\\n -9 \\\\\n -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{47}{4} \\\\\n 3 \\\\\n -1 \\\\\n -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/4)],\n [(25/4)],\n [8],\n [0]])\nb = np.array([\n [-(15/2)],\n [-(13/4)],\n [-9],\n [-6]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{161}{20} & -\\frac{353}{50} & -\\frac{241}{25} \\\\\n \\frac{183}{20} & \\frac{13}{2} & \\frac{841}{100} \\\\\n \\frac{69}{20} & -\\frac{237}{25} & \\frac{38}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{121 x^2}{20}-\\frac{283697 x}{2500}+\\frac{29900917}{100000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(161/20), -(353/50), -(241/25)],\n [(183/20), (13/2), (841/100)],\n [(69/20), -(237/25), (38/5)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & 4 & -5 \\\\\n -3 & 4 & -1 \\\\\n 4 & 1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$61$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 4, -5],\n [-3, 4, -1],\n [4, 1, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -9 & -7 & 1 & 4 \\\\\n 1 & 8 & 8 & 2 \\\\\n -10 & 7 & 9 & 8 \\\\\n 7 & -9 & -3 & -8 \\\\\n -2 & -4 & -8 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, -7, 1, 4],\n [1, 8, 8, 2],\n [-10, 7, 9, 8],\n [7, -9, -3, -8],\n [-2, -4, -8, -7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [-1],\n [-1],\n [1],\n [-1],\n [1],\n [0]]).squeeze()\nb = np.array([\n [1],\n [0],\n [1],\n [-1],\n [1],\n [0],\n [0],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n \\frac{46}{5} & \\frac{24}{5} & \\frac{12}{5} & \\frac{36}{5} & -\\frac{22}{5} \\\\\n \\frac{46}{5} & \\frac{6}{5} & 5 & -7 & -\\frac{28}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(46/5), (24/5), (12/5), (36/5), -(22/5)],\n [(46/5), (6/5), 5, -7, -(28/5)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{79}{8} \\\\\n \\frac{7}{8} \\\\\n \\frac{1}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{1}{8} \\\\\n -\\frac{77}{8} \\\\\n \\frac{17}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{49}{8} \\\\\n -\\frac{671}{16} \\\\\n -\\frac{3045}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(79/8)],\n [(7/8)],\n [(1/4)]])\nb = np.array([\n [(1/8)],\n [-(77/8)],\n [(17/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{8}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & 7 & 4 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{3}{8} & -\\frac{7}{8} & -\\frac{1}{2} & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 7, 4, 8]])\nprint(a * -(1/8))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & -3 & 9 \\\\\n 2 & -4 & 7 \\\\\n -1 & 1 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-5.099-3.259 i,-5.099+3.259 i,-1.802\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3, 9],\n [2, -4, 7],\n [-1, 1, -5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${1, \\frac{5}{2}, -1}$ to the plane $-\\frac{3 x}{2}-2 y+z+\\frac{3}{2}=0$.", - "Output Answer": [ - "$\\frac{12}{\\sqrt{29}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 1, (5/2), -1\nplane = Poly(-((3*x)/2)-2*y+z+(3/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{3} & -\\frac{4}{3} & -\\frac{2}{3} \\\\\n 2 & \\frac{5}{3} & -\\frac{4}{3} \\\\\n -\\frac{7}{3} & \\frac{2}{3} & -\\frac{7}{3} \\\\\n \\frac{4}{3} & -\\frac{2}{3} & 1 \\\\\n \\frac{5}{3} & \\frac{1}{3} & -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{3} & -2 \\\\\n -\\frac{2}{3} & 2 \\\\\n 0 & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & -\\frac{34}{9} \\\\\n -\\frac{4}{9} & -\\frac{14}{9} \\\\\n -\\frac{11}{9} & \\frac{40}{9} \\\\\n \\frac{8}{9} & -\\frac{10}{3} \\\\\n \\frac{1}{3} & -\\frac{34}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/3), -(4/3), -(2/3)],\n [2, (5/3), -(4/3)],\n [-(7/3), (2/3), -(7/3)],\n [(4/3), -(2/3), 1],\n [(5/3), (1/3), -(5/3)]])\nb = np.array([\n [(1/3), -2],\n [-(2/3), 2],\n [0, (2/3)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{5}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -8 & -9 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{8}{5} & \\frac{9}{5} & \\frac{7}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -9, -7]])\nprint(a * -(1/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & 0 & 3 \\\\\n 0 & -1 & 3 \\\\\n -1 & -2 & -3 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -3 & -6 & -9 \\\\\n -3 & -5 & -12 \\\\\n 3 & 8 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0, 3],\n [0, -1, 3],\n [-1, -2, -3]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{2} & \\frac{29}{4} & -7 \\\\\n -\\frac{5}{2} & \\frac{27}{4} & \\frac{35}{4} \\\\\n \\frac{27}{4} & \\frac{33}{4} & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.251,1.508,1.\\}, \\{0.216\\, -1.345 i,-0.594+0.119 i,1.\\}, \\{0.216\\, +1.345 i,-0.594-0.119 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), (29/4), -7],\n [-(5/2), (27/4), (35/4)],\n [(27/4), (33/4), -2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -8 \\\\\n -1 \\\\\n -3 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$28$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-8],\n [-1],\n [-3],\n [9]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 3 & -\\frac{5}{2} & 3 \\\\\n -\\frac{3}{2} & 0 & -2 \\\\\n -\\frac{5}{2} & \\frac{3}{2} & -2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{21}{4} & -3 & 8 \\\\\n \\frac{1}{2} & \\frac{3}{4} & -\\frac{1}{2} \\\\\n -\\frac{19}{4} & \\frac{13}{4} & -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -(5/2), 3],\n [-(3/2), 0, -2],\n [-(5/2), (3/2), -2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\sqrt{\\frac{3}{14}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [1],\n [0],\n [1],\n [-1],\n [1],\n [0],\n [-1]]).squeeze()\nb = np.array([\n [-1],\n [-1],\n [1],\n [0],\n [0],\n [-1],\n [0],\n [-1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{2}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 5 \\\\\n -5 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 15 \\\\\n \\frac{25}{2} \\\\\n -\\frac{25}{2} \\\\\n -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [5],\n [-5],\n [-3]])\nprint(a * (5/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2 & 0 & 3 \\\\\n 2 & 1 & 0 \\\\\n -1 & 3 & -3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 31 & -36 & 48 \\\\\n 0 & 19 & -24 \\\\\n -40 & 12 & 15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, 3],\n [2, 1, 0],\n [-1, 3, -3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{7}{5},\\frac{9}{5},1\\right\\}, \\left\\{-\\frac{2}{5},\\frac{2}{5},-\\frac{9}{5}\\right\\}, \\left\\{\\frac{12}{5},\\frac{9}{5},0\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{7}{\\sqrt{155}},\\frac{9}{\\sqrt{155}},\\sqrt{\\frac{5}{31}}\\right\\}, \\left\\{-\\frac{23}{3 \\sqrt{208630}},\\frac{679}{3 \\sqrt{208630}},-\\frac{119 \\sqrt{\\frac{10}{20863}}}{3}\\right\\}, \\left\\{\\frac{91}{3 \\sqrt{1346}},-\\frac{53}{3 \\sqrt{1346}},-\\frac{16 \\sqrt{\\frac{2}{673}}}{3}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack((((7/5), (9/5), 1), (-(2/5), (2/5), -(9/5)), ((12/5), (9/5), 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{11}{3} & \\frac{10}{9} \\\\\n -\\frac{1}{3} & -\\frac{4}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{6}{17} & \\frac{15}{17} \\\\\n -\\frac{9}{34} & -\\frac{99}{34} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/3), (10/9)],\n [-(1/3), -(4/9)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 3 & -4 & -10 \\\\\n -1 & -7 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 9 & -3 & 2 \\\\\n 1 & -4 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 12 & -7 & -8 \\\\\n 0 & -11 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -4, -10],\n [-1, -7, 8]])\nb = np.array([\n [9, -3, 2],\n [1, -4, -3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 10 \\\\\n 4 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -5 \\\\\n 7 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 7 \\\\\n 5 \\\\\n 11 \\\\\n -13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [10],\n [4],\n [-6]])\nb = np.array([\n [7],\n [-5],\n [7],\n [-7]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 3 \\\\\n -2 & 3 \\\\\n -2 & 0 \\\\\n -3 & 3 \\\\\n -3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.92 \\\\\n -0.01 \\\\\n -2.78 \\\\\n -0.96 \\\\\n -1.1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.569 \\\\\n 0.207 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3],\n [-2, 3],\n [-2, 0],\n [-3, 3],\n [-3, -3]])\nb = np.array([\n [2.92],\n [-0.01],\n [-2.78],\n [-0.96],\n [-1.1]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,-1,-2\\}, \\{-1,-4,-5\\}, \\{-3,-1,-1\\}}$.", - "Output Answer": [ - "$3 x-14 y+12 z+7=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -1, -2],\n [-1, -4, -5],\n [-3, -1, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 6 & -1 & 0 \\\\\n -2 & 7 & 3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -5 & 3 & 2 \\\\\n 1 & -8 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 11 & -4 & -2 \\\\\n -3 & 15 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -1, 0],\n [-2, 7, 3]])\nb = np.array([\n [-5, 3, 2],\n [1, -8, -4]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{42}{5} \\\\\n -4 \\\\\n \\frac{46}{5} \\\\\n \\frac{32}{5} \\\\\n -\\frac{37}{5} \\\\\n -\\frac{6}{5} \\\\\n \\frac{27}{5} \\\\\n -\\frac{6}{5} \\\\\n -\\frac{4}{5} \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{34}{5} \\\\\n \\frac{38}{5} \\\\\n 9 \\\\\n -\\frac{27}{5} \\\\\n \\frac{16}{5} \\\\\n \\frac{33}{5} \\\\\n -\\frac{4}{5} \\\\\n -8 \\\\\n -4 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{14838}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(42/5)],\n [-4],\n [(46/5)],\n [(32/5)],\n [-(37/5)],\n [-(6/5)],\n [(27/5)],\n [-(6/5)],\n [-(4/5)],\n [4]])\nb = np.array([\n [-(34/5)],\n [(38/5)],\n [9],\n [-(27/5)],\n [(16/5)],\n [(33/5)],\n [-(4/5)],\n [-8],\n [-4],\n [-3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & 6 \\\\\n 8 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-x-54$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 6],\n [8, 3]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & 2 \\\\\n -2 & 1 \\\\\n -3 & -2 \\\\\n 2 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.55 \\\\\n 1.5 \\\\\n -0.96 \\\\\n 1.29 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.381 \\\\\n -0.102 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2],\n [-2, 1],\n [-3, -2],\n [2, 0]])\nb = np.array([\n [-2.55],\n [1.5],\n [-0.96],\n [1.29]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & -5 \\\\\n 1 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+3 x+1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -5],\n [1, 1]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & 5 \\\\\n 3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-23$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 5],\n [3, -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -3 & 2 & 0 & 0 \\\\\n -2 & 2 & 2 & -3 \\\\\n 1 & 0 & -1 & -2 \\\\\n 1 & 3 & -1 & -3 \\\\\n -2 & 1 & -2 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 1 \\\\\n 1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 8 \\\\\n 2 \\\\\n -7 \\\\\n -6 \\\\\n 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2, 0, 0],\n [-2, 2, 2, -3],\n [1, 0, -1, -2],\n [1, 3, -1, -3],\n [-2, 1, -2, 1]])\nb = np.array([\n [-2],\n [1],\n [1],\n [2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n \\frac{25}{6} & \\frac{11}{3} & -\\frac{26}{3} \\\\\n \\frac{9}{2} & -\\frac{29}{6} & 2 \\\\\n -3 & \\frac{10}{3} & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -6 & \\frac{5}{2} & \\frac{20}{3} \\\\\n -\\frac{11}{2} & \\frac{55}{6} & \\frac{22}{3} \\\\\n \\frac{53}{6} & \\frac{15}{2} & \\frac{23}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{6} & \\frac{37}{6} & -2 \\\\\n -1 & \\frac{13}{3} & \\frac{28}{3} \\\\\n \\frac{35}{6} & \\frac{65}{6} & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(25/6), (11/3), -(26/3)],\n [(9/2), -(29/6), 2],\n [-3, (10/3), (2/3)]])\nb = np.array([\n [-6, (5/2), (20/3)],\n [-(11/2), (55/6), (22/3)],\n [(53/6), (15/2), (23/6)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n -2 \\\\\n 2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{14}} \\\\\n -\\frac{1}{\\sqrt{14}} \\\\\n -\\sqrt{\\frac{2}{7}} \\\\\n \\sqrt{\\frac{2}{7}} \\\\\n -\\sqrt{\\frac{2}{7}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [-2],\n [2],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{2} \\\\\n \\frac{9}{4} \\\\\n -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{2} \\\\\n -\\frac{3}{4} \\\\\n \\frac{19}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1 \\\\\n 3 \\\\\n -\\frac{45}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2)],\n [(9/4)],\n [-(13/2)]])\nb = np.array([\n [-(7/2)],\n [-(3/4)],\n [(19/4)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 9 \\\\\n -8 \\\\\n -5 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 1 \\\\\n 5 \\\\\n -4 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$11 \\sqrt{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [9],\n [-8],\n [-5],\n [8]])\nb = np.array([\n [5],\n [1],\n [5],\n [-4],\n [6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -4 & -4 \\\\\n 4 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -4],\n [4, 2]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -5 & -1 & 5 & -9 \\\\\n 3 & -2 & 7 & 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 6 & -9 & -8 & -3 \\\\\n 3 & 5 & 1 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & -10 & -3 & -12 \\\\\n 6 & 3 & 8 & 14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -1, 5, -9],\n [3, -2, 7, 7]])\nb = np.array([\n [6, -9, -8, -3],\n [3, 5, 1, 7]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{2} & \\frac{13}{2} \\\\\n -6 & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{6} \\left(-1-i \\sqrt{38}\\right),1\\right\\}, \\left\\{\\frac{1}{6} \\left(-1+i \\sqrt{38}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), (13/2)],\n [-6, -(9/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{47}{5} & -\\frac{23}{5} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -2 & -\\frac{39}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{37}{5} & \\frac{16}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(47/5), -(23/5)]])\nb = np.array([\n [-2, -(39/5)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,3,-4\\}, \\{0,-1,-5\\}, \\{-2,-3,-2\\}}$.", - "Output Answer": [ - "$14 x+y+10 z+51=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, 3, -4],\n [0, -1, -5],\n [-2, -3, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 0 & -2 \\\\\n -7 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, -2],\n [-7, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(\\sqrt{6}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [1],\n [-1],\n [0],\n [1],\n [1]]).squeeze()\nb = np.array([\n [0],\n [1],\n [1],\n [-1],\n [-1],\n [-1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{3} & -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{8}{3} & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{3} & -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/3), -(2/3)]])\nb = np.array([\n [-(8/3), 4]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{2} \\\\\n -\\frac{1}{2} \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$12$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/2)],\n [-(1/2)],\n [6]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 10 & -1 \\\\\n 8 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{16} \\left(19-\\sqrt{329}\\right),1\\right\\}, \\left\\{\\frac{1}{16} \\left(19+\\sqrt{329}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -1],\n [8, -9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5.66 \\\\\n 5.4 \\\\\n 7.48 \\\\\n 6.77 \\\\\n 1.43 \\\\\n 5.5 \\\\\n 9.47 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4.33 \\\\\n 0.05 \\\\\n -4.09 \\\\\n 6.24 \\\\\n -0.58 \\\\\n -3.12 \\\\\n -6.55 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-92.6041$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5.66],\n [5.4],\n [7.48],\n [6.77],\n [1.43],\n [5.5],\n [9.47]])\nb = np.array([\n [4.33],\n [0.05],\n [-4.09],\n [6.24],\n [-0.58],\n [-3.12],\n [-6.55]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\text{Indeterminate}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [0],\n [0]]).squeeze()\nb = np.array([\n [0],\n [1],\n [0],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 0 & 10 \\\\\n 2 & -6 \\\\\n 8 & 5 \\\\\n 4 & -9 \\\\\n -7 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, 10],\n [2, -6],\n [8, 5],\n [4, -9],\n [-7, 5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{8}{3}, 2, \\frac{2}{3}}$ to the plane $\\frac{x}{3}-\\frac{4 y}{3}+\\frac{z}{3}-\\frac{4}{3}=0$.", - "Output Answer": [ - "$\\frac{13 \\sqrt{2}}{9}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (8/3), 2, (2/3)\nplane = Poly((x/3)-((4*y)/3)+(z/3)-(4/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{93}{32}, -\\frac{101}{32}}$ to the line $\\frac{155 x}{32}+\\frac{15 y}{4}+\\frac{107}{32}=0$.", - "Output Answer": [ - "$\\frac{23111}{160 \\sqrt{1537}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(93/32), -(101/32)\nline = Poly(((155*x)/32)+((15*y)/4)+(107/32), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{5}{2}, \\frac{9}{2}}$ to the line $\\frac{3 x}{2}+\\frac{3}{2}=0$.", - "Output Answer": [ - "$\\frac{7}{2}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (5/2), (9/2)\nline = Poly(((3*x)/2)+(3/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & 7 \\\\\n 8 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+8 x-44$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 7],\n [8, -2]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{14}{5}, -\\frac{7}{5}, -\\frac{17}{5}}$ to the plane $-\\frac{13 x}{5}-\\frac{9 y}{5}+\\frac{23 z}{5}+\\frac{24}{5}=0$.", - "Output Answer": [ - "$\\frac{26}{5 \\sqrt{779}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(14/5), -(7/5), -(17/5)\nplane = Poly(-((13*x)/5)-((9*y)/5)+((23*z)/5)+(24/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & 0 & -1 & 2 \\\\\n 1 & -1 & -1 & 0 \\\\\n -1 & 2 & 0 & -2 \\\\\n -2 & 2 & -2 & 3 \\\\\n 3 & 2 & -1 & 2 \\\\\n 1 & 0 & -1 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.4 \\\\\n 0.94 \\\\\n -1.26 \\\\\n 0.27 \\\\\n 2.18 \\\\\n 0.98 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.306 \\\\\n -0.268 \\\\\n -0.765 \\\\\n 0.234 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, -1, 2],\n [1, -1, -1, 0],\n [-1, 2, 0, -2],\n [-2, 2, -2, 3],\n [3, 2, -1, 2],\n [1, 0, -1, -2]])\nb = np.array([\n [1.4],\n [0.94],\n [-1.26],\n [0.27],\n [2.18],\n [0.98]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 1 & -2 & -4 & -10 \\\\\n -4 & -6 & 8 & 4 \\\\\n 6 & 5 & -1 & -8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 10 & 7 & -2 & 10 \\\\\n -6 & -8 & -2 & 9 \\\\\n -5 & 6 & -4 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -9 & -9 & -2 & -20 \\\\\n 2 & 2 & 10 & -5 \\\\\n 11 & -1 & 3 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2, -4, -10],\n [-4, -6, 8, 4],\n [6, 5, -1, -8]])\nb = np.array([\n [10, 7, -2, 10],\n [-6, -8, -2, 9],\n [-5, 6, -4, -7]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -9 & 3 & 3 \\\\\n 4 & 3 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -3 & -3 & 1 \\\\\n -4 & 0 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -12 & 0 & 4 \\\\\n 0 & 3 & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 3, 3],\n [4, 3, -3]])\nb = np.array([\n [-3, -3, 1],\n [-4, 0, -6]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 2 & -1 & 1 & 2 \\\\\n 1 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 0 & 0 & -2 \\\\\n -1 & 1 & -2 \\\\\n 2 & -2 & -1 \\\\\n -3 & -3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -3 & -9 & -7 \\\\\n -3 & -3 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1, 1, 2],\n [1, 0, 0, 1]])\nb = np.array([\n [0, 0, -2],\n [-1, 1, -2],\n [2, -2, -1],\n [-3, -3, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -2 \\\\\n 3 \\\\\n -2 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\sqrt{\\frac{2}{13}} \\\\\n -\\sqrt{\\frac{2}{13}} \\\\\n \\frac{3}{\\sqrt{26}} \\\\\n -\\sqrt{\\frac{2}{13}} \\\\\n \\sqrt{\\frac{2}{13}} \\\\\n \\frac{1}{\\sqrt{26}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-2],\n [3],\n [-2],\n [2],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 9 & -4 & -7 & -1 \\\\\n -3 & 8 & -5 & -10 \\\\\n 4 & 8 & 1 & -8 \\\\\n 5 & -4 & 10 & 10 \\\\\n -10 & 1 & -8 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, -4, -7, -1],\n [-3, 8, -5, -10],\n [4, 8, 1, -8],\n [5, -4, 10, 10],\n [-10, 1, -8, 3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 2 & 10 & 6 & -10 & -8 & -9 & -4 \\\\\n -5 & 8 & 8 & 1 & -9 & -7 & -7 \\\\\n 1 & 6 & 2 & -2 & -9 & -8 & -7 \\\\\n 5 & -1 & -7 & 5 & -7 & -3 & 0 \\\\\n 5 & 2 & -9 & 6 & -2 & 3 & 4 \\\\\n 6 & 3 & 8 & -8 & -5 & -2 & 9 \\\\\n 5 & 0 & 2 & 3 & -1 & -5 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, 10, 6, -10, -8, -9, -4],\n [-5, 8, 8, 1, -9, -7, -7],\n [1, 6, 2, -2, -9, -8, -7],\n [5, -1, -7, 5, -7, -3, 0],\n [5, 2, -9, 6, -2, 3, 4],\n [6, 3, 8, -8, -5, -2, 9],\n [5, 0, 2, 3, -1, -5, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 7 \\\\\n 4 \\\\\n 5 \\\\\n 4 \\\\\n -5 \\\\\n 3 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 0 \\\\\n -1 \\\\\n -6 \\\\\n 7 \\\\\n 8 \\\\\n -8 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{834}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [7],\n [4],\n [5],\n [4],\n [-5],\n [3],\n [5]])\nb = np.array([\n [-2],\n [0],\n [-1],\n [-6],\n [7],\n [8],\n [-8],\n [-9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 4 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 4 \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 44 \\\\\n 56 \\\\\n 20 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [4],\n [-9]])\nb = np.array([\n [-6],\n [4],\n [2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{20}{3} \\\\\n \\frac{13}{3} \\\\\n -\\frac{13}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{37}{6} \\\\\n -\\frac{7}{2} \\\\\n \\frac{17}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n \\frac{5}{6} \\\\\n \\frac{7}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/3)],\n [(13/3)],\n [-(13/6)]])\nb = np.array([\n [(37/6)],\n [-(7/2)],\n [(17/3)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 0 & -1 & 3 \\\\\n -3 & -3 & 8 \\\\\n -2 & -5 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{10.224,-5.863,1.\\}, \\{-0.161-0.369 i,-0.349-1.15 i,1.\\}, \\{-0.161+0.369 i,-0.349+1.15 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -1, 3],\n [-3, -3, 8],\n [-2, -5, -8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{33}{5} \\\\\n -\\frac{13}{5} \\\\\n \\frac{38}{5} \\\\\n -\\frac{27}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{44}{5} \\\\\n -\\frac{14}{5} \\\\\n \\frac{39}{5} \\\\\n -\\frac{16}{5} \\\\\n \\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{1353}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [(33/5)],\n [-(13/5)],\n [(38/5)],\n [-(27/5)]])\nb = np.array([\n [(44/5)],\n [-(14/5)],\n [(39/5)],\n [-(16/5)],\n [(8/5)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -6 \\\\\n -9 \\\\\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -1 \\\\\n -5 \\\\\n -3 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{79}{6 \\sqrt{645}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-6],\n [-9],\n [2],\n [2]]).squeeze()\nb = np.array([\n [8],\n [-1],\n [-5],\n [-3],\n [9]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{14}{3} \\\\\n -\\frac{19}{3} \\\\\n -\\frac{20}{3} \\\\\n -6 \\\\\n -\\frac{26}{3} \\\\\n \\frac{13}{3} \\\\\n 5 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{14}{3} \\\\\n \\frac{8}{3} \\\\\n \\frac{22}{3} \\\\\n -7 \\\\\n -\\frac{7}{3} \\\\\n -\\frac{8}{3} \\\\\n -7 \\\\\n \\frac{16}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{163}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/3)],\n [-(19/3)],\n [-(20/3)],\n [-6],\n [-(26/3)],\n [(13/3)],\n [5],\n [-2]])\nb = np.array([\n [-(14/3)],\n [(8/3)],\n [(22/3)],\n [-7],\n [-(7/3)],\n [-(8/3)],\n [-7],\n [(16/3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{9}{5} & \\frac{17}{10} & -\\frac{19}{10} & -1 & \\frac{23}{10} \\\\\n 2 & 1 & \\frac{29}{10} & \\frac{3}{10} & -\\frac{19}{10} \\\\\n -\\frac{11}{5} & \\frac{29}{10} & \\frac{1}{5} & -\\frac{13}{5} & \\frac{11}{10} \\\\\n \\frac{19}{10} & -2 & -\\frac{2}{5} & \\frac{21}{10} & -\\frac{12}{5} \\\\\n \\frac{13}{10} & -\\frac{12}{5} & -\\frac{1}{5} & \\frac{27}{10} & \\frac{1}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n \\frac{3}{10} \\\\\n \\frac{5}{2} \\\\\n \\frac{13}{10} \\\\\n \\frac{9}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{31}{10} \\\\\n \\frac{238}{25} \\\\\n -\\frac{553}{100} \\\\\n \\frac{39}{25} \\\\\n \\frac{143}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/5), (17/10), -(19/10), -1, (23/10)],\n [2, 1, (29/10), (3/10), -(19/10)],\n [-(11/5), (29/10), (1/5), -(13/5), (11/10)],\n [(19/10), -2, -(2/5), (21/10), -(12/5)],\n [(13/10), -(12/5), -(1/5), (27/10), (1/10)]])\nb = np.array([\n [(5/2)],\n [(3/10)],\n [(5/2)],\n [(13/10)],\n [(9/5)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{43}{8} & -6 & -\\frac{7}{2} \\\\\n \\frac{1}{2} & -\\frac{35}{8} & -\\frac{67}{8} \\\\\n 8 & -\\frac{49}{8} & -\\frac{75}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{153 x^2}{8}-\\frac{757 x}{8}+\\frac{81243}{256}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(43/8), -6, -(7/2)],\n [(1/2), -(35/8), -(67/8)],\n [8, -(49/8), -(75/8)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{9}{10}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{36}{5} \\\\\n \\frac{9}{5} \\\\\n \\frac{9}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [2],\n [2]])\nprint(a * (9/10))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{2} \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -8 \\\\\n 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/2)],\n [-(3/2)]])\nb = np.array([\n [-(1/2)],\n [-(11/2)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -1 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2]])\nb = np.array([\n [-3],\n [1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -4 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -6 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 46 \\\\\n -61 \\\\\n 26 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-4],\n [3]])\nb = np.array([\n [-4],\n [-6],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{5}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 10 & 4 \\\\\n 5 & 6 \\\\\n 8 & -1 \\\\\n 7 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -2 & -\\frac{4}{5} \\\\\n -1 & -\\frac{6}{5} \\\\\n -\\frac{8}{5} & \\frac{1}{5} \\\\\n -\\frac{7}{5} & \\frac{8}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 4],\n [5, 6],\n [8, -1],\n [7, -8]])\nprint(a * -(1/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -8 \\\\\n -2 \\\\\n 1 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-8],\n [-2],\n [1],\n [-8]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & -10 \\\\\n -6 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{12} \\left(-9-\\sqrt{321}\\right),1\\right\\}, \\left\\{\\frac{1}{12} \\left(\\sqrt{321}-9\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -10],\n [-6, -5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 1 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 6 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -31 \\\\\n -21 \\\\\n 19 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [1],\n [6]])\nb = np.array([\n [-1],\n [6],\n [5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n \\frac{29}{10} & \\frac{7}{5} & 1 & -\\frac{17}{10} \\\\\n 2 & -\\frac{4}{5} & -\\frac{13}{10} & \\frac{7}{10} \\\\\n \\frac{7}{5} & -\\frac{6}{5} & 1 & \\frac{13}{5} \\\\\n -\\frac{1}{2} & \\frac{14}{5} & -\\frac{11}{5} & \\frac{1}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -2 & \\frac{13}{10} & -\\frac{1}{5} & -\\frac{27}{10} \\\\\n \\frac{19}{10} & -\\frac{12}{5} & -\\frac{21}{10} & -\\frac{17}{10} \\\\\n \\frac{13}{5} & -\\frac{27}{10} & 0 & \\frac{3}{10} \\\\\n \\frac{3}{10} & -\\frac{9}{5} & \\frac{1}{2} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{21}{20} & \\frac{77}{100} & -\\frac{437}{100} & -\\frac{184}{25} \\\\\n -\\frac{869}{100} & \\frac{677}{100} & \\frac{163}{100} & -\\frac{137}{25} \\\\\n -\\frac{17}{10} & -\\frac{67}{25} & \\frac{177}{50} & -\\frac{267}{50} \\\\\n \\frac{33}{50} & -\\frac{179}{100} & -\\frac{142}{25} & -\\frac{437}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/10), (7/5), 1, -(17/10)],\n [2, -(4/5), -(13/10), (7/10)],\n [(7/5), -(6/5), 1, (13/5)],\n [-(1/2), (14/5), -(11/5), (1/5)]])\nb = np.array([\n [-2, (13/10), -(1/5), -(27/10)],\n [(19/10), -(12/5), -(21/10), -(17/10)],\n [(13/5), -(27/10), 0, (3/10)],\n [(3/10), -(9/5), (1/2), -(3/2)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n -8 \\\\\n -9 \\\\\n 4 \\\\\n -4 \\\\\n 7 \\\\\n 10 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -5 \\\\\n 8 \\\\\n 8 \\\\\n 1 \\\\\n 5 \\\\\n 3 \\\\\n 9 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{694}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [-8],\n [-9],\n [4],\n [-4],\n [7],\n [10],\n [-7]])\nb = np.array([\n [3],\n [-5],\n [8],\n [8],\n [1],\n [5],\n [3],\n [9],\n [-6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 6 & -4 & -8 \\\\\n -9 & 8 & 7 \\\\\n -1 & -1 & -2 \\\\\n 8 & 9 & 7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -2 & -6 & -2 \\\\\n 3 & 2 & 9 \\\\\n 4 & 5 & 2 \\\\\n 7 & 4 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 8 & 2 & -6 \\\\\n -12 & 6 & -2 \\\\\n -5 & -6 & -4 \\\\\n 1 & 5 & 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -4, -8],\n [-9, 8, 7],\n [-1, -1, -2],\n [8, 9, 7]])\nb = np.array([\n [-2, -6, -2],\n [3, 2, 9],\n [4, 5, 2],\n [7, 4, -4]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [1],\n [1],\n [-1]]).squeeze()\nb = np.array([\n [1],\n [1],\n [1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{19}{2} & -\\frac{7}{3} & \\frac{19}{2} & \\frac{31}{6} \\\\\n -\\frac{13}{2} & \\frac{35}{6} & -\\frac{1}{3} & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{25}{6} & -\\frac{25}{6} & \\frac{29}{6} & -4 \\\\\n -\\frac{4}{3} & \\frac{7}{6} & -\\frac{14}{3} & \\frac{17}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{41}{3} & -\\frac{13}{2} & \\frac{43}{3} & \\frac{7}{6} \\\\\n -\\frac{47}{6} & 7 & -5 & \\frac{11}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/2), -(7/3), (19/2), (31/6)],\n [-(13/2), (35/6), -(1/3), -1]])\nb = np.array([\n [(25/6), -(25/6), (29/6), -4],\n [-(4/3), (7/6), -(14/3), (17/6)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{23}{5}, \\frac{8}{5}, -\\frac{7}{5}}$ to the plane $-\\frac{22 x}{5}-\\frac{17 y}{5}+\\frac{4 z}{5}-\\frac{22}{5}=0$.", - "Output Answer": [ - "$52 \\sqrt{\\frac{3}{263}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (23/5), (8/5), -(7/5)\nplane = Poly(-((22*x)/5)-((17*y)/5)+((4*z)/5)-(22/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{5,0,-2\\}, \\{0,0,4\\}, \\{-2,5,3\\}}$.", - "Output Answer": [ - "$30 x+17 y+25 z-100=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [5, 0, -2],\n [0, 0, 4],\n [-2, 5, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{5}{2},-5,-\\frac{3}{2}\\right\\}, \\left\\{-\\frac{7}{2},-5,1\\right\\}, \\{0,-3,0\\}}$.", - "Output Answer": [ - "$20 x-31 (y+3)+8 z=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(5/2), -5, -(3/2)],\n [-(7/2), -5, 1],\n [0, -3, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{47}{7} \\\\\n \\frac{48}{7} \\\\\n -\\frac{20}{7} \\\\\n \\frac{10}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{15}{7} \\\\\n -\\frac{32}{7} \\\\\n \\frac{13}{7} \\\\\n -\\frac{47}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{62}{7} \\\\\n \\frac{80}{7} \\\\\n -\\frac{33}{7} \\\\\n \\frac{57}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(47/7)],\n [(48/7)],\n [-(20/7)],\n [(10/7)]])\nb = np.array([\n [(15/7)],\n [-(32/7)],\n [(13/7)],\n [-(47/7)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -3 & 1 \\\\\n 0 & -3 & 0 \\\\\n -2 & 2 & -1 \\\\\n 2 & -2 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.8 \\\\\n -1.44 \\\\\n 2.95 \\\\\n -1.96 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.958 \\\\\n -0.001 \\\\\n 0.588 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3, 1],\n [0, -3, 0],\n [-2, 2, -1],\n [2, -2, -1]])\nb = np.array([\n [1.8],\n [-1.44],\n [2.95],\n [-1.96]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{46}{5} & \\frac{47}{5} & \\frac{27}{5} \\\\\n \\frac{14}{5} & 8 & -\\frac{26}{5} \\\\\n \\frac{44}{5} & -\\frac{8}{5} & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-7.642,11.421\\, -1.075 i,11.421\\, +1.075 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(46/5), (47/5), (27/5)],\n [(14/5), 8, -(26/5)],\n [(44/5), -(8/5), -2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2} & 2 \\\\\n \\frac{1}{2} & 3 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{5}{4} & 5 \\\\\n \\frac{5}{4} & 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), 2],\n [(1/2), 3]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & -4 & -2 \\\\\n 0 & 0 & -4 \\\\\n -4 & -4 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-128$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -4, -2],\n [0, 0, -4],\n [-4, -4, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -8 & 6 & 5 & -1 \\\\\n 8 & 0 & 9 & 6 \\\\\n -7 & -6 & -7 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & -\\frac{30}{119} \\\\\n 0 & 1 & 0 & -\\frac{127}{102} \\\\\n 0 & 0 & 1 & \\frac{106}{119} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-8, 6, 5, -1],\n [8, 0, 9, 6],\n [-7, -6, -7, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{4,-4,-4\\}, \\{-2,-2,1\\}, \\{-5,-2,-3\\}}$.", - "Output Answer": [ - "$8 x+39 y-6 z+100=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, -4, -4],\n [-2, -2, 1],\n [-5, -2, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 0 \\\\\n 3 \\\\\n -8 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -3 \\\\\n 5 \\\\\n -4 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{21}{10 \\sqrt{179}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [0],\n [3],\n [-8],\n [5]]).squeeze()\nb = np.array([\n [1],\n [-3],\n [5],\n [-4],\n [-7]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -9 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2 \\\\\n -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-9]])\nb = np.array([\n [-6],\n [-6]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{2} & -3 \\\\\n 3 & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{43}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), -3],\n [3, -(1/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{11}{5} & \\frac{46}{5} \\\\\n \\frac{44}{5} & -\\frac{43}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{32 x}{5}-\\frac{2497}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/5), (46/5)],\n [(44/5), -(43/5)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{21}{5} & -\\frac{31}{10} \\\\\n \\frac{37}{10} & \\frac{39}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{491}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(21/5), -(31/10)],\n [(37/10), (39/10)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -8 & 10 \\\\\n 7 & -10 \\\\\n -4 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-8, 10],\n [7, -10],\n [-4, -10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{139}{16} & -\\frac{29}{4} \\\\\n -\\frac{97}{16} & \\frac{137}{16} \\\\\n \\frac{7}{16} & \\frac{57}{16} \\\\\n \\frac{1}{4} & -\\frac{155}{16} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{2} & -\\frac{29}{8} \\\\\n -\\frac{87}{16} & -\\frac{67}{16} \\\\\n -10 & -\\frac{73}{16} \\\\\n \\frac{27}{16} & -\\frac{17}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{99}{16} & -\\frac{29}{8} \\\\\n -\\frac{5}{8} & \\frac{51}{4} \\\\\n \\frac{167}{16} & \\frac{65}{8} \\\\\n -\\frac{23}{16} & -\\frac{121}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(139/16), -(29/4)],\n [-(97/16), (137/16)],\n [(7/16), (57/16)],\n [(1/4), -(155/16)]])\nb = np.array([\n [(5/2), -(29/8)],\n [-(87/16), -(67/16)],\n [-10, -(73/16)],\n [(27/16), -(17/8)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -6 & -\\frac{3}{4} & 8 & 0 & -7 \\\\\n \\frac{9}{2} & -\\frac{37}{4} & -\\frac{17}{2} & -\\frac{1}{4} & -\\frac{5}{2} \\\\\n -3 & \\frac{13}{4} & -\\frac{1}{4} & -\\frac{11}{2} & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -(3/4), 8, 0, -7],\n [(9/2), -(37/4), -(17/2), -(1/4), -(5/2)],\n [-3, (13/4), -(1/4), -(11/2), 5]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{5,-\\frac{8}{3},-1\\right\\}, \\left\\{-\\frac{5}{3},\\frac{2}{3},-\\frac{7}{3}\\right\\}, \\left\\{\\frac{10}{3},\\frac{2}{3},\\frac{1}{3}\\right\\}}$.", - "Output Answer": [ - "$24 x+30 y-45 z-85=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [5, -(8/3), -1],\n [-(5/3), (2/3), -(7/3)],\n [(10/3), (2/3), (1/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -2 & 3 & 3 \\\\\n -2 & 1 & -1 \\\\\n -2 & 1 & -1 \\\\\n -2 & -1 & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -1 & -2 & -1 & 2 \\\\\n -2 & 2 & 1 & 2 \\\\\n -1 & 3 & 1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -7 & 19 & 8 & 5 \\\\\n 1 & 3 & 2 & -3 \\\\\n 1 & 3 & 2 & -3 \\\\\n 1 & 11 & 4 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 3, 3],\n [-2, 1, -1],\n [-2, 1, -1],\n [-2, -1, 3]])\nb = np.array([\n [-1, -2, -1, 2],\n [-2, 2, 1, 2],\n [-1, 3, 1, 1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 9 \\\\\n -3 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -8 \\\\\n 4 \\\\\n -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{543}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [9],\n [-3],\n [3]])\nb = np.array([\n [-2],\n [-8],\n [4],\n [-10]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -7 & -6 & -10 & -10 \\\\\n 5 & -7 & -10 & -10 \\\\\n -9 & 1 & 1 & 4 \\\\\n 2 & 4 & 4 & 4 \\\\\n 6 & -8 & 7 & 10 \\\\\n -9 & 5 & 0 & 6 \\\\\n 1 & -7 & 3 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, -6, -10, -10],\n [5, -7, -10, -10],\n [-9, 1, 1, 4],\n [2, 4, 4, 4],\n [6, -8, 7, 10],\n [-9, 5, 0, 6],\n [1, -7, 3, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{281}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [3]])\nb = np.array([\n [-10],\n [-2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -2 & 2 & 1 & 1 \\\\\n -2 & 0 & -1 & -3 \\\\\n 1 & 1 & 2 & 2 \\\\\n 1 & -3 & 1 & -1 \\\\\n 0 & 1 & 3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.93 \\\\\n 1.17 \\\\\n -2.02 \\\\\n 0.61 \\\\\n 2.89 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.354 \\\\\n -1.274 \\\\\n -0.081 \\\\\n 0.849 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2, 1, 1],\n [-2, 0, -1, -3],\n [1, 1, 2, 2],\n [1, -3, 1, -1],\n [0, 1, 3, 3]])\nb = np.array([\n [-0.93],\n [1.17],\n [-2.02],\n [0.61],\n [2.89]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{32}{7} & \\frac{9}{7} \\\\\n -\\frac{31}{7} & -\\frac{4}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{28}{151} & -\\frac{63}{151} \\\\\n \\frac{217}{151} & \\frac{224}{151} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(32/7), (9/7)],\n [-(31/7), -(4/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -\\frac{1}{2} \\\\\n -2 \\\\\n -1 \\\\\n \\frac{3}{2} \\\\\n 0 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n -1 \\\\\n \\frac{5}{2} \\\\\n 3 \\\\\n -3 \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{95}{127},\\frac{38}{127},-\\frac{95}{127},-\\frac{114}{127},\\frac{114}{127},\\frac{19}{127}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-(1/2)],\n [-2],\n [-1],\n [(3/2)],\n [0]]).squeeze()\nb = np.array([\n [(5/2)],\n [-1],\n [(5/2)],\n [3],\n [-3],\n [-(1/2)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -1 & 0 & -3 \\\\\n 1 & 2 & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 0 & 1 & 2 & 1 \\\\\n 2 & -2 & -2 & 3 \\\\\n -3 & 1 & -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 9 & -4 & 1 & -10 \\\\\n -5 & 0 & -5 & 16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, -3],\n [1, 2, 3]])\nb = np.array([\n [0, 1, 2, 1],\n [2, -2, -2, 3],\n [-3, 1, -1, 3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 3 & 3 & 2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 3 & 3 & 2 & -1 \\\\\n -3 & -3 & -2 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1]])\nb = np.array([\n [3, 3, 2, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{5} & \\frac{3}{5} & 5 \\\\\n \\frac{34}{5} & -\\frac{9}{5} & \\frac{48}{5} \\\\\n -\\frac{6}{5} & -\\frac{13}{5} & -\\frac{29}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{37 x^2}{5}-\\frac{179 x}{5}-\\frac{9421}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/5), (3/5), 5],\n [(34/5), -(9/5), (48/5)],\n [-(6/5), -(13/5), -(29/5)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 3 & -3 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 2 & 1 & 0 \\\\\n -1 & -2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 9 & 9 & 9 \\\\\n -1 & -2 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -3],\n [0, 1]])\nb = np.array([\n [2, 1, 0],\n [-1, -2, -3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{3} & 0 & -\\frac{11}{3} \\\\\n 3 & 2 & -1 \\\\\n -\\frac{2}{3} & \\frac{10}{3} & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{682}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/3), 0, -(11/3)],\n [3, 2, -1],\n [-(2/3), (10/3), 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -3 & -9 & -7 & 7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 5 & 7 & 8 & 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -8 & -16 & -15 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -9, -7, 7]])\nb = np.array([\n [5, 7, 8, 10]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -6 & -3 & 8 & 1 & -8 \\\\\n -6 & 1 & 5 & -4 & -8 \\\\\n 4 & -6 & 4 & 4 & 8 \\\\\n 1 & -3 & 0 & -1 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-323.,482.,196.,268.,291.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-6, -3, 8, 1, -8],\n [-6, 1, 5, -4, -8],\n [4, -6, 4, 4, 8],\n [1, -3, 0, -1, 7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 4 & -8 \\\\\n 1 & 0 \\\\\n -9 & 8 \\\\\n -8 & 6 \\\\\n -7 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, -8],\n [1, 0],\n [-9, 8],\n [-8, 6],\n [-7, 3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 2 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 17 \\\\\n -5 \\\\\n -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-3],\n [2]])\nb = np.array([\n [-10],\n [2],\n [4]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,1,1\\}, \\{1,-2,-2\\}, \\{2,-2,-2\\}}$", - "Output Answer": [ - "${\\left\\{\\sqrt{\\frac{2}{3}},\\frac{1}{\\sqrt{6}},\\frac{1}{\\sqrt{6}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}}\\right\\}, \\{0,0,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, 1, 1), (1, -2, -2), (2, -2, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{37}{5} & \\frac{29}{5} & \\frac{18}{5} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{48}{5} & -\\frac{2}{5} & -\\frac{42}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -17 & \\frac{31}{5} & 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(37/5), (29/5), (18/5)]])\nb = np.array([\n [(48/5), -(2/5), -(42/5)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{2} & -6 \\\\\n \\frac{23}{4} & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{4} \\left(-9-\\sqrt{177}\\right),\\frac{1}{4} \\left(\\sqrt{177}-9\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/2), -6],\n [(23/4), -9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{5}{2},-\\frac{5}{2},-\\frac{1}{2}\\right\\}, \\left\\{-\\frac{3}{2},0,-3\\right\\}, \\left\\{-2,2,\\frac{1}{2}\\right\\}}$.", - "Output Answer": [ - "$110 x-18 y+26 z+243=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(5/2), -(5/2), -(1/2)],\n [-(3/2), 0, -3],\n [-2, 2, (1/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -2 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 0 \\\\\n -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 18 \\\\\n 57 \\\\\n -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-2],\n [-3]])\nb = np.array([\n [-4],\n [0],\n [-9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{2}{9}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 10 & 5 & 1 & -4 \\\\\n -3 & 9 & 0 & -8 \\\\\n 5 & -4 & -10 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{20}{9} & -\\frac{10}{9} & -\\frac{2}{9} & \\frac{8}{9} \\\\\n \\frac{2}{3} & -2 & 0 & \\frac{16}{9} \\\\\n -\\frac{10}{9} & \\frac{8}{9} & \\frac{20}{9} & \\frac{10}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 5, 1, -4],\n [-3, 9, 0, -8],\n [5, -4, -10, -5]])\nprint(a * -(2/9))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\sqrt{3} \\\\\n -3 \\sqrt{3} \\\\\n -3 \\sqrt{3} \\\\\n 2 \\sqrt{3} \\\\\n 6 \\sqrt{3} \\\\\n -4 \\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n 6 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\sqrt{3} \\\\\n 5 \\sqrt{3} \\\\\n -4 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n -\\sqrt{3} \\\\\n -4 \\sqrt{3} \\\\\n 2 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$108$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-3*math.sqrt(3)],\n [-3*math.sqrt(3)],\n [-3*math.sqrt(3)],\n [2*math.sqrt(3)],\n [6*math.sqrt(3)],\n [-4*math.sqrt(3)],\n [-2*math.sqrt(3)],\n [6*math.sqrt(3)]])\nb = np.array([\n [-math.sqrt(3)],\n [5*math.sqrt(3)],\n [-4*math.sqrt(3)],\n [3*math.sqrt(3)],\n [math.sqrt(3)],\n [-math.sqrt(3)],\n [-4*math.sqrt(3)],\n [2*math.sqrt(3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -9 & 5 & 5 \\\\\n 0 & 0 & -6 \\\\\n 7 & -5 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-18 x^2-16 x+60$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 5, 5],\n [0, 0, -6],\n [7, -5, -9]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -9 \\\\\n 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 70 \\\\\n 14 \\\\\n -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [1],\n [7]])\nb = np.array([\n [3],\n [-9],\n [7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 10 & 6 & -10 & 5 & -3 \\\\\n 4 & 3 & 9 & 9 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & -14 & -\\frac{13}{2} & -\\frac{11}{2} \\\\\n 0 & 1 & \\frac{65}{3} & \\frac{35}{3} & \\frac{26}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, 6, -10, 5, -3],\n [4, 3, 9, 9, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{32}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 7 & 4 & 2 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{35}{32} & \\frac{5}{8} & \\frac{5}{16} & \\frac{25}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 4, 2, 5]])\nprint(a * (5/32))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -\\frac{14}{5} & -\\frac{3}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{11}{5} & \\frac{14}{5} & \\frac{9}{5} \\\\\n 0 & \\frac{3}{5} & \\frac{14}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{154}{25} & -\\frac{41}{5} & -\\frac{168}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(14/5), -(3/5)]])\nb = np.array([\n [(11/5), (14/5), (9/5)],\n [0, (3/5), (14/5)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 6 \\\\\n 10 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [6],\n [10],\n [-2]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -7 & 8 & -2 \\\\\n 6 & 6 & -5 \\\\\n 9 & 2 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.396,1.198,1.\\}, \\{0.014\\, -0.427 i,-0.021-0.869 i,1.\\}, \\{0.014\\, +0.427 i,-0.021+0.869 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 8, -2],\n [6, 6, -5],\n [9, 2, 9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 0 & 7 & -10 & 4 & -2 & 10 \\\\\n -3 & -9 & -3 & -4 & 0 & -5 \\\\\n -5 & -2 & -8 & 10 & -9 & 10 \\\\\n 7 & 1 & -1 & 2 & -1 & 0 \\\\\n 5 & -3 & 8 & 0 & -7 & -3 \\\\\n 6 & -2 & 10 & -7 & 2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, 7, -10, 4, -2, 10],\n [-3, -9, -3, -4, 0, -5],\n [-5, -2, -8, 10, -9, 10],\n [7, 1, -1, 2, -1, 0],\n [5, -3, 8, 0, -7, -3],\n [6, -2, 10, -7, 2, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 1 & -2 \\\\\n -1 & \\frac{3}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 8 & -\\frac{27}{2} \\\\\n -\\frac{27}{4} & \\frac{91}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2],\n [-1, (3/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 9 & -3 \\\\\n 7 & 3 \\\\\n 7 & -4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -1 & 3 \\\\\n 9 & 2 \\\\\n 9 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 10 & -6 \\\\\n -2 & 1 \\\\\n -2 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -3],\n [7, 3],\n [7, -4]])\nb = np.array([\n [-1, 3],\n [9, 2],\n [9, -7]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 3 \\\\\n -1 \\\\\n 1 \\\\\n -3 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{21}} \\\\\n \\sqrt{\\frac{3}{7}} \\\\\n -\\frac{1}{\\sqrt{21}} \\\\\n \\frac{1}{\\sqrt{21}} \\\\\n -\\sqrt{\\frac{3}{7}} \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [3],\n [-1],\n [1],\n [-3],\n [0]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -1 & 0 & -4 \\\\\n 2 & 4 & -4 \\\\\n -2 & 2 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{3} & \\frac{1}{9} & -\\frac{2}{9} \\\\\n 0 & \\frac{1}{6} & \\frac{1}{6} \\\\\n -\\frac{1}{6} & -\\frac{1}{36} & \\frac{1}{18} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, -4],\n [2, 4, -4],\n [-2, 2, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{3}{2},\\frac{1}{2},-\\frac{3}{2}\\right\\}, \\left\\{-\\frac{5}{4},\\frac{5}{4},-2\\right\\}, \\left\\{2,-\\frac{1}{4},\\frac{3}{2}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{3}{\\sqrt{19}},\\frac{1}{\\sqrt{19}},-\\frac{3}{\\sqrt{19}}\\right\\}, \\left\\{-\\frac{137}{\\sqrt{37430}},\\frac{81}{\\sqrt{37430}},-11 \\sqrt{\\frac{10}{3743}}\\right\\}, \\left\\{\\frac{7}{\\sqrt{1970}},\\frac{39}{\\sqrt{1970}},2 \\sqrt{\\frac{10}{197}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack((((3/2), (1/2), -(3/2)), (-(5/4), (5/4), -2), (2, -(1/4), (3/2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{4} & -\\frac{65}{8} & \\frac{1}{8} \\\\\n \\frac{69}{8} & \\frac{21}{4} & -\\frac{3}{2} \\\\\n \\frac{37}{4} & -\\frac{23}{8} & \\frac{39}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{57 x^2}{4}-\\frac{6691 x}{64}+\\frac{384855}{512}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/4), -(65/8), (1/8)],\n [(69/8), (21/4), -(3/2)],\n [(37/4), -(23/8), (39/4)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -7 & 10 & 7 \\\\\n 10 & -8 & 7 \\\\\n -6 & 8 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-20 x^2-17 x+416$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 10, 7],\n [10, -8, 7],\n [-6, 8, -5]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & 0 & 3 & 1 \\\\\n -3 & 0 & 2 & 0 \\\\\n 0 & 3 & 3 & 1 \\\\\n -3 & -3 & 0 & -2 \\\\\n -1 & 3 & 0 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.25 \\\\\n -1.47 \\\\\n 2.57 \\\\\n -1.09 \\\\\n 2.45 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.315 \\\\\n -0.161 \\\\\n 0.467 \\\\\n 0.92 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, 3, 1],\n [-3, 0, 2, 0],\n [0, 3, 3, 1],\n [-3, -3, 0, -2],\n [-1, 3, 0, 3]])\nb = np.array([\n [2.25],\n [-1.47],\n [2.57],\n [-1.09],\n [2.45]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -6 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 9 \\\\\n -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 93 \\\\\n 17 \\\\\n 54 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-6],\n [-5]])\nb = np.array([\n [3],\n [9],\n [-8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{2} \\\\\n 0 \\\\\n \\frac{39}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{2} \\\\\n -\\frac{37}{4} \\\\\n -\\frac{31}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -9 \\\\\n -\\frac{37}{4} \\\\\n 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/2)],\n [0],\n [(39/4)]])\nb = np.array([\n [-(7/2)],\n [-(37/4)],\n [-(31/4)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${0, -\\frac{1}{2}}$ to the line $-2 x-\\frac{9 y}{2}+\\frac{1}{2}=0$.", - "Output Answer": [ - "$\\frac{11}{2 \\sqrt{97}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 0, -(1/2)\nline = Poly(-2*x-((9*y)/2)+(1/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{1}{5}, \\frac{4}{5}, -\\frac{13}{5}}$ to the plane $-\\frac{22 x}{5}-\\frac{2 y}{5}-\\frac{6 z}{5}-\\frac{14}{5}=0$.", - "Output Answer": [ - "$\\frac{11}{5 \\sqrt{131}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (1/5), (4/5), -(13/5)\nplane = Poly(-((22*x)/5)-((2*y)/5)-((6*z)/5)-(14/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 6 & 5 & 2 & -7 \\\\\n 10 & -8 & 2 & -6 \\\\\n 7 & 1 & -10 & -2 \\\\\n 5 & -10 & -3 & -5 \\\\\n 9 & 2 & 2 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [6, 5, 2, -7],\n [10, -8, 2, -6],\n [7, 1, -10, -2],\n [5, -10, -3, -5],\n [9, 2, 2, -10]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & 2 \\\\\n 2 & 2 \\\\\n 1 & -2 \\\\\n 3 & 2 \\\\\n -3 & 2 \\\\\n -2 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.79 \\\\\n 2.1 \\\\\n 1.13 \\\\\n -1.37 \\\\\n -1.92 \\\\\n 2.04 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.145 \\\\\n 0.106 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2],\n [2, 2],\n [1, -2],\n [3, 2],\n [-3, 2],\n [-2, 3]])\nb = np.array([\n [0.79],\n [2.1],\n [1.13],\n [-1.37],\n [-1.92],\n [2.04]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -5 & 0 \\\\\n -8 & -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 7 & 6 \\\\\n 3 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 2 & 6 \\\\\n -5 & -13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 0],\n [-8, -10]])\nb = np.array([\n [7, 6],\n [3, -3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,1,0\\}, \\{-3,0,2\\}, \\{1,0,1\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{2}{\\sqrt{5}},\\frac{1}{\\sqrt{5}},0\\right\\}, \\left\\{-\\frac{3}{\\sqrt{145}},-\\frac{6}{\\sqrt{145}},2 \\sqrt{\\frac{5}{29}}\\right\\}, \\left\\{\\frac{2}{\\sqrt{29}},\\frac{4}{\\sqrt{29}},\\frac{3}{\\sqrt{29}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, 1, 0), (-3, 0, 2), (1, 0, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -8 & -9 & 5 \\\\\n 5 & 1 & \\frac{17}{2} \\\\\n -\\frac{19}{2} & -3 & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6.023-11.041 i,-6.023+11.041 i,2.546\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -9, 5],\n [5, 1, (17/2)],\n [-(19/2), -3, -(5/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,4,5\\}, \\{0,0,-4\\}, \\{-4,-5,-5\\}}$.", - "Output Answer": [ - "$41 x-35 y+11 (z+4)=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, 4, 5],\n [0, 0, -4],\n [-4, -5, -5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 4 & 4 & 5 & 10 & 9 \\\\\n 5 & 0 & -1 & -9 & -4 \\\\\n 7 & -7 & 1 & -8 & 5 \\\\\n 0 & 3 & -7 & -3 & -1 \\\\\n -6 & -4 & 5 & 1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, 4, 5, 10, 9],\n [5, 0, -1, -9, -4],\n [7, -7, 1, -8, 5],\n [0, 3, -7, -3, -1],\n [-6, -4, 5, 1, 3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{12}{5} \\\\\n -2 \\\\\n -\\frac{2}{5} \\\\\n -2 \\\\\n \\frac{14}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{\\sqrt{34}} \\\\\n -\\frac{5}{2 \\sqrt{34}} \\\\\n -\\frac{1}{2 \\sqrt{34}} \\\\\n -\\frac{5}{2 \\sqrt{34}} \\\\\n \\frac{7}{2 \\sqrt{34}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(12/5)],\n [-2],\n [-(2/5)],\n [-2],\n [(14/5)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 0 & 1 & 0 \\\\\n -6 & -4 & -2 \\\\\n 1 & 6 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+5 x^2+18 x+52$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 0],\n [-6, -4, -2],\n [1, 6, 9]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n \\frac{4}{3} & \\frac{7}{3} & -1 \\\\\n -\\frac{7}{3} & \\frac{7}{3} & \\frac{2}{3} \\\\\n \\frac{1}{3} & -\\frac{8}{3} & \\frac{8}{3} \\\\\n -2 & -\\frac{8}{3} & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{1}{3} & -2 & 0 & \\frac{7}{3} \\\\\n -3 & -\\frac{2}{3} & \\frac{2}{3} & -\\frac{1}{3} \\\\\n -1 & -\\frac{1}{3} & -\\frac{7}{3} & \\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{50}{9} & -\\frac{35}{9} & \\frac{35}{9} & 2 \\\\\n -\\frac{76}{9} & \\frac{26}{9} & 0 & -6 \\\\\n \\frac{49}{9} & \\frac{2}{9} & -8 & \\frac{23}{9} \\\\\n \\frac{23}{3} & \\frac{53}{9} & -1 & -\\frac{35}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3), (7/3), -1],\n [-(7/3), (7/3), (2/3)],\n [(1/3), -(8/3), (8/3)],\n [-2, -(8/3), -(1/3)]])\nb = np.array([\n [(1/3), -2, 0, (7/3)],\n [-3, -(2/3), (2/3), -(1/3)],\n [-1, -(1/3), -(7/3), (1/3)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n 3 & -9 \\\\\n -4 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -9],\n [-4, 4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -1 & 0 & -1 & 2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -3 & 0 & -3 & 6 & -3 \\\\\n 3 & 0 & 3 & -6 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-3]])\nb = np.array([\n [-1, 0, -1, 2, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{11}{2} \\\\\n \\frac{7}{2} \\\\\n -\\frac{17}{2} \\\\\n \\frac{9}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{17}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/2)],\n [(7/2)],\n [-(17/2)],\n [(9/4)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{8}{9}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -10 & 9 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{80}{9} & -8 & \\frac{8}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 9, -3]])\nprint(a * -(8/9))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -2 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-2],\n [8]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & -2 & 3 \\\\\n -1 & 7 & 9 \\\\\n -8 & 4 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.034,1.409,1.\\}, \\{-0.117-1.481 i,-1.029-2.172 i,1.\\}, \\{-0.117+1.481 i,-1.029+2.172 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -2, 3],\n [-1, 7, 9],\n [-8, 4, 8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & -1 & 1 & -1 \\\\\n -1 & -2 & -1 & 1 \\\\\n 3 & 1 & -1 & 3 \\\\\n -2 & 0 & 3 & 3 \\\\\n 3 & -2 & 3 & -3 \\\\\n 0 & 0 & -1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.25 \\\\\n -1.31 \\\\\n 0.44 \\\\\n 0.78 \\\\\n 1.34 \\\\\n -1.34 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.174 \\\\\n 0.381 \\\\\n 0.464 \\\\\n -0.111 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, 1, -1],\n [-1, -2, -1, 1],\n [3, 1, -1, 3],\n [-2, 0, 3, 3],\n [3, -2, 3, -3],\n [0, 0, -1, 3]])\nb = np.array([\n [0.25],\n [-1.31],\n [0.44],\n [0.78],\n [1.34],\n [-1.34]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -3 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -10 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-25$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-3],\n [-9]])\nb = np.array([\n [-1],\n [-10],\n [5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & -8 \\\\\n -4 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{8} \\left(-3-\\sqrt{137}\\right),1\\right\\}, \\left\\{\\frac{1}{8} \\left(\\sqrt{137}-3\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -8],\n [-4, 3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{21}{5}, \\frac{23}{5}}$ to the line $-\\frac{17 x}{5}+\\frac{21 y}{5}-\\frac{22}{5}=0$.", - "Output Answer": [ - "$\\frac{8 \\sqrt{\\frac{2}{365}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (21/5), (23/5)\nline = Poly(-((17*x)/5)+((21*y)/5)-(22/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{31}{4} & -\\frac{7}{2} & -\\frac{19}{2} & -7 \\\\\n \\frac{17}{2} & 9 & -\\frac{21}{4} & \\frac{21}{4} \\\\\n \\frac{13}{4} & -\\frac{11}{2} & \\frac{9}{2} & 7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 8 & -\\frac{35}{4} & \\frac{31}{4} & \\frac{27}{4} \\\\\n -\\frac{9}{4} & 8 & 4 & -1 \\\\\n -1 & -\\frac{17}{4} & \\frac{3}{2} & -\\frac{21}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{1}{4} & \\frac{21}{4} & -\\frac{69}{4} & -\\frac{55}{4} \\\\\n \\frac{43}{4} & 1 & -\\frac{37}{4} & \\frac{25}{4} \\\\\n \\frac{17}{4} & -\\frac{5}{4} & 3 & \\frac{49}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(31/4), -(7/2), -(19/2), -7],\n [(17/2), 9, -(21/4), (21/4)],\n [(13/4), -(11/2), (9/2), 7]])\nb = np.array([\n [8, -(35/4), (31/4), (27/4)],\n [-(9/4), 8, 4, -1],\n [-1, -(17/4), (3/2), -(21/4)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{3} & \\frac{5}{3} \\\\\n \\frac{14}{3} & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{115}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/3), (5/3)],\n [(14/3), 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & -8 \\\\\n 4 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{-i \\sqrt{2},1\\right\\}, \\left\\{i \\sqrt{2},1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -8],\n [4, -7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n \\frac{13}{2} \\\\\n -\\frac{11}{2} \\\\\n 6 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{\\frac{395}{2}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [(13/2)],\n [-(11/2)],\n [6],\n [8]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{2} \\\\\n -4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{8} \\\\\n \\frac{5}{2} \\\\\n -\\frac{41}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{51}{2} \\\\\n -\\frac{153}{16} \\\\\n -\\frac{51}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2)],\n [-4],\n [-2]])\nb = np.array([\n [-(13/8)],\n [(5/2)],\n [-(41/8)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -3 & 9 \\\\\n 2 & -1 \\\\\n -9 & 2 \\\\\n 8 & 1 \\\\\n 0 & 6 \\\\\n 0 & 4 \\\\\n -6 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 9],\n [2, -1],\n [-9, 2],\n [8, 1],\n [0, 6],\n [0, 4],\n [-6, -10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,3,-1\\}, \\{-3,1,-3\\}, \\{1,-1,-1\\}}$", - "Output Answer": [ - "${\\left\\{\\sqrt{\\frac{2}{7}},\\frac{3}{\\sqrt{14}},-\\frac{1}{\\sqrt{14}}\\right\\}, \\left\\{-\\frac{3}{\\sqrt{19}},\\frac{1}{\\sqrt{19}},-\\frac{3}{\\sqrt{19}}\\right\\}, \\left\\{4 \\sqrt{\\frac{2}{133}},-\\frac{9}{\\sqrt{266}},-\\frac{11}{\\sqrt{266}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, 3, -1), (-3, 1, -3), (1, -1, -1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,-4,-3\\}, \\{-2,0,3\\}, \\{0,4,-3\\}}$.", - "Output Answer": [ - "$2 (4 x+z+5)-y=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, -4, -3],\n [-2, 0, 3],\n [0, 4, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 8 & -7 & -8 & -10 & 8 & -4 & 10 \\\\\n 10 & -1 & 6 & -9 & -2 & -2 & 5 \\\\\n 8 & 2 & -4 & 8 & -9 & -4 & 1 \\\\\n 6 & 3 & 4 & 2 & 3 & 1 & -3 \\\\\n 7 & -6 & 10 & -7 & -6 & 5 & -2 \\\\\n -9 & 4 & -2 & 7 & 6 & -1 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & \\frac{6359}{26242} \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & \\frac{120751}{131210} \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & -\\frac{556587}{524840} \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & -\\frac{290299}{262420} \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & -\\frac{53037}{131210} \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & \\frac{29672}{65605} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, -7, -8, -10, 8, -4, 10],\n [10, -1, 6, -9, -2, -2, 5],\n [8, 2, -4, 8, -9, -4, 1],\n [6, 3, 4, 2, 3, 1, -3],\n [7, -6, 10, -7, -6, 5, -2],\n [-9, 4, -2, 7, 6, -1, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 0 & -3 & 1 & 3 \\\\\n 1 & -2 & -3 & 2 \\\\\n 1 & 0 & -1 & 0 \\\\\n 2 & 0 & 2 & -1 \\\\\n 2 & -3 & -1 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -1 & 1 & 1 \\\\\n 0 & 2 & -3 \\\\\n 1 & -1 & -1 \\\\\n 0 & -3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & -16 & 14 \\\\\n -4 & -6 & 14 \\\\\n -2 & 2 & 2 \\\\\n 0 & 3 & -2 \\\\\n -3 & 6 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3, 1, 3],\n [1, -2, -3, 2],\n [1, 0, -1, 0],\n [2, 0, 2, -1],\n [2, -3, -1, -3]])\nb = np.array([\n [-1, 1, 1],\n [0, 2, -3],\n [1, -1, -1],\n [0, -3, 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -8 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 7 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-136$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-8],\n [-8]])\nb = np.array([\n [-8],\n [7],\n [8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & -8 & 3 \\\\\n -5 & -10 & -5 \\\\\n 8 & -6 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.653,-0.308,1.\\}, \\{1.069,-0.503,1.\\}, \\{2.031,4.741,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -8, 3],\n [-5, -10, -5],\n [8, -6, -1]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{55}{9} & \\frac{17}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{13}{9} & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{14}{3} & \\frac{17}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(55/9), (17/3)]])\nb = np.array([\n [(13/9), 0]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3.6 \\\\\n -0.2 \\\\\n 10. \\\\\n 5.8 \\\\\n 9.8 \\\\\n -6.2 \\\\\n -9.7 \\\\\n 1.2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7.5 \\\\\n 9.7 \\\\\n 2. \\\\\n 9.8 \\\\\n -3.6 \\\\\n 4.9 \\\\\n 2.8 \\\\\n 0.6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9.8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3.6],\n [-0.2],\n [10.],\n [5.8],\n [9.8],\n [-6.2],\n [-9.7],\n [1.2]])\nb = np.array([\n [-7.5],\n [9.7],\n [2.],\n [9.8],\n [-3.6],\n [4.9],\n [2.8],\n [0.6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{2} \\\\\n -\\frac{11}{4} \\\\\n -\\frac{41}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{71}{8} \\\\\n -\\frac{19}{2} \\\\\n -\\frac{33}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1195}{32} \\\\\n -\\frac{4627}{64} \\\\\n \\frac{2757}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/2)],\n [-(11/4)],\n [-(41/8)]])\nb = np.array([\n [(71/8)],\n [-(19/2)],\n [-(33/8)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -2 \\\\\n -2 \\\\\n -1 \\\\\n 0 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{3}} \\\\\n -\\frac{2}{3 \\sqrt{3}} \\\\\n -\\frac{2}{3 \\sqrt{3}} \\\\\n -\\frac{1}{3 \\sqrt{3}} \\\\\n 0 \\\\\n -\\frac{1}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-2],\n [-2],\n [-1],\n [0],\n [-3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 2 \\\\\n -8 \\\\\n -2 \\\\\n -8 \\\\\n 5 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -10 \\\\\n -3 \\\\\n 9 \\\\\n 4 \\\\\n -5 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{587}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [2],\n [-8],\n [-2],\n [-8],\n [5],\n [6]])\nb = np.array([\n [1],\n [-10],\n [-3],\n [9],\n [4],\n [-5],\n [-1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & -2 \\\\\n -5 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -2],\n [-5, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n 5 \\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n 0 \\\\\n 3 \\sqrt{3} \\\\\n 0 \\\\\n 2 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\sqrt{3} \\\\\n 0 \\\\\n 2 \\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$96$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-6*math.sqrt(3)],\n [4*math.sqrt(3)],\n [5*math.sqrt(3)],\n [-2*math.sqrt(3)],\n [0],\n [3*math.sqrt(3)],\n [0],\n [2*math.sqrt(3)]])\nb = np.array([\n [-math.sqrt(3)],\n [0],\n [2*math.sqrt(3)],\n [-2*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [4*math.sqrt(3)],\n [0],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & -\\frac{11}{5} & 4 \\\\\n -3 & -\\frac{22}{5} & -\\frac{4}{5} \\\\\n 3 & \\frac{49}{10} & -\\frac{47}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{82}{265} & \\frac{463}{3975} & \\frac{968}{3975} \\\\\n -\\frac{11}{53} & -\\frac{214}{795} & -\\frac{104}{795} \\\\\n -\\frac{1}{53} & -\\frac{164}{795} & -\\frac{154}{795} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(11/5), 4],\n [-3, -(22/5), -(4/5)],\n [3, (49/10), -(47/10)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -2 \\\\\n 0 \\\\\n 2 \\\\\n -1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2}{\\sqrt{17}} \\\\\n -\\frac{2}{\\sqrt{17}} \\\\\n 0 \\\\\n \\frac{2}{\\sqrt{17}} \\\\\n -\\frac{1}{\\sqrt{17}} \\\\\n \\frac{2}{\\sqrt{17}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-2],\n [0],\n [2],\n [-1],\n [2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 9 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -3 \\\\\n -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -39 \\\\\n 11 \\\\\n -63 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [9],\n [-4]])\nb = np.array([\n [4],\n [-3],\n [-3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 0 & 3 & -8 & 1 & 0 \\\\\n 8 & -6 & -2 & -3 & 4 \\\\\n 7 & -1 & 8 & 9 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & \\frac{244}{253} & -\\frac{211}{253} \\\\\n 0 & 1 & 0 & \\frac{411}{253} & -\\frac{400}{253} \\\\\n 0 & 0 & 1 & \\frac{245}{506} & -\\frac{150}{253} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, 3, -8, 1, 0],\n [8, -6, -2, -3, 4],\n [7, -1, 8, 9, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 0 & \\frac{1}{2} \\\\\n \\frac{5}{2} & -2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{5}{2} & \\frac{21}{8} \\\\\n \\frac{105}{8} & -13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, (1/2)],\n [(5/2), -2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -7 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 5 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{329}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-7],\n [6]])\nb = np.array([\n [5],\n [5],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 1 & -3 & -2 \\\\\n 4 & 4 & -1 \\\\\n -1 & 5 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{26} & \\frac{8}{39} & -\\frac{11}{78} \\\\\n -\\frac{3}{26} & \\frac{2}{39} & \\frac{7}{78} \\\\\n -\\frac{4}{13} & \\frac{1}{39} & -\\frac{8}{39} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3, -2],\n [4, 4, -1],\n [-1, 5, -2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{23}{5} & \\frac{23}{5} & \\frac{49}{5} \\\\\n \\frac{49}{5} & \\frac{47}{5} & -5 \\\\\n -\\frac{24}{5} & \\frac{17}{5} & -\\frac{3}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{9.301,17.519,1.\\}, \\{-0.126-1.045 i,-0.136+0.927 i,1.\\}, \\{-0.126+1.045 i,-0.136-0.927 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/5), (23/5), (49/5)],\n [(49/5), (47/5), -5],\n [-(24/5), (17/5), -(3/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -5 & 2 \\\\\n 4 & -3 & -5 \\\\\n -4 & 1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-190$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -5, 2],\n [4, -3, -5],\n [-4, 1, -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{9} \\\\\n -\\frac{79}{9} \\\\\n -9 \\\\\n 7 \\\\\n -\\frac{26}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{2 \\sqrt{5726}}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/9)],\n [-(79/9)],\n [-9],\n [7],\n [-(26/3)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -3 & 6 & -8 \\\\\n 0 & 1 & -1 \\\\\n 5 & -2 & 8 \\\\\n 0 & 6 & 10 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 4 & 6 & -10 \\\\\n -7 & 5 & 2 \\\\\n 9 & -6 & 10 \\\\\n 9 & 5 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -7 & 0 & 2 \\\\\n 7 & -4 & -3 \\\\\n -4 & 4 & -2 \\\\\n -9 & 1 & 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 6, -8],\n [0, 1, -1],\n [5, -2, 8],\n [0, 6, 10]])\nb = np.array([\n [4, 6, -10],\n [-7, 5, 2],\n [9, -6, 10],\n [9, 5, -2]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{47}{10} \\\\\n -\\frac{2}{5} \\\\\n \\frac{34}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{61}{10} \\\\\n \\frac{17}{5} \\\\\n \\frac{57}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{127}{5} \\\\\n \\frac{6827}{100} \\\\\n -\\frac{677}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(47/10)],\n [-(2/5)],\n [(34/5)]])\nb = np.array([\n [(61/10)],\n [(17/5)],\n [(57/10)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{11}{4} & -\\frac{15}{8} & \\frac{5}{4} & -\\frac{21}{8} & -\\frac{1}{8} \\\\\n -2 & \\frac{1}{8} & \\frac{11}{4} & -\\frac{3}{4} & -\\frac{21}{8} \\\\\n -\\frac{3}{8} & \\frac{17}{8} & \\frac{3}{8} & -\\frac{5}{8} & \\frac{5}{4} \\\\\n \\frac{1}{4} & -\\frac{13}{8} & \\frac{5}{8} & -2 & -2 \\\\\n -\\frac{9}{4} & -\\frac{9}{4} & -\\frac{19}{8} & -2 & \\frac{21}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{15}{8} & -\\frac{23}{8} \\\\\n -\\frac{17}{8} & -\\frac{3}{2} \\\\\n -1 & -\\frac{23}{8} \\\\\n \\frac{13}{8} & 0 \\\\\n -\\frac{5}{4} & \\frac{7}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{209}{32} & -\\frac{563}{64} \\\\\n \\frac{179}{64} & -\\frac{297}{64} \\\\\n -\\frac{433}{64} & -\\frac{67}{32} \\\\\n \\frac{103}{64} & -\\frac{117}{64} \\\\\n \\frac{155}{32} & \\frac{607}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/4), -(15/8), (5/4), -(21/8), -(1/8)],\n [-2, (1/8), (11/4), -(3/4), -(21/8)],\n [-(3/8), (17/8), (3/8), -(5/8), (5/4)],\n [(1/4), -(13/8), (5/8), -2, -2],\n [-(9/4), -(9/4), -(19/8), -2, (21/8)]])\nb = np.array([\n [-(15/8), -(23/8)],\n [-(17/8), -(3/2)],\n [-1, -(23/8)],\n [(13/8), 0],\n [-(5/4), (7/8)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{32}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -8 & 5 & 7 \\\\\n -10 & -9 & -5 \\\\\n 8 & -5 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{4} & -\\frac{5}{32} & -\\frac{7}{32} \\\\\n \\frac{5}{16} & \\frac{9}{32} & \\frac{5}{32} \\\\\n -\\frac{1}{4} & \\frac{5}{32} & -\\frac{5}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 5, 7],\n [-10, -9, -5],\n [8, -5, 5]])\nprint(a * -(1/32))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{51}{10} & -\\frac{47}{10} \\\\\n -\\frac{31}{5} & -\\frac{33}{10} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{59}{10} & -\\frac{11}{2} \\\\\n -\\frac{3}{10} & \\frac{24}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{4}{5} & \\frac{4}{5} \\\\\n -\\frac{59}{10} & -\\frac{81}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(51/10), -(47/10)],\n [-(31/5), -(33/10)]])\nb = np.array([\n [(59/10), -(11/2)],\n [-(3/10), (24/5)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -\\frac{17}{2} \\\\\n 8 \\\\\n \\frac{19}{2} \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$40$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-(17/2)],\n [8],\n [(19/2)],\n [5]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\sqrt{5} \\\\\n 0 \\\\\n 2 \\sqrt{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\sqrt{5} \\\\\n -\\sqrt{5} \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-45$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-3*math.sqrt(5)],\n [0],\n [2*math.sqrt(5)]])\nb = np.array([\n [3*math.sqrt(5)],\n [-math.sqrt(5)],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{2} \\\\\n \\frac{7}{4} \\\\\n -\\frac{5}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{25}{4} \\\\\n -1 \\\\\n \\frac{17}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{109}{8} \\\\\n \\frac{737}{16} \\\\\n \\frac{247}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2)],\n [(7/4)],\n [-(5/4)]])\nb = np.array([\n [-(25/4)],\n [-1],\n [(17/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -1 & \\frac{17}{2} \\\\\n -6 & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{24} i \\left(\\sqrt{767}-7 i\\right),1\\right\\}, \\left\\{-\\frac{1}{24} i \\left(\\sqrt{767}+7 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, (17/2)],\n [-6, (5/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,-4,0\\}, \\{-3,3,2\\}, \\{-1,-5,3\\}}$.", - "Output Answer": [ - "$23 x+5 y-6 z+66=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, -4, 0],\n [-3, 3, 2],\n [-1, -5, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, \\frac{12}{5}}$ to the line $\\frac{4 x}{5}+3 y-\\frac{18}{5}=0$.", - "Output Answer": [ - "$\\frac{30}{\\sqrt{241}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, (12/5)\nline = Poly(((4*x)/5)+3*y-(18/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 5 & -1 \\\\\n 2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{4} & -\\frac{1}{8} \\\\\n \\frac{1}{4} & -\\frac{5}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -1],\n [2, -2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -9 & 7 \\\\\n -2 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-8-i \\sqrt{13},-8+i \\sqrt{13}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 7],\n [-2, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -8 & 2 & -3 & -7 & -2 & 6 \\\\\n 1 & 10 & -9 & -10 & -2 & 8 \\\\\n 6 & 6 & -10 & -2 & -8 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & \\frac{139}{221} & -\\frac{4}{221} & -\\frac{142}{221} \\\\\n 0 & 1 & 0 & -\\frac{261}{221} & \\frac{246}{221} & \\frac{335}{221} \\\\\n 0 & 0 & 1 & -\\frac{29}{221} & \\frac{322}{221} & \\frac{160}{221} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-8, 2, -3, -7, -2, 6],\n [1, 10, -9, -10, -2, 8],\n [6, 6, -10, -2, -8, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-3$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -4 & 4 & 7 \\\\\n -10 & -7 & 3 \\\\\n -1 & 2 & 0 \\\\\n 8 & 4 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 12 & -12 & -21 \\\\\n 30 & 21 & -9 \\\\\n 3 & -6 & 0 \\\\\n -24 & -12 & 24 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 4, 7],\n [-10, -7, 3],\n [-1, 2, 0],\n [8, 4, -8]])\nprint(a * -3)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{4}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n -\\frac{15}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-5]])\nprint(a * (3/4))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 10 & 1 & -1 & -6 \\\\\n -3 & -3 & -2 & 1 \\\\\n -8 & -2 & 1 & 6 \\\\\n -6 & 6 & 0 & 0 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -2 & -10 & -8 & -2 \\\\\n -8 & 0 & 1 & 6 \\\\\n 0 & 3 & -6 & -2 \\\\\n -9 & -10 & 9 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 12 & 11 & 7 & -4 \\\\\n 5 & -3 & -3 & -5 \\\\\n -8 & -5 & 7 & 8 \\\\\n 3 & 16 & -9 & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 1, -1, -6],\n [-3, -3, -2, 1],\n [-8, -2, 1, 6],\n [-6, 6, 0, 0]])\nb = np.array([\n [-2, -10, -8, -2],\n [-8, 0, 1, 6],\n [0, 3, -6, -2],\n [-9, -10, 9, 7]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -3 \\\\\n -2 \\\\\n 1 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 0 \\\\\n -3 \\\\\n 2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{9}{14},0,0,\\frac{27}{14},-\\frac{9}{7},0\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-3],\n [-2],\n [1],\n [-3],\n [2]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [0],\n [-3],\n [2],\n [0]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{6} \\\\\n \\frac{7}{6} \\\\\n -\\frac{2}{3} \\\\\n \\frac{17}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{7}{\\sqrt{403}} \\\\\n \\frac{7}{\\sqrt{403}} \\\\\n -\\frac{4}{\\sqrt{403}} \\\\\n \\frac{17}{\\sqrt{403}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/6)],\n [(7/6)],\n [-(2/3)],\n [(17/6)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 0 \\\\\n 6 \\\\\n -2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -5 \\\\\n 9 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 7 \\\\\n 5 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [0],\n [6],\n [-2]])\nb = np.array([\n [-4],\n [-5],\n [9],\n [-4]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{4}{9} & \\frac{35}{9} & \\frac{7}{3} \\\\\n -\\frac{8}{9} & -2 & \\frac{34}{9} \\\\\n \\frac{8}{3} & \\frac{43}{9} & -\\frac{4}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{695}{1936} & \\frac{1043}{3872} & \\frac{49}{121} \\\\\n \\frac{49}{242} & -\\frac{61}{484} & -\\frac{1}{121} \\\\\n \\frac{1}{44} & \\frac{23}{88} & \\frac{1}{11} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/9), (35/9), (7/3)],\n [-(8/9), -2, (34/9)],\n [(8/3), (43/9), -(4/9)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{1}{2}, -2, -\\frac{9}{2}}$ to the plane $4 x+\\frac{y}{2}+\\frac{7 z}{2}+4=0$.", - "Output Answer": [ - "$\\frac{59}{2 \\sqrt{114}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(1/2), -2, -(9/2)\nplane = Poly(4*x+(y/2)+((7*z)/2)+4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 3 & -10 \\\\\n -2 & 0 \\\\\n -2 & 8 \\\\\n -10 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 4 & -6 \\\\\n 10 & 2 \\\\\n -8 & -5 \\\\\n -5 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 7 & -16 \\\\\n 8 & 2 \\\\\n -10 & 3 \\\\\n -15 & 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -10],\n [-2, 0],\n [-2, 8],\n [-10, 0]])\nb = np.array([\n [4, -6],\n [10, 2],\n [-8, -5],\n [-5, 9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{46}{5} \\\\\n -\\frac{34}{5} \\\\\n -\\frac{3}{10} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{97}{10} \\\\\n -\\frac{24}{5} \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{189}{10} \\\\\n -2 \\\\\n \\frac{6}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(46/5)],\n [-(34/5)],\n [-(3/10)]])\nb = np.array([\n [-(97/10)],\n [-(24/5)],\n [-(3/2)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{\\log (2),0,-\\log (2)\\}, \\{0,-2 \\log (2),-2 \\log (2)\\}, \\{\\log (2),-\\log (2),4 \\log (2)\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{2}},0,-\\frac{1}{\\sqrt{2}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{6}},-\\sqrt{\\frac{2}{3}},-\\frac{1}{\\sqrt{6}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}},\\frac{1}{\\sqrt{3}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((math.log(2), 0, -math.log(2)), (0, -2*math.log(2), -2*math.log(2)), (math.log(2), -math.log(2), 4*math.log(2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & 5 & 4 \\\\\n -6 & -2 & 9 \\\\\n 4 & -1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{2.059,-0.498,1.\\}, \\{-0.207-0.919 i,-1.46+1.571 i,1.\\}, \\{-0.207+0.919 i,-1.46-1.571 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 5, 4],\n [-6, -2, 9],\n [4, -1, -4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(-2 \\sqrt{3}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [0],\n [1],\n [1],\n [0]]).squeeze()\nb = np.array([\n [1],\n [0],\n [1],\n [0],\n [0],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{1,-3,2\\}, \\{2,-2,2\\}, \\{-3,0,-2\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{14}},-\\frac{3}{\\sqrt{14}},\\sqrt{\\frac{2}{7}}\\right\\}, \\left\\{\\frac{4}{\\sqrt{21}},\\frac{2}{\\sqrt{21}},\\frac{1}{\\sqrt{21}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{6}},-\\frac{1}{\\sqrt{6}},-\\sqrt{\\frac{2}{3}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((1, -3, 2), (2, -2, 2), (-3, 0, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 10 & 8 & 6 \\\\\n -1 & -10 & -10 \\\\\n 0 & 3 & 2 \\\\\n -6 & -6 & -10 \\\\\n -1 & 4 & -8 \\\\\n -5 & 3 & -3 \\\\\n 4 & 4 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, 8, 6],\n [-1, -10, -10],\n [0, 3, 2],\n [-6, -6, -10],\n [-1, 4, -8],\n [-5, 3, -3],\n [4, 4, 2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-6$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 9 & 1 & 6 & 2 \\\\\n 2 & 10 & -9 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -54 & -6 & -36 & -12 \\\\\n -12 & -60 & 54 & -24 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 1, 6, 2],\n [2, 10, -9, 4]])\nprint(a * -6)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${0, -\\frac{10}{3}, -\\frac{7}{3}}$ to the plane $-\\frac{13 x}{3}+\\frac{14 y}{3}-3 z+\\frac{10}{3}=0$.", - "Output Answer": [ - "$\\frac{47}{3 \\sqrt{446}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 0, -(10/3), -(7/3)\nplane = Poly(-((13*x)/3)+((14*y)/3)-3*z+(10/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n \\frac{7}{4} & -\\frac{45}{8} & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{15}{2} & -\\frac{9}{2} & -\\frac{77}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{23}{4} & -\\frac{81}{8} & -\\frac{41}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/4), -(45/8), (9/2)]])\nb = np.array([\n [-(15/2), -(9/2), -(77/8)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [-1],\n [0],\n [0],\n [0],\n [1],\n [1],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [-1],\n [0],\n [0],\n [0],\n [1],\n [1],\n [-1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{25}{7}, -\\frac{12}{7}}$ to the line $-\\frac{12 x}{7}-\\frac{y}{7}+\\frac{18}{7}=0$.", - "Output Answer": [ - "$\\frac{438}{7 \\sqrt{145}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(25/7), -(12/7)\nline = Poly(-((12*x)/7)-(y/7)+(18/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -5 & -\\frac{11}{3} \\\\\n -\\frac{10}{3} & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{9}{155} & -\\frac{33}{155} \\\\\n -\\frac{6}{31} & \\frac{9}{31} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -(11/3)],\n [-(10/3), 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 1 & 1 \\\\\n 1 & -2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 4 \\\\\n 4 & -11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1],\n [1, -2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 1 & -5 & -2 \\\\\n 5 & 0 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & \\frac{4}{5} \\\\\n 0 & 1 & \\frac{14}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, -5, -2],\n [5, 0, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -9 & -2 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -1 & -7 & 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -10 & -9 & 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -2, 2]])\nb = np.array([\n [-1, -7, 10]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{39}{16} & -\\frac{11}{16} & -\\frac{5}{2} & 0 \\\\\n \\frac{41}{16} & \\frac{5}{16} & 1 & \\frac{7}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{3}{8} & \\frac{45}{16} & \\frac{7}{8} & -\\frac{7}{8} & -\\frac{27}{16} \\\\\n -\\frac{11}{16} & 0 & \\frac{5}{8} & -\\frac{47}{16} & -\\frac{37}{16} \\\\\n -\\frac{11}{16} & -\\frac{1}{16} & \\frac{9}{16} & \\frac{19}{16} & \\frac{5}{2} \\\\\n \\frac{17}{8} & \\frac{19}{8} & \\frac{21}{16} & -\\frac{29}{16} & \\frac{41}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n \\frac{795}{256} & -\\frac{1715}{256} & -\\frac{127}{32} & \\frac{303}{256} & -\\frac{35}{64} \\\\\n \\frac{475}{256} & \\frac{2893}{256} & \\frac{339}{64} & -\\frac{1317}{256} & \\frac{31}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(39/16), -(11/16), -(5/2), 0],\n [(41/16), (5/16), 1, (7/4)]])\nb = np.array([\n [-(3/8), (45/16), (7/8), -(7/8), -(27/16)],\n [-(11/16), 0, (5/8), -(47/16), -(37/16)],\n [-(11/16), -(1/16), (9/16), (19/16), (5/2)],\n [(17/8), (19/8), (21/16), -(29/16), (41/16)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & -1 & -2 & 2 \\\\\n -2 & 3 & 0 & 0 \\\\\n 0 & 1 & -3 & 3 \\\\\n 3 & 1 & 2 & -1 \\\\\n 2 & -3 & 3 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.19 \\\\\n 0.1 \\\\\n -0.54 \\\\\n -0.93 \\\\\n 1.24 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.271 \\\\\n -0.309 \\\\\n 0.288 \\\\\n 0.41 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, -2, 2],\n [-2, 3, 0, 0],\n [0, 1, -3, 3],\n [3, 1, 2, -1],\n [2, -3, 3, 0]])\nb = np.array([\n [1.19],\n [0.1],\n [-0.54],\n [-0.93],\n [1.24]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 2 & \\frac{7}{3} \\\\\n \\frac{7}{3} & \\frac{14}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{6}{5} & -\\frac{3}{5} \\\\\n -\\frac{3}{5} & \\frac{18}{35} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, (7/3)],\n [(7/3), (14/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & \\frac{21}{4} \\\\\n -\\frac{13}{2} & \\frac{15}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{8} \\left(21-i \\sqrt{2103}\\right),\\frac{1}{8} \\left(21+i \\sqrt{2103}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), (21/4)],\n [-(13/2), (15/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-2$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -7 & -2 & -10 & 6 \\\\\n 1 & 8 & -5 & 1 \\\\\n -2 & -5 & 10 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 14 & 4 & 20 & -12 \\\\\n -2 & -16 & 10 & -2 \\\\\n 4 & 10 & -20 & -20 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -2, -10, 6],\n [1, 8, -5, 1],\n [-2, -5, 10, 10]])\nprint(a * -2)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n 7 & -3 & 2 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -3, 2, 7]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{489}{50} \\\\\n -\\frac{469}{100} \\\\\n \\frac{331}{50} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{1614689}}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(489/50)],\n [-(469/100)],\n [(331/50)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{37}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{407}{128} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/8)]])\nb = np.array([\n [(37/16)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 8 & -7 \\\\\n -6 & 10 \\\\\n -9 & 4 \\\\\n -5 & -8 \\\\\n -3 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [8, -7],\n [-6, 10],\n [-9, 4],\n [-5, -8],\n [-3, 8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{18}{7} & \\frac{29}{7} & \\frac{24}{7} \\\\\n -\\frac{2}{7} & \\frac{27}{7} & \\frac{18}{7} \\\\\n -1 & \\frac{5}{7} & -\\frac{5}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1575}{3698} & -\\frac{1855}{3698} & \\frac{441}{1849} \\\\\n \\frac{476}{1849} & -\\frac{273}{1849} & \\frac{1302}{1849} \\\\\n -\\frac{1253}{3698} & \\frac{2051}{3698} & -\\frac{1904}{1849} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(18/7), (29/7), (24/7)],\n [-(2/7), (27/7), (18/7)],\n [-1, (5/7), -(5/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n 1 \\\\\n -8 \\\\\n -\\frac{21}{4} \\\\\n 10 \\\\\n -\\frac{33}{4} \\\\\n -\\frac{39}{4} \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{4} \\\\\n 8 \\\\\n -\\frac{31}{4} \\\\\n -\\frac{5}{2} \\\\\n -\\frac{7}{2} \\\\\n -\\frac{5}{4} \\\\\n 5 \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{241}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2)],\n [1],\n [-8],\n [-(21/4)],\n [10],\n [-(33/4)],\n [-(39/4)],\n [-4]])\nb = np.array([\n [-(9/4)],\n [8],\n [-(31/4)],\n [-(5/2)],\n [-(7/2)],\n [-(5/4)],\n [5],\n [-(1/2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n 10 & -\\frac{12}{5} & -\\frac{36}{5} \\\\\n \\frac{17}{5} & \\frac{39}{5} & \\frac{24}{5} \\\\\n -\\frac{23}{5} & \\frac{27}{5} & -\\frac{47}{5} \\\\\n -9 & -\\frac{49}{5} & \\frac{19}{5} \\\\\n \\frac{33}{5} & -\\frac{4}{5} & \\frac{28}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -(12/5), -(36/5)],\n [(17/5), (39/5), (24/5)],\n [-(23/5), (27/5), -(47/5)],\n [-9, -(49/5), (19/5)],\n [(33/5), -(4/5), (28/5)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{61}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-8]])\nb = np.array([\n [3],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\sqrt{3} \\\\\n -4 \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n -4 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\sqrt{3} \\\\\n 5 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n 6 \\sqrt{3} \\\\\n -4 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{114}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-2*math.sqrt(3)],\n [-4*math.sqrt(3)],\n [math.sqrt(3)],\n [-5*math.sqrt(3)],\n [-4*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [0]])\nb = np.array([\n [3*math.sqrt(3)],\n [5*math.sqrt(3)],\n [4*math.sqrt(3)],\n [6*math.sqrt(3)],\n [-4*math.sqrt(3)],\n [4*math.sqrt(3)],\n [-5*math.sqrt(3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 3 & 5 & 7 & -3 \\\\\n 4 & 4 & 0 & 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -3 & -5 & -2 & 8 \\\\\n -5 & -9 & 1 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 0 & 0 & 5 & 5 \\\\\n -1 & -5 & 1 & 16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 5, 7, -3],\n [4, 4, 0, 7]])\nb = np.array([\n [-3, -5, -2, 8],\n [-5, -9, 1, 9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{20}{3} & -5 & -\\frac{89}{9} \\\\\n -\\frac{22}{3} & \\frac{10}{9} & \\frac{37}{9} \\\\\n -\\frac{55}{9} & -8 & -\\frac{62}{9} \\\\\n \\frac{65}{9} & \\frac{88}{9} & \\frac{22}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{2}{9} & -8 & 9 \\\\\n -\\frac{71}{9} & \\frac{17}{3} & \\frac{31}{9} \\\\\n \\frac{59}{9} & -\\frac{7}{3} & -\\frac{88}{9} \\\\\n -3 & -\\frac{44}{9} & \\frac{62}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{58}{9} & 3 & -\\frac{170}{9} \\\\\n \\frac{5}{9} & -\\frac{41}{9} & \\frac{2}{3} \\\\\n -\\frac{38}{3} & -\\frac{17}{3} & \\frac{26}{9} \\\\\n \\frac{92}{9} & \\frac{44}{3} & \\frac{4}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/3), -5, -(89/9)],\n [-(22/3), (10/9), (37/9)],\n [-(55/9), -8, -(62/9)],\n [(65/9), (88/9), (22/3)]])\nb = np.array([\n [-(2/9), -8, 9],\n [-(71/9), (17/3), (31/9)],\n [(59/9), -(7/3), -(88/9)],\n [-3, -(44/9), (62/9)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & 3 & 2 \\\\\n 1 & -1 & 2 \\\\\n -3 & 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-16$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 3, 2],\n [1, -1, 2],\n [-3, 1, -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{9}{7} \\\\\n \\frac{9}{7} \\\\\n -\\frac{15}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{\\sqrt{43}} \\\\\n \\frac{3}{\\sqrt{43}} \\\\\n -\\frac{5}{\\sqrt{43}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/7)],\n [(9/7)],\n [-(15/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -8 & -2 & 7 & 5 & -5 & -3 & -5 \\\\\n 1 & -6 & -3 & -1 & -3 & 2 & -7 \\\\\n -7 & -5 & -1 & -6 & 7 & 4 & 7 \\\\\n 9 & 5 & 4 & -10 & 7 & -3 & 1 \\\\\n 4 & 0 & -9 & 8 & 4 & 0 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & -\\frac{15879}{37105} & -\\frac{49034}{37105} \\\\\n 0 & 1 & 0 & 0 & 0 & \\frac{2313}{14842} & \\frac{25219}{14842} \\\\\n 0 & 0 & 1 & 0 & 0 & -\\frac{26586}{37105} & -\\frac{41571}{37105} \\\\\n 0 & 0 & 0 & 1 & 0 & -\\frac{34717}{74210} & -\\frac{69647}{74210} \\\\\n 0 & 0 & 0 & 0 & 1 & -\\frac{3689}{14842} & -\\frac{1073}{14842} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-8, -2, 7, 5, -5, -3, -5],\n [1, -6, -3, -1, -3, 2, -7],\n [-7, -5, -1, -6, 7, 4, 7],\n [9, 5, 4, -10, 7, -3, 1],\n [4, 0, -9, 8, 4, 0, -3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & 2 & 2 & 3 \\\\\n 2 & -2 & 3 & 0 \\\\\n 2 & 3 & -3 & 2 \\\\\n 1 & -3 & 3 & -1 \\\\\n 1 & -1 & 2 & -2 \\\\\n 3 & -3 & 3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.21 \\\\\n 2.6 \\\\\n -2.81 \\\\\n 0.69 \\\\\n 2.48 \\\\\n 2.54 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.004 \\\\\n 0.31 \\\\\n 1.021 \\\\\n -0.087 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, 2, 3],\n [2, -2, 3, 0],\n [2, 3, -3, 2],\n [1, -3, 3, -1],\n [1, -1, 2, -2],\n [3, -3, 3, 2]])\nb = np.array([\n [2.21],\n [2.6],\n [-2.81],\n [0.69],\n [2.48],\n [2.54]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{4}{\\pi },\\frac{2}{\\pi },\\frac{5}{\\pi }\\right\\}, \\left\\{\\frac{7}{\\pi },-\\frac{4}{\\pi },-\\frac{2}{\\pi }\\right\\}, \\left\\{-\\frac{1}{\\pi },-\\frac{8}{\\pi },0\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{4}{3 \\sqrt{5}},\\frac{2}{3 \\sqrt{5}},\\frac{\\sqrt{5}}{3}\\right\\}, \\left\\{\\frac{131}{3 \\sqrt{4945}},-\\frac{88}{3 \\sqrt{4945}},\\frac{28 \\sqrt{\\frac{5}{989}}}{3}\\right\\}, \\left\\{-\\frac{16}{\\sqrt{989}},-\\frac{27}{\\sqrt{989}},-\\frac{2}{\\sqrt{989}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-(4/math.pi), (2/math.pi), (5/math.pi)), ((7/math.pi), -(4/math.pi), -(2/math.pi)), (-(1/math.pi), -(8/math.pi), 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & 7 \\\\\n 4 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+6 x-35$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 7],\n [4, 1]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{5,-1,-3\\}, \\{2,-1,-5\\}, \\{3,0,2\\}}$.", - "Output Answer": [ - "$2 x+19 y-3 z=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [5, -1, -3],\n [2, -1, -5],\n [3, 0, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -8 & -8 & -7 \\\\\n -2 & 4 & 0 \\\\\n -7 & -4 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-11.582,5.179,11.403\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -8, -7],\n [-2, 4, 0],\n [-7, -4, 9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{5}{\\pi },-\\frac{1}{\\pi },\\frac{3}{\\pi }\\right\\}, \\left\\{\\frac{3}{\\pi },-\\frac{3}{\\pi },0\\right\\}, \\left\\{\\frac{4}{\\pi },-\\frac{4}{\\pi },-\\frac{5}{\\pi }\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\sqrt{\\frac{5}{7}},-\\frac{1}{\\sqrt{35}},\\frac{3}{\\sqrt{35}}\\right\\}, \\left\\{\\sqrt{\\frac{5}{238}},-\\frac{29}{\\sqrt{1190}},-9 \\sqrt{\\frac{2}{595}}\\right\\}, \\left\\{\\frac{3}{\\sqrt{34}},\\frac{3}{\\sqrt{34}},-2 \\sqrt{\\frac{2}{17}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((5/math.pi), -(1/math.pi), (3/math.pi)), ((3/math.pi), -(3/math.pi), 0), ((4/math.pi), -(4/math.pi), -(5/math.pi))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & 0 & -2 & -1 \\\\\n -3 & 3 & 3 & -1 \\\\\n 3 & -3 & 0 & 3 \\\\\n -3 & 1 & 2 & -3 \\\\\n 3 & -2 & 1 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.22 \\\\\n 2.58 \\\\\n -1.96 \\\\\n 2.36 \\\\\n -1.89 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.573 \\\\\n 0.1 \\\\\n 0.146 \\\\\n -0.046 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, -2, -1],\n [-3, 3, 3, -1],\n [3, -3, 0, 3],\n [-3, 1, 2, -3],\n [3, -2, 1, 0]])\nb = np.array([\n [-1.22],\n [2.58],\n [-1.96],\n [2.36],\n [-1.89]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 2 & 2 & 2 \\\\\n -2 & -1 & 2 \\\\\n 3 & 0 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 3 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 8 \\\\\n -9 \\\\\n 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, 2],\n [-2, -1, 2],\n [3, 0, -3]])\nb = np.array([\n [2],\n [3],\n [-1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{3} & -\\frac{8}{3} \\\\\n -5 & -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{155}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3), -(8/3)],\n [-5, -(7/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & 8 \\\\\n 9 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-121$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 8],\n [9, -7]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -3 \\\\\n 8 \\\\\n -7 \\\\\n -7 \\\\\n 9 \\\\\n 7 \\\\\n 3 \\\\\n 6 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -9 \\\\\n -3 \\\\\n 7 \\\\\n 4 \\\\\n -3 \\\\\n -7 \\\\\n -1 \\\\\n 3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{231}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-3],\n [8],\n [-7],\n [-7],\n [9],\n [7],\n [3],\n [6],\n [8]])\nb = np.array([\n [0],\n [-9],\n [-3],\n [7],\n [4],\n [-3],\n [-7],\n [-1],\n [3],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n \\frac{13}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{22}{5} \\\\\n \\frac{6}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{18}{5} \\\\\n \\frac{19}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [(13/5)]])\nb = np.array([\n [(22/5)],\n [(6/5)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{45}{16} \\\\\n \\frac{21}{4} \\\\\n \\frac{73}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{8} \\\\\n \\frac{23}{16} \\\\\n \\frac{39}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{4873}{128} \\\\\n -\\frac{121}{2} \\\\\n \\frac{5907}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(45/16)],\n [(21/4)],\n [(73/8)]])\nb = np.array([\n [-(29/8)],\n [(23/16)],\n [(39/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n \\frac{28}{3} & \\frac{5}{3} & 9 & \\frac{16}{3} \\\\\n 1 & 2 & \\frac{23}{3} & -\\frac{20}{3} \\\\\n -\\frac{1}{3} & -\\frac{29}{3} & \\frac{1}{3} & -\\frac{26}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(28/3), (5/3), 9, (16/3)],\n [1, 2, (23/3), -(20/3)],\n [-(1/3), -(29/3), (1/3), -(26/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{25}{3} & \\frac{14}{3} & -\\frac{23}{3} \\\\\n -\\frac{10}{3} & \\frac{16}{3} & \\frac{17}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{11}{3} & 6 & -\\frac{14}{3} \\\\\n -4 & -8 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -12 & -\\frac{4}{3} & -3 \\\\\n \\frac{2}{3} & \\frac{40}{3} & \\frac{5}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/3), (14/3), -(23/3)],\n [-(10/3), (16/3), (17/3)]])\nb = np.array([\n [(11/3), 6, -(14/3)],\n [-4, -8, 4]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{5} & -\\frac{3}{5} & \\frac{14}{5} \\\\\n 3 & -2 & \\frac{4}{5} \\\\\n 1 & 3 & \\frac{22}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{14}{45} & \\frac{23}{75} & \\frac{32}{225} \\\\\n -\\frac{31}{90} & -\\frac{4}{75} & \\frac{103}{450} \\\\\n \\frac{11}{36} & -\\frac{1}{30} & \\frac{7}{180} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/5), -(3/5), (14/5)],\n [3, -2, (4/5)],\n [1, 3, (22/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 6 & 9 \\\\\n -1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, 9],\n [-1, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{5} \\\\\n \\frac{4}{5} \\\\\n -\\frac{2}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{13}{3 \\sqrt{21}} \\\\\n \\frac{4}{3 \\sqrt{21}} \\\\\n -\\frac{2}{3 \\sqrt{21}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/5)],\n [(4/5)],\n [-(2/5)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -5 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 9 \\\\\n 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 57 \\\\\n -15 \\\\\n -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-5],\n [-8]])\nb = np.array([\n [3],\n [9],\n [3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -8 & -\\frac{5}{2} & 3 & -7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n \\frac{5}{2} & \\frac{9}{4} & \\frac{7}{2} & \\frac{27}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{21}{2} & -\\frac{19}{4} & -\\frac{1}{2} & -\\frac{55}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -(5/2), 3, -7]])\nb = np.array([\n [(5/2), (9/4), (7/2), (27/4)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 2 & \\frac{19}{5} \\\\\n -\\frac{17}{5} & -\\frac{21}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{105}{113} & -\\frac{95}{113} \\\\\n \\frac{85}{113} & \\frac{50}{113} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, (19/5)],\n [-(17/5), -(21/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2 & -\\frac{1}{2} & -3 \\\\\n -2 & -3 & -1 \\\\\n -\\frac{5}{2} & \\frac{3}{2} & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{25}{2} & -2 & \\frac{19}{2} \\\\\n \\frac{25}{2} & \\frac{17}{2} & 10 \\\\\n \\frac{9}{2} & -\\frac{19}{4} & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -(1/2), -3],\n [-2, -3, -1],\n [-(5/2), (3/2), -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n -71 & 57 & -106 & 68 \\\\\n 23 & -18 & 33 & -21 \\\\\n 111 & -90 & 166 & -106 \\\\\n 80 & -66 & 121 & -77 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -57 & \\frac{93}{2} & -\\frac{173}{2} & \\frac{111}{2} \\\\\n -\\frac{1}{3} & \\frac{3}{2} & -\\frac{3}{2} & \\frac{7}{6} \\\\\n \\frac{243}{2} & -99 & \\frac{367}{2} & -\\frac{233}{2} \\\\\n \\frac{259}{2} & -\\frac{213}{2} & 196 & -124 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [-71, 57, -106, 68],\n [23, -18, 33, -21],\n [111, -90, 166, -106],\n [80, -66, 121, -77]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 1 & 4 & -2 & -10 & 10 \\\\\n -4 & 9 & 10 & -3 & -7 \\\\\n 1 & -7 & 7 & -6 & 4 \\\\\n -4 & 3 & -3 & 5 & -2 \\\\\n -2 & 10 & 1 & 7 & -5 \\\\\n -8 & 7 & 3 & 3 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, 4, -2, -10, 10],\n [-4, 9, 10, -3, -7],\n [1, -7, 7, -6, 4],\n [-4, 3, -3, 5, -2],\n [-2, 10, 1, 7, -5],\n [-8, 7, 3, 3, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 3+3 i & -2-2 i & 1+i \\\\\n -2-i & -2+4 i & -3-5 i \\\\\n -2-3 i & -5-i & -4+i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 3+19 i & 8-22 i & -9+19 i \\\\\n -4+4 i & 18 i & 42+12 i \\\\\n 23+2 i & 33-9 i & 26+15 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3+3j, -2-2j, 1+ 1j],\n [-2- 1j, -2+4j, -3-5j],\n [-2-3j, -5- 1j, -4+ 1j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,3,2\\}, \\{1,2,1\\}, \\{-2,-1,-2\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{2}{\\sqrt{17}},\\frac{3}{\\sqrt{17}},\\frac{2}{\\sqrt{17}}\\right\\}, \\left\\{\\frac{29}{\\sqrt{1122}},8 \\sqrt{\\frac{2}{561}},\\frac{5}{\\sqrt{1122}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{66}},2 \\sqrt{\\frac{2}{33}},-\\frac{7}{\\sqrt{66}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, 3, 2), (1, 2, 1), (-2, -1, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{2,-4,-3\\}, \\{2,-2,-4\\}, \\{2,2,2\\}}$.", - "Output Answer": [ - "$x-2=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, -4, -3],\n [2, -2, -4],\n [2, 2, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & 5 \\\\\n 9 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-7 x-45$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 5],\n [9, 0]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{39}{8} & \\frac{13}{8} \\\\\n -\\frac{3}{4} & -\\frac{25}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{200}{1053} & -\\frac{8}{81} \\\\\n \\frac{16}{351} & -\\frac{8}{27} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(39/8), (13/8)],\n [-(3/4), -(25/8)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{14}{3}, -2, \\frac{5}{3}}$ to the plane $\\frac{14 x}{3}-\\frac{y}{3}-\\frac{z}{3}-\\frac{2}{3}=0$.", - "Output Answer": [ - "$\\frac{67}{3 \\sqrt{22}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(14/3), -2, (5/3)\nplane = Poly(((14*x)/3)-(y/3)-(z/3)-(2/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{33}{5} & \\frac{48}{5} \\\\\n \\frac{28}{5} & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(43-\\sqrt{5905}\\right),\\frac{1}{10} \\left(43+\\sqrt{5905}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(33/5), (48/5)],\n [(28/5), 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 4 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -1 \\\\\n 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 36 \\\\\n -35 \\\\\n 31 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [4],\n [8]])\nb = np.array([\n [-7],\n [-1],\n [7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{16} & \\frac{39}{16} & \\frac{33}{8} \\\\\n \\frac{61}{16} & -\\frac{23}{16} & -\\frac{55}{16} \\\\\n \\frac{69}{16} & -\\frac{29}{16} & -\\frac{35}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{20}{559} & \\frac{1088}{559} & -\\frac{836}{559} \\\\\n \\frac{1900}{1677} & -\\frac{21856}{1677} & \\frac{18964}{1677} \\\\\n -\\frac{56}{129} & \\frac{944}{129} & -\\frac{824}{129} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/16), (39/16), (33/8)],\n [(61/16), -(23/16), -(55/16)],\n [(69/16), -(29/16), -(35/8)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{2} \\\\\n -2 \\\\\n 8 \\\\\n 4 \\\\\n -\\frac{11}{4} \\\\\n -\\frac{27}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{11}{4} \\\\\n -\\frac{9}{2} \\\\\n -\\frac{37}{4} \\\\\n \\frac{3}{2} \\\\\n -\\frac{17}{4} \\\\\n \\frac{17}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{1961}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/2)],\n [-2],\n [8],\n [4],\n [-(11/4)],\n [-(27/4)]])\nb = np.array([\n [(11/4)],\n [-(9/2)],\n [-(37/4)],\n [(3/2)],\n [-(17/4)],\n [(17/2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -3 & 4 \\\\\n \\frac{11}{5} & \\frac{1}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{47} & \\frac{20}{47} \\\\\n \\frac{11}{47} & \\frac{15}{47} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 4],\n [(11/5), (1/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 10 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 8 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -70 \\\\\n 0 \\\\\n -50 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [10],\n [0]])\nb = np.array([\n [5],\n [8],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 3 & -10 \\\\\n 10 & -3 \\\\\n -6 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, -10],\n [10, -3],\n [-6, 9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 4 \\\\\n 7 \\\\\n -2 \\\\\n -6 \\\\\n 0 \\\\\n 9 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [4],\n [7],\n [-2],\n [-6],\n [0],\n [9],\n [-7]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 3 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -3 \\\\\n 1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{14}{15},\\frac{14}{5},-\\frac{14}{15},-\\frac{28}{15}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [3],\n [-1],\n [-1]]).squeeze()\nb = np.array([\n [1],\n [-3],\n [1],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 26 \\\\\n 90 \\\\\n -50 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-4],\n [-2]])\nb = np.array([\n [-5],\n [-3],\n [-8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-5, -\\frac{10}{3}}$ to the line $3 x-5 y+\\frac{1}{3}=0$.", - "Output Answer": [ - "$\\sqrt{\\frac{2}{17}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -5, -(10/3)\nline = Poly(3*x-5*y+(1/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -4 & -2 & 6 \\\\\n -7 & -7 & -7 \\\\\n 2 & -6 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.893,0.235,1.\\}, \\{-0.658,0.532,1.\\}, \\{1.143,-1.402,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -2, 6],\n [-7, -7, -7],\n [2, -6, -7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 3 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -6 & 0 \\\\\n -9 & 0 \\\\\n 6 & 0 \\\\\n -3 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [3],\n [-2],\n [1]])\nb = np.array([\n [-3, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 1 & -3 & -10 \\\\\n -1 & 8 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & -19 \\\\\n 0 & 1 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, -3, -10],\n [-1, 8, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,-2,-2\\}, \\{1,1,0\\}, \\{2,3,0\\}}$.", - "Output Answer": [ - "$4 x-2 y+3 z-2=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -2, -2],\n [1, 1, 0],\n [2, 3, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & 0 \\\\\n 8 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+3 x-28$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 0],\n [8, -7]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & -10 \\\\\n 8 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{16} i \\left(\\sqrt{319}-i\\right),1\\right\\}, \\left\\{-\\frac{1}{16} i \\left(\\sqrt{319}+i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -10],\n [8, 1]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -6 \\\\\n 5 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-6],\n [5],\n [-9]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & -6 \\\\\n -6 & 7 & -8 \\\\\n 7 & 6 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+15 x^2-147 x+621$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, -6],\n [-6, 7, -8],\n [7, 6, 7]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{3} & \\frac{20}{3} \\\\\n -\\frac{1}{3} & -\\frac{13}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-3-\\frac{2 i}{3},-3+\\frac{2 i}{3}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/3), (20/3)],\n [-(1/3), -(13/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & 1 & -2 & -3 \\\\\n 3 & 2 & -1 & 3 \\\\\n 1 & 0 & 1 & -3 \\\\\n 0 & 2 & 0 & -2 \\\\\n -1 & -2 & 0 & -2 \\\\\n 3 & 0 & -2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.33 \\\\\n -2.05 \\\\\n 1.25 \\\\\n 2.46 \\\\\n -1.5 \\\\\n -1.73 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.792 \\\\\n 1.159 \\\\\n 0.309 \\\\\n -0.449 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, -2, -3],\n [3, 2, -1, 3],\n [1, 0, 1, -3],\n [0, 2, 0, -2],\n [-1, -2, 0, -2],\n [3, 0, -2, -3]])\nb = np.array([\n [2.33],\n [-2.05],\n [1.25],\n [2.46],\n [-1.5],\n [-1.73]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 e \\\\\n -2 e \\\\\n -3 e \\\\\n -2 e \\\\\n -3 e \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -3 e \\\\\n -2 e \\\\\n e \\\\\n 3 e \\\\\n 3 e \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$e^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [2*math.e],\n [-2*math.e],\n [-3*math.e],\n [-2*math.e],\n [-3*math.e],\n [0]])\nb = np.array([\n [0],\n [-3*math.e],\n [-2*math.e],\n [math.e],\n [3*math.e],\n [3*math.e]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 1 & 1 \\\\\n 1 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{5}{6} & \\frac{1}{6} \\\\\n \\frac{1}{6} & -\\frac{1}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1],\n [1, -5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -9 & -2 & 1 & -9 \\\\\n 0 & -7 & 6 & -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -6 & -9 & -1 & 2 \\\\\n 9 & -5 & 4 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -15 & -11 & 0 & -7 \\\\\n 9 & -12 & 10 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -2, 1, -9],\n [0, -7, 6, -5]])\nb = np.array([\n [-6, -9, -1, 2],\n [9, -5, 4, 0]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & 1 \\\\\n 0 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-5 x-14$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 1],\n [0, 7]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n 3 & -4 & -8 \\\\\n 2 & 3 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -4, -8],\n [2, 3, -9]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & 1 & -2 \\\\\n -4 & 2 & -1 \\\\\n 4 & 4 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{10} & -\\frac{3}{20} & \\frac{1}{20} \\\\\n 0 & \\frac{1}{6} & \\frac{1}{6} \\\\\n -\\frac{2}{5} & -\\frac{1}{15} & \\frac{2}{15} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, -2],\n [-4, 2, -1],\n [4, 4, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n \\frac{4}{3} \\\\\n \\frac{4}{3} \\\\\n \\frac{7}{3} \\\\\n \\frac{2}{3} \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{9}{\\sqrt{247}} \\\\\n \\frac{4}{\\sqrt{247}} \\\\\n \\frac{4}{\\sqrt{247}} \\\\\n \\frac{7}{\\sqrt{247}} \\\\\n \\frac{2}{\\sqrt{247}} \\\\\n \\frac{9}{\\sqrt{247}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [(4/3)],\n [(4/3)],\n [(7/3)],\n [(2/3)],\n [3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{21}{4} \\\\\n -\\frac{35}{8} \\\\\n \\frac{19}{2} \\\\\n -\\frac{33}{4} \\\\\n \\frac{25}{4} \\\\\n -\\frac{63}{8} \\\\\n 8 \\\\\n -\\frac{25}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{19}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(21/4)],\n [-(35/8)],\n [(19/2)],\n [-(33/4)],\n [(25/4)],\n [-(63/8)],\n [8],\n [-(25/4)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{5}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1]])\nprint(a * -(3/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 1 & 2 \\\\\n 3 & \\frac{1}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 7 & 3 \\\\\n \\frac{9}{2} & \\frac{25}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2],\n [3, (1/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -6 \\\\\n 8 \\\\\n 3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 10 \\\\\n -10 \\\\\n -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -4 \\\\\n -16 \\\\\n 18 \\\\\n 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-6],\n [8],\n [3]])\nb = np.array([\n [8],\n [10],\n [-10],\n [-3]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -3 & -1 & 1 \\\\\n -1 & 3 & 3 \\\\\n -2 & -1 & 2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -15 & -7 & -3 \\\\\n -17 & 13 & 43 \\\\\n -4 & -11 & -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1, 1],\n [-1, 3, 3],\n [-2, -1, 2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 8 & -8 & 3 & -8 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-3.,0.,8.,0.,0.\\}, \\{1.,0.,0.,1.,0.\\}, \\{1.,1.,0.,0.,0.\\}, \\{5.,0.,0.,0.,8.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [8, -8, 3, -8, -5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -\\frac{18}{5} \\\\\n \\frac{21}{5} \\\\\n \\frac{37}{5} \\\\\n \\frac{19}{5} \\\\\n \\frac{41}{5} \\\\\n \\frac{49}{5} \\\\\n -\\frac{33}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{248}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-(18/5)],\n [(21/5)],\n [(37/5)],\n [(19/5)],\n [(41/5)],\n [(49/5)],\n [-(33/5)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 1 & 3 & 2 & 1 & -1 \\\\\n 0 & -3 & -2 & -2 & -2 \\\\\n 2 & -1 & -2 & 2 & 2 \\\\\n 0 & 1 & -1 & -1 & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -3 & -3 & 3 & -2 & -2 \\\\\n 2 & 0 & 2 & 1 & -2 \\\\\n 3 & -1 & 2 & 2 & 2 \\\\\n -3 & -1 & -1 & -3 & -1 \\\\\n -2 & 0 & 1 & 0 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 8 & -6 & 11 & 2 & -3 \\\\\n -2 & 4 & -10 & -1 & 8 \\\\\n -24 & -6 & 0 & -15 & -12 \\\\\n -4 & 2 & 4 & 2 & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3, 2, 1, -1],\n [0, -3, -2, -2, -2],\n [2, -1, -2, 2, 2],\n [0, 1, -1, -1, 3]])\nb = np.array([\n [-3, -3, 3, -2, -2],\n [2, 0, 2, 1, -2],\n [3, -1, 2, 2, 2],\n [-3, -1, -1, -3, -1],\n [-2, 0, 1, 0, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & 1 & 3 \\\\\n -4 & -4 & 1 \\\\\n 0 & -1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{15}{2} & \\frac{7}{2} & -\\frac{13}{2} \\\\\n -8 & -4 & 7 \\\\\n -2 & -1 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, 3],\n [-4, -4, 1],\n [0, -1, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -9 \\\\\n 10 \\\\\n 6 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 5 \\\\\n 8 \\\\\n -7 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-54$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-9],\n [10],\n [6],\n [3]])\nb = np.array([\n [-4],\n [5],\n [8],\n [-7],\n [-5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{8}{5},\\frac{8}{5},-\\frac{4}{5}\\right\\}, \\left\\{-\\frac{4}{5},-\\frac{1}{5},-1\\right\\}, \\left\\{\\frac{6}{5},-\\frac{4}{5},-\\frac{6}{5}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{2}{3},\\frac{2}{3},-\\frac{1}{3}\\right\\}, \\left\\{-\\frac{26}{3 \\sqrt{353}},\\frac{1}{3 \\sqrt{353}},-\\frac{50}{3 \\sqrt{353}}\\right\\}, \\left\\{\\frac{11}{\\sqrt{353}},-\\frac{14}{\\sqrt{353}},-\\frac{6}{\\sqrt{353}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack((((8/5), (8/5), -(4/5)), (-(4/5), -(1/5), -1), ((6/5), -(4/5), -(6/5))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{50}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & 7 & 3 \\\\\n -7 & 8 & 5 \\\\\n -3 & -7 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{21}{50} & -\\frac{49}{50} & -\\frac{21}{50} \\\\\n \\frac{49}{50} & -\\frac{28}{25} & -\\frac{7}{10} \\\\\n \\frac{21}{50} & \\frac{49}{50} & \\frac{63}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 7, 3],\n [-7, 8, 5],\n [-3, -7, -9]])\nprint(a * -(7/50))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n \\frac{21}{5} & \\frac{36}{5} & -\\frac{23}{5} \\\\\n -\\frac{1}{5} & \\frac{11}{5} & \\frac{39}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(21/5), (36/5), -(23/5)],\n [-(1/5), (11/5), (39/5)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{27}{8} & -\\frac{151}{16} & -\\frac{37}{16} & -\\frac{25}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{101}{16} & -\\frac{15}{16} & \\frac{15}{16} & \\frac{109}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{47}{16} & -\\frac{17}{2} & -\\frac{13}{4} & -\\frac{159}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(27/8), -(151/16), -(37/16), -(25/8)]])\nb = np.array([\n [-(101/16), -(15/16), (15/16), (109/16)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n 8 & -3 & -5 & -5 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -3, -5, -5, 5]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{13}{2} & \\frac{29}{4} \\\\\n -\\frac{35}{4} & -\\frac{13}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{70} \\left(-39-i \\sqrt{2539}\\right),1\\right\\}, \\left\\{\\frac{1}{70} \\left(-39+i \\sqrt{2539}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2), (29/4)],\n [-(35/4), -(13/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & -8 & 2 \\\\\n 3 & -4 & -7 \\\\\n 0 & -2 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.35,0.994,1.\\}, \\{-8.758-3.572 i,-5.247-0.631 i,1.\\}, \\{-8.758+3.572 i,-5.247+0.631 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -8, 2],\n [3, -4, -7],\n [0, -2, -8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 4 & 1 \\\\\n 6 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 9 & -6 \\\\\n 6 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 13 & -5 \\\\\n 12 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 1],\n [6, 8]])\nb = np.array([\n [9, -6],\n [6, -4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{11}{3}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 5 & 10 & -7 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{55}{3} & -\\frac{110}{3} & \\frac{77}{3} & -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 10, -7, 1]])\nprint(a * -(11/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 0 & -2 \\\\\n 0 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & 0 \\\\\n -\\frac{2}{29} & -\\frac{5}{29} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2],\n [0, -5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [1],\n [-1],\n [0],\n [-1],\n [-1],\n [-1],\n [0]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [1],\n [1],\n [1],\n [0],\n [0],\n [0],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{28}{3} & -10 & 5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{20}{3} & -\\frac{25}{3} & \\frac{20}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{8}{3} & -\\frac{5}{3} & -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(28/3), -10, 5]])\nb = np.array([\n [-(20/3), -(25/3), (20/3)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{41}{6} & -\\frac{10}{3} & \\frac{37}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{2} & \\frac{19}{3} & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{28}{3} & 3 & \\frac{1}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(41/6), -(10/3), (37/6)]])\nb = np.array([\n [-(5/2), (19/3), -6]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{233}{50} \\\\\n \\frac{13}{100} \\\\\n \\frac{441}{50} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{297}{100} \\\\\n \\frac{36}{5} \\\\\n -\\frac{439}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{640747}{10000} \\\\\n -\\frac{29158}{625} \\\\\n -\\frac{331659}{10000} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(233/50)],\n [(13/100)],\n [(441/50)]])\nb = np.array([\n [-(297/100)],\n [(36/5)],\n [-(439/100)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -9 \\\\\n -6 \\\\\n 4 \\\\\n 5 \\\\\n 2 \\\\\n 3 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 6 \\\\\n 6 \\\\\n 7 \\\\\n 5 \\\\\n 6 \\\\\n -8 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-73$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-9],\n [-6],\n [4],\n [5],\n [2],\n [3],\n [-9]])\nb = np.array([\n [-5],\n [6],\n [6],\n [7],\n [5],\n [6],\n [-8],\n [6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -9 & -1 \\\\\n -9 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{18} \\left(1-\\sqrt{37}\\right),1\\right\\}, \\left\\{\\frac{1}{18} \\left(1+\\sqrt{37}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -1],\n [-9, -8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${1, -2}$ to the line $-4 x+3 y+1=0$.", - "Output Answer": [ - "$\\frac{9}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 1, -2\nline = Poly(-4*x+3*y+1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n \\frac{19}{9} & -\\frac{2}{3} & -\\frac{2}{3} & -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{9} \\\\\n \\frac{13}{9} \\\\\n -\\frac{14}{9} \\\\\n -\\frac{4}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{64}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/9), -(2/3), -(2/3), -(8/3)]])\nb = np.array([\n [-(2/9)],\n [(13/9)],\n [-(14/9)],\n [-(4/9)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 1 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{45}{7 \\sqrt{43}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [1],\n [2]]).squeeze()\nb = np.array([\n [-9],\n [1],\n [4]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 3 \\\\\n 1 \\\\\n 2 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n -2 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{7}{8},\\frac{7}{8},\\frac{7}{4},0,-\\frac{7}{8},-\\frac{7}{8}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [3],\n [1],\n [2],\n [-3],\n [2]]).squeeze()\nb = np.array([\n [1],\n [-1],\n [-2],\n [0],\n [1],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n \\frac{15}{2} & -\\frac{17}{6} & -\\frac{13}{6} & -\\frac{17}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/2), -(17/6), -(13/6), -(17/6)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\log (2) \\\\\n \\log (2) \\\\\n 14 \\log (2) \\\\\n -3 \\log (2) \\\\\n 11 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\log (2) \\\\\n 2 \\log (2) \\\\\n 0 \\\\\n 14 \\log (2) \\\\\n 7 \\log (2) \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-19 \\log ^2(2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-7*math.log(2)],\n [math.log(2)],\n [14*math.log(2)],\n [-3*math.log(2)],\n [11*math.log(2)]])\nb = np.array([\n [8*math.log(2)],\n [2*math.log(2)],\n [0],\n [14*math.log(2)],\n [7*math.log(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n -1 \\\\\n 3 \\\\\n -6 \\\\\n 9 \\\\\n 7 \\\\\n 8 \\\\\n 6 \\\\\n -3 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -2 \\\\\n -3 \\\\\n 4 \\\\\n 9 \\\\\n -2 \\\\\n 7 \\\\\n 2 \\\\\n -7 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{151}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [-1],\n [3],\n [-6],\n [9],\n [7],\n [8],\n [6],\n [-3],\n [5]])\nb = np.array([\n [7],\n [-2],\n [-3],\n [4],\n [9],\n [-2],\n [7],\n [2],\n [-7],\n [-3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 9 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{157}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [9],\n [8]])\nb = np.array([\n [-7],\n [-2],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{2} & -\\frac{1}{2} & -1 \\\\\n -2 & -2 & -1 \\\\\n -\\frac{5}{2} & 2 & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{23}{4} & -\\frac{7}{4} & 0 \\\\\n \\frac{7}{2} & 3 & 5 \\\\\n -\\frac{21}{4} & -\\frac{19}{4} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), -(1/2), -1],\n [-2, -2, -1],\n [-(5/2), 2, -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 5 & -6 & -8 & 8 & 5 \\\\\n 6 & 6 & -7 & 3 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-39.,-5.,0.,0.,33.\\}, \\{-2.,1.,0.,2.,0.\\}, \\{90.,-13.,66.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, -6, -8, 8, 5],\n [6, 6, -7, 3, 8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & -1 \\\\\n 2 & -2 \\\\\n 1 & 0 \\\\\n 1 & 2 \\\\\n -3 & 1 \\\\\n -1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.82 \\\\\n 2.19 \\\\\n 1.63 \\\\\n -1.52 \\\\\n -2.89 \\\\\n -0.2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.611 \\\\\n -0.475 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1],\n [2, -2],\n [1, 0],\n [1, 2],\n [-3, 1],\n [-1, 2]])\nb = np.array([\n [0.82],\n [2.19],\n [1.63],\n [-1.52],\n [-2.89],\n [-0.2]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n \\frac{13}{2} \\\\\n -1 \\\\\n -4 \\\\\n -4 \\\\\n -\\frac{35}{4} \\\\\n -\\frac{15}{2} \\\\\n -\\frac{15}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{89}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [(13/2)],\n [-1],\n [-4],\n [-4],\n [-(35/4)],\n [-(15/2)],\n [-(15/4)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [-1],\n [1],\n [1],\n [0],\n [0],\n [-1],\n [-1]]).squeeze()\nb = np.array([\n [0],\n [1],\n [1],\n [0],\n [-1],\n [1],\n [0],\n [-1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{11}{2} & -\\frac{15}{2} \\\\\n 10 & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+x+\\frac{201}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/2), -(15/2)],\n [10, (9/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{3}{\\sqrt{2}},-\\frac{3}{\\sqrt{2}},0\\right\\}, \\left\\{\\sqrt{2},0,\\frac{3}{\\sqrt{2}}\\right\\}, \\left\\{-2 \\sqrt{2},-\\frac{1}{\\sqrt{2}},\\sqrt{2}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{2}},-\\frac{1}{\\sqrt{2}},0\\right\\}, \\left\\{\\frac{\\sqrt{2}-\\frac{1}{\\sqrt{2}}}{\\sqrt{5+\\left(\\sqrt{2}-\\frac{1}{\\sqrt{2}}\\right)^2}},-\\frac{1}{\\sqrt{2 \\left(5+\\left(\\sqrt{2}-\\frac{1}{\\sqrt{2}}\\right)^2\\right)}},\\frac{3}{\\sqrt{2 \\left(5+\\left(\\sqrt{2}-\\frac{1}{\\sqrt{2}}\\right)^2\\right)}}\\right\\}, \\left\\{\\frac{\\frac{5}{2 \\sqrt{2}}-2 \\sqrt{2}-\\frac{\\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right) \\left(\\frac{7}{2}-2 \\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)\\right)}{5+\\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)^2}}{\\sqrt{\\left(\\sqrt{2}-\\frac{3 \\left(\\frac{7}{2}-2 \\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)\\right)}{\\sqrt{2} \\left(5+\\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)^2\\right)}\\right)^2+\\left(\\frac{3}{2 \\sqrt{2}}+\\frac{\\frac{7}{2}-2 \\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)}{\\sqrt{2} \\left(5+\\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)^2\\right)}\\right)^2+\\left(-\\frac{5}{2 \\sqrt{2}}+2 \\sqrt{2}-\\frac{\\left(\\frac{1}{\\sqrt{2}}-\\sqrt{2}\\right) \\left(\\frac{7}{2}-2 \\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)\\right)}{5+\\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)^2}\\right)^2}},\\frac{\\frac{3}{2 \\sqrt{2}}+\\frac{\\frac{7}{2}-2 \\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)}{\\sqrt{2} \\left(5+\\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)^2\\right)}}{\\sqrt{\\left(\\sqrt{2}-\\frac{3 \\left(\\frac{7}{2}-2 \\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)\\right)}{\\sqrt{2} \\left(5+\\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)^2\\right)}\\right)^2+\\left(\\frac{3}{2 \\sqrt{2}}+\\frac{\\frac{7}{2}-2 \\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)}{\\sqrt{2} \\left(5+\\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)^2\\right)}\\right)^2+\\left(-\\frac{5}{2 \\sqrt{2}}+2 \\sqrt{2}-\\frac{\\left(\\frac{1}{\\sqrt{2}}-\\sqrt{2}\\right) \\left(\\frac{7}{2}-2 \\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)\\right)}{5+\\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)^2}\\right)^2}},\\frac{\\sqrt{2}-\\frac{3 \\left(\\frac{7}{2}-2 \\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)\\right)}{\\sqrt{2} \\left(5+\\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)^2\\right)}}{\\sqrt{\\left(\\sqrt{2}-\\frac{3 \\left(\\frac{7}{2}-2 \\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)\\right)}{\\sqrt{2} \\left(5+\\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)^2\\right)}\\right)^2+\\left(\\frac{3}{2 \\sqrt{2}}+\\frac{\\frac{7}{2}-2 \\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)}{\\sqrt{2} \\left(5+\\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)^2\\right)}\\right)^2+\\left(-\\frac{5}{2 \\sqrt{2}}+2 \\sqrt{2}-\\frac{\\left(\\frac{1}{\\sqrt{2}}-\\sqrt{2}\\right) \\left(\\frac{7}{2}-2 \\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)\\right)}{5+\\left(-\\frac{1}{\\sqrt{2}}+\\sqrt{2}\\right)^2}\\right)^2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-(3/(math.sqrt(2))), -(3/(math.sqrt(2))), 0), (math.sqrt(2), 0, (3/(math.sqrt(2)))), (-2*math.sqrt(2), -(1/(math.sqrt(2))), math.sqrt(2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{3} & -\\frac{11}{6} \\\\\n \\frac{3}{2} & \\frac{13}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{161}{36}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/3), -(11/6)],\n [(3/2), (13/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & 0 & -1 \\\\\n 2 & -3 & 0 \\\\\n 2 & -2 & 2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & 2 & -3 \\\\\n -4 & 9 & -2 \\\\\n 2 & 2 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 0, -1],\n [2, -3, 0],\n [2, -2, 2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 3 & 0 & -6 \\\\\n -9 & 8 & -4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -10 & -3 & 6 \\\\\n -2 & 10 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 13 & 3 & -12 \\\\\n -7 & -2 & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 0, -6],\n [-9, 8, -4]])\nb = np.array([\n [-10, -3, 6],\n [-2, 10, 2]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -1 \\\\\n -8 \\\\\n -6 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -10 \\\\\n -8 \\\\\n -10 \\\\\n 3 \\\\\n -4 \\\\\n 0 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$175$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-1],\n [-8],\n [-6],\n [-1],\n [0],\n [0],\n [-6]])\nb = np.array([\n [1],\n [-10],\n [-8],\n [-10],\n [3],\n [-4],\n [0],\n [-7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -5 & 1 \\\\\n -4 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+14 x+49$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 1],\n [-4, -9]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -\\frac{21}{8} \\\\\n \\frac{7}{8} \\\\\n \\frac{25}{4} \\\\\n 9 \\\\\n 10 \\\\\n -\\frac{19}{2} \\\\\n \\frac{33}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{21695}}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-(21/8)],\n [(7/8)],\n [(25/4)],\n [9],\n [10],\n [-(19/2)],\n [(33/8)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 4-\\frac{3 i}{2} & \\frac{7}{2}+\\frac{7 i}{2} \\\\\n -2+i & \\frac{5}{2}-i \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{349}{4}-\\frac{507 i}{8} & \\frac{1267}{8}-\\frac{315 i}{8} \\\\\n -\\frac{23}{4}+\\frac{147 i}{2} & -\\frac{789}{8}-\\frac{25 i}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4-((3j)/2), (7/2)+((7j)/2)],\n [-2+ 1j, (5/2)- 1j]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & -1 & 3 & 2 \\\\\n 0 & -3 & -1 & 2 \\\\\n -1 & 1 & -3 & 3 \\\\\n 1 & 0 & 3 & -3 \\\\\n 0 & -1 & -1 & 2 \\\\\n 2 & -2 & 3 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.07 \\\\\n -0.46 \\\\\n 1.54 \\\\\n 0.33 \\\\\n -1.4 \\\\\n 1.02 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.232 \\\\\n 0.546 \\\\\n 0.329 \\\\\n 0.44 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, 3, 2],\n [0, -3, -1, 2],\n [-1, 1, -3, 3],\n [1, 0, 3, -3],\n [0, -1, -1, 2],\n [2, -2, 3, 1]])\nb = np.array([\n [1.07],\n [-0.46],\n [1.54],\n [0.33],\n [-1.4],\n [1.02]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{25}{4} & 8 & -4 \\\\\n -\\frac{27}{4} & -3 & \\frac{25}{4} \\\\\n \\frac{5}{2} & -\\frac{15}{4} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.88,0.895,1.\\}, \\{-1.955-0.517 i,-0.624+2.073 i,1.\\}, \\{-1.955+0.517 i,-0.624-2.073 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/4), 8, -4],\n [-(27/4), -3, (25/4)],\n [(5/2), -(15/4), -(3/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 8 \\\\\n -3 \\\\\n -7 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6 \\sqrt{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [8],\n [-3],\n [-7],\n [-7]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & 5 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-5.,2.,0.\\}, \\{1.,0.,2.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, 5, -1]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -7 & 7 & 7 \\\\\n 10 & -9 & 6 \\\\\n 1 & 8 & 8 \\\\\n 5 & 7 & -8 \\\\\n -5 & -9 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, 7, 7],\n [10, -9, 6],\n [1, 8, 8],\n [5, 7, -8],\n [-5, -9, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0.261 \\\\\n 3.101 \\\\\n 8.896 \\\\\n -9.614 \\\\\n 2.512 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6.593 \\\\\n -2.702 \\\\\n 2.398 \\\\\n 1.989 \\\\\n 4.547 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$16.1755$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0.261],\n [3.101],\n [8.896],\n [-9.614],\n [2.512]])\nb = np.array([\n [-6.593],\n [-2.702],\n [2.398],\n [1.989],\n [4.547]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\sqrt{5} \\\\\n 3 \\sqrt{5} \\\\\n -2 \\sqrt{5} \\\\\n -\\sqrt{5} \\\\\n -\\sqrt{5} \\\\\n -2 \\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n -\\sqrt{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\sqrt{5} \\\\\n -4 \\sqrt{5} \\\\\n 3 \\sqrt{5} \\\\\n -2 \\sqrt{5} \\\\\n 0 \\\\\n -4 \\sqrt{5} \\\\\n \\sqrt{5} \\\\\n \\sqrt{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{470}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [4*math.sqrt(5)],\n [3*math.sqrt(5)],\n [-2*math.sqrt(5)],\n [-math.sqrt(5)],\n [-math.sqrt(5)],\n [-2*math.sqrt(5)],\n [4*math.sqrt(5)],\n [-math.sqrt(5)]])\nb = np.array([\n [3*math.sqrt(5)],\n [-4*math.sqrt(5)],\n [3*math.sqrt(5)],\n [-2*math.sqrt(5)],\n [0],\n [-4*math.sqrt(5)],\n [math.sqrt(5)],\n [math.sqrt(5)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 7 & 6 & -4 & -8 \\\\\n -10 & -8 & 1 & 9 \\\\\n -4 & 1 & -8 & 10 \\\\\n 7 & 3 & -10 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, 6, -4, -8],\n [-10, -8, 1, 9],\n [-4, 1, -8, 10],\n [7, 3, -10, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{3} \\\\\n -1 \\\\\n -\\frac{2}{3} \\\\\n \\frac{8}{3} \\\\\n -\\frac{4}{3} \\\\\n \\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{95}} \\\\\n -\\frac{3}{\\sqrt{95}} \\\\\n -\\frac{2}{\\sqrt{95}} \\\\\n \\frac{8}{\\sqrt{95}} \\\\\n -\\frac{4}{\\sqrt{95}} \\\\\n \\frac{1}{\\sqrt{95}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/3)],\n [-1],\n [-(2/3)],\n [(8/3)],\n [-(4/3)],\n [(1/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -\\frac{14}{3} & \\frac{17}{3} & -\\frac{15}{2} & -\\frac{59}{6} \\\\\n 8 & -\\frac{19}{6} & -\\frac{29}{6} & \\frac{19}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(14/3), (17/3), -(15/2), -(59/6)],\n [8, -(19/6), -(29/6), (19/2)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & 2 & 3 \\\\\n 1 & -3 & 0 \\\\\n 2 & \\frac{5}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 9 & \\frac{7}{2} & \\frac{3}{2} \\\\\n -2 & 11 & 3 \\\\\n \\frac{7}{2} & -\\frac{19}{4} & \\frac{25}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, 3],\n [1, -3, 0],\n [2, (5/2), -(1/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & -1 \\\\\n -1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1],\n [-1, -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{14}{3}, \\frac{1}{3}, -\\frac{14}{3}}$ to the plane $-4 x+4 y-\\frac{14 z}{3}-\\frac{8}{3}=0$.", - "Output Answer": [ - "$\\frac{8}{33}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (14/3), (1/3), -(14/3)\nplane = Poly(-4*x+4*y-((14*z)/3)-(8/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & 0 \\\\\n 0 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-x-6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0],\n [0, 3]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & 2 \\\\\n -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{1,2\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2],\n [-1, 3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,0,0\\}, \\{-1,2,1\\}, \\{-1,-1,-2\\}}$", - "Output Answer": [ - "${\\{0,0,0\\}, \\left\\{-\\frac{1}{\\sqrt{6}},\\sqrt{\\frac{2}{3}},\\frac{1}{\\sqrt{6}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{2}},0,-\\frac{1}{\\sqrt{2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, 0, 0), (-1, 2, 1), (-1, -1, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{25}{9} \\\\\n -\\frac{7}{3} \\\\\n \\frac{17}{9} \\\\\n -\\frac{35}{9} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -\\frac{4}{3} \\\\\n -\\frac{28}{3} \\\\\n -\\frac{4}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{29}{9} \\\\\n -1 \\\\\n \\frac{101}{9} \\\\\n -\\frac{23}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/9)],\n [-(7/3)],\n [(17/9)],\n [-(35/9)]])\nb = np.array([\n [-6],\n [-(4/3)],\n [-(28/3)],\n [-(4/3)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{16}{5} & -\\frac{26}{5} & -\\frac{48}{5} \\\\\n \\frac{42}{5} & -\\frac{14}{5} & -\\frac{23}{5} \\\\\n 9 & -\\frac{28}{5} & -\\frac{4}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{2 x^2}{5}-\\frac{2376 x}{25}+\\frac{39342}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(16/5), -(26/5), -(48/5)],\n [(42/5), -(14/5), -(23/5)],\n [9, -(28/5), -(4/5)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -5 & -1 & -8 & -8 \\\\\n -7 & 8 & 2 & 0 \\\\\n -5 & 7 & 2 & 6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 8 & 6 & -9 & 7 \\\\\n -10 & 5 & 6 & 1 \\\\\n 7 & -10 & 10 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -13 & -7 & 1 & -15 \\\\\n 3 & 3 & -4 & -1 \\\\\n -12 & 17 & -8 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -1, -8, -8],\n [-7, 8, 2, 0],\n [-5, 7, 2, 6]])\nb = np.array([\n [8, 6, -9, 7],\n [-10, 5, 6, 1],\n [7, -10, 10, 4]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -4 & 4 \\\\\n 0 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$16$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 4],\n [0, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{3}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & 10 \\\\\n -5 & 2 \\\\\n 8 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{4}{3} & -\\frac{10}{3} \\\\\n \\frac{5}{3} & -\\frac{2}{3} \\\\\n -\\frac{8}{3} & \\frac{4}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 10],\n [-5, 2],\n [8, -4]])\nprint(a * -(1/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-1, 0}$ to the line $-x-y+3=0$.", - "Output Answer": [ - "$2 \\sqrt{2}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -1, 0\nline = Poly(-x-y+3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 4 & 2 & -4 & 8 & 5 \\\\\n 9 & 3 & 7 & 3 & 4 \\\\\n 9 & -8 & 9 & -10 & 6 \\\\\n -4 & 9 & 9 & -8 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-13535.,-13165.,14197.,14081.,4922.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, 2, -4, 8, 5],\n [9, 3, 7, 3, 4],\n [9, -8, 9, -10, 6],\n [-4, 9, 9, -8, 10]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 1 & -1 \\\\\n -1 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & -\\frac{11}{4} \\\\\n -\\frac{11}{4} & -\\frac{43}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1],\n [-1, -(3/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 8 & 9 & -6 & -9 \\\\\n -3 & -1 & 0 & -6 \\\\\n -6 & -5 & -3 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-417.,585.,155.,111.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [8, 9, -6, -9],\n [-3, -1, 0, -6],\n [-6, -5, -3, 8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,-1,2\\}, \\{-5,3,-3\\}, \\{4,0,3\\}}$.", - "Output Answer": [ - "$x-3 (y+z)+5=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, -1, 2],\n [-5, 3, -3],\n [4, 0, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -2 & 2 & 0 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 4 & -4 & 0 & 4 \\\\\n -6 & 6 & 0 & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [3]])\nb = np.array([\n [-2, 2, 0, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 2 & -3 \\\\\n 1 & -2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3],\n [1, -2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{39}{5} \\\\\n -\\frac{44}{5} \\\\\n -\\frac{17}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{44}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(39/5)],\n [-(44/5)],\n [-(17/10)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{14}{5} & -\\frac{19}{5} & -\\frac{36}{5} \\\\\n -\\frac{17}{5} & -\\frac{38}{5} & -\\frac{18}{5} \\\\\n \\frac{27}{5} & -\\frac{46}{5} & -\\frac{8}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{32 x^2}{5}+\\frac{519 x}{25}-\\frac{60606}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/5), -(19/5), -(36/5)],\n [-(17/5), -(38/5), -(18/5)],\n [(27/5), -(46/5), -(8/5)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & -2 \\\\\n -1 & 0 \\\\\n -1 & 3 \\\\\n -1 & 0 \\\\\n 0 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.83 \\\\\n -1.46 \\\\\n -0.09 \\\\\n 2.23 \\\\\n 0.21 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.484 \\\\\n -0.121 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2],\n [-1, 0],\n [-1, 3],\n [-1, 0],\n [0, 2]])\nb = np.array([\n [1.83],\n [-1.46],\n [-0.09],\n [2.23],\n [0.21]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -5 & -10 & -3 & 6 & -1 \\\\\n -4 & 2 & -10 & -6 & -8 \\\\\n 7 & -6 & 3 & -8 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-73.,37.,-29.,0.,82.\\}, \\{73.,4.,-53.,41.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, -10, -3, 6, -1],\n [-4, 2, -10, -6, -8],\n [7, -6, 3, -8, 10]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{1,2,-1\\}, \\{0,2,-2\\}, \\{3,-1,1\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{6}},\\sqrt{\\frac{2}{3}},-\\frac{1}{\\sqrt{6}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{2}},0,-\\frac{1}{\\sqrt{2}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((1, 2, -1), (0, 2, -2), (3, -1, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -3 & 0 & -2 \\\\\n 0 & -3 & -2 \\\\\n -1 & 1 & 0 \\\\\n 0 & -3 & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & -3 & 0 & 3 \\\\\n -2 & 1 & 2 & 2 \\\\\n 1 & 3 & -2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -8 & 3 & 4 & -11 \\\\\n 4 & -9 & -2 & -8 \\\\\n -4 & 4 & 2 & -1 \\\\\n 9 & 6 & -12 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, -2],\n [0, -3, -2],\n [-1, 1, 0],\n [0, -3, 3]])\nb = np.array([\n [2, -3, 0, 3],\n [-2, 1, 2, 2],\n [1, 3, -2, 1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & 3 \\\\\n 0 & 2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{8} & \\frac{63}{4} \\\\\n 0 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), 3],\n [0, 2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{3,1,-2\\}, \\{1,-1,-3\\}, \\{-2,1,-2\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{3}{\\sqrt{14}},\\frac{1}{\\sqrt{14}},-\\sqrt{\\frac{2}{7}}\\right\\}, \\left\\{-\\frac{\\sqrt{\\frac{5}{7}}}{3},-\\frac{11}{3 \\sqrt{35}},-\\frac{13}{3 \\sqrt{35}}\\right\\}, \\left\\{-\\frac{\\sqrt{\\frac{5}{2}}}{3},\\frac{7}{3 \\sqrt{10}},-\\frac{2 \\sqrt{\\frac{2}{5}}}{3}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((3, 1, -2), (1, -1, -3), (-2, 1, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{3} \\\\\n \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2}{\\sqrt{13}} \\\\\n \\frac{3}{\\sqrt{13}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/3)],\n [(5/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [1],\n [-1],\n [-1],\n [-1],\n [0],\n [0]]).squeeze()\nb = np.array([\n [0],\n [1],\n [1],\n [1],\n [0],\n [0],\n [0],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -3 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -1 & -1 & 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 3 & 3 & 0 & -6 \\\\\n 3 & 3 & 0 & -6 \\\\\n -3 & -3 & 0 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-3],\n [3]])\nb = np.array([\n [-1, -1, 0, 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -3 \\\\\n 7 \\\\\n 8 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-3],\n [7],\n [8],\n [-2]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 2 & -9 \\\\\n 9 & -6 \\\\\n 0 & -9 \\\\\n 8 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, -9],\n [9, -6],\n [0, -9],\n [8, 9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 0 & 2 & -1 \\\\\n 6 & -10 & 2 \\\\\n -7 & -4 & 6 \\\\\n 5 & -1 & -1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -3 & -6 & -1 \\\\\n 1 & -6 & 10 \\\\\n -6 & 9 & -3 \\\\\n 3 & 1 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 3 & 8 & 0 \\\\\n 5 & -4 & -8 \\\\\n -1 & -13 & 9 \\\\\n 2 & -2 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, -1],\n [6, -10, 2],\n [-7, -4, 6],\n [5, -1, -1]])\nb = np.array([\n [-3, -6, -1],\n [1, -6, 10],\n [-6, 9, -3],\n [3, 1, -1]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-1, \\frac{10}{3}, \\frac{7}{3}}$ to the plane $\\frac{14 x}{3}+2 y-\\frac{10 z}{3}+\\frac{1}{3}=0$.", - "Output Answer": [ - "$\\frac{49}{6 \\sqrt{83}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -1, (10/3), (7/3)\nplane = Poly(((14*x)/3)+2*y-((10*z)/3)+(1/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -3 & 2 & -\\frac{19}{4} \\\\\n -\\frac{7}{2} & \\frac{15}{4} & -\\frac{17}{2} \\\\\n -\\frac{13}{4} & -5 & -\\frac{9}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{3 x^2}{2}+\\frac{511 x}{8}+\\frac{3283}{64}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2, -(19/4)],\n [-(7/2), (15/4), -(17/2)],\n [-(13/4), -5, -(9/4)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, 0, -\\frac{1}{2}}$ to the plane $-x+\\frac{y}{2}-4 z+4=0$.", - "Output Answer": [ - "$2 \\sqrt{\\frac{3}{23}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, 0, -(1/2)\nplane = Poly(-x+(y/2)-4*z+4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{6}{5}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -4 & -2 & 3 & -6 \\\\\n -10 & 3 & -4 & -5 \\\\\n -5 & 3 & 1 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{24}{5} & -\\frac{12}{5} & \\frac{18}{5} & -\\frac{36}{5} \\\\\n -12 & \\frac{18}{5} & -\\frac{24}{5} & -6 \\\\\n -6 & \\frac{18}{5} & \\frac{6}{5} & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -2, 3, -6],\n [-10, 3, -4, -5],\n [-5, 3, 1, 5]])\nprint(a * (6/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & 1 & 3 & 2 & 2 \\\\\n -3 & 2 & 2 & 1 & -3 \\\\\n 1 & -1 & -2 & -3 & 2 \\\\\n -1 & -1 & -1 & -1 & 2 \\\\\n -3 & 2 & -1 & 2 & 1 \\\\\n 0 & -3 & -2 & 0 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.02 \\\\\n 2.14 \\\\\n -1.45 \\\\\n -1.52 \\\\\n -0.64 \\\\\n -2.12 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.095 \\\\\n 0.314 \\\\\n 0.713 \\\\\n -0.09 \\\\\n -0.138 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, 3, 2, 2],\n [-3, 2, 2, 1, -3],\n [1, -1, -2, -3, 2],\n [-1, -1, -1, -1, 2],\n [-3, 2, -1, 2, 1],\n [0, -3, -2, 0, -1]])\nb = np.array([\n [2.02],\n [2.14],\n [-1.45],\n [-1.52],\n [-0.64],\n [-2.12]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 3 \\\\\n 6 \\\\\n 9 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 2 \\\\\n 2 \\\\\n 8 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$66$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [3],\n [6],\n [9],\n [-4]])\nb = np.array([\n [-4],\n [2],\n [2],\n [8],\n [3]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{19}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{47}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{28}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/5)]])\nb = np.array([\n [-(47/5)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{28}{5} & -\\frac{39}{5} & \\frac{38}{5} \\\\\n \\frac{31}{5} & 3 & -\\frac{1}{5} \\\\\n \\frac{29}{5} & -\\frac{12}{5} & \\frac{13}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.395,0.63,1.\\}, \\{1.103\\, -0.486 i,1.164\\, +0.66 i,1.\\}, \\{1.103\\, +0.486 i,1.164\\, -0.66 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(28/5), -(39/5), (38/5)],\n [(31/5), 3, -(1/5)],\n [(29/5), -(12/5), (13/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{16}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 10 & 9 \\\\\n 10 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{35}{8} & \\frac{63}{16} \\\\\n \\frac{35}{8} & \\frac{21}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 9],\n [10, 3]])\nprint(a * (7/16))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{16} & \\frac{79}{8} \\\\\n -\\frac{19}{2} & \\frac{25}{16} \\\\\n \\frac{5}{8} & \\frac{11}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{115}{16} & -\\frac{11}{16} \\\\\n -\\frac{35}{16} & -\\frac{89}{16} \\\\\n -\\frac{17}{4} & -\\frac{61}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{29}{4} & \\frac{147}{16} \\\\\n -\\frac{187}{16} & -4 \\\\\n -\\frac{29}{8} & -\\frac{17}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/16), (79/8)],\n [-(19/2), (25/16)],\n [(5/8), (11/2)]])\nb = np.array([\n [-(115/16), -(11/16)],\n [-(35/16), -(89/16)],\n [-(17/4), -(61/8)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 3 \\\\\n -6 \\\\\n 2 \\\\\n -4 \\\\\n -4 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -4 \\\\\n 7 \\\\\n 10 \\\\\n -1 \\\\\n -8 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-38$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [3],\n [-6],\n [2],\n [-4],\n [-4],\n [-4]])\nb = np.array([\n [4],\n [-4],\n [7],\n [10],\n [-1],\n [-8],\n [4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{7} & -\\frac{12}{7} & 1 \\\\\n \\frac{1}{7} & \\frac{18}{7} & -\\frac{4}{7} \\\\\n \\frac{18}{7} & \\frac{17}{7} & \\frac{16}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{18}{7} \\\\\n 3 \\\\\n -\\frac{20}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{302}{49} \\\\\n \\frac{440}{49} \\\\\n -\\frac{41}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/7), -(12/7), 1],\n [(1/7), (18/7), -(4/7)],\n [(18/7), (17/7), (16/7)]])\nb = np.array([\n [-(18/7)],\n [3],\n [-(20/7)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & \\frac{9}{2} \\\\\n -4 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$15$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), (9/2)],\n [-4, 2]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -8 & -\\frac{16}{3} & 8 & \\frac{13}{3} & -2 \\\\\n -\\frac{17}{3} & \\frac{17}{3} & \\frac{23}{3} & -\\frac{1}{3} & \\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -(16/3), 8, (13/3), -2],\n [-(17/3), (17/3), (23/3), -(1/3), (5/3)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{9}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & -6 & 10 \\\\\n 7 & 4 & -3 \\\\\n 2 & 7 & 5 \\\\\n -1 & 0 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{4}{9} & -\\frac{2}{3} & \\frac{10}{9} \\\\\n \\frac{7}{9} & \\frac{4}{9} & -\\frac{1}{3} \\\\\n \\frac{2}{9} & \\frac{7}{9} & \\frac{5}{9} \\\\\n -\\frac{1}{9} & 0 & -\\frac{5}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -6, 10],\n [7, 4, -3],\n [2, 7, 5],\n [-1, 0, -5]])\nprint(a * (1/9))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n 9 & 0 & -5 & -2 & 1 \\\\\n 6 & 3 & -1 & 8 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 0, -5, -2, 1],\n [6, 3, -1, 8, -1]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,3,0\\}, \\{-1,-2,-2\\}, \\{-3,2,-2\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{2}{\\sqrt{13}},\\frac{3}{\\sqrt{13}},0\\right\\}, \\left\\{-\\frac{21}{\\sqrt{1313}},-\\frac{14}{\\sqrt{1313}},-2 \\sqrt{\\frac{13}{101}}\\right\\}, \\left\\{\\frac{6}{\\sqrt{101}},\\frac{4}{\\sqrt{101}},-\\frac{7}{\\sqrt{101}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, 3, 0), (-1, -2, -2), (-3, 2, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -6 \\\\\n 5 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -2 \\\\\n -8 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{190}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-6],\n [5],\n [-1]])\nb = np.array([\n [-4],\n [-2],\n [-8],\n [-3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & -4 \\\\\n 8 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} i \\left(\\sqrt{7}-i\\right),1\\right\\}, \\left\\{-\\frac{1}{4} i \\left(\\sqrt{7}+i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -4],\n [8, -10]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{3,1,-3\\}, \\{2,2,1\\}, \\{1,0,1\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{3}{\\sqrt{19}},\\frac{1}{\\sqrt{19}},-\\frac{3}{\\sqrt{19}}\\right\\}, \\left\\{\\frac{23}{\\sqrt{2774}},\\frac{33}{\\sqrt{2774}},17 \\sqrt{\\frac{2}{1387}}\\right\\}, \\left\\{\\frac{7}{\\sqrt{146}},-\\frac{9}{\\sqrt{146}},2 \\sqrt{\\frac{2}{73}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((3, 1, -3), (2, 2, 1), (1, 0, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 3 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 0 & 0 \\\\\n 3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 3 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1]])\nb = np.array([\n [0, 0],\n [3, 3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -8 & -9 & -9 & -9 \\\\\n -8 & 2 & 9 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -9, -9, -9],\n [-8, 2, 9, 6]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{2}{3} & -\\frac{28}{3} & -\\frac{17}{3} \\\\\n \\frac{23}{3} & \\frac{23}{3} & -\\frac{17}{3} \\\\\n 9 & \\frac{16}{3} & -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{19 x^2}{3}-143 x+\\frac{15413}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3), -(28/3), -(17/3)],\n [(23/3), (23/3), -(17/3)],\n [9, (16/3), -(2/3)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{9}{\\sqrt{2}} \\\\\n -\\frac{13}{\\sqrt{2}} \\\\\n \\frac{1}{\\sqrt{2}} \\\\\n -\\frac{3}{\\sqrt{2}} \\\\\n 5 \\sqrt{2} \\\\\n 3 \\sqrt{2} \\\\\n -\\frac{7}{\\sqrt{2}} \\\\\n \\frac{7}{\\sqrt{2}} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\sqrt{2} \\\\\n -3 \\sqrt{2} \\\\\n -6 \\sqrt{2} \\\\\n \\frac{7}{\\sqrt{2}} \\\\\n -6 \\sqrt{2} \\\\\n -\\sqrt{2} \\\\\n -\\frac{1}{\\sqrt{2}} \\\\\n 5 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$40$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(9/(math.sqrt(2)))],\n [-(13/(math.sqrt(2)))],\n [(1/(math.sqrt(2)))],\n [-(3/(math.sqrt(2)))],\n [5*math.sqrt(2)],\n [3*math.sqrt(2)],\n [-(7/(math.sqrt(2)))],\n [(7/(math.sqrt(2)))]])\nb = np.array([\n [5*math.sqrt(2)],\n [-3*math.sqrt(2)],\n [-6*math.sqrt(2)],\n [(7/(math.sqrt(2)))],\n [-6*math.sqrt(2)],\n [-math.sqrt(2)],\n [-(1/(math.sqrt(2)))],\n [5*math.sqrt(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{2,-1,4\\}, \\{0,2,1\\}, \\{2,4,0\\}}$.", - "Output Answer": [ - "$3 x-8 y-10 z+26=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, -1, 4],\n [0, 2, 1],\n [2, 4, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{11}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{18}{\\sqrt{445}} \\\\\n \\frac{11}{\\sqrt{445}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [(11/9)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${0, \\frac{10}{3}, \\frac{10}{3}}$ to the plane $-\\frac{8 x}{3}-2 y-z+1=0$.", - "Output Answer": [ - "$\\frac{27}{\\sqrt{109}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 0, (10/3), (10/3)\nplane = Poly(-((8*x)/3)-2*y-z+1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -4 & -\\frac{2}{3} & -\\frac{71}{9} \\\\\n \\frac{10}{3} & -\\frac{85}{9} & -\\frac{43}{9} \\\\\n -\\frac{53}{9} & 3 & -\\frac{2}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{41 x^2}{3}-\\frac{880 x}{81}+\\frac{200395}{729}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -(2/3), -(71/9)],\n [(10/3), -(85/9), -(43/9)],\n [-(53/9), 3, -(2/9)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 9 & -6 & 4 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-4.,0.,9.,0.\\}, \\{2.,0.,0.,3.\\}, \\{2.,3.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, -6, 4, -6]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & 1 \\\\\n 1 & 1 \\\\\n -2 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.23 \\\\\n 2.26 \\\\\n -1.59 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.43 \\\\\n 0.37 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1],\n [1, 1],\n [-2, 0]])\nb = np.array([\n [-0.23],\n [2.26],\n [-1.59]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n 0 & 6 & 7 & 3 & 1 \\\\\n 7 & 7 & -8 & -2 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 6, 7, 3, 1],\n [7, 7, -8, -2, -7]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{53}{6} \\\\\n -\\frac{23}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{59}{6} \\\\\n -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{56}{3} \\\\\n -\\frac{28}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(53/6)],\n [-(23/3)]])\nb = np.array([\n [-(59/6)],\n [-(5/3)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -5 \\\\\n -1 \\\\\n -5 \\\\\n -7 \\\\\n 7 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 5 \\\\\n 8 \\\\\n 2 \\\\\n 7 \\\\\n -3 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{706}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-5],\n [-1],\n [-5],\n [-7],\n [7],\n [-5]])\nb = np.array([\n [9],\n [5],\n [8],\n [2],\n [7],\n [-3],\n [7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{4}{3} & \\frac{5}{3} & -\\frac{8}{3} \\\\\n 4 & -\\frac{14}{3} & \\frac{16}{3} \\\\\n \\frac{1}{3} & \\frac{25}{3} & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{5 x^2}{3}+\\frac{658 x}{9}-\\frac{1924}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3), (5/3), -(8/3)],\n [4, -(14/3), (16/3)],\n [(1/3), (25/3), 5]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 9 & -9 & 10 & 5 & -3 & 0 \\\\\n 3 & -3 & 6 & -10 & -9 & 9 \\\\\n -1 & -4 & 8 & -2 & -5 & -2 \\\\\n 3 & 8 & -9 & 8 & -8 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & -\\frac{5001}{4427} & \\frac{1400}{4427} \\\\\n 0 & 1 & 0 & 0 & -\\frac{15422}{4427} & -\\frac{8275}{4427} \\\\\n 0 & 0 & 1 & 0 & -\\frac{10971}{4427} & -\\frac{6282}{4427} \\\\\n 0 & 0 & 0 & 1 & \\frac{528}{4427} & -\\frac{4851}{4427} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, -9, 10, 5, -3, 0],\n [3, -3, 6, -10, -9, 9],\n [-1, -4, 8, -2, -5, -2],\n [3, 8, -9, 8, -8, -10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,3,-4\\}, \\{1,4,3\\}, \\{-1,1,3\\}}$.", - "Output Answer": [ - "$21 x-14 y-4 z+47=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, 3, -4],\n [1, 4, 3],\n [-1, 1, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{16}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 8 & 1 & 0 \\\\\n -6 & -5 & 5 \\\\\n -4 & 8 & -4 \\\\\n -6 & -10 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & \\frac{5}{16} & 0 \\\\\n -\\frac{15}{8} & -\\frac{25}{16} & \\frac{25}{16} \\\\\n -\\frac{5}{4} & \\frac{5}{2} & -\\frac{5}{4} \\\\\n -\\frac{15}{8} & -\\frac{25}{8} & -\\frac{45}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 1, 0],\n [-6, -5, 5],\n [-4, 8, -4],\n [-6, -10, -9]])\nprint(a * (5/16))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{11}{6} & \\frac{7}{6} \\\\\n 0 & \\frac{1}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{11}{36}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/6), (7/6)],\n [0, (1/6)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -1 & 1 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 1 & -2 & 1 \\\\\n -2 & 1 & 1 \\\\\n -2 & 3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & -3 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, -2]])\nb = np.array([\n [1, -2, 1],\n [-2, 1, 1],\n [-2, 3, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & 1 & 0 \\\\\n 2 & -1 & \\frac{3}{2} \\\\\n -\\frac{1}{2} & -\\frac{1}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{4} & \\frac{9}{4} & \\frac{9}{4} \\\\\n \\frac{27}{8} & -\\frac{49}{8} & 9 \\\\\n -\\frac{21}{4} & -\\frac{15}{4} & \\frac{95}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 0],\n [2, -1, (3/2)],\n [-(1/2), -(1/2), (5/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{2}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -9 & -7 \\\\\n 6 & 0 \\\\\n 3 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{45}{2} & -\\frac{35}{2} \\\\\n 15 & 0 \\\\\n \\frac{15}{2} & 15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -7],\n [6, 0],\n [3, 6]])\nprint(a * (5/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & -3 \\\\\n -5 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{39}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), -3],\n [-5, -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{5} \\\\\n -1 \\\\\n 0 \\\\\n \\frac{9}{5} \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{3 \\sqrt{23}} \\\\\n -\\frac{5}{3 \\sqrt{23}} \\\\\n 0 \\\\\n \\frac{3}{\\sqrt{23}} \\\\\n \\frac{10}{3 \\sqrt{23}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/5)],\n [-1],\n [0],\n [(9/5)],\n [2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -2 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 0 & 3 & -1 & -1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 0 & -3 & 1 & 1 & 3 \\\\\n 0 & -6 & 2 & 2 & 6 \\\\\n 0 & -6 & 2 & 2 & 6 \\\\\n 0 & 3 & -1 & -1 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-2],\n [-2],\n [1]])\nb = np.array([\n [0, 3, -1, -1, -3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{7}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -7 \\\\\n 5 & -8 \\\\\n 10 & -8 \\\\\n -5 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{10}{7} & 5 \\\\\n -\\frac{25}{7} & \\frac{40}{7} \\\\\n -\\frac{50}{7} & \\frac{40}{7} \\\\\n \\frac{25}{7} & -\\frac{20}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -7],\n [5, -8],\n [10, -8],\n [-5, 4]])\nprint(a * -(5/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{4} \\\\\n -\\frac{5}{2} \\\\\n -\\frac{5}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{3 \\sqrt{14}} \\\\\n -\\frac{5 \\sqrt{\\frac{2}{7}}}{3} \\\\\n -\\frac{5}{3 \\sqrt{14}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/4)],\n [-(5/2)],\n [-(5/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{2} & -\\frac{5}{2} & -1 \\\\\n -\\frac{1}{2} & \\frac{1}{2} & -\\frac{5}{2} \\\\\n -\\frac{3}{2} & \\frac{5}{2} & -2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{107}{8} & \\frac{105}{8} & -\\frac{57}{4} \\\\\n -\\frac{47}{8} & -\\frac{9}{8} & -\\frac{3}{8} \\\\\n -\\frac{1}{8} & -\\frac{65}{8} & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), -(5/2), -1],\n [-(1/2), (1/2), -(5/2)],\n [-(3/2), (5/2), -2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{4} \\\\\n 3 \\\\\n -\\frac{17}{4} \\\\\n -\\frac{19}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n 0 \\\\\n 3 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{27 \\sqrt{\\frac{21}{46}}}{19}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/4)],\n [3],\n [-(17/4)],\n [-(19/2)]]).squeeze()\nb = np.array([\n [(5/2)],\n [0],\n [3],\n [5]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & -3 \\\\\n 1 & -3 \\\\\n -3 & -2 \\\\\n 2 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.43 \\\\\n -1.97 \\\\\n 1.27 \\\\\n 1.49 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.234 \\\\\n 0.284 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -3],\n [1, -3],\n [-3, -2],\n [2, 0]])\nb = np.array([\n [-1.43],\n [-1.97],\n [1.27],\n [1.49]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 5 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -9 \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -53 \\\\\n -16 \\\\\n 34 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [5],\n [-7]])\nb = np.array([\n [4],\n [-9],\n [2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{34}{7} \\\\\n 5 \\\\\n -\\frac{22}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -\\frac{12}{7} \\\\\n \\frac{13}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{191}{49} \\\\\n -\\frac{482}{49} \\\\\n -\\frac{1062}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(34/7)],\n [5],\n [-(22/7)]])\nb = np.array([\n [6],\n [-(12/7)],\n [(13/7)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{23}{5} \\\\\n \\frac{29}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{5} \\\\\n -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{6}{5} \\\\\n \\frac{13}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/5)],\n [(29/5)]])\nb = np.array([\n [-(17/5)],\n [-(9/2)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -7 & 8 & -1 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-10.,0.,0.,7.\\}, \\{-1.,0.,7.,0.\\}, \\{8.,7.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, 8, -1, -10]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -4 \\\\\n 8 \\\\\n 1 \\\\\n 6 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{247}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-4],\n [8],\n [1],\n [6],\n [7]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{2}{3},-\\frac{1}{3},2\\right\\}, \\left\\{4,\\frac{7}{3},-\\frac{10}{3}\\right\\}, \\left\\{0,-\\frac{14}{3},-\\frac{11}{3}\\right\\}}$.", - "Output Answer": [ - "$516 x-303 y+171 z-787=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(2/3), -(1/3), 2],\n [4, (7/3), -(10/3)],\n [0, -(14/3), -(11/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{7}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{59}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{19}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2)]])\nb = np.array([\n [-(59/6)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & -3 \\\\\n 3 & -3 \\\\\n 2 & 1 \\\\\n 2 & 3 \\\\\n -1 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.87 \\\\\n 1.03 \\\\\n 2.2 \\\\\n 1.71 \\\\\n -1.3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.709 \\\\\n 0.235 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3],\n [3, -3],\n [2, 1],\n [2, 3],\n [-1, 0]])\nb = np.array([\n [0.87],\n [1.03],\n [2.2],\n [1.71],\n [-1.3]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 5 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$16$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [5],\n [-1]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & 5 \\\\\n 0 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 5],\n [0, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{2}{3},\\frac{8}{3},0\\right\\}, \\left\\{-\\frac{2}{3},0,\\frac{4}{3}\\right\\}, \\left\\{2,-\\frac{4}{3},\\frac{7}{3}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{17}},\\frac{4}{\\sqrt{17}},0\\right\\}, \\left\\{-\\frac{8}{\\sqrt{357}},\\frac{2}{\\sqrt{357}},\\sqrt{\\frac{17}{21}}\\right\\}, \\left\\{\\frac{4}{\\sqrt{21}},-\\frac{1}{\\sqrt{21}},\\frac{2}{\\sqrt{21}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack((((2/3), (8/3), 0), (-(2/3), 0, (4/3)), (2, -(4/3), (7/3))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{23}{5} & -1 \\\\\n -\\frac{13}{5} & -\\frac{17}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{326}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/5), -1],\n [-(13/5), -(17/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -10 & -9 \\\\\n -3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, -9],\n [-3, 2]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & \\frac{3}{4} \\\\\n -\\frac{5}{2} & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{3 x}{2}-\\frac{5}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, (3/4)],\n [-(5/2), -(5/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,3,-2\\}, \\{-4,4,4\\}, \\{1,-4,-2\\}}$.", - "Output Answer": [ - "$14 x+8 y+z+20=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, 3, -2],\n [-4, 4, 4],\n [1, -4, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n \\frac{46}{9} & \\frac{2}{3} & -\\frac{29}{3} \\\\\n -\\frac{2}{3} & \\frac{19}{3} & -\\frac{41}{9} \\\\\n -\\frac{59}{9} & -\\frac{25}{3} & \\frac{56}{9} \\\\\n \\frac{61}{9} & \\frac{71}{9} & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(46/9), (2/3), -(29/3)],\n [-(2/3), (19/3), -(41/9)],\n [-(59/9), -(25/3), (56/9)],\n [(61/9), (71/9), 3]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{57}{7} \\\\\n \\frac{29}{7} \\\\\n \\frac{19}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -\\frac{13}{7} \\\\\n -\\frac{9}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{149}{49}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(57/7)],\n [(29/7)],\n [(19/7)]])\nb = np.array([\n [-1],\n [-(13/7)],\n [-(9/7)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{5}{3},\\frac{2}{3},-\\frac{13}{3}\\right\\}, \\left\\{-\\frac{11}{3},\\frac{5}{3},\\frac{1}{3}\\right\\}, \\left\\{-2,-\\frac{13}{3},5\\right\\}}$.", - "Output Answer": [ - "$882 x+462 y+279 z+2371=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(5/3), (2/3), -(13/3)],\n [-(11/3), (5/3), (1/3)],\n [-2, -(13/3), 5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{4}{3} & 2 & \\frac{4}{3} \\\\\n -\\frac{2}{3} & -\\frac{11}{3} & -\\frac{5}{3} \\\\\n \\frac{5}{3} & 0 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{98}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/3), 2, (4/3)],\n [-(2/3), -(11/3), -(5/3)],\n [(5/3), 0, -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{5}{\\pi },\\frac{3}{\\pi },\\frac{6}{\\pi }\\right\\}, \\left\\{0,\\frac{9}{\\pi },-\\frac{6}{\\pi }\\right\\}, \\left\\{-\\frac{3}{\\pi },-\\frac{9}{\\pi },\\frac{4}{\\pi }\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\sqrt{\\frac{5}{14}},\\frac{3}{\\sqrt{70}},3 \\sqrt{\\frac{2}{35}}\\right\\}, \\left\\{3 \\sqrt{\\frac{5}{12614}},\\frac{219}{\\sqrt{63070}},-61 \\sqrt{\\frac{2}{31535}}\\right\\}, \\left\\{-\\frac{24}{\\sqrt{901}},\\frac{10}{\\sqrt{901}},\\frac{15}{\\sqrt{901}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((5/math.pi), (3/math.pi), (6/math.pi)), (0, (9/math.pi), -(6/math.pi)), (-(3/math.pi), -(9/math.pi), (4/math.pi))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 1 & -5 \\\\\n 3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{2}{17} & \\frac{5}{17} \\\\\n -\\frac{3}{17} & \\frac{1}{17} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -5],\n [3, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & -3 & -2 \\\\\n 2 & -1 & -3 \\\\\n -1 & 0 & 2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 9 & 9 \\\\\n -3 & 2 & -1 \\\\\n 0 & 3 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3, -2],\n [2, -1, -3],\n [-1, 0, 2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 7 \\\\\n -8 \\\\\n -9 \\\\\n -7 \\\\\n -9 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -2 \\\\\n 10 \\\\\n 9 \\\\\n -3 \\\\\n 8 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-203$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [7],\n [-8],\n [-9],\n [-7],\n [-9],\n [4]])\nb = np.array([\n [3],\n [-2],\n [10],\n [9],\n [-3],\n [8],\n [8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 5 & 4 \\\\\n -3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{7} & -\\frac{4}{7} \\\\\n \\frac{3}{7} & \\frac{5}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 4],\n [-3, -1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -1 & 4 \\\\\n 5 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, 4],\n [5, 5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -8 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -9 \\\\\n 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 64 \\\\\n -50 \\\\\n -130 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-8],\n [8]])\nb = np.array([\n [-5],\n [-9],\n [1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{32}{9} & 5 & \\frac{35}{9} \\\\\n -\\frac{10}{9} & \\frac{7}{9} & \\frac{10}{9} \\\\\n \\frac{31}{9} & -\\frac{40}{9} & -\\frac{2}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{3474}{31807} & -\\frac{11790}{31807} & \\frac{1845}{31807} \\\\\n \\frac{2610}{31807} & -\\frac{10341}{31807} & -\\frac{6030}{31807} \\\\\n \\frac{1647}{31807} & \\frac{24075}{31807} & \\frac{6066}{31807} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(32/9), 5, (35/9)],\n [-(10/9), (7/9), (10/9)],\n [(31/9), -(40/9), -(2/9)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & -3 & -1 \\\\\n -2 & -2 & -3 \\\\\n -2 & -1 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, -1],\n [-2, -2, -3],\n [-2, -1, -5]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{26}{3} \\\\\n -\\frac{23}{3} \\\\\n 10 \\\\\n \\frac{20}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$33$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/3)],\n [-(23/3)],\n [10],\n [(20/3)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{2}{5} \\\\\n \\frac{19}{10} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -\\frac{9}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{18}{5} \\\\\n \\frac{14}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/5)],\n [(19/10)]])\nb = np.array([\n [4],\n [-(9/10)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 9 & -10 & -9 & 4 \\\\\n -8 & 10 & 0 & -5 \\\\\n -7 & 9 & -3 & -7 \\\\\n 9 & -3 & -3 & 10 \\\\\n -2 & -9 & -1 & 9 \\\\\n 9 & -2 & 5 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, -10, -9, 4],\n [-8, 10, 0, -5],\n [-7, 9, -3, -7],\n [9, -3, -3, 10],\n [-2, -9, -1, 9],\n [9, -2, 5, 1]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -9 & -8 & 1 & 6 & -9 & 4 \\\\\n 3 & 6 & 8 & 2 & -1 & -8 \\\\\n 2 & -10 & -2 & 8 & 4 & 7 \\\\\n 8 & 5 & -7 & -10 & 3 & 0 \\\\\n 8 & -3 & 1 & -10 & 7 & 5 \\\\\n 3 & 9 & 5 & -2 & -6 & -10 \\\\\n 7 & -10 & -4 & 9 & 0 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-9, -8, 1, 6, -9, 4],\n [3, 6, 8, 2, -1, -8],\n [2, -10, -2, 8, 4, 7],\n [8, 5, -7, -10, 3, 0],\n [8, -3, 1, -10, 7, 5],\n [3, 9, 5, -2, -6, -10],\n [7, -10, -4, 9, 0, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -10 & -6 & -3 \\\\\n -9 & 0 & 10 \\\\\n 4 & -6 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-13.899,-1.551-6.519 i,-1.551+6.519 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -6, -3],\n [-9, 0, 10],\n [4, -6, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 3 \\\\\n 3 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2},\\frac{1}{2},0,0\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [3],\n [3]]).squeeze()\nb = np.array([\n [-1],\n [-1],\n [0],\n [0]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-5,-1,-2\\}, \\{-1,-3,-2\\}, \\{-4,-1,2\\}}$.", - "Output Answer": [ - "$4 x+8 y-z+26=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-5, -1, -2],\n [-1, -3, -2],\n [-4, -1, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 4+3 i & -2 \\\\\n 2+3 i & -4 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 3+18 i & -8+2 i \\\\\n 11+10 i & -20-6 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4+3j, -2],\n [2+3j, -4j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 7 & -3 & 4 \\\\\n -2 & 10 & 8 \\\\\n -2 & 2 & 5 \\\\\n -4 & 2 & 0 \\\\\n -9 & 4 & 4 \\\\\n 2 & 8 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, -3, 4],\n [-2, 10, 8],\n [-2, 2, 5],\n [-4, 2, 0],\n [-9, 4, 4],\n [2, 8, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -1 & 2 & 3 \\\\\n 5 & 2 & -5 \\\\\n 0 & -3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{11}{54} & \\frac{13}{54} & \\frac{8}{27} \\\\\n \\frac{5}{27} & \\frac{1}{27} & -\\frac{5}{27} \\\\\n \\frac{5}{18} & \\frac{1}{18} & \\frac{2}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2, 3],\n [5, 2, -5],\n [0, -3, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & 1 & 3 & 1 \\\\\n -2 & 3 & 0 & -1 \\\\\n 1 & -3 & 3 & 0 \\\\\n 3 & 3 & 2 & 3 \\\\\n -1 & 1 & 3 & 0 \\\\\n 0 & -2 & -3 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.01 \\\\\n -1.07 \\\\\n -1.19 \\\\\n 1.11 \\\\\n -0.2 \\\\\n 0.1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.848 \\\\\n -0.288 \\\\\n -0.325 \\\\\n 1.747 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1, 3, 1],\n [-2, 3, 0, -1],\n [1, -3, 3, 0],\n [3, 3, 2, 3],\n [-1, 1, 3, 0],\n [0, -2, -3, -1]])\nb = np.array([\n [-0.01],\n [-1.07],\n [-1.19],\n [1.11],\n [-0.2],\n [0.1]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & 7 \\\\\n -5 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{10} \\left(-3-i \\sqrt{131}\\right),1\\right\\}, \\left\\{\\frac{1}{10} \\left(-3+i \\sqrt{131}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 7],\n [-5, -9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -3 & 10 & 1 & 1 & 4 & -7 & 4 \\\\\n 2 & 2 & -6 & -1 & 2 & -2 & 7 \\\\\n -7 & 9 & -8 & -4 & 3 & -8 & 9 \\\\\n 0 & 3 & -8 & 6 & 6 & -10 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & \\frac{423}{4147} & \\frac{1778}{4147} & \\frac{5230}{4147} \\\\\n 0 & 1 & 0 & 0 & \\frac{130}{319} & -\\frac{170}{319} & \\frac{317}{319} \\\\\n 0 & 0 & 1 & 0 & -\\frac{1005}{4147} & \\frac{1805}{4147} & -\\frac{279}{4147} \\\\\n 0 & 0 & 0 & 1 & \\frac{1962}{4147} & -\\frac{3400}{4147} & -\\frac{8653}{4147} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 10, 1, 1, 4, -7, 4],\n [2, 2, -6, -1, 2, -2, 7],\n [-7, 9, -8, -4, 3, -8, 9],\n [0, 3, -8, 6, 6, -10, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 0 & -3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 3 & -1 \\\\\n 0 & 6 & -2 \\\\\n 0 & 3 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-2],\n [-1]])\nb = np.array([\n [0, -3, 1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & -2 \\\\\n 8 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-10 x+25$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2],\n [8, 9]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{61}{10} & \\frac{49}{10} & \\frac{23}{10} \\\\\n -4 & \\frac{14}{5} & -\\frac{49}{10} \\\\\n \\frac{41}{10} & -\\frac{11}{5} & -\\frac{41}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{23 x^2}{2}-\\frac{937 x}{100}-\\frac{59511}{1000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(61/10), (49/10), (23/10)],\n [-4, (14/5), -(49/10)],\n [(41/10), -(11/5), -(41/5)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 7 \\\\\n -4 \\\\\n -10 \\\\\n -2 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 8 \\\\\n 6 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-94$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [7],\n [-4],\n [-10],\n [-2],\n [9]])\nb = np.array([\n [1],\n [0],\n [1],\n [8],\n [6],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{5,-\\frac{14}{3},4\\right\\}, \\left\\{\\frac{4}{3},-\\frac{14}{3},-\\frac{10}{3}\\right\\}, \\{-2,4,-2\\}}$.", - "Output Answer": [ - "$26 x+12 y-13 z-22=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [5, -(14/3), 4],\n [(4/3), -(14/3), -(10/3)],\n [-2, 4, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -6 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -6 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -60 \\\\\n -10 \\\\\n -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-6],\n [-5]])\nb = np.array([\n [0],\n [-6],\n [5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{51}{10} & -\\frac{87}{10} \\\\\n -\\frac{14}{5} & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{29 x}{10}-\\frac{1629}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(51/10), -(87/10)],\n [-(14/5), 8]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 5 \\\\\n 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -47 \\\\\n 49 \\\\\n 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [8]])\nb = np.array([\n [7],\n [5],\n [7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{2} & 1 & 3 \\\\\n 5 & 3 & \\frac{5}{2} \\\\\n 0 & -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{281}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), 1, 3],\n [5, 3, (5/2)],\n [0, -1, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 0 & 2 \\\\\n 2 & -3 & -1 \\\\\n -3 & -3 & -2 \\\\\n 1 & 2 & 1 \\\\\n 3 & -3 & 2 \\\\\n 2 & 1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.5 \\\\\n -2.36 \\\\\n -2.96 \\\\\n -0.27 \\\\\n -1.76 \\\\\n -2.17 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.205 \\\\\n 0.601 \\\\\n -0.187 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, 2],\n [2, -3, -1],\n [-3, -3, -2],\n [1, 2, 1],\n [3, -3, 2],\n [2, 1, 1]])\nb = np.array([\n [-2.5],\n [-2.36],\n [-2.96],\n [-0.27],\n [-1.76],\n [-2.17]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -3 & 0 & -1 & -2 \\\\\n -2 & 0 & 4 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.,0.,-1.,2.\\}, \\{0.,1.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, 0, -1, -2],\n [-2, 0, 4, 1]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{3}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & 4 \\\\\n -8 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{20}{3} & -\\frac{20}{3} \\\\\n \\frac{40}{3} & -\\frac{40}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 4],\n [-8, 8]])\nprint(a * -(5/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & 4 & -2 \\\\\n 3 & 2 & 0 \\\\\n -1 & 2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{12} & \\frac{1}{3} & -\\frac{1}{6} \\\\\n \\frac{1}{8} & 0 & \\frac{1}{4} \\\\\n -\\frac{1}{3} & \\frac{1}{3} & \\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 4, -2],\n [3, 2, 0],\n [-1, 2, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{9}{2}-\\frac{i}{2} & 4+\\frac{3 i}{2} & 3+2 i \\\\\n -1+2 i & i & 2-\\frac{7 i}{2} \\\\\n -\\frac{5}{2}+\\frac{5 i}{2} & \\frac{5}{2}+2 i & \\frac{1}{2}-\\frac{3 i}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2}+\\frac{9 i}{2} & \\frac{83}{4}+\\frac{79 i}{4} & \\frac{129}{4}-7 i \\\\\n -\\frac{7}{4}+\\frac{89 i}{4} & 4+\\frac{7 i}{4} & -\\frac{31}{4}+\\frac{5 i}{4} \\\\\n -14+\\frac{41 i}{2} & -\\frac{23}{2}+6 i & -\\frac{5}{2}-\\frac{15 i}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/2)-(1j/2), 4+((3j)/2), 3+2j],\n [-1+2j, 1j, 2-((7j)/2)],\n [-(5/2)+((5j)/2), (5/2)+2j, (1/2)-((3j)/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 2 & 5 & 2 \\\\\n 1 & -7 & -2 \\\\\n 1 & 0 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-12 x^2-14 x+137$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 5, 2],\n [1, -7, -2],\n [1, 0, -7]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -7 \\\\\n 8 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$25$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-7],\n [8],\n [-3]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & 0 & 9 \\\\\n -2 & -1 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{3.,0.,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, 0, 9],\n [-2, -1, 6]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{23}{10} \\\\\n \\frac{2}{5} \\\\\n -\\frac{1}{2} \\\\\n \\frac{5}{2} \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{23}{\\sqrt{1195}} \\\\\n \\frac{4}{\\sqrt{1195}} \\\\\n -\\sqrt{\\frac{5}{239}} \\\\\n 5 \\sqrt{\\frac{5}{239}} \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/10)],\n [(2/5)],\n [-(1/2)],\n [(5/2)],\n [0]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,2,-1\\}, \\{3,1,-1\\}, \\{-3,2,-1\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{2}{3},\\frac{2}{3},-\\frac{1}{3}\\right\\}, \\left\\{\\frac{1}{\\sqrt{2}},-\\frac{1}{\\sqrt{2}},0\\right\\}, \\left\\{-\\frac{1}{3 \\sqrt{2}},-\\frac{1}{3 \\sqrt{2}},-\\frac{2 \\sqrt{2}}{3}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, 2, -1), (3, 1, -1), (-3, 2, -1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 3 & -7 & 4 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-4.,0.,3.,0.\\}, \\{1.,0.,0.,3.\\}, \\{7.,3.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, -7, 4, -1]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -2 & 5 & 1 & -9 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -4 & -8 & 6 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 2 & 13 & -5 & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 5, 1, -9]])\nb = np.array([\n [-4, -8, 6, 0]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{86}{9} \\\\\n \\frac{11}{3} \\\\\n -\\frac{44}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{16}{3} \\\\\n \\frac{70}{9} \\\\\n -\\frac{79}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{473}{81} \\\\\n -\\frac{8906}{81} \\\\\n -\\frac{7604}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(86/9)],\n [(11/3)],\n [-(44/9)]])\nb = np.array([\n [(16/3)],\n [(70/9)],\n [-(79/9)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(2 \\sqrt{3}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [0],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [-1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -3 & -9 \\\\\n -9 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+3 x-81$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -9],\n [-9, 0]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 10 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 1 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -68 \\\\\n 39 \\\\\n -43 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [10],\n [-2]])\nb = np.array([\n [5],\n [1],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,0,0\\}, \\{2,0,-1\\}, \\{-1,-1,0\\}}$", - "Output Answer": [ - "${\\{1,0,0\\}, \\{0,0,-1\\}, \\{0,-1,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, 0, 0), (2, 0, -1), (-1, -1, 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & -4 \\\\\n -6 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{5-\\sqrt{33},5+\\sqrt{33}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -4],\n [-6, 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -5 & -3 & 6 \\\\\n 2 & 9 & -8 \\\\\n -10 & 9 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-2.635-8.905 i,-2.635+8.905 i,3.27\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -3, 6],\n [2, 9, -8],\n [-10, 9, -6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{47}{10} & -\\frac{22}{5} & 2 \\\\\n -\\frac{43}{10} & \\frac{24}{5} & -\\frac{6}{5} \\\\\n -\\frac{14}{5} & -\\frac{24}{5} & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{5108}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(47/10), -(22/5), 2],\n [-(43/10), (24/5), -(6/5)],\n [-(14/5), -(24/5), 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & -8 \\\\\n -3 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(1-\\sqrt{145}\\right),\\frac{1}{2} \\left(1+\\sqrt{145}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -8],\n [-3, -3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & -\\frac{3}{2} \\\\\n 0 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -(3/2)],\n [0, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -4 \\\\\n 6 \\\\\n -8 \\\\\n 1 \\\\\n -4 \\\\\n -9 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-4],\n [6],\n [-8],\n [1],\n [-4],\n [-9],\n [-8]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & -\\frac{1}{3} & -\\frac{2}{3} \\\\\n \\frac{2}{3} & \\frac{11}{3} & -3 \\\\\n \\frac{29}{3} & -6 & -\\frac{17}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.032,-1.876,1.\\}, \\{0.071,0.285,1.\\}, \\{3.141,3.548,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -(1/3), -(2/3)],\n [(2/3), (11/3), -3],\n [(29/3), -6, -(17/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 0 & -3 & 2 & 3 & -1 \\\\\n -3 & 2 & 3 & 1 & 2 \\\\\n 1 & 3 & 3 & 3 & 0 \\\\\n 0 & -1 & 2 & -2 & -2 \\\\\n -3 & 0 & -1 & -3 & 2 \\\\\n 0 & 0 & 3 & 3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.82 \\\\\n 2.25 \\\\\n -1.04 \\\\\n 1.6 \\\\\n -0.55 \\\\\n 1.88 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.835 \\\\\n 0.002 \\\\\n 0.818 \\\\\n -0.9 \\\\\n 0.953 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3, 2, 3, -1],\n [-3, 2, 3, 1, 2],\n [1, 3, 3, 3, 0],\n [0, -1, 2, -2, -2],\n [-3, 0, -1, -3, 2],\n [0, 0, 3, 3, 2]])\nb = np.array([\n [-2.82],\n [2.25],\n [-1.04],\n [1.6],\n [-0.55],\n [1.88]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${1, -\\frac{1}{2}, -\\frac{5}{2}}$ to the plane $-\\frac{3 x}{2}+3 y+\\frac{z}{2}+\\frac{3}{2}=0$.", - "Output Answer": [ - "$\\frac{11}{2 \\sqrt{46}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 1, -(1/2), -(5/2)\nplane = Poly(-((3*x)/2)+3*y+(z/2)+(3/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{5} & \\frac{42}{5} \\\\\n \\frac{7}{5} & -\\frac{17}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{14 x}{5}-\\frac{69}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/5), (42/5)],\n [(7/5), -(17/5)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7.8 \\\\\n -1.5 \\\\\n -9.8 \\\\\n 6.5 \\\\\n -3.6 \\\\\n -9.5 \\\\\n -8.2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6.8 \\\\\n -7.7 \\\\\n 4. \\\\\n 7.2 \\\\\n 2.8 \\\\\n -5.6 \\\\\n 8.3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$23.6387$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7.8],\n [-1.5],\n [-9.8],\n [6.5],\n [-3.6],\n [-9.5],\n [-8.2]])\nb = np.array([\n [6.8],\n [-7.7],\n [4.],\n [7.2],\n [2.8],\n [-5.6],\n [8.3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 4 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 5 \\\\\n -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 11 \\\\\n -92 \\\\\n -62 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [4],\n [-7]])\nb = np.array([\n [8],\n [5],\n [-6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{12}{5} & \\frac{7}{5} \\\\\n \\frac{13}{5} & \\frac{6}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{30}{19} & \\frac{35}{19} \\\\\n \\frac{65}{19} & -\\frac{60}{19} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(12/5), (7/5)],\n [(13/5), (6/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -5 & 7 \\\\\n 7 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(3-\\sqrt{365}\\right),\\frac{1}{2} \\left(3+\\sqrt{365}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 7],\n [7, 8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{1}{2},-\\frac{5}{2},1\\right\\}, \\left\\{\\frac{7}{2},-1,-\\frac{9}{2}\\right\\}, \\left\\{-4,\\frac{1}{2},1\\right\\}}$.", - "Output Answer": [ - "$132 x+154 y+138 z+313=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(1/2), -(5/2), 1],\n [(7/2), -1, -(9/2)],\n [-4, (1/2), 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{4,1,-2\\}, \\{-1,4,3\\}, \\{5,4,-2\\}}$.", - "Output Answer": [ - "$-15 x+5 y-18 z+19=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, 1, -2],\n [-1, 4, 3],\n [5, 4, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 0 & 3 \\\\\n 0 & -3 & 2 \\\\\n 3 & -1 & -2 \\\\\n -3 & 1 & -2 \\\\\n -1 & 3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.43 \\\\\n -0.45 \\\\\n 0.05 \\\\\n -1.74 \\\\\n -1.53 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.323 \\\\\n -0.124 \\\\\n 0.117 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0, 3],\n [0, -3, 2],\n [3, -1, -2],\n [-3, 1, -2],\n [-1, 3, 3]])\nb = np.array([\n [1.43],\n [-0.45],\n [0.05],\n [-1.74],\n [-1.53]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -\\frac{3}{2} \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n -2 \\\\\n \\frac{1}{2} \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{9}{70},-\\frac{6}{35},\\frac{3}{70},-\\frac{9}{70}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [-(3/2)],\n [-1]]).squeeze()\nb = np.array([\n [-(3/2)],\n [-2],\n [(1/2)],\n [-(3/2)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 3 & -2 & \\frac{3}{2} \\\\\n \\frac{1}{2} & -1 & -2 \\\\\n \\frac{1}{2} & -2 & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 27 & -\\frac{55}{2} & \\frac{217}{8} \\\\\n \\frac{27}{8} & -\\frac{19}{2} & -8 \\\\\n \\frac{35}{8} & -\\frac{23}{2} & -\\frac{5}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2, (3/2)],\n [(1/2), -1, -2],\n [(1/2), -2, 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,2,0\\}, \\{-1,1,5\\}, \\{-2,-2,-3\\}}$.", - "Output Answer": [ - "$23 x-13 y+2 z+26=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, 2, 0],\n [-1, 1, 5],\n [-2, -2, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -5 & 0 \\\\\n -\\frac{1}{3} & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-25$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 0],\n [-(1/3), 5]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -7 & \\frac{11}{3} & \\frac{23}{6} & \\frac{53}{6} \\\\\n -\\frac{20}{3} & \\frac{28}{3} & 8 & \\frac{15}{2} \\\\\n -\\frac{23}{6} & \\frac{43}{6} & -\\frac{2}{3} & -1 \\\\\n -8 & -\\frac{7}{2} & \\frac{53}{6} & \\frac{29}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{5}{6} & \\frac{14}{3} & -\\frac{20}{3} & -2 \\\\\n -\\frac{7}{2} & -2 & \\frac{31}{6} & -\\frac{59}{6} \\\\\n -\\frac{5}{2} & \\frac{1}{6} & \\frac{17}{3} & -\\frac{8}{3} \\\\\n -\\frac{7}{6} & \\frac{22}{3} & -\\frac{19}{3} & -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{37}{6} & -1 & \\frac{21}{2} & \\frac{65}{6} \\\\\n -\\frac{19}{6} & \\frac{34}{3} & \\frac{17}{6} & \\frac{52}{3} \\\\\n -\\frac{4}{3} & 7 & -\\frac{19}{3} & \\frac{5}{3} \\\\\n -\\frac{41}{6} & -\\frac{65}{6} & \\frac{91}{6} & \\frac{34}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, (11/3), (23/6), (53/6)],\n [-(20/3), (28/3), 8, (15/2)],\n [-(23/6), (43/6), -(2/3), -1],\n [-8, -(7/2), (53/6), (29/3)]])\nb = np.array([\n [-(5/6), (14/3), -(20/3), -2],\n [-(7/2), -2, (31/6), -(59/6)],\n [-(5/2), (1/6), (17/3), -(8/3)],\n [-(7/6), (22/3), -(19/3), -(5/3)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{38}{7} \\\\\n \\frac{12}{7} \\\\\n \\frac{11}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{38}{7} \\\\\n \\frac{61}{7} \\\\\n \\frac{39}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{29}{7} \\\\\n \\frac{1900}{49} \\\\\n -\\frac{2774}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(38/7)],\n [(12/7)],\n [(11/7)]])\nb = np.array([\n [(38/7)],\n [(61/7)],\n [(39/7)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{4} \\\\\n -\\frac{15}{4} \\\\\n \\frac{39}{4} \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{7}{4} \\\\\n \\frac{3}{4} \\\\\n \\frac{17}{2} \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{592 \\sqrt{\\frac{2}{11}}}{325}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/4)],\n [-(15/4)],\n [(39/4)],\n [-2]]).squeeze()\nb = np.array([\n [(7/4)],\n [(3/4)],\n [(17/2)],\n [(3/2)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -6 & -8 & -4 & 4 \\\\\n -6 & 1 & 8 & 4 \\\\\n 6 & -9 & -5 & 2 \\\\\n 10 & -5 & 10 & -8 \\\\\n -4 & -10 & 6 & -6 \\\\\n -4 & -7 & 8 & -4 \\\\\n -7 & 2 & 7 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-6, -8, -4, 4],\n [-6, 1, 8, 4],\n [6, -9, -5, 2],\n [10, -5, 10, -8],\n [-4, -10, 6, -6],\n [-4, -7, 8, -4],\n [-7, 2, 7, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & 3 \\\\\n 3 & 0 \\\\\n -3 & 1 \\\\\n -3 & 1 \\\\\n 0 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.07 \\\\\n -1.78 \\\\\n 1.71 \\\\\n -1.59 \\\\\n -2.08 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.376 \\\\\n -0.842 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 3],\n [3, 0],\n [-3, 1],\n [-3, 1],\n [0, 3]])\nb = np.array([\n [-2.07],\n [-1.78],\n [1.71],\n [-1.59],\n [-2.08]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 2 & 2 & -3 & 3 & 2 \\\\\n 0 & -1 & -2 & 2 & 1 \\\\\n 3 & 3 & 0 & 0 & -1 \\\\\n -1 & -2 & 0 & -3 & -1 \\\\\n 2 & -1 & 1 & 3 & 0 \\\\\n -3 & -3 & 2 & -1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.32 \\\\\n 0.66 \\\\\n -2.38 \\\\\n 0.65 \\\\\n -0.76 \\\\\n 1.44 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.88 \\\\\n -0.157 \\\\\n 0. \\\\\n 0.311 \\\\\n -0.48 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, -3, 3, 2],\n [0, -1, -2, 2, 1],\n [3, 3, 0, 0, -1],\n [-1, -2, 0, -3, -1],\n [2, -1, 1, 3, 0],\n [-3, -3, 2, -1, 3]])\nb = np.array([\n [-2.32],\n [0.66],\n [-2.38],\n [0.65],\n [-0.76],\n [1.44]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n 3 & \\frac{33}{5} & \\frac{91}{10} & \\frac{32}{5} & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, (33/5), (91/10), (32/5), -3]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & -8 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8,0\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -8],\n [0, 0]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{9}{5} \\\\\n \\frac{7}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{39}{10} \\\\\n \\frac{71}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{57}{10} \\\\\n \\frac{39}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/5)],\n [(7/10)]])\nb = np.array([\n [(39/10)],\n [(71/10)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{83}{10} \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{103}{10}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(83/10)],\n [-2]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -3 \\\\\n 3 \\\\\n 2 \\\\\n -2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{31}} \\\\\n -\\frac{3}{\\sqrt{31}} \\\\\n \\frac{3}{\\sqrt{31}} \\\\\n \\frac{2}{\\sqrt{31}} \\\\\n -\\frac{2}{\\sqrt{31}} \\\\\n -\\frac{2}{\\sqrt{31}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-3],\n [3],\n [2],\n [-2],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -3 & -10 & 0 & -10 & -2 \\\\\n 4 & 8 & 7 & 8 & -2 \\\\\n -9 & -6 & -9 & 10 & 6 \\\\\n 3 & -6 & 3 & -2 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-238.,138.,184.,-117.,252.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, -10, 0, -10, -2],\n [4, 8, 7, 8, -2],\n [-9, -6, -9, 10, 6],\n [3, -6, 3, -2, 3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{60}{7} & \\frac{12}{7} \\\\\n \\frac{9}{7} & \\frac{38}{7} \\\\\n \\frac{6}{7} & -\\frac{23}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{65}{7} & -\\frac{61}{7} \\\\\n \\frac{40}{7} & \\frac{62}{7} \\\\\n -\\frac{4}{7} & \\frac{62}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{125}{7} & -7 \\\\\n 7 & \\frac{100}{7} \\\\\n \\frac{2}{7} & \\frac{39}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(60/7), (12/7)],\n [(9/7), (38/7)],\n [(6/7), -(23/7)]])\nb = np.array([\n [(65/7), -(61/7)],\n [(40/7), (62/7)],\n [-(4/7), (62/7)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 2 \\\\\n 2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 2 \\\\\n -6 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{122}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [2],\n [2],\n [-1]])\nb = np.array([\n [-2],\n [2],\n [-6],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -6 & -6 \\\\\n -7 & 7 \\\\\n 6 & 2 \\\\\n 8 & -7 \\\\\n 9 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -6],\n [-7, 7],\n [6, 2],\n [8, -7],\n [9, 1]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 5 \\\\\n 9 \\\\\n -7 \\\\\n 0 \\\\\n -3 \\\\\n 9 \\\\\n -3 \\\\\n 2 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 2 \\\\\n 5 \\\\\n -2 \\\\\n -10 \\\\\n 5 \\\\\n 2 \\\\\n -8 \\\\\n 0 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{553}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [5],\n [9],\n [-7],\n [0],\n [-3],\n [9],\n [-3],\n [2],\n [-10]])\nb = np.array([\n [-4],\n [2],\n [5],\n [-2],\n [-10],\n [5],\n [2],\n [-8],\n [0],\n [5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & -\\frac{1}{2} \\\\\n \\frac{19}{8} & -\\frac{15}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{15}{13} & -\\frac{4}{13} \\\\\n \\frac{19}{13} & -\\frac{12}{13} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), -(1/2)],\n [(19/8), -(15/8)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -5 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -8 \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 6 \\\\\n 12 \\\\\n 36 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-5],\n [2]])\nb = np.array([\n [4],\n [-8],\n [2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{3}{\\sqrt{10}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-8]]).squeeze()\nb = np.array([\n [8],\n [-4]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{4}{3} & -\\frac{8}{3} & -\\frac{2}{3} & -2 & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -\\frac{5}{3} \\\\\n -\\frac{1}{3} \\\\\n 2 \\\\\n \\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{20}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3), -(8/3), -(2/3), -2, (2/3)]])\nb = np.array([\n [1],\n [-(5/3)],\n [-(1/3)],\n [2],\n [(1/3)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{1}{10}, \\frac{49}{10}}$ to the line $\\frac{17 x}{5}-\\frac{24 y}{5}-\\frac{9}{5}=0$.", - "Output Answer": [ - "$\\frac{1283}{10 \\sqrt{865}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(1/10), (49/10)\nline = Poly(((17*x)/5)-((24*y)/5)-(9/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{29}{3} \\\\\n -\\frac{10}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$13$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/3)],\n [-(10/3)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{5} & -\\frac{28}{5} & -\\frac{18}{5} \\\\\n \\frac{8}{5} & 1 & -\\frac{3}{5} \\\\\n \\frac{41}{5} & -\\frac{17}{5} & -\\frac{39}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.694,-0.701,1.\\}, \\{0.53\\, -0.48 i,0.054\\, +0.115 i,1.\\}, \\{0.53\\, +0.48 i,0.054\\, -0.115 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/5), -(28/5), -(18/5)],\n [(8/5), 1, -(3/5)],\n [(41/5), -(17/5), -(39/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & -8 & 5 \\\\\n 7 & -7 & 0 \\\\\n -5 & 0 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.064,0.651,1.\\}, \\{-0.232-1.759 i,-1.363-0.15 i,1.\\}, \\{-0.232+1.759 i,-1.363+0.15 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -8, 5],\n [7, -7, 0],\n [-5, 0, -6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -3 \\\\\n 8 \\\\\n -8 \\\\\n 5 \\\\\n 7 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{301}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-3],\n [8],\n [-8],\n [5],\n [7],\n [-9]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{3}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -5 & -8 & -2 & 7 \\\\\n 2 & 3 & -9 & 8 \\\\\n -4 & -8 & 3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{25}{3} & \\frac{40}{3} & \\frac{10}{3} & -\\frac{35}{3} \\\\\n -\\frac{10}{3} & -5 & 15 & -\\frac{40}{3} \\\\\n \\frac{20}{3} & \\frac{40}{3} & -5 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -8, -2, 7],\n [2, 3, -9, 8],\n [-4, -8, 3, 3]])\nprint(a * -(5/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -6 & 5 & 4 & 7 \\\\\n 7 & -8 & -3 & -5 \\\\\n -4 & 1 & 1 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 5, 4, 7],\n [7, -8, -3, -5],\n [-4, 1, 1, 9]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & -2 & 1 \\\\\n -1 & -2 & 3 \\\\\n -3 & -2 & -2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & 2 & -8 \\\\\n -7 & 0 & -13 \\\\\n 8 & 14 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2, 1],\n [-1, -2, 3],\n [-3, -2, -2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & 5 \\\\\n -5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-4-3 i,5\\}, \\{-4+3 i,5\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 5],\n [-5, -4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -5 \\\\\n 9 \\\\\n 5 \\\\\n 7 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$33$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-5],\n [9],\n [5],\n [7],\n [3]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{7} & \\frac{9}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{3}{7} & \\frac{9}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1]])\nb = np.array([\n [-(3/7), (9/7)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & -2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n e & 0 & 0 \\\\\n 0 & e & 0 \\\\\n 0 & \\frac{1-e^2}{e} & \\frac{1}{e} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [1, 0, 0],\n [0, 1, 0],\n [0, -2, -1]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -3 \\\\\n 6 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -5 \\\\\n 7 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(4 \\sqrt{\\frac{22}{455}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-3],\n [6],\n [8]]).squeeze()\nb = np.array([\n [1],\n [-5],\n [7],\n [4]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 2 & 2 \\\\\n \\frac{3}{2} & 2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 7 & 8 \\\\\n 6 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2],\n [(3/2), 2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,-3,-1\\}, \\{2,-5,4\\}, \\{-2,3,3\\}}$.", - "Output Answer": [ - "$38 x+21 y+16 z-35=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, -3, -1],\n [2, -5, 4],\n [-2, 3, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n \\frac{33}{4} \\\\\n 3 \\\\\n 4 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{125}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [(33/4)],\n [3],\n [4],\n [9]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{7}{3} & -4 & -\\frac{4}{3} \\\\\n \\frac{8}{3} & -1 & -1 \\\\\n 3 & \\frac{7}{3} & -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{63}{193} & \\frac{168}{193} & -\\frac{36}{193} \\\\\n -\\frac{87}{386} & \\frac{39}{386} & \\frac{33}{386} \\\\\n -\\frac{249}{386} & \\frac{471}{386} & -\\frac{225}{386} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/3), -4, -(4/3)],\n [(8/3), -1, -1],\n [3, (7/3), -(7/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -1 & 2 & 0 \\\\\n 4 & -2 & -3 \\\\\n -3 & 2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & 0 & -\\frac{1}{2} \\\\\n \\frac{3}{4} & 0 & -\\frac{1}{4} \\\\\n \\frac{1}{6} & -\\frac{1}{3} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2, 0],\n [4, -2, -3],\n [-3, 2, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 0 \\\\\n -2 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -3 \\\\\n 3 \\\\\n 2 \\\\\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{7}{31},\\frac{21}{31},-\\frac{21}{31},-\\frac{14}{31},-\\frac{14}{31},-\\frac{14}{31}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [0],\n [-2],\n [0],\n [0],\n [1]]).squeeze()\nb = np.array([\n [1],\n [-3],\n [3],\n [2],\n [2],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{5}{2} & -\\frac{5}{2} & -2 & -2 & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{1}{2} & \\frac{5}{2} & \\frac{5}{2} & 0 & 1 \\\\\n \\frac{3}{2} & 1 & -\\frac{5}{2} & -1 & -\\frac{1}{2} \\\\\n \\frac{3}{2} & \\frac{5}{2} & -\\frac{1}{2} & 0 & -1 \\\\\n \\frac{3}{2} & \\frac{3}{2} & -\\frac{1}{2} & 2 & -3 \\\\\n -1 & -\\frac{1}{2} & -\\frac{1}{2} & -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -\\frac{23}{2} & -\\frac{9}{2} & \\frac{57}{4} & -2 & \\frac{53}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), -(5/2), -2, -2, (1/2)]])\nb = np.array([\n [-(1/2), (5/2), (5/2), 0, 1],\n [(3/2), 1, -(5/2), -1, -(1/2)],\n [(3/2), (5/2), -(1/2), 0, -1],\n [(3/2), (3/2), -(1/2), 2, -3],\n [-1, -(1/2), -(1/2), -1, 3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{3}{5}, \\frac{17}{5}, \\frac{21}{5}}$ to the plane $4 x-\\frac{6 y}{5}-2 z+\\frac{22}{5}=0$.", - "Output Answer": [ - "$\\frac{71}{5 \\sqrt{134}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (3/5), (17/5), (21/5)\nplane = Poly(4*x-((6*y)/5)-2*z+(22/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & \\frac{3}{2} \\\\\n -\\frac{19}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{4} \\left(9-i \\sqrt{227}\\right),\\frac{1}{4} \\left(9+i \\sqrt{227}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, (3/2)],\n [-(19/2), (5/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{19}{4} & \\frac{5}{4} \\\\\n 10 & \\frac{7}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{4} \\left(13-2 \\sqrt{59}\\right),\\frac{1}{4} \\left(13+2 \\sqrt{59}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/4), (5/4)],\n [10, (7/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n -3 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 0 \\\\\n -1 \\\\\n -2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{13}{6},0,-\\frac{13}{18},-\\frac{13}{9},-\\frac{13}{9}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [0],\n [0],\n [1],\n [-3]]).squeeze()\nb = np.array([\n [3],\n [0],\n [-1],\n [-2],\n [-2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{5}{2} \\\\\n -\\frac{3}{2} \\\\\n \\frac{5}{2} \\\\\n -1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{4}{\\sqrt{95}} \\\\\n \\sqrt{\\frac{5}{19}} \\\\\n -\\frac{3}{\\sqrt{95}} \\\\\n \\sqrt{\\frac{5}{19}} \\\\\n -\\frac{2}{\\sqrt{95}} \\\\\n -\\frac{4}{\\sqrt{95}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [(5/2)],\n [-(3/2)],\n [(5/2)],\n [-1],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 0 \\\\\n 2 & -2 \\\\\n 1 & 1 \\\\\n 2 & 1 \\\\\n -1 & -1 \\\\\n 3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.54 \\\\\n 0.43 \\\\\n -0.44 \\\\\n -1.17 \\\\\n -2.64 \\\\\n 2.55 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.103 \\\\\n 0.431 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 0],\n [2, -2],\n [1, 1],\n [2, 1],\n [-1, -1],\n [3, 3]])\nb = np.array([\n [-0.54],\n [0.43],\n [-0.44],\n [-1.17],\n [-2.64],\n [2.55]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -2 & -3 & 2 & -2 \\\\\n -3 & 0 & 1 & 2 \\\\\n -3 & 2 & 3 & 3 \\\\\n -2 & -1 & 1 & -2 \\\\\n 3 & 1 & -2 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.93 \\\\\n -2.03 \\\\\n -1.69 \\\\\n -1.37 \\\\\n 0.77 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.408 \\\\\n -1.318 \\\\\n 1.329 \\\\\n 0.418 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, 2, -2],\n [-3, 0, 1, 2],\n [-3, 2, 3, 3],\n [-2, -1, 1, -2],\n [3, 1, -2, 2]])\nb = np.array([\n [2.93],\n [-2.03],\n [-1.69],\n [-1.37],\n [0.77]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{4} \\\\\n -\\frac{29}{4} \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -3 \\\\\n -\\frac{11}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{65}{32} \\\\\n \\frac{91}{32} \\\\\n -\\frac{13}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/4)],\n [-(29/4)],\n [-4]])\nb = np.array([\n [-2],\n [-3],\n [-(11/8)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{6}{5}, -\\frac{13}{5}, \\frac{11}{5}}$ to the plane $\\frac{2 x}{5}-\\frac{14 y}{5}+\\frac{9 z}{5}-3=0$.", - "Output Answer": [ - "$\\frac{194}{5 \\sqrt{281}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(6/5), -(13/5), (11/5)\nplane = Poly(((2*x)/5)-((14*y)/5)+((9*z)/5)-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{15}{2}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 9 & 2 & 9 \\\\\n 0 & 10 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{135}{2} & 15 & \\frac{135}{2} \\\\\n 0 & 75 & -\\frac{135}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 2, 9],\n [0, 10, -9]])\nprint(a * (15/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-19$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-4]])\nb = np.array([\n [5],\n [6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{1,\\frac{11}{3},-3\\right\\}, \\left\\{\\frac{13}{3},\\frac{5}{3},\\frac{14}{3}\\right\\}, \\left\\{\\frac{8}{3},3,\\frac{1}{3}\\right\\}}$.", - "Output Answer": [ - "$14 x-15 y-10 z+11=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, (11/3), -3],\n [(13/3), (5/3), (14/3)],\n [(8/3), 3, (1/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{13}{9} & \\frac{14}{9} \\\\\n \\frac{40}{9} & -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{27}{31} & \\frac{63}{124} \\\\\n \\frac{45}{31} & \\frac{117}{248} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/9), (14/9)],\n [(40/9), -(8/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & 3 \\\\\n 2 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1,2\\}, \\{3,1\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 3],\n [2, -7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{22}{3} & -\\frac{8}{3} & -\\frac{26}{3} \\\\\n \\frac{23}{3} & -9 & -1 \\\\\n 1 & -\\frac{7}{3} & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.915,-0.963,1.\\}, \\{1.303\\, -2.683 i,3.486\\, +1.408 i,1.\\}, \\{1.303\\, +2.683 i,3.486\\, -1.408 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(22/3), -(8/3), -(26/3)],\n [(23/3), -9, -1],\n [1, -(7/3), -2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n \\frac{19}{2} & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/2), -(7/2)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 2 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{4} \\\\\n -\\frac{1}{4} \\\\\n \\frac{1}{4} \\\\\n \\frac{1}{2} \\\\\n -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [1],\n [2],\n [-3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 1 & 2 \\\\\n -2 & 3 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -3 & 8 \\\\\n -8 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2],\n [-2, 3]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 2 \\\\\n -1 \\\\\n 2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n 1 \\\\\n 1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{6}{11},\\frac{12}{11},\\frac{6}{11},\\frac{6}{11},-\\frac{12}{11}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [2],\n [-1],\n [2],\n [-1]]).squeeze()\nb = np.array([\n [1],\n [2],\n [1],\n [1],\n [-2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -\\frac{5}{2} \\\\\n \\frac{3}{2} \\\\\n 2 \\\\\n \\frac{5}{2} \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2}{\\sqrt{83}} \\\\\n -\\frac{5}{\\sqrt{83}} \\\\\n \\frac{3}{\\sqrt{83}} \\\\\n \\frac{4}{\\sqrt{83}} \\\\\n \\frac{5}{\\sqrt{83}} \\\\\n -\\frac{2}{\\sqrt{83}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-(5/2)],\n [(3/2)],\n [2],\n [(5/2)],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n -\\frac{23}{7} \\\\\n -\\frac{38}{7} \\\\\n \\frac{58}{7} \\\\\n -\\frac{27}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{62}{7} \\\\\n -\\frac{19}{7} \\\\\n \\frac{1}{7} \\\\\n \\frac{39}{7} \\\\\n -\\frac{24}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{7649}{49}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [-(23/7)],\n [-(38/7)],\n [(58/7)],\n [-(27/7)]])\nb = np.array([\n [-(62/7)],\n [-(19/7)],\n [(1/7)],\n [(39/7)],\n [-(24/7)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{5,2,-4\\}, \\{3,-2,0\\}, \\{4,4,-2\\}}$.", - "Output Answer": [ - "$2 x+z-6=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [5, 2, -4],\n [3, -2, 0],\n [4, 4, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{89}{10} \\\\\n \\frac{1}{5} \\\\\n -\\frac{31}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{87}{10} \\\\\n -\\frac{42}{5} \\\\\n -\\frac{19}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2623}{50} \\\\\n -\\frac{3703}{100} \\\\\n -\\frac{153}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(89/10)],\n [(1/5)],\n [-(31/5)]])\nb = np.array([\n [(87/10)],\n [-(42/5)],\n [-(19/10)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [-1],\n [1],\n [-1],\n [0],\n [1],\n [1],\n [0]]).squeeze()\nb = np.array([\n [0],\n [-1],\n [-1],\n [-1],\n [1],\n [-1],\n [0],\n [0],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${4, -2}$ to the line $-x-4 y+4=0$.", - "Output Answer": [ - "$\\frac{8}{\\sqrt{17}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 4, -2\nline = Poly(-x-4*y+4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 9 & 5 & 1 & 8 \\\\\n 7 & 1 & -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-7.,-29.,0.,26.\\}, \\{3.,-8.,13.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, 5, 1, 8],\n [7, 1, -1, 3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{27}{4} & -\\frac{9}{2} & \\frac{19}{2} \\\\\n \\frac{23}{4} & -4 & \\frac{1}{4} \\\\\n -\\frac{1}{2} & \\frac{29}{4} & \\frac{29}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{7 x^2}{2}+\\frac{177 x}{8}+\\frac{49483}{64}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(27/4), -(9/2), (19/2)],\n [(23/4), -4, (1/4)],\n [-(1/2), (29/4), (29/4)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$12$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [3]])\nb = np.array([\n [6],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 2 & 1 & 4 \\\\\n 6 & 2 & -3 \\\\\n -9 & 1 & -9 \\\\\n 4 & -6 & 4 \\\\\n 10 & 5 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, 1, 4],\n [6, 2, -3],\n [-9, 1, -9],\n [4, -6, 4],\n [10, 5, -8]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 3 & 3 & 2 \\\\\n -4 & -8 & 9 \\\\\n -1 & -10 & 1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -1 & 3 & 8 \\\\\n -4 & -3 & -8 \\\\\n 9 & 4 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 4 & 0 & -6 \\\\\n 0 & -5 & 17 \\\\\n -10 & -14 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3, 2],\n [-4, -8, 9],\n [-1, -10, 1]])\nb = np.array([\n [-1, 3, 8],\n [-4, -3, -8],\n [9, 4, -7]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{9}{2} & -\\frac{17}{8} & -\\frac{15}{8} \\\\\n \\frac{29}{8} & \\frac{5}{4} & 2 \\\\\n \\frac{5}{2} & -\\frac{31}{8} & -\\frac{19}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{928}{11865} & \\frac{1448}{11865} & \\frac{976}{11865} \\\\\n -\\frac{3792}{3955} & -\\frac{4448}{3955} & -\\frac{376}{3955} \\\\\n \\frac{1256}{1695} & \\frac{1664}{1695} & -\\frac{152}{1695} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2), -(17/8), -(15/8)],\n [(29/8), (5/4), 2],\n [(5/2), -(31/8), -(19/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -10 & -7 & -4 \\\\\n -4 & 0 & 5 \\\\\n -9 & 2 & 0 \\\\\n 8 & 5 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, -7, -4],\n [-4, 0, 5],\n [-9, 2, 0],\n [8, 5, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -8 & 2 & 7 & 1 \\\\\n -1 & -5 & 7 & -9 \\\\\n 10 & -7 & -5 & -7 \\\\\n 4 & -7 & 2 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-8, 2, 7, 1],\n [-1, -5, 7, -9],\n [10, -7, -5, -7],\n [4, -7, 2, 7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 0 & -1 & 6 & 8 & -9 & 6 \\\\\n 10 & 3 & 3 & 5 & 5 & 2 \\\\\n 0 & 9 & 7 & 8 & -1 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & \\frac{89}{610} & \\frac{38}{61} & \\frac{106}{305} \\\\\n 0 & 1 & 0 & -\\frac{8}{61} & \\frac{57}{61} & -\\frac{78}{61} \\\\\n 0 & 0 & 1 & \\frac{80}{61} & -\\frac{82}{61} & \\frac{48}{61} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, -1, 6, 8, -9, 6],\n [10, 3, 3, 5, 5, 2],\n [0, 9, 7, 8, -1, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & 0 & 7 \\\\\n 4 & 9 & 10 \\\\\n 9 & -7 & -9 \\\\\n 5 & -7 & 0 \\\\\n 0 & 10 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, 0, 7],\n [4, 9, 10],\n [9, -7, -9],\n [5, -7, 0],\n [0, 10, 1]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 5 & -9 & -2 \\\\\n 8 & -6 & 4 \\\\\n -4 & 8 & -10 \\\\\n -1 & -9 & 0 \\\\\n -10 & -4 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, -9, -2],\n [8, -6, 4],\n [-4, 8, -10],\n [-1, -9, 0],\n [-10, -4, 4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & -1 & -1 \\\\\n 0 & -2 & 1 \\\\\n 0 & 0 & -2 \\\\\n -3 & -3 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.87 \\\\\n -1.4 \\\\\n 0.68 \\\\\n 2.84 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.825 \\\\\n 0.152 \\\\\n -0.601 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1, -1],\n [0, -2, 1],\n [0, 0, -2],\n [-3, -3, -1]])\nb = np.array([\n [-0.87],\n [-1.4],\n [0.68],\n [2.84]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 4 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n 0 \\\\\n 3 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n -4 \\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n 2 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$45$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [0],\n [4*math.sqrt(3)],\n [4*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [0],\n [3*math.sqrt(3)]])\nb = np.array([\n [-3*math.sqrt(3)],\n [4*math.sqrt(3)],\n [3*math.sqrt(3)],\n [-4*math.sqrt(3)],\n [-2*math.sqrt(3)],\n [2*math.sqrt(3)],\n [3*math.sqrt(3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & 6 \\\\\n -6 & -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+18 x+116$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 6],\n [-6, -10]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & 5 & 7 \\\\\n 5 & 9 & -6 \\\\\n -9 & -1 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{6.377\\, -6.738 i,6.377\\, +6.738 i,13.246\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 5, 7],\n [5, 9, -6],\n [-9, -1, 10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 4 & -1 & 2 \\\\\n 4 & -5 & 10 \\\\\n 6 & -7 & -4 \\\\\n 7 & 8 & 6 \\\\\n -1 & -7 & -3 \\\\\n 5 & -1 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, -1, 2],\n [4, -5, 10],\n [6, -7, -4],\n [7, 8, 6],\n [-1, -7, -3],\n [5, -1, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -1 & 3 & 1 & -2 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -2 & -2 & 3 & 1 & 2 \\\\\n 0 & -3 & 2 & 2 & 0 \\\\\n 2 & 1 & -1 & 2 & -3 \\\\\n -3 & 2 & -3 & -1 & 2 \\\\\n -3 & 2 & 3 & 3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 7 & -8 & 11 & 12 & -10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, 1, -2, 1]])\nb = np.array([\n [-2, -2, 3, 1, 2],\n [0, -3, 2, 2, 0],\n [2, 1, -1, 2, -3],\n [-3, 2, -3, -1, 2],\n [-3, 2, 3, 3, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 0 & -9 & 8 \\\\\n -8 & -2 & -4 \\\\\n 2 & 8 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+60 x-552$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -9, 8],\n [-8, -2, -4],\n [2, 8, 2]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{1,1,3\\}, \\{-2,2,-2\\}, \\{-1,-3,2\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{11}},\\frac{1}{\\sqrt{11}},\\frac{3}{\\sqrt{11}}\\right\\}, \\left\\{-2 \\sqrt{\\frac{2}{33}},\\frac{7}{\\sqrt{66}},-\\frac{1}{\\sqrt{66}}\\right\\}, \\left\\{-\\sqrt{\\frac{2}{3}},-\\frac{1}{\\sqrt{6}},\\frac{1}{\\sqrt{6}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((1, 1, 3), (-2, 2, -2), (-1, -3, 2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-1$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -10 & 7 \\\\\n 3 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 10 & -7 \\\\\n -3 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 7],\n [3, -7]])\nprint(a * -1)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 7 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -8 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -89 \\\\\n -25 \\\\\n -35 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [7],\n [-5]])\nb = np.array([\n [5],\n [-8],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{5} & \\frac{9}{5} \\\\\n -8 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(-43-3 \\sqrt{201}\\right),\\frac{1}{10} \\left(3 \\sqrt{201}-43\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/5), (9/5)],\n [-8, -10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{16}{3} \\\\\n \\frac{25}{3} \\\\\n \\frac{1}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{41}{6} \\\\\n \\frac{29}{3} \\\\\n -\\frac{19}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1483}{18} \\\\\n -\\frac{871}{18} \\\\\n -\\frac{217}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(16/3)],\n [(25/3)],\n [(1/3)]])\nb = np.array([\n [(41/6)],\n [(29/3)],\n [-(19/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & 1 & 0 \\\\\n -3 & 2 & 2 \\\\\n 1 & -1 & -3 \\\\\n -1 & 2 & 0 \\\\\n 3 & -2 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.71 \\\\\n -0.44 \\\\\n -1.52 \\\\\n -0.56 \\\\\n -0.85 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.496 \\\\\n 0.25 \\\\\n 0.492 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 1, 0],\n [-3, 2, 2],\n [1, -1, -3],\n [-1, 2, 0],\n [3, -2, 0]])\nb = np.array([\n [-2.71],\n [-0.44],\n [-1.52],\n [-0.56],\n [-0.85]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 9 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 0 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -45 \\\\\n -75 \\\\\n 45 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [9],\n [9]])\nb = np.array([\n [-5],\n [0],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & 9 & 0 \\\\\n -1 & -5 & 1 \\\\\n 5 & 0 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.518,1.786,1.\\}, \\{-0.353,0.187,1.\\}, \\{0.671,0.027,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 9, 0],\n [-1, -5, 1],\n [5, 0, 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -4 & -2 \\\\\n 1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-14$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -2],\n [1, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2}-2 i & -3+4 i \\\\\n -\\frac{5}{2}-i & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{31}{4}-5 i & 23-14 i \\\\\n \\frac{21}{2}+10 i & \\frac{127}{4}-7 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2)-2j, -3+4j],\n [-(5/2)- 1j, -(9/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 7 & 2 & 0 & 4 & -6 \\\\\n -6 & 7 & 3 & 8 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & -\\frac{6}{61} & \\frac{12}{61} & -\\frac{46}{61} \\\\\n 0 & 1 & \\frac{21}{61} & \\frac{80}{61} & -\\frac{22}{61} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, 2, 0, 4, -6],\n [-6, 7, 3, 8, 2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & 2 & 5 \\\\\n 1 & -2 & -2 \\\\\n -2 & 3 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$25$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, 5],\n [1, -2, -2],\n [-2, 3, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -10 & 4 & 3 & 7 \\\\\n -1 & -7 & 8 & -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -10 & 1 & 2 & -7 \\\\\n 5 & -3 & 2 & -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -20 & 5 & 5 & 0 \\\\\n 4 & -10 & 10 & -18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 4, 3, 7],\n [-1, -7, 8, -8]])\nb = np.array([\n [-10, 1, 2, -7],\n [5, -3, 2, -10]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 2 \\\\\n 4 \\\\\n 2 \\\\\n 8 \\\\\n -6 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 10 \\\\\n -8 \\\\\n 8 \\\\\n 1 \\\\\n 9 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-91$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [2],\n [4],\n [2],\n [8],\n [-6],\n [-1]])\nb = np.array([\n [-8],\n [10],\n [-8],\n [8],\n [1],\n [9],\n [9]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-3,-1,-1\\}, \\{1,1,2\\}, \\{0,-1,3\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{3}{\\sqrt{11}},-\\frac{1}{\\sqrt{11}},-\\frac{1}{\\sqrt{11}}\\right\\}, \\left\\{-\\frac{7}{\\sqrt{330}},\\sqrt{\\frac{5}{66}},8 \\sqrt{\\frac{2}{165}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{30}},-\\sqrt{\\frac{5}{6}},\\sqrt{\\frac{2}{15}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-3, -1, -1), (1, 1, 2), (0, -1, 3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 0 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -6 \\\\\n 0 \\\\\n -4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [0],\n [2],\n [1]])\nb = np.array([\n [-2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -\\frac{71}{10} \\\\\n -\\frac{67}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(71/10)],\n [-(67/10)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 2 \\\\\n 1 \\\\\n -3 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 0 \\\\\n 0 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{0,0,0,0\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [2],\n [1],\n [-3]]).squeeze()\nb = np.array([\n [-2],\n [0],\n [0],\n [-2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{9}{10}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{27}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6]])\nprint(a * -(9/10))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 2 \\\\\n -2 \\\\\n 8 \\\\\n 5 \\\\\n -6 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 4 \\\\\n 0 \\\\\n 3 \\\\\n -1 \\\\\n 3 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$52$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [2],\n [-2],\n [8],\n [5],\n [-6],\n [7]])\nb = np.array([\n [-3],\n [4],\n [0],\n [3],\n [-1],\n [3],\n [7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3.5 \\\\\n 8.7 \\\\\n 7.11 \\\\\n 0.39 \\\\\n 7.21 \\\\\n 3.78 \\\\\n 4.13 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -0.86 \\\\\n -5.65 \\\\\n 0.71 \\\\\n -6.28 \\\\\n 6.68 \\\\\n 8.79 \\\\\n -4.23 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$20.1408$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3.5],\n [8.7],\n [7.11],\n [0.39],\n [7.21],\n [3.78],\n [4.13]])\nb = np.array([\n [-0.86],\n [-5.65],\n [0.71],\n [-6.28],\n [6.68],\n [8.79],\n [-4.23]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & -3 \\\\\n 0 & -1 \\\\\n -1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.74 \\\\\n -1.33 \\\\\n 2.82 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.47 \\\\\n -0.457 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -3],\n [0, -1],\n [-1, -1]])\nb = np.array([\n [-2.74],\n [-1.33],\n [2.82]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{65}{7} & \\frac{19}{7} & 6 & -\\frac{57}{7} \\\\\n -\\frac{55}{7} & \\frac{57}{7} & -\\frac{25}{7} & -\\frac{13}{7} \\\\\n \\frac{6}{7} & -\\frac{39}{7} & 2 & 8 \\\\\n \\frac{33}{7} & \\frac{20}{7} & \\frac{59}{7} & \\frac{55}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{66}{7} & \\frac{13}{7} & -\\frac{22}{7} & \\frac{41}{7} \\\\\n -\\frac{68}{7} & -\\frac{12}{7} & \\frac{59}{7} & \\frac{15}{7} \\\\\n \\frac{25}{7} & -10 & \\frac{44}{7} & -\\frac{10}{7} \\\\\n -\\frac{31}{7} & -\\frac{53}{7} & 9 & -\\frac{16}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{1}{7} & \\frac{6}{7} & \\frac{64}{7} & -14 \\\\\n \\frac{13}{7} & \\frac{69}{7} & -12 & -4 \\\\\n -\\frac{19}{7} & \\frac{31}{7} & -\\frac{30}{7} & \\frac{66}{7} \\\\\n \\frac{64}{7} & \\frac{73}{7} & -\\frac{4}{7} & \\frac{71}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(65/7), (19/7), 6, -(57/7)],\n [-(55/7), (57/7), -(25/7), -(13/7)],\n [(6/7), -(39/7), 2, 8],\n [(33/7), (20/7), (59/7), (55/7)]])\nb = np.array([\n [-(66/7), (13/7), -(22/7), (41/7)],\n [-(68/7), -(12/7), (59/7), (15/7)],\n [(25/7), -10, (44/7), -(10/7)],\n [-(31/7), -(53/7), 9, -(16/7)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7.3 \\\\\n 3.4 \\\\\n -4.7 \\\\\n -5.4 \\\\\n 8.8 \\\\\n 3.4 \\\\\n -5.8 \\\\\n 8.1 \\\\\n 9.6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3.4 \\\\\n -3.2 \\\\\n 1.4 \\\\\n 3.9 \\\\\n 1.4 \\\\\n 2.3 \\\\\n -7.5 \\\\\n 10. \\\\\n 6.7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$18.7784$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7.3],\n [3.4],\n [-4.7],\n [-5.4],\n [8.8],\n [3.4],\n [-5.8],\n [8.1],\n [9.6]])\nb = np.array([\n [-3.4],\n [-3.2],\n [1.4],\n [3.9],\n [1.4],\n [2.3],\n [-7.5],\n [10.],\n [6.7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -8 & -9 & -9 & -1 & 0 \\\\\n 1 & 1 & 7 & -6 & -9 \\\\\n 3 & -4 & -8 & -5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -9, -9, -1, 0],\n [1, 1, 7, -6, -9],\n [3, -4, -8, -5, -4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,0,-4\\}, \\{-3,4,-5\\}, \\left\\{\\frac{5}{2},-\\frac{9}{2},-3\\right\\}}$.", - "Output Answer": [ - "$x+11 y+44 z+179=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, 0, -4],\n [-3, 4, -5],\n [(5/2), -(9/2), -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\sqrt{2} \\\\\n 2 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\sqrt{2} \\\\\n 3 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{13}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [2*math.sqrt(2)],\n [2*math.sqrt(2)]])\nb = np.array([\n [-3*math.sqrt(2)],\n [3*math.sqrt(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{25}{4} & -\\frac{13}{2} & \\frac{5}{4} & 9 & 6 \\\\\n -2 & -10 & -2 & -\\frac{29}{4} & 2 \\\\\n -\\frac{39}{4} & \\frac{17}{2} & -\\frac{7}{4} & \\frac{35}{4} & \\frac{37}{4} \\\\\n \\frac{13}{4} & \\frac{5}{4} & -\\frac{11}{2} & \\frac{25}{4} & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/4), -(13/2), (5/4), 9, 6],\n [-2, -10, -2, -(29/4), 2],\n [-(39/4), (17/2), -(7/4), (35/4), (37/4)],\n [(13/4), (5/4), -(11/2), (25/4), -(7/2)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{17}{4} & \\frac{9}{4} & -\\frac{13}{4} \\\\\n \\frac{5}{2} & -\\frac{9}{4} & -\\frac{17}{4} \\\\\n \\frac{1}{2} & \\frac{13}{4} & \\frac{13}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{51} & \\frac{143}{204} & \\frac{45}{68} \\\\\n \\frac{41}{102} & -\\frac{247}{408} & -\\frac{53}{136} \\\\\n -\\frac{37}{102} & \\frac{203}{408} & \\frac{81}{136} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/4), (9/4), -(13/4)],\n [(5/2), -(9/4), -(17/4)],\n [(1/2), (13/4), (13/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 1 & -4 & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 1 & 4 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 2 & 0 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -4, 3]])\nb = np.array([\n [1, 4, -4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -4 & \\frac{5}{2} \\\\\n \\frac{1}{2} & \\frac{3}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 2 & \\frac{17}{4} \\\\\n \\frac{1}{4} & \\frac{11}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -2 & \\frac{27}{4} \\\\\n \\frac{3}{4} & \\frac{25}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, (5/2)],\n [(1/2), (3/4)]])\nb = np.array([\n [2, (17/4)],\n [(1/4), (11/2)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & -1 & -1 \\\\\n 1 & -2 & 2 \\\\\n -3 & 1 & -2 \\\\\n 1 & 1 & 1 \\\\\n 2 & 2 & 0 \\\\\n -1 & 2 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.43 \\\\\n -2.51 \\\\\n 0.82 \\\\\n -0.28 \\\\\n -1.01 \\\\\n 1.41 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.39 \\\\\n 0.453 \\\\\n -0.004 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1, -1],\n [1, -2, 2],\n [-3, 1, -2],\n [1, 1, 1],\n [2, 2, 0],\n [-1, 2, 3]])\nb = np.array([\n [-0.43],\n [-2.51],\n [0.82],\n [-0.28],\n [-1.01],\n [1.41]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -1 \\\\\n 2 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{\\sqrt{14}} \\\\\n -\\frac{1}{\\sqrt{14}} \\\\\n \\sqrt{\\frac{2}{7}} \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-1],\n [2],\n [0],\n [0]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 4 \\sqrt{2} \\\\\n \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\sqrt{2} \\\\\n 6 \\sqrt{2} \\\\\n 6 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$60$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [4*math.sqrt(2)],\n [math.sqrt(2)]])\nb = np.array([\n [6*math.sqrt(2)],\n [6*math.sqrt(2)],\n [6*math.sqrt(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8]])\nb = np.array([\n [-7]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & -\\frac{9}{2} & -\\frac{9}{4} \\\\\n \\frac{19}{4} & -\\frac{9}{4} & -\\frac{37}{4} \\\\\n -\\frac{3}{4} & \\frac{13}{2} & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{3.041,0.694,1.\\}, \\{-0.424-0.409 i,-0.317-1.274 i,1.\\}, \\{-0.424+0.409 i,-0.317+1.274 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -(9/2), -(9/4)],\n [(19/4), -(9/4), -(37/4)],\n [-(3/4), (13/2), 3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{14}{3} & -\\frac{19}{6} \\\\\n \\frac{23}{6} & \\frac{37}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{3 x}{2}-\\frac{599}{36}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(14/3), -(19/6)],\n [(23/6), (37/6)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{9}{64}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 4 & 7 & 0 & -3 \\\\\n 6 & 1 & 9 & -6 \\\\\n 5 & -6 & 1 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{9}{16} & -\\frac{63}{64} & 0 & \\frac{27}{64} \\\\\n -\\frac{27}{32} & -\\frac{9}{64} & -\\frac{81}{64} & \\frac{27}{32} \\\\\n -\\frac{45}{64} & \\frac{27}{32} & -\\frac{9}{64} & \\frac{9}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 7, 0, -3],\n [6, 1, 9, -6],\n [5, -6, 1, -8]])\nprint(a * -(9/64))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{8}{3} & \\frac{2}{3} & -\\frac{14}{3} \\\\\n \\frac{14}{3} & \\frac{4}{3} & \\frac{7}{3} \\\\\n -3 & -\\frac{1}{3} & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{610}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/3), (2/3), -(14/3)],\n [(14/3), (4/3), (7/3)],\n [-3, -(1/3), (2/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{34}{7} & 3 & -\\frac{22}{7} \\\\\n -\\frac{8}{7} & \\frac{25}{7} & \\frac{15}{7} \\\\\n -\\frac{32}{7} & -\\frac{11}{7} & \\frac{18}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{205}{2262} & \\frac{68}{3393} & -\\frac{865}{6786} \\\\\n \\frac{56}{1131} & \\frac{658}{3393} & -\\frac{343}{3393} \\\\\n -\\frac{148}{1131} & \\frac{523}{3393} & \\frac{341}{3393} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(34/7), 3, -(22/7)],\n [-(8/7), (25/7), (15/7)],\n [-(32/7), -(11/7), (18/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{18}{5} & 9 \\\\\n -\\frac{21}{5} & \\frac{26}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{21} i \\left(\\sqrt{461}-22 i\\right),1\\right\\}, \\left\\{-\\frac{1}{21} i \\left(\\sqrt{461}+22 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(18/5), 9],\n [-(21/5), (26/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{2,-3,-2\\}, \\left\\{-\\frac{9}{2},2,-1\\right\\}, \\{-4,4,2\\}}$.", - "Output Answer": [ - "$26 x+40 y-31 z+6=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, -3, -2],\n [-(9/2), 2, -1],\n [-4, 4, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -9 & -1 & 2 & 4 \\\\\n -5 & -6 & 10 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & -\\frac{2}{49} & -\\frac{3}{7} \\\\\n 0 & 1 & -\\frac{80}{49} & -\\frac{1}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-9, -1, 2, 4],\n [-5, -6, 10, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{37}{4} & -\\frac{9}{2} & \\frac{11}{2} \\\\\n 8 & -\\frac{31}{4} & 0 \\\\\n \\frac{19}{2} & \\frac{11}{4} & -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.401,0.441,1.\\}, \\{-0.882-0.181 i,1.043\\, -0.882 i,1.\\}, \\{-0.882+0.181 i,1.043\\, +0.882 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(37/4), -(9/2), (11/2)],\n [8, -(31/4), 0],\n [(19/2), (11/4), -(11/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{25}{3} \\\\\n \\frac{16}{3} \\\\\n -\\frac{8}{3} \\\\\n \\frac{10}{3} \\\\\n \\frac{2}{3} \\\\\n -8 \\\\\n 5 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{25}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(25/3)],\n [(16/3)],\n [-(8/3)],\n [(10/3)],\n [(2/3)],\n [-8],\n [5],\n [5]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -7 & 7 & -9 & -2 \\\\\n -5 & -2 & -4 & 6 \\\\\n -3 & 0 & 7 & -10 \\\\\n -1 & 4 & -3 & -9 \\\\\n -7 & -7 & -5 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 7, -9, -2],\n [-5, -2, -4, 6],\n [-3, 0, 7, -10],\n [-1, 4, -3, -9],\n [-7, -7, -5, -7]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n 0 \\\\\n 0 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{3}} \\\\\n -\\frac{1}{\\sqrt{3}} \\\\\n 0 \\\\\n 0 \\\\\n \\frac{1}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-2],\n [0],\n [0],\n [2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -1 & 2 \\\\\n 3 & -2 & 1 \\\\\n -3 & 0 & 0 \\\\\n 3 & 2 & -3 \\\\\n -1 & 3 & -2 \\\\\n 1 & -2 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.47 \\\\\n 2.24 \\\\\n 1.8 \\\\\n -1.96 \\\\\n 2.39 \\\\\n 0.54 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.285 \\\\\n -0.304 \\\\\n -0.232 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, 2],\n [3, -2, 1],\n [-3, 0, 0],\n [3, 2, -3],\n [-1, 3, -2],\n [1, -2, 0]])\nb = np.array([\n [-0.47],\n [2.24],\n [1.8],\n [-1.96],\n [2.39],\n [0.54]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & 1 & -3 & 1 \\\\\n 1 & 2 & -1 & 0 \\\\\n -2 & -2 & 0 & 3 \\\\\n 3 & 0 & 2 & 0 \\\\\n 0 & -2 & -2 & 0 \\\\\n 2 & -3 & 2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.48 \\\\\n -1.02 \\\\\n 0.67 \\\\\n 2.38 \\\\\n -2.76 \\\\\n 0.91 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.786 \\\\\n 0.028 \\\\\n 0.452 \\\\\n 0.715 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, -3, 1],\n [1, 2, -1, 0],\n [-2, -2, 0, 3],\n [3, 0, 2, 0],\n [0, -2, -2, 0],\n [2, -3, 2, -3]])\nb = np.array([\n [2.48],\n [-1.02],\n [0.67],\n [2.38],\n [-2.76],\n [0.91]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{3} & -\\frac{1}{3} & \\frac{23}{6} \\\\\n \\frac{10}{3} & -\\frac{10}{3} & \\frac{1}{6} \\\\\n -\\frac{9}{2} & -\\frac{29}{6} & -\\frac{1}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{21}{1846} & \\frac{2007}{12922} & -\\frac{687}{6461} \\\\\n \\frac{3}{1846} & -\\frac{267}{1846} & -\\frac{99}{923} \\\\\n \\frac{240}{923} & \\frac{6}{6461} & -\\frac{120}{6461} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/3), -(1/3), (23/6)],\n [(10/3), -(10/3), (1/6)],\n [-(9/2), -(29/6), -(1/6)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 3 \\\\\n 1 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -6 \\\\\n 10 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{347}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [3],\n [1],\n [5]])\nb = np.array([\n [4],\n [-6],\n [10],\n [-3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 3 & 2 & -2 & -3 \\\\\n -1 & -3 & 1 & 1 \\\\\n 1 & 3 & 0 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 2 & -1 \\\\\n 1 & 2 \\\\\n 2 & 1 \\\\\n -1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 7 & 8 \\\\\n -4 & -7 \\\\\n 5 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2, -2, -3],\n [-1, -3, 1, 1],\n [1, 3, 0, 0]])\nb = np.array([\n [2, -1],\n [1, 2],\n [2, 1],\n [-1, -3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & -2 & -2 \\\\\n -1 & -3 & -2 \\\\\n -2 & -2 & -3 \\\\\n 3 & -1 & 2 \\\\\n 3 & 1 & 2 \\\\\n -2 & -2 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.08 \\\\\n 2.39 \\\\\n 1.03 \\\\\n 2.12 \\\\\n 2.17 \\\\\n -1.8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.646 \\\\\n -0.409 \\\\\n -0.297 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2, -2],\n [-1, -3, -2],\n [-2, -2, -3],\n [3, -1, 2],\n [3, 1, 2],\n [-2, -2, 2]])\nb = np.array([\n [2.08],\n [2.39],\n [1.03],\n [2.12],\n [2.17],\n [-1.8]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -8 \\\\\n 9 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{185}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-8],\n [9],\n [-6]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{3 \\log (2),\\log (2),-\\log (2)\\}, \\{\\log (2),2 \\log (2),4 \\log (2)\\}, \\{-4 \\log (2),-2 \\log (2),0\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{3}{\\sqrt{11}},\\frac{1}{\\sqrt{11}},-\\frac{1}{\\sqrt{11}}\\right\\}, \\left\\{4 \\sqrt{\\frac{2}{1265}},\\frac{21}{\\sqrt{2530}},9 \\sqrt{\\frac{5}{506}}\\right\\}, \\left\\{3 \\sqrt{\\frac{2}{115}},-\\frac{13}{\\sqrt{230}},\\sqrt{\\frac{5}{46}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((3*math.log(2), math.log(2), -math.log(2)), (math.log(2), 2*math.log(2), 4*math.log(2)), (-4*math.log(2), -2*math.log(2), 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 10 & 0 & 9 \\\\\n 4 & -5 & 1 \\\\\n 5 & 7 & -4 \\\\\n 0 & 3 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -9 & 8 & 9 \\\\\n 10 & 3 & -6 \\\\\n 3 & 1 & -8 \\\\\n 7 & 8 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 8 & 18 \\\\\n 14 & -2 & -5 \\\\\n 8 & 8 & -12 \\\\\n 7 & 11 & 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 0, 9],\n [4, -5, 1],\n [5, 7, -4],\n [0, 3, 8]])\nb = np.array([\n [-9, 8, 9],\n [10, 3, -6],\n [3, 1, -8],\n [7, 8, 3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{4,3,3\\}, \\left\\{3,-2,-\\frac{5}{2}\\right\\}, \\left\\{\\frac{3}{2},4,1\\right\\}}$.", - "Output Answer": [ - "$62 x+47 y-54 z-227=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, 3, 3],\n [3, -2, -(5/2)],\n [(3/2), 4, 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n 2 & 0 & 0 & 0 \\\\\n 0 & 0 & -2 & -2 \\\\\n 2 & 0 & 0 & 0 \\\\\n -2 & 0 & 2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n e^2 & 0 & 0 & 0 \\\\\n 0 & 1 & 1-e^2 & 1-e^2 \\\\\n e^2-1 & 0 & 1 & 0 \\\\\n 1-e^2 & 0 & e^2-1 & e^2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [2, 0, 0, 0],\n [0, 0, -2, -2],\n [2, 0, 0, 0],\n [-2, 0, 2, 2]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,0,1\\}, \\{-3,4,1\\}, \\{5,-3,-2\\}}$.", - "Output Answer": [ - "$12 x+9 y+11 z-11=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, 0, 1],\n [-3, 4, 1],\n [5, -3, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{2} & -\\frac{19}{2} \\\\\n \\frac{13}{2} & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{4} \\left(17-i \\sqrt{939}\\right),\\frac{1}{4} \\left(17+i \\sqrt{939}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), -(19/2)],\n [(13/2), 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -2 & 6 & -6 & 4 & -6 \\\\\n -7 & 7 & 9 & -10 & -6 \\\\\n 7 & 3 & -8 & 7 & -5 \\\\\n 10 & 1 & -7 & 2 & -8 \\\\\n -1 & 7 & 4 & 0 & 2 \\\\\n -7 & -7 & 7 & 2 & 6 \\\\\n 10 & -5 & -4 & -7 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, 6, -6, 4, -6],\n [-7, 7, 9, -10, -6],\n [7, 3, -8, 7, -5],\n [10, 1, -7, 2, -8],\n [-1, 7, 4, 0, 2],\n [-7, -7, 7, 2, 6],\n [10, -5, -4, -7, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,0,1\\}, \\left\\{1,-\\frac{5}{2},-\\frac{3}{2}\\right\\}, \\{3,2,3\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{2}{\\sqrt{5}},0,\\frac{1}{\\sqrt{5}}\\right\\}, \\left\\{\\frac{8}{3 \\sqrt{105}},-\\frac{5 \\sqrt{\\frac{5}{21}}}{3},-\\frac{16}{3 \\sqrt{105}}\\right\\}, \\left\\{\\frac{5}{3 \\sqrt{21}},\\frac{8}{3 \\sqrt{21}},-\\frac{10}{3 \\sqrt{21}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, 0, 1), (1, -(5/2), -(3/2)), (3, 2, 3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 4 & -8 \\\\\n 7 & 1 \\\\\n 2 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, -8],\n [7, 1],\n [2, -8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{18}{5} & \\frac{13}{5} & -\\frac{23}{5} \\\\\n -\\frac{27}{5} & -\\frac{2}{5} & -\\frac{13}{5} \\\\\n -\\frac{12}{5} & \\frac{34}{5} & \\frac{22}{5} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -8 & 7 & -8 \\\\\n \\frac{16}{5} & -\\frac{39}{5} & -\\frac{31}{5} \\\\\n \\frac{8}{5} & -\\frac{36}{5} & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{58}{5} & -\\frac{22}{5} & \\frac{17}{5} \\\\\n -\\frac{43}{5} & \\frac{37}{5} & \\frac{18}{5} \\\\\n -4 & 14 & \\frac{12}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(18/5), (13/5), -(23/5)],\n [-(27/5), -(2/5), -(13/5)],\n [-(12/5), (34/5), (22/5)]])\nb = np.array([\n [-8, 7, -8],\n [(16/5), -(39/5), -(31/5)],\n [(8/5), -(36/5), 2]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -1 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -6 \\\\\n 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 39 \\\\\n -50 \\\\\n -35 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-1],\n [7]])\nb = np.array([\n [-5],\n [-6],\n [3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 8 & 1 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 9 & 0 & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, 2]])\nb = np.array([\n [8, 1, -9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{2} & 5 \\\\\n \\frac{11}{2} & \\frac{11}{2} \\\\\n -7 & 3 \\\\\n -9 & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), 5],\n [(11/2), (11/2)],\n [-7, 3],\n [-9, (5/2)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 4 & 3 \\\\\n 8 & 0 \\\\\n -8 & -10 \\\\\n 3 & -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -8 & 3 \\\\\n 9 & 6 \\\\\n -7 & -5 \\\\\n -1 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -4 & 6 \\\\\n 17 & 6 \\\\\n -15 & -15 \\\\\n 2 & -11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 3],\n [8, 0],\n [-8, -10],\n [3, -4]])\nb = np.array([\n [-8, 3],\n [9, 6],\n [-7, -5],\n [-1, -7]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & -10 \\\\\n 1 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6,3\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -10],\n [1, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{43}{7} & 6 & \\frac{51}{7} \\\\\n -\\frac{27}{7} & 3 & -\\frac{38}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{57}{7} & \\frac{65}{7} & \\frac{3}{7} \\\\\n \\frac{38}{7} & -\\frac{37}{7} & -\\frac{25}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{100}{7} & \\frac{107}{7} & \\frac{54}{7} \\\\\n \\frac{11}{7} & -\\frac{16}{7} & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(43/7), 6, (51/7)],\n [-(27/7), 3, -(38/7)]])\nb = np.array([\n [-(57/7), (65/7), (3/7)],\n [(38/7), -(37/7), -(25/7)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & 2 \\\\\n 8 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{2} \\left(1-\\sqrt{2}\\right),1\\right\\}, \\left\\{\\frac{1}{2} \\left(1+\\sqrt{2}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2],\n [8, -8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(\\sqrt{30}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [-1],\n [1],\n [-1],\n [-1],\n [1],\n [0],\n [-1]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [-1],\n [0],\n [1],\n [0],\n [1],\n [1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -1 & 4 & 2 \\\\\n 5 & -7 & -6 \\\\\n 1 & -8 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-15 x^2+7 x+49$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 4, 2],\n [5, -7, -6],\n [1, -8, -7]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -2 \\\\\n 7 \\\\\n -10 \\\\\n 8 \\\\\n -6 \\\\\n 7 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -5 \\\\\n 7 \\\\\n -7 \\\\\n 6 \\\\\n -10 \\\\\n -9 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$181$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-2],\n [7],\n [-10],\n [8],\n [-6],\n [7],\n [7]])\nb = np.array([\n [7],\n [-5],\n [7],\n [-7],\n [6],\n [-10],\n [-9],\n [-8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{10} \\\\\n -\\frac{42}{5} \\\\\n \\frac{73}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{\\frac{6613}{2}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/10)],\n [-(42/5)],\n [(73/10)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{45}{7} \\\\\n \\frac{59}{7} \\\\\n \\frac{17}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{7} \\\\\n -6 \\\\\n -\\frac{6}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{360}{49} \\\\\n \\frac{185}{49} \\\\\n -\\frac{1595}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(45/7)],\n [(59/7)],\n [(17/7)]])\nb = np.array([\n [-(5/7)],\n [-6],\n [-(6/7)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{67}{8} & -\\frac{3}{8} & \\frac{13}{2} \\\\\n \\frac{9}{4} & -\\frac{43}{8} & -\\frac{5}{4} \\\\\n \\frac{13}{4} & -\\frac{13}{4} & \\frac{33}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{77 x^2}{8}+\\frac{2307 x}{64}+\\frac{148855}{512}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(67/8), -(3/8), (13/2)],\n [(9/4), -(43/8), -(5/4)],\n [(13/4), -(13/4), (33/8)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{5} \\\\\n \\frac{1}{5} \\\\\n \\frac{13}{5} \\\\\n 9 \\\\\n \\frac{24}{5} \\\\\n -\\frac{46}{5} \\\\\n -\\frac{38}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{46}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/5)],\n [(1/5)],\n [(13/5)],\n [9],\n [(24/5)],\n [-(46/5)],\n [-(38/5)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{5} & \\frac{23}{5} & \\frac{18}{5} \\\\\n \\frac{14}{5} & \\frac{8}{5} & \\frac{18}{5} \\\\\n -\\frac{14}{5} & -2 & \\frac{36}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{33 x^2}{5}+\\frac{86 x}{25}-\\frac{4608}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/5), (23/5), (18/5)],\n [(14/5), (8/5), (18/5)],\n [-(14/5), -2, (36/5)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{49}{5} \\\\\n -\\frac{49}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{36}{5} \\\\\n -\\frac{34}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}+\\cot ^{-1}(35)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(49/5)],\n [-(49/5)]]).squeeze()\nb = np.array([\n [(36/5)],\n [-(34/5)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{17}{4} & -\\frac{21}{4} \\\\\n -7 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{56} \\left(11-\\sqrt{2473}\\right),1\\right\\}, \\left\\{\\frac{1}{56} \\left(11+\\sqrt{2473}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/4), -(21/4)],\n [-7, 7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{1}{3}, 3}$ to the line $\\frac{14 x}{3}-2 y-\\frac{8}{3}=0$.", - "Output Answer": [ - "$\\frac{16 \\sqrt{\\frac{2}{29}}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (1/3), 3\nline = Poly(((14*x)/3)-2*y-(8/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{32}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 7 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{16} \\\\\n -\\frac{7}{32} \\\\\n \\frac{5}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [7],\n [-5]])\nprint(a * -(1/32))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 0 & 1 & 1 \\\\\n -2 & -2 & 3 \\\\\n 3 & -3 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n 9 \\\\\n -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 1],\n [-2, -2, 3],\n [3, -3, 0]])\nb = np.array([\n [-2],\n [-1],\n [1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-1$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -6 & -6 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 6 & 6 & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -6, 9]])\nprint(a * -1)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{59}{16} & \\frac{45}{8} & \\frac{3}{16} \\\\\n -\\frac{85}{16} & -\\frac{77}{16} & -\\frac{61}{16} \\\\\n -\\frac{119}{16} & -\\frac{19}{4} & -\\frac{19}{4} \\\\\n -\\frac{7}{8} & \\frac{111}{16} & \\frac{143}{16} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{16} & \\frac{55}{16} & 6 \\\\\n -\\frac{125}{16} & \\frac{35}{8} & \\frac{127}{16} \\\\\n \\frac{143}{16} & 5 & \\frac{67}{8} \\\\\n \\frac{13}{16} & \\frac{151}{16} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 4 & \\frac{35}{16} & -\\frac{93}{16} \\\\\n \\frac{5}{2} & -\\frac{147}{16} & -\\frac{47}{4} \\\\\n -\\frac{131}{8} & -\\frac{39}{4} & -\\frac{105}{8} \\\\\n -\\frac{27}{16} & -\\frac{5}{2} & \\frac{167}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(59/16), (45/8), (3/16)],\n [-(85/16), -(77/16), -(61/16)],\n [-(119/16), -(19/4), -(19/4)],\n [-(7/8), (111/16), (143/16)]])\nb = np.array([\n [-(5/16), (55/16), 6],\n [-(125/16), (35/8), (127/16)],\n [(143/16), 5, (67/8)],\n [(13/16), (151/16), -(3/2)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{5}{8} & 0 & -1 & -\\frac{61}{8} & -\\frac{79}{8} \\\\\n -\\frac{25}{4} & -\\frac{9}{2} & \\frac{33}{8} & \\frac{3}{4} & -\\frac{47}{8} \\\\\n -\\frac{9}{2} & -\\frac{1}{4} & -\\frac{17}{2} & \\frac{1}{2} & \\frac{75}{8} \\\\\n \\frac{27}{8} & -7 & \\frac{23}{8} & -\\frac{7}{4} & -\\frac{57}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/8), 0, -1, -(61/8), -(79/8)],\n [-(25/4), -(9/2), (33/8), (3/4), -(47/8)],\n [-(9/2), -(1/4), -(17/2), (1/2), (75/8)],\n [(27/8), -7, (23/8), -(7/4), -(57/8)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\log (2) \\\\\n -14 \\log (2) \\\\\n 9 \\log (2) \\\\\n 12 \\log (2) \\\\\n -9 \\log (2) \\\\\n 8 \\log (2) \\\\\n -13 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -11 \\log (2) \\\\\n -3 \\log (2) \\\\\n -\\log (2) \\\\\n 2 \\log (2) \\\\\n 4 \\log (2) \\\\\n -4 \\log (2) \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{273} \\log (2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [6*math.log(2)],\n [-14*math.log(2)],\n [9*math.log(2)],\n [12*math.log(2)],\n [-9*math.log(2)],\n [8*math.log(2)],\n [-13*math.log(2)]])\nb = np.array([\n [-11*math.log(2)],\n [-3*math.log(2)],\n [-math.log(2)],\n [2*math.log(2)],\n [4*math.log(2)],\n [-4*math.log(2)],\n [0]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{9}{5} & \\frac{12}{5} & -\\frac{17}{5} \\\\\n -\\frac{46}{5} & -5 & \\frac{18}{5} \\\\\n -6 & \\frac{31}{5} & \\frac{9}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-4.425-3.309 i,-4.425+3.309 i,7.45\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/5), (12/5), -(17/5)],\n [-(46/5), -5, (18/5)],\n [-6, (31/5), (9/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -10 & 10 & 9 & 4 & 4 \\\\\n 2 & -2 & 3 & -1 & 5 \\\\\n 1 & -8 & 6 & 5 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & -\\frac{5}{4} & \\frac{11}{28} \\\\\n 0 & 1 & 0 & -\\frac{13}{16} & -\\frac{33}{112} \\\\\n 0 & 0 & 1 & -\\frac{1}{24} & \\frac{29}{24} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, 10, 9, 4, 4],\n [2, -2, 3, -1, 5],\n [1, -8, 6, 5, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -8 & -6 & -1 \\\\\n 9 & 2 & -1 \\\\\n 10 & 9 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.113,-0.355,1.\\}, \\{-0.711-0.417 i,0.126\\, +1.137 i,1.\\}, \\{-0.711+0.417 i,0.126\\, -1.137 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -6, -1],\n [9, 2, -1],\n [10, 9, 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{17}{\\sqrt{\\pi }} \\\\\n \\frac{1}{\\sqrt{\\pi }} \\\\\n -\\frac{12}{\\sqrt{\\pi }} \\\\\n \\frac{7}{\\sqrt{\\pi }} \\\\\n -\\frac{13}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{17}{\\sqrt{\\pi }} \\\\\n -\\frac{11}{\\sqrt{\\pi }} \\\\\n -\\frac{1}{\\sqrt{\\pi }} \\\\\n \\frac{8}{\\sqrt{\\pi }} \\\\\n \\frac{10}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{362}{\\pi }$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [-(17/(math.sqrt(math.pi)))],\n [(1/(math.sqrt(math.pi)))],\n [-(12/(math.sqrt(math.pi)))],\n [(7/(math.sqrt(math.pi)))],\n [-(13/(math.sqrt(math.pi)))]])\nb = np.array([\n [0],\n [(17/(math.sqrt(math.pi)))],\n [-(11/(math.sqrt(math.pi)))],\n [-(1/(math.sqrt(math.pi)))],\n [(8/(math.sqrt(math.pi)))],\n [(10/(math.sqrt(math.pi)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -4 & -8 & -6 \\\\\n -2 & 7 & -6 \\\\\n -1 & -4 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-4.121,-0.225,1.\\}, \\{1.352,0.477,1.\\}, \\{2.534,-4.943,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -8, -6],\n [-2, 7, -6],\n [-1, -4, -8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -1 & 3 & 5 & 1 & 9 \\\\\n -3 & 8 & -8 & -3 & -6 \\\\\n 2 & 3 & -3 & 5 & -6 \\\\\n 9 & -5 & 4 & 3 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{2545.,-713.,-3650.,245.,2521.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, 3, 5, 1, 9],\n [-3, 8, -8, -3, -6],\n [2, 3, -3, 5, -6],\n [9, -5, 4, 3, -5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -2 & -3 \\\\\n 4 & 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 8 & 9 \\\\\n 5 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 6 & 6 \\\\\n 9 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3],\n [4, 5]])\nb = np.array([\n [8, 9],\n [5, -4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & -1 & -1 & 3 \\\\\n 0 & 3 & -3 & 3 \\\\\n 2 & -3 & -1 & -3 \\\\\n 2 & -3 & 0 & 3 \\\\\n 0 & -1 & -3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.51 \\\\\n 0.03 \\\\\n -2.81 \\\\\n 2.7 \\\\\n 0.62 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.541 \\\\\n 0.259 \\\\\n 0.722 \\\\\n 0.581 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -1, -1, 3],\n [0, 3, -3, 3],\n [2, -3, -1, -3],\n [2, -3, 0, 3],\n [0, -1, -3, 3]])\nb = np.array([\n [-1.51],\n [0.03],\n [-2.81],\n [2.7],\n [0.62]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 9 \\\\\n 6 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -1 \\\\\n -8 \\\\\n 2 \\\\\n -5 \\\\\n -1 \\\\\n 7 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{583}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [9],\n [6],\n [1],\n [1],\n [1],\n [-4]])\nb = np.array([\n [10],\n [-1],\n [-8],\n [2],\n [-5],\n [-1],\n [7],\n [7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $3$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -8 & 9 & -7 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -24 & 27 & -21 & 24 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 9, -7, 8]])\nprint(a * 3)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 9 \\\\\n -2 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [9],\n [-2],\n [-6]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 3 & -\\frac{21}{5} & \\frac{4}{5} \\\\\n -7 & -\\frac{39}{5} & \\frac{13}{5} \\\\\n -\\frac{14}{5} & \\frac{31}{5} & -\\frac{17}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{41 x^2}{5}+\\frac{1259 x}{25}+\\frac{13693}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -(21/5), (4/5)],\n [-7, -(39/5), (13/5)],\n [-(14/5), (31/5), -(17/5)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & 1 & \\frac{1}{2} \\\\\n -\\frac{1}{2} & -\\frac{3}{2} & -\\frac{5}{2} \\\\\n 1 & -\\frac{5}{2} & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{20}{69} & -\\frac{10}{69} & \\frac{14}{69} \\\\\n \\frac{10}{23} & \\frac{18}{23} & -\\frac{16}{23} \\\\\n -\\frac{22}{69} & -\\frac{58}{69} & \\frac{26}{69} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), 1, (1/2)],\n [-(1/2), -(3/2), -(5/2)],\n [1, -(5/2), -(5/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -7 & 2 & -8 \\\\\n -3 & 0 & -4 \\\\\n -4 & -2 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-8 x^2+27 x+34$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 2, -8],\n [-3, 0, -4],\n [-4, -2, -1]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{1}{2},3,\\frac{1}{2}\\right\\}, \\left\\{-\\frac{3}{2},\\frac{7}{2},0\\right\\}, \\left\\{0,-\\frac{3}{2},5\\right\\}}$.", - "Output Answer": [ - "$2 (y+z)-7=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(1/2), 3, (1/2)],\n [-(3/2), (7/2), 0],\n [0, -(3/2), 5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{3}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/16)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{15}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/2)]])\nb = np.array([\n [1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{1,0,-1\\}, \\{-1,2,0\\}, \\{1,1,1\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{2}},0,-\\frac{1}{\\sqrt{2}}\\right\\}, \\left\\{-\\frac{1}{3 \\sqrt{2}},\\frac{2 \\sqrt{2}}{3},-\\frac{1}{3 \\sqrt{2}}\\right\\}, \\left\\{\\frac{2}{3},\\frac{1}{3},\\frac{2}{3}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((1, 0, -1), (-1, 2, 0), (1, 1, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -9 & -6 \\\\\n -10 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, -6],\n [-10, -4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -6 \\\\\n -8 \\\\\n -4 \\\\\n -6 \\\\\n -5 \\\\\n 10 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n -9 \\\\\n 2 \\\\\n 2 \\\\\n -9 \\\\\n -3 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6 \\sqrt{14}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-6],\n [-8],\n [-4],\n [-6],\n [-5],\n [10],\n [9]])\nb = np.array([\n [0],\n [-1],\n [-9],\n [2],\n [2],\n [-9],\n [-3],\n [-3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{9}{4} \\\\\n -\\frac{3}{2} \\\\\n -\\frac{5}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{9}{\\sqrt{142}} \\\\\n -3 \\sqrt{\\frac{2}{71}} \\\\\n -\\frac{5}{\\sqrt{142}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/4)],\n [-(3/2)],\n [-(5/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -6 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 1 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -41 \\\\\n 7 \\\\\n -47 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-6],\n [-7]])\nb = np.array([\n [-9],\n [1],\n [8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -3 & -5 & -2 & -8 & -2 & -8 \\\\\n 0 & -5 & 2 & -7 & -1 & 9 \\\\\n 6 & 5 & 3 & 2 & 8 & -2 \\\\\n -7 & 10 & 0 & -9 & -5 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & \\frac{376}{233} & -\\frac{1593}{466} \\\\\n 0 & 1 & 0 & 0 & \\frac{378}{1165} & -\\frac{1511}{2330} \\\\\n 0 & 0 & 1 & 0 & -\\frac{204}{233} & \\frac{3053}{466} \\\\\n 0 & 0 & 0 & 1 & -\\frac{79}{233} & \\frac{489}{466} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, -5, -2, -8, -2, -8],\n [0, -5, 2, -7, -1, 9],\n [6, 5, 3, 2, 8, -2],\n [-7, 10, 0, -9, -5, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{8}{3} \\\\\n -\\frac{1}{2} \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -8 \\sqrt{\\frac{2}{173}} \\\\\n -\\frac{3}{\\sqrt{346}} \\\\\n \\frac{9}{\\sqrt{346}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/3)],\n [-(1/2)],\n [(3/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -5 & 9 \\\\\n 8 & \\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{3} \\left(-4-\\sqrt{769}\\right),\\frac{1}{3} \\left(\\sqrt{769}-4\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 9],\n [8, (7/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n \\frac{14}{3} & -9 & -1 & -5 \\\\\n -\\frac{1}{3} & \\frac{17}{3} & -\\frac{19}{3} & -\\frac{8}{3} \\\\\n -\\frac{5}{3} & -\\frac{10}{3} & \\frac{14}{3} & -\\frac{5}{3} \\\\\n -\\frac{28}{3} & -8 & 7 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/3), -9, -1, -5],\n [-(1/3), (17/3), -(19/3), -(8/3)],\n [-(5/3), -(10/3), (14/3), -(5/3)],\n [-(28/3), -8, 7, 2]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{14}{5} & \\frac{1}{5} \\\\\n \\frac{7}{5} & -\\frac{4}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{63}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/5), (1/5)],\n [(7/5), -(4/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -8 & 10 & -6 & 10 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-3.,0.,4.,0.,0.\\}, \\{1.,0.,0.,0.,2.\\}, \\{5.,0.,0.,4.,0.\\}, \\{5.,4.,0.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-8, 10, -6, 10, 4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 10 & -9 & -7 \\\\\n 5 & 0 & -4 \\\\\n -3 & -3 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+8 x^2+8 x-213$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -9, -7],\n [5, 0, -4],\n [-3, -3, -2]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{42}{5} & -9 \\\\\n 3 & -\\frac{26}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{15} \\left(34-\\sqrt{481}\\right),1\\right\\}, \\left\\{\\frac{1}{15} \\left(34+\\sqrt{481}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(42/5), -9],\n [3, -(26/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & 5 & 1 \\\\\n -1 & 4 & 1 \\\\\n -5 & 5 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 5, 1],\n [-1, 4, 1],\n [-5, 5, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{0,-\\frac{13}{3},-1\\right\\}, \\left\\{-\\frac{10}{3},\\frac{10}{3},-\\frac{11}{3}\\right\\}, \\{1,-1,1\\}}$.", - "Output Answer": [ - "$218 x+36 y-169 z-13=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, -(13/3), -1],\n [-(10/3), (10/3), -(11/3)],\n [1, -1, 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -7 \\\\\n 10 \\\\\n 3 \\\\\n -9 \\\\\n -8 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -5 \\\\\n -5 \\\\\n 3 \\\\\n 6 \\\\\n 7 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{206}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-7],\n [10],\n [3],\n [-9],\n [-8],\n [-2]])\nb = np.array([\n [-1],\n [-5],\n [-5],\n [3],\n [6],\n [7],\n [7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 1 & -3 & 0 & -1 & 2 \\\\\n -1 & 2 & 0 & 1 & -2 \\\\\n 0 & 2 & -1 & -2 & 2 \\\\\n 0 & -2 & 0 & 0 & -3 \\\\\n -1 & 0 & 2 & -3 & 0 \\\\\n 2 & 2 & 1 & 3 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.86 \\\\\n -1.89 \\\\\n -1.83 \\\\\n -0.43 \\\\\n -1.16 \\\\\n -1.22 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.083 \\\\\n -1.017 \\\\\n -0.027 \\\\\n 0.73 \\\\\n 0.821 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3, 0, -1, 2],\n [-1, 2, 0, 1, -2],\n [0, 2, -1, -2, 2],\n [0, -2, 0, 0, -3],\n [-1, 0, 2, -3, 0],\n [2, 2, 1, 3, 1]])\nb = np.array([\n [2.86],\n [-1.89],\n [-1.83],\n [-0.43],\n [-1.16],\n [-1.22]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -3 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -6 \\\\\n -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 51 \\\\\n 38 \\\\\n -48 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-3],\n [4]])\nb = np.array([\n [-4],\n [-6],\n [-9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 2 & 4 \\\\\n -4 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{6} & -\\frac{1}{6} \\\\\n \\frac{1}{6} & \\frac{1}{12} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 4],\n [-4, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 10 & 5 & 8 \\\\\n 10 & 3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{19.,-70.,20.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [10, 5, 8],\n [10, 3, 1]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{7}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -7 & -9 & 5 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 3 & \\frac{27}{7} & -\\frac{15}{7} & -\\frac{3}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -9, 5, 1]])\nprint(a * -(3/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -4 \\\\\n 0 \\\\\n 4 \\\\\n -7 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 5 \\\\\n 6 \\\\\n -7 \\\\\n 10 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-22$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-4],\n [0],\n [4],\n [-7],\n [8]])\nb = np.array([\n [-8],\n [5],\n [6],\n [-7],\n [10],\n [6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -4 & -5 & -2 \\\\\n -5 & -3 & 5 \\\\\n -9 & -7 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-7.-4.243 i,-7.+4.243 i,2.\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -5, -2],\n [-5, -3, 5],\n [-9, -7, -5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{2}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & -8 \\\\\n 5 & 4 \\\\\n -8 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{9}{2} & -12 \\\\\n \\frac{15}{2} & 6 \\\\\n -12 & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -8],\n [5, 4],\n [-8, 1]])\nprint(a * (3/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,-4,2\\}, \\{5,2,3\\}, \\{-2,-1,4\\}}$.", - "Output Answer": [ - "$9 x-16 y+15 z-58=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, -4, 2],\n [5, 2, 3],\n [-2, -1, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -1 & -9 \\\\\n 4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} i \\left(\\sqrt{35}-i\\right),1\\right\\}, \\left\\{-\\frac{1}{4} i \\left(\\sqrt{35}+i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -9],\n [4, -3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 0 & 3 & 1 \\\\\n -1 & -9 & 1 \\\\\n 4 & 0 & 7 \\\\\n -7 & -10 & 2 \\\\\n -5 & 8 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, 3, 1],\n [-1, -9, 1],\n [4, 0, 7],\n [-7, -10, 2],\n [-5, 8, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{ccc}\n -1 & 1 & -1 \\\\\n -1 & 0 & 0 \\\\\n 0 & -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 1 & -1 \\\\\n -\\frac{1}{2} & \\frac{1}{2} & \\frac{1}{2} \\\\\n \\frac{1}{2} & -\\frac{3}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [-1, 1, -1],\n [-1, 0, 0],\n [0, -1, 1]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{9}{4}, -\\frac{77}{16}}$ to the line $-\\frac{25 x}{16}-\\frac{71 y}{32}+\\frac{59}{16}=0$.", - "Output Answer": [ - "$\\frac{5555}{16 \\sqrt{7541}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (9/4), -(77/16)\nline = Poly(-((25*x)/16)-((71*y)/32)+(59/16), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & 2 & -\\frac{1}{2} \\\\\n -\\frac{5}{2} & 3 & -4 \\\\\n 1 & -\\frac{3}{2} & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{395}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 2, -(1/2)],\n [-(5/2), 3, -4],\n [1, -(3/2), -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{8}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{9}{8} \\\\\n \\frac{1}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-2]])\nprint(a * -(1/8))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{6} & -\\frac{23}{3} & \\frac{29}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & -6 & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{3} & -\\frac{41}{3} & \\frac{55}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/6), -(23/3), (29/3)]])\nb = np.array([\n [(1/2), -6, -(1/2)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & -2 & 2 & 1 \\\\\n -3 & -2 & -2 & 0 \\\\\n -1 & 1 & -2 & -3 \\\\\n -1 & -3 & -2 & -1 \\\\\n -1 & 0 & -2 & 3 \\\\\n 1 & 1 & -2 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.87 \\\\\n 0.52 \\\\\n -0.16 \\\\\n -2.19 \\\\\n 2.7 \\\\\n -1.02 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.039 \\\\\n 0.822 \\\\\n 0.204 \\\\\n 0.609 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2, 2, 1],\n [-3, -2, -2, 0],\n [-1, 1, -2, -3],\n [-1, -3, -2, -1],\n [-1, 0, -2, 3],\n [1, 1, -2, -1]])\nb = np.array([\n [2.87],\n [0.52],\n [-0.16],\n [-2.19],\n [2.7],\n [-1.02]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{3} \\\\\n \\frac{14}{9} \\\\\n \\frac{8}{3} \\\\\n -\\frac{14}{9} \\\\\n -\\frac{20}{9} \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{7}{\\sqrt{282}} \\\\\n \\frac{7 \\sqrt{\\frac{2}{141}}}{3} \\\\\n 4 \\sqrt{\\frac{2}{141}} \\\\\n -\\frac{7 \\sqrt{\\frac{2}{141}}}{3} \\\\\n -\\frac{10 \\sqrt{\\frac{2}{141}}}{3} \\\\\n 3 \\sqrt{\\frac{3}{94}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/3)],\n [(14/9)],\n [(8/3)],\n [-(14/9)],\n [-(20/9)],\n [3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 0 & -2 \\\\\n 3 & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -6 & 2 \\\\\n -3 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2],\n [3, -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -5 \\\\\n 9 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -4 \\\\\n 6 \\\\\n 8 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$98$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-5],\n [9],\n [1],\n [1]])\nb = np.array([\n [-2],\n [-4],\n [6],\n [8],\n [2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n -7 \\\\\n 8 \\\\\n 10 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -4 \\\\\n -3 \\\\\n -7 \\\\\n 8 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$58$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [-7],\n [8],\n [10],\n [0]])\nb = np.array([\n [-9],\n [-4],\n [-3],\n [-7],\n [8],\n [-7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{64}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -4 \\\\\n 7 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{15}{64} \\\\\n -\\frac{5}{16} \\\\\n \\frac{35}{64} \\\\\n -\\frac{5}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-4],\n [7],\n [-8]])\nprint(a * (5/64))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{5} & -\\frac{27}{5} & \\frac{46}{5} \\\\\n -\\frac{18}{5} & \\frac{14}{5} & \\frac{18}{5} \\\\\n \\frac{14}{5} & -7 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-2.18-3.281 i,-2.18+3.281 i,7.76\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/5), -(27/5), (46/5)],\n [-(18/5), (14/5), (18/5)],\n [(14/5), -7, 0]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 3 & 4 & -3 & -5 & 9 \\\\\n 1 & -2 & 1 & -4 & -3 \\\\\n 6 & -4 & 8 & -6 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & -\\frac{38}{17} & \\frac{33}{34} \\\\\n 0 & 1 & 0 & \\frac{61}{34} & \\frac{99}{34} \\\\\n 0 & 0 & 1 & \\frac{31}{17} & \\frac{63}{34} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, 4, -3, -5, 9],\n [1, -2, 1, -4, -3],\n [6, -4, 8, -6, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{10}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -6 & 0 \\\\\n -3 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{3}{5} & 0 \\\\\n \\frac{3}{10} & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 0],\n [-3, 10]])\nprint(a * -(1/10))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & -3 \\\\\n 0 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-49$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -3],\n [0, 7]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -1 & 7 \\\\\n -5 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-5 x+29$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 7],\n [-5, 6]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{2}{3}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -3 \\\\\n 0 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -4 \\\\\n 2 \\\\\n 0 \\\\\n -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-3],\n [0],\n [7]])\nprint(a * -(2/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{22}{3} & \\frac{26}{3} \\\\\n -\\frac{4}{3} & \\frac{26}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{2} \\left(12-\\sqrt{118}\\right),1\\right\\}, \\left\\{\\frac{1}{2} \\left(12+\\sqrt{118}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(22/3), (26/3)],\n [-(4/3), (26/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n \\frac{20}{3} & 9 & \\frac{89}{9} & -\\frac{28}{9} \\\\\n -\\frac{28}{9} & -\\frac{71}{9} & \\frac{20}{9} & -\\frac{22}{9} \\\\\n \\frac{41}{9} & -\\frac{62}{9} & \\frac{20}{3} & -\\frac{28}{9} \\\\\n -\\frac{5}{3} & -\\frac{50}{9} & -\\frac{83}{9} & -\\frac{2}{3} \\\\\n -3 & \\frac{47}{9} & -\\frac{2}{3} & -\\frac{16}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(20/3), 9, (89/9), -(28/9)],\n [-(28/9), -(71/9), (20/9), -(22/9)],\n [(41/9), -(62/9), (20/3), -(28/9)],\n [-(5/3), -(50/9), -(83/9), -(2/3)],\n [-3, (47/9), -(2/3), -(16/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -4 & -\\frac{37}{5} & -9 \\\\\n 4 & -\\frac{18}{5} & -\\frac{48}{5} \\\\\n -\\frac{44}{5} & -\\frac{36}{5} & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{8 x^2}{5}+\\frac{3748 x}{25}+\\frac{57456}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -(37/5), -9],\n [4, -(18/5), -(48/5)],\n [-(44/5), -(36/5), 6]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -5 & \\frac{1}{9} & \\frac{38}{9} \\\\\n -\\frac{2}{9} & -\\frac{16}{9} & -\\frac{19}{9} \\\\\n -\\frac{13}{9} & -\\frac{4}{9} & -\\frac{28}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{108}{779} & \\frac{36}{779} & -\\frac{9}{41} \\\\\n -\\frac{1719}{24149} & -\\frac{15786}{24149} & \\frac{441}{1271} \\\\\n \\frac{1800}{24149} & \\frac{1737}{24149} & -\\frac{342}{1271} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, (1/9), (38/9)],\n [-(2/9), -(16/9), -(19/9)],\n [-(13/9), -(4/9), -(28/9)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{11}{32}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & -6 & 4 \\\\\n -6 & -9 & 3 \\\\\n -1 & -7 & 6 \\\\\n -7 & -1 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{33}{32} & \\frac{33}{16} & -\\frac{11}{8} \\\\\n \\frac{33}{16} & \\frac{99}{32} & -\\frac{33}{32} \\\\\n \\frac{11}{32} & \\frac{77}{32} & -\\frac{33}{16} \\\\\n \\frac{77}{32} & \\frac{11}{32} & \\frac{99}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -6, 4],\n [-6, -9, 3],\n [-1, -7, 6],\n [-7, -1, -9]])\nprint(a * -(11/32))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -3 & 0 \\\\\n 2 & -1 & 3 \\\\\n -1 & 0 & -2 \\\\\n -2 & -1 & -2 \\\\\n -1 & -2 & 3 \\\\\n -3 & 2 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.79 \\\\\n -0.28 \\\\\n 0.76 \\\\\n 2.04 \\\\\n 2.74 \\\\\n -2.93 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.28 \\\\\n -0.625 \\\\\n 0.091 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3, 0],\n [2, -1, 3],\n [-1, 0, -2],\n [-2, -1, -2],\n [-1, -2, 3],\n [-3, 2, -1]])\nb = np.array([\n [-0.79],\n [-0.28],\n [0.76],\n [2.04],\n [2.74],\n [-2.93]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -3 & 9 \\\\\n 9 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-6 x-108$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 9],\n [9, 9]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{17}{5}, \\frac{14}{5}}$ to the line $\\frac{14 x}{5}+y-\\frac{18}{5}=0$.", - "Output Answer": [ - "$\\frac{258}{5 \\sqrt{221}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(17/5), (14/5)\nline = Poly(((14*x)/5)+y-(18/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & 6 & 10 \\\\\n 10 & -2 & 1 \\\\\n -9 & -9 & -6 \\\\\n 2 & -7 & -6 \\\\\n -4 & -8 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [8, 6, 10],\n [10, -2, 1],\n [-9, -9, -6],\n [2, -7, -6],\n [-4, -8, 5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2 & 2 & 1 \\\\\n -2 & 0 & -2 \\\\\n -2 & -2 & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -2 & -6 & -7 \\\\\n 8 & 0 & 0 \\\\\n 10 & -2 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2, 1],\n [-2, 0, -2],\n [-2, -2, -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{8}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 6 & 4 & -9 \\\\\n -3 & 6 & 8 \\\\\n 0 & 6 & -2 \\\\\n 10 & 5 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{3}{4} & \\frac{1}{2} & -\\frac{9}{8} \\\\\n -\\frac{3}{8} & \\frac{3}{4} & 1 \\\\\n 0 & \\frac{3}{4} & -\\frac{1}{4} \\\\\n \\frac{5}{4} & \\frac{5}{8} & \\frac{3}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 4, -9],\n [-3, 6, 8],\n [0, 6, -2],\n [10, 5, 3]])\nprint(a * (1/8))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{3,\\frac{1}{4},0\\right\\}, \\left\\{0,-\\frac{1}{2},\\frac{1}{4}\\right\\}, \\left\\{-\\frac{11}{4},-\\frac{3}{4},\\frac{9}{4}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{12}{\\sqrt{145}},\\frac{1}{\\sqrt{145}},0\\right\\}, \\left\\{\\frac{24}{\\sqrt{104545}},-\\frac{288}{\\sqrt{104545}},\\sqrt{\\frac{145}{721}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{721}},\\frac{12}{\\sqrt{721}},\\frac{24}{\\sqrt{721}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((3, (1/4), 0), (0, -(1/2), (1/4)), (-(11/4), -(3/4), (9/4))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{50}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -5 & -4 & -6 & -2 \\\\\n 1 & -8 & 6 & 3 \\\\\n -1 & 9 & 8 & 9 \\\\\n 8 & 4 & -2 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{1}{10} & \\frac{2}{25} & \\frac{3}{25} & \\frac{1}{25} \\\\\n -\\frac{1}{50} & \\frac{4}{25} & -\\frac{3}{25} & -\\frac{3}{50} \\\\\n \\frac{1}{50} & -\\frac{9}{50} & -\\frac{4}{25} & -\\frac{9}{50} \\\\\n -\\frac{4}{25} & -\\frac{2}{25} & \\frac{1}{25} & -\\frac{1}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -4, -6, -2],\n [1, -8, 6, 3],\n [-1, 9, 8, 9],\n [8, 4, -2, 5]])\nprint(a * -(1/50))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{3}{2}, -\\frac{5}{2}, \\frac{9}{2}}$ to the plane $\\frac{x}{2}+3 y-\\frac{z}{2}+3=0$.", - "Output Answer": [ - "$\\frac{15}{\\sqrt{38}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(3/2), -(5/2), (9/2)\nplane = Poly((x/2)+3*y-(z/2)+3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 3 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -15 \\\\\n 19 \\\\\n 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [3],\n [7]])\nb = np.array([\n [5],\n [3],\n [2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${2, \\frac{7}{2}, \\frac{1}{2}}$ to the plane $-\\frac{x}{2}-y-\\frac{7 z}{2}+\\frac{1}{2}=0$.", - "Output Answer": [ - "$\\frac{23}{6 \\sqrt{6}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 2, (7/2), (1/2)\nplane = Poly(-(x/2)-y-((7*z)/2)+(1/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,1,1\\}, \\{0,-3,0\\}, \\{0,-1,-2\\}}$", - "Output Answer": [ - "${\\left\\{-\\sqrt{\\frac{2}{3}},\\frac{1}{\\sqrt{6}},\\frac{1}{\\sqrt{6}}\\right\\}, \\left\\{-\\sqrt{\\frac{2}{15}},-\\sqrt{\\frac{5}{6}},\\frac{1}{\\sqrt{30}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{5}},0,-\\frac{2}{\\sqrt{5}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, 1, 1), (0, -3, 0), (0, -1, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -2 & 5 & -7 \\\\\n -7 & 10 & 2 \\\\\n -6 & 2 & -5 \\\\\n 4 & -9 & 10 \\\\\n -2 & -6 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, 5, -7],\n [-7, 10, 2],\n [-6, 2, -5],\n [4, -9, 10],\n [-2, -6, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,-2,-1\\}, \\{-5,2,3\\}, \\{-3,4,3\\}}$.", - "Output Answer": [ - "$x-y+3 z-2=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, -2, -1],\n [-5, 2, 3],\n [-3, 4, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -9 \\\\\n -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 54 \\\\\n -18 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [6]])\nb = np.array([\n [-3],\n [-9],\n [-3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & -3 \\\\\n -3 & 0 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{45}{4} & \\frac{9}{2} \\\\\n \\frac{9}{2} & 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), -3],\n [-3, 0]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\sqrt{\\frac{6}{7}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [0],\n [1],\n [0],\n [1],\n [1],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [1],\n [-1],\n [0],\n [-1],\n [0],\n [-1],\n [-1],\n [1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{41}{5} & \\frac{1}{5} \\\\\n -\\frac{17}{5} & -\\frac{47}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{6 x}{5}-\\frac{382}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(41/5), (1/5)],\n [-(17/5), -(47/5)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & 3 \\\\\n -3 & 2 & -2 \\\\\n 1 & 2 & 2 \\\\\n 1 & -1 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -2 & 1 & -3 & 2 \\\\\n -1 & -2 & 0 & -2 \\\\\n -2 & 1 & -1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -7 & 6 & -6 & 4 \\\\\n 8 & -9 & 11 & -10 \\\\\n -8 & -1 & -5 & -2 \\\\\n 5 & 0 & 0 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, 3],\n [-3, 2, -2],\n [1, 2, 2],\n [1, -1, -3]])\nb = np.array([\n [-2, 1, -3, 2],\n [-1, -2, 0, -2],\n [-2, 1, -1, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -2 \\\\\n -1 & -2 \\\\\n -2 & -1 \\\\\n 3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.87 \\\\\n 1.38 \\\\\n -0.71 \\\\\n -0.65 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.113 \\\\\n 0.209 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2],\n [-1, -2],\n [-2, -1],\n [3, -3]])\nb = np.array([\n [-1.87],\n [1.38],\n [-0.71],\n [-0.65]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 4 \\\\\n -5 \\\\\n -5 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [4],\n [-5],\n [-5],\n [-9]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 8 \\\\\n -8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 4 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1 \\\\\n 4 \\\\\n -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [8],\n [-8]])\nb = np.array([\n [3],\n [4],\n [-4]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 4 & -2 \\\\\n -2 & \\frac{3}{2} & 3 \\\\\n -4 & -\\frac{1}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-42$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 4, -2],\n [-2, (3/2), 3],\n [-4, -(1/2), (5/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -2 & 7 & 4 & 1 & -4 \\\\\n 1 & 1 & -8 & -7 & 5 \\\\\n 5 & 6 & -4 & -6 & -3 \\\\\n 7 & -7 & 7 & -10 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & -\\frac{867}{973} \\\\\n 0 & 1 & 0 & 0 & -\\frac{655}{973} \\\\\n 0 & 0 & 1 & 0 & -\\frac{45}{973} \\\\\n 0 & 0 & 0 & 1 & -\\frac{123}{139} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, 7, 4, 1, -4],\n [1, 1, -8, -7, 5],\n [5, 6, -4, -6, -3],\n [7, -7, 7, -10, 7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -9 & 8 \\\\\n -4 & 7 \\\\\n 7 & -3 \\\\\n -7 & 0 \\\\\n -3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 8],\n [-4, 7],\n [7, -3],\n [-7, 0],\n [-3, -1]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{8}{e} \\\\\n -\\frac{22}{e} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{11}{e} \\\\\n \\frac{21}{e} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{550}{e^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(8/math.e)],\n [-(22/math.e)]])\nb = np.array([\n [(11/math.e)],\n [(21/math.e)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -1 & 8 \\\\\n 4 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(7-\\sqrt{209}\\right),\\frac{1}{2} \\left(7+\\sqrt{209}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 8],\n [4, 8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{12}{e} \\\\\n \\frac{23}{e} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{e} \\\\\n -\\frac{13}{e} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{311}{e^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(12/math.e)],\n [(23/math.e)]])\nb = np.array([\n [-(1/math.e)],\n [-(13/math.e)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n -2 \\\\\n -3 \\\\\n 6 \\\\\n -1 \\\\\n -2 \\\\\n -8 \\\\\n 2 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -1 \\\\\n -3 \\\\\n 8 \\\\\n 9 \\\\\n -6 \\\\\n -2 \\\\\n -2 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{262}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [-2],\n [-3],\n [6],\n [-1],\n [-2],\n [-8],\n [2],\n [-9]])\nb = np.array([\n [-2],\n [-1],\n [-3],\n [8],\n [9],\n [-6],\n [-2],\n [-2],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{7} \\\\\n \\frac{2}{7} \\\\\n \\frac{11}{7} \\\\\n \\frac{11}{7} \\\\\n -\\frac{3}{7} \\\\\n \\frac{20}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{9}{4 \\sqrt{46}} \\\\\n \\frac{1}{2 \\sqrt{46}} \\\\\n \\frac{11}{4 \\sqrt{46}} \\\\\n \\frac{11}{4 \\sqrt{46}} \\\\\n -\\frac{3}{4 \\sqrt{46}} \\\\\n \\frac{5}{\\sqrt{46}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/7)],\n [(2/7)],\n [(11/7)],\n [(11/7)],\n [-(3/7)],\n [(20/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 8 \\\\\n 5 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [8],\n [5],\n [-5]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -3 \\\\\n -1 \\\\\n -1 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-3],\n [-1],\n [-1],\n [9]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{137}{20} \\\\\n -\\frac{87}{100} \\\\\n -\\frac{177}{50} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{108}{25} \\\\\n \\frac{777}{100} \\\\\n \\frac{131}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{31533}{1250} \\\\\n -\\frac{13271}{5000} \\\\\n \\frac{494661}{10000} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(137/20)],\n [-(87/100)],\n [-(177/50)]])\nb = np.array([\n [-(108/25)],\n [(777/100)],\n [(131/50)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & 8 \\\\\n 1 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+14 x+40$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 8],\n [1, -8]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{3}{2},-1,-\\frac{5}{2}\\right\\}, \\left\\{\\frac{3}{2},-3,1\\right\\}, \\left\\{-5,-\\frac{5}{2},0\\right\\}}$.", - "Output Answer": [ - "$2 x-158 y-92 z-385=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(3/2), -1, -(5/2)],\n [(3/2), -3, 1],\n [-5, -(5/2), 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{17}{6} & \\frac{53}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{13}{3} & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{43}{6} & \\frac{37}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/6), (53/6)]])\nb = np.array([\n [(13/3), (7/2)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{23}{5} & -\\frac{1}{10} & -\\frac{7}{10} \\\\\n \\frac{9}{5} & \\frac{18}{5} & \\frac{9}{5} \\\\\n \\frac{11}{5} & -\\frac{33}{10} & \\frac{9}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{23751}{500}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/5), -(1/10), -(7/10)],\n [(9/5), (18/5), (9/5)],\n [(11/5), -(33/10), (9/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{22}{5} & 2 \\\\\n -3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{5}{8} & -\\frac{5}{4} \\\\\n \\frac{15}{8} & -\\frac{11}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(22/5), 2],\n [-3, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $2$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 4 & 10 & 8 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 8 & 20 & 16 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 10, 8, 0]])\nprint(a * 2)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-4, 1}$ to the line $2 x-2=0$.", - "Output Answer": [ - "$5$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -4, 1\nline = Poly(2*x-2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 7 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -9 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -44 \\\\\n 16 \\\\\n -19 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [7],\n [-8]])\nb = np.array([\n [-5],\n [-9],\n [4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -7 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -8 \\\\\n -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 120 \\\\\n 56 \\\\\n -41 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-7],\n [8]])\nb = np.array([\n [1],\n [-8],\n [-8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -4 & 3 & 2 & -8 \\\\\n -8 & 8 & -7 & -5 \\\\\n -7 & -4 & 3 & -1 \\\\\n -6 & -5 & -2 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, 3, 2, -8],\n [-8, 8, -7, -5],\n [-7, -4, 3, -1],\n [-6, -5, -2, 3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -5 & 4 \\\\\n 2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{13} & \\frac{4}{13} \\\\\n \\frac{2}{13} & \\frac{5}{13} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 4],\n [2, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -10 \\\\\n 2 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 8 \\\\\n -3 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{401}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-10],\n [2],\n [-5]])\nb = np.array([\n [-2],\n [8],\n [-3],\n [-1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 9 & -5 & 5 & -3 \\\\\n -8 & -4 & -10 & 5 \\\\\n -9 & 6 & -9 & 6 \\\\\n 10 & -2 & -7 & 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & 2 & -4 & 5 \\\\\n 5 & 3 & -6 & 8 \\\\\n 3 & 3 & -6 & -9 \\\\\n 0 & 8 & -2 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 11 & -3 & 1 & 2 \\\\\n -3 & -1 & -16 & 13 \\\\\n -6 & 9 & -15 & -3 \\\\\n 10 & 6 & -9 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -5, 5, -3],\n [-8, -4, -10, 5],\n [-9, 6, -9, 6],\n [10, -2, -7, 9]])\nb = np.array([\n [2, 2, -4, 5],\n [5, 3, -6, 8],\n [3, 3, -6, -9],\n [0, 8, -2, -4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 3 & -2 & -1 \\\\\n -3 & -2 & 2 \\\\\n -1 & 2 & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 67 & -38 & -24 \\\\\n -56 & -20 & 33 \\\\\n -26 & 32 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2, -1],\n [-3, -2, 2],\n [-1, 2, 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{2} & -2 & 4 \\\\\n 0 & \\frac{13}{2} & -5 \\\\\n 3 & -6 & \\frac{15}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -8 & -\\frac{13}{2} & -\\frac{9}{2} \\\\\n -6 & 6 & -3 \\\\\n -5 & \\frac{19}{2} & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & \\frac{9}{2} & \\frac{17}{2} \\\\\n 6 & \\frac{1}{2} & -2 \\\\\n 8 & -\\frac{31}{2} & 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/2), -2, 4],\n [0, (13/2), -5],\n [3, -6, (15/2)]])\nb = np.array([\n [-8, -(13/2), -(9/2)],\n [-6, 6, -3],\n [-5, (19/2), -(9/2)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & -9 \\\\\n -2 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{2} \\left(8-\\sqrt{82}\\right),1\\right\\}, \\left\\{\\frac{1}{2} \\left(8+\\sqrt{82}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -9],\n [-2, 10]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -5 & 4 & -3 \\\\\n -5 & 2 & -5 \\\\\n 0 & 5 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-40$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 4, -3],\n [-5, 2, -5],\n [0, 5, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{6}{5} & \\frac{11}{5} & \\frac{48}{5} \\\\\n -\\frac{23}{5} & -\\frac{27}{5} & \\frac{6}{5} \\\\\n -\\frac{34}{5} & -\\frac{33}{5} & -\\frac{12}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{4.362,-4.654,1.\\}, \\{-0.378-1.107 i,0.605\\, -0.221 i,1.\\}, \\{-0.378+1.107 i,0.605\\, +0.221 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(6/5), (11/5), (48/5)],\n [-(23/5), -(27/5), (6/5)],\n [-(34/5), -(33/5), -(12/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & -2 & 0 & 0 \\\\\n -1 & -3 & 0 & 0 \\\\\n 0 & -2 & 1 & 0 \\\\\n -3 & 2 & 3 & 3 \\\\\n 1 & 3 & -1 & -3 \\\\\n 0 & 1 & 3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.95 \\\\\n -0.83 \\\\\n -0.58 \\\\\n -1.69 \\\\\n 1.39 \\\\\n 0.49 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.058 \\\\\n 0.198 \\\\\n -0.244 \\\\\n -0.3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2, 0, 0],\n [-1, -3, 0, 0],\n [0, -2, 1, 0],\n [-3, 2, 3, 3],\n [1, 3, -1, -3],\n [0, 1, 3, -3]])\nb = np.array([\n [-0.95],\n [-0.83],\n [-0.58],\n [-1.69],\n [1.39],\n [0.49]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{57}{16}, -\\frac{65}{16}}$ to the line $-\\frac{9 x}{2}+\\frac{29 y}{32}+\\frac{7}{16}=0$.", - "Output Answer": [ - "$\\frac{9869}{16 \\sqrt{21577}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (57/16), -(65/16)\nline = Poly(-((9*x)/2)+((29*y)/32)+(7/16), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{4} \\\\\n \\frac{9}{4} \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{5}{\\sqrt{122}} \\\\\n \\frac{9}{\\sqrt{122}} \\\\\n 2 \\sqrt{\\frac{2}{61}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/4)],\n [(9/4)],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{4}{3} \\\\\n -10 \\\\\n -5 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3)],\n [-10],\n [-5],\n [5]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{9} \\\\\n -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{17}{\\sqrt{514}} \\\\\n -\\frac{15}{\\sqrt{514}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/9)],\n [-(5/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -9 & 10 \\\\\n -4 & -10 \\\\\n -2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 10],\n [-4, -10],\n [-2, 0]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -2 & -9 & 8 & 8 \\\\\n -7 & -3 & -2 & 2 \\\\\n -6 & -4 & 1 & -4 \\\\\n -4 & -8 & 2 & 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -9 & 2 & -4 & 0 \\\\\n -1 & 7 & -4 & -9 \\\\\n 5 & 2 & 9 & 4 \\\\\n 9 & -7 & -1 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -11 & -7 & 4 & 8 \\\\\n -8 & 4 & -6 & -7 \\\\\n -1 & -2 & 10 & 0 \\\\\n 5 & -15 & 1 & 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -9, 8, 8],\n [-7, -3, -2, 2],\n [-6, -4, 1, -4],\n [-4, -8, 2, 7]])\nb = np.array([\n [-9, 2, -4, 0],\n [-1, 7, -4, -9],\n [5, 2, 9, 4],\n [9, -7, -1, 3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -8 & -10 & -9 \\\\\n 0 & -3 & -1 \\\\\n -1 & 9 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-15 x^2-68 x-151$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -10, -9],\n [0, -3, -1],\n [-1, 9, -4]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{25}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & 7 & 3 \\\\\n 5 & -5 & -1 \\\\\n 9 & 2 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{9}{25} & \\frac{21}{25} & \\frac{9}{25} \\\\\n \\frac{3}{5} & -\\frac{3}{5} & -\\frac{3}{25} \\\\\n \\frac{27}{25} & \\frac{6}{25} & \\frac{6}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 7, 3],\n [5, -5, -1],\n [9, 2, 10]])\nprint(a * (3/25))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{16} \\\\\n -\\frac{3}{2} \\\\\n -\\frac{3}{8} \\\\\n -\\frac{19}{8} \\\\\n \\frac{11}{4} \\\\\n -\\frac{19}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{17}{\\sqrt{4642}} \\\\\n -12 \\sqrt{\\frac{2}{2321}} \\\\\n -3 \\sqrt{\\frac{2}{2321}} \\\\\n -19 \\sqrt{\\frac{2}{2321}} \\\\\n 2 \\sqrt{\\frac{22}{211}} \\\\\n -\\frac{19}{\\sqrt{4642}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/16)],\n [-(3/2)],\n [-(3/8)],\n [-(19/8)],\n [(11/4)],\n [-(19/16)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & \\frac{22}{5} \\\\\n \\frac{22}{5} & -\\frac{12}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{604}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, (22/5)],\n [(22/5), -(12/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & 0 & -6 \\\\\n -10 & 5 & -7 \\\\\n 10 & -1 & 4 \\\\\n 6 & -5 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, 0, -6],\n [-10, 5, -7],\n [10, -1, 4],\n [6, -5, -1]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{11}{7} & -2 & -\\frac{13}{7} & 3 & -\\frac{12}{7} \\\\\n -\\frac{8}{7} & \\frac{6}{7} & -\\frac{10}{7} & -\\frac{1}{7} & \\frac{12}{7} \\\\\n \\frac{20}{7} & \\frac{5}{7} & \\frac{9}{7} & \\frac{1}{7} & \\frac{8}{7} \\\\\n -2 & -\\frac{10}{7} & \\frac{19}{7} & -\\frac{8}{7} & -\\frac{20}{7} \\\\\n -\\frac{11}{7} & -\\frac{13}{7} & -\\frac{5}{7} & \\frac{13}{7} & \\frac{1}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 0 & -\\frac{19}{7} \\\\\n \\frac{18}{7} & -\\frac{13}{7} \\\\\n \\frac{16}{7} & \\frac{2}{7} \\\\\n \\frac{12}{7} & \\frac{20}{7} \\\\\n 2 & \\frac{17}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{376}{49} & \\frac{83}{7} \\\\\n \\frac{104}{49} & \\frac{34}{7} \\\\\n \\frac{358}{49} & -\\frac{271}{49} \\\\\n -\\frac{36}{7} & -\\frac{66}{49} \\\\\n -\\frac{144}{49} & \\frac{645}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/7), -2, -(13/7), 3, -(12/7)],\n [-(8/7), (6/7), -(10/7), -(1/7), (12/7)],\n [(20/7), (5/7), (9/7), (1/7), (8/7)],\n [-2, -(10/7), (19/7), -(8/7), -(20/7)],\n [-(11/7), -(13/7), -(5/7), (13/7), (1/7)]])\nb = np.array([\n [0, -(19/7)],\n [(18/7), -(13/7)],\n [(16/7), (2/7)],\n [(12/7), (20/7)],\n [2, (17/7)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & -\\frac{1}{2} \\\\\n -3 & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{33}{8} & -\\frac{25}{8} \\\\\n -\\frac{75}{4} & -\\frac{167}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), -(1/2)],\n [-3, -(5/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{8}{7} & -\\frac{8}{7} & -\\frac{17}{7} & -2 \\\\\n \\frac{17}{7} & -\\frac{6}{7} & \\frac{11}{7} & -\\frac{9}{7} \\\\\n -\\frac{13}{7} & -\\frac{15}{7} & \\frac{6}{7} & -\\frac{18}{7} \\\\\n -\\frac{10}{7} & \\frac{19}{7} & -\\frac{16}{7} & \\frac{1}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{12}{7} & \\frac{8}{7} & \\frac{4}{7} & -\\frac{13}{7} \\\\\n -\\frac{2}{7} & \\frac{20}{7} & -\\frac{20}{7} & -\\frac{4}{7} \\\\\n \\frac{12}{7} & \\frac{20}{7} & -\\frac{19}{7} & -\\frac{17}{7} \\\\\n -\\frac{2}{7} & -2 & -\\frac{13}{7} & -\\frac{5}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{256}{49} & -\\frac{368}{49} & \\frac{633}{49} & \\frac{495}{49} \\\\\n \\frac{366}{49} & \\frac{362}{49} & \\frac{96}{49} & -\\frac{339}{49} \\\\\n -\\frac{18}{49} & -\\frac{32}{49} & \\frac{368}{49} & \\frac{31}{7} \\\\\n -\\frac{352}{49} & -\\frac{34}{49} & -\\frac{129}{49} & \\frac{321}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/7), -(8/7), -(17/7), -2],\n [(17/7), -(6/7), (11/7), -(9/7)],\n [-(13/7), -(15/7), (6/7), -(18/7)],\n [-(10/7), (19/7), -(16/7), (1/7)]])\nb = np.array([\n [(12/7), (8/7), (4/7), -(13/7)],\n [-(2/7), (20/7), -(20/7), -(4/7)],\n [(12/7), (20/7), -(19/7), -(17/7)],\n [-(2/7), -2, -(13/7), -(5/7)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{21}{4} \\\\\n \\frac{27}{4} \\\\\n \\frac{5}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n \\frac{11}{8} \\\\\n \\frac{67}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{877}{16} \\\\\n -\\frac{1767}{32} \\\\\n \\frac{2175}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(21/4)],\n [(27/4)],\n [(5/4)]])\nb = np.array([\n [-9],\n [(11/8)],\n [(67/8)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 2 & 1 & 1 & -2 \\\\\n -3 & -1 & 2 & -1 \\\\\n -3 & 3 & 0 & -1 \\\\\n 0 & 1 & -1 & -1 \\\\\n -3 & 1 & 3 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -1 & -1 & 0 \\\\\n -2 & -2 & -3 \\\\\n -3 & 2 & -3 \\\\\n 1 & 2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -9 & -6 & -10 \\\\\n -2 & 7 & -5 \\\\\n -4 & -5 & -11 \\\\\n 0 & -6 & -2 \\\\\n -6 & 11 & -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, 1, -2],\n [-3, -1, 2, -1],\n [-3, 3, 0, -1],\n [0, 1, -1, -1],\n [-3, 1, 3, 2]])\nb = np.array([\n [-1, -1, 0],\n [-2, -2, -3],\n [-3, 2, -3],\n [1, 2, 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 7 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -48 \\\\\n -20 \\\\\n 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [2],\n [8]])\nb = np.array([\n [-2],\n [7],\n [4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -2 & 1 \\\\\n 1 & -2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -14 & 13 \\\\\n 13 & -14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 1],\n [1, -2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{62}{7} \\\\\n 8 \\\\\n -\\frac{31}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{34}{7} \\\\\n -5 \\\\\n -\\frac{10}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{235}{7} \\\\\n \\frac{1674}{49} \\\\\n -\\frac{38}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(62/7)],\n [8],\n [-(31/7)]])\nb = np.array([\n [-(34/7)],\n [-5],\n [-(10/7)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & 7 \\\\\n 8 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(5-\\sqrt{393}\\right),\\frac{1}{2} \\left(5+\\sqrt{393}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 7],\n [8, -4]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -6 & -10 & -9 & -8 & 3 \\\\\n 2 & -2 & 1 & -10 & -3 \\\\\n -3 & 0 & -10 & -1 & -5 \\\\\n 9 & 3 & 6 & 6 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -10, -9, -8, 3],\n [2, -2, 1, -10, -3],\n [-3, 0, -10, -1, -5],\n [9, 3, 6, 6, 4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & -\\frac{15}{2} \\\\\n -\\frac{1}{2} & \\frac{19}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{2} \\left(17-\\sqrt{349}\\right),1\\right\\}, \\left\\{\\frac{1}{2} \\left(17+\\sqrt{349}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(15/2)],\n [-(1/2), (19/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{6} \\\\\n 1 \\\\\n -\\frac{13}{6} \\\\\n \\frac{11}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{327}} \\\\\n 2 \\sqrt{\\frac{3}{109}} \\\\\n -\\frac{13}{\\sqrt{327}} \\\\\n \\frac{11}{\\sqrt{327}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/6)],\n [1],\n [-(13/6)],\n [(11/6)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -\\frac{9}{7} \\\\\n \\frac{13}{7} \\\\\n 1 \\\\\n \\frac{11}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\sqrt{\\frac{7}{67}} \\\\\n -\\frac{9}{\\sqrt{469}} \\\\\n \\frac{13}{\\sqrt{469}} \\\\\n \\sqrt{\\frac{7}{67}} \\\\\n \\frac{11}{\\sqrt{469}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-(9/7)],\n [(13/7)],\n [1],\n [(11/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 6 \\\\\n 9 \\\\\n 0 \\\\\n 6 \\\\\n 2 \\\\\n 2 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 1 \\\\\n 4 \\\\\n 8 \\\\\n 3 \\\\\n -9 \\\\\n 1 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{263}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [6],\n [9],\n [0],\n [6],\n [2],\n [2],\n [-5]])\nb = np.array([\n [5],\n [1],\n [4],\n [8],\n [3],\n [-9],\n [1],\n [-8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & 4 \\\\\n -8 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} i \\left(\\sqrt{7}-i\\right),1\\right\\}, \\left\\{-\\frac{1}{4} i \\left(\\sqrt{7}+i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 4],\n [-8, -4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{1}{2},-2,1\\right\\}, \\left\\{-\\frac{7}{2},5,\\frac{5}{2}\\right\\}, \\left\\{\\frac{3}{2},-\\frac{3}{2},3\\right\\}}$.", - "Output Answer": [ - "$106 x+72 y-124 z+321=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(1/2), -2, 1],\n [-(7/2), 5, (5/2)],\n [(3/2), -(3/2), 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & \\frac{10}{3} \\\\\n 3 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{-\\frac{5}{3},1\\right\\}, \\left\\{\\frac{2}{3},1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, (10/3)],\n [3, 6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & 1 & 0 \\\\\n 1 & -2 & -3 \\\\\n -1 & 0 & -2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 5 & 0 & -3 \\\\\n 3 & 5 & 12 \\\\\n 0 & -1 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, 0],\n [1, -2, -3],\n [-1, 0, -2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{25}{6} & \\frac{19}{6} & \\frac{9}{2} & -\\frac{1}{3} & -10 \\\\\n \\frac{7}{2} & \\frac{28}{3} & 9 & \\frac{17}{6} & \\frac{23}{6} \\\\\n -\\frac{43}{6} & -\\frac{17}{6} & \\frac{13}{3} & \\frac{13}{3} & \\frac{7}{6} \\\\\n -3 & -\\frac{47}{6} & 1 & -\\frac{35}{6} & \\frac{11}{6} \\\\\n -\\frac{41}{6} & -5 & -\\frac{31}{6} & 3 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/6), (19/6), (9/2), -(1/3), -10],\n [(7/2), (28/3), 9, (17/6), (23/6)],\n [-(43/6), -(17/6), (13/3), (13/3), (7/6)],\n [-3, -(47/6), 1, -(35/6), (11/6)],\n [-(41/6), -5, -(31/6), 3, -9]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 4 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 1 \\\\\n -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3 \\\\\n 5 \\\\\n 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [4],\n [8]])\nb = np.array([\n [6],\n [1],\n [-6]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 2 \\\\\n 0 \\\\\n 8 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -9 \\\\\n -10 \\\\\n 2 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{330}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [2],\n [0],\n [8],\n [-2]])\nb = np.array([\n [9],\n [-9],\n [-10],\n [2],\n [6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{9}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -7 & -4 \\\\\n 9 & -5 \\\\\n 5 & 3 \\\\\n -6 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{7}{9} & \\frac{4}{9} \\\\\n -1 & \\frac{5}{9} \\\\\n -\\frac{5}{9} & -\\frac{1}{3} \\\\\n \\frac{2}{3} & \\frac{1}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -4],\n [9, -5],\n [5, 3],\n [-6, -1]])\nprint(a * -(1/9))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -9 & \\frac{60}{7} \\\\\n -\\frac{62}{7} & -\\frac{12}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{75 x}{7}+\\frac{4476}{49}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, (60/7)],\n [-(62/7), -(12/7)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 2 \\\\\n -2 \\\\\n 2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -2 \\\\\n 2 \\\\\n 1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{0,\\frac{12}{13},-\\frac{12}{13},-\\frac{6}{13},\\frac{12}{13}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [2],\n [-2],\n [2],\n [0]]).squeeze()\nb = np.array([\n [0],\n [-2],\n [2],\n [1],\n [-2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -0.1 \\\\\n -9.6 \\\\\n -6. \\\\\n 2.8 \\\\\n -2.1 \\\\\n 0.4 \\\\\n 10. \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2.4 \\\\\n 2.9 \\\\\n 4.3 \\\\\n -4. \\\\\n 1. \\\\\n -9.8 \\\\\n -6.3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$26.3289$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-0.1],\n [-9.6],\n [-6.],\n [2.8],\n [-2.1],\n [0.4],\n [10.]])\nb = np.array([\n [-2.4],\n [2.9],\n [4.3],\n [-4.],\n [1.],\n [-9.8],\n [-6.3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & 4 & -\\frac{19}{2} \\\\\n \\frac{7}{2} & 4 & -\\frac{15}{2} \\\\\n \\frac{13}{2} & 1 & \\frac{11}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.305,3.14,1.\\}, \\{0.028\\, -1.081 i,0.237\\, -0.981 i,1.\\}, \\{0.028\\, +1.081 i,0.237\\, +0.981 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), 4, -(19/2)],\n [(7/2), 4, -(15/2)],\n [(13/2), 1, (11/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,3,-2\\}, \\{-1,0,0\\}, \\{4,3,-3\\}}$.", - "Output Answer": [ - "$3 x+16 y+21 z+3=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, 3, -2],\n [-1, 0, 0],\n [4, 3, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\pi \\\\\n -\\pi \\\\\n 2 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\pi \\\\\n \\pi \\\\\n 2 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{5} \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-2*math.pi],\n [-math.pi],\n [2*math.pi]])\nb = np.array([\n [-3*math.pi],\n [math.pi],\n [2*math.pi]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${2, -4}$ to the line $-2 x+4 y+1=0$.", - "Output Answer": [ - "$\\frac{19}{2 \\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 2, -4\nline = Poly(-2*x+4*y+1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{32}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 4 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{7}{32} \\\\\n -\\frac{1}{8} \\\\\n -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [4],\n [8]])\nprint(a * -(1/32))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -3 & -7 & -7 & 0 \\\\\n -4 & 7 & 4 & 2 \\\\\n -7 & 6 & -9 & -2 \\\\\n -1 & 7 & -1 & 1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 3 & -6 & -3 & 3 \\\\\n -3 & 1 & -9 & 2 \\\\\n -6 & -3 & -1 & 6 \\\\\n 2 & 5 & -6 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -6 & -1 & -4 & -3 \\\\\n -1 & 6 & 13 & 0 \\\\\n -1 & 9 & -8 & -8 \\\\\n -3 & 2 & 5 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -7, -7, 0],\n [-4, 7, 4, 2],\n [-7, 6, -9, -2],\n [-1, 7, -1, 1]])\nb = np.array([\n [3, -6, -3, 3],\n [-3, 1, -9, 2],\n [-6, -3, -1, 6],\n [2, 5, -6, -5]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -7 & 0 & 8 & 10 & 6 \\\\\n 8 & 3 & -5 & -7 & -1 \\\\\n 0 & 0 & 9 & 4 & 1 \\\\\n -7 & -9 & -4 & -3 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 159 \\\\\n 0 & 1 & 0 & 0 & -\\frac{887}{6} \\\\\n 0 & 0 & 1 & 0 & -77 \\\\\n 0 & 0 & 0 & 1 & \\frac{347}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, 0, 8, 10, 6],\n [8, 3, -5, -7, -1],\n [0, 0, 9, 4, 1],\n [-7, -9, -4, -3, 5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & -3 & 3 \\\\\n -1 & -5 & 3 \\\\\n 2 & -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{2}{5} & \\frac{1}{5} & \\frac{1}{5} \\\\\n \\frac{3}{10} & -\\frac{2}{5} & \\frac{1}{10} \\\\\n \\frac{11}{30} & -\\frac{4}{15} & \\frac{7}{30} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, 3],\n [-1, -5, 3],\n [2, -1, 3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{50}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 7 & -7 & -9 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{49}{50} & -\\frac{49}{50} & -\\frac{63}{50} & -\\frac{21}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -7, -9, -3]])\nprint(a * (7/50))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 1 & 1 & 3 & 2 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 2 & -2 \\\\\n -1 & 1 \\\\\n 0 & -2 \\\\\n 1 & 2 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 3 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1, 3, 2, -1]])\nb = np.array([\n [2, -2],\n [-1, 1],\n [0, -2],\n [1, 2],\n [0, 1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2 \\\\\n -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-4]])\nb = np.array([\n [1],\n [-1]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{13}{64}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{39}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6]])\nprint(a * -(13/64))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 3 & 3 \\\\\n 0 & -4 & 0 \\\\\n 1 & 0 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$12$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 3, 3],\n [0, -4, 0],\n [1, 0, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{23}{5} \\\\\n \\frac{28}{5} \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{47}{5} \\\\\n -\\frac{9}{5} \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{1333}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/5)],\n [(28/5)],\n [0]])\nb = np.array([\n [-(47/5)],\n [-(9/5)],\n [2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & -5 & -2 \\\\\n -1 & -1 & -2 \\\\\n 2 & 3 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$73$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -5, -2],\n [-1, -1, -2],\n [2, 3, -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -5 & 6 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{2.,0.,1.\\}, \\{6.,5.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, 6, 10]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -8 \\\\\n -6 \\\\\n 3 \\\\\n -7 \\\\\n 8 \\\\\n 4 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -1 \\\\\n 6 \\\\\n 3 \\\\\n -3 \\\\\n 9 \\\\\n 7 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$139$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-8],\n [-6],\n [3],\n [-7],\n [8],\n [4],\n [1]])\nb = np.array([\n [4],\n [-1],\n [6],\n [3],\n [-3],\n [9],\n [7],\n [1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & -4 & 8 \\\\\n -1 & -1 & -2 \\\\\n 7 & 5 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.852,2.268,1.\\}, \\{-1.898,0.025,1.\\}, \\{0.691,-0.21,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -4, 8],\n [-1, -1, -2],\n [7, 5, 8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{6}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & 6 & 3 \\\\\n -6 & 10 & 1 \\\\\n -7 & 1 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{5}{6} & -5 & -\\frac{5}{2} \\\\\n 5 & -\\frac{25}{3} & -\\frac{5}{6} \\\\\n \\frac{35}{6} & -\\frac{5}{6} & \\frac{20}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 6, 3],\n [-6, 10, 1],\n [-7, 1, -8]])\nprint(a * -(5/6))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2 \\log (2),\\log (2),\\log (2)\\}, \\{0,2 \\log (2),4 \\log (2)\\}, \\{3 \\log (2),\\log (2),-\\log (2)\\}}$", - "Output Answer": [ - "${\\left\\{\\sqrt{\\frac{2}{3}},\\frac{1}{\\sqrt{6}},\\frac{1}{\\sqrt{6}}\\right\\}, \\left\\{-\\sqrt{\\frac{2}{7}},\\frac{1}{\\sqrt{14}},\\frac{3}{\\sqrt{14}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{21}},\\frac{4}{\\sqrt{21}},-\\frac{2}{\\sqrt{21}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((2*math.log(2), math.log(2), math.log(2)), (0, 2*math.log(2), 4*math.log(2)), (3*math.log(2), math.log(2), -math.log(2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{453}{100} \\\\\n -\\frac{287}{50} \\\\\n \\frac{767}{100} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{641}{100} \\\\\n -\\frac{32}{25} \\\\\n \\frac{371}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{57389}{5000} \\\\\n -\\frac{20224}{625} \\\\\n -\\frac{6199}{200} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(453/100)],\n [-(287/50)],\n [(767/100)]])\nb = np.array([\n [-(641/100)],\n [-(32/25)],\n [(371/100)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-4, 3, 0}$ to the plane $3 x+3 z-1=0$.", - "Output Answer": [ - "$\\frac{13}{3 \\sqrt{2}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -4, 3, 0\nplane = Poly(3*x+3*z-1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -5 & -9 & 0 \\\\\n -7 & 4 & -1 \\\\\n 9 & 7 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, -9, 0],\n [-7, 4, -1],\n [9, 7, -3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 0 & 8 & 7 \\\\\n 5 & 9 & -5 \\\\\n -4 & 0 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+3 x^2+66 x+652$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 8, 7],\n [5, 9, -5],\n [-4, 0, -6]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{ccc}\n 2 & -1 & -1 \\\\\n 0 & 1 & -1 \\\\\n 0 & 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n e^2 & e-e^2 & e-e^2 \\\\\n 0 & e & e-e^2 \\\\\n 0 & 0 & e^2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [2, -1, -1],\n [0, 1, -1],\n [0, 0, 2]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & -\\frac{5}{2} & -\\frac{5}{2} \\\\\n 1 & \\frac{3}{2} & -\\frac{1}{2} \\\\\n -2 & 0 & \\frac{1}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{57}{4} & -\\frac{235}{8} & -\\frac{115}{8} \\\\\n \\frac{63}{4} & -\\frac{93}{8} & -\\frac{103}{8} \\\\\n -\\frac{31}{2} & 20 & \\frac{101}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(5/2), -(5/2)],\n [1, (3/2), -(1/2)],\n [-2, 0, (1/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 0 & 0 & 1 \\\\\n -1 & 1 & 1 \\\\\n 1 & -1 & -1 \\\\\n 1 & 0 & 2 \\\\\n 0 & 3 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -3 & -1 & 1 & 1 & -2 \\\\\n -3 & 0 & 0 & 3 & 0 \\\\\n 3 & 2 & 0 & -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 3 & 2 & 0 & -1 & 2 \\\\\n 3 & 3 & -1 & 1 & 4 \\\\\n -3 & -3 & 1 & -1 & -4 \\\\\n 3 & 3 & 1 & -1 & 2 \\\\\n -9 & 0 & 0 & 9 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0, 1],\n [-1, 1, 1],\n [1, -1, -1],\n [1, 0, 2],\n [0, 3, 0]])\nb = np.array([\n [-3, -1, 1, 1, -2],\n [-3, 0, 0, 3, 0],\n [3, 2, 0, -1, 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 3 & -9 & -7 \\\\\n 2 & 7 & 3 \\\\\n 1 & -6 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{2.761\\, -5.213 i,2.761\\, +5.213 i,3.477\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -9, -7],\n [2, 7, 3],\n [1, -6, -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{1,2,0\\}, \\{0,-1,2\\}, \\{-2,1,0\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{5}},\\frac{2}{\\sqrt{5}},0\\right\\}, \\left\\{\\frac{2}{\\sqrt{105}},-\\frac{1}{\\sqrt{105}},2 \\sqrt{\\frac{5}{21}}\\right\\}, \\left\\{-\\frac{4}{\\sqrt{21}},\\frac{2}{\\sqrt{21}},\\frac{1}{\\sqrt{21}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((1, 2, 0), (0, -1, 2), (-2, 1, 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 10 & -10 & -4 & 5 & 7 & -2 & 6 \\\\\n 6 & 7 & 3 & -7 & -2 & 10 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & \\frac{1}{65} & -\\frac{7}{26} & \\frac{29}{130} & \\frac{43}{65} & -\\frac{4}{65} \\\\\n 0 & 1 & \\frac{27}{65} & -\\frac{10}{13} & -\\frac{31}{65} & \\frac{56}{65} & -\\frac{43}{65} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, -10, -4, 5, 7, -2, 6],\n [6, 7, 3, -7, -2, 10, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -3 & 0 & -2 & 1 & 1 \\\\\n 2 & -2 & -1 & 1 & 2 \\\\\n 1 & 3 & 2 & -3 & 3 \\\\\n -1 & -2 & 2 & 1 & 1 \\\\\n -1 & -2 & 3 & 2 & -1 \\\\\n -1 & -2 & 2 & 1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.65 \\\\\n -1.61 \\\\\n 2.54 \\\\\n -0.34 \\\\\n 1.07 \\\\\n -1.35 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.485 \\\\\n 0.921 \\\\\n 0.721 \\\\\n 0.461 \\\\\n -0.278 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, -2, 1, 1],\n [2, -2, -1, 1, 2],\n [1, 3, 2, -3, 3],\n [-1, -2, 2, 1, 1],\n [-1, -2, 3, 2, -1],\n [-1, -2, 2, 1, 2]])\nb = np.array([\n [-2.65],\n [-1.61],\n [2.54],\n [-0.34],\n [1.07],\n [-1.35]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n \\frac{1}{5} \\\\\n -\\frac{2}{5} \\\\\n \\frac{9}{5} \\\\\n -\\frac{11}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{6}{5} \\\\\n -\\frac{14}{5} \\\\\n -1 \\\\\n -\\frac{1}{5} \\\\\n -\\frac{7}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{204}{1535},-\\frac{476}{1535},-\\frac{34}{307},-\\frac{34}{1535},-\\frac{238}{1535}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [(1/5)],\n [-(2/5)],\n [(9/5)],\n [-(11/5)]]).squeeze()\nb = np.array([\n [-(6/5)],\n [-(14/5)],\n [-1],\n [-(1/5)],\n [-(7/5)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{71}{10} \\\\\n \\frac{33}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{71}{10}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(71/10)],\n [(33/10)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -\\frac{22}{9} & \\frac{16}{9} \\\\\n \\frac{59}{9} & -\\frac{85}{9} \\\\\n -\\frac{2}{9} & 2 \\\\\n -\\frac{89}{9} & \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(22/9), (16/9)],\n [(59/9), -(85/9)],\n [-(2/9), 2],\n [-(89/9), (4/3)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{2}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 7 & -3 & 1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{7}{2} & -\\frac{3}{2} & \\frac{1}{2} & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -3, 1, 4]])\nprint(a * (1/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -9 & 8 & 4 & 7 \\\\\n -4 & 4 & 2 & 7 \\\\\n -2 & -4 & -10 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 7 \\\\\n 0 & 1 & 0 & \\frac{191}{16} \\\\\n 0 & 0 & 1 & -\\frac{51}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-9, 8, 4, 7],\n [-4, 4, 2, 7],\n [-2, -4, -10, 2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 0 & -7 \\\\\n 2 & -5 \\\\\n -5 & 6 \\\\\n -7 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, -7],\n [2, -5],\n [-5, 6],\n [-7, 10]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 3 & -1 & 6 & -10 \\\\\n -5 & 0 & 9 & -7 \\\\\n 7 & 5 & -7 & -8 \\\\\n -9 & -5 & -6 & 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -8 & -5 & 1 & 1 \\\\\n 6 & 5 & -1 & -9 \\\\\n -2 & -8 & -3 & 0 \\\\\n -4 & 6 & -6 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -5 & -6 & 7 & -9 \\\\\n 1 & 5 & 8 & -16 \\\\\n 5 & -3 & -10 & -8 \\\\\n -13 & 1 & -12 & 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, 6, -10],\n [-5, 0, 9, -7],\n [7, 5, -7, -8],\n [-9, -5, -6, 7]])\nb = np.array([\n [-8, -5, 1, 1],\n [6, 5, -1, -9],\n [-2, -8, -3, 0],\n [-4, 6, -6, 4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 3 & -\\frac{1}{2} \\\\\n 1 & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{17}{2} & -\\frac{1}{4} \\\\\n \\frac{1}{2} & \\frac{23}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -(1/2)],\n [1, -(5/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{20}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 9 & 10 & -7 & -8 \\\\\n 8 & -7 & -5 & 1 \\\\\n 9 & 2 & 5 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{27}{20} & -\\frac{3}{2} & \\frac{21}{20} & \\frac{6}{5} \\\\\n -\\frac{6}{5} & \\frac{21}{20} & \\frac{3}{4} & -\\frac{3}{20} \\\\\n -\\frac{27}{20} & -\\frac{3}{10} & -\\frac{3}{4} & -\\frac{9}{20} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 10, -7, -8],\n [8, -7, -5, 1],\n [9, 2, 5, 3]])\nprint(a * -(3/20))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{2} & 2 & -2 \\\\\n 1 & -1 & 3 \\\\\n \\frac{5}{2} & 3 & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{13}{4} & -13 & 13 \\\\\n 4 & 12 & -8 \\\\\n -\\frac{23}{4} & -1 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), 2, -2],\n [1, -1, 3],\n [(5/2), 3, -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{8} \\\\\n -\\frac{33}{16} \\\\\n \\frac{67}{8} \\\\\n \\frac{3}{16} \\\\\n -\\frac{33}{16} \\\\\n \\frac{5}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{67}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/8)],\n [-(33/16)],\n [(67/8)],\n [(3/16)],\n [-(33/16)],\n [(5/4)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{6}{7} & \\frac{17}{7} & \\frac{12}{7} & \\frac{1}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{18}{7} & -\\frac{11}{7} & \\frac{2}{7} \\\\\n -3 & -\\frac{13}{7} & -2 \\\\\n \\frac{17}{7} & -\\frac{6}{7} & \\frac{20}{7} \\\\\n -\\frac{15}{7} & -\\frac{8}{7} & -\\frac{15}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{276}{49} & -\\frac{235}{49} & -\\frac{25}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(6/7), (17/7), (12/7), (1/7)]])\nb = np.array([\n [(18/7), -(11/7), (2/7)],\n [-3, -(13/7), -2],\n [(17/7), -(6/7), (20/7)],\n [-(15/7), -(8/7), -(15/7)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -3 & -3 & -2 & 3 & 2 \\\\\n 2 & 1 & -1 & 0 & 3 \\\\\n -1 & 1 & 3 & -3 & -3 \\\\\n 1 & 0 & -2 & 1 & -2 \\\\\n -2 & 3 & -1 & -1 & 0 \\\\\n -2 & -2 & 3 & -2 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.41 \\\\\n -0.55 \\\\\n 0.28 \\\\\n 1.84 \\\\\n 1.91 \\\\\n -1.08 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.262 \\\\\n -0.333 \\\\\n -1.281 \\\\\n -1.094 \\\\\n -0.315 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3, -2, 3, 2],\n [2, 1, -1, 0, 3],\n [-1, 1, 3, -3, -3],\n [1, 0, -2, 1, -2],\n [-2, 3, -1, -1, 0],\n [-2, -2, 3, -2, 2]])\nb = np.array([\n [0.41],\n [-0.55],\n [0.28],\n [1.84],\n [1.91],\n [-1.08]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 3 & -1 & -4 \\\\\n -3 & 2 & -3 \\\\\n -2 & 3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{3}{10} & -\\frac{9}{50} & \\frac{11}{50} \\\\\n \\frac{3}{10} & \\frac{1}{50} & \\frac{21}{50} \\\\\n -\\frac{1}{10} & -\\frac{7}{50} & \\frac{3}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, -4],\n [-3, 2, -3],\n [-2, 3, 3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -3 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 2 \\\\\n 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -11 \\\\\n -14 \\\\\n -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-3],\n [-5]])\nb = np.array([\n [-7],\n [2],\n [7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -4 & 9 & -4 & 1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.,0.,0.,0.,2.\\}, \\{-1.,0.,1.,0.,0.\\}, \\{1.,0.,0.,4.,0.\\}, \\{9.,4.,0.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, 9, -4, 1, -2]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n \\frac{11}{5} & -\\frac{13}{5} \\\\\n -2 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{14}{5} & -3 & \\frac{2}{5} & -\\frac{2}{5} & \\frac{2}{5} \\\\\n -\\frac{1}{5} & \\frac{7}{5} & \\frac{12}{5} & \\frac{6}{5} & \\frac{1}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -\\frac{141}{25} & -\\frac{256}{25} & -\\frac{134}{25} & -4 & \\frac{9}{25} \\\\\n \\frac{27}{5} & \\frac{37}{5} & \\frac{8}{5} & 2 & -\\frac{3}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/5), -(13/5)],\n [-2, 1]])\nb = np.array([\n [-(14/5), -3, (2/5), -(2/5), (2/5)],\n [-(1/5), (7/5), (12/5), (6/5), (1/5)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{2}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -10 & 9 & -8 \\\\\n -2 & 4 & 2 \\\\\n 1 & 6 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 25 & -\\frac{45}{2} & 20 \\\\\n 5 & -10 & -5 \\\\\n -\\frac{5}{2} & -15 & 25 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 9, -8],\n [-2, 4, 2],\n [1, 6, -10]])\nprint(a * -(5/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -3 & 1 & 2 & 0 & 3 \\\\\n 3 & 1 & -2 & 1 & -2 \\\\\n -3 & -3 & -2 & -3 & 1 \\\\\n -1 & 3 & -2 & -1 & -3 \\\\\n -3 & -2 & -1 & 1 & 3 \\\\\n 1 & 0 & 3 & 1 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.1 \\\\\n -0.58 \\\\\n 0.37 \\\\\n -0.03 \\\\\n 1.87 \\\\\n 2.72 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.821 \\\\\n -0.269 \\\\\n 0.312 \\\\\n 0.755 \\\\\n -0.5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1, 2, 0, 3],\n [3, 1, -2, 1, -2],\n [-3, -3, -2, -3, 1],\n [-1, 3, -2, -1, -3],\n [-3, -2, -1, 1, 3],\n [1, 0, 3, 1, -3]])\nb = np.array([\n [2.1],\n [-0.58],\n [0.37],\n [-0.03],\n [1.87],\n [2.72]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & -5 & -3 \\\\\n 1 & -10 & -7 \\\\\n -8 & -6 & -1 \\\\\n 1 & 8 & 1 \\\\\n -3 & -10 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, -5, -3],\n [1, -10, -7],\n [-8, -6, -1],\n [1, 8, 1],\n [-3, -10, 6]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 6 & -2 \\\\\n -8 & -6 \\\\\n 8 & -5 \\\\\n 9 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, -2],\n [-8, -6],\n [8, -5],\n [9, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -1 & 3 & -4 \\\\\n -1 & 1 & -4 \\\\\n 0 & 3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{7}{2} & -\\frac{9}{2} & -2 \\\\\n \\frac{1}{2} & -\\frac{1}{2} & 0 \\\\\n -\\frac{3}{4} & \\frac{3}{4} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, -4],\n [-1, 1, -4],\n [0, 3, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 3+2 i & -1-i \\\\\n 3-3 i & -3+i \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -27+16 i & 7+i \\\\\n -3+21 i & 2 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3+2j, -1- 1j],\n [3-3j, -3+ 1j]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -5 & -5 & 10 \\\\\n 3 & -8 & -9 \\\\\n 8 & 7 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.843,-0.378,1.\\}, \\{-1.571-0.689 i,-0.141+1.851 i,1.\\}, \\{-1.571+0.689 i,-0.141-1.851 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -5, 10],\n [3, -8, -9],\n [8, 7, 5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 4 & -10 \\\\\n -9 & -1 \\\\\n 2 & 10 \\\\\n 6 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, -10],\n [-9, -1],\n [2, 10],\n [6, -5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,-5,5\\}, \\{2,4,-4\\}, \\{-1,1,-5\\}}$.", - "Output Answer": [ - "$12 x-11 y-3 z+8=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, -5, 5],\n [2, 4, -4],\n [-1, 1, -5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 5 \\\\\n 5 \\\\\n 1 \\\\\n 0 \\\\\n -7 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 4 \\\\\n -10 \\\\\n -2 \\\\\n 1 \\\\\n -5 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{557}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [5],\n [5],\n [1],\n [0],\n [-7],\n [-10]])\nb = np.array([\n [-5],\n [4],\n [-10],\n [-2],\n [1],\n [-5],\n [4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & 3 & -3 \\\\\n -2 & 3 & 4 \\\\\n 4 & -3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$87$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3, -3],\n [-2, 3, 4],\n [4, -3, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -2 & 0 & 0 & 0 & 1 \\\\\n 3 & 1 & -3 & 2 & 2 \\\\\n -1 & 1 & -1 & -3 & 2 \\\\\n -3 & 2 & 0 & 0 & -3 \\\\\n -3 & -1 & -1 & 0 & -3 \\\\\n -3 & 3 & 0 & -1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.56 \\\\\n 2.04 \\\\\n -0.36 \\\\\n -0.38 \\\\\n -0.8 \\\\\n 2.43 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.464 \\\\\n 0.788 \\\\\n -0.145 \\\\\n -0.026 \\\\\n -0.247 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, 0, 0, 1],\n [3, 1, -3, 2, 2],\n [-1, 1, -1, -3, 2],\n [-3, 2, 0, 0, -3],\n [-3, -1, -1, 0, -3],\n [-3, 3, 0, -1, -1]])\nb = np.array([\n [-1.56],\n [2.04],\n [-0.36],\n [-0.38],\n [-0.8],\n [2.43]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, 1, -2}$ to the plane $-2 x+4 y+4 z=0$.", - "Output Answer": [ - "$\\frac{5}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, 1, -2\nplane = Poly(-2*x+4*y+4*z, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{4} \\\\\n -1 \\\\\n 0 \\\\\n \\frac{21}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n \\frac{19}{4} \\\\\n \\frac{33}{4} \\\\\n \\frac{11}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{53}{4} \\\\\n \\frac{15}{4} \\\\\n \\frac{33}{4} \\\\\n \\frac{43}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/4)],\n [-1],\n [0],\n [(21/4)]])\nb = np.array([\n [-9],\n [(19/4)],\n [(33/4)],\n [(11/2)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -\\frac{55}{7} & \\frac{3}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(55/7), (3/7)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -7 \\\\\n 8 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -5 \\\\\n 1 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-45$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-7],\n [8],\n [-8]])\nb = np.array([\n [-8],\n [-5],\n [1],\n [3]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 10 \\\\\n -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 7 \\\\\n -18 \\\\\n -20 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-3],\n [2]])\nb = np.array([\n [0],\n [10],\n [-9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n \\frac{5}{4} \\\\\n \\frac{47}{8} \\\\\n -\\frac{27}{8} \\\\\n -\\frac{7}{8} \\\\\n \\frac{3}{8} \\\\\n \\frac{9}{2} \\\\\n \\frac{1}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [(5/4)],\n [(47/8)],\n [-(27/8)],\n [-(7/8)],\n [(3/8)],\n [(9/2)],\n [(1/8)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 9 & -\\frac{61}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{11}{3} & -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{38}{3} & -\\frac{103}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -(61/9)]])\nb = np.array([\n [(11/3), -(14/3)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{4} & \\frac{15}{4} & \\frac{25}{4} \\\\\n \\frac{21}{4} & \\frac{11}{4} & -9 \\\\\n 5 & 6 & -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-12 x^2-10 x+\\frac{211}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/4), (15/4), (25/4)],\n [(21/4), (11/4), -9],\n [5, 6, -10]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & 0 & 0 \\\\\n -4 & 5 & -3 \\\\\n 5 & 0 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$20$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 0, 0],\n [-4, 5, -3],\n [5, 0, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -2 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -9]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{33}{10} \\\\\n \\frac{33}{5} \\\\\n \\frac{14}{5} \\\\\n -\\frac{26}{5} \\\\\n \\frac{7}{2} \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{\\frac{5129}{2}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(33/10)],\n [(33/5)],\n [(14/5)],\n [-(26/5)],\n [(7/2)],\n [-1]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{4} & 2 \\\\\n \\frac{9}{2} & -\\frac{17}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{68}{229} & \\frac{32}{229} \\\\\n \\frac{72}{229} & -\\frac{20}{229} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/4), 2],\n [(9/2), -(17/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{29}{4} & -\\frac{3}{8} & \\frac{13}{16} \\\\\n \\frac{39}{4} & -\\frac{15}{8} & \\frac{5}{8} \\\\\n -\\frac{11}{4} & \\frac{11}{4} & -\\frac{5}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{117}{16} & -\\frac{71}{16} & -\\frac{25}{4} \\\\\n -\\frac{17}{8} & \\frac{19}{2} & \\frac{11}{8} \\\\\n -\\frac{103}{16} & \\frac{59}{16} & \\frac{43}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{233}{16} & \\frac{65}{16} & \\frac{113}{16} \\\\\n \\frac{95}{8} & -\\frac{91}{8} & -\\frac{3}{4} \\\\\n \\frac{59}{16} & -\\frac{15}{16} & -\\frac{63}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/4), -(3/8), (13/16)],\n [(39/4), -(15/8), (5/8)],\n [-(11/4), (11/4), -(5/4)]])\nb = np.array([\n [-(117/16), -(71/16), -(25/4)],\n [-(17/8), (19/2), (11/8)],\n [-(103/16), (59/16), (43/16)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{2} & -\\frac{23}{4} \\\\\n -\\frac{21}{4} & -\\frac{9}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{8} \\left(9-\\sqrt{2661}\\right),\\frac{1}{8} \\left(9+\\sqrt{2661}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/2), -(23/4)],\n [-(21/4), -(9/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 1 & 1 \\\\\n 2 & 2 & 4 \\\\\n 0 & -3 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$28$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, 1],\n [2, 2, 4],\n [0, -3, 5]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & 9 & -4 \\\\\n -2 & -10 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{28.,-16.,13.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, 9, -4],\n [-2, -10, -8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{33}{4} & -9 \\\\\n -\\frac{37}{4} & -\\frac{17}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{4} \\left(8-\\sqrt{1957}\\right),\\frac{1}{4} \\left(8+\\sqrt{1957}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(33/4), -9],\n [-(37/4), -(17/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,-1,2\\}, \\{4,4,4\\}, \\{3,3,0\\}}$.", - "Output Answer": [ - "$6 x-10 y+z+12=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, -1, 2],\n [4, 4, 4],\n [3, 3, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 0 & -2 & 0 & -2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 0 & 2 & 0 & 2 & 2 \\\\\n 0 & -2 & 0 & -2 & -2 \\\\\n 0 & 2 & 0 & 2 & 2 \\\\\n 0 & -4 & 0 & -4 & -4 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [-1],\n [2],\n [0]])\nb = np.array([\n [0, -2, 0, -2, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & 3 & 2 & -3 \\\\\n 2 & -3 & 0 & 3 \\\\\n -2 & -2 & -3 & 1 \\\\\n 0 & 2 & -3 & 1 \\\\\n -1 & 3 & -2 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.8 \\\\\n -0.17 \\\\\n -0.91 \\\\\n 1.6 \\\\\n 2.93 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.452 \\\\\n 0.578 \\\\\n 0.322 \\\\\n 0.905 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 3, 2, -3],\n [2, -3, 0, 3],\n [-2, -2, -3, 1],\n [0, 2, -3, 1],\n [-1, 3, -2, 2]])\nb = np.array([\n [-1.8],\n [-0.17],\n [-0.91],\n [1.6],\n [2.93]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 1 & 2 & 2 \\\\\n -1 & 1 & 3 \\\\\n 1 & -1 & 1 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & 3 & 2 & 0 \\\\\n 2 & -1 & 0 & 2 \\\\\n -3 & 2 & -2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 0 & 5 & -2 & 2 \\\\\n -9 & 2 & -8 & -1 \\\\\n -3 & 6 & 0 & -3 \\\\\n -3 & 2 & -2 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, 2],\n [-1, 1, 3],\n [1, -1, 1],\n [0, 0, 1]])\nb = np.array([\n [2, 3, 2, 0],\n [2, -1, 0, 2],\n [-3, 2, -2, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -5 & 5 \\\\\n 0 & -1 \\\\\n 6 & 4 \\\\\n 7 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 5],\n [0, -1],\n [6, 4],\n [7, -5]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n \\frac{67}{9} \\\\\n \\frac{7}{9} \\\\\n 9 \\\\\n -\\frac{25}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [(67/9)],\n [(7/9)],\n [9],\n [-(25/9)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 3 \\\\\n -\\frac{3}{2} \\\\\n 1 \\\\\n -\\frac{3}{2} \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{4}{5 \\sqrt{3}} \\\\\n \\frac{2 \\sqrt{3}}{5} \\\\\n -\\frac{\\sqrt{3}}{5} \\\\\n \\frac{2}{5 \\sqrt{3}} \\\\\n -\\frac{\\sqrt{3}}{5} \\\\\n \\frac{1}{5 \\sqrt{3}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [3],\n [-(3/2)],\n [1],\n [-(3/2)],\n [(1/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n 5 & 7 \\\\\n 5 & 4 \\\\\n 1 & 10 \\\\\n -5 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 7],\n [5, 4],\n [1, 10],\n [-5, -6]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 7 & 7 & -7 & -3 \\\\\n -2 & 1 & 10 & -10 \\\\\n -5 & -1 & -8 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -7 & 4 & 6 & -5 \\\\\n 7 & 4 & 10 & -2 \\\\\n -3 & 6 & -3 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 0 & 11 & -1 & -8 \\\\\n 5 & 5 & 20 & -12 \\\\\n -8 & 5 & -11 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 7, -7, -3],\n [-2, 1, 10, -10],\n [-5, -1, -8, 1]])\nb = np.array([\n [-7, 4, 6, -5],\n [7, 4, 10, -2],\n [-3, 6, -3, 1]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n -1 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2 \\\\\n 2 \\\\\n -2 \\\\\n -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [-1],\n [-3]])\nb = np.array([\n [2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{34}{5} & 0 \\\\\n \\frac{18}{5} & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{-\\frac{17}{9},1\\right\\}, \\{0,1\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(34/5), 0],\n [(18/5), 0]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & -2 \\\\\n -4 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{2 \\left(1-\\sqrt{2}\\right),2 \\left(1+\\sqrt{2}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2],\n [-4, 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -5 & \\frac{1}{2} \\\\\n 0 & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{5}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, (1/2)],\n [0, -(1/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 7 & 8 & 1 & -4 & 10 \\\\\n 8 & 3 & -2 & 8 & 3 \\\\\n -4 & -3 & -6 & -6 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-285.,330.,-109.,134.,0.\\}, \\{219.,-578.,411.,0.,268.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, 8, 1, -4, 10],\n [8, 3, -2, 8, 3],\n [-4, -3, -6, -6, 6]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{2}{\\sqrt{35}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [-1],\n [0],\n [-1],\n [0],\n [0],\n [1],\n [1]]).squeeze()\nb = np.array([\n [0],\n [1],\n [1],\n [-1],\n [-1],\n [0],\n [-1],\n [-1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 0 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-2],\n [2]])\nb = np.array([\n [0, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{11}{5} & -\\frac{16}{5} \\\\\n \\frac{1}{5} & \\frac{12}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{116}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/5), -(16/5)],\n [(1/5), (12/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{5} \\\\\n -\\frac{8}{5} \\\\\n \\frac{1}{5} \\\\\n 3 \\\\\n -\\frac{13}{5} \\\\\n -\\frac{7}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2}{\\sqrt{131}} \\\\\n -\\frac{4}{\\sqrt{131}} \\\\\n \\frac{1}{2 \\sqrt{131}} \\\\\n \\frac{15}{2 \\sqrt{131}} \\\\\n -\\frac{13}{2 \\sqrt{131}} \\\\\n -\\frac{7}{2 \\sqrt{131}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/5)],\n [-(8/5)],\n [(1/5)],\n [3],\n [-(13/5)],\n [-(7/5)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -9 & -7 & -3 \\\\\n 8 & -2 & 4 \\\\\n -10 & 1 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.499,0.076,1.\\}, \\{0.03\\, -0.458 i,-0.736+0.043 i,1.\\}, \\{0.03\\, +0.458 i,-0.736-0.043 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -7, -3],\n [8, -2, 4],\n [-10, 1, -7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{3}{2}, -\\frac{3}{2}, -\\frac{5}{2}}$ to the plane $\\frac{3 x}{2}-\\frac{9 y}{2}+\\frac{9 z}{2}-2=0$.", - "Output Answer": [ - "$\\frac{35}{6 \\sqrt{19}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(3/2), -(3/2), -(5/2)\nplane = Poly(((3*x)/2)-((9*y)/2)+((9*z)/2)-2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 6 & 0 & 3 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-5.,0.,0.,3.\\}, \\{-1.,0.,2.,0.\\}, \\{0.,1.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [6, 0, 3, 10]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{3}{2}, -4, 2}$ to the plane $-4 x-\\frac{7 y}{2}-2 z+3=0$.", - "Output Answer": [ - "$\\frac{38}{\\sqrt{129}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(3/2), -4, 2\nplane = Poly(-4*x-((7*y)/2)-2*z+3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,-1,1\\}, \\{1,-2,-1\\}, \\{-1,2,-3\\}}$", - "Output Answer": [ - "${\\left\\{-\\sqrt{\\frac{2}{3}},-\\frac{1}{\\sqrt{6}},\\frac{1}{\\sqrt{6}}\\right\\}, \\left\\{2 \\sqrt{\\frac{2}{105}},-\\frac{13}{\\sqrt{210}},-\\sqrt{\\frac{5}{42}}\\right\\}, \\left\\{-\\frac{3}{\\sqrt{35}},\\frac{1}{\\sqrt{35}},-\\sqrt{\\frac{5}{7}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, -1, 1), (1, -2, -1), (-1, 2, -3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(3 \\sqrt{2}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [-1],\n [1],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [0],\n [0],\n [-1],\n [1],\n [1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 6 \\\\\n -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 57 \\\\\n 9 \\\\\n 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [-8]])\nb = np.array([\n [0],\n [6],\n [-9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 6 & 1 \\\\\n 3 & 3 \\\\\n -8 & 9 \\\\\n -10 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, 1],\n [3, 3],\n [-8, 9],\n [-10, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{4}{3}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & 5 & 9 & -5 \\\\\n -2 & 2 & -5 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{4}{3} & -\\frac{20}{3} & -12 & \\frac{20}{3} \\\\\n \\frac{8}{3} & -\\frac{8}{3} & \\frac{20}{3} & -\\frac{32}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 5, 9, -5],\n [-2, 2, -5, 8]])\nprint(a * -(4/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,4,0\\}, \\{-1,-1,0\\}, \\{4,5,-3\\}}$.", - "Output Answer": [ - "$15 x+9 y+43 z+24=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, 4, 0],\n [-1, -1, 0],\n [4, 5, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{2}{5},\\frac{6}{5}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [2]]).squeeze()\nb = np.array([\n [1],\n [3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{3} & -\\frac{11}{3} & -1 \\\\\n 0 & 0 & -\\frac{11}{3} \\\\\n 5 & -3 & \\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{638}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/3), -(11/3), -1],\n [0, 0, -(11/3)],\n [5, -3, (8/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 10 & 8 \\\\\n 7 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{14} \\left(7-\\sqrt{273}\\right),1\\right\\}, \\left\\{\\frac{1}{14} \\left(7+\\sqrt{273}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 8],\n [7, 3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -1 & 0 & 0 \\\\\n -1 & 3 & -2 \\\\\n 2 & 2 & 1 \\\\\n -2 & -2 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -2 & -2 & 0 & 3 & -1 \\\\\n 1 & 3 & 0 & -3 & -1 \\\\\n 2 & 2 & -3 & -1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 2 & 2 & 0 & -3 & 1 \\\\\n 1 & 7 & 6 & -10 & 4 \\\\\n 0 & 4 & -3 & -1 & -7 \\\\\n 2 & -2 & 0 & 0 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, 0],\n [-1, 3, -2],\n [2, 2, 1],\n [-2, -2, 0]])\nb = np.array([\n [-2, -2, 0, 3, -1],\n [1, 3, 0, -3, -1],\n [2, 2, -3, -1, -3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -3 \\\\\n 1 \\\\\n 1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{2}{\\sqrt{19}} \\\\\n -\\frac{3}{\\sqrt{19}} \\\\\n \\frac{1}{\\sqrt{19}} \\\\\n \\frac{1}{\\sqrt{19}} \\\\\n \\frac{2}{\\sqrt{19}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-3],\n [1],\n [1],\n [2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & 3 & -1 \\\\\n -2 & 3 & 1 \\\\\n 3 & -2 & 1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -8 & 8 & 3 \\\\\n -1 & 1 & 6 \\\\\n 4 & 1 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, -1],\n [-2, 3, 1],\n [3, -2, 1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{11}{5} & \\frac{6}{5} \\\\\n 2 & -\\frac{29}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{5} \\left(-20-\\sqrt{141}\\right),\\frac{1}{5} \\left(\\sqrt{141}-20\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/5), (6/5)],\n [2, -(29/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{4} \\\\\n \\frac{7}{2} \\\\\n \\frac{11}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -4 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 36 \\\\\n -\\frac{13}{2} \\\\\n \\frac{5}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/4)],\n [(7/2)],\n [(11/2)]])\nb = np.array([\n [-1],\n [-4],\n [4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${4, -4, -4}$ to the plane $5 x+5 y-3 z-4=0$.", - "Output Answer": [ - "$\\frac{8}{\\sqrt{59}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 4, -4, -4\nplane = Poly(5*x+5*y-3*z-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{18}{5}, -\\frac{49}{10}}$ to the line $-\\frac{9 x}{5}-\\frac{37 y}{10}-\\frac{21}{10}=0$.", - "Output Answer": [ - "$\\frac{2251}{10 \\sqrt{1693}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(18/5), -(49/10)\nline = Poly(-((9*x)/5)-((37*y)/10)-(21/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 4 & -7 & 3 & 8 & 4 \\\\\n -7 & -5 & 7 & -9 & -7 \\\\\n 9 & 10 & 1 & 8 & -4 \\\\\n -8 & -3 & -10 & 9 & -2 \\\\\n -2 & -4 & 5 & -9 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, -7, 3, 8, 4],\n [-7, -5, 7, -9, -7],\n [9, 10, 1, 8, -4],\n [-8, -3, -10, 9, -2],\n [-2, -4, 5, -9, -1]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n \\frac{29}{3} & -2 & -\\frac{25}{3} & -\\frac{16}{3} & -9 \\\\\n -\\frac{14}{3} & -7 & -4 & -\\frac{1}{3} & -2 \\\\\n \\frac{5}{3} & 6 & \\frac{2}{3} & -\\frac{11}{3} & \\frac{26}{3} \\\\\n -\\frac{17}{3} & -6 & \\frac{25}{3} & 3 & -\\frac{23}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/3), -2, -(25/3), -(16/3), -9],\n [-(14/3), -7, -4, -(1/3), -2],\n [(5/3), 6, (2/3), -(11/3), (26/3)],\n [-(17/3), -6, (25/3), 3, -(23/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n \\frac{75}{8} \\\\\n -\\frac{29}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(75/8)],\n [-(29/8)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, 0, -1}$ to the plane $4 x-y+2=0$.", - "Output Answer": [ - "$\\frac{6}{\\sqrt{17}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, 0, -1\nplane = Poly(4*x-y+2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{21}{5}, -\\frac{14}{5}, \\frac{23}{5}}$ to the plane $-\\frac{23 x}{5}+\\frac{12 y}{5}-3 z+\\frac{14}{5}=0$.", - "Output Answer": [ - "$\\frac{463 \\sqrt{\\frac{2}{449}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (21/5), -(14/5), (23/5)\nplane = Poly(-((23*x)/5)+((12*y)/5)-3*z+(14/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,-1,0\\}, \\{4,-5,-5\\}, \\{-1,0,-1\\}}$.", - "Output Answer": [ - "$3 x+7 y-5 z-2=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, -1, 0],\n [4, -5, -5],\n [-1, 0, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & -\\frac{17}{2} \\\\\n -\\frac{3}{2} & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{6} \\left(-11-5 \\sqrt{13}\\right),1\\right\\}, \\left\\{\\frac{1}{6} \\left(5 \\sqrt{13}-11\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -(17/2)],\n [-(3/2), (7/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{11}{2} & 5 \\\\\n -\\frac{1}{2} & \\frac{37}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} \\left(15-\\sqrt{65}\\right),1\\right\\}, \\left\\{\\frac{1}{4} \\left(15+\\sqrt{65}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/2), 5],\n [-(1/2), (37/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n 0 & -\\frac{3}{4} \\\\\n -\\frac{5}{2} & \\frac{27}{4} \\\\\n -10 & 5 \\\\\n \\frac{15}{4} & \\frac{25}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -(3/4)],\n [-(5/2), (27/4)],\n [-10, 5],\n [(15/4), (25/4)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n 1 & -5 & 6 \\\\\n -9 & -5 & -1 \\\\\n -1 & 2 & -10 \\\\\n -8 & -9 & -5 \\\\\n 10 & -7 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -5, 6],\n [-9, -5, -1],\n [-1, 2, -10],\n [-8, -9, -5],\n [10, -7, -1]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9.206 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9.423 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$86.7481$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9.206]])\nb = np.array([\n [-9.423]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{15}{2} \\\\\n -7 \\\\\n \\frac{19}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{17}{2} \\\\\n -\\frac{3}{2} \\\\\n \\frac{19}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{209}{4} \\\\\n \\frac{19}{2} \\\\\n \\frac{193}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/2)],\n [-7],\n [(19/2)]])\nb = np.array([\n [(17/2)],\n [-(3/2)],\n [(19/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{22}{5} & \\frac{14}{5} \\\\\n \\frac{17}{5} & \\frac{31}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(53-\\sqrt{1033}\\right),\\frac{1}{10} \\left(53+\\sqrt{1033}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(22/5), (14/5)],\n [(17/5), (31/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{5,-4,-3\\}, \\{4,2,-3\\}, \\{0,2,-1\\}}$.", - "Output Answer": [ - "$6 x+y+12 z+10=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [5, -4, -3],\n [4, 2, -3],\n [0, 2, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4]])\nb = np.array([\n [7]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{9}{2} \\\\\n \\frac{1}{2} \\\\\n 0 \\\\\n \\frac{7}{2} \\\\\n -8 \\\\\n \\frac{3}{2} \\\\\n -\\frac{7}{2} \\\\\n -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -6 \\\\\n 3 \\\\\n -2 \\\\\n -\\frac{15}{2} \\\\\n -\\frac{3}{2} \\\\\n 10 \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{67}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/2)],\n [(1/2)],\n [0],\n [(7/2)],\n [-8],\n [(3/2)],\n [-(7/2)],\n [-(7/2)]])\nb = np.array([\n [5],\n [-6],\n [3],\n [-2],\n [-(15/2)],\n [-(3/2)],\n [10],\n [(1/2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [-1],\n [-1],\n [0],\n [0],\n [1],\n [0],\n [0]]).squeeze()\nb = np.array([\n [0],\n [1],\n [0],\n [0],\n [0],\n [0],\n [-1],\n [-1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -10 & -\\frac{55}{16} & -\\frac{45}{16} & \\frac{107}{16} \\\\\n \\frac{3}{16} & -\\frac{41}{8} & -\\frac{33}{4} & \\frac{105}{16} \\\\\n -\\frac{65}{16} & -\\frac{75}{8} & \\frac{7}{4} & -\\frac{103}{16} \\\\\n -\\frac{15}{2} & -\\frac{83}{16} & -\\frac{65}{8} & -\\frac{19}{4} \\\\\n -\\frac{29}{4} & \\frac{7}{4} & \\frac{105}{16} & -\\frac{113}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -(55/16), -(45/16), (107/16)],\n [(3/16), -(41/8), -(33/4), (105/16)],\n [-(65/16), -(75/8), (7/4), -(103/16)],\n [-(15/2), -(83/16), -(65/8), -(19/4)],\n [-(29/4), (7/4), (105/16), -(113/16)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 8 \\\\\n -10 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 6 \\\\\n 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -4 \\\\\n 2 \\\\\n -10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [8],\n [-10]])\nb = np.array([\n [-2],\n [6],\n [0]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -2 & -7 & -10 & -4 \\\\\n 8 & 1 & 0 & -9 \\\\\n -1 & 3 & -10 & -6 \\\\\n -8 & -4 & -6 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, -7, -10, -4],\n [8, 1, 0, -9],\n [-1, 3, -10, -6],\n [-8, -4, -6, 9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n \\frac{3}{2} \\\\\n 1 \\\\\n \\frac{3}{2} \\\\\n \\frac{5}{2} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n -1 \\\\\n -\\frac{5}{2} \\\\\n -2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{141}{116},\\frac{47}{58},\\frac{235}{116},\\frac{47}{29},\\frac{47}{58}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2)],\n [(3/2)],\n [1],\n [(3/2)],\n [(5/2)]]).squeeze()\nb = np.array([\n [(3/2)],\n [-1],\n [-(5/2)],\n [-2],\n [-1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 3 & 1 & 2 & 3 \\\\\n 1 & -1 & 1 & 2 \\\\\n 3 & -2 & -3 & -2 \\\\\n 0 & -3 & 1 & 1 \\\\\n 0 & -3 & 3 & 3 \\\\\n -2 & -3 & -3 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.53 \\\\\n 2.29 \\\\\n -2.2 \\\\\n 2.85 \\\\\n 1.16 \\\\\n -2.42 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.027 \\\\\n -0.215 \\\\\n 0.959 \\\\\n -0.272 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1, 2, 3],\n [1, -1, 1, 2],\n [3, -2, -3, -2],\n [0, -3, 1, 1],\n [0, -3, 3, 3],\n [-2, -3, -3, -1]])\nb = np.array([\n [0.53],\n [2.29],\n [-2.2],\n [2.85],\n [1.16],\n [-2.42]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{27}{4} \\\\\n \\frac{15}{2} \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{57}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(27/4)],\n [(15/2)],\n [0]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{3} & -\\frac{20}{3} & -\\frac{22}{3} \\\\\n -5 & \\frac{23}{3} & 10 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{10}{3} & \\frac{29}{3} & \\frac{5}{3} \\\\\n -\\frac{23}{3} & \\frac{29}{3} & \\frac{29}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -5 & -\\frac{49}{3} & -9 \\\\\n \\frac{8}{3} & -2 & \\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/3), -(20/3), -(22/3)],\n [-5, (23/3), 10]])\nb = np.array([\n [(10/3), (29/3), (5/3)],\n [-(23/3), (29/3), (29/3)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n \\frac{49}{8} & -10 \\\\\n -\\frac{9}{2} & -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(49/8), -10],\n [-(9/2), -(1/4)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{9} \\\\\n \\frac{16}{9} \\\\\n \\frac{1}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{71}{9} \\\\\n -\\frac{20}{3} \\\\\n \\frac{1}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{76}{81} \\\\\n \\frac{8}{9} \\\\\n -\\frac{1076}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/9)],\n [(16/9)],\n [(1/9)]])\nb = np.array([\n [(71/9)],\n [-(20/3)],\n [(1/9)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & 2 & 0 \\\\\n 2 & 2 & 1 \\\\\n 1 & -3 & 2 \\\\\n 2 & 1 & 2 \\\\\n 1 & -3 & 2 \\\\\n -3 & 2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.53 \\\\\n -2.15 \\\\\n 1.35 \\\\\n -0.14 \\\\\n 2.7 \\\\\n 2.08 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.611 \\\\\n -0.569 \\\\\n 0.14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2, 0],\n [2, 2, 1],\n [1, -3, 2],\n [2, 1, 2],\n [1, -3, 2],\n [-3, 2, -3]])\nb = np.array([\n [-0.53],\n [-2.15],\n [1.35],\n [-0.14],\n [2.7],\n [2.08]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & 4 \\\\\n -7 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+5 x+4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 4],\n [-7, -8]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$16$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [3]])\nb = np.array([\n [-7],\n [-4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -9 \\\\\n -9 \\\\\n 5 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$36$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-9],\n [-9],\n [5],\n [4]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{11}{2} \\\\\n -\\frac{33}{4} \\\\\n \\frac{37}{4} \\\\\n 7 \\\\\n -\\frac{19}{2} \\\\\n -\\frac{15}{2} \\\\\n -\\frac{17}{4} \\\\\n -\\frac{33}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{2} \\\\\n \\frac{3}{2} \\\\\n -\\frac{15}{4} \\\\\n \\frac{9}{4} \\\\\n 7 \\\\\n \\frac{19}{4} \\\\\n \\frac{13}{4} \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-227$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/2)],\n [-(33/4)],\n [(37/4)],\n [7],\n [-(19/2)],\n [-(15/2)],\n [-(17/4)],\n [-(33/4)]])\nb = np.array([\n [-(11/2)],\n [(3/2)],\n [-(15/4)],\n [(9/4)],\n [7],\n [(19/4)],\n [(13/4)],\n [6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -3 & 2 & -3 & 2 & 3 \\\\\n 3 & 1 & -3 & 2 & 1 \\\\\n -2 & -1 & 3 & -3 & 0 \\\\\n -1 & 0 & 3 & 2 & 3 \\\\\n 0 & 2 & -2 & 1 & 0 \\\\\n -3 & 2 & 1 & 3 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.34 \\\\\n 2.42 \\\\\n -2.07 \\\\\n 2.19 \\\\\n 0.85 \\\\\n 0.81 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.573 \\\\\n 0.424 \\\\\n 0.247 \\\\\n 0.38 \\\\\n 0.396 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2, -3, 2, 3],\n [3, 1, -3, 2, 1],\n [-2, -1, 3, -3, 0],\n [-1, 0, 3, 2, 3],\n [0, 2, -2, 1, 0],\n [-3, 2, 1, 3, 1]])\nb = np.array([\n [0.34],\n [2.42],\n [-2.07],\n [2.19],\n [0.85],\n [0.81]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 2 \\\\\n 7 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 0 \\\\\n -4 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -9 \\\\\n 2 \\\\\n 3 \\\\\n -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [2],\n [7],\n [0]])\nb = np.array([\n [-3],\n [0],\n [-4],\n [-4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -5 & -1 & 0 \\\\\n -3 & -1 & 1 \\\\\n -3 & 2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -1, 0],\n [-3, -1, 1],\n [-3, 2, -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{100}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 3 \\\\\n -9 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{7}{100} \\\\\n -\\frac{3}{100} \\\\\n \\frac{9}{100} \\\\\n \\frac{7}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [3],\n [-9],\n [-7]])\nprint(a * -(1/100))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, -\\frac{7}{2}}$ to the line $\\frac{3 x}{2}-\\frac{7}{2}=0$.", - "Output Answer": [ - "$\\frac{13}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, -(7/2)\nline = Poly(((3*x)/2)-(7/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -5 & 7 & -6 & -6 & 4 & -2 \\\\\n 0 & -1 & -5 & -1 & 8 & -6 \\\\\n -10 & 9 & -3 & 4 & 1 & -5 \\\\\n 10 & -4 & -3 & 2 & 3 & 10 \\\\\n -4 & -3 & 2 & 10 & -8 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & \\frac{4080}{2299} \\\\\n 0 & 1 & 0 & 0 & 0 & \\frac{3451}{2299} \\\\\n 0 & 0 & 1 & 0 & 0 & \\frac{2279}{9196} \\\\\n 0 & 0 & 0 & 1 & 0 & \\frac{865}{9196} \\\\\n 0 & 0 & 0 & 0 & 1 & -\\frac{3639}{9196} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, 7, -6, -6, 4, -2],\n [0, -1, -5, -1, 8, -6],\n [-10, 9, -3, 4, 1, -5],\n [10, -4, -3, 2, 3, 10],\n [-4, -3, 2, 10, -8, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -\\frac{12}{5} \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{5}{13} \\\\\n -\\frac{12}{13} \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-(12/5)],\n [0]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{7}{2}, \\frac{22}{5}}$ to the line $4 x-\\frac{47 y}{10}+\\frac{6}{5}=0$.", - "Output Answer": [ - "$\\frac{274}{5 \\sqrt{3809}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (7/2), (22/5)\nline = Poly(4*x-((47*y)/10)+(6/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{\\sqrt{\\pi }} \\\\\n \\frac{4}{\\sqrt{\\pi }} \\\\\n \\frac{1}{\\sqrt{\\pi }} \\\\\n 0 \\\\\n -\\frac{17}{\\sqrt{\\pi }} \\\\\n -\\frac{2}{\\sqrt{\\pi }} \\\\\n \\frac{11}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{15}{\\sqrt{\\pi }} \\\\\n -\\frac{17}{\\sqrt{\\pi }} \\\\\n \\frac{15}{\\sqrt{\\pi }} \\\\\n \\frac{6}{\\sqrt{\\pi }} \\\\\n -\\frac{2}{\\sqrt{\\pi }} \\\\\n \\frac{15}{\\sqrt{\\pi }} \\\\\n \\frac{1}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{37}{\\pi }$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(5/(math.sqrt(math.pi)))],\n [(4/(math.sqrt(math.pi)))],\n [(1/(math.sqrt(math.pi)))],\n [0],\n [-(17/(math.sqrt(math.pi)))],\n [-(2/(math.sqrt(math.pi)))],\n [(11/(math.sqrt(math.pi)))]])\nb = np.array([\n [(15/(math.sqrt(math.pi)))],\n [-(17/(math.sqrt(math.pi)))],\n [(15/(math.sqrt(math.pi)))],\n [(6/(math.sqrt(math.pi)))],\n [-(2/(math.sqrt(math.pi)))],\n [(15/(math.sqrt(math.pi)))],\n [(1/(math.sqrt(math.pi)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{11}{5}, 0, \\frac{18}{5}}$ to the plane $\\frac{19 x}{5}+\\frac{18 y}{5}-\\frac{22 z}{5}+\\frac{13}{5}=0$.", - "Output Answer": [ - "$\\frac{108}{\\sqrt{1169}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(11/5), 0, (18/5)\nplane = Poly(((19*x)/5)+((18*y)/5)-((22*z)/5)+(13/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{3} & \\frac{7}{3} & \\frac{13}{3} \\\\\n \\frac{7}{3} & -1 & 4 \\\\\n \\frac{1}{3} & -4 & \\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{423}{1723} & \\frac{489}{1723} & -\\frac{369}{1723} \\\\\n -\\frac{15}{1723} & \\frac{54}{1723} & -\\frac{453}{1723} \\\\\n \\frac{243}{1723} & \\frac{159}{1723} & \\frac{102}{1723} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/3), (7/3), (13/3)],\n [(7/3), -1, 4],\n [(1/3), -4, (1/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & -7 & 3 \\\\\n 8 & 3 & 6 \\\\\n -9 & 3 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-0.599,0.3\\, -5.317 i,0.3\\, +5.317 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -7, 3],\n [8, 3, 6],\n [-9, 3, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 7 & -5 & -6 & 2 & -10 \\\\\n 7 & -3 & -5 & -6 & 5 \\\\\n -3 & 2 & -1 & -6 & -1 \\\\\n -7 & 6 & -5 & 1 & 1 \\\\\n 2 & -1 & 2 & 6 & -8 \\\\\n -3 & 0 & 6 & 1 & -6 \\\\\n -2 & 1 & -2 & 1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, -5, -6, 2, -10],\n [7, -3, -5, -6, 5],\n [-3, 2, -1, -6, -1],\n [-7, 6, -5, 1, 1],\n [2, -1, 2, 6, -8],\n [-3, 0, 6, 1, -6],\n [-2, 1, -2, 1, -3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, \\frac{1}{3}}$ to the line $4 x+\\frac{4 y}{3}-\\frac{2}{3}=0$.", - "Output Answer": [ - "$\\frac{37}{6 \\sqrt{10}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, (1/3)\nline = Poly(4*x+((4*y)/3)-(2/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -9 & -1 & 2 & -2 & 8 \\\\\n 6 & 2 & -10 & 3 & 9 \\\\\n 0 & -3 & -2 & 10 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-104.,750.,165.,258.,0.\\}, \\{302.,288.,471.,0.,258.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, -1, 2, -2, 8],\n [6, 2, -10, 3, 9],\n [0, -3, -2, 10, 7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 4 & 4 \\\\\n 7 & 1 \\\\\n -5 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, 4],\n [7, 1],\n [-5, -5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 6 \\\\\n 8 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 6 \\\\\n 1 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3 \\\\\n 12 \\\\\n 9 \\\\\n 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [6],\n [8],\n [8]])\nb = np.array([\n [9],\n [6],\n [1],\n [-4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & -8 & 4 \\\\\n 8 & 0 & -10 \\\\\n -7 & -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.626,1.34,1.\\}, \\{-0.417-1.508 i,-1.445+0.408 i,1.\\}, \\{-0.417+1.508 i,-1.445-0.408 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -8, 4],\n [8, 0, -10],\n [-7, -1, 2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 5 & -3 \\\\\n 0 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{5} & \\frac{3}{20} \\\\\n 0 & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -3],\n [0, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -4 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 3 \\\\\n -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 6 \\\\\n 8 \\\\\n 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-4],\n [2]])\nb = np.array([\n [1],\n [3],\n [-3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & -\\frac{9}{2} \\\\\n -3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-2-3 \\sqrt{10}\\right),\\frac{1}{2} \\left(3 \\sqrt{10}-2\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -(9/2)],\n [-3, 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{2} & \\frac{8}{3} \\\\\n \\frac{5}{6} & -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{257}{18}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2), (8/3)],\n [(5/6), -(11/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -2 \\\\\n -8 \\\\\n -6 \\\\\n -1 \\\\\n 9 \\\\\n 7 \\\\\n 8 \\\\\n -2 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -2 \\\\\n 7 \\\\\n -3 \\\\\n 1 \\\\\n -9 \\\\\n 10 \\\\\n -4 \\\\\n -6 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{190}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-2],\n [-8],\n [-6],\n [-1],\n [9],\n [7],\n [8],\n [-2],\n [4]])\nb = np.array([\n [-9],\n [-2],\n [7],\n [-3],\n [1],\n [-9],\n [10],\n [-4],\n [-6],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{3}{2},2,-\\frac{5}{2}\\right\\}, \\left\\{\\frac{9}{2},-\\frac{3}{2},-\\frac{5}{2}\\right\\}, \\left\\{0,\\frac{5}{2},-\\frac{7}{2}\\right\\}}$.", - "Output Answer": [ - "$28 x+24 y-30 z-165=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(3/2), 2, -(5/2)],\n [(9/2), -(3/2), -(5/2)],\n [0, (5/2), -(7/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{2}{e},-\\frac{8}{e},-\\frac{1}{e}\\right\\}, \\left\\{\\frac{7}{e},\\frac{1}{e},\\frac{6}{e}\\right\\}, \\left\\{-\\frac{6}{e},\\frac{1}{e},-\\frac{3}{e}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{2}{\\sqrt{69}},-\\frac{8}{\\sqrt{69}},-\\frac{1}{\\sqrt{69}}\\right\\}, \\left\\{\\frac{427}{5 \\sqrt{14214}},-\\frac{31}{\\sqrt{14214}},\\frac{193 \\sqrt{\\frac{2}{7107}}}{5}\\right\\}, \\left\\{-\\frac{47}{5 \\sqrt{206}},\\frac{1}{\\sqrt{206}},\\frac{27 \\sqrt{\\frac{2}{103}}}{5}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-(2/math.e), -(8/math.e), -(1/math.e)), ((7/math.e), (1/math.e), (6/math.e)), (-(6/math.e), (1/math.e), -(3/math.e))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{11}{3},-\\frac{1}{3},1\\right\\}, \\left\\{-4,\\frac{8}{3},1\\right\\}, \\left\\{\\frac{4}{3},2,-\\frac{2}{3}\\right\\}}$.", - "Output Answer": [ - "$135 x+15 y+426 z+74=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(11/3), -(1/3), 1],\n [-4, (8/3), 1],\n [(4/3), 2, -(2/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 9 & 0 & 3 & 3 & 4 & -2 \\\\\n 7 & 10 & -5 & -9 & -9 & 8 \\\\\n -8 & 7 & -5 & 0 & -4 & -5 \\\\\n -10 & 5 & -3 & 7 & 9 & 8 \\\\\n 5 & 7 & 3 & -4 & -2 & -6 \\\\\n -4 & -5 & 6 & -4 & 0 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, 0, 3, 3, 4, -2],\n [7, 10, -5, -9, -9, 8],\n [-8, 7, -5, 0, -4, -5],\n [-10, 5, -3, 7, 9, 8],\n [5, 7, 3, -4, -2, -6],\n [-4, -5, 6, -4, 0, -8]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 0 & -1 & -8 & -5 & 0 \\\\\n 1 & 10 & 7 & 10 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & -73 & -40 & 8 \\\\\n 0 & 1 & 8 & 5 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, -1, -8, -5, 0],\n [1, 10, 7, 10, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -6 & -9 & -2 & -8 \\\\\n -2 & -10 & 10 & 5 \\\\\n -2 & -4 & 10 & -9 \\\\\n -2 & 2 & 1 & -2 \\\\\n 6 & -7 & 6 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-6, -9, -2, -8],\n [-2, -10, 10, 5],\n [-2, -4, 10, -9],\n [-2, 2, 1, -2],\n [6, -7, 6, -10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{29}{5} & -\\frac{28}{5} \\\\\n \\frac{36}{5} & \\frac{41}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{12 x}{5}-\\frac{181}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/5), -(28/5)],\n [(36/5), (41/5)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & -2 & 0 \\\\\n -3 & 0 & -1 \\\\\n -3 & -1 & -2 \\\\\n 3 & -2 & 0 \\\\\n -1 & 2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.37 \\\\\n -0.14 \\\\\n -2.26 \\\\\n -2.86 \\\\\n 2.65 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.413 \\\\\n 1.073 \\\\\n -0.282 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2, 0],\n [-3, 0, -1],\n [-3, -1, -2],\n [3, -2, 0],\n [-1, 2, -3]])\nb = np.array([\n [1.37],\n [-0.14],\n [-2.26],\n [-2.86],\n [2.65]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{131}{16} \\\\\n \\frac{51}{8} \\\\\n -\\frac{87}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{2} \\\\\n \\frac{7}{8} \\\\\n -\\frac{141}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3291}{64} \\\\\n \\frac{31695}{256} \\\\\n \\frac{8669}{128} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(131/16)],\n [(51/8)],\n [-(87/16)]])\nb = np.array([\n [-(19/2)],\n [(7/8)],\n [-(141/16)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n -2 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{3}{5},\\frac{3}{10},-\\frac{3}{10},0,\\frac{3}{5}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [-2],\n [2],\n [1]]).squeeze()\nb = np.array([\n [-2],\n [-1],\n [1],\n [0],\n [-2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -1 & -2 & -3 & 3 & 1 \\\\\n 0 & 0 & 1 & -3 & -1 \\\\\n -2 & -1 & 2 & 0 & 0 \\\\\n 0 & -1 & 1 & 0 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -1 & -2 \\\\\n -2 & -2 \\\\\n -1 & -3 \\\\\n 2 & 0 \\\\\n 1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 15 & 13 \\\\\n -8 & -1 \\\\\n 2 & 0 \\\\\n -1 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, -3, 3, 1],\n [0, 0, 1, -3, -1],\n [-2, -1, 2, 0, 0],\n [0, -1, 1, 0, -2]])\nb = np.array([\n [-1, -2],\n [-2, -2],\n [-1, -3],\n [2, 0],\n [1, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{2} \\\\\n -2 \\\\\n -3 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{1}{2} \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{120}{53},-\\frac{30}{53},-\\frac{180}{53}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2)],\n [-2],\n [-3]]).squeeze()\nb = np.array([\n [2],\n [(1/2)],\n [3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 2 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [1],\n [2]])\nb = np.array([\n [7],\n [2],\n [5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & 3 & 2 \\\\\n -1 & 1 & -3 \\\\\n -3 & 2 & 2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -8 & 10 & -3 \\\\\n 7 & -8 & -11 \\\\\n -11 & -3 & -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3, 2],\n [-1, 1, -3],\n [-3, 2, 2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5.8 \\\\\n -0.22 \\\\\n 7.86 \\\\\n -2.24 \\\\\n -1.48 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3.31 \\\\\n -7.3 \\\\\n 4.28 \\\\\n -1.77 \\\\\n -6.25 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$29.2636$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5.8],\n [-0.22],\n [7.86],\n [-2.24],\n [-1.48]])\nb = np.array([\n [-3.31],\n [-7.3],\n [4.28],\n [-1.77],\n [-6.25]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -2 & 2 & 7 & 7 \\\\\n -4 & -8 & -3 & -6 \\\\\n 8 & -4 & -10 & 0 \\\\\n 5 & -4 & 0 & 6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 7 & -4 & 7 & 9 \\\\\n 7 & 7 & -9 & 7 \\\\\n -7 & -6 & -5 & -1 \\\\\n 8 & 8 & 5 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -9 & 6 & 0 & -2 \\\\\n -11 & -15 & 6 & -13 \\\\\n 15 & 2 & -5 & 1 \\\\\n -3 & -12 & -5 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2, 7, 7],\n [-4, -8, -3, -6],\n [8, -4, -10, 0],\n [5, -4, 0, 6]])\nb = np.array([\n [7, -4, 7, 9],\n [7, 7, -9, 7],\n [-7, -6, -5, -1],\n [8, 8, 5, 5]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & \\frac{41}{10} \\\\\n \\frac{1}{10} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{559}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), (41/10)],\n [(1/10), -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -3 & -10 & -3 & 0 \\\\\n 8 & 8 & 7 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -10, -3, 0],\n [8, 8, 7, -5]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 2 \\\\\n -10 \\\\\n 3 \\\\\n -9 \\\\\n -5 \\\\\n 2 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -1 \\\\\n -5 \\\\\n -10 \\\\\n -8 \\\\\n -6 \\\\\n 10 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$117$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [2],\n [-10],\n [3],\n [-9],\n [-5],\n [2],\n [-5]])\nb = np.array([\n [-2],\n [-1],\n [-5],\n [-10],\n [-8],\n [-6],\n [10],\n [7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{5} & \\frac{21}{5} & \\frac{36}{5} \\\\\n -\\frac{2}{5} & \\frac{39}{5} & -\\frac{32}{5} \\\\\n -\\frac{39}{5} & \\frac{32}{5} & \\frac{1}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{2.4,3.811,1.\\}, \\{0.452\\, -0.843 i,0.389\\, +0.362 i,1.\\}, \\{0.452\\, +0.843 i,0.389\\, -0.362 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/5), (21/5), (36/5)],\n [-(2/5), (39/5), -(32/5)],\n [-(39/5), (32/5), (1/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n \\frac{2}{5} & -2 & \\frac{3}{5} & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -1 & \\frac{12}{5} & -\\frac{12}{5} & -\\frac{12}{5} & -\\frac{13}{5} \\\\\n \\frac{3}{5} & -\\frac{8}{5} & -\\frac{2}{5} & 2 & -\\frac{7}{5} \\\\\n \\frac{3}{5} & -\\frac{2}{5} & \\frac{12}{5} & \\frac{12}{5} & -\\frac{6}{5} \\\\\n \\frac{6}{5} & 1 & -\\frac{4}{5} & \\frac{2}{5} & \\frac{1}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n \\frac{29}{25} & \\frac{148}{25} & -\\frac{8}{25} & -\\frac{68}{25} & \\frac{36}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/5), -2, (3/5), 2]])\nb = np.array([\n [-1, (12/5), -(12/5), -(12/5), -(13/5)],\n [(3/5), -(8/5), -(2/5), 2, -(7/5)],\n [(3/5), -(2/5), (12/5), (12/5), -(6/5)],\n [(6/5), 1, -(4/5), (2/5), (1/5)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & \\frac{5}{2} & 2 \\\\\n -\\frac{5}{2} & 1 & -2 \\\\\n \\frac{5}{2} & \\frac{3}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{49}{4} & -\\frac{5}{8} & -\\frac{23}{2} \\\\\n -\\frac{35}{8} & -\\frac{155}{4} & -\\frac{47}{2} \\\\\n -\\frac{65}{8} & \\frac{191}{8} & -\\frac{19}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, (5/2), 2],\n [-(5/2), 1, -2],\n [(5/2), (3/2), (5/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 3 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 1 \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 12 \\\\\n -102 \\\\\n 33 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [3],\n [6]])\nb = np.array([\n [-8],\n [1],\n [6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & -3 & 1 \\\\\n -1 & 0 & -1 \\\\\n 1 & 0 & 1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 4 & 0 & 4 \\\\\n -1 & 3 & -2 \\\\\n 1 & -3 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3, 1],\n [-1, 0, -1],\n [1, 0, 1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 5 & -4 \\\\\n -4 & -7 \\\\\n -7 & 1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -6 & -9 \\\\\n 0 & -7 \\\\\n 3 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 11 & 5 \\\\\n -4 & 0 \\\\\n -10 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -4],\n [-4, -7],\n [-7, 1]])\nb = np.array([\n [-6, -9],\n [0, -7],\n [3, -4]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{3} & \\frac{1}{3} & 2 \\\\\n \\frac{10}{3} & \\frac{10}{3} & -\\frac{1}{3} \\\\\n -\\frac{4}{3} & -\\frac{11}{3} & \\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{895}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/3), (1/3), 2],\n [(10/3), (10/3), -(1/3)],\n [-(4/3), -(11/3), (5/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & -2 & 0 & -2 \\\\\n 3 & -1 & 1 & -2 \\\\\n -2 & 0 & 0 & -2 \\\\\n 1 & 1 & 2 & 3 \\\\\n -3 & 2 & 2 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.76 \\\\\n -1.01 \\\\\n 2.04 \\\\\n -1.7 \\\\\n 2.13 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.765 \\\\\n -0.08 \\\\\n 0.301 \\\\\n -0.403 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, 0, -2],\n [3, -1, 1, -2],\n [-2, 0, 0, -2],\n [1, 1, 2, 3],\n [-3, 2, 2, 2]])\nb = np.array([\n [1.76],\n [-1.01],\n [2.04],\n [-1.7],\n [2.13]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -3 & 0 & 3 \\\\\n 3 & 2 & 3 \\\\\n 0 & 3 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{17}{78} & \\frac{3}{26} & -\\frac{1}{13} \\\\\n \\frac{2}{13} & \\frac{2}{13} & \\frac{3}{13} \\\\\n \\frac{3}{26} & \\frac{3}{26} & -\\frac{1}{13} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, 3],\n [3, 2, 3],\n [0, 3, -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{6}{5} \\\\\n \\frac{2}{5} \\\\\n -\\frac{8}{5} \\\\\n \\frac{7}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n \\frac{8}{5} \\\\\n \\frac{12}{5} \\\\\n -\\frac{12}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{134}{377},-\\frac{1072}{1885},-\\frac{1608}{1885},\\frac{1608}{1885}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(6/5)],\n [(2/5)],\n [-(8/5)],\n [(7/5)]]).squeeze()\nb = np.array([\n [1],\n [(8/5)],\n [(12/5)],\n [-(12/5)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 7 \\\\\n 1 \\\\\n -2 \\\\\n 2 \\\\\n -6 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$28$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [7],\n [1],\n [-2],\n [2],\n [-6],\n [-9]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & -5 \\\\\n -5 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+10 x-1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -5],\n [-5, -4]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 2 & -5 & -5 & -2 \\\\\n 7 & -5 & 9 & 3 \\\\\n 1 & 4 & 9 & -2 \\\\\n 4 & 3 & 6 & -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -9 & -3 & 8 & 3 \\\\\n 5 & 6 & -3 & 5 \\\\\n -2 & 5 & -10 & 1 \\\\\n 2 & -4 & 2 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -7 & -8 & 3 & 1 \\\\\n 12 & 1 & 6 & 8 \\\\\n -1 & 9 & -1 & -1 \\\\\n 6 & -1 & 8 & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -5, -5, -2],\n [7, -5, 9, 3],\n [1, 4, 9, -2],\n [4, 3, 6, -7]])\nb = np.array([\n [-9, -3, 8, 3],\n [5, 6, -3, 5],\n [-2, 5, -10, 1],\n [2, -4, 2, 1]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 3 & -8 & -6 & -5 & 0 \\\\\n 4 & -6 & 9 & 0 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-108.,-51.,14.,0.,0.\\}, \\{-15.,-10.,0.,7.,0.\\}, \\{8.,3.,0.,0.,14.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, -8, -6, -5, 0],\n [4, -6, 9, 0, -1]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1}{\\sqrt{6}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [-1],\n [-1],\n [0]]).squeeze()\nb = np.array([\n [1],\n [1],\n [0],\n [1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{32}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 6 & 1 & -3 \\\\\n -1 & -9 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{15}{16} & -\\frac{5}{32} & \\frac{15}{32} \\\\\n \\frac{5}{32} & \\frac{45}{32} & -\\frac{15}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 1, -3],\n [-1, -9, 3]])\nprint(a * -(5/32))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 5 \\\\\n \\frac{17}{3} \\\\\n -7 \\\\\n -\\frac{25}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$35$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [5],\n [(17/3)],\n [-7],\n [-(25/3)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{8}{3} \\\\\n \\frac{7}{3} \\\\\n -2 \\\\\n \\frac{7}{3} \\\\\n -\\frac{7}{3} \\\\\n -\\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{8}{\\sqrt{263}} \\\\\n \\frac{7}{\\sqrt{263}} \\\\\n -\\frac{6}{\\sqrt{263}} \\\\\n \\frac{7}{\\sqrt{263}} \\\\\n -\\frac{7}{\\sqrt{263}} \\\\\n -\\frac{4}{\\sqrt{263}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/3)],\n [(7/3)],\n [-2],\n [(7/3)],\n [-(7/3)],\n [-(4/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -2 \\\\\n 6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 1 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3 \\\\\n -3 \\\\\n 13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-2],\n [6]])\nb = np.array([\n [4],\n [1],\n [-7]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{5} & 5 \\\\\n -3 & -\\frac{21}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{5} \\left(-10-i \\sqrt{254}\\right),\\frac{1}{5} \\left(-10+i \\sqrt{254}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/5), 5],\n [-3, -(21/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & 7 & 9 \\\\\n 2 & 5 & 6 \\\\\n 0 & 0 & -2 \\\\\n 0 & 6 & -3 \\\\\n -1 & -4 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, 7, 9],\n [2, 5, 6],\n [0, 0, -2],\n [0, 6, -3],\n [-1, -4, 2]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 6 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 6 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -78 \\\\\n -51 \\\\\n -18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [6],\n [9]])\nb = np.array([\n [-3],\n [6],\n [-4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -3 & 1 & 1 \\\\\n 0 & -3 & 3 \\\\\n 4 & 0 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 0 & \\frac{1}{4} \\\\\n \\frac{1}{2} & -\\frac{1}{6} & \\frac{3}{8} \\\\\n \\frac{1}{2} & \\frac{1}{6} & \\frac{3}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1, 1],\n [0, -3, 3],\n [4, 0, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{2}{3}, -\\frac{7}{3}, -2}$ to the plane $\\frac{7 x}{3}-y+4 z+\\frac{5}{3}=0$.", - "Output Answer": [ - "$\\frac{25 \\sqrt{\\frac{2}{101}}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(2/3), -(7/3), -2\nplane = Poly(((7*x)/3)-y+4*z+(5/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -3 \\\\\n 1 \\\\\n -3 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -9 \\\\\n -6 \\\\\n 9 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{75}{\\sqrt{27371}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-3],\n [1],\n [-3],\n [-9]]).squeeze()\nb = np.array([\n [3],\n [-9],\n [-6],\n [9],\n [8]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -4 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -3 \\\\\n 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -28 \\\\\n 63 \\\\\n 47 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-4],\n [0]])\nb = np.array([\n [5],\n [-3],\n [7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -7 & -10 & 2 & 4 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-10.,7.,0.,0.,0.\\}, \\{2.,0.,7.,0.,0.\\}, \\{4.,0.,0.,7.,0.\\}, \\{9.,0.,0.,0.,7.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, -10, 2, 4, 9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{12}{7}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 5 & 4 & 6 \\\\\n 3 & -2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{60}{7} & \\frac{48}{7} & \\frac{72}{7} \\\\\n \\frac{36}{7} & -\\frac{24}{7} & -\\frac{36}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 4, 6],\n [3, -2, -3]])\nprint(a * (12/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 2 \\\\\n -1 \\\\\n 1 \\\\\n 3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{2}{\\sqrt{23}} \\\\\n \\frac{2}{\\sqrt{23}} \\\\\n -\\frac{1}{\\sqrt{23}} \\\\\n \\frac{1}{\\sqrt{23}} \\\\\n \\frac{3}{\\sqrt{23}} \\\\\n -\\frac{2}{\\sqrt{23}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [2],\n [-1],\n [1],\n [3],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{12}{7}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & 8 & -10 \\\\\n 3 & 8 & 9 \\\\\n 0 & 0 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{12}{7} & -\\frac{96}{7} & \\frac{120}{7} \\\\\n -\\frac{36}{7} & -\\frac{96}{7} & -\\frac{108}{7} \\\\\n 0 & 0 & -\\frac{72}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 8, -10],\n [3, 8, 9],\n [0, 0, 6]])\nprint(a * -(12/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -2 & -3 & 0 \\\\\n -1 & -2 & 1 \\\\\n 2 & 1 & 2 \\\\\n 2 & 0 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -1 & -1 & 2 & -1 & -2 \\\\\n -2 & 3 & 3 & 2 & -2 \\\\\n 1 & -2 & -1 & 3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 8 & -7 & -13 & -4 & 10 \\\\\n 6 & -7 & -9 & 0 & 5 \\\\\n -2 & -3 & 5 & 6 & -8 \\\\\n -4 & 2 & 6 & -8 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, 0],\n [-1, -2, 1],\n [2, 1, 2],\n [2, 0, -2]])\nb = np.array([\n [-1, -1, 2, -1, -2],\n [-2, 3, 3, 2, -2],\n [1, -2, -1, 3, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,3,-3\\}, \\{-3,5,-4\\}, \\{4,0,-5\\}}$.", - "Output Answer": [ - "$7 x+6 y+19 z+67=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, 3, -3],\n [-3, 5, -4],\n [4, 0, -5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{2} & \\frac{19}{2} & \\frac{7}{2} \\\\\n \\frac{17}{2} & \\frac{11}{2} & \\frac{19}{2} \\\\\n \\frac{17}{2} & -\\frac{1}{2} & -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/2), (19/2), (7/2)],\n [(17/2), (11/2), (19/2)],\n [(17/2), -(1/2), -(17/2)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{29}{3} \\\\\n \\frac{10}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{25}{3} \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{995}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/3)],\n [(10/3)]])\nb = np.array([\n [-(25/3)],\n [-9]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & -6 & 5 \\\\\n 3 & -10 & 8 \\\\\n 0 & -5 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-9.103-6.235 i,-9.103+6.235 i,0.205\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -6, 5],\n [3, -10, 8],\n [0, -5, -10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n 6 & 6 & -8 & -5 \\\\\n -36 & -32 & 43 & 25 \\\\\n -22 & -19 & 25 & 14 \\\\\n 0 & 0 & 1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{20}{3} & \\frac{11}{2} & -\\frac{15}{2} & -\\frac{14}{3} \\\\\n -41 & -\\frac{71}{2} & 49 & \\frac{57}{2} \\\\\n -\\frac{53}{3} & -\\frac{31}{2} & 21 & \\frac{67}{6} \\\\\n -\\frac{43}{3} & -\\frac{25}{2} & 18 & \\frac{71}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [6, 6, -8, -5],\n [-36, -32, 43, 25],\n [-22, -19, 25, 14],\n [0, 0, 1, 1]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\pi \\\\\n -\\pi \\\\\n -\\pi \\\\\n \\pi \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\pi \\\\\n 2 \\pi \\\\\n 0 \\\\\n \\pi \\\\\n 2 \\pi \\\\\n -\\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\pi ^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [math.pi],\n [-math.pi],\n [-math.pi],\n [math.pi],\n [0]])\nb = np.array([\n [math.pi],\n [2*math.pi],\n [0],\n [math.pi],\n [2*math.pi],\n [-math.pi]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{3} \\\\\n -\\frac{1}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{8}{\\sqrt{65}} \\\\\n -\\frac{1}{\\sqrt{65}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/3)],\n [-(1/6)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & -10 & 10 \\\\\n -6 & 5 & 2 \\\\\n -3 & 3 & 2 \\\\\n -9 & 10 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, -10, 10],\n [-6, 5, 2],\n [-3, 3, 2],\n [-9, 10, 0]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n \\frac{17}{2} & \\frac{17}{2} & \\frac{13}{2} \\\\\n -2 & \\frac{15}{2} & -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 7 & \\frac{11}{2} & -6 \\\\\n \\frac{3}{2} & -6 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{31}{2} & 14 & \\frac{1}{2} \\\\\n -\\frac{1}{2} & \\frac{3}{2} & -\\frac{21}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/2), (17/2), (13/2)],\n [-2, (15/2), -(13/2)]])\nb = np.array([\n [7, (11/2), -6],\n [(3/2), -6, -4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,-1,5\\}, \\{-1,-1,-1\\}, \\{3,-5,-1\\}}$.", - "Output Answer": [ - "$3 x+3 y-2 z+4=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, -1, 5],\n [-1, -1, -1],\n [3, -5, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -\\frac{5}{3} \\\\\n -\\frac{7}{3} \\\\\n \\frac{7}{3} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{2}{3} \\\\\n \\frac{5}{3} \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{70}{141},\\frac{175}{141},-\\frac{35}{47},\\frac{35}{47}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-(5/3)],\n [-(7/3)],\n [(7/3)]]).squeeze()\nb = np.array([\n [(2/3)],\n [(5/3)],\n [-1],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{19}{16} \\\\\n \\frac{3}{4} \\\\\n \\frac{45}{16} \\\\\n -\\frac{9}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{19}{\\sqrt{3826}} \\\\\n 6 \\sqrt{\\frac{2}{1913}} \\\\\n \\frac{45}{\\sqrt{3826}} \\\\\n -18 \\sqrt{\\frac{2}{1913}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/16)],\n [(3/4)],\n [(45/16)],\n [-(9/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -8 & 1 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1.,0.,1.\\}, \\{1.,8.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-8, 1, 8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & \\frac{1}{2} & -\\frac{5}{2} \\\\\n -\\frac{3}{2} & 3 & 0 \\\\\n 0 & 1 & -2 \\\\\n -\\frac{5}{2} & -\\frac{5}{2} & 0 \\\\\n -1 & \\frac{3}{2} & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -2 & -2 & -2 & 0 \\\\\n -2 & 3 & \\frac{1}{2} & -\\frac{5}{2} \\\\\n \\frac{1}{2} & -\\frac{3}{2} & 1 & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{29}{4} & \\frac{1}{4} & -\\frac{29}{4} & -\\frac{15}{2} \\\\\n -3 & 12 & \\frac{9}{2} & -\\frac{15}{2} \\\\\n -3 & 6 & -\\frac{3}{2} & -\\frac{15}{2} \\\\\n 10 & -\\frac{5}{2} & \\frac{15}{4} & \\frac{25}{4} \\\\\n -2 & \\frac{19}{2} & \\frac{3}{4} & -\\frac{35}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), (1/2), -(5/2)],\n [-(3/2), 3, 0],\n [0, 1, -2],\n [-(5/2), -(5/2), 0],\n [-1, (3/2), -2]])\nb = np.array([\n [-2, -2, -2, 0],\n [-2, 3, (1/2), -(5/2)],\n [(1/2), -(3/2), 1, (5/2)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & -3 & 2 \\\\\n -4 & -1 & -3 \\\\\n 0 & 1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{2} & -1 & -\\frac{11}{2} \\\\\n 0 & 0 & 1 \\\\\n 2 & 1 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3, 2],\n [-4, -1, -3],\n [0, 1, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{8}{3} & \\frac{11}{2} & 9 & \\frac{7}{3} \\\\\n \\frac{14}{3} & \\frac{17}{3} & \\frac{11}{2} & 3 \\\\\n \\frac{11}{3} & -\\frac{22}{3} & \\frac{19}{6} & \\frac{55}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{7}{6} & \\frac{28}{3} & \\frac{49}{6} & -8 \\\\\n \\frac{1}{3} & -\\frac{11}{6} & \\frac{16}{3} & -3 \\\\\n \\frac{13}{2} & \\frac{9}{2} & -\\frac{17}{6} & \\frac{13}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{23}{6} & \\frac{89}{6} & \\frac{103}{6} & -\\frac{17}{3} \\\\\n 5 & \\frac{23}{6} & \\frac{65}{6} & 0 \\\\\n \\frac{61}{6} & -\\frac{17}{6} & \\frac{1}{3} & \\frac{27}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(8/3), (11/2), 9, (7/3)],\n [(14/3), (17/3), (11/2), 3],\n [(11/3), -(22/3), (19/6), (55/6)]])\nb = np.array([\n [(7/6), (28/3), (49/6), -8],\n [(1/3), -(11/6), (16/3), -3],\n [(13/2), (9/2), -(17/6), (13/3)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 8 & 9 & 3 \\\\\n -1 & 4 & -3 \\\\\n 7 & -2 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+5 x^2+70 x-602$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 9, 3],\n [-1, 4, -3],\n [7, -2, -7]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-1, \\frac{7}{2}, -1}$ to the plane $3 x+y+\\frac{9 z}{2}-4=0$.", - "Output Answer": [ - "$\\frac{16}{11}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -1, (7/2), -1\nplane = Poly(3*x+y+((9*z)/2)-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & 1 & -4 \\\\\n 0 & -4 & 3 \\\\\n 4 & 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{50} & \\frac{3}{50} & \\frac{13}{50} \\\\\n -\\frac{6}{25} & -\\frac{7}{25} & \\frac{3}{25} \\\\\n -\\frac{8}{25} & -\\frac{1}{25} & \\frac{4}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, -4],\n [0, -4, 3],\n [4, 1, -1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n \\frac{1}{2} & \\frac{3}{2} & -\\frac{1}{2} & -1 \\\\\n -\\frac{3}{2} & 2 & \\frac{3}{2} & 0 \\\\\n 2 & -2 & -\\frac{3}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -1 & 3 & 3 & \\frac{5}{2} & -\\frac{5}{2} \\\\\n 3 & -2 & -2 & \\frac{5}{2} & -\\frac{3}{2} \\\\\n \\frac{1}{2} & 0 & \\frac{1}{2} & 0 & 1 \\\\\n \\frac{1}{2} & 0 & \\frac{3}{2} & \\frac{3}{2} & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n \\frac{13}{4} & -\\frac{3}{2} & -\\frac{13}{4} & \\frac{7}{2} & -6 \\\\\n \\frac{33}{4} & -\\frac{17}{2} & -\\frac{31}{4} & \\frac{5}{4} & \\frac{9}{4} \\\\\n -\\frac{15}{2} & 10 & 13 & \\frac{15}{4} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), (3/2), -(1/2), -1],\n [-(3/2), 2, (3/2), 0],\n [2, -2, -(3/2), (5/2)]])\nb = np.array([\n [-1, 3, 3, (5/2), -(5/2)],\n [3, -2, -2, (5/2), -(3/2)],\n [(1/2), 0, (1/2), 0, 1],\n [(1/2), 0, (3/2), (3/2), 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 0 & 1 & 2 & 1 & -3 \\\\\n 1 & 3 & 1 & 0 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 2 & 2 \\\\\n 2 & -1 \\\\\n -2 & 2 \\\\\n -3 & 1 \\\\\n 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -8 & 7 \\\\\n 7 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 2, 1, -3],\n [1, 3, 1, 0, 1]])\nb = np.array([\n [2, 2],\n [2, -1],\n [-2, 2],\n [-3, 1],\n [1, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 0 & 6 & 6 & 2 & 0 & -2 & 2 \\\\\n 6 & -7 & -7 & 2 & -3 & -2 & -5 \\\\\n 2 & 9 & 9 & 8 & -1 & 7 & -9 \\\\\n -4 & 10 & 9 & -6 & -5 & 3 & 6 \\\\\n 1 & 2 & -4 & 7 & -7 & -5 & -8 \\\\\n -8 & 1 & 10 & 5 & 6 & -7 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & \\frac{50438}{261243} \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & \\frac{106927}{261243} \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & \\frac{22349}{261243} \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & -\\frac{290093}{261243} \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & \\frac{150247}{261243} \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & -\\frac{163508}{261243} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, 6, 6, 2, 0, -2, 2],\n [6, -7, -7, 2, -3, -2, -5],\n [2, 9, 9, 8, -1, 7, -9],\n [-4, 10, 9, -6, -5, 3, 6],\n [1, 2, -4, 7, -7, -5, -8],\n [-8, 1, 10, 5, 6, -7, 2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{19}{2} & \\frac{7}{8} & \\frac{19}{4} & \\frac{69}{8} \\\\\n \\frac{17}{2} & -\\frac{19}{4} & 6 & \\frac{3}{8} \\\\\n -\\frac{29}{4} & 5 & -\\frac{39}{4} & -\\frac{15}{4} \\\\\n -\\frac{29}{8} & -\\frac{57}{8} & -\\frac{7}{8} & -\\frac{53}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{47}{8} & -2 & \\frac{3}{8} & -\\frac{45}{8} \\\\\n -\\frac{63}{8} & -\\frac{35}{8} & -\\frac{27}{8} & \\frac{23}{8} \\\\\n -\\frac{17}{8} & -\\frac{9}{2} & \\frac{65}{8} & \\frac{15}{8} \\\\\n -\\frac{73}{8} & -2 & \\frac{5}{8} & \\frac{9}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{123}{8} & -\\frac{9}{8} & \\frac{41}{8} & 3 \\\\\n \\frac{5}{8} & -\\frac{73}{8} & \\frac{21}{8} & \\frac{13}{4} \\\\\n -\\frac{75}{8} & \\frac{1}{2} & -\\frac{13}{8} & -\\frac{15}{8} \\\\\n -\\frac{51}{4} & -\\frac{73}{8} & -\\frac{1}{4} & -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/2), (7/8), (19/4), (69/8)],\n [(17/2), -(19/4), 6, (3/8)],\n [-(29/4), 5, -(39/4), -(15/4)],\n [-(29/8), -(57/8), -(7/8), -(53/8)]])\nb = np.array([\n [(47/8), -2, (3/8), -(45/8)],\n [-(63/8), -(35/8), -(27/8), (23/8)],\n [-(17/8), -(9/2), (65/8), (15/8)],\n [-(73/8), -2, (5/8), (9/8)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & -1 & 1 \\\\\n -3 & -1 & -2 \\\\\n 2 & 0 & 3 \\\\\n 1 & -2 & 3 \\\\\n -3 & 1 & 1 \\\\\n -3 & 1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.98 \\\\\n -1.23 \\\\\n 0.88 \\\\\n -1.21 \\\\\n -1.9 \\\\\n 0.25 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.562 \\\\\n 0.767 \\\\\n -0.33 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -1, 1],\n [-3, -1, -2],\n [2, 0, 3],\n [1, -2, 3],\n [-3, 1, 1],\n [-3, 1, -1]])\nb = np.array([\n [-2.98],\n [-1.23],\n [0.88],\n [-1.21],\n [-1.9],\n [0.25]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n -2 & -4 & 1 & 2 \\\\\n 4 & 6 & -2 & -3 \\\\\n 2 & 0 & -2 & 0 \\\\\n 1 & 4 & 1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -5 & -8 & 4 & 4 \\\\\n \\frac{47}{6} & \\frac{31}{3} & -5 & -\\frac{14}{3} \\\\\n -2 & -4 & 2 & 2 \\\\\n \\frac{20}{3} & \\frac{26}{3} & -\\frac{7}{2} & -\\frac{10}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [-2, -4, 1, 2],\n [4, 6, -2, -3],\n [2, 0, -2, 0],\n [1, 4, 1, -2]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & 3 & 1 & -2 & 3 \\\\\n -3 & 2 & 1 & -1 & 0 \\\\\n -2 & 3 & 0 & 0 & 2 \\\\\n 2 & -2 & 2 & 1 & 2 \\\\\n 2 & 1 & -2 & 1 & 0 \\\\\n -1 & -2 & -1 & 3 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.1 \\\\\n 2.68 \\\\\n 2.12 \\\\\n 0.75 \\\\\n -2.88 \\\\\n 0.29 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.605 \\\\\n 0.252 \\\\\n 1.097 \\\\\n 0.471 \\\\\n -0.079 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, 1, -2, 3],\n [-3, 2, 1, -1, 0],\n [-2, 3, 0, 0, 2],\n [2, -2, 2, 1, 2],\n [2, 1, -2, 1, 0],\n [-1, -2, -1, 3, 0]])\nb = np.array([\n [1.1],\n [2.68],\n [2.12],\n [0.75],\n [-2.88],\n [0.29]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & 4 & -3 \\\\\n -2 & 1 & -2 \\\\\n -1 & -1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{2}{3} & 1 & -\\frac{5}{3} \\\\\n \\frac{2}{3} & -1 & \\frac{2}{3} \\\\\n 1 & -2 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 4, -3],\n [-2, 1, -2],\n [-1, -1, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 3 & -10 & 6 \\\\\n 5 & 2 & 3 \\\\\n -3 & 0 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-2 x^2-39 x-266$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -10, 6],\n [5, 2, 3],\n [-3, 0, -7]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{51}{7} & -\\frac{12}{7} \\\\\n -6 & -\\frac{58}{7} \\\\\n -\\frac{1}{7} & \\frac{51}{7} \\\\\n -\\frac{69}{7} & -\\frac{44}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{51}{7} & -\\frac{55}{7} \\\\\n 4 & -\\frac{25}{7} \\\\\n \\frac{33}{7} & \\frac{26}{7} \\\\\n \\frac{65}{7} & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & \\frac{43}{7} \\\\\n -10 & -\\frac{33}{7} \\\\\n -\\frac{34}{7} & \\frac{25}{7} \\\\\n -\\frac{134}{7} & -\\frac{58}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(51/7), -(12/7)],\n [-6, -(58/7)],\n [-(1/7), (51/7)],\n [-(69/7), -(44/7)]])\nb = np.array([\n [-(51/7), -(55/7)],\n [4, -(25/7)],\n [(33/7), (26/7)],\n [(65/7), 2]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{8} \\\\\n -\\frac{11}{4} \\\\\n \\frac{5}{2} \\\\\n \\frac{17}{8} \\\\\n -\\frac{11}{8} \\\\\n \\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{17}{23 \\sqrt{3}} \\\\\n -\\frac{22}{23 \\sqrt{3}} \\\\\n \\frac{20}{23 \\sqrt{3}} \\\\\n \\frac{17}{23 \\sqrt{3}} \\\\\n -\\frac{11}{23 \\sqrt{3}} \\\\\n \\frac{2}{23 \\sqrt{3}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/8)],\n [-(11/4)],\n [(5/2)],\n [(17/8)],\n [-(11/8)],\n [(1/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -\\frac{21}{10} & \\frac{21}{10} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{2}{5} & \\frac{23}{10} & \\frac{3}{10} & \\frac{27}{10} \\\\\n \\frac{3}{10} & -\\frac{12}{5} & \\frac{12}{5} & -\\frac{1}{10} \\\\\n -\\frac{13}{10} & -\\frac{13}{10} & -\\frac{5}{2} & \\frac{3}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{11}{25} & -\\frac{461}{50} & \\frac{283}{50} & -\\frac{309}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(21/10), (21/10), -(1/2)]])\nb = np.array([\n [(2/5), (23/10), (3/10), (27/10)],\n [(3/10), -(12/5), (12/5), -(1/10)],\n [-(13/10), -(13/10), -(5/2), (3/5)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -7 \\\\\n 0 \\\\\n -10 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$34$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-7],\n [0],\n [-10],\n [-9]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -1 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -9 \\\\\n -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 60 \\\\\n 6 \\\\\n 81 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-1],\n [6]])\nb = np.array([\n [9],\n [-9],\n [-6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{12}{7}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & -7 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{36}{7} & -12 & \\frac{48}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -7, 4]])\nprint(a * (12/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 e \\\\\n -2 e \\\\\n e \\\\\n -2 e \\\\\n 3 e \\\\\n 2 e \\\\\n -3 e \\\\\n 2 e \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 e \\\\\n 0 \\\\\n -3 e \\\\\n -e \\\\\n -3 e \\\\\n 0 \\\\\n -e \\\\\n 3 e \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{115} e$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-3*math.e],\n [-2*math.e],\n [math.e],\n [-2*math.e],\n [3*math.e],\n [2*math.e],\n [-3*math.e],\n [2*math.e]])\nb = np.array([\n [4*math.e],\n [0],\n [-3*math.e],\n [-math.e],\n [-3*math.e],\n [0],\n [-math.e],\n [3*math.e]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 3 & -\\frac{11}{4} \\\\\n -\\frac{11}{4} & -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{4}{133} & -\\frac{44}{133} \\\\\n -\\frac{44}{133} & -\\frac{48}{133} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -(11/4)],\n [-(11/4), -(1/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 9 & 6 & 2 & -4 \\\\\n 8 & 8 & -1 & -9 \\\\\n -2 & 4 & 9 & -5 \\\\\n 3 & 5 & 5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, 6, 2, -4],\n [8, 8, -1, -9],\n [-2, 4, 9, -5],\n [3, 5, 5, -4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 6 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [6],\n [0]]).squeeze()\nb = np.array([\n [-8],\n [-2],\n [2]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{21}{4} & -\\frac{3}{2} & \\frac{19}{2} \\\\\n -\\frac{13}{2} & \\frac{23}{4} & \\frac{1}{2} \\\\\n -\\frac{29}{4} & -\\frac{7}{2} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-4.168-8.586 i,-4.168+8.586 i,7.336\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(21/4), -(3/2), (19/2)],\n [-(13/2), (23/4), (1/2)],\n [-(29/4), -(7/2), -(3/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & -1 & 0 & 1 & -3 \\\\\n 1 & -2 & -2 & -1 & -1 \\\\\n 1 & 2 & 3 & -1 & -3 \\\\\n -3 & 0 & 0 & 3 & 1 \\\\\n 2 & -2 & -2 & -1 & 3 \\\\\n 0 & 2 & -3 & 3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.93 \\\\\n 0.13 \\\\\n 0.79 \\\\\n 1.67 \\\\\n 0.93 \\\\\n -2.8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.084 \\\\\n -1.605 \\\\\n 1.43 \\\\\n 1.573 \\\\\n -0.008 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, 0, 1, -3],\n [1, -2, -2, -1, -1],\n [1, 2, 3, -1, -3],\n [-3, 0, 0, 3, 1],\n [2, -2, -2, -1, 3],\n [0, 2, -3, 3, 2]])\nb = np.array([\n [1.93],\n [0.13],\n [0.79],\n [1.67],\n [0.93],\n [-2.8]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{19}{9} \\\\\n \\frac{22}{9} \\\\\n -\\frac{20}{9} \\\\\n \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{19}{\\sqrt{1389}} \\\\\n \\frac{22}{\\sqrt{1389}} \\\\\n -\\frac{20}{\\sqrt{1389}} \\\\\n 4 \\sqrt{\\frac{3}{463}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/9)],\n [(22/9)],\n [-(20/9)],\n [(4/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{2} & \\frac{15}{4} \\\\\n 10 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{4} \\left(21-\\sqrt{721}\\right),\\frac{1}{4} \\left(21+\\sqrt{721}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), (15/4)],\n [10, 8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{4}{5} & -\\frac{43}{10} \\\\\n -\\frac{23}{10} & -\\frac{17}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{853}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/5), -(43/10)],\n [-(23/10), -(17/10)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & -3 \\\\\n 10 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{20} \\left(-3-i \\sqrt{111}\\right),1\\right\\}, \\left\\{\\frac{1}{20} \\left(-3+i \\sqrt{111}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -3],\n [10, -3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 1 & -9 & -5 & 10 \\\\\n 7 & 3 & -4 & -10 \\\\\n 6 & 3 & -3 & 3 \\\\\n 6 & -10 & 8 & 4 \\\\\n 4 & 4 & 3 & 9 \\\\\n 6 & 2 & 2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, -9, -5, 10],\n [7, 3, -4, -10],\n [6, 3, -3, 3],\n [6, -10, 8, 4],\n [4, 4, 3, 9],\n [6, 2, 2, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{32}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -8 \\\\\n 5 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{32} \\\\\n -\\frac{3}{4} \\\\\n \\frac{15}{32} \\\\\n \\frac{15}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-8],\n [5],\n [10]])\nprint(a * (3/32))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-4, 2, -5}$ to the plane $-4 x-y+5 z-3=0$.", - "Output Answer": [ - "$\\sqrt{\\frac{14}{3}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -4, 2, -5\nplane = Poly(-4*x-y+5*z-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{8} \\\\\n -\\frac{41}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{14}{\\sqrt{1877}} \\\\\n -\\frac{41}{\\sqrt{1877}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/8)],\n [-(41/16)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{13}{4}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & -8 & -1 & 8 \\\\\n -2 & 4 & 8 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 0 & -26 & -\\frac{13}{4} & 26 \\\\\n -\\frac{13}{2} & 13 & 26 & -\\frac{91}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -8, -1, 8],\n [-2, 4, 8, -7]])\nprint(a * (13/4))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{19}{7} & \\frac{32}{7} \\\\\n -\\frac{15}{7} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{49}{253} & -\\frac{56}{253} \\\\\n \\frac{105}{1012} & -\\frac{133}{1012} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/7), (32/7)],\n [-(15/7), -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-5,-\\frac{3}{2},-\\frac{9}{2}\\right\\}, \\left\\{-\\frac{7}{2},-\\frac{9}{2},3\\right\\}, \\left\\{-2,0,\\frac{3}{2}\\right\\}}$.", - "Output Answer": [ - "$26 x-12 y-10 z+67=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-5, -(3/2), -(9/2)],\n [-(7/2), -(9/2), 3],\n [-2, 0, (3/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 5 \\\\\n 9 \\\\\n 3 \\\\\n 1 \\\\\n -5 \\\\\n 9 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 5 \\\\\n 9 \\\\\n 10 \\\\\n 5 \\\\\n -6 \\\\\n -4 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{383}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [5],\n [9],\n [3],\n [1],\n [-5],\n [9],\n [-2]])\nb = np.array([\n [9],\n [5],\n [9],\n [10],\n [5],\n [-6],\n [-4],\n [0]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{27}{\\pi } \\\\\n -\\frac{17}{\\pi } \\\\\n -\\frac{13}{\\pi } \\\\\n -\\frac{10}{\\pi } \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{18}{\\pi } \\\\\n \\frac{21}{\\pi } \\\\\n -\\frac{7}{\\pi } \\\\\n \\frac{10}{\\pi } \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{120}{\\pi ^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(27/math.pi)],\n [-(17/math.pi)],\n [-(13/math.pi)],\n [-(10/math.pi)]])\nb = np.array([\n [-(18/math.pi)],\n [(21/math.pi)],\n [-(7/math.pi)],\n [(10/math.pi)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1.52 \\\\\n 3.85 \\\\\n -8.03 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6.56 \\\\\n -7.06 \\\\\n -8.76 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$13.5959$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1.52],\n [3.85],\n [-8.03]])\nb = np.array([\n [-6.56],\n [-7.06],\n [-8.76]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -4 & -5 & 0 \\\\\n 2 & -1 & 4 \\\\\n -3 & 1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & -1 & -1 \\\\\n -\\frac{1}{5} & \\frac{4}{5} & \\frac{4}{5} \\\\\n -\\frac{1}{20} & \\frac{19}{20} & \\frac{7}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -5, 0],\n [2, -1, 4],\n [-3, 1, -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{2}{3}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -10 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{20}{3} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 0]])\nprint(a * -(2/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 10 & -1 & -8 \\\\\n 9 & 3 & -6 \\\\\n -5 & -6 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [10, -1, -8],\n [9, 3, -6],\n [-5, -6, -6]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 0 & 10 & -8 \\\\\n 4 & -1 & 10 \\\\\n 0 & 8 & 2 \\\\\n -6 & -6 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, 10, -8],\n [4, -1, 10],\n [0, 8, 2],\n [-6, -6, 4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{5}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -1 \\\\\n 5 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{9}{5} \\\\\n -\\frac{3}{5} \\\\\n 3 \\\\\n \\frac{12}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-1],\n [5],\n [4]])\nprint(a * (3/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & -3 & 0 & -2 \\\\\n -1 & 3 & 1 & -1 \\\\\n 0 & 3 & 1 & 1 \\\\\n -3 & -3 & -3 & 0 \\\\\n 2 & -1 & -1 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.41 \\\\\n -2.06 \\\\\n -2.84 \\\\\n -0.78 \\\\\n 2.75 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.875 \\\\\n -0.223 \\\\\n -0.582 \\\\\n -0.003 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3, 0, -2],\n [-1, 3, 1, -1],\n [0, 3, 1, 1],\n [-3, -3, -3, 0],\n [2, -1, -1, -2]])\nb = np.array([\n [1.41],\n [-2.06],\n [-2.84],\n [-0.78],\n [2.75]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-1,-\\frac{1}{3},\\frac{5}{3}\\right\\}, \\left\\{\\frac{14}{3},\\frac{5}{3},\\frac{5}{3}\\right\\}, \\left\\{-\\frac{10}{3},\\frac{11}{3},\\frac{5}{3}\\right\\}}$.", - "Output Answer": [ - "$3 z-5=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, -(1/3), (5/3)],\n [(14/3), (5/3), (5/3)],\n [-(10/3), (11/3), (5/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 10 & 4 \\\\\n -4 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-5 x-34$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 4],\n [-4, -5]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 0 \\\\\n 1 \\\\\n 3 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{2 \\sqrt{5}} \\\\\n 0 \\\\\n \\frac{1}{2 \\sqrt{5}} \\\\\n \\frac{3}{2 \\sqrt{5}} \\\\\n -\\frac{1}{2 \\sqrt{5}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [0],\n [1],\n [3],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{27}{10}, \\frac{13}{10}}$ to the line $\\frac{x}{10}+\\frac{43}{10}=0$.", - "Output Answer": [ - "$\\frac{403}{10}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(27/10), (13/10)\nline = Poly((x/10)+(43/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{4}{3} & \\frac{14}{3} \\\\\n \\frac{10}{3} & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{200}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/3), (14/3)],\n [(10/3), 5]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 4 \\\\\n -7 & -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{28} \\left(-29-\\sqrt{393}\\right),1\\right\\}, \\left\\{\\frac{1}{28} \\left(\\sqrt{393}-29\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 4],\n [-7, -(13/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{23}{3} & \\frac{10}{3} & -\\frac{17}{3} \\\\\n -9 & -\\frac{2}{3} & \\frac{10}{3} \\\\\n \\frac{13}{3} & 7 & -\\frac{13}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{8 x^2}{3}+\\frac{38 x}{9}+\\frac{2755}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/3), (10/3), -(17/3)],\n [-9, -(2/3), (10/3)],\n [(13/3), 7, -(13/3)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{1}{e},\\frac{5}{e},\\frac{5}{e}\\right\\}, \\left\\{\\frac{2}{e},-\\frac{7}{e},-\\frac{3}{e}\\right\\}, \\left\\{-\\frac{5}{e},\\frac{5}{e},\\frac{2}{e}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{51}},\\frac{5}{\\sqrt{51}},\\frac{5}{\\sqrt{51}}\\right\\}, \\left\\{25 \\sqrt{\\frac{2}{2431}},-3 \\sqrt{\\frac{13}{374}},\\frac{29}{\\sqrt{4862}}\\right\\}, \\left\\{-10 \\sqrt{\\frac{2}{429}},-\\sqrt{\\frac{13}{66}},\\frac{17}{\\sqrt{858}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((1/math.e), (5/math.e), (5/math.e)), ((2/math.e), -(7/math.e), -(3/math.e)), (-(5/math.e), (5/math.e), (2/math.e))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{35}{4} & -\\frac{13}{2} \\\\\n \\frac{27}{4} & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{54} \\left(-59-\\sqrt{673}\\right),1\\right\\}, \\left\\{\\frac{1}{54} \\left(\\sqrt{673}-59\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(35/4), -(13/2)],\n [(27/4), 6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-2$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & -2 & -10 \\\\\n 10 & 7 & 8 \\\\\n 8 & 3 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 4 & 4 & 20 \\\\\n -20 & -14 & -16 \\\\\n -16 & -6 & -18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2, -10],\n [10, 7, 8],\n [8, 3, 9]])\nprint(a * -2)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, 2}$ to the line $-\\frac{23 x}{5}+\\frac{22 y}{5}-\\frac{7}{5}=0$.", - "Output Answer": [ - "$\\frac{106}{\\sqrt{1013}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, 2\nline = Poly(-((23*x)/5)+((22*y)/5)-(7/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -6 \\\\\n 5 \\\\\n -6 \\\\\n -3 \\\\\n 9 \\\\\n -3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 5 \\\\\n 6 \\\\\n 2 \\\\\n -2 \\\\\n -2 \\\\\n 4 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-80$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-6],\n [5],\n [-6],\n [-3],\n [9],\n [-3],\n [-2]])\nb = np.array([\n [-7],\n [5],\n [6],\n [2],\n [-2],\n [-2],\n [4],\n [-6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 2 \\\\\n -1 \\\\\n 3 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{\\sqrt{\\frac{3}{2}}}{2} \\\\\n \\frac{1}{\\sqrt{6}} \\\\\n -\\frac{1}{2 \\sqrt{6}} \\\\\n \\frac{\\sqrt{\\frac{3}{2}}}{2} \\\\\n 0 \\\\\n \\frac{1}{2 \\sqrt{6}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [2],\n [-1],\n [3],\n [0],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{9}{2} & -\\frac{15}{2} & 1 \\\\\n -\\frac{15}{2} & 5 & -7 \\\\\n -\\frac{1}{2} & -\\frac{5}{2} & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.963,0.293,1.\\}, \\{2.897,3.301,1.\\}, \\{3.134,-3.608,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/2), -(15/2), 1],\n [-(15/2), 5, -7],\n [-(1/2), -(5/2), 6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n 4 & -\\frac{42}{5} & \\frac{21}{5} \\\\\n \\frac{13}{5} & 1 & 9 \\\\\n \\frac{8}{5} & \\frac{48}{5} & \\frac{2}{5} \\\\\n \\frac{44}{5} & 5 & -\\frac{17}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -(42/5), (21/5)],\n [(13/5), 1, 9],\n [(8/5), (48/5), (2/5)],\n [(44/5), 5, -(17/5)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{8}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 6 & 3 & 1 \\\\\n -1 & -7 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{9}{4} & -\\frac{9}{8} & -\\frac{3}{8} \\\\\n \\frac{3}{8} & \\frac{21}{8} & -\\frac{9}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 3, 1],\n [-1, -7, 3]])\nprint(a * -(3/8))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{4} & \\frac{15}{4} \\\\\n -\\frac{5}{4} & -\\frac{9}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{3}{10} & -\\frac{1}{2} \\\\\n \\frac{1}{6} & -\\frac{1}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/4), (15/4)],\n [-(5/4), -(9/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{11}{5}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -6 & -3 & -8 & -6 \\\\\n 5 & -10 & 1 & -2 \\\\\n -4 & 1 & 3 & 10 \\\\\n 3 & -8 & -9 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{66}{5} & -\\frac{33}{5} & -\\frac{88}{5} & -\\frac{66}{5} \\\\\n 11 & -22 & \\frac{11}{5} & -\\frac{22}{5} \\\\\n -\\frac{44}{5} & \\frac{11}{5} & \\frac{33}{5} & 22 \\\\\n \\frac{33}{5} & -\\frac{88}{5} & -\\frac{99}{5} & -\\frac{77}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -3, -8, -6],\n [5, -10, 1, -2],\n [-4, 1, 3, 10],\n [3, -8, -9, -7]])\nprint(a * (11/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\sqrt{3},-\\frac{1}{\\sqrt{3}},\\frac{4}{\\sqrt{3}}\\right\\}, \\left\\{-\\frac{5}{\\sqrt{3}},0,\\frac{2}{\\sqrt{3}}\\right\\}, \\left\\{\\frac{5}{\\sqrt{3}},0,-\\frac{5}{\\sqrt{3}}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{3}{\\sqrt{26}},-\\frac{1}{\\sqrt{26}},2 \\sqrt{\\frac{2}{13}}\\right\\}, \\left\\{\\frac{\\frac{23 \\sqrt{3}}{26}-\\frac{5}{\\sqrt{3}}}{\\sqrt{\\frac{2129}{2028}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{26}\\right)^2}},\\frac{23}{26 \\sqrt{3 \\left(\\frac{2129}{2028}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{26}\\right)^2\\right)}},-\\frac{20}{13 \\sqrt{3 \\left(\\frac{2129}{2028}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{26}\\right)^2\\right)}}\\right\\}, \\left\\{\\frac{\\frac{5}{\\sqrt{3}}-\\frac{35 \\sqrt{3}}{26}-\\frac{\\left(-\\frac{5}{\\sqrt{3}}+\\frac{23 \\sqrt{3}}{26}\\right) \\left(\\frac{100}{39}+\\frac{5 \\left(-\\frac{5}{\\sqrt{3}}+\\frac{23 \\sqrt{3}}{26}\\right)}{\\sqrt{3}}\\right)}{\\frac{2129}{2028}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{26}\\right)^2}}{\\sqrt{\\left(-\\frac{5}{13 \\sqrt{3}}-\\frac{20 \\left(\\frac{100}{39}+\\frac{5 \\left(-\\frac{5}{\\sqrt{3}}+\\frac{23 \\sqrt{3}}{26}\\right)}{\\sqrt{3}}\\right)}{13 \\sqrt{3} \\left(\\frac{2129}{2028}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{26}\\right)^2\\right)}\\right)^2+\\left(\\frac{35}{26 \\sqrt{3}}+\\frac{23 \\left(\\frac{100}{39}+\\frac{5 \\left(-\\frac{5}{\\sqrt{3}}+\\frac{23 \\sqrt{3}}{26}\\right)}{\\sqrt{3}}\\right)}{26 \\sqrt{3} \\left(\\frac{2129}{2028}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{26}\\right)^2\\right)}\\right)^2+\\left(-\\frac{5}{\\sqrt{3}}+\\frac{35 \\sqrt{3}}{26}-\\frac{\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{26}\\right) \\left(\\frac{100}{39}+\\frac{5 \\left(-\\frac{5}{\\sqrt{3}}+\\frac{23 \\sqrt{3}}{26}\\right)}{\\sqrt{3}}\\right)}{\\frac{2129}{2028}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{26}\\right)^2}\\right)^2}},\\frac{-\\frac{35}{26 \\sqrt{3}}-\\frac{23 \\left(\\frac{100}{39}+\\frac{5 \\left(-\\frac{5}{\\sqrt{3}}+\\frac{23 \\sqrt{3}}{26}\\right)}{\\sqrt{3}}\\right)}{26 \\sqrt{3} \\left(\\frac{2129}{2028}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{26}\\right)^2\\right)}}{\\sqrt{\\left(-\\frac{5}{13 \\sqrt{3}}-\\frac{20 \\left(\\frac{100}{39}+\\frac{5 \\left(-\\frac{5}{\\sqrt{3}}+\\frac{23 \\sqrt{3}}{26}\\right)}{\\sqrt{3}}\\right)}{13 \\sqrt{3} \\left(\\frac{2129}{2028}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{26}\\right)^2\\right)}\\right)^2+\\left(\\frac{35}{26 \\sqrt{3}}+\\frac{23 \\left(\\frac{100}{39}+\\frac{5 \\left(-\\frac{5}{\\sqrt{3}}+\\frac{23 \\sqrt{3}}{26}\\right)}{\\sqrt{3}}\\right)}{26 \\sqrt{3} \\left(\\frac{2129}{2028}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{26}\\right)^2\\right)}\\right)^2+\\left(-\\frac{5}{\\sqrt{3}}+\\frac{35 \\sqrt{3}}{26}-\\frac{\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{26}\\right) \\left(\\frac{100}{39}+\\frac{5 \\left(-\\frac{5}{\\sqrt{3}}+\\frac{23 \\sqrt{3}}{26}\\right)}{\\sqrt{3}}\\right)}{\\frac{2129}{2028}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{26}\\right)^2}\\right)^2}},\\frac{\\frac{5}{13 \\sqrt{3}}+\\frac{20 \\left(\\frac{100}{39}+\\frac{5 \\left(-\\frac{5}{\\sqrt{3}}+\\frac{23 \\sqrt{3}}{26}\\right)}{\\sqrt{3}}\\right)}{13 \\sqrt{3} \\left(\\frac{2129}{2028}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{26}\\right)^2\\right)}}{\\sqrt{\\left(-\\frac{5}{13 \\sqrt{3}}-\\frac{20 \\left(\\frac{100}{39}+\\frac{5 \\left(-\\frac{5}{\\sqrt{3}}+\\frac{23 \\sqrt{3}}{26}\\right)}{\\sqrt{3}}\\right)}{13 \\sqrt{3} \\left(\\frac{2129}{2028}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{26}\\right)^2\\right)}\\right)^2+\\left(\\frac{35}{26 \\sqrt{3}}+\\frac{23 \\left(\\frac{100}{39}+\\frac{5 \\left(-\\frac{5}{\\sqrt{3}}+\\frac{23 \\sqrt{3}}{26}\\right)}{\\sqrt{3}}\\right)}{26 \\sqrt{3} \\left(\\frac{2129}{2028}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{26}\\right)^2\\right)}\\right)^2+\\left(-\\frac{5}{\\sqrt{3}}+\\frac{35 \\sqrt{3}}{26}-\\frac{\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{26}\\right) \\left(\\frac{100}{39}+\\frac{5 \\left(-\\frac{5}{\\sqrt{3}}+\\frac{23 \\sqrt{3}}{26}\\right)}{\\sqrt{3}}\\right)}{\\frac{2129}{2028}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{23 \\sqrt{3}}{26}\\right)^2}\\right)^2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-math.sqrt(3), -(1/(math.sqrt(3))), (4/(math.sqrt(3)))), (-(5/(math.sqrt(3))), 0, (2/(math.sqrt(3)))), ((5/(math.sqrt(3))), 0, -(5/(math.sqrt(3))))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{19}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2)],\n [4]])\nb = np.array([\n [-7],\n [2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{26}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [3]])\nb = np.array([\n [1],\n [-2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 9 & -9 & -4 \\\\\n 7 & 0 & -9 \\\\\n -8 & 10 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+18 x^2-202 x+449$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -9, -4],\n [7, 0, -9],\n [-8, 10, 9]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & 4 \\\\\n 0 & 4 & 0 \\\\\n 2 & -2 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-48$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, 4],\n [0, 4, 0],\n [2, -2, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 1+3 i & -4 i \\\\\n -1 & -2+3 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -8+10 i & 24+4 i \\\\\n 1-6 i & -5-8 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1+3j, -4j],\n [-1, -2+3j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n \\frac{26}{9} & -\\frac{22}{9} & -\\frac{17}{3} \\\\\n -\\frac{1}{9} & -\\frac{11}{3} & \\frac{17}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 9 & -\\frac{7}{3} & \\frac{40}{9} \\\\\n 3 & \\frac{80}{9} & -\\frac{82}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{107}{9} & -\\frac{43}{9} & -\\frac{11}{9} \\\\\n \\frac{26}{9} & \\frac{47}{9} & -\\frac{31}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/9), -(22/9), -(17/3)],\n [-(1/9), -(11/3), (17/3)]])\nb = np.array([\n [9, -(7/3), (40/9)],\n [3, (80/9), -(82/9)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -3 & -\\frac{26}{3} \\\\\n -4 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{6} \\left(-15-\\sqrt{1257}\\right),\\frac{1}{6} \\left(\\sqrt{1257}-15\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -(26/3)],\n [-4, -2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -4 \\\\\n 7 \\\\\n -9 \\\\\n -8 \\\\\n 8 \\\\\n 9 \\\\\n 3 \\\\\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -4 \\\\\n 5 \\\\\n -6 \\\\\n -6 \\\\\n 0 \\\\\n -8 \\\\\n -9 \\\\\n 9 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{757}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-4],\n [7],\n [-9],\n [-8],\n [8],\n [9],\n [3],\n [2],\n [2]])\nb = np.array([\n [-4],\n [-4],\n [5],\n [-6],\n [-6],\n [0],\n [-8],\n [-9],\n [9],\n [7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{3} & -\\frac{28}{3} \\\\\n -\\frac{13}{6} & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{16 x}{3}-\\frac{287}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3), -(28/3)],\n [-(13/6), -7]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & -\\frac{13}{4} \\\\\n \\frac{39}{4} & \\frac{19}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{27 x}{2}+\\frac{1115}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -(13/4)],\n [(39/4), (19/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{2}{5} & -\\frac{13}{10} \\\\\n -\\frac{44}{5} & -\\frac{71}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{15 x}{2}-\\frac{43}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/5), -(13/10)],\n [-(44/5), -(71/10)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 7 \\\\\n 9 \\\\\n -3 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 3 \\\\\n 4 \\\\\n -3 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$41$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [7],\n [9],\n [-3],\n [-5]])\nb = np.array([\n [2],\n [3],\n [4],\n [-3],\n [3]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -3 & -1 & -2 \\\\\n -2 & 4 & -3 \\\\\n -4 & 1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{15}{91} & -\\frac{1}{91} & -\\frac{11}{91} \\\\\n -\\frac{18}{91} & \\frac{17}{91} & \\frac{5}{91} \\\\\n -\\frac{2}{13} & -\\frac{1}{13} & \\frac{2}{13} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1, -2],\n [-2, 4, -3],\n [-4, 1, 3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{25}{4} & 6 & 0 & -4 \\\\\n \\frac{13}{4} & \\frac{13}{2} & -\\frac{9}{4} & -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{3}{2} & \\frac{11}{2} & -\\frac{5}{2} & -8 \\\\\n \\frac{19}{4} & 6 & \\frac{19}{4} & -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{19}{4} & \\frac{23}{2} & -\\frac{5}{2} & -12 \\\\\n 8 & \\frac{25}{2} & \\frac{5}{2} & -\\frac{27}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/4), 6, 0, -4],\n [(13/4), (13/2), -(9/4), -(1/4)]])\nb = np.array([\n [(3/2), (11/2), -(5/2), -8],\n [(19/4), 6, (19/4), -(13/2)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 8 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -5 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{194}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [8],\n [9]])\nb = np.array([\n [4],\n [-5],\n [9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 1 & 1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -1 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 2 & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1]])\nb = np.array([\n [-1, 8]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{41}{10} \\\\\n \\frac{79}{10} \\\\\n \\frac{79}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{77}{10} \\\\\n \\frac{31}{10} \\\\\n -\\frac{3}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1343}{50} \\\\\n -\\frac{3103}{50} \\\\\n \\frac{1203}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(41/10)],\n [(79/10)],\n [(79/10)]])\nb = np.array([\n [-(77/10)],\n [(31/10)],\n [-(3/10)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 4+4 i & -4+i & -1+4 i \\\\\n 4 i & -4+3 i & -2+2 i \\\\\n -3+3 i & 2 i & -3-3 i \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 82-84 i & 215+60 i & 75-5 i \\\\\n 172-116 i & 296+189 i & 118+46 i \\\\\n 102-56 i & 109+103 i & 90+62 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4+4j, -4+ 1j, -1+4j],\n [4j, -4+3j, -2+2j],\n [-3+3j, 2j, -3-3j]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 2 & 1 & -1 & 0 \\\\\n -2 & 1 & -2 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 0 & 0 & 0 & -1 & 1 \\\\\n -3 & -3 & -2 & 0 & -1 \\\\\n -1 & 2 & -1 & 2 & 0 \\\\\n -2 & -2 & 2 & -1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -2 & -5 & -1 & -4 & 1 \\\\\n -1 & -7 & 0 & -2 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, -1, 0],\n [-2, 1, -2, 0]])\nb = np.array([\n [0, 0, 0, -1, 1],\n [-3, -3, -2, 0, -1],\n [-1, 2, -1, 2, 0],\n [-2, -2, 2, -1, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & -2 & 2 \\\\\n -3 & -1 & -3 \\\\\n 1 & 0 & -2 \\\\\n 0 & 2 & -1 \\\\\n 1 & -3 & 3 \\\\\n 1 & -3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.39 \\\\\n 0.28 \\\\\n -1.44 \\\\\n 0.69 \\\\\n -1.81 \\\\\n 2.02 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.129 \\\\\n -0.035 \\\\\n -0.252 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2, 2],\n [-3, -1, -3],\n [1, 0, -2],\n [0, 2, -1],\n [1, -3, 3],\n [1, -3, -3]])\nb = np.array([\n [0.39],\n [0.28],\n [-1.44],\n [0.69],\n [-1.81],\n [2.02]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [1]])\nb = np.array([\n [0],\n [-1],\n [-4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{20}{7},\\frac{5}{7},-\\frac{11}{7}\\right\\}, \\left\\{-3,0,-\\frac{6}{7}\\right\\}, \\left\\{-\\frac{13}{7},\\frac{4}{7},-\\frac{17}{7}\\right\\}}$", - "Output Answer": [ - "${\\left\\{10 \\sqrt{\\frac{2}{273}},\\frac{5}{\\sqrt{546}},-\\frac{11}{\\sqrt{546}}\\right\\}, \\left\\{-\\frac{731}{\\sqrt{2049411}},\\frac{295}{\\sqrt{2049411}},-\\frac{1195}{\\sqrt{2049411}}\\right\\}, \\left\\{-5 \\sqrt{\\frac{2}{7507}},\\frac{117}{\\sqrt{15014}},\\frac{35}{\\sqrt{15014}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack((((20/7), (5/7), -(11/7)), (-3, 0, -(6/7)), (-(13/7), (4/7), -(17/7))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-1,0,-3\\}, \\{1,0,-2\\}, \\{-1,-1,-3\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{10}},0,-\\frac{3}{\\sqrt{10}}\\right\\}, \\left\\{\\frac{3}{\\sqrt{10}},0,-\\frac{1}{\\sqrt{10}}\\right\\}, \\{0,-1,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, 0, -3), (1, 0, -2), (-1, -1, -3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 1 & 2 \\\\\n 1 & 2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 3 & 6 \\\\\n 3 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2],\n [1, 2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & 4 & 5 \\\\\n 5 & 8 & -1 \\\\\n 5 & -8 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-4.233,10.117\\, -2.512 i,10.117\\, +2.512 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 4, 5],\n [5, 8, -1],\n [5, -8, 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{5} \\\\\n \\frac{8}{5} \\\\\n -\\frac{1}{5} \\\\\n -\\frac{9}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{9}{\\sqrt{227}} \\\\\n \\frac{8}{\\sqrt{227}} \\\\\n -\\frac{1}{\\sqrt{227}} \\\\\n -\\frac{9}{\\sqrt{227}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/5)],\n [(8/5)],\n [-(1/5)],\n [-(9/5)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{23}{6} & -\\frac{17}{6} \\\\\n -\\frac{13}{6} & -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{589}{36}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/6), -(17/6)],\n [-(13/6), -(8/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{13}{4} & -\\frac{35}{16} & \\frac{23}{4} & \\frac{17}{4} \\\\\n \\frac{33}{16} & -\\frac{31}{16} & -\\frac{25}{4} & -\\frac{21}{8} \\\\\n -\\frac{35}{16} & \\frac{75}{16} & -\\frac{43}{8} & -\\frac{153}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 4 & \\frac{25}{4} & \\frac{25}{4} & \\frac{19}{4} \\\\\n -\\frac{93}{16} & -\\frac{5}{8} & -\\frac{1}{8} & -\\frac{11}{2} \\\\\n \\frac{105}{16} & -\\frac{27}{8} & -\\frac{23}{4} & \\frac{35}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{29}{4} & \\frac{65}{16} & 12 & 9 \\\\\n -\\frac{15}{4} & -\\frac{41}{16} & -\\frac{51}{8} & -\\frac{65}{8} \\\\\n \\frac{35}{8} & \\frac{21}{16} & -\\frac{89}{8} & -\\frac{59}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/4), -(35/16), (23/4), (17/4)],\n [(33/16), -(31/16), -(25/4), -(21/8)],\n [-(35/16), (75/16), -(43/8), -(153/16)]])\nb = np.array([\n [4, (25/4), (25/4), (19/4)],\n [-(93/16), -(5/8), -(1/8), -(11/2)],\n [(105/16), -(27/8), -(23/4), (35/16)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -2 & -1 & -2 & 1 \\\\\n 3 & -2 & 3 & -3 \\\\\n -1 & -2 & 1 & 3 \\\\\n -3 & 0 & 0 & 3 \\\\\n -2 & 0 & 3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.19 \\\\\n 0.31 \\\\\n -1.57 \\\\\n -0.78 \\\\\n 1.72 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.732 \\\\\n 0.345 \\\\\n 0.431 \\\\\n -0.728 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1, -2, 1],\n [3, -2, 3, -3],\n [-1, -2, 1, 3],\n [-3, 0, 0, 3],\n [-2, 0, 3, 2]])\nb = np.array([\n [-0.19],\n [0.31],\n [-1.57],\n [-0.78],\n [1.72]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 2 & 3 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 2 & 2 & -1 \\\\\n 1 & -2 & 0 \\\\\n -1 & 0 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 10 & -2 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 3, -3]])\nb = np.array([\n [2, 2, -1],\n [1, -2, 0],\n [-1, 0, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & -4 \\\\\n 4 & 1 & -5 \\\\\n 3 & -3 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{2}{5} & \\frac{1}{5} & \\frac{1}{5} \\\\\n -\\frac{1}{15} & \\frac{1}{5} & -\\frac{11}{45} \\\\\n -\\frac{1}{3} & 0 & \\frac{1}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, -4],\n [4, 1, -5],\n [3, -3, -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & -5 & -3 \\\\\n -3 & 1 & 5 \\\\\n -4 & -2 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$160$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -5, -3],\n [-3, 1, 5],\n [-4, -2, -5]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{17}{3} & -\\frac{88}{9} & -\\frac{61}{9} \\\\\n -\\frac{44}{9} & \\frac{56}{9} & \\frac{17}{9} \\\\\n -\\frac{13}{9} & \\frac{73}{9} & \\frac{56}{9} \\\\\n 2 & -\\frac{73}{9} & -\\frac{64}{9} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{73}{9} & -\\frac{16}{9} & -\\frac{16}{3} \\\\\n \\frac{13}{3} & \\frac{5}{9} & -\\frac{10}{9} \\\\\n -\\frac{13}{9} & \\frac{64}{9} & -\\frac{44}{9} \\\\\n -\\frac{7}{9} & -\\frac{67}{9} & -\\frac{88}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{124}{9} & -8 & -\\frac{13}{9} \\\\\n -\\frac{83}{9} & \\frac{17}{3} & 3 \\\\\n 0 & 1 & \\frac{100}{9} \\\\\n \\frac{25}{9} & -\\frac{2}{3} & \\frac{8}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/3), -(88/9), -(61/9)],\n [-(44/9), (56/9), (17/9)],\n [-(13/9), (73/9), (56/9)],\n [2, -(73/9), -(64/9)]])\nb = np.array([\n [(73/9), -(16/9), -(16/3)],\n [(13/3), (5/9), -(10/9)],\n [-(13/9), (64/9), -(44/9)],\n [-(7/9), -(67/9), -(88/9)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{26}{3} & -\\frac{26}{3} & \\frac{2}{3} \\\\\n -\\frac{28}{3} & \\frac{11}{3} & \\frac{19}{3} \\\\\n -3 & \\frac{8}{3} & \\frac{29}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-3.334,8.11,17.224\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/3), -(26/3), (2/3)],\n [-(28/3), (11/3), (19/3)],\n [-3, (8/3), (29/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{12}{7}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -9 & 5 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{108}{7} & \\frac{60}{7} & -\\frac{96}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 5, -8]])\nprint(a * (12/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & 9 & -8 \\\\\n -8 & 6 & 8 \\\\\n 1 & 4 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{2.054\\, -8.872 i,2.054\\, +8.872 i,13.892\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 9, -8],\n [-8, 6, 8],\n [1, 4, 10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,-5,-2\\}, \\{1,-5,4\\}, \\{-2,1,-1\\}}$.", - "Output Answer": [ - "$36 x+13 y-6 z+53=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, -5, -2],\n [1, -5, 4],\n [-2, 1, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{53}{10} \\\\\n -\\frac{39}{5} \\\\\n \\frac{5}{2} \\\\\n \\frac{7}{10} \\\\\n -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{263}{10}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(53/10)],\n [-(39/5)],\n [(5/2)],\n [(7/10)],\n [-10]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n \\frac{88}{9} & -\\frac{11}{3} & -\\frac{49}{9} \\\\\n -7 & -\\frac{74}{9} & -\\frac{17}{9} \\\\\n -\\frac{74}{9} & -\\frac{46}{9} & \\frac{53}{9} \\\\\n \\frac{14}{3} & \\frac{5}{3} & 8 \\\\\n \\frac{68}{9} & \\frac{56}{9} & -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(88/9), -(11/3), -(49/9)],\n [-7, -(74/9), -(17/9)],\n [-(74/9), -(46/9), (53/9)],\n [(14/3), (5/3), 8],\n [(68/9), (56/9), -(11/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -4 & -1 & -5 \\\\\n 0 & 4 & 3 \\\\\n 2 & -3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{9}{2} & -\\frac{15}{2} & -\\frac{17}{2} \\\\\n -3 & -5 & -6 \\\\\n 4 & 7 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -1, -5],\n [0, 4, 3],\n [2, -3, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-10]])\nb = np.array([\n [0],\n [-1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{8}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -10 & -6 & -6 & 4 \\\\\n -6 & -8 & -8 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{25}{4} & \\frac{15}{4} & \\frac{15}{4} & -\\frac{5}{2} \\\\\n \\frac{15}{4} & 5 & 5 & -\\frac{5}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -6, -6, 4],\n [-6, -8, -8, 2]])\nprint(a * -(5/8))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [4]]).squeeze()\nb = np.array([\n [-9],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{14}{\\sqrt{\\pi }} \\\\\n \\frac{11}{\\sqrt{\\pi }} \\\\\n -\\frac{6}{\\sqrt{\\pi }} \\\\\n -\\frac{8}{\\sqrt{\\pi }} \\\\\n -\\frac{12}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{8}{\\sqrt{\\pi }} \\\\\n -\\frac{1}{\\sqrt{\\pi }} \\\\\n \\frac{8}{\\sqrt{\\pi }} \\\\\n \\frac{18}{\\sqrt{\\pi }} \\\\\n -\\frac{7}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{7}{\\pi }$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(14/(math.sqrt(math.pi)))],\n [(11/(math.sqrt(math.pi)))],\n [-(6/(math.sqrt(math.pi)))],\n [-(8/(math.sqrt(math.pi)))],\n [-(12/(math.sqrt(math.pi)))]])\nb = np.array([\n [(8/(math.sqrt(math.pi)))],\n [-(1/(math.sqrt(math.pi)))],\n [(8/(math.sqrt(math.pi)))],\n [(18/(math.sqrt(math.pi)))],\n [-(7/(math.sqrt(math.pi)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -4 & 3 \\\\\n 1 & -2 & 4 \\\\\n -3 & -5 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -4, 3],\n [1, -2, 4],\n [-3, -5, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -3 \\\\\n -2 \\\\\n -2 \\\\\n 0 \\\\\n -3 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 3 \\\\\n 3 \\\\\n 3 \\\\\n -3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{40}{41},-\\frac{60}{41},-\\frac{60}{41},-\\frac{60}{41},\\frac{60}{41},-\\frac{20}{41}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-3],\n [-2],\n [-2],\n [0],\n [-3]]).squeeze()\nb = np.array([\n [-2],\n [3],\n [3],\n [3],\n [-3],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 8 & -3 & 10 & -4 & 2 \\\\\n -1 & -4 & -4 & 1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & \\frac{52}{35} & -\\frac{19}{35} & \\frac{8}{35} \\\\\n 0 & 1 & \\frac{22}{35} & -\\frac{4}{35} & -\\frac{2}{35} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, -3, 10, -4, 2],\n [-1, -4, -4, 1, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & 0 & -3 & 2 \\\\\n 1 & 1 & -1 & 2 \\\\\n 3 & 1 & -3 & -1 \\\\\n 0 & 1 & -2 & 3 \\\\\n 0 & -1 & 0 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.32 \\\\\n 0.19 \\\\\n 0.29 \\\\\n 2.73 \\\\\n 1.04 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.45 \\\\\n -0.433 \\\\\n -0.006 \\\\\n 0.688 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, -3, 2],\n [1, 1, -1, 2],\n [3, 1, -3, -1],\n [0, 1, -2, 3],\n [0, -1, 0, 1]])\nb = np.array([\n [-0.32],\n [0.19],\n [0.29],\n [2.73],\n [1.04]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{2} & \\frac{1}{2} \\\\\n -\\frac{3}{2} & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{11}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2), (1/2)],\n [-(3/2), -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 9 & -6 & 2 & -1 & 4 & -4 \\\\\n -7 & -3 & 6 & -5 & 6 & 0 \\\\\n -8 & 4 & -6 & -9 & 8 & -3 \\\\\n 8 & 3 & 7 & 5 & 7 & 5 \\\\\n -1 & -1 & -9 & 5 & 1 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & -\\frac{10009}{16609} \\\\\n 0 & 1 & 0 & 0 & 0 & -\\frac{2268}{16609} \\\\\n 0 & 0 & 1 & 0 & 0 & -\\frac{2684}{16609} \\\\\n 0 & 0 & 0 & 1 & 0 & \\frac{23963}{16609} \\\\\n 0 & 0 & 0 & 0 & 1 & \\frac{9842}{16609} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, -6, 2, -1, 4, -4],\n [-7, -3, 6, -5, 6, 0],\n [-8, 4, -6, -9, 8, -3],\n [8, 3, 7, 5, 7, 5],\n [-1, -1, -9, 5, 1, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & -9 \\\\\n 2 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} \\left(-1-i \\sqrt{71}\\right),1\\right\\}, \\left\\{\\frac{1}{4} \\left(-1+i \\sqrt{71}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -9],\n [2, 3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -1 & 0 & -2 & 0 \\\\\n 2 & 1 & 2 & 2 \\\\\n 0 & 0 & 1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 2 & 2 & -2 & 3 & 3 \\\\\n 3 & 0 & 2 & -2 & 1 \\\\\n -1 & 2 & -3 & -3 & -3 \\\\\n -1 & -1 & 0 & -1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 0 & -6 & 8 & 3 & 3 \\\\\n 3 & 6 & -8 & -4 & -1 \\\\\n -3 & 0 & -3 & -5 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, -2, 0],\n [2, 1, 2, 2],\n [0, 0, 1, 2]])\nb = np.array([\n [2, 2, -2, 3, 3],\n [3, 0, 2, -2, 1],\n [-1, 2, -3, -3, -3],\n [-1, -1, 0, -1, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 0 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [0],\n [-2]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 2 & 2 \\\\\n 2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, 2],\n [2, 1]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{65}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-6]])\nb = np.array([\n [-6],\n [1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & -\\frac{9}{10} & -\\frac{18}{5} \\\\\n -\\frac{1}{5} & -\\frac{7}{2} & \\frac{21}{5} \\\\\n \\frac{3}{5} & \\frac{23}{10} & -\\frac{9}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{4857}{200}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), -(9/10), -(18/5)],\n [-(1/5), -(7/2), (21/5)],\n [(3/5), (23/10), -(9/10)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & -3 & 1 \\\\\n -2 & -2 & 3 \\\\\n 0 & 3 & -1 \\\\\n -1 & 2 & -1 \\\\\n 3 & 2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.19 \\\\\n -2.61 \\\\\n 0.25 \\\\\n -1.97 \\\\\n -1.32 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.795 \\\\\n 0.257 \\\\\n 0.644 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, 1],\n [-2, -2, 3],\n [0, 3, -1],\n [-1, 2, -1],\n [3, 2, -3]])\nb = np.array([\n [-2.19],\n [-2.61],\n [0.25],\n [-1.97],\n [-1.32]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{10}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1]])\nprint(a * -(3/10))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-1,0,-2\\}, \\{-1,1,2\\}, \\{-2,1,-2\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{5}},0,-\\frac{2}{\\sqrt{5}}\\right\\}, \\left\\{-\\frac{8}{\\sqrt{105}},\\sqrt{\\frac{5}{21}},\\frac{4}{\\sqrt{105}}\\right\\}, \\left\\{\\frac{2}{\\sqrt{21}},\\frac{4}{\\sqrt{21}},-\\frac{1}{\\sqrt{21}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, 0, -2), (-1, 1, 2), (-2, 1, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{3} \\\\\n -\\frac{5}{3} \\\\\n -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\sqrt{\\frac{2}{39}} \\\\\n -\\frac{5}{\\sqrt{78}} \\\\\n -\\frac{7}{\\sqrt{78}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3)],\n [-(5/3)],\n [-(7/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{11}{8} \\\\\n \\frac{13}{8} \\\\\n \\frac{5}{2} \\\\\n -2 \\\\\n -\\frac{7}{8} \\\\\n \\frac{13}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{11}{2 \\sqrt{291}} \\\\\n \\frac{13}{2 \\sqrt{291}} \\\\\n \\frac{10}{\\sqrt{291}} \\\\\n -\\frac{8}{\\sqrt{291}} \\\\\n -\\frac{7}{2 \\sqrt{291}} \\\\\n \\frac{13}{2 \\sqrt{291}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/8)],\n [(13/8)],\n [(5/2)],\n [-2],\n [-(7/8)],\n [(13/8)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{10}{7}, 5}$ to the line $\\frac{4 x}{7}+\\frac{4 y}{7}-\\frac{34}{7}=0$.", - "Output Answer": [ - "$\\frac{29}{14 \\sqrt{2}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (10/7), 5\nline = Poly(((4*x)/7)+((4*y)/7)-(34/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{14}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{23}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3]])\nb = np.array([\n [(14/3)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{29}{5} & -\\frac{11}{5} \\\\\n -\\frac{7}{5} & \\frac{29}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{7} \\left(29-3 \\sqrt{102}\\right),1\\right\\}, \\left\\{\\frac{1}{7} \\left(29+3 \\sqrt{102}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/5), -(11/5)],\n [-(7/5), (29/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,5,1\\}, \\{2,2,-1\\}, \\{-4,-2,4\\}}$.", - "Output Answer": [ - "$23 x+8 y+34 z-28=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, 5, 1],\n [2, 2, -1],\n [-4, -2, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -2 & -2 & 9 & 0 & -5 & 4 \\\\\n -6 & 1 & 9 & -4 & -10 & -3 \\\\\n 7 & -7 & -10 & 8 & -7 & -10 \\\\\n 9 & -2 & -4 & -9 & -1 & -1 \\\\\n 6 & 4 & 10 & -8 & 6 & -4 \\\\\n 8 & -3 & -1 & 8 & 10 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, -2, 9, 0, -5, 4],\n [-6, 1, 9, -4, -10, -3],\n [7, -7, -10, 8, -7, -10],\n [9, -2, -4, -9, -1, -1],\n [6, 4, 10, -8, 6, -4],\n [8, -3, -1, 8, 10, -10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${4, -\\frac{1}{3}, 0}$ to the plane $-\\frac{7 x}{3}+\\frac{2 y}{3}-z+\\frac{4}{3}=0$.", - "Output Answer": [ - "$\\frac{37 \\sqrt{\\frac{2}{31}}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 4, -(1/3), 0\nplane = Poly(-((7*x)/3)+((2*y)/3)-z+(4/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 9 \\\\\n 1 \\\\\n 9 \\\\\n -2 \\\\\n -7 \\\\\n 5 \\\\\n -8 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -2 \\\\\n -9 \\\\\n 6 \\\\\n 2 \\\\\n -1 \\\\\n -4 \\\\\n 5 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{593}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [9],\n [1],\n [9],\n [-2],\n [-7],\n [5],\n [-8],\n [1]])\nb = np.array([\n [4],\n [-2],\n [-9],\n [6],\n [2],\n [-1],\n [-4],\n [5],\n [-5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 0 & -3 \\\\\n 3 & -3 & 2 \\\\\n 2 & 2 & -3 \\\\\n -2 & 3 & 2 \\\\\n 3 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.43 \\\\\n 2.24 \\\\\n 0.74 \\\\\n -1.14 \\\\\n -1.18 \\\\\n -2.94 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.08 \\\\\n -0.491 \\\\\n -0.348 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, -3],\n [3, -3, 2],\n [2, 2, -3],\n [-2, 3, 2],\n [3, 1, 0],\n [0, 0, 1]])\nb = np.array([\n [1.43],\n [2.24],\n [0.74],\n [-1.14],\n [-1.18],\n [-2.94]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -3 & \\frac{22}{3} & \\frac{4}{3} \\\\\n -4 & -1 & -5 \\\\\n \\frac{22}{3} & \\frac{13}{3} & 8 \\\\\n -\\frac{8}{3} & \\frac{28}{3} & -\\frac{28}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{14}{3} & -\\frac{19}{3} & -\\frac{20}{3} \\\\\n -3 & 7 & -\\frac{17}{3} \\\\\n \\frac{10}{3} & 0 & \\frac{7}{3} \\\\\n 8 & \\frac{25}{3} & \\frac{29}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{5}{3} & 1 & -\\frac{16}{3} \\\\\n -7 & 6 & -\\frac{32}{3} \\\\\n \\frac{32}{3} & \\frac{13}{3} & \\frac{31}{3} \\\\\n \\frac{16}{3} & \\frac{53}{3} & \\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, (22/3), (4/3)],\n [-4, -1, -5],\n [(22/3), (13/3), 8],\n [-(8/3), (28/3), -(28/3)]])\nb = np.array([\n [(14/3), -(19/3), -(20/3)],\n [-3, 7, -(17/3)],\n [(10/3), 0, (7/3)],\n [8, (25/3), (29/3)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{8} & -\\frac{27}{16} & -\\frac{23}{16} \\\\\n \\frac{27}{8} & \\frac{57}{16} & \\frac{3}{8} \\\\\n \\frac{5}{8} & \\frac{5}{2} & \\frac{35}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{2000}{3379} & \\frac{1552}{10137} & \\frac{3064}{16895} \\\\\n -\\frac{64}{109} & \\frac{16}{109} & -\\frac{112}{545} \\\\\n \\frac{848}{3379} & -\\frac{1072}{10137} & \\frac{5408}{16895} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/8), -(27/16), -(23/16)],\n [(27/8), (57/16), (3/8)],\n [(5/8), (5/2), (35/8)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 9 \\\\\n -3 \\\\\n -7 \\\\\n -4 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 5 \\\\\n -1 \\\\\n 8 \\\\\n -10 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-34$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [9],\n [-3],\n [-7],\n [-4],\n [9]])\nb = np.array([\n [6],\n [5],\n [-1],\n [8],\n [-10],\n [-6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -2 \\\\\n -7 \\\\\n 8 \\\\\n 9 \\\\\n 7 \\\\\n 3 \\\\\n 6 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -4 \\\\\n -8 \\\\\n -4 \\\\\n 7 \\\\\n 7 \\\\\n 3 \\\\\n -4 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{613}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-2],\n [-7],\n [8],\n [9],\n [7],\n [3],\n [6],\n [-1]])\nb = np.array([\n [-9],\n [-4],\n [-8],\n [-4],\n [7],\n [7],\n [3],\n [-4],\n [5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & 0 & 4 \\\\\n -2 & -2 & -3 \\\\\n 1 & 1 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-13$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, 4],\n [-2, -2, -3],\n [1, 1, -5]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -3 & -4 \\\\\n -4 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{13} & -\\frac{4}{13} \\\\\n -\\frac{4}{13} & \\frac{3}{13} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -4],\n [-4, -1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -5+3 i & -\\frac{7}{2}+5 i & -5-\\frac{9 i}{2} \\\\\n -\\frac{1}{2}-i & \\frac{1}{2}-4 i & \\frac{3}{2}-2 i \\\\\n -\\frac{3}{2}+3 i & \\frac{3}{2}-\\frac{3 i}{2} & -\\frac{1}{2}+\\frac{3 i}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{515}{2}+\\frac{905 i}{2} & \\frac{269}{4}+\\frac{2083 i}{8} & -\\frac{929}{2}+\\frac{155 i}{8} \\\\\n -\\frac{527}{8}-\\frac{479 i}{8} & -\\frac{985}{8}+\\frac{255 i}{8} & -\\frac{13}{8}-\\frac{721 i}{8} \\\\\n \\frac{897}{8}+\\frac{1593 i}{8} & \\frac{459}{8}+\\frac{159 i}{4} & -\\frac{967}{8}+183 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5+3j, -(7/2)+5j, -5-((9j)/2)],\n [-(1/2)- 1j, (1/2)-4j, (3/2)-2j],\n [-(3/2)+3j, (3/2)-((3j)/2), -(1/2)+((3j)/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & 8 & -5 \\\\\n -4 & 4 & -2 \\\\\n 4 & 7 & -7 \\\\\n -4 & 1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [8, 8, -5],\n [-4, 4, -2],\n [4, 7, -7],\n [-4, 1, 4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & 2 & 1 \\\\\n 2 & 2 & 4 \\\\\n 0 & 4 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & 0 & -\\frac{1}{4} \\\\\n \\frac{1}{6} & -\\frac{1}{6} & \\frac{1}{4} \\\\\n -\\frac{1}{3} & \\frac{1}{3} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, 1],\n [2, 2, 4],\n [0, 4, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -2 \\\\\n 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -17 \\\\\n 45 \\\\\n 25 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-3],\n [2]])\nb = np.array([\n [5],\n [-2],\n [7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,0,-2\\}, \\{0,-1,1\\}, \\{1,-1,2\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{2}},0,-\\frac{1}{\\sqrt{2}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{6}},-\\sqrt{\\frac{2}{3}},\\frac{1}{\\sqrt{6}}\\right\\}, \\{0,0,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, 0, -2), (0, -1, 1), (1, -1, 2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 1 & 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 1 & -1 \\\\\n 2 & 2 & -2 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [2],\n [0]])\nb = np.array([\n [1, 1, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{11}{4} & 5 \\\\\n -\\frac{13}{4} & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{28}{207} & -\\frac{40}{207} \\\\\n \\frac{26}{207} & -\\frac{22}{207} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/4), 5],\n [-(13/4), -(7/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{8} \\\\\n \\frac{3}{4} \\\\\n -\\frac{3}{8} \\\\\n -\\frac{45}{16} \\\\\n \\frac{11}{8} \\\\\n \\frac{13}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{6}{\\sqrt{3401}} \\\\\n \\frac{12}{\\sqrt{3401}} \\\\\n -\\frac{6}{\\sqrt{3401}} \\\\\n -\\frac{45}{\\sqrt{3401}} \\\\\n \\frac{22}{\\sqrt{3401}} \\\\\n \\frac{26}{\\sqrt{3401}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/8)],\n [(3/4)],\n [-(3/8)],\n [-(45/16)],\n [(11/8)],\n [(13/8)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -6 \\\\\n 1 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -6 \\\\\n 2 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 8 \\\\\n -12 \\\\\n 3 \\\\\n 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-6],\n [1],\n [9]])\nb = np.array([\n [8],\n [-6],\n [2],\n [-4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 3 & 1 & 2 & -1 & 3 \\\\\n -1 & -1 & 1 & -3 & -1 \\\\\n 1 & 2 & -2 & 0 & 3 \\\\\n -2 & 0 & 1 & -3 & -3 \\\\\n 3 & -2 & -3 & 3 & -1 \\\\\n 3 & 2 & 2 & -1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.45 \\\\\n -2.74 \\\\\n 0. \\\\\n -1.19 \\\\\n -2.62 \\\\\n 0.24 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.618 \\\\\n 0.902 \\\\\n 0.649 \\\\\n 1.007 \\\\\n 0.033 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1, 2, -1, 3],\n [-1, -1, 1, -3, -1],\n [1, 2, -2, 0, 3],\n [-2, 0, 1, -3, -3],\n [3, -2, -3, 3, -1],\n [3, 2, 2, -1, 3]])\nb = np.array([\n [-0.45],\n [-2.74],\n [0.],\n [-1.19],\n [-2.62],\n [0.24]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{12}{7}, -3}$ to the line $-\\frac{30 x}{7}-4 y+\\frac{20}{7}=0$.", - "Output Answer": [ - "$\\frac{184}{7 \\sqrt{421}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (12/7), -3\nline = Poly(-((30*x)/7)-4*y+(20/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 0 & -1 & -3 & -1 & 0 \\\\\n -2 & -3 & -2 & -3 & 3 \\\\\n 0 & -2 & -2 & 1 & 3 \\\\\n -1 & 0 & -3 & -2 & 2 \\\\\n 3 & 3 & -2 & -3 & 1 \\\\\n 2 & -3 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.67 \\\\\n -2.61 \\\\\n 0.42 \\\\\n -1.82 \\\\\n -0.63 \\\\\n 1.45 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.586 \\\\\n -0.395 \\\\\n -0.576 \\\\\n 0.57 \\\\\n -0.736 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -1, -3, -1, 0],\n [-2, -3, -2, -3, 3],\n [0, -2, -2, 1, 3],\n [-1, 0, -3, -2, 2],\n [3, 3, -2, -3, 1],\n [2, -3, 0, 0, 1]])\nb = np.array([\n [1.67],\n [-2.61],\n [0.42],\n [-1.82],\n [-0.63],\n [1.45]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 10 \\\\\n 4 \\\\\n 8 \\\\\n 4 \\\\\n -9 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$49$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [10],\n [4],\n [8],\n [4],\n [-9],\n [6]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{67}{9} & -5 \\\\\n \\frac{13}{9} & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{112 x}{9}+\\frac{400}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(67/9), -5],\n [(13/9), -5]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{33}{5} \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{13}{5} \\\\\n -\\frac{19}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{2237}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(33/5)],\n [-6]])\nb = np.array([\n [(13/5)],\n [-(19/5)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -7 \\\\\n 5 \\\\\n 7 \\\\\n -1 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{222}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-7],\n [5],\n [7],\n [-1],\n [7]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & -6 & 3 \\\\\n -2 & 9 & -4 \\\\\n 3 & 4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-2.904,0.286,9.617\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -6, 3],\n [-2, 9, -4],\n [3, 4, -3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -1 & -3 & -3 & 1 & 0 \\\\\n 3 & 0 & 1 & 0 & 2 \\\\\n 0 & 1 & 1 & 2 & 1 \\\\\n -1 & 3 & 0 & 0 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 2 \\\\\n 2 \\\\\n 3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -8 \\\\\n 1 \\\\\n 11 \\\\\n 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -3, -3, 1, 0],\n [3, 0, 1, 0, 2],\n [0, 1, 1, 2, 1],\n [-1, 3, 0, 0, -1]])\nb = np.array([\n [-1],\n [2],\n [2],\n [3],\n [1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{101}{32}, \\frac{153}{32}}$ to the line $-\\frac{95 x}{32}-\\frac{77 y}{32}-\\frac{9}{2}=0$.", - "Output Answer": [ - "$406 \\sqrt{\\frac{2}{7477}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (101/32), (153/32)\nline = Poly(-((95*x)/32)-((77*y)/32)-(9/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & 2 & -2 \\\\\n 3 & -2 & -5 \\\\\n -3 & -4 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-18$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2, -2],\n [3, -2, -5],\n [-3, -4, 2]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{67}{9} \\\\\n -\\frac{59}{9} \\\\\n -\\frac{16}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{62}{9} \\\\\n -\\frac{71}{9} \\\\\n -\\frac{16}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{64}{9} \\\\\n -\\frac{80}{27} \\\\\n \\frac{1099}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(67/9)],\n [-(59/9)],\n [-(16/3)]])\nb = np.array([\n [-(62/9)],\n [-(71/9)],\n [-(16/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 10 & -1 & -9 \\\\\n -4 & \\frac{13}{2} & -2 \\\\\n -3 & \\frac{7}{2} & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{3.114\\, -2.901 i,3.114\\, +2.901 i,14.272\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -1, -9],\n [-4, (13/2), -2],\n [-3, (7/2), 4]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{ccc}\n 5 & 8 & 21 \\\\\n -6 & -8 & -22 \\\\\n 1 & 1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 5 & \\frac{13}{2} & 17 \\\\\n -8 & -10 & -30 \\\\\n 2 & \\frac{5}{2} & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [5, 8, 21],\n [-6, -8, -22],\n [1, 1, 3]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -\\frac{6}{5} & -\\frac{26}{5} \\\\\n -\\frac{34}{5} & -\\frac{34}{5} \\\\\n -\\frac{6}{5} & \\frac{27}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(6/5), -(26/5)],\n [-(34/5), -(34/5)],\n [-(6/5), (27/5)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{32}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & 9 & 1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 0 & -\\frac{63}{32} & -\\frac{7}{32} & -\\frac{7}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 9, 1, 1]])\nprint(a * -(7/32))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 2 & -3 & 0 & 3 & -2 \\\\\n -2 & -1 & 1 & 2 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 0 & 1 \\\\\n -3 & 3 \\\\\n -1 & 1 \\\\\n -1 & -1 \\\\\n 2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 2 & -12 \\\\\n -2 & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3, 0, 3, -2],\n [-2, -1, 1, 2, -1]])\nb = np.array([\n [0, 1],\n [-3, 3],\n [-1, 1],\n [-1, -1],\n [2, 1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n \\frac{1}{8} \\\\\n -\\frac{33}{16} \\\\\n -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{16} & -\\frac{19}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{7}{128} & -\\frac{19}{128} \\\\\n -\\frac{231}{256} & \\frac{627}{256} \\\\\n -\\frac{7}{64} & \\frac{19}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/8)],\n [-(33/16)],\n [-(1/4)]])\nb = np.array([\n [(7/16), -(19/16)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 3 \\\\\n -1 \\\\\n 8 \\\\\n 5 \\\\\n -9 \\\\\n -7 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [3],\n [-1],\n [8],\n [5],\n [-9],\n [-7],\n [-3]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 0 & 2 \\\\\n 1 & -1 \\\\\n 1 & -3 \\\\\n 1 & 3 \\\\\n -3 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 4 \\\\\n 0 \\\\\n -4 \\\\\n 8 \\\\\n -10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2],\n [1, -1],\n [1, -3],\n [1, 3],\n [-3, -2]])\nb = np.array([\n [2],\n [2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{11}{16}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{11}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [2]])\nprint(a * -(11/16))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-1, \\frac{5}{7}}$ to the line $-\\frac{34 x}{7}-\\frac{24 y}{7}+\\frac{22}{7}=0$.", - "Output Answer": [ - "$\\frac{136}{7 \\sqrt{433}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -1, (5/7)\nline = Poly(-((34*x)/7)-((24*y)/7)+(22/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,-2,4\\}, \\{3,-4,-5\\}, \\{4,-1,-3\\}}$.", - "Output Answer": [ - "$x-y+z-2=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, -2, 4],\n [3, -4, -5],\n [4, -1, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -5 \\\\\n -8 \\\\\n 8 \\\\\n 10 \\\\\n -7 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -9 \\\\\n 1 \\\\\n 7 \\\\\n 1 \\\\\n -2 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$93$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-5],\n [-8],\n [8],\n [10],\n [-7],\n [3]])\nb = np.array([\n [-1],\n [-9],\n [1],\n [7],\n [1],\n [-2],\n [-6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 0 \\\\\n -1 \\\\\n 7 \\\\\n 1 \\\\\n 10 \\\\\n -8 \\\\\n -10 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -7 \\\\\n 3 \\\\\n -3 \\\\\n -2 \\\\\n -7 \\\\\n -2 \\\\\n -1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{870}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [0],\n [-1],\n [7],\n [1],\n [10],\n [-8],\n [-10],\n [-1]])\nb = np.array([\n [7],\n [-7],\n [3],\n [-3],\n [-2],\n [-7],\n [-2],\n [-1],\n [-2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${2, \\frac{12}{5}, -\\frac{17}{5}}$ to the plane $\\frac{12 x}{5}-\\frac{16 y}{5}-\\frac{8 z}{5}+\\frac{16}{5}=0$.", - "Output Answer": [ - "$\\frac{36}{5 \\sqrt{29}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 2, (12/5), -(17/5)\nplane = Poly(((12*x)/5)-((16*y)/5)-((8*z)/5)+(16/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & 3 \\\\\n 1 & 0 \\\\\n -1 & 3 \\\\\n -1 & 2 \\\\\n 3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.9 \\\\\n -0.52 \\\\\n -2.8 \\\\\n 2.7 \\\\\n -2.12 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.109 \\\\\n 0.246 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 3],\n [1, 0],\n [-1, 3],\n [-1, 2],\n [3, -2]])\nb = np.array([\n [1.9],\n [-0.52],\n [-2.8],\n [2.7],\n [-2.12]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{2} \\\\\n \\frac{13}{2} \\\\\n \\frac{3}{2} \\\\\n -\\frac{7}{2} \\\\\n -\\frac{9}{2} \\\\\n 9 \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n 2 \\\\\n -\\frac{19}{2} \\\\\n -\\frac{17}{2} \\\\\n -5 \\\\\n -6 \\\\\n -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-11$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2)],\n [(13/2)],\n [(3/2)],\n [-(7/2)],\n [-(9/2)],\n [9],\n [(3/2)]])\nb = np.array([\n [(1/2)],\n [2],\n [-(19/2)],\n [-(17/2)],\n [-5],\n [-6],\n [-(13/2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-5,2,4\\}, \\{-2,0,1\\}, \\{5,-4,4\\}}$.", - "Output Answer": [ - "$9 x+15 y-z+19=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-5, 2, 4],\n [-2, 0, 1],\n [5, -4, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & 9 \\\\\n 7 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{3}{2} \\left(1-\\sqrt{53}\\right),\\frac{3}{2} \\left(1+\\sqrt{53}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 9],\n [7, -6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,1,5\\}, \\{4,1,-4\\}, \\{2,-3,4\\}}$.", - "Output Answer": [ - "$6 x+y+2 z-17=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, 1, 5],\n [4, 1, -4],\n [2, -3, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & -1 \\\\\n -3 & 3 \\\\\n 0 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.33 \\\\\n -1.26 \\\\\n -1.66 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.513 \\\\\n -0.122 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1],\n [-3, 3],\n [0, 3]])\nb = np.array([\n [-2.33],\n [-1.26],\n [-1.66]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 9 & -3 \\\\\n 0 & 0 \\\\\n -3 & 1 \\\\\n 3 & -1 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [0],\n [-1],\n [1],\n [0]])\nb = np.array([\n [3, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 2 & -3 \\\\\n 4 & -4 & 4 \\\\\n 1 & 4 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-132$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, -3],\n [4, -4, 4],\n [1, 4, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & 2 & -9 \\\\\n -5 & -9 & -5 \\\\\n -1 & -7 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-13.763,3.609,5.153\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 2, -9],\n [-5, -9, -5],\n [-1, -7, -4]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & 0 \\\\\n -8 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+2 x-8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 0],\n [-8, 2]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,-2,-1\\}, \\{1,-5,2\\}, \\{-3,-3,0\\}}$.", - "Output Answer": [ - "$y+z+3=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -2, -1],\n [1, -5, 2],\n [-3, -3, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & -1 & 2 \\\\\n -3 & -\\frac{1}{2} & -1 \\\\\n 3 & \\frac{3}{2} & 1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 10 & \\frac{9}{2} & 1 \\\\\n \\frac{3}{2} & \\frac{7}{4} & -\\frac{13}{2} \\\\\n -\\frac{9}{2} & -\\frac{9}{4} & \\frac{11}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, 2],\n [-3, -(1/2), -1],\n [3, (3/2), 1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -1 & 1 \\\\\n -10 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1-3 i,10\\}, \\{-1+3 i,10\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1],\n [-10, -3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{ccc}\n -6 & 39 & 9 \\\\\n -2 & 12 & 3 \\\\\n 4 & -22 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -8 & 57 & \\frac{27}{2} \\\\\n -2 & 13 & 3 \\\\\n 2 & -10 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [-6, 39, 9],\n [-2, 12, 3],\n [4, -22, -6]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,-2,1\\}, \\{-1,-4,0\\}, \\{3,-5,5\\}}$.", - "Output Answer": [ - "$11 x+4 y-8 z+27=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, -2, 1],\n [-1, -4, 0],\n [3, -5, 5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(\\sqrt{35}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [1],\n [1],\n [-1],\n [0],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [-1],\n [1],\n [-1],\n [-1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 10 & -3 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 7 & 0 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 17 & -3 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -3, 8]])\nb = np.array([\n [7, 0, -1]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 9 & 8 & -9 & -10 \\\\\n 2 & -4 & 5 & -2 \\\\\n 0 & 3 & -4 & 10 \\\\\n 2 & 6 & 9 & -4 \\\\\n 6 & -10 & 3 & -7 \\\\\n -4 & -4 & 8 & 2 \\\\\n 8 & 7 & 5 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, 8, -9, -10],\n [2, -4, 5, -2],\n [0, 3, -4, 10],\n [2, 6, 9, -4],\n [6, -10, 3, -7],\n [-4, -4, 8, 2],\n [8, 7, 5, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{42}{5} \\\\\n \\frac{43}{5} \\\\\n 5 \\\\\n -\\frac{2}{5} \\\\\n -\\frac{3}{5} \\\\\n -\\frac{1}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{38}{5} \\\\\n -\\frac{26}{5} \\\\\n -\\frac{27}{5} \\\\\n 4 \\\\\n \\frac{34}{5} \\\\\n -\\frac{38}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{301}{2 \\sqrt{6217487}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(42/5)],\n [(43/5)],\n [5],\n [-(2/5)],\n [-(3/5)],\n [-(1/5)]]).squeeze()\nb = np.array([\n [(38/5)],\n [-(26/5)],\n [-(27/5)],\n [4],\n [(34/5)],\n [-(38/5)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 2 \\\\\n -2 \\\\\n 0 \\\\\n 9 \\\\\n 3 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 7 \\\\\n 4 \\\\\n 8 \\\\\n 2 \\\\\n -7 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [2],\n [-2],\n [0],\n [9],\n [3],\n [8]])\nb = np.array([\n [1],\n [7],\n [4],\n [8],\n [2],\n [-7],\n [1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{35}{4} \\\\\n \\frac{5}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{5 \\sqrt{197}}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(35/4)],\n [(5/8)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{28}{9} & -\\frac{14}{3} & -\\frac{52}{9} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{29}{3} & -\\frac{16}{3} & -\\frac{83}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{115}{9} & \\frac{2}{3} & \\frac{31}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(28/9), -(14/3), -(52/9)]])\nb = np.array([\n [(29/3), -(16/3), -(83/9)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,2,-2\\}, \\{-1,-2,-2\\}, \\{1,1,-2\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{3}},\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}}\\right\\}, \\left\\{-\\sqrt{\\frac{2}{39}},-\\frac{5}{\\sqrt{78}},-\\frac{7}{\\sqrt{78}}\\right\\}, \\left\\{-2 \\sqrt{\\frac{2}{13}},\\frac{3}{\\sqrt{26}},-\\frac{1}{\\sqrt{26}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, 2, -2), (-1, -2, -2), (1, 1, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{9}{7}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -6 & -1 \\\\\n 6 & -6 \\\\\n 6 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{54}{7} & -\\frac{9}{7} \\\\\n \\frac{54}{7} & -\\frac{54}{7} \\\\\n \\frac{54}{7} & -\\frac{9}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -1],\n [6, -6],\n [6, -1]])\nprint(a * (9/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -5 \\\\\n 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -20 \\\\\n 54 \\\\\n 21 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-3],\n [2]])\nb = np.array([\n [-3],\n [-5],\n [10]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{32}{5} & -\\frac{38}{5} & -\\frac{14}{5} & -\\frac{27}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{14}{5} & \\frac{37}{10} & \\frac{19}{5} & \\frac{3}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{46}{5} & -\\frac{39}{10} & 1 & -\\frac{21}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(32/5), -(38/5), -(14/5), -(27/10)]])\nb = np.array([\n [(14/5), (37/10), (19/5), (3/5)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & -2 \\\\\n 2 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} \\left(11-\\sqrt{105}\\right),1\\right\\}, \\left\\{\\frac{1}{4} \\left(11+\\sqrt{105}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2],\n [2, -8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1}{\\sqrt{3}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [-1],\n [1],\n [-1],\n [-1],\n [0],\n [1]]).squeeze()\nb = np.array([\n [1],\n [-1],\n [1],\n [-1],\n [-1],\n [1],\n [-1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{7}{10}, \\frac{8}{5}}$ to the line $\\frac{49 x}{10}+3 y+\\frac{22}{5}=0$.", - "Output Answer": [ - "$\\frac{1263}{10 \\sqrt{3301}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (7/10), (8/5)\nline = Poly(((49*x)/10)+3*y+(22/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -2 \\\\\n -9 \\\\\n -2 \\\\\n 7 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-2],\n [-9],\n [-2],\n [7],\n [-3]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -9 & 6 \\\\\n 10 & -4 \\\\\n -4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, 6],\n [10, -4],\n [-4, 0]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -10 & 1 & -10 \\\\\n 4 & -10 & 8 \\\\\n 8 & -3 & -10 \\\\\n -7 & -6 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, 1, -10],\n [4, -10, 8],\n [8, -3, -10],\n [-7, -6, -1]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{11}{3} & \\frac{4}{3} \\\\\n -\\frac{13}{3} & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{9}{19} & -\\frac{12}{19} \\\\\n \\frac{39}{19} & -\\frac{33}{19} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/3), (4/3)],\n [-(13/3), 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{26}{3} & -\\frac{29}{3} \\\\\n -\\frac{28}{3} & -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(5-3 \\sqrt{57}\\right),\\frac{1}{2} \\left(5+3 \\sqrt{57}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/3), -(29/3)],\n [-(28/3), -(11/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{13}{4} & -\\frac{3}{4} \\\\\n \\frac{9}{4} & -\\frac{15}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{10}{37} & \\frac{2}{37} \\\\\n -\\frac{6}{37} & -\\frac{26}{111} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/4), -(3/4)],\n [(9/4), -(15/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{15}{2} & \\frac{29}{6} \\\\\n 6 & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+3 x-\\frac{251}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/2), (29/6)],\n [6, (9/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 9 & 5 & 2 & -6 \\\\\n 2 & -4 & 9 & 3 \\\\\n 10 & 0 & 5 & -8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -8 & -2 & -6 & 7 \\\\\n 1 & 5 & -2 & 1 \\\\\n -8 & -5 & 9 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 17 & 7 & 8 & -13 \\\\\n 1 & -9 & 11 & 2 \\\\\n 18 & 5 & -4 & -10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 5, 2, -6],\n [2, -4, 9, 3],\n [10, 0, 5, -8]])\nb = np.array([\n [-8, -2, -6, 7],\n [1, 5, -2, 1],\n [-8, -5, 9, 2]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 0 \\\\\n 2 \\\\\n -3 \\\\\n 4 \\\\\n -10 \\\\\n 3 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$28$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [0],\n [2],\n [-3],\n [4],\n [-10],\n [3],\n [3]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{8}{3} & \\frac{23}{3} & -8 \\\\\n 3 & \\frac{7}{3} & -10 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{23}{3} & 0 & \\frac{1}{3} \\\\\n \\frac{11}{3} & 8 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{31}{3} & \\frac{23}{3} & -\\frac{25}{3} \\\\\n -\\frac{2}{3} & -\\frac{17}{3} & -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/3), (23/3), -8],\n [3, (7/3), -10]])\nb = np.array([\n [(23/3), 0, (1/3)],\n [(11/3), 8, 2]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & 1 & 0 \\\\\n -5 & 3 & 8 \\\\\n -7 & 0 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-7.364,5.182\\, -2.338 i,5.182\\, +2.338 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 1, 0],\n [-5, 3, 8],\n [-7, 0, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 10 & \\frac{13}{3} \\\\\n -5 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{15} \\left(-30-\\sqrt{705}\\right),1\\right\\}, \\left\\{\\frac{1}{15} \\left(\\sqrt{705}-30\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, (13/3)],\n [-5, -10]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 1 & 1 & 1 & -1 & -2 \\\\\n 2 & 1 & 1 & 2 & 1 \\\\\n -3 & 1 & 2 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -3 \\\\\n -2 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -6 \\\\\n -7 \\\\\n -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1, 1, -1, -2],\n [2, 1, 1, 2, 1],\n [-3, 1, 2, -1, 2]])\nb = np.array([\n [-1],\n [-3],\n [-2],\n [0],\n [0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{37}{4} \\\\\n -\\frac{35}{4} \\\\\n \\frac{9}{4} \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{4} \\\\\n -\\frac{15}{2} \\\\\n 8 \\\\\n \\frac{19}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{257 \\sqrt{\\frac{5}{206322}}}{3}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(37/4)],\n [-(35/4)],\n [(9/4)],\n [-8]]).squeeze()\nb = np.array([\n [-(15/4)],\n [-(15/2)],\n [8],\n [(19/4)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & \\frac{11}{2} & 1 \\\\\n \\frac{7}{2} & 7 & -8 \\\\\n -\\frac{19}{2} & -7 & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.367,-1.153,1.\\}, \\{0.219\\, -0.931 i,0.492\\, +0.61 i,1.\\}, \\{0.219\\, +0.931 i,0.492\\, -0.61 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), (11/2), 1],\n [(7/2), 7, -8],\n [-(19/2), -7, (7/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -1 & 4 & -7 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 4, -7, 0]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n \\frac{26}{3} & 4 & -\\frac{25}{3} & -\\frac{16}{3} \\\\\n \\frac{29}{3} & \\frac{16}{3} & 4 & \\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/3), 4, -(25/3), -(16/3)],\n [(29/3), (16/3), 4, (7/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{15}{8}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -5 \\\\\n 4 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{45}{8} \\\\\n \\frac{75}{8} \\\\\n -\\frac{15}{2} \\\\\n -\\frac{45}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-5],\n [4],\n [6]])\nprint(a * -(15/8))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 7 & -6 & -5 & 3 & 8 & 0 & -8 \\\\\n -9 & 3 & 8 & 8 & -2 & -9 & 2 \\\\\n -2 & 2 & 2 & -4 & 7 & -3 & -5 \\\\\n -1 & -4 & -5 & -9 & -4 & 3 & 5 \\\\\n 9 & -10 & -2 & -5 & -5 & -3 & -3 \\\\\n 5 & 7 & 4 & 8 & 1 & 6 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & -\\frac{6988}{7231} \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & -\\frac{8077}{7231} \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & \\frac{8112}{7231} \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & \\frac{458}{7231} \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & -\\frac{2276}{7231} \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & \\frac{32437}{21693} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, -6, -5, 3, 8, 0, -8],\n [-9, 3, 8, 8, -2, -9, 2],\n [-2, 2, 2, -4, 7, -3, -5],\n [-1, -4, -5, -9, -4, 3, 5],\n [9, -10, -2, -5, -5, -3, -3],\n [5, 7, 4, 8, 1, 6, 1]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [2]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{14}{3} \\\\\n \\frac{41}{6} \\\\\n -\\frac{47}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{1}{6} \\\\\n \\frac{5}{2} \\\\\n \\frac{29}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3083}{36} \\\\\n -\\frac{557}{12} \\\\\n \\frac{379}{36} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/3)],\n [(41/6)],\n [-(47/6)]])\nb = np.array([\n [(1/6)],\n [(5/2)],\n [(29/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5.702 \\\\\n -1.403 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3.63 \\\\\n -0.967 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2.11738$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5.702],\n [-1.403]])\nb = np.array([\n [3.63],\n [-0.967]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & -9 & -7 \\\\\n 5 & 9 & -1 \\\\\n -7 & 9 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.602,-0.185,1.\\}, \\{-1.19-0.127 i,-0.155-0.91 i,1.\\}, \\{-1.19+0.127 i,-0.155+0.91 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -9, -7],\n [5, 9, -1],\n [-7, 9, 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{18}{5} & \\frac{3}{5} \\\\\n -\\frac{16}{5} & \\frac{18}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{2 \\sqrt{69}}{5},\\frac{2 \\sqrt{69}}{5}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(18/5), (3/5)],\n [-(16/5), (18/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3.102 \\\\\n 9.751 \\\\\n -9.106 \\\\\n 5.208 \\\\\n 7.478 \\\\\n -4.919 \\\\\n 2.822 \\\\\n 2.183 \\\\\n 1.856 \\\\\n -1.502 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9.992 \\\\\n 0.875 \\\\\n 0.792 \\\\\n -0.406 \\\\\n -8.972 \\\\\n 7.824 \\\\\n 3.726 \\\\\n -6.955 \\\\\n 2.663 \\\\\n 5.898 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$28.783$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3.102],\n [9.751],\n [-9.106],\n [5.208],\n [7.478],\n [-4.919],\n [2.822],\n [2.183],\n [1.856],\n [-1.502]])\nb = np.array([\n [9.992],\n [0.875],\n [0.792],\n [-0.406],\n [-8.972],\n [7.824],\n [3.726],\n [-6.955],\n [2.663],\n [5.898]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -1 \\\\\n -9 \\\\\n -1 \\\\\n -5 \\\\\n -10 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -9 \\\\\n 1 \\\\\n 7 \\\\\n -2 \\\\\n 4 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{651}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-1],\n [-9],\n [-1],\n [-5],\n [-10],\n [-3]])\nb = np.array([\n [7],\n [-9],\n [1],\n [7],\n [-2],\n [4],\n [4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n \\frac{28}{5} & \\frac{24}{5} & \\frac{24}{5} \\\\\n -8 & \\frac{49}{5} & -\\frac{14}{5} \\\\\n -\\frac{22}{5} & \\frac{17}{5} & -\\frac{17}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(28/5), (24/5), (24/5)],\n [-8, (49/5), -(14/5)],\n [-(22/5), (17/5), -(17/5)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{13}{3},5,\\frac{13}{3}\\right\\}, \\left\\{\\frac{14}{3},-\\frac{7}{3},\\frac{11}{3}\\right\\}, \\left\\{-1,1,-\\frac{10}{3}\\right\\}}$.", - "Output Answer": [ - "$1446 x+165 y-1092 z-2359=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(13/3), 5, (13/3)],\n [(14/3), -(7/3), (11/3)],\n [-1, 1, -(10/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -4 \\\\\n -4 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -3 \\\\\n 2 \\\\\n -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 4 \\\\\n -7 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-4],\n [-4],\n [5]])\nb = np.array([\n [8],\n [-3],\n [2],\n [-3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{141}{20} & \\frac{1}{2} \\\\\n -\\frac{127}{20} & -\\frac{242}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{263 x}{100}-\\frac{65069}{1000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(141/20), (1/2)],\n [-(127/20), -(242/25)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -1 \\\\\n -8 \\\\\n -6 \\\\\n -8 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -9 \\\\\n -7 \\\\\n 0 \\\\\n -1 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$183$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-1],\n [-8],\n [-6],\n [-8],\n [10]])\nb = np.array([\n [5],\n [-9],\n [-7],\n [0],\n [-1],\n [8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{27}{4} & \\frac{25}{4} & -\\frac{5}{2} & -\\frac{21}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{1}{2} & 0 & \\frac{13}{4} & \\frac{37}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{29}{4} & \\frac{25}{4} & \\frac{3}{4} & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(27/4), (25/4), -(5/2), -(21/4)]])\nb = np.array([\n [-(1/2), 0, (13/4), (37/4)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{479}{50} \\\\\n -\\frac{797}{100} \\\\\n \\frac{931}{100} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{479}{50}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(479/50)],\n [-(797/100)],\n [(931/100)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${0, \\frac{3}{2}}$ to the line $-\\frac{3 x}{2}-\\frac{7 y}{2}-2=0$.", - "Output Answer": [ - "$\\frac{\\sqrt{\\frac{29}{2}}}{2}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 0, (3/2)\nline = Poly(-((3*x)/2)-((7*y)/2)-2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{12}{7}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{72}{7} \\\\\n -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-7]])\nprint(a * (12/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -5 \\\\\n 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [10]])\nb = np.array([\n [0],\n [-4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{43}{5} & \\frac{42}{5} & -\\frac{36}{5} \\\\\n -\\frac{2}{5} & 9 & -\\frac{34}{5} \\\\\n \\frac{13}{5} & 9 & \\frac{11}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-7.613,5.106\\, -7.644 i,5.106\\, +7.644 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(43/5), (42/5), -(36/5)],\n [-(2/5), 9, -(34/5)],\n [(13/5), 9, (11/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{2}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -5 & 8 \\\\\n -2 & 4 \\\\\n 1 & -8 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{15}{2} & -12 \\\\\n 3 & -6 \\\\\n -\\frac{3}{2} & 12 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 8],\n [-2, 4],\n [1, -8],\n [0, 0]])\nprint(a * -(3/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n 2 & -8 \\\\\n 9 & 0 \\\\\n -2 & 8 \\\\\n 4 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -8],\n [9, 0],\n [-2, 8],\n [4, 8]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -5 & 10 & -6 & -7 & -2 \\\\\n 0 & -6 & -5 & 8 & 4 \\\\\n 10 & 2 & -6 & -7 & 6 \\\\\n 2 & 8 & 7 & 7 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2424.,622.,2200.,-742.,5167.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, 10, -6, -7, -2],\n [0, -6, -5, 8, 4],\n [10, 2, -6, -7, 6],\n [2, 8, 7, 7, -2]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n -\\frac{5}{16} \\\\\n \\frac{11}{16} \\\\\n \\frac{7}{4} \\\\\n -\\frac{47}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{24}{\\sqrt{3715}} \\\\\n -\\sqrt{\\frac{5}{743}} \\\\\n \\frac{11}{\\sqrt{3715}} \\\\\n \\frac{28}{\\sqrt{3715}} \\\\\n -\\frac{47}{\\sqrt{3715}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2)],\n [-(5/16)],\n [(11/16)],\n [(7/4)],\n [-(47/16)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $1$ and the matrix\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 4 \\\\\n 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [5]])\nprint(a * 1)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & 6 & 9 \\\\\n 4 & -8 & 3 \\\\\n 9 & 7 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.756,0.06,1.\\}, \\{-0.291,-0.808,1.\\}, \\{1.317,0.4,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 6, 9],\n [4, -8, 3],\n [9, 7, -2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 8 & -6 & -8 & -2 \\\\\n 2 & -8 & -8 & 10 \\\\\n -6 & 0 & 9 & -5 \\\\\n -1 & 5 & 4 & -10 \\\\\n -10 & -9 & -3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, -6, -8, -2],\n [2, -8, -8, 10],\n [-6, 0, 9, -5],\n [-1, 5, 4, -10],\n [-10, -9, -3, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 2 & 3 \\\\\n 3 & -1 & 0 \\\\\n -2 & -3 & 3 \\\\\n -2 & 0 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.68 \\\\\n -1.35 \\\\\n 2.67 \\\\\n 2.66 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.469 \\\\\n 0.354 \\\\\n 0.991 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, 3],\n [3, -1, 0],\n [-2, -3, 3],\n [-2, 0, 1]])\nb = np.array([\n [2.68],\n [-1.35],\n [2.67],\n [2.66]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 1 & 1 & -2 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -2 & 3 & -1 & -2 & -2 \\\\\n 2 & 1 & -1 & 1 & -3 \\\\\n 2 & -2 & 3 & -1 & 0 \\\\\n 2 & 1 & -1 & 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -4 & 8 & -8 & 1 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1, -2, 0]])\nb = np.array([\n [-2, 3, -1, -2, -2],\n [2, 1, -1, 1, -3],\n [2, -2, 3, -1, 0],\n [2, 1, -1, 1, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -3 \\\\\n -1 & 2 \\\\\n 0 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.65 \\\\\n -2.91 \\\\\n -2.77 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.469 \\\\\n -0.284 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3],\n [-1, 2],\n [0, -1]])\nb = np.array([\n [-1.65],\n [-2.91],\n [-2.77]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 6 & 8 & 0 & -7 & 4 & -1 \\\\\n 5 & 8 & 4 & 10 & -4 & 0 \\\\\n 6 & 9 & -9 & -7 & -4 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & -\\frac{313}{24} & \\frac{53}{6} & \\frac{29}{24} \\\\\n 0 & 1 & 0 & \\frac{285}{32} & -\\frac{49}{8} & -\\frac{33}{32} \\\\\n 0 & 0 & 1 & \\frac{95}{96} & \\frac{5}{24} & \\frac{53}{96} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, 8, 0, -7, 4, -1],\n [5, 8, 4, 10, -4, 0],\n [6, 9, -9, -7, -4, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 4 \\\\\n 1 \\\\\n 5 \\\\\n 6 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 10 \\\\\n -3 \\\\\n 8 \\\\\n -4 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{3 \\sqrt{\\frac{2}{715}}}{5}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [4],\n [1],\n [5],\n [6],\n [7]]).squeeze()\nb = np.array([\n [6],\n [10],\n [-3],\n [8],\n [-4],\n [-5]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 3 & -2 \\\\\n 1 & 2 \\\\\n 1 & 1 \\\\\n 3 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 0 & 0 & -1 \\\\\n 3 & 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -6 & 0 & -7 \\\\\n 6 & 0 & 3 \\\\\n 3 & 0 & 1 \\\\\n -6 & 0 & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2],\n [1, 2],\n [1, 1],\n [3, -2]])\nb = np.array([\n [0, 0, -1],\n [3, 0, 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 0 & 5 & 0 \\\\\n 0 & 0 & -4 \\\\\n -3 & 4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{4}{15} & 0 & -\\frac{1}{3} \\\\\n \\frac{1}{5} & 0 & 0 \\\\\n 0 & -\\frac{1}{4} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 5, 0],\n [0, 0, -4],\n [-3, 4, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -3 \\\\\n -4 \\\\\n -7 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-3],\n [-4],\n [-7],\n [2]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 2 & -10 & 6 & 6 & -3 & 1 \\\\\n -5 & -5 & 0 & -1 & 9 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & \\frac{1}{2} & \\frac{2}{3} & -\\frac{7}{4} & -\\frac{17}{12} \\\\\n 0 & 1 & -\\frac{1}{2} & -\\frac{7}{15} & -\\frac{1}{20} & -\\frac{23}{60} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, -10, 6, 6, -3, 1],\n [-5, -5, 0, -1, 9, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -5 & -2 & 9 & -1 \\\\\n 2 & -4 & 2 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{4.,-13.,0.,6.\\}, \\{8.,7.,6.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, -2, 9, -1],\n [2, -4, 2, -10]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & 2 & 3 \\\\\n 1 & 0 & -1 \\\\\n 2 & 3 & 1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 11 & 19 & 16 \\\\\n 3 & 2 & -3 \\\\\n 15 & 22 & 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, 3],\n [1, 0, -1],\n [2, 3, 1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{22}{5} & -\\frac{9}{5} \\\\\n 4 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{5}{13} & -\\frac{9}{52} \\\\\n \\frac{5}{13} & -\\frac{11}{26} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(22/5), -(9/5)],\n [4, -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\sqrt{5} \\\\\n 0 \\\\\n -4 \\sqrt{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\sqrt{5} \\\\\n -\\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{345}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-4*math.sqrt(5)],\n [0],\n [-4*math.sqrt(5)]])\nb = np.array([\n [-2*math.sqrt(5)],\n [-math.sqrt(5)],\n [4*math.sqrt(5)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{5} \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{16}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/5)],\n [1]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -8 \\\\\n 4 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -2 \\\\\n -10 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$14 \\sqrt{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-8],\n [4],\n [3]])\nb = np.array([\n [5],\n [-2],\n [-10],\n [-1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -2 & -2 & 2 & -1 \\\\\n 0 & -2 & -1 & -2 \\\\\n -3 & 1 & 1 & -1 \\\\\n -1 & 3 & -1 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -2 & -1 & 0 \\\\\n -1 & -2 & 1 \\\\\n 1 & 2 & 2 \\\\\n 2 & 1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 6 & 9 & 4 \\\\\n -3 & 0 & 0 \\\\\n 4 & 2 & 5 \\\\\n -6 & -9 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2, 2, -1],\n [0, -2, -1, -2],\n [-3, 1, 1, -1],\n [-1, 3, -1, -2]])\nb = np.array([\n [-2, -1, 0],\n [-1, -2, 1],\n [1, 2, 2],\n [2, 1, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -1 & -2 & 3 \\\\\n 4 & 10 & 0 \\\\\n 4 & 9 & -2 \\\\\n -4 & 2 & -6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -1 & 9 & -5 \\\\\n 10 & 9 & -2 \\\\\n 2 & -4 & -9 \\\\\n 9 & 8 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & -11 & 8 \\\\\n -6 & 1 & 2 \\\\\n 2 & 13 & 7 \\\\\n -13 & -6 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, 3],\n [4, 10, 0],\n [4, 9, -2],\n [-4, 2, -6]])\nb = np.array([\n [-1, 9, -5],\n [10, 9, -2],\n [2, -4, -9],\n [9, 8, -1]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & -6 \\\\\n 3 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(3-\\sqrt{217}\\right),\\frac{1}{2} \\left(3+\\sqrt{217}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -6],\n [3, 10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 1 & 3 \\\\\n -1 & -3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 4 & 12 \\\\\n -4 & -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3],\n [-1, -3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 0 & -1 & 2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 0 & -1 & 2 & 2 \\\\\n 0 & 1 & -2 & -2 \\\\\n 0 & -1 & 2 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [1]])\nb = np.array([\n [0, -1, 2, 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 2 \\\\\n 4 \\\\\n -1 \\\\\n 2 \\\\\n 9 \\\\\n -5 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -7 \\\\\n -5 \\\\\n 6 \\\\\n -3 \\\\\n -10 \\\\\n 5 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{761}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [2],\n [4],\n [-1],\n [2],\n [9],\n [-5],\n [-6]])\nb = np.array([\n [-4],\n [-7],\n [-5],\n [6],\n [-3],\n [-10],\n [5],\n [-6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{7} \\\\\n \\frac{66}{7} \\\\\n -\\frac{46}{7} \\\\\n \\frac{25}{7} \\\\\n \\frac{53}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{55}{7} \\\\\n \\frac{13}{7} \\\\\n -\\frac{68}{7} \\\\\n -\\frac{53}{7} \\\\\n \\frac{1}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{2659}{49}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/7)],\n [(66/7)],\n [-(46/7)],\n [(25/7)],\n [(53/7)]])\nb = np.array([\n [(55/7)],\n [(13/7)],\n [-(68/7)],\n [-(53/7)],\n [(1/7)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 1 \\\\\n -3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1],\n [-3, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{643}{100} & -\\frac{18}{5} \\\\\n -\\frac{21}{25} & \\frac{411}{50} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{20} & -\\frac{823}{100} \\\\\n \\frac{168}{25} & \\frac{209}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{152}{25} & -\\frac{1183}{100} \\\\\n \\frac{147}{25} & \\frac{829}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(643/100), -(18/5)],\n [-(21/25), (411/50)]])\nb = np.array([\n [-(7/20), -(823/100)],\n [(168/25), (209/25)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2.1 \\\\\n 3.41 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4.1 \\\\\n -7.66 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$11.2492$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2.1],\n [3.41]])\nb = np.array([\n [4.1],\n [-7.66]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n -7 & -8 & -9 \\\\\n 2 & 4 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -8, -9],\n [2, 4, -4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & -1 & 2 \\\\\n -1 & 1 & 0 \\\\\n -3 & 3 & 2 \\\\\n 1 & 3 & -2 \\\\\n 0 & -1 & 0 \\\\\n 3 & -3 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.66 \\\\\n -0.55 \\\\\n -1.19 \\\\\n -1.63 \\\\\n -2.77 \\\\\n 0.65 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.487 \\\\\n -0.074 \\\\\n 0.62 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, 2],\n [-1, 1, 0],\n [-3, 3, 2],\n [1, 3, -2],\n [0, -1, 0],\n [3, -3, -1]])\nb = np.array([\n [2.66],\n [-0.55],\n [-1.19],\n [-1.63],\n [-2.77],\n [0.65]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{3} \\\\\n \\frac{11}{6} \\\\\n -1 \\\\\n -\\frac{35}{6} \\\\\n -1 \\\\\n -\\frac{1}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{4783}}{6}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/3)],\n [(11/6)],\n [-1],\n [-(35/6)],\n [-1],\n [-(1/6)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 4 \\\\\n -6 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [4],\n [-6],\n [9]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [-1],\n [1],\n [0],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [0],\n [0],\n [0],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,0,0\\}, \\{-1,0,2\\}, \\{-2,1,2\\}}$", - "Output Answer": [ - "${\\{-1,0,0\\}, \\{0,0,1\\}, \\{0,1,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, 0, 0), (-1, 0, 2), (-2, 1, 2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{8}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -6 & 4 & 0 & -2 \\\\\n -1 & -5 & -1 & 10 \\\\\n -2 & 3 & 1 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{3}{4} & \\frac{1}{2} & 0 & -\\frac{1}{4} \\\\\n -\\frac{1}{8} & -\\frac{5}{8} & -\\frac{1}{8} & \\frac{5}{4} \\\\\n -\\frac{1}{4} & \\frac{3}{8} & \\frac{1}{8} & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 4, 0, -2],\n [-1, -5, -1, 10],\n [-2, 3, 1, -8]])\nprint(a * (1/8))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n \\frac{13}{3} \\\\\n \\frac{8}{3} \\\\\n -\\frac{47}{6} \\\\\n \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/3)],\n [(8/3)],\n [-(47/6)],\n [(4/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 2 & -1 \\\\\n 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & -1 \\\\\n 1 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1],\n [1, -1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{7}{2},-\\frac{7}{2},-\\frac{3}{2}\\right\\}, \\left\\{-\\frac{3}{2},-\\frac{3}{2},-\\frac{7}{2}\\right\\}, \\left\\{\\frac{3}{2},-4,-\\frac{1}{2}\\right\\}}$.", - "Output Answer": [ - "$x-12 y-11 z-55=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(7/2), -(7/2), -(3/2)],\n [-(3/2), -(3/2), -(7/2)],\n [(3/2), -4, -(1/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -9 & 5 & 3 & -5 \\\\\n 1 & 6 & -8 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-75.,-76.,0.,59.\\}, \\{58.,69.,59.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, 5, 3, -5],\n [1, 6, -8, 9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n \\frac{11}{2} \\\\\n \\frac{5}{2} \\\\\n -\\frac{19}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/2)],\n [(5/2)],\n [-(19/2)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -2 & -5 & 4 & \\frac{5}{2} \\\\\n -\\frac{5}{2} & \\frac{19}{2} & -\\frac{1}{2} & 0 \\\\\n -7 & 5 & 9 & -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -5, 4, (5/2)],\n [-(5/2), (19/2), -(1/2), 0],\n [-7, 5, 9, -(13/2)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{2}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -7 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 9 \\\\\n \\frac{21}{2} \\\\\n -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-7],\n [3]])\nprint(a * -(3/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & 3 & -3 \\\\\n 0 & -4 & -1 \\\\\n -2 & -3 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-46$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 3, -3],\n [0, -4, -1],\n [-2, -3, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 2 & -3 & 0 & -1 & 0 \\\\\n -2 & -1 & 0 & 0 & -2 \\\\\n 0 & 2 & 1 & 1 & 2 \\\\\n 0 & 3 & 3 & -3 & 3 \\\\\n 0 & 0 & 3 & -1 & -3 \\\\\n 1 & 0 & -3 & 1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.32 \\\\\n 2.32 \\\\\n -2.22 \\\\\n -1.7 \\\\\n 0.4 \\\\\n 0.19 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.467 \\\\\n -0.512 \\\\\n -0.375 \\\\\n -0.555 \\\\\n -0.267 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3, 0, -1, 0],\n [-2, -1, 0, 0, -2],\n [0, 2, 1, 1, 2],\n [0, 3, 3, -3, 3],\n [0, 0, 3, -1, -3],\n [1, 0, -3, 1, 1]])\nb = np.array([\n [1.32],\n [2.32],\n [-2.22],\n [-1.7],\n [0.4],\n [0.19]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, -\\frac{10}{3}}$ to the line $\\frac{7 x}{3}+\\frac{2 y}{3}-3=0$.", - "Output Answer": [ - "$\\frac{89}{3 \\sqrt{53}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, -(10/3)\nline = Poly(((7*x)/3)+((2*y)/3)-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 3 & 3 \\\\\n 3 & 3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 108 & 108 \\\\\n 108 & 108 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3],\n [3, 3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -4 & 0 & 3 \\\\\n -9 & -9 & -10 \\\\\n -7 & 3 & -10 \\\\\n 5 & 4 & -7 \\\\\n -4 & -6 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, 0, 3],\n [-9, -9, -10],\n [-7, 3, -10],\n [5, 4, -7],\n [-4, -6, -10]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{ccc}\n -2 & 0 & 0 \\\\\n 4 & 0 & 2 \\\\\n 4 & 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{e^2} & 0 & 0 \\\\\n e^2-\\frac{1}{e^2} & 1 & e^2-1 \\\\\n e^2-\\frac{1}{e^2} & 0 & e^2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [-2, 0, 0],\n [4, 0, 2],\n [4, 0, 2]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2 & \\frac{5}{2} & \\frac{5}{2} \\\\\n \\frac{3}{2} & -\\frac{3}{2} & -2 \\\\\n -3 & 1 & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{4} & -\\frac{25}{4} & -\\frac{25}{2} \\\\\n \\frac{3}{4} & 4 & \\frac{35}{4} \\\\\n \\frac{21}{2} & -10 & -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, (5/2), (5/2)],\n [(3/2), -(3/2), -2],\n [-3, 1, -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{21}{4} \\\\\n -\\frac{3}{4} \\\\\n -4 \\\\\n -\\frac{17}{4} \\\\\n \\frac{23}{4} \\\\\n -\\frac{39}{4} \\\\\n -\\frac{15}{2} \\\\\n -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{4429}}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(21/4)],\n [-(3/4)],\n [-4],\n [-(17/4)],\n [(23/4)],\n [-(39/4)],\n [-(15/2)],\n [-(11/2)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{2} & -\\frac{5}{2} \\\\\n -\\frac{1}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2), -(5/2)],\n [-(1/2), (1/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & 2 & 1 & 3 \\\\\n -1 & 0 & 2 & -1 \\\\\n -2 & -2 & 2 & 1 \\\\\n 1 & 2 & 2 & 1 \\\\\n 0 & 2 & -3 & -3 \\\\\n -2 & -2 & 3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.08 \\\\\n -1.47 \\\\\n -1.01 \\\\\n -3. \\\\\n -2.31 \\\\\n -2.19 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.937 \\\\\n -0.925 \\\\\n -0.694 \\\\\n 0.548 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, 1, 3],\n [-1, 0, 2, -1],\n [-2, -2, 2, 1],\n [1, 2, 2, 1],\n [0, 2, -3, -3],\n [-2, -2, 3, 2]])\nb = np.array([\n [-0.08],\n [-1.47],\n [-1.01],\n [-3.],\n [-2.31],\n [-2.19]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-5$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & 3 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -20 & -15 & -50 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 3, 10]])\nprint(a * -5)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, 4, 4}$ to the plane $2 x-3 y+3 z-3=0$.", - "Output Answer": [ - "$\\frac{3}{\\sqrt{22}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, 4, 4\nplane = Poly(2*x-3*y+3*z-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{6} \\\\\n \\frac{17}{6} \\\\\n -\\frac{5}{2} \\\\\n -\\frac{1}{6} \\\\\n \\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{17}{2 \\sqrt{265}} \\\\\n \\frac{17}{2 \\sqrt{265}} \\\\\n -\\frac{3 \\sqrt{\\frac{5}{53}}}{2} \\\\\n -\\frac{1}{2 \\sqrt{265}} \\\\\n \\frac{8}{\\sqrt{265}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/6)],\n [(17/6)],\n [-(5/2)],\n [-(1/6)],\n [(8/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & 0 & -3 \\\\\n -\\frac{5}{2} & \\frac{5}{2} & -2 \\\\\n -1 & \\frac{1}{2} & 1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 4 & -\\frac{3}{2} & -6 \\\\\n -\\frac{27}{4} & \\frac{21}{4} & \\frac{1}{2} \\\\\n -\\frac{13}{4} & \\frac{7}{4} & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 0, -3],\n [-(5/2), (5/2), -2],\n [-1, (1/2), 1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 1 \\\\\n 5 \\\\\n -6 \\\\\n -5 \\\\\n 7 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 0 \\\\\n -5 \\\\\n 5 \\\\\n 7 \\\\\n -7 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-92$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [1],\n [5],\n [-6],\n [-5],\n [7],\n [7]])\nb = np.array([\n [-9],\n [0],\n [-5],\n [5],\n [7],\n [-7],\n [-1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & 0 \\\\\n -3 & \\frac{3}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{9}{4} & 0 \\\\\n -9 & \\frac{9}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), 0],\n [-3, (3/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 8 & 2 & 9 \\\\\n -8 & -2 & 5 \\\\\n -4 & -3 & 0 \\\\\n 3 & -6 & -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -10 & -9 & -5 \\\\\n -3 & -4 & 2 \\\\\n 10 & 3 & -1 \\\\\n 0 & -5 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -2 & -7 & 4 \\\\\n -11 & -6 & 7 \\\\\n 6 & 0 & -1 \\\\\n 3 & -11 & -18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 2, 9],\n [-8, -2, 5],\n [-4, -3, 0],\n [3, -6, -9]])\nb = np.array([\n [-10, -9, -5],\n [-3, -4, 2],\n [10, 3, -1],\n [0, -5, -9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{4} \\\\\n -\\frac{13}{4} \\\\\n -3 \\\\\n \\frac{17}{4} \\\\\n \\frac{35}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n \\frac{25}{4} \\\\\n -\\frac{1}{4} \\\\\n -\\frac{7}{2} \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{\\frac{521}{2}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/4)],\n [-(13/4)],\n [-3],\n [(17/4)],\n [(35/4)]])\nb = np.array([\n [(3/2)],\n [(25/4)],\n [-(1/4)],\n [-(7/2)],\n [-1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10},-\\frac{3}{10}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-1]]).squeeze()\nb = np.array([\n [1],\n [-3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -3 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -3 & 1 & 2 \\\\\n -1 & 2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 8 & -1 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1]])\nb = np.array([\n [-3, 1, 2],\n [-1, 2, 1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-6]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{1}{4} & \\frac{3}{2} & 2 & 3 & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{5}{2} & -\\frac{3}{4} & \\frac{7}{4} & -\\frac{1}{2} \\\\\n -\\frac{5}{4} & \\frac{9}{4} & \\frac{3}{2} & -\\frac{9}{4} \\\\\n \\frac{5}{2} & \\frac{1}{4} & \\frac{7}{4} & -\\frac{3}{2} \\\\\n -\\frac{3}{2} & \\frac{11}{4} & -\\frac{7}{4} & -2 \\\\\n 1 & \\frac{9}{4} & -\\frac{3}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{1}{2} & \\frac{281}{16} & -\\frac{45}{16} & -\\frac{55}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/4), (3/2), 2, 3, (5/2)]])\nb = np.array([\n [-(5/2), -(3/4), (7/4), -(1/2)],\n [-(5/4), (9/4), (3/2), -(9/4)],\n [(5/2), (1/4), (7/4), -(3/2)],\n [-(3/2), (11/4), -(7/4), -2],\n [1, (9/4), -(3/2), -(1/2)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,-5,-1\\}, \\{2,-4,4\\}, \\{4,-4,-2\\}}$.", - "Output Answer": [ - "$3 x-8 y+z-42=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -5, -1],\n [2, -4, 4],\n [4, -4, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{3} \\\\\n -6 \\\\\n \\frac{25}{3} \\\\\n -\\frac{5}{3} \\\\\n -\\frac{17}{3} \\\\\n 8 \\\\\n \\frac{11}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -\\frac{14}{3} \\\\\n 7 \\\\\n 8 \\\\\n \\frac{14}{3} \\\\\n \\frac{14}{3} \\\\\n \\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$103$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/3)],\n [-6],\n [(25/3)],\n [-(5/3)],\n [-(17/3)],\n [8],\n [(11/3)]])\nb = np.array([\n [-7],\n [-(14/3)],\n [7],\n [8],\n [(14/3)],\n [(14/3)],\n [(8/3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{59}{16} & -\\frac{15}{4} & -\\frac{31}{16} \\\\\n -\\frac{7}{4} & \\frac{23}{8} & \\frac{67}{8} \\\\\n -\\frac{33}{16} & -\\frac{1}{4} & -\\frac{39}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{27 x^2}{16}+\\frac{7643 x}{256}+\\frac{82881}{2048}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(59/16), -(15/4), -(31/16)],\n [-(7/4), (23/8), (67/8)],\n [-(33/16), -(1/4), -(39/8)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n \\frac{12}{5} & -\\frac{1}{5} & \\frac{13}{5} & -\\frac{3}{5} \\\\\n \\frac{1}{5} & \\frac{8}{5} & \\frac{8}{5} & \\frac{6}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{14}{5} & \\frac{2}{5} & 2 \\\\\n -\\frac{3}{5} & -\\frac{12}{5} & -\\frac{7}{5} \\\\\n -2 & \\frac{9}{5} & \\frac{3}{5} \\\\\n -\\frac{4}{5} & -\\frac{6}{5} & \\frac{3}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{53}{25} & \\frac{171}{25} & \\frac{157}{25} \\\\\n -\\frac{114}{25} & -\\frac{58}{25} & -\\frac{4}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(12/5), -(1/5), (13/5), -(3/5)],\n [(1/5), (8/5), (8/5), (6/5)]])\nb = np.array([\n [(14/5), (2/5), 2],\n [-(3/5), -(12/5), -(7/5)],\n [-2, (9/5), (3/5)],\n [-(4/5), -(6/5), (3/5)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -1 & -\\frac{5}{2} \\\\\n \\frac{7}{2} & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{18}{53} & \\frac{10}{53} \\\\\n -\\frac{14}{53} & -\\frac{4}{53} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -(5/2)],\n [(7/2), -(9/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -\\frac{21}{5} \\\\\n \\frac{23}{5} \\\\\n -1 \\\\\n 8 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{\\frac{919}{5}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-(21/5)],\n [(23/5)],\n [-1],\n [8],\n [-4]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 7 \\\\\n -9 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 2 \\\\\n 7 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-94$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [7],\n [-9],\n [2]])\nb = np.array([\n [-7],\n [2],\n [7],\n [-5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{5} & \\frac{9}{5} \\\\\n -\\frac{7}{5} & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{119}{50}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/5), (9/5)],\n [-(7/5), -(7/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -9 & -7 & 8 & -2 \\\\\n -9 & 10 & 8 & -1 \\\\\n -10 & 5 & 7 & 8 \\\\\n -10 & -3 & 8 & 2 \\\\\n 4 & 2 & 6 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, -7, 8, -2],\n [-9, 10, 8, -1],\n [-10, 5, 7, 8],\n [-10, -3, 8, 2],\n [4, 2, 6, -10]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 10 \\\\\n 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [0]])\nb = np.array([\n [1],\n [3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & 1 & -2 \\\\\n 0 & -4 & -2 \\\\\n -4 & -5 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$54$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, -2],\n [0, -4, -2],\n [-4, -5, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n \\frac{38}{5} & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(38/5), 6]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & -1 & 3 \\\\\n -1 & -1 & -3 \\\\\n -3 & -1 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-14$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1, 3],\n [-1, -1, -3],\n [-3, -1, -5]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 4 & -4 \\\\\n 0 & -4 & -2 \\\\\n 2 & 1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-48$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 4, -4],\n [0, -4, -2],\n [2, 1, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 4 \\\\\n -10 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -3 \\\\\n 6 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{483}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [4],\n [-10],\n [-8]])\nb = np.array([\n [9],\n [-3],\n [6],\n [5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 9 & -\\frac{19}{2} & \\frac{3}{2} & -3 \\\\\n \\frac{11}{2} & 9 & \\frac{7}{2} & 7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 7 & \\frac{13}{2} & 2 & 3 \\\\\n \\frac{7}{2} & \\frac{9}{2} & -\\frac{5}{2} & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 2 & -16 & -\\frac{1}{2} & -6 \\\\\n 2 & \\frac{9}{2} & 6 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -(19/2), (3/2), -3],\n [(11/2), 9, (7/2), 7]])\nb = np.array([\n [7, (13/2), 2, 3],\n [(7/2), (9/2), -(5/2), 5]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -10 & -6 & 7 & -9 \\\\\n -5 & 10 & 5 & -1 \\\\\n 7 & 8 & -5 & -7 \\\\\n 0 & 10 & 9 & 5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -1 & 1 & 1 & -10 \\\\\n 6 & -6 & 5 & -3 \\\\\n -4 & -4 & -7 & 2 \\\\\n -6 & -5 & -1 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -9 & -7 & 6 & 1 \\\\\n -11 & 16 & 0 & 2 \\\\\n 11 & 12 & 2 & -9 \\\\\n 6 & 15 & 10 & 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -6, 7, -9],\n [-5, 10, 5, -1],\n [7, 8, -5, -7],\n [0, 10, 9, 5]])\nb = np.array([\n [-1, 1, 1, -10],\n [6, -6, 5, -3],\n [-4, -4, -7, 2],\n [-6, -5, -1, -4]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{181}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-4]])\nb = np.array([\n [6],\n [5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{5} \\\\\n -\\frac{3}{5} \\\\\n -\\frac{1}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{12}{5} & \\frac{9}{5} & -\\frac{12}{5} & -\\frac{6}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{108}{25} & -\\frac{81}{25} & \\frac{108}{25} & \\frac{54}{25} \\\\\n -\\frac{36}{25} & -\\frac{27}{25} & \\frac{36}{25} & \\frac{18}{25} \\\\\n -\\frac{12}{25} & -\\frac{9}{25} & \\frac{12}{25} & \\frac{6}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/5)],\n [-(3/5)],\n [-(1/5)]])\nb = np.array([\n [(12/5), (9/5), -(12/5), -(6/5)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{2}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 7 \\\\\n -8 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 25 \\\\\n \\frac{35}{2} \\\\\n -20 \\\\\n \\frac{5}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [7],\n [-8],\n [1]])\nprint(a * (5/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -5 & -3 \\\\\n 4 & -8 \\\\\n -1 & 8 \\\\\n 9 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, -3],\n [4, -8],\n [-1, 8],\n [9, -4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -4 & -3 & -10 \\\\\n 3 & -5 & -3 \\\\\n -2 & -9 & -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 6 & -4 & -3 \\\\\n -6 & -8 & 9 \\\\\n -10 & 7 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 2 & -7 & -13 \\\\\n -3 & -13 & 6 \\\\\n -12 & -2 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -3, -10],\n [3, -5, -3],\n [-2, -9, -4]])\nb = np.array([\n [6, -4, -3],\n [-6, -8, 9],\n [-10, 7, 7]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 3 & 6 & -5 & -5 & 1 \\\\\n 3 & -6 & 2 & 6 & -5 \\\\\n -4 & -6 & 3 & 2 & -2 \\\\\n -2 & -7 & 10 & -1 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & -\\frac{783}{1139} \\\\\n 0 & 1 & 0 & 0 & \\frac{1153}{1139} \\\\\n 0 & 0 & 1 & 0 & \\frac{8}{67} \\\\\n 0 & 0 & 0 & 1 & \\frac{550}{1139} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, 6, -5, -5, 1],\n [3, -6, 2, 6, -5],\n [-4, -6, 3, 2, -2],\n [-2, -7, 10, -1, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1+2 i & -3 i & 4 i \\\\\n -4+3 i & -1-5 i & 1-5 i \\\\\n i & 3 i & -1+i \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 59-118 i & 108+12 i & 15+103 i \\\\\n -101-97 i & 176-193 i & 141+89 i \\\\\n -3+70 i & -90 & 29-119 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1+2j, -3j, 4j],\n [-4+3j, -1-5j, 1-5j],\n [1j, 3j, -1+ 1j]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & 1 & 2 & 2 & -2 \\\\\n 3 & -1 & 2 & 2 & -2 \\\\\n -2 & -3 & -1 & -2 & -2 \\\\\n -2 & 3 & 3 & -3 & 2 \\\\\n 1 & 1 & -2 & 1 & -1 \\\\\n 1 & 2 & 0 & 2 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.16 \\\\\n 2.66 \\\\\n -2.28 \\\\\n 2.24 \\\\\n 0.67 \\\\\n 2.14 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.102 \\\\\n 0.515 \\\\\n 0.323 \\\\\n -0.512 \\\\\n 0.048 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, 2, 2, -2],\n [3, -1, 2, 2, -2],\n [-2, -3, -1, -2, -2],\n [-2, 3, 3, -3, 2],\n [1, 1, -2, 1, -1],\n [1, 2, 0, 2, 2]])\nb = np.array([\n [-1.16],\n [2.66],\n [-2.28],\n [2.24],\n [0.67],\n [2.14]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}+\\tan ^{-1}\\left(\\frac{3}{7}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-4]]).squeeze()\nb = np.array([\n [-5],\n [-2]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 1 & 2 & 0 \\\\\n 4 & -2 & -2 \\\\\n 0 & 3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & \\frac{1}{8} & -\\frac{1}{4} \\\\\n \\frac{1}{4} & -\\frac{1}{16} & \\frac{1}{8} \\\\\n \\frac{3}{4} & -\\frac{3}{16} & -\\frac{5}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, 0],\n [4, -2, -2],\n [0, 3, -1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{17}{7},-\\frac{18}{7},-2\\right\\}, \\left\\{\\frac{19}{7},\\frac{18}{7},\\frac{20}{7}\\right\\}, \\left\\{-3,\\frac{2}{7},\\frac{19}{7}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{17}{\\sqrt{809}},-\\frac{18}{\\sqrt{809}},-\\frac{14}{\\sqrt{809}}\\right\\}, \\left\\{-\\frac{194}{\\sqrt{3728681}},-\\frac{1062}{\\sqrt{3728681}},\\frac{1601}{\\sqrt{3728681}}\\right\\}, \\left\\{-\\frac{54}{\\sqrt{4609}},\\frac{37}{\\sqrt{4609}},\\frac{18}{\\sqrt{4609}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-(17/7), -(18/7), -2), ((19/7), (18/7), (20/7)), (-3, (2/7), (19/7))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -1 & 0 & -2 \\\\\n -2 & 0 & 0 \\\\\n 2 & 0 & -3 \\\\\n -1 & 1 & 3 \\\\\n -1 & 1 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 2 & -1 & -2 \\\\\n 0 & 1 & 0 \\\\\n 1 & -2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -4 & 5 & 2 \\\\\n -4 & 2 & 4 \\\\\n 1 & 4 & -4 \\\\\n 1 & -4 & 2 \\\\\n -3 & 4 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, -2],\n [-2, 0, 0],\n [2, 0, -3],\n [-1, 1, 3],\n [-1, 1, -1]])\nb = np.array([\n [2, -1, -2],\n [0, 1, 0],\n [1, -2, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -6 & -10 \\\\\n -6 & -8 \\\\\n 9 & -5 \\\\\n -9 & 2 \\\\\n -9 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-6, -10],\n [-6, -8],\n [9, -5],\n [-9, 2],\n [-9, -6]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -2 & 0 & -2 & 1 \\\\\n 2 & -2 & -2 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 2 & -1 & -2 & -1 & 2 \\\\\n 2 & -2 & 1 & 2 & -2 \\\\\n -3 & -2 & 3 & 1 & 2 \\\\\n 0 & 2 & -2 & 2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 2 & 8 & -4 & 2 & -8 \\\\\n 6 & 0 & -6 & -14 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, -2, 1],\n [2, -2, -2, -3]])\nb = np.array([\n [2, -1, -2, -1, 2],\n [2, -2, 1, 2, -2],\n [-3, -2, 3, 1, 2],\n [0, 2, -2, 2, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{23}{6} & -\\frac{14}{3} \\\\\n 5 & \\frac{17}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{449}{36}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/6), -(14/3)],\n [5, (17/6)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -3 \\\\\n 5 \\\\\n -1 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-3],\n [5],\n [-1],\n [7]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 0 & -4 \\\\\n 4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{3}{16} & \\frac{1}{4} \\\\\n -\\frac{1}{4} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -4],\n [4, -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 9 & -4 & 4 & -10 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-4.,0.,9.,0.,0.\\}, \\{-1.,0.,0.,0.,9.\\}, \\{4.,9.,0.,0.,0.\\}, \\{10.,0.,0.,9.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, -4, 4, -10, 1]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & 3 & 1 \\\\\n -4 & -3 & -3 \\\\\n -1 & -4 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$94$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, 1],\n [-4, -3, -3],\n [-1, -4, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n \\frac{7}{2} \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 6 \\\\\n \\frac{17}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{143}{4} \\\\\n -\\frac{151}{2} \\\\\n \\frac{115}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [(7/2)],\n [-1]])\nb = np.array([\n [-1],\n [6],\n [(17/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -1 \\\\\n -\\frac{39}{4} \\\\\n -\\frac{1}{2} \\\\\n \\frac{29}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{\\frac{1319}{2}}}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-1],\n [-(39/4)],\n [-(1/2)],\n [(29/4)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{17}{2} & -4 \\\\\n -\\frac{15}{2} & \\frac{13}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{15} \\left(15-\\sqrt{345}\\right),1\\right\\}, \\left\\{\\frac{1}{15} \\left(15+\\sqrt{345}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/2), -4],\n [-(15/2), (13/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & -2 & 1 \\\\\n -2 & 1 & -1 \\\\\n -2 & 1 & 2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 2 & -1 & 4 \\\\\n 0 & 4 & -5 \\\\\n -6 & 7 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2, 1],\n [-2, 1, -1],\n [-2, 1, 2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -6 & 7 & -8 \\\\\n -1 & 9 & 0 \\\\\n 7 & -4 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+4 x^2-12 x+425$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 7, -8],\n [-1, 9, 0],\n [7, -4, 1]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -3 & \\frac{21}{10} \\\\\n \\frac{13}{2} & \\frac{11}{2} \\\\\n -\\frac{29}{5} & \\frac{17}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, (21/10)],\n [(13/2), (11/2)],\n [-(29/5), (17/10)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -3 & 0 & 0 \\\\\n 0 & 2 & 0 \\\\\n -1 & 2 & 2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 9 & 0 & 0 \\\\\n 0 & 4 & 0 \\\\\n 1 & 8 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, 0],\n [0, 2, 0],\n [-1, 2, 2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n 3 & 0 & 7 & 5 \\\\\n -6 & 3 & 7 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 0, 7, 5],\n [-6, 3, 7, -10]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\pi \\\\\n \\pi \\\\\n 3 \\pi \\\\\n -\\pi \\\\\n -3 \\pi \\\\\n -\\pi \\\\\n -2 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\pi \\\\\n -2 \\pi \\\\\n \\pi \\\\\n \\pi \\\\\n 2 \\pi \\\\\n -2 \\pi \\\\\n 3 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-8 \\pi ^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.pi],\n [math.pi],\n [3*math.pi],\n [-math.pi],\n [-3*math.pi],\n [-math.pi],\n [-2*math.pi]])\nb = np.array([\n [2*math.pi],\n [-2*math.pi],\n [math.pi],\n [math.pi],\n [2*math.pi],\n [-2*math.pi],\n [3*math.pi]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 1 & 1 \\\\\n 2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{10} & \\frac{1}{5} \\\\\n \\frac{1}{10} & \\frac{1}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1],\n [2, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -1 & 0 \\\\\n -1 & 3 & 1 \\\\\n 2 & 0 & -3 \\\\\n 3 & 2 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.88 \\\\\n -1.14 \\\\\n -1.07 \\\\\n 0.29 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.339 \\\\\n -0.342 \\\\\n 0.493 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, 0],\n [-1, 3, 1],\n [2, 0, -3],\n [3, 2, 1]])\nb = np.array([\n [-1.88],\n [-1.14],\n [-1.07],\n [0.29]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n -5 & 2 & 8 \\\\\n 5 & 1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 2, 8],\n [5, 1, 4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -\\frac{2}{3} \\\\\n -\\frac{1}{3} \\\\\n -2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{4}{3} \\\\\n -\\frac{2}{3} \\\\\n 1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{196}{195},-\\frac{98}{195},\\frac{49}{65},-\\frac{98}{65}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-(2/3)],\n [-(1/3)],\n [-2]]).squeeze()\nb = np.array([\n [(4/3)],\n [-(2/3)],\n [1],\n [-2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{3} \\\\\n -\\frac{10}{3} \\\\\n -\\frac{26}{3} \\\\\n 3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -\\frac{4}{3} \\\\\n \\frac{5}{3} \\\\\n \\frac{8}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{11}{3} \\\\\n -2 \\\\\n -\\frac{31}{3} \\\\\n \\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/3)],\n [-(10/3)],\n [-(26/3)],\n [3]])\nb = np.array([\n [2],\n [-(4/3)],\n [(5/3)],\n [(8/3)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{12}{7}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 4 & 2 & -3 & -8 \\\\\n -7 & -7 & 3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{48}{7} & \\frac{24}{7} & -\\frac{36}{7} & -\\frac{96}{7} \\\\\n -12 & -12 & \\frac{36}{7} & \\frac{36}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 2, -3, -8],\n [-7, -7, 3, 3]])\nprint(a * (12/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 6 & 7 & -7 \\\\\n -5 & 0 & 9 \\\\\n 5 & 6 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+9 x^2-34 x+306$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 7, -7],\n [-5, 0, 9],\n [5, 6, 3]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 1 & 4 & -6 \\\\\n 8 & -4 & 3 \\\\\n 0 & 1 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-3 x^2+39 x-51$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 4, -6],\n [8, -4, 3],\n [0, 1, 0]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -4 & -7 & -8 & 5 \\\\\n 1 & -8 & -5 & 0 \\\\\n -6 & -6 & 8 & -4 \\\\\n -6 & 6 & -6 & -3 \\\\\n -10 & -10 & -2 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, -7, -8, 5],\n [1, -8, -5, 0],\n [-6, -6, 8, -4],\n [-6, 6, -6, -3],\n [-10, -10, -2, 7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n \\frac{32}{7} \\\\\n \\frac{3}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -\\frac{30}{7} \\\\\n -\\frac{65}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1990}{49} \\\\\n -\\frac{142}{7} \\\\\n \\frac{188}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [(32/7)],\n [(3/7)]])\nb = np.array([\n [-4],\n [-(30/7)],\n [-(65/7)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 7 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 30 \\\\\n -42 \\\\\n 63 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [2],\n [-2]])\nb = np.array([\n [-7],\n [7],\n [8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 7 & -2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -7 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 14 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -2]])\nb = np.array([\n [-7, -1]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -8 & 7 & 3 & 2 \\\\\n -8 & 5 & -3 & 7 \\\\\n 2 & 8 & 10 & 8 \\\\\n 8 & -6 & -9 & -8 \\\\\n -7 & 2 & -7 & 9 \\\\\n 3 & 1 & 0 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-8, 7, 3, 2],\n [-8, 5, -3, 7],\n [2, 8, 10, 8],\n [8, -6, -9, -8],\n [-7, 2, -7, 9],\n [3, 1, 0, -3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-1$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -5 & -10 & 9 & 6 \\\\\n -5 & -7 & -10 & -8 \\\\\n -6 & 8 & 10 & 8 \\\\\n 1 & 3 & 0 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 5 & 10 & -9 & -6 \\\\\n 5 & 7 & 10 & 8 \\\\\n 6 & -8 & -10 & -8 \\\\\n -1 & -3 & 0 & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -10, 9, 6],\n [-5, -7, -10, -8],\n [-6, 8, 10, 8],\n [1, 3, 0, 6]])\nprint(a * -1)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -2 & 9 & 1 & 3 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-5.,0.,0.,0.,2.\\}, \\{1.,0.,2.,0.,0.\\}, \\{3.,0.,0.,2.,0.\\}, \\{9.,2.,0.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, 9, 1, 3, -5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & -\\frac{13}{2} \\\\\n \\frac{9}{2} & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{4} \\left(-1-3 i \\sqrt{51}\\right),\\frac{1}{4} \\left(-1+3 i \\sqrt{51}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), -(13/2)],\n [(9/2), -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -7 & 7 & -9 \\\\\n -2 & 0 & 3 \\\\\n 2 & -7 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{18.169,6.883,1.\\}, \\{-0.71-0.182 i,0.451\\, -0.716 i,1.\\}, \\{-0.71+0.182 i,0.451\\, +0.716 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 7, -9],\n [-2, 0, 3],\n [2, -7, 7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1}{\\sqrt{6}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [0],\n [1]]).squeeze()\nb = np.array([\n [1],\n [0],\n [-1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 1 & \\frac{3}{2} & \\frac{1}{2} & 0 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 3 \\\\\n -2 \\\\\n \\frac{3}{2} \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{9}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, (3/2), (1/2), 0, 0]])\nb = np.array([\n [1],\n [3],\n [-2],\n [(3/2)],\n [(3/2)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 7 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -1 \\\\\n 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 76 \\\\\n 94 \\\\\n -59 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [7],\n [6]])\nb = np.array([\n [9],\n [-1],\n [10]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{5} \\\\\n \\frac{11}{5} \\\\\n \\frac{1}{5} \\\\\n -\\frac{6}{5} \\\\\n \\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{13}{\\sqrt{391}} \\\\\n \\frac{11}{\\sqrt{391}} \\\\\n \\frac{1}{\\sqrt{391}} \\\\\n -\\frac{6}{\\sqrt{391}} \\\\\n \\frac{8}{\\sqrt{391}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/5)],\n [(11/5)],\n [(1/5)],\n [-(6/5)],\n [(8/5)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 8 & 9 & -4 \\\\\n -6 & -8 & 5 \\\\\n 1 & 7 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+41 x-99$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 9, -4],\n [-6, -8, 5],\n [1, 7, 0]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{6}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & -2 & 2 \\\\\n -9 & 3 & -2 \\\\\n 0 & -10 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{7}{3} & -\\frac{7}{3} & \\frac{7}{3} \\\\\n -\\frac{21}{2} & \\frac{7}{2} & -\\frac{7}{3} \\\\\n 0 & -\\frac{35}{3} & -\\frac{35}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2, 2],\n [-9, 3, -2],\n [0, -10, -10]])\nprint(a * (7/6))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -e \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n e \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [0],\n [-math.e]])\nb = np.array([\n [0],\n [math.e],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & -3 \\\\\n 2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -3],\n [2, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{23}{4} \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{21}{4} \\\\\n -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2)],\n [-(5/2)]])\nb = np.array([\n [-(23/4)],\n [6]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 1 & -5 & -6 & -10 & 1 \\\\\n -4 & 10 & 6 & -7 & 6 \\\\\n 10 & 3 & -9 & 10 & -2 \\\\\n -5 & 5 & 8 & -6 & 5 \\\\\n -1 & -4 & 6 & 8 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [1, -5, -6, -10, 1],\n [-4, 10, 6, -7, 6],\n [10, 3, -9, 10, -2],\n [-5, 5, 8, -6, 5],\n [-1, -4, 6, 8, 1]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{24}{7} & 5 \\\\\n 8 & \\frac{61}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{66}{7} & \\frac{57}{7} \\\\\n \\frac{67}{7} & \\frac{22}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -6 & -\\frac{22}{7} \\\\\n -\\frac{11}{7} & \\frac{39}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(24/7), 5],\n [8, (61/7)]])\nb = np.array([\n [(66/7), (57/7)],\n [(67/7), (22/7)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{20}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{4} \\\\\n -\\frac{1}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [4]])\nprint(a * -(1/20))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 1 & 9 & -1 & 6 & 8 & 10 & -7 \\\\\n 4 & -1 & -9 & -7 & 0 & -4 & 3 \\\\\n -1 & 7 & 2 & 0 & 6 & 6 & 6 \\\\\n -4 & -1 & 3 & -7 & 6 & -1 & -6 \\\\\n 8 & 9 & -8 & -6 & 6 & -3 & 1 \\\\\n 0 & 7 & -5 & 9 & -3 & 7 & 0 \\\\\n -6 & 5 & 7 & 9 & 7 & -5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, 9, -1, 6, 8, 10, -7],\n [4, -1, -9, -7, 0, -4, 3],\n [-1, 7, 2, 0, 6, 6, 6],\n [-4, -1, 3, -7, 6, -1, -6],\n [8, 9, -8, -6, 6, -3, 1],\n [0, 7, -5, 9, -3, 7, 0],\n [-6, 5, 7, 9, 7, -5, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{5} & -\\frac{9}{10} \\\\\n \\frac{1}{2} & -\\frac{23}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{91}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/5), -(9/10)],\n [(1/2), -(23/10)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -2 & 1 \\\\\n 1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{3} & \\frac{1}{3} \\\\\n \\frac{1}{3} & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 1],\n [1, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -3 & \\frac{7}{2} \\\\\n -3 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(7-\\sqrt{127}\\right),\\frac{1}{2} \\left(7+\\sqrt{127}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, (7/2)],\n [-3, 10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -8 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -7 \\\\\n -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 150 \\\\\n 120 \\\\\n -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-8],\n [10]])\nb = np.array([\n [5],\n [-7],\n [-10]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{9}{5} \\\\\n -\\frac{2}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{5} \\\\\n \\frac{3}{5} \\\\\n -\\frac{6}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{217}{470},-\\frac{93}{470},\\frac{93}{235}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [(9/5)],\n [-(2/5)]]).squeeze()\nb = np.array([\n [-(7/5)],\n [(3/5)],\n [-(6/5)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & 0 \\\\\n -2 & 0 \\\\\n 2 & 3 \\\\\n -1 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.8 \\\\\n -1.8 \\\\\n -1.66 \\\\\n -2.94 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.776 \\\\\n -0.408 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0],\n [-2, 0],\n [2, 3],\n [-1, -2]])\nb = np.array([\n [1.8],\n [-1.8],\n [-1.66],\n [-2.94]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{13}{10}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & 7 & -4 \\\\\n -9 & -6 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{39}{10} & -\\frac{91}{10} & \\frac{26}{5} \\\\\n \\frac{117}{10} & \\frac{39}{5} & -\\frac{39}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 7, -4],\n [-9, -6, 6]])\nprint(a * -(13/10))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 3 & -3 \\\\\n -5 & -10 \\\\\n 1 & -7 \\\\\n -7 & -8 \\\\\n -9 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, -3],\n [-5, -10],\n [1, -7],\n [-7, -8],\n [-9, 5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{8} \\\\\n \\frac{15}{2} \\\\\n -\\frac{15}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{2} \\\\\n -\\frac{11}{4} \\\\\n -\\frac{27}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1785}{32} \\\\\n \\frac{921}{32} \\\\\n \\frac{2137}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/8)],\n [(15/2)],\n [-(15/8)]])\nb = np.array([\n [-(19/2)],\n [-(11/4)],\n [-(27/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{1}{2},-\\frac{7}{2},-\\frac{7}{2}\\right\\}, \\left\\{\\frac{3}{2},-\\frac{1}{2},\\frac{3}{2}\\right\\}, \\left\\{2,\\frac{9}{2},\\frac{3}{2}\\right\\}}$.", - "Output Answer": [ - "$50 x-5 y-17 z-52=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(1/2), -(7/2), -(7/2)],\n [(3/2), -(1/2), (3/2)],\n [2, (9/2), (3/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{33}{7} & \\frac{51}{7} & -\\frac{30}{7} \\\\\n -\\frac{46}{7} & -\\frac{62}{7} & -\\frac{47}{7} \\\\\n \\frac{44}{7} & -\\frac{64}{7} & \\frac{25}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{4 x^2}{7}+\\frac{2113 x}{49}-\\frac{367392}{343}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(33/7), (51/7), -(30/7)],\n [-(46/7), -(62/7), -(47/7)],\n [(44/7), -(64/7), (25/7)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -3 & 3 & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -6 & 6 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2]])\nb = np.array([\n [-3, 3, -(1/2)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & 1 \\\\\n -1 & 1 \\\\\n 2 & 2 \\\\\n 1 & 0 \\\\\n 1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.36 \\\\\n 0.89 \\\\\n -0.59 \\\\\n 1.51 \\\\\n 0.3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.139 \\\\\n 0.122 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1],\n [-1, 1],\n [2, 2],\n [1, 0],\n [1, 2]])\nb = np.array([\n [0.36],\n [0.89],\n [-0.59],\n [1.51],\n [0.3]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -3 \\\\\n 0 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2}{\\sqrt{17}} \\\\\n -\\frac{3}{\\sqrt{17}} \\\\\n 0 \\\\\n \\frac{2}{\\sqrt{17}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-3],\n [0],\n [2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & 2 & -1 \\\\\n 0 & -1 & 3 \\\\\n 2 & -2 & -3 \\\\\n 1 & -3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.63 \\\\\n 1.35 \\\\\n -1.18 \\\\\n 2.87 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -3.279 \\\\\n -1.468 \\\\\n -0.543 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2, -1],\n [0, -1, 3],\n [2, -2, -3],\n [1, -3, -3]])\nb = np.array([\n [2.63],\n [1.35],\n [-1.18],\n [2.87]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{2}{3}, -\\frac{2}{3}}$ to the line $\\frac{11 x}{3}-\\frac{y}{3}+\\frac{8}{3}=0$.", - "Output Answer": [ - "$8 \\sqrt{\\frac{2}{61}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (2/3), -(2/3)\nline = Poly(((11*x)/3)-(y/3)+(8/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2} & \\frac{1}{2} \\\\\n -\\frac{1}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & 1 \\\\\n -1 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), (1/2)],\n [-(1/2), (5/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 1 \\\\\n -5 \\\\\n 0 \\\\\n 8 \\\\\n -6 \\\\\n -1 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$35$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [1],\n [-5],\n [0],\n [8],\n [-6],\n [-1],\n [-8]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 2 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -4 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 28 \\\\\n 28 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [2],\n [9]])\nb = np.array([\n [4],\n [-4],\n [-4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & 1 & -2 & -2 \\\\\n 2 & -2 & -1 & 2 \\\\\n -2 & -2 & -1 & 1 \\\\\n 0 & -2 & 3 & -3 \\\\\n -2 & 0 & 3 & 2 \\\\\n 1 & 1 & -3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.18 \\\\\n -2.12 \\\\\n 2.22 \\\\\n -0.74 \\\\\n 2.26 \\\\\n 1.39 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.566 \\\\\n 0.141 \\\\\n -0.04 \\\\\n 0.132 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1, -2, -2],\n [2, -2, -1, 2],\n [-2, -2, -1, 1],\n [0, -2, 3, -3],\n [-2, 0, 3, 2],\n [1, 1, -3, -2]])\nb = np.array([\n [0.18],\n [-2.12],\n [2.22],\n [-0.74],\n [2.26],\n [1.39]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{16} \\\\\n -\\frac{13}{16} \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{2474}} \\\\\n -\\frac{13}{\\sqrt{2474}} \\\\\n -24 \\sqrt{\\frac{2}{1237}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/16)],\n [-(13/16)],\n [-3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 0 & 7 & -2 & -3 \\\\\n 0 & 4 & 7 & -6 \\\\\n -8 & -9 & 2 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 6 & 0 & -1 & 1 \\\\\n -1 & -5 & -4 & -10 \\\\\n -2 & 10 & -8 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 6 & 7 & -3 & -2 \\\\\n -1 & -1 & 3 & -16 \\\\\n -10 & 1 & -6 & -11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 7, -2, -3],\n [0, 4, 7, -6],\n [-8, -9, 2, -2]])\nb = np.array([\n [6, 0, -1, 1],\n [-1, -5, -4, -10],\n [-2, 10, -8, -9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{1}{e},\\frac{5}{e},-\\frac{2}{e}\\right\\}, \\left\\{-\\frac{3}{e},\\frac{3}{e},\\frac{8}{e}\\right\\}, \\left\\{-\\frac{5}{e},\\frac{6}{e},0\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{30}},\\sqrt{\\frac{5}{6}},-\\sqrt{\\frac{2}{15}}\\right\\}, \\left\\{-\\frac{22}{\\sqrt{4605}},4 \\sqrt{\\frac{5}{921}},\\frac{61}{\\sqrt{4605}}\\right\\}, \\left\\{-\\frac{23}{\\sqrt{614}},-\\frac{7}{\\sqrt{614}},-3 \\sqrt{\\frac{2}{307}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-(1/math.e), (5/math.e), -(2/math.e)), (-(3/math.e), (3/math.e), (8/math.e)), (-(5/math.e), (6/math.e), 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 4 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -2 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 36 \\\\\n -38 \\\\\n -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [4],\n [8]])\nb = np.array([\n [-1],\n [-2],\n [5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{46}{5} & \\frac{29}{5} & 4 \\\\\n \\frac{44}{5} & \\frac{27}{5} & \\frac{11}{5} \\\\\n \\frac{17}{5} & 0 & -\\frac{24}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-5.737,0.269,15.269\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(46/5), (29/5), 4],\n [(44/5), (27/5), (11/5)],\n [(17/5), 0, -(24/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{42}{5} & \\frac{22}{5} \\\\\n \\frac{42}{5} & -\\frac{32}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{42} \\left(-5-\\sqrt{949}\\right),1\\right\\}, \\left\\{\\frac{1}{42} \\left(\\sqrt{949}-5\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(42/5), (22/5)],\n [(42/5), -(32/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{26}{3} \\\\\n \\frac{62}{9} \\\\\n -\\frac{4}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{67}{9} \\\\\n 2 \\\\\n \\frac{28}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1760}{27} \\\\\n -\\frac{6284}{81} \\\\\n \\frac{5558}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/3)],\n [(62/9)],\n [-(4/9)]])\nb = np.array([\n [-(67/9)],\n [2],\n [(28/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{7}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 8 & 10 \\\\\n -7 & 10 \\\\\n 5 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{24}{7} & \\frac{30}{7} \\\\\n -3 & \\frac{30}{7} \\\\\n \\frac{15}{7} & -\\frac{27}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 10],\n [-7, 10],\n [5, -9]])\nprint(a * (3/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{28}{9} & \\frac{8}{9} \\\\\n -\\frac{31}{9} & -\\frac{13}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{13}{68} & -\\frac{2}{17} \\\\\n \\frac{31}{68} & -\\frac{7}{17} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(28/9), (8/9)],\n [-(31/9), -(13/9)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -3 & -3 \\\\\n 7 & 6 \\\\\n -7 & -1 \\\\\n -1 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, -3],\n [7, 6],\n [-7, -1],\n [-1, 10]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 1 & -4 & 3 & 7 \\\\\n -1 & -2 & -7 & 2 \\\\\n 10 & -7 & 5 & -1 \\\\\n 2 & -8 & 2 & -3 \\\\\n 1 & 6 & -5 & -8 \\\\\n -5 & -8 & -7 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, -4, 3, 7],\n [-1, -2, -7, 2],\n [10, -7, 5, -1],\n [2, -8, 2, -3],\n [1, 6, -5, -8],\n [-5, -8, -7, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 9 \\\\\n -4 \\\\\n 9 \\\\\n 8 \\\\\n 4 \\\\\n -5 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 3 \\\\\n -6 \\\\\n -8 \\\\\n 7 \\\\\n 7 \\\\\n -5 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$116$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [9],\n [-4],\n [9],\n [8],\n [4],\n [-5],\n [6]])\nb = np.array([\n [-1],\n [3],\n [-6],\n [-8],\n [7],\n [7],\n [-5],\n [4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{4} \\\\\n -\\frac{3}{4} \\\\\n -\\frac{7}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{\\sqrt{67}} \\\\\n -\\frac{3}{\\sqrt{67}} \\\\\n -\\frac{7}{\\sqrt{67}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/4)],\n [-(3/4)],\n [-(7/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{25}{3} & \\frac{13}{3} & \\frac{26}{3} \\\\\n -\\frac{1}{3} & \\frac{5}{3} & \\frac{28}{3} \\\\\n -\\frac{1}{3} & 0 & \\frac{13}{3} \\\\\n \\frac{14}{3} & \\frac{17}{3} & -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{7}{3} & -\\frac{28}{3} & -\\frac{29}{3} \\\\\n -\\frac{10}{3} & -5 & -\\frac{5}{3} \\\\\n \\frac{13}{3} & -\\frac{29}{3} & \\frac{28}{3} \\\\\n 7 & -\\frac{11}{3} & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -6 & -5 & -1 \\\\\n -\\frac{11}{3} & -\\frac{10}{3} & \\frac{23}{3} \\\\\n 4 & -\\frac{29}{3} & \\frac{41}{3} \\\\\n \\frac{35}{3} & 2 & \\frac{5}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/3), (13/3), (26/3)],\n [-(1/3), (5/3), (28/3)],\n [-(1/3), 0, (13/3)],\n [(14/3), (17/3), -(7/3)]])\nb = np.array([\n [(7/3), -(28/3), -(29/3)],\n [-(10/3), -5, -(5/3)],\n [(13/3), -(29/3), (28/3)],\n [7, -(11/3), 4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 10 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 25 \\\\\n 10 \\\\\n 20 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-1],\n [-2]])\nb = np.array([\n [0],\n [10],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\pi \\\\\n -\\pi \\\\\n -3 \\pi \\\\\n 3 \\pi \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\pi \\\\\n -\\pi \\\\\n 2 \\pi \\\\\n 2 \\pi \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4 \\pi ^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.pi],\n [-math.pi],\n [-3*math.pi],\n [3*math.pi],\n [0]])\nb = np.array([\n [3*math.pi],\n [-math.pi],\n [2*math.pi],\n [2*math.pi],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & -3 & 2 \\\\\n -2 & -3 & -3 \\\\\n 0 & -3 & 3 \\\\\n -1 & 1 & 0 \\\\\n -1 & -2 & 1 \\\\\n 1 & 3 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.97 \\\\\n -0.19 \\\\\n -0.59 \\\\\n -1.48 \\\\\n -0.38 \\\\\n -2.61 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.172 \\\\\n -0.283 \\\\\n 0.099 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, 2],\n [-2, -3, -3],\n [0, -3, 3],\n [-1, 1, 0],\n [-1, -2, 1],\n [1, 3, 0]])\nb = np.array([\n [2.97],\n [-0.19],\n [-0.59],\n [-1.48],\n [-0.38],\n [-2.61]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{4} & -\\frac{15}{2} \\\\\n -\\frac{5}{4} & \\frac{7}{4} \\\\\n -4 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/4), -(15/2)],\n [-(5/4), (7/4)],\n [-4, -5]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{14}{3} \\\\\n \\frac{16}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{13}{3} \\\\\n \\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}+\\tan ^{-1}\\left(\\frac{27}{160}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(14/3)],\n [(16/3)]]).squeeze()\nb = np.array([\n [(13/3)],\n [(8/3)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{97}{50} & -\\frac{243}{100} & -\\frac{123}{25} \\\\\n -\\frac{117}{25} & -\\frac{226}{25} & -\\frac{589}{100} \\\\\n -\\frac{133}{100} & \\frac{687}{100} & \\frac{173}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{9 x^2}{50}+\\frac{441213 x}{10000}+\\frac{76747667}{1000000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(97/50), -(243/100), -(123/25)],\n [-(117/25), -(226/25), -(589/100)],\n [-(133/100), (687/100), (173/25)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{18}{e} \\\\\n -\\frac{8}{e} \\\\\n -\\frac{10}{e} \\\\\n \\frac{1}{e} \\\\\n -\\frac{20}{e} \\\\\n -\\frac{17}{e} \\\\\n -\\frac{11}{e} \\\\\n \\frac{20}{e} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{e} \\\\\n -\\frac{13}{e} \\\\\n -\\frac{7}{e} \\\\\n \\frac{5}{e} \\\\\n -\\frac{10}{e} \\\\\n -\\frac{2}{e} \\\\\n -\\frac{18}{e} \\\\\n -\\frac{15}{e} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{1938}}{e}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(18/math.e)],\n [-(8/math.e)],\n [-(10/math.e)],\n [(1/math.e)],\n [-(20/math.e)],\n [-(17/math.e)],\n [-(11/math.e)],\n [(20/math.e)]])\nb = np.array([\n [-(1/math.e)],\n [-(13/math.e)],\n [-(7/math.e)],\n [(5/math.e)],\n [-(10/math.e)],\n [-(2/math.e)],\n [-(18/math.e)],\n [-(15/math.e)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & -3 & 2 & 0 \\\\\n 0 & 3 & 2 & 1 \\\\\n 2 & 0 & 0 & -3 \\\\\n 0 & -2 & -2 & 1 \\\\\n 3 & -1 & 1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.35 \\\\\n 2.07 \\\\\n 2.55 \\\\\n 0.61 \\\\\n 0.19 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.446 \\\\\n 0.394 \\\\\n -0.072 \\\\\n -0.281 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -3, 2, 0],\n [0, 3, 2, 1],\n [2, 0, 0, -3],\n [0, -2, -2, 1],\n [3, -1, 1, 1]])\nb = np.array([\n [-1.35],\n [2.07],\n [2.55],\n [0.61],\n [0.19]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n -1 & 6 & 3 \\\\\n 2 & 4 & 8 \\\\\n 0 & -5 & 3 \\\\\n -3 & -6 & -5 \\\\\n 3 & 4 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 6, 3],\n [2, 4, 8],\n [0, -5, 3],\n [-3, -6, -5],\n [3, 4, 1]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -3 & 8 & 8 & 1 \\\\\n -2 & 1 & 5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & -\\frac{32}{13} & \\frac{33}{13} \\\\\n 0 & 1 & \\frac{1}{13} & \\frac{14}{13} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 8, 8, 1],\n [-2, 1, 5, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n \\frac{13}{10} & 1 \\\\\n -\\frac{9}{5} & \\frac{5}{2} \\\\\n \\frac{11}{5} & \\frac{23}{10} \\\\\n \\frac{3}{2} & -\\frac{14}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{23}{10} & -\\frac{29}{10} & -\\frac{5}{2} \\\\\n -\\frac{11}{10} & -\\frac{13}{5} & \\frac{3}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{189}{100} & -\\frac{637}{100} & -\\frac{59}{20} \\\\\n -\\frac{689}{100} & -\\frac{32}{25} & \\frac{21}{4} \\\\\n \\frac{253}{100} & -\\frac{309}{25} & -\\frac{481}{100} \\\\\n \\frac{653}{100} & \\frac{293}{100} & -\\frac{459}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/10), 1],\n [-(9/5), (5/2)],\n [(11/5), (23/10)],\n [(3/2), -(14/5)]])\nb = np.array([\n [(23/10), -(29/10), -(5/2)],\n [-(11/10), -(13/5), (3/10)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 6 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 8 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -16 \\\\\n 50 \\\\\n -76 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [6],\n [5]])\nb = np.array([\n [6],\n [8],\n [4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{31}{9} \\\\\n -\\frac{35}{9} \\\\\n \\frac{2}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{68}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(31/9)],\n [-(35/9)],\n [(2/9)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -7 \\\\\n 6 \\\\\n -9 \\\\\n 4 \\\\\n 3 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-7],\n [6],\n [-9],\n [4],\n [3],\n [-3]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 8 & -5 & 3 & -6 \\\\\n 4 & 10 & 10 & -8 \\\\\n -2 & 10 & 5 & 3 \\\\\n 5 & -1 & -7 & 8 \\\\\n -9 & -3 & -9 & 5 \\\\\n 2 & -1 & 2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, -5, 3, -6],\n [4, 10, 10, -8],\n [-2, 10, 5, 3],\n [5, -1, -7, 8],\n [-9, -3, -9, 5],\n [2, -1, 2, 1]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n \\frac{3}{5} \\\\\n -\\frac{8}{5} \\\\\n \\frac{7}{10} \\\\\n -\\frac{27}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3 \\sqrt{\\frac{5}{259}} \\\\\n \\frac{6}{\\sqrt{1295}} \\\\\n -\\frac{16}{\\sqrt{1295}} \\\\\n \\sqrt{\\frac{7}{185}} \\\\\n -\\frac{27}{\\sqrt{1295}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2)],\n [(3/5)],\n [-(8/5)],\n [(7/10)],\n [-(27/10)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{13}{3}, -\\frac{2}{3}, -1}$ to the plane $\\frac{10 x}{3}-y-\\frac{10}{3}=0$.", - "Output Answer": [ - "$\\frac{154}{3 \\sqrt{109}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(13/3), -(2/3), -1\nplane = Poly(((10*x)/3)-y-(10/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n 7 & 6 \\\\\n 4 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 6],\n [4, -2]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 3 & -2 \\\\\n -4 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{5} & -\\frac{2}{5} \\\\\n -\\frac{4}{5} & -\\frac{3}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2],\n [-4, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -2 & -3 & -2 & -2 \\\\\n -1 & -3 & -3 & -3 \\\\\n -2 & -2 & -2 & -1 \\\\\n -1 & -3 & -3 & 0 \\\\\n 3 & -1 & 3 & 0 \\\\\n 0 & -2 & 0 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.1 \\\\\n 1. \\\\\n -0.78 \\\\\n 0.52 \\\\\n 2.65 \\\\\n 2.06 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.143 \\\\\n -0.73 \\\\\n 0.569 \\\\\n -0.279 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, -2, -2],\n [-1, -3, -3, -3],\n [-2, -2, -2, -1],\n [-1, -3, -3, 0],\n [3, -1, 3, 0],\n [0, -2, 0, -2]])\nb = np.array([\n [2.1],\n [1.],\n [-0.78],\n [0.52],\n [2.65],\n [2.06]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -2 & 10 & 0 & 1 & 1 \\\\\n 2 & -5 & -10 & -4 & -4 \\\\\n -2 & 6 & -2 & 7 & 5 \\\\\n -7 & 5 & -9 & 1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{10.,-62.,-223.,-1627.,2267.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, 10, 0, 1, 1],\n [2, -5, -10, -4, -4],\n [-2, 6, -2, 7, 5],\n [-7, 5, -9, 1, 0]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & -1 & -3 & -1 \\\\\n 2 & -1 & 3 & 3 \\\\\n 2 & 3 & 3 & 1 \\\\\n -1 & 0 & -3 & -2 \\\\\n 2 & 3 & 2 & 2 \\\\\n 1 & -1 & -2 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.31 \\\\\n 1.17 \\\\\n -2.75 \\\\\n 1.03 \\\\\n 0.65 \\\\\n -2.2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.136 \\\\\n -0.355 \\\\\n 0.285 \\\\\n -0.285 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -1, -3, -1],\n [2, -1, 3, 3],\n [2, 3, 3, 1],\n [-1, 0, -3, -2],\n [2, 3, 2, 2],\n [1, -1, -2, 3]])\nb = np.array([\n [-0.31],\n [1.17],\n [-2.75],\n [1.03],\n [0.65],\n [-2.2]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 4 & -6 \\\\\n 7 & -7 \\\\\n 10 & 10 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 7 & 1 \\\\\n -8 & -2 \\\\\n -6 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -3 & -7 \\\\\n 15 & -5 \\\\\n 16 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -6],\n [7, -7],\n [10, 10]])\nb = np.array([\n [7, 1],\n [-8, -2],\n [-6, 6]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -9 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 1 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -80 \\\\\n 32 \\\\\n 16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-9],\n [8]])\nb = np.array([\n [2],\n [1],\n [8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 2 \\\\\n 1 \\\\\n -5 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -8 \\\\\n 7 \\\\\n -9 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$42$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [2],\n [1],\n [-5],\n [-3]])\nb = np.array([\n [-8],\n [-8],\n [7],\n [-9],\n [-2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{2}{5} \\\\\n -\\frac{36}{5} \\\\\n -\\frac{21}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{21}{5} \\\\\n -\\frac{19}{5} \\\\\n \\frac{14}{5} \\\\\n \\frac{29}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1075}{\\sqrt{3201699}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-(2/5)],\n [-(36/5)],\n [-(21/5)]]).squeeze()\nb = np.array([\n [-(21/5)],\n [-(19/5)],\n [(14/5)],\n [(29/5)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{4} & -9 \\\\\n -3 & \\frac{11}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{12} \\left(5-\\sqrt{457}\\right),1\\right\\}, \\left\\{\\frac{1}{12} \\left(5+\\sqrt{457}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/4), -9],\n [-3, (11/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -3 & 8 \\\\\n 7 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+2 x-59$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 8],\n [7, 1]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{23}{4} \\\\\n -\\frac{11}{4} \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{35}{4} \\\\\n \\frac{37}{4} \\\\\n -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -40 \\\\\n \\frac{19}{2} \\\\\n -\\frac{233}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/4)],\n [-(11/4)],\n [7]])\nb = np.array([\n [(35/4)],\n [(37/4)],\n [-9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{4}{3} \\\\\n \\frac{8}{3} \\\\\n -2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{3} \\\\\n \\frac{23}{3} \\\\\n \\frac{23}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{17}{3} \\\\\n -5 \\\\\n -\\frac{29}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3)],\n [(8/3)],\n [-2]])\nb = np.array([\n [-(13/3)],\n [(23/3)],\n [(23/3)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -7 & 9 \\\\\n -8 & -6 \\\\\n -4 & -1 \\\\\n -6 & 6 \\\\\n 4 & -8 \\\\\n 8 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, 9],\n [-8, -6],\n [-4, -1],\n [-6, 6],\n [4, -8],\n [8, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -4 \\\\\n 6 \\\\\n -9 \\\\\n -9 \\\\\n 8 \\\\\n -9 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{433}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-4],\n [6],\n [-9],\n [-9],\n [8],\n [-9],\n [-5]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 1 & -4 & -4 & -7 \\\\\n -1 & 9 & -1 & 7 \\\\\n 5 & -9 & -7 & 9 \\\\\n 3 & -3 & 3 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 9 & -3 & 4 & 2 \\\\\n 5 & 7 & 5 & -4 \\\\\n 9 & -1 & 8 & 9 \\\\\n 4 & -9 & 2 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 10 & -7 & 0 & -5 \\\\\n 4 & 16 & 4 & 3 \\\\\n 14 & -10 & 1 & 18 \\\\\n 7 & -12 & 5 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -4, -4, -7],\n [-1, 9, -1, 7],\n [5, -9, -7, 9],\n [3, -3, 3, 0]])\nb = np.array([\n [9, -3, 4, 2],\n [5, 7, 5, -4],\n [9, -1, 8, 9],\n [4, -9, 2, -5]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -9 & 0 & -10 \\\\\n 3 & 3 & -8 \\\\\n -9 & 9 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{10.,2.,9.\\}, \\{-0.667-0.471 i,0.556\\, -1.257 i,1.\\}, \\{-0.667+0.471 i,0.556\\, +1.257 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 0, -10],\n [3, 3, -8],\n [-9, 9, -10]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 6 & 2 \\\\\n -4 & -3 \\\\\n -1 & -10 \\\\\n 1 & 3 \\\\\n -7 & 10 \\\\\n 9 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, 2],\n [-4, -3],\n [-1, -10],\n [1, 3],\n [-7, 10],\n [9, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & -4 \\\\\n -3 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-1-2 \\sqrt{19},2 \\sqrt{19}-1\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -4],\n [-3, -9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & \\frac{26}{3} \\\\\n \\frac{2}{3} & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{3} \\left(27-2 \\sqrt{13}\\right),\\frac{1}{3} \\left(27+2 \\sqrt{13}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, (26/3)],\n [(2/3), 9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -2 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-2],\n [-7]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n -3 & -2 & 5 & 25 \\\\\n -4 & -2 & 5 & 28 \\\\\n 1 & 3 & -5 & -22 \\\\\n -1 & -1 & 2 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{7}{2} & -\\frac{5}{2} & \\frac{11}{2} & 32 \\\\\n -\\frac{11}{2} & -2 & 6 & \\frac{75}{2} \\\\\n 2 & \\frac{17}{6} & -\\frac{23}{6} & -\\frac{145}{6} \\\\\n -\\frac{3}{2} & -\\frac{7}{6} & \\frac{13}{6} & \\frac{40}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [-3, -2, 5, 25],\n [-4, -2, 5, 28],\n [1, 3, -5, -22],\n [-1, -1, 2, 10]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -1 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -3 \\\\\n -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 21 \\\\\n -22 \\\\\n 26 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-1],\n [4]])\nb = np.array([\n [8],\n [-3],\n [-9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{11}{8}, -\\frac{21}{8}}$ to the line $\\frac{75 x}{32}-\\frac{67 y}{32}+\\frac{33}{32}=0$.", - "Output Answer": [ - "$\\frac{423}{4 \\sqrt{10114}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(11/8), -(21/8)\nline = Poly(((75*x)/32)-((67*y)/32)+(33/32), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{13}{3} & \\frac{16}{3} \\\\\n -1 & \\frac{28}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{6} \\left(41-\\sqrt{1489}\\right),1\\right\\}, \\left\\{\\frac{1}{6} \\left(41+\\sqrt{1489}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/3), (16/3)],\n [-1, (28/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,-4,-3\\}, \\{-3,2,-3\\}, \\{1,-2,-2\\}}$.", - "Output Answer": [ - "$x+y+1=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, -4, -3],\n [-3, 2, -3],\n [1, -2, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{15}{2} & -\\frac{35}{6} \\\\\n -6 & \\frac{55}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{50 x}{3}+\\frac{135}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/2), -(35/6)],\n [-6, (55/6)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & -1 & -6 \\\\\n -3 & -5 & 0 \\\\\n 3 & 0 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-3.759,-40.865,1.\\}, \\{-0.287-1.367 i,-0.068+0.377 i,1.\\}, \\{-0.287+1.367 i,-0.068-0.377 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -1, -6],\n [-3, -5, 0],\n [3, 0, 6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{11}{3},-\\frac{10}{3},-4\\right\\}, \\left\\{-\\frac{1}{3},\\frac{8}{3},\\frac{2}{3}\\right\\}, \\left\\{-3,-\\frac{11}{3},\\frac{2}{3}\\right\\}}$.", - "Output Answer": [ - "$133 x-56 y-23 z+209=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(11/3), -(10/3), -4],\n [-(1/3), (8/3), (2/3)],\n [-3, -(11/3), (2/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 8 \\\\\n 1 \\\\\n -7 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{203}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [8],\n [1],\n [-7],\n [5]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 1 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -32 \\\\\n 108 \\\\\n 18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [1],\n [10]])\nb = np.array([\n [9],\n [3],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 1 & -2 & -3 \\\\\n 0 & 2 & 3 \\\\\n -2 & 1 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -3 & 3 & -3 & -1 & -2 \\\\\n 0 & -3 & -2 & -1 & -1 \\\\\n 0 & -1 & 1 & -2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -3 & 12 & -2 & 7 & 6 \\\\\n 0 & -9 & -1 & -8 & -8 \\\\\n 6 & -9 & 4 & 1 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2, -3],\n [0, 2, 3],\n [-2, 1, 0]])\nb = np.array([\n [-3, 3, -3, -1, -2],\n [0, -3, -2, -1, -1],\n [0, -1, 1, -2, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 3 & \\frac{6}{7} \\\\\n 4 & -\\frac{33}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{11}{41} & \\frac{2}{41} \\\\\n \\frac{28}{123} & -\\frac{7}{41} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, (6/7)],\n [4, -(33/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 2 \\\\\n -10 \\\\\n -3 \\\\\n 9 \\\\\n 6 \\\\\n -2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{73}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [2],\n [-10],\n [-3],\n [9],\n [6],\n [-2],\n [3]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{22}{3} \\\\\n 4 \\\\\n \\frac{38}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n \\frac{50}{9} \\\\\n \\frac{29}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{856}{81} \\\\\n \\frac{1664}{27} \\\\\n -\\frac{2072}{27} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(22/3)],\n [4],\n [(38/9)]])\nb = np.array([\n [9],\n [(50/9)],\n [(29/9)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -3 & -5 \\\\\n 9 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-5-i \\sqrt{41},-5+i \\sqrt{41}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -5],\n [9, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -9 & 10 \\\\\n -10 & -7 \\\\\n 5 & 7 \\\\\n 9 & -5 \\\\\n 8 & -7 \\\\\n -6 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-9, 10],\n [-10, -7],\n [5, 7],\n [9, -5],\n [8, -7],\n [-6, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,-2,0\\}, \\{0,0,0\\}, \\{-3,-2,2\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{2}},-\\frac{1}{\\sqrt{2}},0\\right\\}, \\{0,0,0\\}, \\left\\{-\\frac{5}{\\sqrt{66}},-\\frac{5}{\\sqrt{66}},2 \\sqrt{\\frac{2}{33}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, -2, 0), (0, 0, 0), (-3, -2, 2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -8 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -32 \\\\\n 64 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-8],\n [-4]])\nb = np.array([\n [7],\n [-4],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 6 & 2 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -5 & -5 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & -3 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 2, 0]])\nb = np.array([\n [-5, -5, -3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{8} & 1 & \\frac{5}{8} \\\\\n -\\frac{1}{4} & -\\frac{17}{4} & -\\frac{35}{4} \\\\\n \\frac{23}{4} & \\frac{5}{4} & \\frac{15}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{25 x^2}{8}+\\frac{395 x}{16}-\\frac{3935}{128}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/8), 1, (5/8)],\n [-(1/4), -(17/4), -(35/4)],\n [(23/4), (5/4), (15/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{17}{3} & -\\frac{1}{3} \\\\\n \\frac{11}{3} & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{6} \\left(29-i \\sqrt{19}\\right),\\frac{1}{6} \\left(29+i \\sqrt{19}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/3), -(1/3)],\n [(11/3), 4]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{14}{5} \\\\\n -\\frac{13}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{8}{5} \\\\\n \\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10},\\frac{1}{10}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/5)],\n [-(13/5)]]).squeeze()\nb = np.array([\n [(8/5)],\n [(8/5)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -\\frac{4}{5} \\\\\n -\\frac{12}{5} \\\\\n \\frac{7}{5} \\\\\n \\frac{1}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{26}{5} \\\\\n \\frac{18}{5} \\\\\n \\frac{3}{5} \\\\\n -\\frac{7}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{\\frac{69}{5}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-(4/5)],\n [-(12/5)],\n [(7/5)],\n [(1/5)]])\nb = np.array([\n [2],\n [(26/5)],\n [(18/5)],\n [(3/5)],\n [-(7/5)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{977}{100} & \\frac{23}{10} \\\\\n \\frac{133}{25} & \\frac{447}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{356 x}{25}+\\frac{314359}{10000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(977/100), (23/10)],\n [(133/25), (447/100)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 10 & 7 \\\\\n -3 & 9 \\\\\n 10 & 4 \\\\\n -5 & 1 \\\\\n 5 & -3 \\\\\n -2 & 1 \\\\\n 9 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, 7],\n [-3, 9],\n [10, 4],\n [-5, 1],\n [5, -3],\n [-2, 1],\n [9, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & \\frac{14}{3} & -8 \\\\\n -5 & 6 & \\frac{28}{3} \\\\\n -\\frac{17}{3} & \\frac{22}{3} & \\frac{17}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-4.094,2.615,15.146\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, (14/3), -8],\n [-5, 6, (28/3)],\n [-(17/3), (22/3), (17/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 1 & -\\frac{10}{3} \\\\\n \\frac{1}{6} & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{18}{23} & \\frac{30}{23} \\\\\n -\\frac{3}{46} & \\frac{9}{23} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(10/3)],\n [(1/6), 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 2 \\\\\n 8 \\\\\n -7 \\\\\n 0 \\\\\n 10 \\\\\n 7 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 5 \\\\\n -4 \\\\\n -4 \\\\\n -4 \\\\\n 6 \\\\\n 6 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{130}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [2],\n [8],\n [-7],\n [0],\n [10],\n [7],\n [6]])\nb = np.array([\n [2],\n [5],\n [-4],\n [-4],\n [-4],\n [6],\n [6],\n [-9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 5 & 8 \\\\\n 4 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+2 x-67$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 8],\n [4, -7]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 0 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 8 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -48 \\\\\n 52 \\\\\n 16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [0],\n [6]])\nb = np.array([\n [8],\n [8],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 4 & -4 & 2 \\\\\n 1 & 4 & 0 \\\\\n 5 & -3 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{8}{17} & \\frac{5}{17} & -\\frac{4}{17} \\\\\n -\\frac{2}{17} & \\frac{3}{17} & \\frac{1}{17} \\\\\n -\\frac{23}{34} & -\\frac{4}{17} & \\frac{10}{17} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -4, 2],\n [1, 4, 0],\n [5, -3, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{1}{2},-\\frac{7}{2},0\\right\\}, \\left\\{-\\frac{7}{2},-1,-1\\right\\}, \\left\\{-1,\\frac{1}{2},-1\\right\\}}$.", - "Output Answer": [ - "$6 x-10 y-49 z-38=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(1/2), -(7/2), 0],\n [-(7/2), -1, -1],\n [-1, (1/2), -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{10}{3} & 3 \\\\\n 1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{49}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(10/3), 3],\n [1, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{56}{9} & -\\frac{13}{3} & -\\frac{76}{9} \\\\\n -3 & \\frac{17}{3} & -\\frac{10}{3} \\\\\n -\\frac{50}{9} & -\\frac{70}{9} & -7 \\\\\n -\\frac{49}{9} & -10 & -\\frac{80}{9} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 1 & \\frac{13}{9} & \\frac{52}{9} \\\\\n -5 & -\\frac{53}{9} & -\\frac{49}{9} \\\\\n \\frac{40}{9} & -\\frac{4}{3} & \\frac{11}{3} \\\\\n \\frac{10}{3} & -\\frac{28}{9} & -\\frac{20}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{65}{9} & -\\frac{52}{9} & -\\frac{128}{9} \\\\\n 2 & \\frac{104}{9} & \\frac{19}{9} \\\\\n -10 & -\\frac{58}{9} & -\\frac{32}{3} \\\\\n -\\frac{79}{9} & -\\frac{62}{9} & -\\frac{20}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(56/9), -(13/3), -(76/9)],\n [-3, (17/3), -(10/3)],\n [-(50/9), -(70/9), -7],\n [-(49/9), -10, -(80/9)]])\nb = np.array([\n [1, (13/9), (52/9)],\n [-5, -(53/9), -(49/9)],\n [(40/9), -(4/3), (11/3)],\n [(10/3), -(28/9), -(20/3)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 8 \\\\\n 9 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 3 \\\\\n -7 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{349}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [8],\n [9],\n [4]])\nb = np.array([\n [-9],\n [3],\n [-7],\n [6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{11}{5}, -4, \\frac{22}{5}}$ to the plane $-\\frac{21 x}{5}+\\frac{23 y}{5}+\\frac{21 z}{5}+1=0$.", - "Output Answer": [ - "$\\frac{12 \\sqrt{\\frac{17}{83}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (11/5), -4, (22/5)\nplane = Poly(-((21*x)/5)+((23*y)/5)+((21*z)/5)+1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 3+4 i & -3-2 i \\\\\n -2-2 i & 4-4 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -5+34 i & -21-14 i \\\\\n -14-14 i & 2-22 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3+4j, -3-2j],\n [-2-2j, 4-4j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{11}{10}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & 4 & 1 & 9 \\\\\n -8 & 2 & -5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{11}{10} & \\frac{22}{5} & \\frac{11}{10} & \\frac{99}{10} \\\\\n -\\frac{44}{5} & \\frac{11}{5} & -\\frac{11}{2} & -\\frac{22}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 4, 1, 9],\n [-8, 2, -5, -4]])\nprint(a * (11/10))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{9}{8} \\\\\n \\frac{3}{8} \\\\\n \\frac{19}{8} \\\\\n \\frac{5}{2} \\\\\n -\\frac{5}{8} \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{9}{2 \\sqrt{235}} \\\\\n \\frac{3}{2 \\sqrt{235}} \\\\\n \\frac{19}{2 \\sqrt{235}} \\\\\n 2 \\sqrt{\\frac{5}{47}} \\\\\n -\\frac{\\sqrt{\\frac{5}{47}}}{2} \\\\\n \\frac{4}{\\sqrt{235}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/8)],\n [(3/8)],\n [(19/8)],\n [(5/2)],\n [-(5/8)],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{3} & \\frac{14}{9} & -\\frac{23}{9} \\\\\n \\frac{37}{9} & -\\frac{26}{9} & \\frac{35}{9} \\\\\n -\\frac{22}{9} & \\frac{17}{9} & -\\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{2547}{5026} & \\frac{2007}{5026} & \\frac{486}{2513} \\\\\n \\frac{1467}{2513} & \\frac{2115}{2513} & \\frac{3357}{2513} \\\\\n -\\frac{513}{5026} & \\frac{2313}{5026} & \\frac{1980}{2513} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/3), (14/9), -(23/9)],\n [(37/9), -(26/9), (35/9)],\n [-(22/9), (17/9), -(4/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{13}{5},0,-3\\right\\}, \\left\\{\\frac{7}{5},2,-\\frac{6}{5}\\right\\}, \\left\\{-\\frac{2}{5},3,-\\frac{3}{5}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{13}{\\sqrt{394}},0,-\\frac{15}{\\sqrt{394}}\\right\\}, \\left\\{\\frac{2745}{\\sqrt{28718266}},10 \\sqrt{\\frac{394}{72889}},-\\frac{2379}{\\sqrt{28718266}}\\right\\}, \\left\\{-\\frac{150}{\\sqrt{72889}},\\frac{183}{\\sqrt{72889}},\\frac{130}{\\sqrt{72889}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-(13/5), 0, -3), ((7/5), 2, -(6/5)), (-(2/5), 3, -(3/5))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -1 & 9 \\\\\n 7 & -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 7 & 3 \\\\\n 0 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 6 & 12 \\\\\n 7 & -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 9],\n [7, -4]])\nb = np.array([\n [7, 3],\n [0, -4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 7 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -32 \\\\\n 28 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [0],\n [0]])\nb = np.array([\n [-6],\n [7],\n [8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & 1 & -1 \\\\\n -5 & -2 & -3 \\\\\n 1 & -1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 1, -1],\n [-5, -2, -3],\n [1, -1, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & -5 \\\\\n 2 & 0 & 4 \\\\\n -3 & 2 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, -5],\n [2, 0, 4],\n [-3, 2, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & 2 \\\\\n 1 & 0 \\\\\n -1 & -2 \\\\\n -2 & 0 \\\\\n -1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.1 \\\\\n 1.02 \\\\\n 2.25 \\\\\n -2.85 \\\\\n -1.79 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.091 \\\\\n -0.283 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2],\n [1, 0],\n [-1, -2],\n [-2, 0],\n [-1, 1]])\nb = np.array([\n [2.1],\n [1.02],\n [2.25],\n [-2.85],\n [-1.79]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{ccc}\n 6 & -9 & 48 \\\\\n -6 & 9 & -43 \\\\\n -2 & 3 & -15 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 4 & -\\frac{9}{2} & \\frac{51}{2} \\\\\n -8 & 13 & -58 \\\\\n -2 & 3 & -14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [6, -9, 48],\n [-6, 9, -43],\n [-2, 3, -15]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 9 \\\\\n 10 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -7 \\\\\n 1 \\\\\n 1 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$13$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [9],\n [10],\n [-1],\n [-1]])\nb = np.array([\n [-8],\n [-7],\n [1],\n [1],\n [5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 7 \\\\\n 4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [7],\n [4],\n [-2]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{73}{8} \\\\\n 8 \\\\\n \\frac{17}{4} \\\\\n -\\frac{21}{8} \\\\\n \\frac{31}{8} \\\\\n \\frac{37}{4} \\\\\n -\\frac{53}{8} \\\\\n -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$44$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(73/8)],\n [8],\n [(17/4)],\n [-(21/8)],\n [(31/8)],\n [(37/4)],\n [-(53/8)],\n [-(1/4)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & 7 \\\\\n 9 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{6} \\left(1-\\sqrt{29}\\right),1\\right\\}, \\left\\{\\frac{1}{6} \\left(1+\\sqrt{29}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 7],\n [9, -7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,-3,-1\\}, \\{0,-1,0\\}, \\{3,0,-3\\}}$.", - "Output Answer": [ - "$7 x-3 y+6 z-3=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, -3, -1],\n [0, -1, 0],\n [3, 0, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & 2 & 2 & 2 \\\\\n 2 & -3 & 3 & -3 \\\\\n 0 & -2 & 1 & 2 \\\\\n 1 & -1 & 3 & -2 \\\\\n 3 & 0 & 3 & 3 \\\\\n -3 & -3 & -3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.92 \\\\\n -2.41 \\\\\n -0.06 \\\\\n 1.94 \\\\\n 2.47 \\\\\n 1.35 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.475 \\\\\n -0.106 \\\\\n -0.234 \\\\\n 0.407 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2, 2, 2],\n [2, -3, 3, -3],\n [0, -2, 1, 2],\n [1, -1, 3, -2],\n [3, 0, 3, 3],\n [-3, -3, -3, 2]])\nb = np.array([\n [-1.92],\n [-2.41],\n [-0.06],\n [1.94],\n [2.47],\n [1.35]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7.54 \\\\\n 1.21 \\\\\n 8.83 \\\\\n 6.5 \\\\\n 4.91 \\\\\n 1.99 \\\\\n -5.72 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -0.41 \\\\\n -9.64 \\\\\n -7.49 \\\\\n -2.89 \\\\\n -1.5 \\\\\n -0.94 \\\\\n 7.22 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$27.2064$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7.54],\n [1.21],\n [8.83],\n [6.5],\n [4.91],\n [1.99],\n [-5.72]])\nb = np.array([\n [-0.41],\n [-9.64],\n [-7.49],\n [-2.89],\n [-1.5],\n [-0.94],\n [7.22]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{11}{9}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -10 & 1 \\\\\n -4 & -2 \\\\\n 7 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{110}{9} & -\\frac{11}{9} \\\\\n \\frac{44}{9} & \\frac{22}{9} \\\\\n -\\frac{77}{9} & -11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 1],\n [-4, -2],\n [7, 9]])\nprint(a * -(11/9))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{137}{16} \\\\\n -\\frac{11}{8} \\\\\n \\frac{91}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{\\frac{13767}{2}}}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(137/16)],\n [-(11/8)],\n [(91/16)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 6 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -8 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 32 \\\\\n 60 \\\\\n -56 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [6],\n [7]])\nb = np.array([\n [8],\n [-8],\n [-4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 9 \\\\\n 6 \\\\\n 3 \\\\\n 3 \\\\\n -3 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -1 \\\\\n -6 \\\\\n 6 \\\\\n -2 \\\\\n 6 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-111$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [9],\n [6],\n [3],\n [3],\n [-3],\n [4]])\nb = np.array([\n [-4],\n [-1],\n [-6],\n [6],\n [-2],\n [6],\n [-7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{25}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{25}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(25/3)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{14}{3} & -\\frac{29}{6} \\\\\n \\frac{9}{2} & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{317}{12}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/3), -(29/6)],\n [(9/2), 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{5}{2} \\\\\n -\\frac{3}{2} \\\\\n 0 \\\\\n -1 \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{5}{\\sqrt{39}} \\\\\n -\\sqrt{\\frac{3}{13}} \\\\\n 0 \\\\\n -\\frac{2}{\\sqrt{39}} \\\\\n -\\frac{1}{\\sqrt{39}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [(5/2)],\n [-(3/2)],\n [0],\n [-1],\n [-(1/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{43}{5} & \\frac{13}{5} & -\\frac{39}{5} \\\\\n -\\frac{27}{5} & -\\frac{43}{5} & -\\frac{21}{5} \\\\\n -\\frac{24}{5} & \\frac{29}{5} & -\\frac{34}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8.766-6.189 i,-8.766+6.189 i,10.732\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(43/5), (13/5), -(39/5)],\n [-(27/5), -(43/5), -(21/5)],\n [-(24/5), (29/5), -(34/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -1 & -1 & 4 & -9 & 8 \\\\\n -8 & 10 & -2 & 6 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-14.,-13.,0.,3.,0.\\}, \\{19.,17.,9.,0.,0.\\}, \\{40.,32.,0.,0.,9.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, -1, 4, -9, 8],\n [-8, 10, -2, 6, 0]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{4}{5}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 2 \\\\\n 9 & -7 \\\\\n 1 & 7 \\\\\n 3 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{12}{5} & -\\frac{8}{5} \\\\\n -\\frac{36}{5} & \\frac{28}{5} \\\\\n -\\frac{4}{5} & -\\frac{28}{5} \\\\\n -\\frac{12}{5} & \\frac{28}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2],\n [9, -7],\n [1, 7],\n [3, -7]])\nprint(a * -(4/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & -3 \\\\\n 6 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+7 x+24$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -3],\n [6, -1]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$86$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [2]])\nb = np.array([\n [8],\n [3]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{16}{3} \\\\\n \\frac{23}{3} \\\\\n \\frac{16}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n \\frac{17}{3} \\\\\n 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{203}{9} \\\\\n -\\frac{64}{3} \\\\\n \\frac{73}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(16/3)],\n [(23/3)],\n [(16/3)]])\nb = np.array([\n [-5],\n [(17/3)],\n [1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 \\pi \\\\\n -3 \\pi \\\\\n -2 \\pi \\\\\n -\\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\pi \\\\\n -\\pi \\\\\n \\pi \\\\\n -\\pi \\\\\n -\\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-3 \\pi ^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [3*math.pi],\n [-3*math.pi],\n [-2*math.pi],\n [-math.pi]])\nb = np.array([\n [-2*math.pi],\n [-math.pi],\n [math.pi],\n [-math.pi],\n [-math.pi]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, \\frac{4}{7}}$ to the line $-\\frac{19 x}{7}-\\frac{24 y}{7}-\\frac{23}{7}=0$.", - "Output Answer": [ - "$\\frac{656}{7 \\sqrt{937}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, (4/7)\nline = Poly(-((19*x)/7)-((24*y)/7)-(23/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{4}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -1 \\\\\n 7 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{15}{2} \\\\\n -\\frac{5}{4} \\\\\n \\frac{35}{4} \\\\\n \\frac{25}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-1],\n [7],\n [10]])\nprint(a * (5/4))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -2 & 2 \\\\\n 4 & 3 & -3 \\\\\n 4 & -3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-44$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2, 2],\n [4, 3, -3],\n [4, -3, -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 2 & \\frac{7}{2} \\\\\n 2 & 4 \\\\\n 4 & -1 \\\\\n -6 & \\frac{15}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -4 & 8 \\\\\n \\frac{3}{2} & -5 \\\\\n -7 & \\frac{3}{2} \\\\\n -\\frac{7}{2} & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -2 & \\frac{23}{2} \\\\\n \\frac{7}{2} & -1 \\\\\n -3 & \\frac{1}{2} \\\\\n -\\frac{19}{2} & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, (7/2)],\n [2, 4],\n [4, -1],\n [-6, (15/2)]])\nb = np.array([\n [-4, 8],\n [(3/2), -5],\n [-7, (3/2)],\n [-(7/2), -(7/2)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -1 \\\\\n -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -3 \\\\\n -1 \\\\\n 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-2],\n [1]])\nb = np.array([\n [4],\n [-1],\n [-8]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{2} & -1 & -1 \\\\\n \\frac{1}{2} & -\\frac{1}{2} & -\\frac{5}{2} \\\\\n -1 & 2 & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{65}{8} & \\frac{21}{4} & -\\frac{11}{4} \\\\\n -\\frac{45}{8} & \\frac{21}{8} & \\frac{93}{8} \\\\\n \\frac{1}{4} & -\\frac{21}{2} & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), -1, -1],\n [(1/2), -(1/2), -(5/2)],\n [-1, 2, 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-5,-1,2\\}, \\{-1,-4,2\\}, \\{4,3,-4\\}}$.", - "Output Answer": [ - "$18 x+24 y+43 z+28=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-5, -1, 2],\n [-1, -4, 2],\n [4, 3, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & -2 & 2 \\\\\n 2 & 0 & 2 \\\\\n -1 & 2 & 3 \\\\\n 2 & -1 & -2 \\\\\n -3 & -1 & -1 \\\\\n 0 & 0 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.59 \\\\\n -1.05 \\\\\n -2.91 \\\\\n 0.81 \\\\\n 1.95 \\\\\n -2.49 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.311 \\\\\n -0.169 \\\\\n -0.652 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2, 2],\n [2, 0, 2],\n [-1, 2, 3],\n [2, -1, -2],\n [-3, -1, -1],\n [0, 0, -1]])\nb = np.array([\n [-2.59],\n [-1.05],\n [-2.91],\n [0.81],\n [1.95],\n [-2.49]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 3 & 5 & -6 \\\\\n 2 & -5 & 5 \\\\\n -6 & -7 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8.222-3.733 i,-8.222+3.733 i,5.445\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 5, -6],\n [2, -5, 5],\n [-6, -7, -9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 1 & 9 & 4 & -2 \\\\\n -4 & -8 & -7 & 4 \\\\\n -5 & -7 & -3 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 8 & -2 & 10 & -8 \\\\\n 4 & 3 & -9 & -4 \\\\\n 5 & -3 & -8 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 9 & 7 & 14 & -10 \\\\\n 0 & -5 & -16 & 0 \\\\\n 0 & -10 & -11 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 9, 4, -2],\n [-4, -8, -7, 4],\n [-5, -7, -3, -3]])\nb = np.array([\n [8, -2, 10, -8],\n [4, 3, -9, -4],\n [5, -3, -8, -2]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -9 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 7 \\\\\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -11 \\\\\n -2 \\\\\n 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-9],\n [1]])\nb = np.array([\n [-7],\n [7],\n [9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 1 \\\\\n 7 \\\\\n 8 \\\\\n 4 \\\\\n 10 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 2 \\\\\n -9 \\\\\n 2 \\\\\n -2 \\\\\n 6 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{413}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [1],\n [7],\n [8],\n [4],\n [10],\n [8]])\nb = np.array([\n [0],\n [2],\n [-9],\n [2],\n [-2],\n [6],\n [0]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & -2 \\\\\n -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2],\n [-1, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{3} & 4 & -5 \\\\\n -1 & -\\frac{4}{3} & -\\frac{2}{3} \\\\\n -2 & 2 & \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{914}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/3), 4, -5],\n [-1, -(4/3), -(2/3)],\n [-2, 2, (4/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -6 & 0 & 10 & -8 \\\\\n 0 & 3 & 8 & -7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 0 & 7 & 0 & -6 \\\\\n -3 & 7 & 9 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -6 & -7 & 10 & -2 \\\\\n 3 & -4 & -1 & -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 0, 10, -8],\n [0, 3, 8, -7]])\nb = np.array([\n [0, 7, 0, -6],\n [-3, 7, 9, 5]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -5 & 2 & 4 & 0 & -6 & 10 \\\\\n 7 & -5 & -10 & -6 & -2 & 7 \\\\\n 10 & -10 & -5 & -9 & -9 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & \\frac{12}{11} & \\frac{34}{11} & -\\frac{64}{11} \\\\\n 0 & 1 & 0 & \\frac{96}{55} & \\frac{206}{55} & -\\frac{557}{165} \\\\\n 0 & 0 & 1 & \\frac{27}{55} & \\frac{27}{55} & -\\frac{509}{165} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, 2, 4, 0, -6, 10],\n [7, -5, -10, -6, -2, 7],\n [10, -10, -5, -9, -9, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -8 & -4 & 0 & -5 & -5 & -8 & 6 \\\\\n -1 & -10 & -1 & 6 & -9 & 9 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & -\\frac{1}{19} & \\frac{37}{38} & \\frac{7}{38} & \\frac{29}{19} & -\\frac{7}{19} \\\\\n 0 & 1 & \\frac{2}{19} & -\\frac{53}{76} & \\frac{67}{76} & -\\frac{20}{19} & -\\frac{29}{38} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-8, -4, 0, -5, -5, -8, 6],\n [-1, -10, -1, 6, -9, 9, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{13}{7}, -\\frac{4}{7}}$ to the line $\\frac{20 x}{7}-\\frac{27 y}{7}-\\frac{9}{7}=0$.", - "Output Answer": [ - "$\\frac{305}{7 \\sqrt{1129}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (13/7), -(4/7)\nline = Poly(((20*x)/7)-((27*y)/7)-(9/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{2}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -7 \\\\\n 10 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2 \\\\\n -\\frac{7}{2} \\\\\n 5 \\\\\n -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-7],\n [10],\n [-7]])\nprint(a * (1/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{29}{3} & -7 \\\\\n \\frac{19}{3} & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{19} \\left(-25-\\sqrt{226}\\right),1\\right\\}, \\left\\{\\frac{1}{19} \\left(\\sqrt{226}-25\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/3), -7],\n [(19/3), 7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 6 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 2 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -34 \\\\\n -54 \\\\\n 26 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [6],\n [2]])\nb = np.array([\n [-7],\n [2],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{3} \\\\\n -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{11}{25},-\\frac{44}{75}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/3)],\n [-(8/3)]]).squeeze()\nb = np.array([\n [-2],\n [-(8/3)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & -5 \\\\\n -5 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-13 x+15$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -5],\n [-5, 5]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{11}{5}, -\\frac{9}{5}}$ to the line $-2 x-\\frac{14 y}{5}-3=0$.", - "Output Answer": [ - "$\\frac{59}{10 \\sqrt{74}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (11/5), -(9/5)\nline = Poly(-2*x-((14*y)/5)-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{10}{7},-\\frac{3}{7},\\frac{19}{7}\\right\\}, \\left\\{\\frac{10}{7},-\\frac{5}{7},-3\\right\\}, \\left\\{\\frac{1}{7},-\\frac{15}{7},-\\frac{17}{7}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\sqrt{\\frac{10}{47}},-\\frac{3}{\\sqrt{470}},\\frac{19}{\\sqrt{470}}\\right\\}, \\left\\{\\frac{377 \\sqrt{\\frac{10}{242003}}}{3},-\\frac{1601}{3 \\sqrt{2420030}},-\\frac{2237}{3 \\sqrt{2420030}}\\right\\}, \\left\\{-\\frac{79}{3 \\sqrt{5149}},-\\frac{200}{3 \\sqrt{5149}},\\frac{10}{3 \\sqrt{5149}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack((((10/7), -(3/7), (19/7)), ((10/7), -(5/7), -3), ((1/7), -(15/7), -(17/7))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, -1, -5}$ to the plane $-x-3 y-4 z-3=0$.", - "Output Answer": [ - "$\\frac{23}{\\sqrt{26}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, -1, -5\nplane = Poly(-x-3*y-4*z-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 8 & -10 & -10 & -8 & 0 & -7 & -5 \\\\\n -9 & -9 & 8 & -6 & -2 & -6 & 2 \\\\\n 3 & 3 & 8 & 7 & -3 & -7 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & \\frac{361}{864} & -\\frac{205}{864} & -\\frac{781}{864} & \\frac{55}{216} \\\\\n 0 & 1 & 0 & \\frac{575}{864} & \\frac{133}{864} & \\frac{709}{864} & \\frac{17}{216} \\\\\n 0 & 0 & 1 & \\frac{15}{32} & -\\frac{11}{32} & -\\frac{27}{32} & \\frac{5}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, -10, -10, -8, 0, -7, -5],\n [-9, -9, 8, -6, -2, -6, 2],\n [3, 3, 8, 7, -3, -7, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -1 & -2 & -3 & 2 \\\\\n -3 & 9 & 6 & -2 \\\\\n 2 & 10 & 7 & 9 \\\\\n 2 & -1 & 0 & -9 \\\\\n 0 & -6 & -1 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, -3, 2],\n [-3, 9, 6, -2],\n [2, 10, 7, 9],\n [2, -1, 0, -9],\n [0, -6, -1, 7]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -9 & 3 \\\\\n -2 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} \\left(17-\\sqrt{265}\\right),1\\right\\}, \\left\\{\\frac{1}{4} \\left(17+\\sqrt{265}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 3],\n [-2, 8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4.472 \\\\\n -5.59 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1.829 \\\\\n 3.039 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10.6847$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4.472],\n [-5.59]])\nb = np.array([\n [1.829],\n [3.039]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & 1 & 3 & -2 \\\\\n -3 & 3 & 3 & 3 \\\\\n 0 & 3 & 2 & -2 \\\\\n 2 & -1 & -2 & 2 \\\\\n -1 & -1 & -1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.5 \\\\\n 1.5 \\\\\n -2.52 \\\\\n -1.3 \\\\\n -2.28 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.103 \\\\\n -1.405 \\\\\n 1.512 \\\\\n 0.011 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, 3, -2],\n [-3, 3, 3, 3],\n [0, 3, 2, -2],\n [2, -1, -2, 2],\n [-1, -1, -1, 3]])\nb = np.array([\n [2.5],\n [1.5],\n [-2.52],\n [-1.3],\n [-2.28]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{77}{10} & -\\frac{611}{100} \\\\\n \\frac{849}{100} & \\frac{351}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{17 x}{25}-\\frac{21801}{10000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(77/10), -(611/100)],\n [(849/100), (351/50)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & -9 & 7 \\\\\n 4 & -8 & 4 \\\\\n 10 & -5 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.712,-3.07,1.\\}, \\{-0.599,0.235,1.\\}, \\{0.771,0.355,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -9, 7],\n [4, -8, 4],\n [10, -5, 6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & -\\frac{14}{3} \\\\\n 2 & -\\frac{13}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{28}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -(14/3)],\n [2, -(13/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(-2 \\sqrt{5}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [0],\n [-1],\n [0],\n [1]]).squeeze()\nb = np.array([\n [1],\n [-1],\n [1],\n [0],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{5}{e},\\frac{6}{e},\\frac{1}{e}\\right\\}, \\left\\{\\frac{1}{e},-\\frac{1}{e},\\frac{1}{e}\\right\\}, \\left\\{\\frac{5}{e},\\frac{5}{e},\\frac{1}{e}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{5}{\\sqrt{62}},3 \\sqrt{\\frac{2}{31}},\\frac{1}{\\sqrt{62}}\\right\\}, \\left\\{\\frac{6}{\\sqrt{1333}},-\\frac{1}{\\sqrt{1333}},\\frac{36}{\\sqrt{1333}}\\right\\}, \\left\\{\\frac{7}{\\sqrt{86}},3 \\sqrt{\\frac{2}{43}},-\\frac{1}{\\sqrt{86}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-(5/math.e), (6/math.e), (1/math.e)), ((1/math.e), -(1/math.e), (1/math.e)), ((5/math.e), (5/math.e), (1/math.e))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & 1 \\\\\n 2 & -2 \\\\\n 3 & -3 \\\\\n 1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.95 \\\\\n 2.05 \\\\\n -1.95 \\\\\n 2.47 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.122 \\\\\n -0.122 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1],\n [2, -2],\n [3, -3],\n [1, -1]])\nb = np.array([\n [-2.95],\n [2.05],\n [-1.95],\n [2.47]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{9}{2}, 5, -\\frac{7}{2}}$ to the plane $5 x+\\frac{3 y}{2}+\\frac{5 z}{2}-2=0$.", - "Output Answer": [ - "$\\frac{77}{2 \\sqrt{134}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (9/2), 5, -(7/2)\nplane = Poly(5*x+((3*y)/2)+((5*z)/2)-2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -2 & -9 & \\frac{5}{2} \\\\\n \\frac{13}{2} & -\\frac{13}{2} & \\frac{1}{2} \\\\\n -1 & \\frac{1}{2} & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-4.204-7.418 i,-4.204+7.418 i,2.908\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -9, (5/2)],\n [(13/2), -(13/2), (1/2)],\n [-1, (1/2), 3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 8 & 6 & -\\frac{3}{2} & -6 \\\\\n \\frac{3}{2} & -\\frac{7}{2} & -\\frac{19}{2} & -\\frac{3}{2} \\\\\n 9 & -\\frac{11}{2} & \\frac{11}{2} & \\frac{7}{2} \\\\\n \\frac{1}{2} & \\frac{3}{2} & \\frac{17}{2} & -9 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -3 & \\frac{7}{2} & 2 & -\\frac{11}{2} \\\\\n 6 & -3 & -\\frac{13}{2} & 8 \\\\\n -4 & \\frac{3}{2} & -9 & 0 \\\\\n -1 & -1 & 10 & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 11 & \\frac{5}{2} & -\\frac{7}{2} & -\\frac{1}{2} \\\\\n -\\frac{9}{2} & -\\frac{1}{2} & -3 & -\\frac{19}{2} \\\\\n 13 & -7 & \\frac{29}{2} & \\frac{7}{2} \\\\\n \\frac{3}{2} & \\frac{5}{2} & -\\frac{3}{2} & -\\frac{27}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 6, -(3/2), -6],\n [(3/2), -(7/2), -(19/2), -(3/2)],\n [9, -(11/2), (11/2), (7/2)],\n [(1/2), (3/2), (17/2), -9]])\nb = np.array([\n [-3, (7/2), 2, -(11/2)],\n [6, -3, -(13/2), 8],\n [-4, (3/2), -9, 0],\n [-1, -1, 10, (9/2)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 7 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 1 \\\\\n 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 39 \\\\\n 98 \\\\\n -53 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [7],\n [10]])\nb = np.array([\n [7],\n [1],\n [7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -6 \\\\\n 4 \\\\\n 1 \\\\\n -4 \\\\\n -5 \\\\\n -3 \\\\\n 4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 3 \\\\\n -10 \\\\\n 5 \\\\\n -3 \\\\\n -1 \\\\\n -4 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10 \\sqrt{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-6],\n [4],\n [1],\n [-4],\n [-5],\n [-3],\n [4],\n [-2]])\nb = np.array([\n [-4],\n [3],\n [-10],\n [5],\n [-3],\n [-1],\n [-4],\n [-2],\n [1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{17}{2} & -8 \\\\\n -7 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{4} \\left(-5-3 \\sqrt{193}\\right),\\frac{1}{4} \\left(3 \\sqrt{193}-5\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/2), -8],\n [-7, 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 6 \\\\\n -6 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [6],\n [-6],\n [9]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -4 & -2 & -10 \\\\\n -6 & -7 & -7 \\\\\n 2 & 2 & -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-21 x^2-160 x-208$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -2, -10],\n [-6, -7, -7],\n [2, 2, -10]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 2 & -1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 8 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -6 & -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1]])\nb = np.array([\n [8, 7]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 2 & -5 & 5 & -3 & -1 & 8 \\\\\n 0 & 8 & -5 & -3 & -6 & 4 \\\\\n -1 & -2 & 7 & 3 & 6 & -3 \\\\\n -3 & -9 & -7 & 6 & 5 & 4 \\\\\n -6 & 6 & 3 & -2 & 0 & -3 \\\\\n 5 & -1 & -10 & 9 & -2 & -4 \\\\\n 1 & -3 & 6 & -10 & 9 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, -5, 5, -3, -1, 8],\n [0, 8, -5, -3, -6, 4],\n [-1, -2, 7, 3, 6, -3],\n [-3, -9, -7, 6, 5, 4],\n [-6, 6, 3, -2, 0, -3],\n [5, -1, -10, 9, -2, -4],\n [1, -3, 6, -10, 9, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -5 & -9 & 8 \\\\\n -7 & 6 & 0 \\\\\n 0 & -3 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{3.51,-5.232,1.\\}, \\{1.245\\, -1.703 i,0.783\\, -0.759 i,1.\\}, \\{1.245\\, +1.703 i,0.783\\, +0.759 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -9, 8],\n [-7, 6, 0],\n [0, -3, -5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & 8 \\\\\n 6 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+x-90$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 8],\n [6, -7]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & -\\frac{5}{2} \\\\\n -\\frac{1}{2} & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{29}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -(5/2)],\n [-(1/2), -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{13}{100}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & -6 & -4 & -4 \\\\\n 9 & 1 & -4 & 0 \\\\\n -5 & 3 & -9 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{13}{100} & -\\frac{39}{50} & -\\frac{13}{25} & -\\frac{13}{25} \\\\\n \\frac{117}{100} & \\frac{13}{100} & -\\frac{13}{25} & 0 \\\\\n -\\frac{13}{20} & \\frac{39}{100} & -\\frac{117}{100} & -\\frac{117}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -6, -4, -4],\n [9, 1, -4, 0],\n [-5, 3, -9, -9]])\nprint(a * (13/100))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 \\\\\n -3 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 3 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{12}{11},\\frac{36}{11},-\\frac{12}{11}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [3],\n [-3]]).squeeze()\nb = np.array([\n [1],\n [3],\n [-1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -5 & 3 & 0 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 3, 0, -3]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 5 \\\\\n -6 \\\\\n -1 \\\\\n 5 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 10 \\\\\n 3 \\\\\n -6 \\\\\n 0 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{173}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [5],\n [-6],\n [-1],\n [5],\n [-3]])\nb = np.array([\n [5],\n [10],\n [3],\n [-6],\n [0],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -3 \\\\\n 9 \\\\\n 7 \\\\\n -8 \\\\\n -5 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -8 \\\\\n -8 \\\\\n 0 \\\\\n -2 \\\\\n 2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{130}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-3],\n [9],\n [7],\n [-8],\n [-5],\n [-7]])\nb = np.array([\n [8],\n [-8],\n [-8],\n [0],\n [-2],\n [2],\n [-1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 3 & 2 & 2 & 3 & 3 \\\\\n -2 & 0 & 3 & -3 & 1 \\\\\n -1 & -1 & 0 & -1 & -1 \\\\\n -1 & -2 & 3 & -1 & 0 \\\\\n 3 & 3 & 2 & 3 & 0 \\\\\n 3 & 0 & 2 & 2 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.64 \\\\\n 2.99 \\\\\n -2.1 \\\\\n 1.15 \\\\\n 2.28 \\\\\n -2.57 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -4.029 \\\\\n 1.44 \\\\\n 0.841 \\\\\n 2.771 \\\\\n 0.754 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2, 2, 3, 3],\n [-2, 0, 3, -3, 1],\n [-1, -1, 0, -1, -1],\n [-1, -2, 3, -1, 0],\n [3, 3, 2, 3, 0],\n [3, 0, 2, 2, 3]])\nb = np.array([\n [2.64],\n [2.99],\n [-2.1],\n [1.15],\n [2.28],\n [-2.57]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0.7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2.3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-1.61$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0.7]])\nb = np.array([\n [-2.3]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{7}{10} & \\frac{9}{5} & 7 \\\\\n -\\frac{22}{5} & -\\frac{57}{10} & \\frac{26}{5} \\\\\n \\frac{99}{10} & -\\frac{5}{2} & -\\frac{61}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{111 x^2}{10}+\\frac{2187 x}{100}+\\frac{549801}{1000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/10), (9/5), 7],\n [-(22/5), -(57/10), (26/5)],\n [(99/10), -(5/2), -(61/10)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 3 \\\\\n -9 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [3],\n [-9],\n [5]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{2} & -\\frac{1}{2} & -\\frac{17}{2} \\\\\n -\\frac{39}{4} & -\\frac{11}{2} & \\frac{15}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{4} & \\frac{33}{4} & 6 \\\\\n -\\frac{9}{4} & -\\frac{9}{4} & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{4} & -\\frac{35}{4} & -\\frac{29}{2} \\\\\n -\\frac{15}{2} & -\\frac{13}{4} & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), -(1/2), -(17/2)],\n [-(39/4), -(11/2), (15/2)]])\nb = np.array([\n [(5/4), (33/4), 6],\n [-(9/4), -(9/4), (9/2)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 5 & -6 & -9 & 1 \\\\\n -1 & 2 & -5 & -4 \\\\\n -4 & 8 & -2 & -8 \\\\\n -8 & -4 & -2 & 1 \\\\\n -4 & -10 & 3 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, -6, -9, 1],\n [-1, 2, -5, -4],\n [-4, 8, -2, -8],\n [-8, -4, -2, 1],\n [-4, -10, 3, 5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -9 & -8 & 0 \\\\\n -5 & 0 & 7 \\\\\n 2 & -7 & -6 \\\\\n -6 & 9 & -2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 8 & 4 & 9 \\\\\n -3 & -5 & -1 \\\\\n 3 & -6 & -10 \\\\\n 9 & 1 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -17 & -12 & -9 \\\\\n -2 & 5 & 8 \\\\\n -1 & -1 & 4 \\\\\n -15 & 8 & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -8, 0],\n [-5, 0, 7],\n [2, -7, -6],\n [-6, 9, -2]])\nb = np.array([\n [8, 4, 9],\n [-3, -5, -1],\n [3, -6, -10],\n [9, 1, 7]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -4 & -9 & 2 \\\\\n 5 & -7 & -2 \\\\\n 2 & 6 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 9 & 0 & 1 \\\\\n -1 & 10 & 5 \\\\\n -3 & 0 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 5 & -9 & 3 \\\\\n 4 & 3 & 3 \\\\\n -1 & 6 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -9, 2],\n [5, -7, -2],\n [2, 6, -1]])\nb = np.array([\n [9, 0, 1],\n [-1, 10, 5],\n [-3, 0, 5]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & -3 & 3 \\\\\n -2 & 1 & 4 \\\\\n 2 & 1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-51$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3, 3],\n [-2, 1, 4],\n [2, 1, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,-3,-3\\}, \\{-5,-1,-3\\}, \\{0,0,-4\\}}$.", - "Output Answer": [ - "$2 x+5 y+15 z+60=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, -3, -3],\n [-5, -1, -3],\n [0, 0, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{13}{8} & -\\frac{1}{4} & -\\frac{11}{4} & \\frac{5}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{8} \\\\\n 1 \\\\\n \\frac{7}{8} \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{81}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/8), -(1/4), -(11/4), (5/4)]])\nb = np.array([\n [-(7/8)],\n [1],\n [(7/8)],\n [2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & -8 \\\\\n -10 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(5-\\sqrt{329}\\right),\\frac{1}{2} \\left(5+\\sqrt{329}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -8],\n [-10, 4]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,2,3\\}, \\{3,-4,-5\\}, \\{4,-1,3\\}}$.", - "Output Answer": [ - "$2 (x+y)-z-3=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, 2, 3],\n [3, -4, -5],\n [4, -1, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{10}{3}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -8 & -9 \\\\\n -8 & 8 \\\\\n -10 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{80}{3} & -30 \\\\\n -\\frac{80}{3} & \\frac{80}{3} \\\\\n -\\frac{100}{3} & \\frac{80}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -9],\n [-8, 8],\n [-10, 8]])\nprint(a * (10/3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 5 \\\\\n -3 \\\\\n -8 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -2 \\\\\n -4 \\\\\n -4 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(23 \\sqrt{\\frac{3}{6109}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [5],\n [-3],\n [-8],\n [-5]]).squeeze()\nb = np.array([\n [8],\n [-2],\n [-4],\n [-4],\n [-7]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & 9 \\\\\n 5 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+x-57$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 9],\n [5, 3]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & -3 & 2 \\\\\n 4 & 4 & 2 \\\\\n -4 & -2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$24$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, 2],\n [4, 4, 2],\n [-4, -2, -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{3} \\\\\n -\\frac{73}{9} \\\\\n -\\frac{14}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{26}{3} \\\\\n \\frac{5}{9} \\\\\n -\\frac{4}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{362}{81} \\\\\n 16 \\\\\n -\\frac{1813}{27} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/3)],\n [-(73/9)],\n [-(14/9)]])\nb = np.array([\n [-(26/3)],\n [(5/9)],\n [-(4/9)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 0 & 6 \\\\\n -8 & 4 \\\\\n -7 & 0 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 8 & 8 \\\\\n -1 & 1 \\\\\n -7 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -8 & -2 \\\\\n -7 & 3 \\\\\n 0 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 6],\n [-8, 4],\n [-7, 0]])\nb = np.array([\n [8, 8],\n [-1, 1],\n [-7, 5]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -5 & \\frac{19}{4} & 8 \\\\\n \\frac{33}{4} & -\\frac{43}{8} & \\frac{27}{8} \\\\\n 8 & -\\frac{63}{8} & -\\frac{35}{8} \\\\\n \\frac{19}{8} & \\frac{79}{8} & -\\frac{29}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, (19/4), 8],\n [(33/4), -(43/8), (27/8)],\n [8, -(63/8), -(35/8)],\n [(19/8), (79/8), -(29/8)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{5}{e},-\\frac{1}{e},0\\right\\}, \\left\\{-\\frac{3}{e},-\\frac{5}{e},-\\frac{4}{e}\\right\\}, \\left\\{\\frac{5}{e},\\frac{3}{e},\\frac{1}{e}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{5}{\\sqrt{26}},-\\frac{1}{\\sqrt{26}},0\\right\\}, \\left\\{-\\frac{7}{5 \\sqrt{78}},-\\frac{7}{\\sqrt{78}},-\\frac{\\sqrt{\\frac{26}{3}}}{5}\\right\\}, \\left\\{\\frac{1}{5 \\sqrt{3}},\\frac{1}{\\sqrt{3}},-\\frac{7}{5 \\sqrt{3}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((5/math.e), -(1/math.e), 0), (-(3/math.e), -(5/math.e), -(4/math.e)), ((5/math.e), (3/math.e), (1/math.e))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{46}{5} \\\\\n -\\frac{27}{5} \\\\\n -\\frac{44}{5} \\\\\n \\frac{13}{5} \\\\\n -\\frac{9}{5} \\\\\n -\\frac{6}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{3 \\sqrt{563}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(46/5)],\n [-(27/5)],\n [-(44/5)],\n [(13/5)],\n [-(9/5)],\n [-(6/5)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 2 & 6 & -3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 5 & -4 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -3 & 10 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 6, -3]])\nb = np.array([\n [5, -4, -2]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 9 & -7 \\\\\n 4 & 4 \\\\\n -7 & 0 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 2 & -6 \\\\\n 6 & 7 \\\\\n 1 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 7 & -1 \\\\\n -2 & -3 \\\\\n -8 & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -7],\n [4, 4],\n [-7, 0]])\nb = np.array([\n [2, -6],\n [6, 7],\n [1, 9]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -6 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -2 \\\\\n -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 20 \\\\\n 7 \\\\\n -38 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-6],\n [1]])\nb = np.array([\n [-5],\n [-2],\n [-3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n \\frac{49}{5} \\\\\n \\frac{12}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{5} \\\\\n -\\frac{9}{5} \\\\\n -\\frac{23}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-236 \\sqrt{\\frac{2}{1242215}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [(49/5)],\n [(12/5)]]).squeeze()\nb = np.array([\n [-(7/5)],\n [-(9/5)],\n [-(23/5)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{5} & \\frac{26}{5} \\\\\n 9 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{30} \\left(11-\\sqrt{641}\\right),1\\right\\}, \\left\\{\\frac{1}{30} \\left(11+\\sqrt{641}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/5), (26/5)],\n [9, -8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{16} \\\\\n \\frac{15}{16} \\\\\n \\frac{29}{16} \\\\\n -\\frac{17}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{8} & \\frac{19}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{117}{128} & -\\frac{247}{128} \\\\\n \\frac{135}{128} & \\frac{285}{128} \\\\\n \\frac{261}{128} & \\frac{551}{128} \\\\\n -\\frac{153}{64} & -\\frac{323}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/16)],\n [(15/16)],\n [(29/16)],\n [-(17/8)]])\nb = np.array([\n [(9/8), (19/8)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 2 \\\\\n -9 \\\\\n -1 \\\\\n 7 \\\\\n -4 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 7 \\\\\n 3 \\\\\n -1 \\\\\n 1 \\\\\n 9 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-53$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [2],\n [-9],\n [-1],\n [7],\n [-4],\n [-3]])\nb = np.array([\n [2],\n [7],\n [3],\n [-1],\n [1],\n [9],\n [-2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{1}{10}, -\\frac{7}{2}}$ to the line $-\\frac{13 x}{5}+\\frac{12 y}{5}+\\frac{3}{5}=0$.", - "Output Answer": [ - "$\\frac{403}{10 \\sqrt{313}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (1/10), -(7/2)\nline = Poly(-((13*x)/5)+((12*y)/5)+(3/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n 0 & -5 & 8 & 10 \\\\\n -8 & -3 & 0 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -5, 8, 10],\n [-8, -3, 0, 1]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\log (2) \\\\\n -7 \\log (2) \\\\\n -\\log (2) \\\\\n 6 \\log (2) \\\\\n 6 \\log (2) \\\\\n -8 \\log (2) \\\\\n \\log (2) \\\\\n -4 \\log (2) \\\\\n -8 \\log (2) \\\\\n 11 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\log (2) \\\\\n -7 \\log (2) \\\\\n 5 \\log (2) \\\\\n 5 \\log (2) \\\\\n -5 \\log (2) \\\\\n -\\log (2) \\\\\n -6 \\log (2) \\\\\n 5 \\log (2) \\\\\n 2 \\log (2) \\\\\n 9 \\log (2) \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7 \\sqrt{10} \\log (2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [3*math.log(2)],\n [-7*math.log(2)],\n [-math.log(2)],\n [6*math.log(2)],\n [6*math.log(2)],\n [-8*math.log(2)],\n [math.log(2)],\n [-4*math.log(2)],\n [-8*math.log(2)],\n [11*math.log(2)]])\nb = np.array([\n [-4*math.log(2)],\n [-7*math.log(2)],\n [5*math.log(2)],\n [5*math.log(2)],\n [-5*math.log(2)],\n [-math.log(2)],\n [-6*math.log(2)],\n [5*math.log(2)],\n [2*math.log(2)],\n [9*math.log(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 11 \\\\\n 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [8]])\nb = np.array([\n [9],\n [-3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -9 \\\\\n 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 9 \\\\\n 5 \\\\\n -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [1]])\nb = np.array([\n [5],\n [-9],\n [0]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 2 & 0 & -3 & 2 & 3 \\\\\n 0 & 0 & 1 & 2 & -1 \\\\\n 1 & 1 & -1 & -2 & 1 \\\\\n 2 & -2 & 0 & 2 & -2 \\\\\n -1 & 1 & 1 & 3 & -3 \\\\\n -1 & 0 & 2 & 0 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.22 \\\\\n -1.74 \\\\\n 0.06 \\\\\n 0.33 \\\\\n 1.67 \\\\\n -1.24 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.572 \\\\\n -0.053 \\\\\n -0.922 \\\\\n -0.099 \\\\\n -0.598 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, -3, 2, 3],\n [0, 0, 1, 2, -1],\n [1, 1, -1, -2, 1],\n [2, -2, 0, 2, -2],\n [-1, 1, 1, 3, -3],\n [-1, 0, 2, 0, 1]])\nb = np.array([\n [-0.22],\n [-1.74],\n [0.06],\n [0.33],\n [1.67],\n [-1.24]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\sqrt{2},-\\frac{3}{\\sqrt{2}},0\\right\\}, \\left\\{2 \\sqrt{2},-\\frac{3}{\\sqrt{2}},\\sqrt{2}\\right\\}, \\left\\{0,-2 \\sqrt{2},2 \\sqrt{2}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{2}{\\sqrt{13}},-\\frac{3}{\\sqrt{13}},0\\right\\}, \\left\\{\\frac{9}{\\sqrt{286}},3 \\sqrt{\\frac{2}{143}},\\sqrt{\\frac{13}{22}}\\right\\}, \\left\\{-\\frac{3}{\\sqrt{22}},-\\sqrt{\\frac{2}{11}},\\frac{3}{\\sqrt{22}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((math.sqrt(2), -(3/(math.sqrt(2))), 0), (2*math.sqrt(2), -(3/(math.sqrt(2))), math.sqrt(2)), (0, -2*math.sqrt(2), 2*math.sqrt(2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -3 & 3 & -4 & 5 & -8 \\\\\n -9 & -5 & -4 & 9 & -5 \\\\\n 4 & -4 & 4 & 2 & 9 \\\\\n -10 & 3 & 7 & 1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & \\frac{857}{2618} \\\\\n 0 & 1 & 0 & 0 & -\\frac{807}{1309} \\\\\n 0 & 0 & 1 & 0 & \\frac{487}{374} \\\\\n 0 & 0 & 0 & 1 & \\frac{3}{374} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 3, -4, 5, -8],\n [-9, -5, -4, 9, -5],\n [4, -4, 4, 2, 9],\n [-10, 3, 7, 1, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -1 & -6 \\\\\n 2 & -4 \\\\\n 3 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, -6],\n [2, -4],\n [3, -5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -8 \\\\\n -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{8}{3} \\\\\n \\frac{13}{3} \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{595}{9} \\\\\n -\\frac{371}{9} \\\\\n -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-8],\n [-(7/3)]])\nb = np.array([\n [(8/3)],\n [(13/3)],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{10} \\\\\n -\\frac{33}{10} \\\\\n \\frac{27}{5} \\\\\n -\\frac{9}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/10)],\n [-(33/10)],\n [(27/5)],\n [-(9/10)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -3 \\\\\n -7 \\\\\n 2 \\\\\n 0 \\\\\n 0 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 10 \\\\\n 0 \\\\\n 8 \\\\\n 2 \\\\\n -1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-3],\n [-7],\n [2],\n [0],\n [0],\n [8]])\nb = np.array([\n [-5],\n [10],\n [0],\n [8],\n [2],\n [-1],\n [-2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -3 \\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n -3 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n 0 \\\\\n -5 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4 \\sqrt{3}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [-3*math.sqrt(3)],\n [-2*math.sqrt(3)],\n [-3*math.sqrt(3)]])\nb = np.array([\n [-2*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [0],\n [-5*math.sqrt(3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -2 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1]])\nb = np.array([\n [-2, 1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-1$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 7 & -1 & -6 \\\\\n 4 & -4 & 4 \\\\\n 2 & 9 & 9 \\\\\n 5 & -4 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -7 & 1 & 6 \\\\\n -4 & 4 & -4 \\\\\n -2 & -9 & -9 \\\\\n -5 & 4 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -1, -6],\n [4, -4, 4],\n [2, 9, 9],\n [5, -4, 5]])\nprint(a * -1)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{9} \\\\\n -\\frac{80}{9} \\\\\n \\frac{14}{9} \\\\\n \\frac{10}{9} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{14}{9} \\\\\n -9 \\\\\n -\\frac{68}{9} \\\\\n -\\frac{52}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{31}{9} \\\\\n \\frac{1}{9} \\\\\n \\frac{82}{9} \\\\\n \\frac{62}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/9)],\n [-(80/9)],\n [(14/9)],\n [(10/9)]])\nb = np.array([\n [(14/9)],\n [-9],\n [-(68/9)],\n [-(52/9)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{18}{5} & -\\frac{24}{5} \\\\\n -2 & -\\frac{22}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{55}{78} & \\frac{10}{13} \\\\\n \\frac{25}{78} & -\\frac{15}{26} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(18/5), -(24/5)],\n [-2, -(22/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{117}{100} & -\\frac{37}{20} \\\\\n \\frac{17}{2} & -\\frac{391}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{137 x}{50}+\\frac{111503}{10000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(117/100), -(37/20)],\n [(17/2), -(391/100)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\sqrt{2} \\\\\n 0 \\\\\n 2 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\sqrt{2} \\\\\n \\sqrt{2} \\\\\n -6 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{37}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-4*math.sqrt(2)],\n [0],\n [2*math.sqrt(2)]])\nb = np.array([\n [-7*math.sqrt(2)],\n [math.sqrt(2)],\n [-6*math.sqrt(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & 9 & -8 \\\\\n 9 & -9 & -6 \\\\\n -9 & 4 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-14.569,-1.224,13.793\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 9, -8],\n [9, -9, -6],\n [-9, 4, 8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 9 & -6 & -2 \\\\\n -3 & 2 & -9 \\\\\n 5 & 10 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-4.095-9.321 i,-4.095+9.321 i,11.191\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -6, -2],\n [-3, 2, -9],\n [5, 10, -8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{2} & -\\frac{3}{2} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), -(3/2), -(3/2)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{13}{2}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 7 & -3 & 2 & 9 \\\\\n -2 & -7 & 7 & -2 \\\\\n 0 & -7 & -4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{91}{2} & -\\frac{39}{2} & 13 & \\frac{117}{2} \\\\\n -13 & -\\frac{91}{2} & \\frac{91}{2} & -13 \\\\\n 0 & -\\frac{91}{2} & -26 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -3, 2, 9],\n [-2, -7, 7, -2],\n [0, -7, -4, 0]])\nprint(a * (13/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{2} \\\\\n -\\frac{53}{6} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{35}{6} \\\\\n \\frac{17}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{8}{3} \\\\\n -\\frac{35}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/2)],\n [-(53/6)]])\nb = np.array([\n [-(35/6)],\n [(17/6)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & 9 & -8 \\\\\n -8 & 8 & -4 \\\\\n -4 & -8 & -4 \\\\\n 7 & 4 & 4 \\\\\n 10 & 4 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, 9, -8],\n [-8, 8, -4],\n [-4, -8, -4],\n [7, 4, 4],\n [10, 4, -5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -8 & -4 & -7 \\\\\n 5 & 8 & -1 \\\\\n -4 & -5 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.176,1.875,1.\\}, \\{-0.245,-0.498,1.\\}, \\{6.818,-2.094,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -4, -7],\n [5, 8, -1],\n [-4, -5, 9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -3 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 6 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -48 \\\\\n 27 \\\\\n -39 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-3],\n [9]])\nb = np.array([\n [5],\n [6],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 2 \\\\\n -1 \\\\\n -10 \\\\\n 1 \\\\\n -6 \\\\\n 4 \\\\\n 8 \\\\\n 4 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 6 \\\\\n 7 \\\\\n 9 \\\\\n -1 \\\\\n 8 \\\\\n 9 \\\\\n -2 \\\\\n -8 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{1011}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [2],\n [-1],\n [-10],\n [1],\n [-6],\n [4],\n [8],\n [4],\n [-5]])\nb = np.array([\n [8],\n [6],\n [7],\n [9],\n [-1],\n [8],\n [9],\n [-2],\n [-8],\n [-6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{16}{7} \\\\\n -\\frac{20}{7} \\\\\n \\frac{2}{7} \\\\\n -\\frac{8}{7} \\\\\n \\frac{8}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{8}{\\sqrt{197}} \\\\\n -\\frac{10}{\\sqrt{197}} \\\\\n \\frac{1}{\\sqrt{197}} \\\\\n -\\frac{4}{\\sqrt{197}} \\\\\n \\frac{4}{\\sqrt{197}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(16/7)],\n [-(20/7)],\n [(2/7)],\n [-(8/7)],\n [(8/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 6 & -9 & 10 & 5 & 9 & 3 & -4 \\\\\n 3 & 0 & 10 & 0 & -1 & 4 & 4 \\\\\n -9 & -8 & 8 & -3 & 4 & 4 & -5 \\\\\n 9 & 8 & -10 & -10 & 7 & -10 & 8 \\\\\n -7 & -2 & 8 & 9 & 7 & -1 & 1 \\\\\n -4 & 0 & 3 & -6 & -3 & -3 & 2 \\\\\n 3 & -4 & -4 & 3 & -5 & 2 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, -9, 10, 5, 9, 3, -4],\n [3, 0, 10, 0, -1, 4, 4],\n [-9, -8, 8, -3, 4, 4, -5],\n [9, 8, -10, -10, 7, -10, 8],\n [-7, -2, 8, 9, 7, -1, 1],\n [-4, 0, 3, -6, -3, -3, 2],\n [3, -4, -4, 3, -5, 2, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -6 & -3 & 7 \\\\\n 1 & 9 & 2 \\\\\n -6 & 0 & -7 \\\\\n -4 & -10 & -10 \\\\\n 9 & 7 & 6 \\\\\n -10 & 6 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-6, -3, 7],\n [1, 9, 2],\n [-6, 0, -7],\n [-4, -10, -10],\n [9, 7, 6],\n [-10, 6, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -9 & -2 & -8 & 2 \\\\\n -4 & 10 & 7 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 4 & -2 & -5 & -9 \\\\\n -8 & 3 & -8 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -5 & -4 & -13 & -7 \\\\\n -12 & 13 & -1 & 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -2, -8, 2],\n [-4, 10, 7, 0]])\nb = np.array([\n [4, -2, -5, -9],\n [-8, 3, -8, 9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8.129 \\\\\n -8.211 \\\\\n 9.646 \\\\\n -1.295 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7.527 \\\\\n -7.025 \\\\\n -8.797 \\\\\n 1.223 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$32.4296$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8.129],\n [-8.211],\n [9.646],\n [-1.295]])\nb = np.array([\n [-7.527],\n [-7.025],\n [-8.797],\n [1.223]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n \\frac{41}{7} & \\frac{10}{7} \\\\\n \\frac{11}{7} & \\frac{9}{7} \\\\\n \\frac{3}{7} & \\frac{16}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(41/7), (10/7)],\n [(11/7), (9/7)],\n [(3/7), (16/7)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{15}{16} & \\frac{5}{8} & -\\frac{55}{16} \\\\\n \\frac{1}{4} & -\\frac{23}{8} & -\\frac{67}{16} \\\\\n \\frac{53}{16} & 4 & \\frac{75}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{6704}{99625} & \\frac{6832}{19925} & \\frac{1024}{3985} \\\\\n \\frac{30808}{99625} & -\\frac{2864}{19925} & \\frac{392}{3985} \\\\\n -\\frac{21552}{99625} & -\\frac{2384}{19925} & -\\frac{208}{3985} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/16), (5/8), -(55/16)],\n [(1/4), -(23/8), -(67/16)],\n [(53/16), 4, (75/16)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 9 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -5 \\\\\n 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 78 \\\\\n 9 \\\\\n -105 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [9],\n [3]])\nb = np.array([\n [10],\n [-5],\n [7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n 10 & 5 \\\\\n 6 & 9 \\\\\n 8 & 0 \\\\\n 9 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 5],\n [6, 9],\n [8, 0],\n [9, -3]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{7}{3}, -\\frac{10}{3}}$ to the line $-\\frac{7 x}{3}+3 y+\\frac{11}{3}=0$.", - "Output Answer": [ - "$\\frac{53 \\sqrt{\\frac{2}{65}}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (7/3), -(10/3)\nline = Poly(-((7*x)/3)+3*y+(11/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n \\frac{50}{7} & \\frac{40}{7} & -\\frac{22}{7} & -\\frac{10}{7} & -\\frac{57}{7} \\\\\n \\frac{36}{7} & \\frac{17}{7} & -3 & -\\frac{45}{7} & \\frac{61}{7} \\\\\n -\\frac{69}{7} & \\frac{38}{7} & \\frac{58}{7} & \\frac{39}{7} & \\frac{9}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(50/7), (40/7), -(22/7), -(10/7), -(57/7)],\n [(36/7), (17/7), -3, -(45/7), (61/7)],\n [-(69/7), (38/7), (58/7), (39/7), (9/7)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 2 & -2 \\\\\n -1 & -2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 12 & -12 \\\\\n -6 & -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2],\n [-1, -2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -2 & 2 & -1 & -3 \\\\\n -3 & 1 & 0 & -1 \\\\\n -1 & 3 & -3 & -3 \\\\\n 1 & 1 & 0 & 0 \\\\\n 0 & -1 & -2 & -2 \\\\\n -1 & 3 & -1 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.71 \\\\\n -1.72 \\\\\n -1.75 \\\\\n 0.18 \\\\\n -1.35 \\\\\n 2.11 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.576 \\\\\n 0.788 \\\\\n 1.342 \\\\\n -0.687 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2, -1, -3],\n [-3, 1, 0, -1],\n [-1, 3, -3, -3],\n [1, 1, 0, 0],\n [0, -1, -2, -2],\n [-1, 3, -1, 0]])\nb = np.array([\n [2.71],\n [-1.72],\n [-1.75],\n [0.18],\n [-1.35],\n [2.11]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -10 \\\\\n -6 \\\\\n 5 \\\\\n 5 \\\\\n -6 \\\\\n 3 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-10],\n [-6],\n [5],\n [5],\n [-6],\n [3],\n [5]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 0 \\\\\n 6 \\\\\n 5 \\\\\n -4 \\\\\n -5 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$35$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [0],\n [6],\n [5],\n [-4],\n [-5],\n [6]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{53}{7} \\\\\n -9 \\\\\n \\frac{44}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{65}{7} \\\\\n -\\frac{68}{7} \\\\\n -\\frac{38}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-17$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(53/7)],\n [-9],\n [(44/7)]])\nb = np.array([\n [-(65/7)],\n [-(68/7)],\n [-(38/7)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{12}{5} \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{8}{\\sqrt{89}} \\\\\n -\\frac{5}{\\sqrt{89}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(12/5)],\n [-(3/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -1 & 2 \\\\\n 2 & 0 \\\\\n -2 & -3 \\\\\n 0 & -2 \\\\\n -2 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -2 & 0 & -3 & 3 & 0 \\\\\n 0 & 3 & -2 & 2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 2 & 6 & -1 & 1 & -2 \\\\\n -4 & 0 & -6 & 6 & 0 \\\\\n 4 & -9 & 12 & -12 & 3 \\\\\n 0 & -6 & 4 & -4 & 2 \\\\\n 4 & 3 & 4 & -4 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2],\n [2, 0],\n [-2, -3],\n [0, -2],\n [-2, 1]])\nb = np.array([\n [-2, 0, -3, 3, 0],\n [0, 3, -2, 2, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{37}{5} \\\\\n 9 \\\\\n -\\frac{43}{5} \\\\\n -\\frac{1}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{37}{10} \\\\\n -\\frac{11}{5} \\\\\n -\\frac{9}{10} \\\\\n \\frac{31}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{37}{10} \\\\\n \\frac{34}{5} \\\\\n -\\frac{19}{2} \\\\\n 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/5)],\n [9],\n [-(43/5)],\n [-(1/10)]])\nb = np.array([\n [-(37/10)],\n [-(11/5)],\n [-(9/10)],\n [(31/10)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -\\frac{14}{5} \\\\\n 3 \\\\\n \\frac{2}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{6}{5} \\\\\n \\frac{6}{5} \\\\\n \\frac{12}{5} \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{264}{395},\\frac{264}{395},\\frac{528}{395},\\frac{88}{79}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-(14/5)],\n [3],\n [(2/5)]]).squeeze()\nb = np.array([\n [-(6/5)],\n [(6/5)],\n [(12/5)],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & -2 & 1 \\\\\n -2 & 3 & 2 \\\\\n -4 & 1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{3} & \\frac{3}{10} & -\\frac{7}{30} \\\\\n 0 & \\frac{2}{5} & -\\frac{1}{5} \\\\\n \\frac{1}{3} & \\frac{1}{5} & \\frac{1}{15} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2, 1],\n [-2, 3, 2],\n [-4, 1, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -3 \\\\\n 8 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -5 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-18$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-3],\n [8],\n [7]])\nb = np.array([\n [-3],\n [-5],\n [-2],\n [1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{16}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 5 & 6 & 2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{15}{16} & \\frac{9}{8} & \\frac{3}{8} & -\\frac{3}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 6, 2, -2]])\nprint(a * (3/16))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{3} & -\\frac{8}{3} \\\\\n -\\frac{28}{3} & -\\frac{23}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -3 & \\frac{14}{3} \\\\\n 8 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{14}{3} & 2 \\\\\n -\\frac{4}{3} & \\frac{4}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/3), -(8/3)],\n [-(28/3), -(23/3)]])\nb = np.array([\n [-3, (14/3)],\n [8, 9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 5 & 9 \\\\\n -4 & -1 \\\\\n 8 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, 9],\n [-4, -1],\n [8, 1]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 8 & -6 & 0 \\\\\n 6 & -6 & -3 \\\\\n 10 & -7 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+10 x^2+17 x-84$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -6, 0],\n [6, -6, -3],\n [10, -7, 8]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -6 & -7 & 2 & 1 \\\\\n 7 & -5 & 1 & 5 \\\\\n -8 & 0 & -5 & -3 \\\\\n 10 & -4 & -9 & -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -10 & 3 & 6 & 7 \\\\\n 3 & -9 & 4 & 5 \\\\\n -1 & -1 & -2 & -1 \\\\\n 0 & 4 & 1 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -16 & -4 & 8 & 8 \\\\\n 10 & -14 & 5 & 10 \\\\\n -9 & -1 & -7 & -4 \\\\\n 10 & 0 & -8 & -11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -7, 2, 1],\n [7, -5, 1, 5],\n [-8, 0, -5, -3],\n [10, -4, -9, -8]])\nb = np.array([\n [-10, 3, 6, 7],\n [3, -9, 4, 5],\n [-1, -1, -2, -1],\n [0, 4, 1, -3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -4 & -\\frac{1}{5} & -\\frac{38}{5} & 10 \\\\\n -\\frac{4}{5} & \\frac{41}{5} & \\frac{4}{5} & \\frac{4}{5} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{1}{5} & -\\frac{34}{5} & -\\frac{24}{5} & \\frac{16}{5} \\\\\n -\\frac{32}{5} & \\frac{31}{5} & \\frac{18}{5} & -\\frac{37}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{19}{5} & \\frac{33}{5} & -\\frac{14}{5} & \\frac{34}{5} \\\\\n \\frac{28}{5} & 2 & -\\frac{14}{5} & \\frac{41}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -(1/5), -(38/5), 10],\n [-(4/5), (41/5), (4/5), (4/5)]])\nb = np.array([\n [-(1/5), -(34/5), -(24/5), (16/5)],\n [-(32/5), (31/5), (18/5), -(37/5)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -4 \\\\\n -1 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-14$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -4],\n [-1, 5]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 1 \\\\\n 2 \\\\\n 2 \\\\\n 2 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{\\sqrt{31}} \\\\\n \\frac{1}{\\sqrt{31}} \\\\\n \\frac{2}{\\sqrt{31}} \\\\\n \\frac{2}{\\sqrt{31}} \\\\\n \\frac{2}{\\sqrt{31}} \\\\\n -\\frac{3}{\\sqrt{31}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [1],\n [2],\n [2],\n [2],\n [-3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & \\frac{26}{7} & \\frac{19}{7} \\\\\n -\\frac{29}{7} & 2 & -5 \\\\\n -2 & -\\frac{32}{7} & \\frac{5}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1225}{8761} & -\\frac{861}{8761} & -\\frac{1372}{8761} \\\\\n \\frac{4445}{52566} & \\frac{686}{26283} & -\\frac{2429}{17522} \\\\\n \\frac{3934}{26283} & -\\frac{2842}{26283} & \\frac{651}{8761} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, (26/7), (19/7)],\n [-(29/7), 2, -5],\n [-2, -(32/7), (5/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 2 \\\\\n 2 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n \\sqrt{\\frac{2}{5}} \\\\\n \\sqrt{\\frac{2}{5}} \\\\\n \\frac{1}{\\sqrt{10}} \\\\\n \\frac{1}{\\sqrt{10}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [2],\n [2],\n [1],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n \\frac{11}{8} & -\\frac{7}{4} \\\\\n -1 & \\frac{19}{8} \\\\\n -\\frac{3}{4} & -\\frac{13}{8} \\\\\n -\\frac{5}{2} & -\\frac{7}{4} \\\\\n 3 & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{21}{8} & -\\frac{23}{8} & -\\frac{5}{4} & \\frac{19}{8} \\\\\n -\\frac{5}{8} & -3 & \\frac{5}{8} & -\\frac{11}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{301}{64} & \\frac{83}{64} & -\\frac{45}{16} & \\frac{517}{64} \\\\\n -\\frac{263}{64} & -\\frac{17}{4} & \\frac{175}{64} & -\\frac{285}{32} \\\\\n -\\frac{61}{64} & \\frac{225}{32} & -\\frac{5}{64} & \\frac{43}{16} \\\\\n -\\frac{175}{32} & \\frac{199}{16} & \\frac{65}{32} & -\\frac{9}{8} \\\\\n \\frac{131}{16} & -\\frac{57}{8} & -\\frac{65}{16} & \\frac{17}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/8), -(7/4)],\n [-1, (19/8)],\n [-(3/4), -(13/8)],\n [-(5/2), -(7/4)],\n [3, -(1/2)]])\nb = np.array([\n [(21/8), -(23/8), -(5/4), (19/8)],\n [-(5/8), -3, (5/8), -(11/4)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{4}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & -2 \\\\\n 6 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{9}{4} & \\frac{3}{2} \\\\\n -\\frac{9}{2} & -\\frac{9}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2],\n [6, 3]])\nprint(a * -(3/4))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 3 & -1 & 1 \\\\\n -3 & 1 & 2 \\\\\n 1 & -3 & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 61 & -23 & -1 \\\\\n -25 & 11 & -14 \\\\\n 43 & -1 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, 1],\n [-3, 1, 2],\n [1, -3, 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 5 & 9 & 7 \\\\\n -7 & 3 & -7 \\\\\n -10 & 6 & 1 \\\\\n 2 & 6 & -4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 6 & 4 & -4 \\\\\n 0 & -10 & -6 \\\\\n -7 & 2 & 4 \\\\\n 7 & 0 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & 5 & 11 \\\\\n -7 & 13 & -1 \\\\\n -3 & 4 & -3 \\\\\n -5 & 6 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 9, 7],\n [-7, 3, -7],\n [-10, 6, 1],\n [2, 6, -4]])\nb = np.array([\n [6, 4, -4],\n [0, -10, -6],\n [-7, 2, 4],\n [7, 0, -3]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{16}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -10 & 8 & 6 \\\\\n 4 & -6 & 5 \\\\\n -2 & -9 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{5}{8} & -\\frac{1}{2} & -\\frac{3}{8} \\\\\n -\\frac{1}{4} & \\frac{3}{8} & -\\frac{5}{16} \\\\\n \\frac{1}{8} & \\frac{9}{16} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 8, 6],\n [4, -6, 5],\n [-2, -9, 8]])\nprint(a * -(1/16))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & 0 \\\\\n -5 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0,0\\}, \\{0,1\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 0],\n [-5, 9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -4 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -8 \\\\\n -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n 39 \\\\\n -52 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-4],\n [-3]])\nb = np.array([\n [7],\n [-8],\n [-6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1]])\nb = np.array([\n [-2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 3 & -3 & 1 & -2 & 3 \\\\\n 3 & 1 & 0 & 1 & -3 \\\\\n -2 & 0 & -3 & 0 & 0 \\\\\n -1 & 1 & -3 & 1 & 2 \\\\\n 1 & 0 & 2 & 0 & 2 \\\\\n 2 & 1 & 3 & -1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.22 \\\\\n 0.78 \\\\\n 2.63 \\\\\n 2.57 \\\\\n 0.64 \\\\\n -1.13 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.41 \\\\\n 0.579 \\\\\n -0.779 \\\\\n -0.217 \\\\\n 0.378 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -3, 1, -2, 3],\n [3, 1, 0, 1, -3],\n [-2, 0, -3, 0, 0],\n [-1, 1, -3, 1, 2],\n [1, 0, 2, 0, 2],\n [2, 1, 3, -1, -1]])\nb = np.array([\n [0.22],\n [0.78],\n [2.63],\n [2.57],\n [0.64],\n [-1.13]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n -2 \\\\\n -\\frac{3}{2} \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{\\sqrt{43}} \\\\\n -\\frac{4}{\\sqrt{43}} \\\\\n -\\frac{3}{\\sqrt{43}} \\\\\n \\frac{3}{\\sqrt{43}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2)],\n [-2],\n [-(3/2)],\n [(3/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -2 & -7 & 1 & 4 \\\\\n -7 & -4 & -5 & -2 \\\\\n 3 & 3 & 6 & 8 \\\\\n 5 & -6 & 6 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, -7, 1, 4],\n [-7, -4, -5, -2],\n [3, 3, 6, 8],\n [5, -6, 6, 2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & -1 \\\\\n 5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(3-\\sqrt{101}\\right),\\frac{1}{2} \\left(3+\\sqrt{101}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -1],\n [5, -4]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{4,-3,-\\frac{5}{2}\\right\\}, \\left\\{0,-2,\\frac{3}{2}\\right\\}, \\left\\{-2,\\frac{7}{2},1\\right\\}}$.", - "Output Answer": [ - "$9 x+4 y+8 z-4=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, -3, -(5/2)],\n [0, -2, (3/2)],\n [-2, (7/2), 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n -3 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{1}{\\sqrt{11}} \\\\\n -\\frac{3}{\\sqrt{11}} \\\\\n 0 \\\\\n 0 \\\\\n -\\frac{1}{\\sqrt{11}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [-3],\n [0],\n [0],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{4} \\\\\n \\frac{11}{4} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{7}{10},-\\frac{7}{20}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/4)],\n [(11/4)]]).squeeze()\nb = np.array([\n [2],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-1$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & -5 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -4 & 5 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -5, -5]])\nprint(a * -1)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{11}{4} \\\\\n -\\frac{1}{8} \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{22}{\\sqrt{1061}} \\\\\n -\\frac{1}{\\sqrt{1061}} \\\\\n -\\frac{24}{\\sqrt{1061}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/4)],\n [-(1/8)],\n [-3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & 1 & 4 \\\\\n -3 & -3 & -1 \\\\\n -4 & 3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-77$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 1, 4],\n [-3, -3, -1],\n [-4, 3, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{21}{5}, \\frac{4}{5}}$ to the line $\\frac{14 x}{5}-\\frac{3}{5}=0$.", - "Output Answer": [ - "$\\frac{309}{70}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(21/5), (4/5)\nline = Poly(((14*x)/5)-(3/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 3 \\\\\n -3 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -6 \\\\\n 10 \\\\\n -8 \\\\\n 8 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-7 \\sqrt{\\frac{2}{451}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [3],\n [-3],\n [0],\n [-1],\n [0]]).squeeze()\nb = np.array([\n [0],\n [-6],\n [10],\n [-8],\n [8],\n [-8]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{3,-\\frac{2}{3},-4\\right\\}, \\left\\{1,-\\frac{4}{3},\\frac{13}{3}\\right\\}, \\left\\{-\\frac{2}{3},\\frac{11}{3},4\\right\\}}$.", - "Output Answer": [ - "$1119 x+393 y+300 z-1895=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, -(2/3), -4],\n [1, -(4/3), (13/3)],\n [-(2/3), (11/3), 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 2 & -2 & 0 & 9 \\\\\n 10 & 6 & 6 & -3 \\\\\n -1 & -7 & -8 & 3 \\\\\n -6 & -8 & -10 & 4 \\\\\n 7 & -6 & -7 & 2 \\\\\n -7 & -9 & -7 & 1 \\\\\n -7 & 3 & -10 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, -2, 0, 9],\n [10, 6, 6, -3],\n [-1, -7, -8, 3],\n [-6, -8, -10, 4],\n [7, -6, -7, 2],\n [-7, -9, -7, 1],\n [-7, 3, -10, 5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & -2 \\\\\n -5 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2],\n [-5, -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & 2 & 2 \\\\\n 0 & 3 & -3 \\\\\n 0 & 2 & 1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 8 & 50 & -34 \\\\\n 0 & -15 & -21 \\\\\n 0 & 14 & -29 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, 2],\n [0, 3, -3],\n [0, 2, 1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -2 & 1 & -6 \\\\\n -1 & 6 & -2 \\\\\n 8 & 0 & 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -7 & 0 & 4 \\\\\n 2 & -9 & -2 \\\\\n -2 & 6 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -9 & 1 & -2 \\\\\n 1 & -3 & -4 \\\\\n 6 & 6 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 1, -6],\n [-1, 6, -2],\n [8, 0, 5]])\nb = np.array([\n [-7, 0, 4],\n [2, -9, -2],\n [-2, 6, -3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 2 & -2 \\\\\n -3 & -5 & 5 \\\\\n -3 & -2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-30$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, -2],\n [-3, -5, 5],\n [-3, -2, -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 2 \\\\\n -9 \\\\\n -3 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$26$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [2],\n [-9],\n [-3],\n [-3]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -3 & 3 \\\\\n 1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{2} \\left(-7-\\sqrt{61}\\right),1\\right\\}, \\left\\{\\frac{1}{2} \\left(\\sqrt{61}-7\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 3],\n [1, 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -3 & 2 & 1 & 3 \\\\\n -1 & 2 & -3 & 0 \\\\\n -1 & 0 & 1 & -2 \\\\\n 3 & 1 & 1 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 3 & -2 \\\\\n 2 & 2 \\\\\n 2 & 0 \\\\\n 0 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -3 & 7 \\\\\n -5 & 6 \\\\\n -1 & 4 \\\\\n 13 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2, 1, 3],\n [-1, 2, -3, 0],\n [-1, 0, 1, -2],\n [3, 1, 1, 0]])\nb = np.array([\n [3, -2],\n [2, 2],\n [2, 0],\n [0, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-5]])\nb = np.array([\n [-6],\n [-4]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -\\frac{20}{9} & -\\frac{19}{9} \\\\\n \\frac{2}{9} & \\frac{14}{9} \\\\\n \\frac{1}{9} & \\frac{10}{9} \\\\\n -\\frac{8}{9} & -\\frac{7}{3} \\\\\n \\frac{25}{9} & \\frac{23}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{10}{9} \\\\\n \\frac{25}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{275}{81} \\\\\n \\frac{110}{27} \\\\\n \\frac{80}{27} \\\\\n -\\frac{445}{81} \\\\\n \\frac{325}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/9), -(19/9)],\n [(2/9), (14/9)],\n [(1/9), (10/9)],\n [-(8/9), -(7/3)],\n [(25/9), (23/9)]])\nb = np.array([\n [-(10/9)],\n [(25/9)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n 9 & 9 & 6 \\\\\n 4 & 9 & 7 \\\\\n 10 & 8 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 9, 6],\n [4, 9, 7],\n [10, 8, 9]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2.7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5.4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-14.58$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2.7]])\nb = np.array([\n [5.4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 7 & -5 & 0 \\\\\n 9 & 2 & 5 \\\\\n 7 & 4 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+17 x^2-111 x+157$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -5, 0],\n [9, 2, 5],\n [7, 4, 8]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & 3 \\\\\n -1 & 0 \\\\\n 0 & -2 \\\\\n 2 & 0 \\\\\n 1 & -1 \\\\\n 1 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.18 \\\\\n 2.2 \\\\\n -2.89 \\\\\n 1.22 \\\\\n 2.31 \\\\\n 0.81 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.526 \\\\\n 0.324 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 3],\n [-1, 0],\n [0, -2],\n [2, 0],\n [1, -1],\n [1, 0]])\nb = np.array([\n [0.18],\n [2.2],\n [-2.89],\n [1.22],\n [2.31],\n [0.81]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 9 & 6 & -7 & 5 \\\\\n -5 & 10 & -10 & -8 \\\\\n 3 & 9 & -10 & -3 \\\\\n 9 & -2 & -2 & 8 \\\\\n 4 & -9 & 7 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, 6, -7, 5],\n [-5, 10, -10, -8],\n [3, 9, -10, -3],\n [9, -2, -2, 8],\n [4, -9, 7, -2]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 1 & -\\frac{5}{2} \\\\\n -\\frac{3}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{83}{8} & -\\frac{55}{4} \\\\\n -\\frac{33}{4} & \\frac{61}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(5/2)],\n [-(3/2), (1/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -6 \\\\\n 2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 7 \\\\\n 8 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{47}{15 \\sqrt{46}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-6],\n [2],\n [-2]]).squeeze()\nb = np.array([\n [9],\n [7],\n [8],\n [6]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -\\frac{2}{5} \\\\\n \\frac{19}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{5} \\\\\n -\\frac{49}{5} \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{951}{25} \\\\\n -\\frac{88}{25} \\\\\n \\frac{241}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-(2/5)],\n [(19/5)]])\nb = np.array([\n [-(2/5)],\n [-(49/5)],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 1 & 3 & -1 & 0 & 2 \\\\\n -3 & 1 & -3 & 1 & -3 \\\\\n -3 & 0 & -3 & -1 & 1 \\\\\n 1 & -2 & 3 & 3 & -3 \\\\\n 3 & 1 & 0 & 0 & 0 \\\\\n 1 & 2 & 2 & -3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.55 \\\\\n 2.12 \\\\\n 0.82 \\\\\n 0.81 \\\\\n -1.32 \\\\\n -0.29 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.748 \\\\\n 0.771 \\\\\n 0.375 \\\\\n 0.757 \\\\\n 0.167 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3, -1, 0, 2],\n [-3, 1, -3, 1, -3],\n [-3, 0, -3, -1, 1],\n [1, -2, 3, 3, -3],\n [3, 1, 0, 0, 0],\n [1, 2, 2, -3, 2]])\nb = np.array([\n [1.55],\n [2.12],\n [0.82],\n [0.81],\n [-1.32],\n [-0.29]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{2,\\frac{10}{3},-\\frac{8}{3}\\right\\}, \\left\\{\\frac{14}{3},-2,-\\frac{5}{3}\\right\\}, \\left\\{\\frac{5}{3},-3,2\\right\\}}$.", - "Output Answer": [ - "$501 x+345 y+504 z-808=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, (10/3), -(8/3)],\n [(14/3), -2, -(5/3)],\n [(5/3), -3, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{5}{4} & -\\frac{5}{8} & \\frac{5}{4} & -\\frac{47}{16} & -\\frac{7}{4} \\\\\n -\\frac{5}{4} & -\\frac{5}{16} & \\frac{7}{4} & \\frac{7}{8} & -\\frac{41}{16} \\\\\n \\frac{33}{16} & -3 & 1 & -\\frac{7}{4} & \\frac{13}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{39}{16} \\\\\n -\\frac{41}{16} \\\\\n \\frac{17}{8} \\\\\n \\frac{43}{16} \\\\\n -\\frac{13}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{213}{256} \\\\\n \\frac{189}{32} \\\\\n \\frac{2257}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/4), -(5/8), (5/4), -(47/16), -(7/4)],\n [-(5/4), -(5/16), (7/4), (7/8), -(41/16)],\n [(33/16), -3, 1, -(7/4), (13/8)]])\nb = np.array([\n [(39/16)],\n [-(41/16)],\n [(17/8)],\n [(43/16)],\n [-(13/16)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{2}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -9 & 0 & 1 \\\\\n 7 & -5 & -3 \\\\\n -1 & 2 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{9}{2} & 0 & -\\frac{1}{2} \\\\\n -\\frac{7}{2} & \\frac{5}{2} & \\frac{3}{2} \\\\\n \\frac{1}{2} & -1 & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 0, 1],\n [7, -5, -3],\n [-1, 2, -9]])\nprint(a * -(1/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 0 & \\frac{13}{2} & -\\frac{13}{2} \\\\\n \\frac{7}{4} & \\frac{5}{4} & 6 \\\\\n -9 & -\\frac{15}{2} & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{19 x^2}{4}+\\frac{41 x}{2}-\\frac{3029}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, (13/2), -(13/2)],\n [(7/4), (5/4), 6],\n [-9, -(15/2), (7/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -2 & 9 & 3 & -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & -8 & -1 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 0 & 1 & 2 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 9, 3, -7]])\nb = np.array([\n [2, -8, -1, 4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 5 & 1 \\\\\n 2 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-4 x-7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 1],\n [2, -1]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{13}{5} & -\\frac{16}{5} \\\\\n -\\frac{33}{10} & -\\frac{3}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/5), -(16/5)],\n [-(33/10), -(3/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{19}{5}, -\\frac{23}{5}, \\frac{17}{5}}$ to the plane $\\frac{17 x}{5}-\\frac{24 y}{5}+\\frac{12 z}{5}+5=0$.", - "Output Answer": [ - "$\\frac{1204}{5 \\sqrt{1009}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (19/5), -(23/5), (17/5)\nplane = Poly(((17*x)/5)-((24*y)/5)+((12*z)/5)+5, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-1$ and the matrix\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 7 \\\\\n 7 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2 \\\\\n -7 \\\\\n -7 \\\\\n -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [7],\n [7],\n [9]])\nprint(a * -1)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & -2 & -1 & -1 & -3 \\\\\n 0 & -2 & 2 & 0 & -1 \\\\\n -1 & 2 & 0 & 2 & -2 \\\\\n 2 & -3 & -1 & 3 & 0 \\\\\n -1 & -1 & -2 & 0 & -2 \\\\\n -1 & -3 & -2 & 3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.6 \\\\\n 2.54 \\\\\n 0.48 \\\\\n 0.14 \\\\\n 0.53 \\\\\n -0.7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.107 \\\\\n -0.104 \\\\\n 0.754 \\\\\n 0.238 \\\\\n -0.058 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, -1, -1, -3],\n [0, -2, 2, 0, -1],\n [-1, 2, 0, 2, -2],\n [2, -3, -1, 3, 0],\n [-1, -1, -2, 0, -2],\n [-1, -3, -2, 3, -2]])\nb = np.array([\n [-1.6],\n [2.54],\n [0.48],\n [0.14],\n [0.53],\n [-0.7]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 2 & 3 & -\\frac{3}{2} \\\\\n 8 & -\\frac{25}{4} & 3 \\\\\n \\frac{39}{4} & -\\frac{13}{2} & -\\frac{13}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{15 x^2}{2}-\\frac{183 x}{16}+\\frac{7423}{32}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 3, -(3/2)],\n [8, -(25/4), 3],\n [(39/4), -(13/2), -(13/4)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{29}{5} & -\\frac{44}{5} \\\\\n \\frac{31}{5} & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{5} \\left(27-4 i \\sqrt{85}\\right),\\frac{1}{5} \\left(27+4 i \\sqrt{85}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/5), -(44/5)],\n [(31/5), 5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n 1 \\\\\n -2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{3}{4},-\\frac{3}{8},-\\frac{3}{8},\\frac{3}{8},-\\frac{3}{8}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-2],\n [1],\n [-2],\n [-2]]).squeeze()\nb = np.array([\n [-2],\n [1],\n [1],\n [-1],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{5} & -\\frac{4}{5} & -\\frac{14}{5} \\\\\n 9 & -3 & -\\frac{27}{5} \\\\\n -\\frac{47}{5} & -\\frac{37}{5} & \\frac{46}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{34 x^2}{5}+\\frac{2074 x}{25}+\\frac{31317}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/5), -(4/5), -(14/5)],\n [9, -3, -(27/5)],\n [-(47/5), -(37/5), (46/5)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -6 \\\\\n 0 \\\\\n 1 \\\\\n -10 \\\\\n 7 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n 5 \\\\\n 9 \\\\\n 8 \\\\\n -6 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{663}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-6],\n [0],\n [1],\n [-10],\n [7],\n [-8]])\nb = np.array([\n [1],\n [-2],\n [5],\n [9],\n [8],\n [-6],\n [-1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 3-3 i & 5-i \\\\\n 2-4 i & -4+i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 6-40 i & -7-9 i \\\\\n -10 & 21-30 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3-3j, 5- 1j],\n [2-4j, -4+ 1j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n -\\frac{3}{5} \\\\\n -\\frac{2}{5} \\\\\n -\\frac{9}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{5} \\\\\n -2 \\\\\n \\frac{3}{5} \\\\\n -\\frac{4}{5} \\\\\n \\frac{2}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{217}{890},-\\frac{31}{89},\\frac{93}{890},-\\frac{62}{445},\\frac{31}{445}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [-(3/5)],\n [-(2/5)],\n [-(9/5)]]).squeeze()\nb = np.array([\n [-(7/5)],\n [-2],\n [(3/5)],\n [-(4/5)],\n [(2/5)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 0 & 3 & 0 & 3 & 0 \\\\\n 2 & -2 & -3 & -3 & -2 \\\\\n -2 & 2 & 3 & 2 & 2 \\\\\n -2 & 2 & 3 & 1 & -3 \\\\\n -2 & 0 & 2 & -2 & -1 \\\\\n -1 & 2 & 1 & 0 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.76 \\\\\n -1.85 \\\\\n 0.15 \\\\\n 0.74 \\\\\n -1.69 \\\\\n 2.86 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 5.566 \\\\\n 1.045 \\\\\n 4.021 \\\\\n -1.144 \\\\\n 0.541 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 3, 0, 3, 0],\n [2, -2, -3, -3, -2],\n [-2, 2, 3, 2, 2],\n [-2, 2, 3, 1, -3],\n [-2, 0, 2, -2, -1],\n [-1, 2, 1, 0, 3]])\nb = np.array([\n [-0.76],\n [-1.85],\n [0.15],\n [0.74],\n [-1.69],\n [2.86]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-1, 3}$ to the line $-\\frac{4 x}{3}+\\frac{2 y}{3}+\\frac{4}{3}=0$.", - "Output Answer": [ - "$\\frac{7}{\\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -1, 3\nline = Poly(-((4*x)/3)+((2*y)/3)+(4/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & -2 \\\\\n 2 & 1 \\\\\n 3 & 3 \\\\\n 2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.34 \\\\\n -0.23 \\\\\n 0.8 \\\\\n 0.08 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.007 \\\\\n 0.069 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2],\n [2, 1],\n [3, 3],\n [2, -2]])\nb = np.array([\n [0.34],\n [-0.23],\n [0.8],\n [0.08]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,-1,3\\}, \\{-1,-4,2\\}, \\{0,-4,2\\}}$.", - "Output Answer": [ - "$y-3 z+10=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, -1, 3],\n [-1, -4, 2],\n [0, -4, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -2 & -\\frac{1}{2} \\\\\n \\frac{5}{2} & 3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{27}{4} & -\\frac{23}{8} \\\\\n \\frac{115}{8} & 22 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -(1/2)],\n [(5/2), 3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{4}{5} \\\\\n \\frac{21}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{8}{\\sqrt{505}} \\\\\n \\frac{21}{\\sqrt{505}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/5)],\n [(21/10)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2 & \\frac{5}{2} & 3 \\\\\n \\frac{5}{2} & 2 & \\frac{3}{2} \\\\\n -1 & -\\frac{3}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{29}{4} & -\\frac{9}{2} & -\\frac{15}{4} \\\\\n -\\frac{3}{2} & 8 & \\frac{39}{4} \\\\\n -\\frac{5}{4} & -\\frac{19}{4} & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, (5/2), 3],\n [(5/2), 2, (3/2)],\n [-1, -(3/2), -(1/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n -3 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{2}{\\sqrt{19}} \\\\\n -\\frac{2}{\\sqrt{19}} \\\\\n -\\frac{3}{\\sqrt{19}} \\\\\n \\frac{1}{\\sqrt{19}} \\\\\n -\\frac{1}{\\sqrt{19}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-2],\n [-3],\n [1],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 9 \\\\\n -4 \\\\\n 7 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [9],\n [-4],\n [7],\n [8]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 1 \\\\\n -\\frac{5}{2} \\\\\n -1 \\\\\n 1 \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n 2 \\\\\n 2 \\\\\n 2 \\\\\n 1 \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{185}{172},-\\frac{37}{43},-\\frac{37}{43},-\\frac{37}{43},-\\frac{37}{86},\\frac{111}{172}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [1],\n [-(5/2)],\n [-1],\n [1],\n [-(3/2)]]).squeeze()\nb = np.array([\n [(5/2)],\n [2],\n [2],\n [2],\n [1],\n [-(3/2)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n -9 \\\\\n -9 \\\\\n -6 \\\\\n -9 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -9 \\\\\n 1 \\\\\n 9 \\\\\n 1 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$15$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [-9],\n [-9],\n [-6],\n [-9],\n [9]])\nb = np.array([\n [-6],\n [-9],\n [1],\n [9],\n [1],\n [-6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 5 & -4 & 4 & -10 \\\\\n -10 & -4 & -6 & 8 \\\\\n 3 & 1 & 10 & 4 \\\\\n -8 & -2 & 2 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, -4, 4, -10],\n [-10, -4, -6, 8],\n [3, 1, 10, 4],\n [-8, -2, 2, -9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & -3 \\\\\n 0 & -3 \\\\\n -3 & -3 \\\\\n 1 & 3 \\\\\n 3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.27 \\\\\n -1. \\\\\n 0.77 \\\\\n 2.6 \\\\\n -1.11 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.219 \\\\\n 0.17 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3],\n [0, -3],\n [-3, -3],\n [1, 3],\n [3, 3]])\nb = np.array([\n [0.27],\n [-1.],\n [0.77],\n [2.6],\n [-1.11]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{2} \\\\\n -\\frac{7}{16} \\\\\n \\frac{5}{16} \\\\\n \\frac{23}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{1}{4} & -\\frac{19}{16} & -\\frac{19}{8} & \\frac{47}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{5}{8} & \\frac{95}{32} & \\frac{95}{16} & -\\frac{235}{32} \\\\\n -\\frac{7}{64} & \\frac{133}{256} & \\frac{133}{128} & -\\frac{329}{256} \\\\\n \\frac{5}{64} & -\\frac{95}{256} & -\\frac{95}{128} & \\frac{235}{256} \\\\\n \\frac{23}{64} & -\\frac{437}{256} & -\\frac{437}{128} & \\frac{1081}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2)],\n [-(7/16)],\n [(5/16)],\n [(23/16)]])\nb = np.array([\n [(1/4), -(19/16), -(19/8), (47/16)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{9}{2} & -\\frac{35}{8} & -\\frac{79}{16} \\\\\n -4 & -\\frac{27}{16} & -\\frac{29}{8} \\\\\n \\frac{35}{16} & \\frac{7}{8} & \\frac{13}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1760}{13829} & \\frac{11424}{13829} & \\frac{30832}{13829} \\\\\n -\\frac{5856}{13829} & \\frac{14288}{13829} & \\frac{14080}{13829} \\\\\n \\frac{784}{13829} & -\\frac{23072}{13829} & -\\frac{40576}{13829} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2), -(35/8), -(79/16)],\n [-4, -(27/16), -(29/8)],\n [(35/16), (7/8), (13/8)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -3 & 2 & 5 & 5 & 0 & -1 \\\\\n -6 & -4 & -10 & 7 & -7 & 9 \\\\\n -4 & 8 & 4 & -6 & -7 & -1 \\\\\n -10 & 1 & -5 & 8 & -10 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & \\frac{307}{128} & -\\frac{7175}{128} \\\\\n 0 & 1 & 0 & 0 & \\frac{193}{128} & -\\frac{9629}{128} \\\\\n 0 & 0 & 1 & 0 & -\\frac{57}{128} & \\frac{4533}{128} \\\\\n 0 & 0 & 0 & 1 & \\frac{41}{32} & -\\frac{1253}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 2, 5, 5, 0, -1],\n [-6, -4, -10, 7, -7, 9],\n [-4, 8, 4, -6, -7, -1],\n [-10, 1, -5, 8, -10, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,1,2\\}, \\{2,2,2\\}, \\{-4,1,-4\\}}$.", - "Output Answer": [ - "$3 x-12 y-z+20=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, 1, 2],\n [2, 2, 2],\n [-4, 1, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{19}{10} & -\\frac{3}{2} \\\\\n \\frac{17}{5} & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{54}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/10), -(3/2)],\n [(17/5), -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n -18 & -33 & -11 & 60 \\\\\n 8 & 14 & 4 & -26 \\\\\n -14 & -22 & -9 & 43 \\\\\n -4 & -7 & -3 & 13 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -35 & -\\frac{129}{2} & -\\frac{43}{2} & \\frac{237}{2} \\\\\n \\frac{38}{3} & \\frac{67}{3} & 7 & -\\frac{121}{3} \\\\\n 1 & \\frac{7}{2} & 1 & -5 \\\\\n -\\frac{13}{3} & -\\frac{49}{6} & -3 & \\frac{47}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [-18, -33, -11, 60],\n [8, 14, 4, -26],\n [-14, -22, -9, 43],\n [-4, -7, -3, 13]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 0 & 10 & -4 & 8 & 8 & -3 & 4 \\\\\n 1 & -9 & 6 & -5 & -5 & 3 & 0 \\\\\n -4 & 1 & -7 & -6 & 4 & -1 & 8 \\\\\n 5 & -8 & -8 & 9 & 9 & 7 & -1 \\\\\n -8 & 5 & -9 & 1 & -6 & 7 & -1 \\\\\n -8 & 3 & -4 & -7 & -4 & -2 & -9 \\\\\n 6 & 8 & 4 & 6 & -9 & -7 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, 10, -4, 8, 8, -3, 4],\n [1, -9, 6, -5, -5, 3, 0],\n [-4, 1, -7, -6, 4, -1, 8],\n [5, -8, -8, 9, 9, 7, -1],\n [-8, 5, -9, 1, -6, 7, -1],\n [-8, 3, -4, -7, -4, -2, -9],\n [6, 8, 4, 6, -9, -7, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{1,-2,-3\\}, \\left\\{\\frac{8}{3},-\\frac{7}{3},-\\frac{8}{3}\\right\\}, \\left\\{-\\frac{2}{3},-\\frac{8}{3},-2\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{14}},-\\sqrt{\\frac{2}{7}},-\\frac{3}{\\sqrt{14}}\\right\\}, \\left\\{\\frac{33}{\\sqrt{1267}},-\\frac{3}{\\sqrt{1267}},\\frac{13}{\\sqrt{1267}}\\right\\}, \\left\\{-\\frac{5}{\\sqrt{362}},-8 \\sqrt{\\frac{2}{181}},\\frac{9}{\\sqrt{362}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((1, -2, -3), ((8/3), -(7/3), -(8/3)), (-(2/3), -(8/3), -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 3 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 4 \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2 \\\\\n 7 \\\\\n -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [3],\n [-9]])\nb = np.array([\n [-5],\n [4],\n [6]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{3}{4} & -1 & -\\frac{11}{4} & -\\frac{11}{4} & -\\frac{1}{2} \\\\\n -\\frac{3}{4} & -\\frac{7}{4} & -1 & \\frac{7}{4} & -\\frac{3}{4} \\\\\n \\frac{3}{4} & -1 & \\frac{9}{4} & \\frac{3}{4} & -\\frac{1}{2} \\\\\n \\frac{11}{4} & -\\frac{7}{4} & 1 & -\\frac{1}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{4} & \\frac{11}{4} \\\\\n -\\frac{9}{4} & -\\frac{3}{4} \\\\\n -2 & \\frac{7}{4} \\\\\n -\\frac{1}{2} & \\frac{1}{2} \\\\\n -\\frac{7}{4} & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{175}{16} & -8 \\\\\n \\frac{117}{16} & -\\frac{19}{8} \\\\\n -\\frac{43}{16} & \\frac{53}{8} \\\\\n -\\frac{3}{8} & \\frac{79}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/4), -1, -(11/4), -(11/4), -(1/2)],\n [-(3/4), -(7/4), -1, (7/4), -(3/4)],\n [(3/4), -1, (9/4), (3/4), -(1/2)],\n [(11/4), -(7/4), 1, -(1/2), -(1/2)]])\nb = np.array([\n [-(5/4), (11/4)],\n [-(9/4), -(3/4)],\n [-2, (7/4)],\n [-(1/2), (1/2)],\n [-(7/4), 1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{53}{7} \\\\\n -\\frac{67}{7} \\\\\n -\\frac{10}{7} \\\\\n -8 \\\\\n \\frac{11}{7} \\\\\n \\frac{32}{7} \\\\\n \\frac{43}{7} \\\\\n \\frac{4}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{45}{7} \\\\\n -\\frac{59}{7} \\\\\n -\\frac{59}{7} \\\\\n -5 \\\\\n \\frac{38}{7} \\\\\n -\\frac{39}{7} \\\\\n \\frac{2}{7} \\\\\n -\\frac{60}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{27 \\sqrt{33}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(53/7)],\n [-(67/7)],\n [-(10/7)],\n [-8],\n [(11/7)],\n [(32/7)],\n [(43/7)],\n [(4/7)]])\nb = np.array([\n [(45/7)],\n [-(59/7)],\n [-(59/7)],\n [-5],\n [(38/7)],\n [-(39/7)],\n [(2/7)],\n [-(60/7)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -\\frac{5}{4} \\\\\n -\\frac{3}{2} \\\\\n 5 \\\\\n 5 \\\\\n \\frac{5}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{11}{2} \\\\\n \\frac{19}{4} \\\\\n 5 \\\\\n 7 \\\\\n -\\frac{9}{4} \\\\\n -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(2 \\sqrt{\\frac{15785}{53}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-(5/4)],\n [-(3/2)],\n [5],\n [5],\n [(5/4)]]).squeeze()\nb = np.array([\n [(11/2)],\n [(19/4)],\n [5],\n [7],\n [-(9/4)],\n [-10]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{9} & \\frac{23}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/9), (23/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 10 & 0 & 0 \\\\\n 3 & -5 & -2 \\\\\n -4 & -4 & -1 \\\\\n -5 & -8 & 0 \\\\\n -10 & -6 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [10, 0, 0],\n [3, -5, -2],\n [-4, -4, -1],\n [-5, -8, 0],\n [-10, -6, -1]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -7 & 1 & -1 & 8 & 0 \\\\\n 5 & 0 & 9 & 1 & 9 \\\\\n 0 & -5 & -2 & 0 & -7 \\\\\n -4 & -4 & -10 & -4 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 1, -1, 8, 0],\n [5, 0, 9, 1, 9],\n [0, -5, -2, 0, -7],\n [-4, -4, -10, -4, 10]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -6 \\\\\n -8 \\\\\n -7 \\\\\n -10 \\\\\n 10 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -5 \\\\\n 2 \\\\\n -9 \\\\\n -3 \\\\\n 10 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$182$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-6],\n [-8],\n [-7],\n [-10],\n [10],\n [10]])\nb = np.array([\n [5],\n [-5],\n [2],\n [-9],\n [-3],\n [10],\n [2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{23}{3} & -\\frac{28}{3} \\\\\n \\frac{13}{3} & \\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{13} \\left(-17-5 i \\sqrt{3}\\right),1\\right\\}, \\left\\{\\frac{1}{13} \\left(-17+5 i \\sqrt{3}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/3), -(28/3)],\n [(13/3), (11/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & 2 \\\\\n 3 & -1 \\\\\n -3 & -1 \\\\\n -3 & -1 \\\\\n 3 & -2 \\\\\n -3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.45 \\\\\n -2.74 \\\\\n -1.31 \\\\\n 1.91 \\\\\n -0.79 \\\\\n -0.73 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.174 \\\\\n 0.153 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2],\n [3, -1],\n [-3, -1],\n [-3, -1],\n [3, -2],\n [-3, 2]])\nb = np.array([\n [0.45],\n [-2.74],\n [-1.31],\n [1.91],\n [-0.79],\n [-0.73]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{3}{4} & \\frac{5}{8} & -2 & 0 & \\frac{19}{8} \\\\\n -\\frac{5}{8} & -\\frac{3}{4} & \\frac{3}{8} & -\\frac{15}{8} & -\\frac{21}{8} \\\\\n -\\frac{9}{4} & -\\frac{3}{4} & -1 & 0 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{8} \\\\\n \\frac{9}{8} \\\\\n -\\frac{7}{4} \\\\\n -\\frac{3}{4} \\\\\n -\\frac{13}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n \\frac{39}{8} \\\\\n \\frac{133}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/4), (5/8), -2, 0, (19/8)],\n [-(5/8), -(3/4), (3/8), -(15/8), -(21/8)],\n [-(9/4), -(3/4), -1, 0, -3]])\nb = np.array([\n [-(9/8)],\n [(9/8)],\n [-(7/4)],\n [-(3/4)],\n [-(13/8)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{3}{2} & 6 & -\\frac{5}{2} & -6 \\\\\n -\\frac{5}{2} & -4 & 7 & 6 \\\\\n -\\frac{5}{2} & 4 & 7 & -\\frac{15}{2} \\\\\n \\frac{9}{2} & 6 & \\frac{7}{2} & -8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -3 & -7 & -6 & -\\frac{9}{2} \\\\\n \\frac{1}{2} & 0 & 4 & -\\frac{15}{2} \\\\\n -3 & \\frac{5}{2} & -\\frac{11}{2} & 7 \\\\\n -6 & -\\frac{7}{2} & -6 & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{9}{2} & 13 & \\frac{7}{2} & -\\frac{3}{2} \\\\\n -3 & -4 & 3 & \\frac{27}{2} \\\\\n \\frac{1}{2} & \\frac{3}{2} & \\frac{25}{2} & -\\frac{29}{2} \\\\\n \\frac{21}{2} & \\frac{19}{2} & \\frac{19}{2} & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), 6, -(5/2), -6],\n [-(5/2), -4, 7, 6],\n [-(5/2), 4, 7, -(15/2)],\n [(9/2), 6, (7/2), -8]])\nb = np.array([\n [-3, -7, -6, -(9/2)],\n [(1/2), 0, 4, -(15/2)],\n [-3, (5/2), -(11/2), 7],\n [-6, -(7/2), -6, -(9/2)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -3 \\\\\n -10 \\\\\n -6 \\\\\n 9 \\\\\n 6 \\\\\n 3 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 1 \\\\\n 0 \\\\\n 10 \\\\\n 9 \\\\\n -2 \\\\\n -4 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{22}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-3],\n [-10],\n [-6],\n [9],\n [6],\n [3],\n [-1]])\nb = np.array([\n [2],\n [1],\n [0],\n [10],\n [9],\n [-2],\n [-4],\n [7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n \\frac{15}{2} \\\\\n \\frac{7}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n \\frac{26}{3} \\\\\n -\\frac{1}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{773}{36} \\\\\n -\\frac{25}{6} \\\\\n -\\frac{281}{12} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [(15/2)],\n [(7/3)]])\nb = np.array([\n [-(3/2)],\n [(26/3)],\n [-(1/6)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{11}{9} & -\\frac{25}{9} & \\frac{7}{3} & 3 & -\\frac{5}{9} \\\\\n -\\frac{22}{9} & \\frac{8}{3} & 0 & -\\frac{4}{9} & \\frac{1}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -\\frac{11}{9} \\\\\n \\frac{4}{3} \\\\\n \\frac{5}{3} \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{788}{81} \\\\\n -\\frac{11}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/9), -(25/9), (7/3), 3, -(5/9)],\n [-(22/9), (8/3), 0, -(4/9), (1/3)]])\nb = np.array([\n [-1],\n [-(11/9)],\n [(4/3)],\n [(5/3)],\n [1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{8}{3}, -\\frac{11}{3}}$ to the line $-\\frac{10 x}{3}+\\frac{y}{3}-\\frac{1}{3}=0$.", - "Output Answer": [ - "$\\frac{94}{3 \\sqrt{101}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (8/3), -(11/3)\nline = Poly(-((10*x)/3)+(y/3)-(1/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & 2 & 3 \\\\\n -3 & -1 & 0 \\\\\n 2 & 0 & 1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & -2 & 3 \\\\\n 3 & -5 & -9 \\\\\n 2 & 4 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, 3],\n [-3, -1, 0],\n [2, 0, 1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\sqrt{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\sqrt{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$40$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [4*math.sqrt(5)]])\nb = np.array([\n [2*math.sqrt(5)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{4} \\\\\n -\\frac{15}{16} \\\\\n -\\frac{13}{8} \\\\\n \\frac{21}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{12}{53} \\\\\n -\\frac{15}{53} \\\\\n -\\frac{26}{53} \\\\\n \\frac{42}{53} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/4)],\n [-(15/16)],\n [-(13/8)],\n [(21/8)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{2} \\\\\n -3 \\\\\n 1 \\\\\n -\\frac{27}{4} \\\\\n \\frac{11}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{27}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2)],\n [-3],\n [1],\n [-(27/4)],\n [(11/4)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -\\frac{54}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{75}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-(54/7)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3.431 \\\\\n -2.908 \\\\\n -8.033 \\\\\n -1.11 \\\\\n 8.765 \\\\\n 2.658 \\\\\n -7.759 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2.843 \\\\\n -7.594 \\\\\n -1.763 \\\\\n -7.67 \\\\\n 3.062 \\\\\n 5.804 \\\\\n 8.111 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$14.3371$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3.431],\n [-2.908],\n [-8.033],\n [-1.11],\n [8.765],\n [2.658],\n [-7.759]])\nb = np.array([\n [2.843],\n [-7.594],\n [-1.763],\n [-7.67],\n [3.062],\n [5.804],\n [8.111]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{26}{7}, \\frac{4}{7}}$ to the line $-\\frac{34 x}{7}-\\frac{8 y}{7}-\\frac{2}{7}=0$.", - "Output Answer": [ - "$\\frac{93 \\sqrt{\\frac{5}{61}}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (26/7), (4/7)\nline = Poly(-((34*x)/7)-((8*y)/7)-(2/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 0 \\\\\n -3 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-15$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 0],\n [-3, -5]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{20}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -4 & -4 & 3 \\\\\n -9 & 1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{5} & -\\frac{3}{5} & \\frac{9}{20} \\\\\n -\\frac{27}{20} & \\frac{3}{20} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -4, 3],\n [-9, 1, 0]])\nprint(a * (3/20))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -8 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -6 \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 44 \\\\\n 72 \\\\\n 40 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-8],\n [10]])\nb = np.array([\n [8],\n [-6],\n [2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 5 & -\\frac{7}{3} \\\\\n -1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{37}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -(7/3)],\n [-1, -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -10 & -5 \\\\\n -1 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{2} \\left(3-\\sqrt{29}\\right),1\\right\\}, \\left\\{\\frac{1}{2} \\left(3+\\sqrt{29}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -5],\n [-1, -7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{37}{4} & -3 & \\frac{43}{8} \\\\\n -\\frac{37}{4} & -9 & \\frac{55}{8} \\\\\n \\frac{1}{8} & 5 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{19 x^2}{4}+\\frac{9427 x}{64}-\\frac{259}{32}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/4), -3, (43/8)],\n [-(37/4), -9, (55/8)],\n [(1/8), 5, -5]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & 7 \\\\\n 1 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{1-2 \\sqrt{2},1\\right\\}, \\left\\{1+2 \\sqrt{2},1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 7],\n [1, 7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & -9 \\\\\n -3 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(1-\\sqrt{277}\\right),\\frac{1}{2} \\left(1+\\sqrt{277}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -9],\n [-3, 7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{5}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -1 \\\\\n -1 & 0 \\\\\n 4 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{2}{5} & \\frac{1}{5} \\\\\n \\frac{1}{5} & 0 \\\\\n -\\frac{4}{5} & -\\frac{7}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1],\n [-1, 0],\n [4, 7]])\nprint(a * -(1/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 2 & -1 \\\\\n -2 & 2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 20 & -14 \\\\\n -28 & 20 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1],\n [-2, 2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [0]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{17}{5}, -\\frac{16}{5}, \\frac{16}{5}}$ to the plane $\\frac{3 x}{5}+5 y-\\frac{2 z}{5}+\\frac{1}{5}=0$.", - "Output Answer": [ - "$\\frac{239 \\sqrt{\\frac{2}{319}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(17/5), -(16/5), (16/5)\nplane = Poly(((3*x)/5)+5*y-((2*z)/5)+(1/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 3 & 0 & -2 \\\\\n 9 & 5 & -1 \\\\\n -10 & -3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-3.462,2.558,7.904\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 0, -2],\n [9, 5, -1],\n [-10, -3, -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 2 & 1 & -\\frac{3}{2} \\\\\n -1 & \\frac{3}{2} & -2 \\\\\n 2 & -\\frac{5}{2} & 1 \\\\\n -2 & \\frac{5}{2} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{3}{2} & \\frac{3}{2} & -\\frac{1}{2} & 2 & 0 \\\\\n 0 & -\\frac{5}{2} & \\frac{3}{2} & 2 & \\frac{3}{2} \\\\\n \\frac{1}{2} & -\\frac{1}{2} & \\frac{5}{2} & -\\frac{1}{2} & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -\\frac{15}{4} & \\frac{5}{4} & -\\frac{13}{4} & \\frac{27}{4} & -3 \\\\\n \\frac{1}{2} & -\\frac{17}{4} & -\\frac{9}{4} & 2 & -\\frac{15}{4} \\\\\n -\\frac{5}{2} & \\frac{35}{4} & -\\frac{9}{4} & -\\frac{3}{2} & -\\frac{3}{4} \\\\\n \\frac{9}{4} & -\\frac{17}{2} & 1 & \\frac{7}{4} & -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, -(3/2)],\n [-1, (3/2), -2],\n [2, -(5/2), 1],\n [-2, (5/2), -(3/2)]])\nb = np.array([\n [-(3/2), (3/2), -(1/2), 2, 0],\n [0, -(5/2), (3/2), 2, (3/2)],\n [(1/2), -(1/2), (5/2), -(1/2), 3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\sqrt{2} \\\\\n 3 \\sqrt{2} \\\\\n 2 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{5}{\\sqrt{2}} \\\\\n -\\frac{11}{\\sqrt{2}} \\\\\n \\frac{1}{\\sqrt{2}} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-46$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-3*math.sqrt(2)],\n [3*math.sqrt(2)],\n [2*math.sqrt(2)]])\nb = np.array([\n [(5/(math.sqrt(2)))],\n [-(11/(math.sqrt(2)))],\n [(1/(math.sqrt(2)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -8 \\\\\n 7 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7 \\sqrt{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-8],\n [7],\n [-3]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -\\frac{2}{5} & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{14}{5} & -\\frac{9}{5} & 2 & -\\frac{13}{5} \\\\\n \\frac{9}{10} & \\frac{1}{5} & -\\frac{13}{5} & \\frac{11}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{17}{25} & \\frac{8}{25} & \\frac{22}{5} & -\\frac{84}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/5), -2]])\nb = np.array([\n [-(14/5), -(9/5), 2, -(13/5)],\n [(9/10), (1/5), -(13/5), (11/5)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{2}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -8 & 4 & -4 & -3 \\\\\n -10 & 5 & 5 & -8 \\\\\n -1 & -8 & 4 & 3 \\\\\n 8 & 2 & -1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -4 & 2 & -2 & -\\frac{3}{2} \\\\\n -5 & \\frac{5}{2} & \\frac{5}{2} & -4 \\\\\n -\\frac{1}{2} & -4 & 2 & \\frac{3}{2} \\\\\n 4 & 1 & -\\frac{1}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 4, -4, -3],\n [-10, 5, 5, -8],\n [-1, -8, 4, 3],\n [8, 2, -1, -1]])\nprint(a * (1/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -1 & 1 & 0 \\\\\n -4 & -3 & -3 \\\\\n 3 & -4 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{8} & -\\frac{1}{8} & -\\frac{1}{8} \\\\\n \\frac{1}{8} & -\\frac{1}{8} & -\\frac{1}{8} \\\\\n \\frac{25}{24} & -\\frac{1}{24} & \\frac{7}{24} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, 0],\n [-4, -3, -3],\n [3, -4, 3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n 4 & -6 & -5 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -6, -5, -6]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 1 & -9 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 2 & -7 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 3 & -16 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -9, 8]])\nb = np.array([\n [2, -7, -9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{29}{4} & -\\frac{13}{2} \\\\\n -5 & -\\frac{21}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 5 & \\frac{23}{4} \\\\\n \\frac{5}{4} & \\frac{33}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{9}{4} & -\\frac{49}{4} \\\\\n -\\frac{25}{4} & -\\frac{27}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/4), -(13/2)],\n [-5, -(21/4)]])\nb = np.array([\n [5, (23/4)],\n [(5/4), (33/4)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 9 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [9],\n [0]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & -\\frac{3}{2} & \\frac{3}{2} \\\\\n -1 & -\\frac{3}{2} & 3 \\\\\n 0 & -1 & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & -\\frac{3}{4} & -\\frac{15}{4} \\\\\n \\frac{1}{2} & \\frac{3}{4} & -\\frac{15}{2} \\\\\n 1 & 2 & -\\frac{11}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(3/2), (3/2)],\n [-1, -(3/2), 3],\n [0, -1, -(1/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -4 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 2 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 6 \\\\\n 4 \\\\\n 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-4],\n [7]])\nb = np.array([\n [2],\n [2],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{17}{5} & -\\frac{33}{5} & -3 \\\\\n \\frac{28}{5} & -\\frac{27}{5} & -\\frac{17}{5} \\\\\n -\\frac{18}{5} & -1 & \\frac{17}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.148,-0.433,1.\\}, \\{1.284\\, -0.536 i,0.261\\, -0.959 i,1.\\}, \\{1.284\\, +0.536 i,0.261\\, +0.959 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/5), -(33/5), -3],\n [(28/5), -(27/5), -(17/5)],\n [-(18/5), -1, (17/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{19}{2} \\\\\n \\frac{15}{2} \\\\\n -\\frac{29}{4} \\\\\n \\frac{13}{2} \\\\\n -\\frac{31}{4} \\\\\n \\frac{21}{4} \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{177}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/2)],\n [(15/2)],\n [-(29/4)],\n [(13/2)],\n [-(31/4)],\n [(21/4)],\n [-(1/2)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 0 & 1 & 0 & -3 & -3 \\\\\n -2 & -2 & 1 & -3 & 2 \\\\\n 0 & 0 & 2 & 3 & -3 \\\\\n 2 & 3 & 1 & 3 & -3 \\\\\n 1 & -1 & 2 & 0 & 2 \\\\\n 0 & 2 & -1 & 2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.27 \\\\\n 0.16 \\\\\n 1.87 \\\\\n 0.07 \\\\\n -0.22 \\\\\n -2.95 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.661 \\\\\n -1.415 \\\\\n -0.045 \\\\\n 0.24 \\\\\n -0.45 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 0, -3, -3],\n [-2, -2, 1, -3, 2],\n [0, 0, 2, 3, -3],\n [2, 3, 1, 3, -3],\n [1, -1, 2, 0, 2],\n [0, 2, -1, 2, -2]])\nb = np.array([\n [-1.27],\n [0.16],\n [1.87],\n [0.07],\n [-0.22],\n [-2.95]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 1 \\\\\n -5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -8 \\\\\n -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n 9 \\\\\n -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [1],\n [-5]])\nb = np.array([\n [2],\n [-8],\n [-3]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{41}{5} & \\frac{22}{5} \\\\\n -6 & -\\frac{23}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{5} \\left(9-2 \\sqrt{91}\\right),\\frac{1}{5} \\left(9+2 \\sqrt{91}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(41/5), (22/5)],\n [-6, -(23/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 7 \\\\\n 6 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -6 \\\\\n 4 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-24 \\sqrt{\\frac{2}{3055}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [7],\n [6],\n [-6]]).squeeze()\nb = np.array([\n [6],\n [-6],\n [4],\n [10]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-1$ and the matrix\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n 7 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1 \\\\\n -2 \\\\\n -7 \\\\\n -10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [2],\n [7],\n [10]])\nprint(a * -1)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 9 & 9 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.,0.,3.\\}, \\{-1.,1.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, 9, 3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{8} & -\\frac{143}{16} & \\frac{21}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/8), -(143/16), (21/8)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & -4 \\\\\n -10 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(1-\\sqrt{449}\\right),\\frac{1}{2} \\left(1+\\sqrt{449}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -4],\n [-10, -8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -7 & -5 & -5 \\\\\n 8 & 9 & -7 \\\\\n -9 & -7 & 1 \\\\\n 2 & -1 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, -5, -5],\n [8, 9, -7],\n [-9, -7, 1],\n [2, -1, 8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -6 \\\\\n 5 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-6],\n [5],\n [-7]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,2,0\\}, \\left\\{-2,-\\frac{1}{2},-\\frac{5}{2}\\right\\}, \\left\\{\\frac{5}{2},-3,2\\right\\}}$", - "Output Answer": [ - "${\\{0,1,0\\}, \\left\\{-\\frac{4}{\\sqrt{41}},0,-\\frac{5}{\\sqrt{41}}\\right\\}, \\left\\{\\frac{5}{\\sqrt{41}},0,-\\frac{4}{\\sqrt{41}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, 2, 0), (-2, -(1/2), -(5/2)), ((5/2), -3, 2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{16}{5}, \\frac{18}{5}, -\\frac{19}{5}}$ to the plane $3 x+\\frac{23 y}{5}+\\frac{3 z}{5}+2=0$.", - "Output Answer": [ - "$\\frac{167}{5 \\sqrt{763}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(16/5), (18/5), -(19/5)\nplane = Poly(3*x+((23*y)/5)+((3*z)/5)+2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 6 & \\frac{27}{4} & \\frac{73}{8} \\\\\n \\frac{33}{4} & -\\frac{33}{4} & -7 \\\\\n \\frac{17}{8} & -\\frac{1}{8} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{7 x^2}{4}+\\frac{8101 x}{64}-\\frac{123}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, (27/4), (73/8)],\n [(33/4), -(33/4), -7],\n [(17/8), -(1/8), (1/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n \\frac{37}{16} & -\\frac{11}{8} & \\frac{43}{16} & -\\frac{25}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{39}{16} \\\\\n -\\frac{3}{16} \\\\\n -\\frac{25}{16} \\\\\n -\\frac{3}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{73}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/16), -(11/8), (43/16), -(25/16)]])\nb = np.array([\n [(39/16)],\n [-(3/16)],\n [-(25/16)],\n [-(3/8)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n -\\frac{7}{3} \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{\\sqrt{67}} \\\\\n -\\frac{3}{\\sqrt{67}} \\\\\n -\\frac{7}{\\sqrt{67}} \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [-(7/3)],\n [0]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & -3 & 2 \\\\\n 0 & -2 & 2 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & -\\frac{3}{4} & \\frac{1}{2} \\\\\n 0 & -\\frac{1}{2} & 1 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3, 2],\n [0, -2, 2],\n [0, 0, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 2 & -5 \\\\\n -9 & -10 \\\\\n 2 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, -5],\n [-9, -10],\n [2, 9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{4} \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{15}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/4)],\n [-1]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,-1,4\\}, \\{4,5,4\\}, \\{2,3,3\\}}$.", - "Output Answer": [ - "$2 x-y-2 z+5=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -1, 4],\n [4, 5, 4],\n [2, 3, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -2 \\\\\n -1 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -2 & -2 & 2 & -2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -6 & -6 & 6 & -6 & -3 \\\\\n 4 & 4 & -4 & 4 & 2 \\\\\n 2 & 2 & -2 & 2 & 1 \\\\\n 4 & 4 & -4 & 4 & 2 \\\\\n -2 & -2 & 2 & -2 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-2],\n [-1],\n [-2],\n [1]])\nb = np.array([\n [-2, -2, 2, -2, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & -\\frac{23}{4} \\\\\n -\\frac{1}{4} & \\frac{35}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{2} \\left(19-\\sqrt{453}\\right),1\\right\\}, \\left\\{\\frac{1}{2} \\left(19+\\sqrt{453}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -(23/4)],\n [-(1/4), (35/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 0 & 0 \\\\\n 2 & -1 \\\\\n 0 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n 4 \\\\\n 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0],\n [2, -1],\n [0, 2]])\nb = np.array([\n [3],\n [2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -2 & 1 & 1 & 2 \\\\\n 0 & -1 & 2 & -1 \\\\\n -1 & -1 & -2 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -2 & 2 & -2 & 2 \\\\\n 1 & -2 & 1 & 2 \\\\\n 1 & -1 & -1 & -1 \\\\\n 2 & 3 & 1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 10 & -1 & 6 & -1 \\\\\n -1 & -3 & -4 & -5 \\\\\n -5 & -4 & 1 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 1, 1, 2],\n [0, -1, 2, -1],\n [-1, -1, -2, -2]])\nb = np.array([\n [-2, 2, -2, 2],\n [1, -2, 1, 2],\n [1, -1, -1, -1],\n [2, 3, 1, 1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 10 & -2 \\\\\n 6 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{2 \\left(2-\\sqrt{6}\\right),2 \\left(2+\\sqrt{6}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -2],\n [6, -2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 8 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 13 \\\\\n 26 \\\\\n -39 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [8],\n [5]])\nb = np.array([\n [5],\n [-1],\n [1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & 1 & 2 \\\\\n -3 & -2 & -1 \\\\\n 3 & 1 & -2 \\\\\n -2 & 0 & 1 \\\\\n 2 & 3 & 2 \\\\\n 1 & -1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.56 \\\\\n -0.85 \\\\\n 0.73 \\\\\n -0.17 \\\\\n -2.03 \\\\\n 2.1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.447 \\\\\n -0.886 \\\\\n 0.052 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1, 2],\n [-3, -2, -1],\n [3, 1, -2],\n [-2, 0, 1],\n [2, 3, 2],\n [1, -1, 3]])\nb = np.array([\n [-0.56],\n [-0.85],\n [0.73],\n [-0.17],\n [-2.03],\n [2.1]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{69}{32}, -\\frac{129}{32}}$ to the line $\\frac{127 x}{32}+\\frac{119 y}{32}-\\frac{29}{16}=0$.", - "Output Answer": [ - "$\\frac{2111}{8 \\sqrt{30290}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (69/32), -(129/32)\nline = Poly(((127*x)/32)+((119*y)/32)-(29/16), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & 4 & 3 \\\\\n -4 & 1 & 4 \\\\\n 1 & 4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{19}{45} & -\\frac{8}{15} & -\\frac{13}{45} \\\\\n \\frac{8}{45} & -\\frac{1}{15} & \\frac{4}{45} \\\\\n \\frac{17}{45} & -\\frac{4}{15} & -\\frac{14}{45} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 4, 3],\n [-4, 1, 4],\n [1, 4, -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -1 \\\\\n 0 \\\\\n \\frac{5}{4} \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{8}{11} \\\\\n -\\frac{4}{11} \\\\\n 0 \\\\\n \\frac{5}{11} \\\\\n -\\frac{4}{11} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-1],\n [0],\n [(5/4)],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $2$ and the matrix\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 7 \\\\\n -3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 12 \\\\\n 14 \\\\\n -6 \\\\\n -16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [7],\n [-3],\n [-8]])\nprint(a * 2)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -4 \\\\\n -6 \\\\\n -5 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 10 \\\\\n 0 \\\\\n 0 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-47$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-4],\n [-6],\n [-5],\n [-4]])\nb = np.array([\n [-1],\n [10],\n [0],\n [0],\n [3]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{9}{5}, 4, \\frac{23}{5}}$ to the plane $\\frac{11 x}{5}-\\frac{4 y}{5}+2 z-3=0$.", - "Output Answer": [ - "$\\frac{58 \\sqrt{\\frac{3}{79}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (9/5), 4, (23/5)\nplane = Poly(((11*x)/5)-((4*y)/5)+2*z-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -3 & -2 \\\\\n -9 & -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -1 & 3 \\\\\n 10 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -4 & 1 \\\\\n 1 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2],\n [-9, -4]])\nb = np.array([\n [-1, 3],\n [10, 8]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${4, -5}$ to the line $\\frac{7 x}{2}-\\frac{9 y}{2}-3=0$.", - "Output Answer": [ - "$\\frac{67}{\\sqrt{130}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 4, -5\nline = Poly(((7*x)/2)-((9*y)/2)-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n 5 & 8 & 7 & 5 & 9 \\\\\n 6 & -9 & 1 & -1 & 3 \\\\\n 2 & -9 & 6 & 9 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 8, 7, 5, 9],\n [6, -9, 1, -1, 3],\n [2, -9, 6, 9, 8]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n \\frac{3}{4} & 2 & \\frac{1}{4} & \\frac{9}{4} \\\\\n 0 & \\frac{7}{4} & -2 & 1 \\\\\n \\frac{9}{4} & \\frac{3}{4} & \\frac{1}{2} & 0 \\\\\n \\frac{3}{2} & -1 & -\\frac{5}{4} & \\frac{7}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n \\frac{11}{4} & 2 & \\frac{3}{2} & -\\frac{3}{2} & -\\frac{1}{4} \\\\\n \\frac{3}{2} & -\\frac{5}{2} & -\\frac{5}{4} & 1 & \\frac{5}{4} \\\\\n -\\frac{3}{4} & \\frac{9}{4} & -1 & \\frac{9}{4} & -\\frac{3}{2} \\\\\n -2 & -\\frac{1}{4} & -\\frac{5}{4} & \\frac{11}{4} & \\frac{7}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n \\frac{3}{8} & -\\frac{7}{2} & -\\frac{71}{16} & \\frac{61}{8} & \\frac{47}{8} \\\\\n \\frac{17}{8} & -\\frac{73}{8} & -\\frac{23}{16} & 0 & \\frac{111}{16} \\\\\n \\frac{111}{16} & \\frac{15}{4} & \\frac{31}{16} & -\\frac{3}{2} & -\\frac{3}{8} \\\\\n \\frac{1}{16} & \\frac{9}{4} & \\frac{41}{16} & -\\frac{5}{4} & \\frac{53}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/4), 2, (1/4), (9/4)],\n [0, (7/4), -2, 1],\n [(9/4), (3/4), (1/2), 0],\n [(3/2), -1, -(5/4), (7/4)]])\nb = np.array([\n [(11/4), 2, (3/2), -(3/2), -(1/4)],\n [(3/2), -(5/2), -(5/4), 1, (5/4)],\n [-(3/4), (9/4), -1, (9/4), -(3/2)],\n [-2, -(1/4), -(5/4), (11/4), (7/4)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -6 & 4 & -10 \\\\\n 7 & 5 & -7 \\\\\n 3 & 9 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8.971,3.486\\, -9.295 i,3.486\\, +9.295 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 4, -10],\n [7, 5, -7],\n [3, 9, -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n \\frac{133}{16} & -\\frac{21}{8} & -\\frac{133}{16} \\\\\n -\\frac{19}{4} & \\frac{25}{8} & -\\frac{11}{2} \\\\\n \\frac{33}{8} & \\frac{41}{16} & -\\frac{21}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(133/16), -(21/8), -(133/16)],\n [-(19/4), (25/8), -(11/2)],\n [(33/8), (41/16), -(21/16)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 3 & -2 \\\\\n \\frac{1}{2} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{45}{2} & -\\frac{23}{2} \\\\\n \\frac{23}{8} & -\\frac{27}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2],\n [(1/2), -(3/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-1,2,0\\}, \\{-1,-3,-3\\}, \\{1,-3,2\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{5}},\\frac{2}{\\sqrt{5}},0\\right\\}, \\left\\{-\\sqrt{\\frac{2}{7}},-\\frac{1}{\\sqrt{14}},-\\frac{3}{\\sqrt{14}}\\right\\}, \\left\\{-3 \\sqrt{\\frac{2}{35}},-\\frac{3}{\\sqrt{70}},\\sqrt{\\frac{5}{14}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, 2, 0), (-1, -3, -3), (1, -3, 2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -6 & 4 & -9 \\\\\n 3 & 5 & -6 \\\\\n 4 & -10 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-6, 4, -9],\n [3, 5, -6],\n [4, -10, 1]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 0 & -1 \\\\\n -3 & -2 & 0 \\\\\n 3 & 3 & -1 \\\\\n -2 & 3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.12 \\\\\n 1.17 \\\\\n 2.06 \\\\\n 2.75 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.684 \\\\\n 1.129 \\\\\n 0.549 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, -1],\n [-3, -2, 0],\n [3, 3, -1],\n [-2, 3, -3]])\nb = np.array([\n [-2.12],\n [1.17],\n [2.06],\n [2.75]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{11}{6} & \\frac{5}{6} & -1 & -1 & -\\frac{5}{2} \\\\\n \\frac{17}{6} & \\frac{3}{2} & -\\frac{1}{3} & \\frac{1}{2} & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{5}{6} & -\\frac{1}{2} & -\\frac{1}{2} & 3 \\\\\n \\frac{17}{6} & \\frac{3}{2} & -\\frac{7}{3} & -\\frac{11}{6} \\\\\n \\frac{1}{6} & \\frac{4}{3} & \\frac{13}{6} & \\frac{5}{6} \\\\\n -\\frac{11}{6} & -\\frac{5}{3} & \\frac{3}{2} & \\frac{2}{3} \\\\\n \\frac{3}{2} & \\frac{7}{3} & -\\frac{3}{2} & -\\frac{7}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{65}{36} & -\\frac{31}{6} & -\\frac{25}{9} & \\frac{97}{18} \\\\\n \\frac{185}{36} & -\\frac{11}{9} & -\\frac{79}{18} & \\frac{223}{36} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/6), (5/6), -1, -1, -(5/2)],\n [(17/6), (3/2), -(1/3), (1/2), -(1/3)]])\nb = np.array([\n [(5/6), -(1/2), -(1/2), 3],\n [(17/6), (3/2), -(7/3), -(11/6)],\n [(1/6), (4/3), (13/6), (5/6)],\n [-(11/6), -(5/3), (3/2), (2/3)],\n [(3/2), (7/3), -(3/2), -(7/6)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -3 \\\\\n -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [2]])\nb = np.array([\n [8],\n [5]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n \\frac{59}{6} \\\\\n -\\frac{19}{2} \\\\\n -\\frac{22}{3} \\\\\n \\frac{10}{3} \\\\\n -\\frac{19}{3} \\\\\n \\frac{53}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{289}{6}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [(59/6)],\n [-(19/2)],\n [-(22/3)],\n [(10/3)],\n [-(19/3)],\n [(53/6)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{38}{25} \\\\\n -\\frac{157}{50} \\\\\n \\frac{391}{50} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{459}{50} \\\\\n -\\frac{833}{100} \\\\\n \\frac{527}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{383}{50} \\\\\n -\\frac{1147}{100} \\\\\n \\frac{1309}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(38/25)],\n [-(157/50)],\n [(391/50)]])\nb = np.array([\n [(459/50)],\n [-(833/100)],\n [(527/100)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & -1 & 0 \\\\\n -3 & 1 & -1 \\\\\n 2 & 3 & 2 \\\\\n -1 & -1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.96 \\\\\n 2.78 \\\\\n 1.87 \\\\\n -1.28 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.88 \\\\\n 1.025 \\\\\n 0.143 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1, 0],\n [-3, 1, -1],\n [2, 3, 2],\n [-1, -1, 1]])\nb = np.array([\n [2.96],\n [2.78],\n [1.87],\n [-1.28]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 2 & -1 \\\\\n 3 & 2 & -3 \\\\\n 1 & 1 & -2 \\\\\n -1 & 3 & 3 \\\\\n 0 & -3 & 1 \\\\\n -1 & 1 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.83 \\\\\n 1.99 \\\\\n -1.08 \\\\\n 2.95 \\\\\n 1.87 \\\\\n 2.93 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.672 \\\\\n 0.244 \\\\\n -0.184 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, -1],\n [3, 2, -3],\n [1, 1, -2],\n [-1, 3, 3],\n [0, -3, 1],\n [-1, 1, -3]])\nb = np.array([\n [-2.83],\n [1.99],\n [-1.08],\n [2.95],\n [1.87],\n [2.93]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{10}{3} & \\frac{25}{3} & \\frac{10}{3} \\\\\n -\\frac{19}{3} & -\\frac{5}{3} & -3 \\\\\n -\\frac{29}{3} & \\frac{7}{3} & \\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{0.737\\, -9.291 i,0.737\\, +9.291 i,3.859\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(10/3), (25/3), (10/3)],\n [-(19/3), -(5/3), -3],\n [-(29/3), (7/3), (11/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 e \\\\\n e \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 e \\\\\n 4 e \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{34} e$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-3*math.e],\n [math.e]])\nb = np.array([\n [2*math.e],\n [4*math.e]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{9}{4} \\\\\n -5 \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{49}{8} \\\\\n \\frac{3}{8} \\\\\n -\\frac{49}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{499}{16} \\\\\n \\frac{735}{32} \\\\\n -\\frac{953}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/4)],\n [-5],\n [-(3/2)]])\nb = np.array([\n [-(49/8)],\n [(3/8)],\n [-(49/8)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n \\frac{37}{10} & \\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/10), (8/5)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{2} & \\frac{11}{2} & -\\frac{15}{2} \\\\\n -3 & 6 & 0 \\\\\n 3 & -1 & -\\frac{19}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-7.454,2.727\\, -3.157 i,2.727\\, +3.157 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), (11/2), -(15/2)],\n [-3, 6, 0],\n [3, -1, -(19/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -6 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 4 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{27}{\\sqrt{13937}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-6],\n [-8]]).squeeze()\nb = np.array([\n [5],\n [4],\n [6]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 5 & -6 \\\\\n -1 & -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -9 & 8 \\\\\n -10 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -4 & 2 \\\\\n -11 & -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -6],\n [-1, -5]])\nb = np.array([\n [-9, 8],\n [-10, -7]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 7 & -6 & 3 \\\\\n 2 & 5 & 5 \\\\\n 4 & -3 & -10 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 4 & -3 & -5 \\\\\n -1 & -4 & -10 \\\\\n 3 & 0 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 3 & -3 & 8 \\\\\n 3 & 9 & 15 \\\\\n 1 & -3 & -11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -6, 3],\n [2, 5, 5],\n [4, -3, -10]])\nb = np.array([\n [4, -3, -5],\n [-1, -4, -10],\n [3, 0, 1]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n \\frac{13}{9} \\\\\n -7 \\\\\n \\frac{22}{3} \\\\\n -\\frac{50}{9} \\\\\n \\frac{86}{9} \\\\\n \\frac{61}{9} \\\\\n -\\frac{59}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{25673}}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [(13/9)],\n [-7],\n [(22/3)],\n [-(50/9)],\n [(86/9)],\n [(61/9)],\n [-(59/9)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -3 \\\\\n 0 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 5 \\\\\n 4 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-78$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-3],\n [0],\n [-7]])\nb = np.array([\n [0],\n [5],\n [4],\n [9]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{17}{7} & \\frac{19}{7} & \\frac{8}{7} & \\frac{9}{7} & -\\frac{5}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{4}{7} & \\frac{2}{7} & -\\frac{5}{7} \\\\\n -\\frac{8}{7} & \\frac{18}{7} & -\\frac{10}{7} \\\\\n -\\frac{5}{7} & -\\frac{2}{7} & -\\frac{5}{7} \\\\\n \\frac{20}{7} & -\\frac{19}{7} & -\\frac{2}{7} \\\\\n 0 & \\frac{3}{7} & -\\frac{19}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{80}{49} & \\frac{174}{49} & -\\frac{34}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/7), (19/7), (8/7), (9/7), -(5/7)]])\nb = np.array([\n [-(4/7), (2/7), -(5/7)],\n [-(8/7), (18/7), -(10/7)],\n [-(5/7), -(2/7), -(5/7)],\n [(20/7), -(19/7), -(2/7)],\n [0, (3/7), -(19/7)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{12}{5} & \\frac{37}{5} & 9 \\\\\n -\\frac{48}{5} & \\frac{34}{5} & \\frac{47}{5} \\\\\n \\frac{41}{5} & -\\frac{6}{5} & \\frac{42}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{1.328\\, -7.789 i,1.328\\, +7.789 i,14.945\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(12/5), (37/5), 9],\n [-(48/5), (34/5), (47/5)],\n [(41/5), -(6/5), (42/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{6}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 5 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{4}{3} \\\\\n \\frac{5}{6} \\\\\n -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [5],\n [-4]])\nprint(a * (1/6))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-1, 4}$ to the line $-2 x-4 y+3=0$.", - "Output Answer": [ - "$\\frac{11}{2 \\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -1, 4\nline = Poly(-2*x-4*y+3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 7 & 1 & 2 & -1 & -5 \\\\\n -8 & 7 & -3 & -6 & -9 \\\\\n 4 & 6 & -2 & 1 & -1 \\\\\n -4 & -9 & -9 & 5 & 1 \\\\\n 2 & -7 & 4 & 9 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, 1, 2, -1, -5],\n [-8, 7, -3, -6, -9],\n [4, 6, -2, 1, -1],\n [-4, -9, -9, 5, 1],\n [2, -7, 4, 9, 2]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 0 & 10 & 4 & 5 \\\\\n -6 & -9 & -6 & 10 \\\\\n -6 & 5 & 4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{115.,-270.,510.,132.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, 10, 4, 5],\n [-6, -9, -6, 10],\n [-6, 5, 4, 0]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${2, -\\frac{3}{2}}$ to the line $5 x-\\frac{9 y}{2}-\\frac{3}{2}=0$.", - "Output Answer": [ - "$\\frac{61}{2 \\sqrt{181}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 2, -(3/2)\nline = Poly(5*x-((9*y)/2)-(3/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4.02 \\\\\n 4.49 \\\\\n -6.15 \\\\\n 1.21 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7.91 \\\\\n -3.78 \\\\\n -8.4 \\\\\n 5.13 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$72.6933$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4.02],\n [4.49],\n [-6.15],\n [1.21]])\nb = np.array([\n [7.91],\n [-3.78],\n [-8.4],\n [5.13]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 7 & 6 & 7 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 5 & 2 & -3 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 12 & 8 & 4 & -10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 6, 7, -1]])\nb = np.array([\n [5, 2, -3, -9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n -8 & -4 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -4, -10]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -3 & \\frac{1}{2} & \\frac{7}{5} & -\\frac{6}{5} \\\\\n \\frac{1}{10} & -\\frac{1}{10} & -2 & 0 \\\\\n -2 & \\frac{7}{5} & -\\frac{19}{10} & -\\frac{13}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{10} & \\frac{21}{10} \\\\\n -\\frac{21}{10} & -\\frac{13}{5} \\\\\n \\frac{3}{10} & -\\frac{1}{5} \\\\\n \\frac{21}{10} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{69}{20} & -\\frac{212}{25} \\\\\n -\\frac{19}{50} & \\frac{87}{100} \\\\\n -\\frac{917}{100} & -\\frac{219}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, (1/2), (7/5), -(6/5)],\n [(1/10), -(1/10), -2, 0],\n [-2, (7/5), -(19/10), -(13/5)]])\nb = np.array([\n [(1/10), (21/10)],\n [-(21/10), -(13/5)],\n [(3/10), -(1/5)],\n [(21/10), (1/2)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -10 & -6 \\\\\n 8 & -7 \\\\\n 0 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, -6],\n [8, -7],\n [0, 3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{29}{5} \\\\\n \\frac{31}{5} \\\\\n -\\frac{18}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{11}{5} \\\\\n -\\frac{38}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1376}{25} \\\\\n \\frac{1102}{25} \\\\\n -\\frac{319}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/5)],\n [(31/5)],\n [-(18/5)]])\nb = np.array([\n [0],\n [-(11/5)],\n [-(38/5)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 0 \\\\\n 3 \\\\\n 2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{2}{\\sqrt{21}} \\\\\n 0 \\\\\n \\sqrt{\\frac{3}{7}} \\\\\n \\frac{2}{\\sqrt{21}} \\\\\n -\\frac{2}{\\sqrt{21}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [0],\n [3],\n [2],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{27}{5} & \\frac{49}{5} \\\\\n \\frac{31}{5} & -\\frac{24}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{51 x}{5}-\\frac{871}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(27/5), (49/5)],\n [(31/5), -(24/5)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 4 \\\\\n -1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 4],\n [-1, -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{34}{7}, -\\frac{19}{7}}$ to the line $-\\frac{23 x}{7}-\\frac{12 y}{7}-5=0$.", - "Output Answer": [ - "$\\frac{799}{7 \\sqrt{673}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (34/7), -(19/7)\nline = Poly(-((23*x)/7)-((12*y)/7)-5, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -6 & 9 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -5 & 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -1 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 9]])\nb = np.array([\n [-5, 10]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n 7 & -\\frac{35}{9} & \\frac{14}{9} & \\frac{53}{9} & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -(35/9), (14/9), (53/9), -2]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 1 & 8 & -4 \\\\\n 6 & 2 & 5 \\\\\n 3 & 5 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+6 x^2+50 x-139$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 8, -4],\n [6, 2, 5],\n [3, 5, 3]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -10 & -5 & 3 & -6 & -7 & -8 & 6 \\\\\n 3 & -7 & 0 & 6 & 7 & -3 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & -\\frac{21}{85} & \\frac{72}{85} & \\frac{84}{85} & \\frac{41}{85} & \\frac{8}{85} \\\\\n 0 & 1 & -\\frac{9}{85} & -\\frac{42}{85} & -\\frac{49}{85} & \\frac{54}{85} & -\\frac{118}{85} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, -5, 3, -6, -7, -8, 6],\n [3, -7, 0, 6, 7, -3, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{3} & -\\frac{10}{3} \\\\\n -\\frac{4}{3} & \\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{33}{29} & -\\frac{30}{29} \\\\\n -\\frac{12}{29} & -\\frac{3}{29} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/3), -(10/3)],\n [-(4/3), (11/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{37}{4} \\\\\n -\\frac{3}{4} \\\\\n \\frac{35}{4} \\\\\n \\frac{25}{4} \\\\\n \\frac{3}{4} \\\\\n -\\frac{1}{4} \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$36$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/4)],\n [-(3/4)],\n [(35/4)],\n [(25/4)],\n [(3/4)],\n [-(1/4)],\n [10]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-1,-3,2\\}, \\{2,2,1\\}, \\{-2,2,0\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{14}},-\\frac{3}{\\sqrt{14}},\\sqrt{\\frac{2}{7}}\\right\\}, \\left\\{\\frac{11}{3 \\sqrt{35}},\\frac{\\sqrt{\\frac{5}{7}}}{3},\\frac{13}{3 \\sqrt{35}}\\right\\}, \\left\\{-\\frac{7}{3 \\sqrt{10}},\\frac{\\sqrt{\\frac{5}{2}}}{3},\\frac{2 \\sqrt{\\frac{2}{5}}}{3}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, -3, 2), (2, 2, 1), (-2, 2, 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 7 & 0 & 6 & -7 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-6.,0.,7.,0.,0.\\}, \\{0.,1.,0.,0.,0.\\}, \\{1.,0.,0.,1.,0.\\}, \\{8.,0.,0.,0.,7.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, 0, 6, -7, -8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & \\frac{5}{2} \\\\\n -1 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{9}{4} & -\\frac{5}{2} \\\\\n 1 & -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), (5/2)],\n [-1, -(3/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -10 & 0 \\\\\n -4 & 7 \\\\\n 2 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, 0],\n [-4, 7],\n [2, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & 3 & -2 & 2 \\\\\n -2 & 1 & -2 & 0 \\\\\n -2 & -1 & -1 & 2 \\\\\n -2 & 0 & -2 & -3 \\\\\n -3 & 3 & 0 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.84 \\\\\n -1.01 \\\\\n -0.19 \\\\\n 1.89 \\\\\n 0.44 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.279 \\\\\n 0.48 \\\\\n -0.514 \\\\\n -0.128 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 3, -2, 2],\n [-2, 1, -2, 0],\n [-2, -1, -1, 2],\n [-2, 0, -2, -3],\n [-3, 3, 0, 3]])\nb = np.array([\n [2.84],\n [-1.01],\n [-0.19],\n [1.89],\n [0.44]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & 6 \\\\\n 5 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{5} \\left(3-\\sqrt{39}\\right),1\\right\\}, \\left\\{\\frac{1}{5} \\left(3+\\sqrt{39}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 6],\n [5, -5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & -2 \\\\\n 2 & -3 \\\\\n 1 & -1 \\\\\n 3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.6 \\\\\n -1.21 \\\\\n 0.67 \\\\\n 1.19 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.041 \\\\\n -0.097 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2],\n [2, -3],\n [1, -1],\n [3, -3]])\nb = np.array([\n [0.6],\n [-1.21],\n [0.67],\n [1.19]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -3 & -2 & -4 & 4 \\\\\n 5 & 5 & 10 & -7 \\\\\n 2 & -9 & 2 & 8 \\\\\n -5 & 2 & -6 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, -2, -4, 4],\n [5, 5, 10, -7],\n [2, -9, 2, 8],\n [-5, 2, -6, -4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,0,3\\}, \\left\\{-\\frac{1}{2},1,\\frac{1}{2}\\right\\}, \\left\\{\\frac{7}{2},\\frac{7}{2},\\frac{9}{2}\\right\\}}$.", - "Output Answer": [ - "$41 x-96 y+19 z+107=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, 0, 3],\n [-(1/2), 1, (1/2)],\n [(7/2), (7/2), (9/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{5}{e},\\frac{6}{e},\\frac{7}{e}\\right\\}, \\left\\{\\frac{2}{e},\\frac{4}{e},0\\right\\}, \\left\\{\\frac{1}{e},-\\frac{4}{e},\\frac{6}{e}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\sqrt{\\frac{5}{22}},3 \\sqrt{\\frac{2}{55}},\\frac{7}{\\sqrt{110}}\\right\\}, \\left\\{29 \\sqrt{\\frac{5}{11022}},89 \\sqrt{\\frac{2}{27555}},-\\frac{49}{\\sqrt{55110}}\\right\\}, \\left\\{\\frac{14}{\\sqrt{501}},-\\frac{7}{\\sqrt{501}},\\frac{16}{\\sqrt{501}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-(5/math.e), (6/math.e), (7/math.e)), ((2/math.e), (4/math.e), 0), ((1/math.e), -(4/math.e), (6/math.e))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -3 & 6 \\\\\n -4 & 2 \\\\\n 0 & -2 \\\\\n 3 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 1 & 10 \\\\\n 4 & 9 \\\\\n 6 & 5 \\\\\n 0 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -2 & 16 \\\\\n 0 & 11 \\\\\n 6 & 3 \\\\\n 3 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 6],\n [-4, 2],\n [0, -2],\n [3, -3]])\nb = np.array([\n [1, 10],\n [4, 9],\n [6, 5],\n [0, 8]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{35}{8} \\\\\n \\frac{69}{8} \\\\\n \\frac{21}{4} \\\\\n -\\frac{21}{8} \\\\\n -\\frac{31}{4} \\\\\n \\frac{61}{8} \\\\\n -7 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{69}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(35/8)],\n [(69/8)],\n [(21/4)],\n [-(21/8)],\n [-(31/4)],\n [(61/8)],\n [-7],\n [0]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 1 & -9 & -5 \\\\\n 1 & 4 & -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 9 & -5 & 4 \\\\\n 2 & 8 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 10 & -14 & -1 \\\\\n 3 & 12 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -9, -5],\n [1, 4, -5]])\nb = np.array([\n [9, -5, 4],\n [2, 8, 7]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{11}{5} & \\frac{22}{5} \\\\\n \\frac{17}{5} & -\\frac{11}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{99}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/5), (22/5)],\n [(17/5), -(11/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{1}{\\sqrt{11}} \\\\\n -\\frac{1}{\\sqrt{11}} \\\\\n \\frac{3}{\\sqrt{11}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [-1],\n [3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & -2 & -1 \\\\\n 2 & 0 & -3 \\\\\n 3 & 2 & -1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 4 & 24 & 12 \\\\\n -24 & 16 & 36 \\\\\n -36 & -24 & 28 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2, -1],\n [2, 0, -3],\n [3, 2, -1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{4} & -\\frac{7}{2} \\\\\n -\\frac{13}{4} & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{4}{191} & -\\frac{56}{191} \\\\\n -\\frac{52}{191} & \\frac{36}{191} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/4), -(7/2)],\n [-(13/4), (1/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{51}{7} & -5 \\\\\n \\frac{66}{7} & -\\frac{4}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{55 x}{7}+\\frac{2514}{49}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(51/7), -5],\n [(66/7), -(4/7)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{411}{50} \\\\\n \\frac{141}{100} \\\\\n \\frac{943}{100} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{11}{2} \\\\\n -\\frac{47}{100} \\\\\n \\frac{35}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{10481}{625} \\\\\n \\frac{12379}{100} \\\\\n -\\frac{9729}{2500} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(411/50)],\n [(141/100)],\n [(943/100)]])\nb = np.array([\n [(11/2)],\n [-(47/100)],\n [(35/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n \\frac{7}{3} & -\\frac{7}{2} & \\frac{55}{6} \\\\\n \\frac{23}{3} & -\\frac{16}{3} & \\frac{43}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/3), -(7/2), (55/6)],\n [(23/3), -(16/3), (43/6)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{27}{10} & \\frac{9}{10} & -\\frac{1}{10} & \\frac{2}{5} \\\\\n -\\frac{13}{10} & -2 & \\frac{17}{2} & -4 \\\\\n \\frac{36}{5} & -\\frac{23}{10} & \\frac{11}{2} & 7 \\\\\n \\frac{7}{5} & \\frac{41}{10} & 3 & \\frac{1}{5} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n \\frac{4}{5} & \\frac{49}{5} & 0 & \\frac{49}{5} \\\\\n -\\frac{43}{5} & -\\frac{7}{2} & \\frac{4}{5} & \\frac{57}{10} \\\\\n 9 & -\\frac{11}{10} & -\\frac{13}{2} & -\\frac{11}{2} \\\\\n \\frac{14}{5} & \\frac{97}{10} & \\frac{28}{5} & -\\frac{59}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{7}{2} & -\\frac{89}{10} & -\\frac{1}{10} & -\\frac{47}{5} \\\\\n \\frac{73}{10} & \\frac{3}{2} & \\frac{77}{10} & -\\frac{97}{10} \\\\\n -\\frac{9}{5} & -\\frac{6}{5} & 12 & \\frac{25}{2} \\\\\n -\\frac{7}{5} & -\\frac{28}{5} & -\\frac{13}{5} & \\frac{61}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(27/10), (9/10), -(1/10), (2/5)],\n [-(13/10), -2, (17/2), -4],\n [(36/5), -(23/10), (11/2), 7],\n [(7/5), (41/10), 3, (1/5)]])\nb = np.array([\n [(4/5), (49/5), 0, (49/5)],\n [-(43/5), -(7/2), (4/5), (57/10)],\n [9, -(11/10), -(13/2), -(11/2)],\n [(14/5), (97/10), (28/5), -(59/10)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 4 \\\\\n -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 9 \\\\\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 78 \\\\\n \\frac{95}{3} \\\\\n -23 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [4],\n [-(14/3)]])\nb = np.array([\n [-1],\n [9],\n [9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 0 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 1 & -1 & 1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 2 & -2 & 2 & 4 \\\\\n 0 & 0 & 0 & 0 \\\\\n -2 & 2 & -2 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [0],\n [-2]])\nb = np.array([\n [1, -1, 1, 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -\\frac{121}{16} & \\frac{97}{16} & \\frac{13}{4} & \\frac{113}{16} \\\\\n \\frac{105}{16} & -\\frac{75}{16} & -\\frac{27}{8} & \\frac{71}{8} \\\\\n -\\frac{59}{8} & -\\frac{13}{16} & \\frac{33}{8} & -\\frac{29}{4} \\\\\n \\frac{33}{16} & -\\frac{123}{16} & \\frac{93}{16} & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(121/16), (97/16), (13/4), (113/16)],\n [(105/16), -(75/16), -(27/8), (71/8)],\n [-(59/8), -(13/16), (33/8), -(29/4)],\n [(33/16), -(123/16), (93/16), -(9/2)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{15}{e} \\\\\n -\\frac{6}{e} \\\\\n \\frac{5}{e} \\\\\n \\frac{27}{e} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{11}{e} \\\\\n \\frac{12}{e} \\\\\n -\\frac{13}{e} \\\\\n \\frac{10}{e} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{953}}{e}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(15/math.e)],\n [-(6/math.e)],\n [(5/math.e)],\n [(27/math.e)]])\nb = np.array([\n [(11/math.e)],\n [(12/math.e)],\n [-(13/math.e)],\n [(10/math.e)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -9 & -4 & -3 & 3 \\\\\n 10 & -9 & 3 & -1 \\\\\n -10 & -5 & 10 & -3 \\\\\n -9 & -8 & -10 & -9 \\\\\n -3 & -9 & 1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, -4, -3, 3],\n [10, -9, 3, -1],\n [-10, -5, 10, -3],\n [-9, -8, -10, -9],\n [-3, -9, 1, -4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{2} & \\frac{9}{2} \\\\\n \\frac{11}{2} & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{11} \\left(7-2 \\sqrt{37}\\right),1\\right\\}, \\left\\{\\frac{1}{11} \\left(7+2 \\sqrt{37}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), (9/2)],\n [(11/2), -(9/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{69}{8} \\\\\n -\\frac{23}{8} \\\\\n -\\frac{15}{4} \\\\\n \\frac{19}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{2} \\\\\n \\frac{79}{16} \\\\\n -\\frac{31}{8} \\\\\n \\frac{23}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{49}{8} \\\\\n -\\frac{125}{16} \\\\\n \\frac{1}{8} \\\\\n \\frac{53}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(69/8)],\n [-(23/8)],\n [-(15/4)],\n [(19/2)]])\nb = np.array([\n [-(5/2)],\n [(79/16)],\n [-(31/8)],\n [(23/8)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{9} & \\frac{49}{9} & -\\frac{20}{9} \\\\\n \\frac{25}{3} & -\\frac{77}{9} & -\\frac{1}{3} \\\\\n \\frac{23}{9} & \\frac{13}{9} & -\\frac{25}{3} \\\\\n -\\frac{5}{3} & \\frac{5}{3} & -\\frac{80}{9} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{83}{9} & -\\frac{11}{9} & \\frac{2}{9} \\\\\n \\frac{22}{3} & \\frac{28}{3} & -\\frac{49}{9} \\\\\n \\frac{26}{9} & -\\frac{16}{3} & \\frac{46}{9} \\\\\n \\frac{37}{9} & -\\frac{73}{9} & -\\frac{73}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{32}{3} & \\frac{20}{3} & -\\frac{22}{9} \\\\\n 1 & -\\frac{161}{9} & \\frac{46}{9} \\\\\n -\\frac{1}{3} & \\frac{61}{9} & -\\frac{121}{9} \\\\\n -\\frac{52}{9} & \\frac{88}{9} & -\\frac{7}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/9), (49/9), -(20/9)],\n [(25/3), -(77/9), -(1/3)],\n [(23/9), (13/9), -(25/3)],\n [-(5/3), (5/3), -(80/9)]])\nb = np.array([\n [-(83/9), -(11/9), (2/9)],\n [(22/3), (28/3), -(49/9)],\n [(26/9), -(16/3), (46/9)],\n [(37/9), -(73/9), -(73/9)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -2 \\\\\n -2 \\\\\n -6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 3 \\\\\n 2 \\\\\n 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2 \\\\\n -5 \\\\\n -4 \\\\\n -13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-2],\n [-2],\n [-6]])\nb = np.array([\n [1],\n [3],\n [2],\n [7]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{6}{5} & -\\frac{2}{5} & \\frac{3}{5} \\\\\n -4 & \\frac{14}{5} & \\frac{7}{5} \\\\\n \\frac{1}{5} & \\frac{21}{5} & -\\frac{13}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{554}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(6/5), -(2/5), (3/5)],\n [-4, (14/5), (7/5)],\n [(1/5), (21/5), -(13/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{2}{5}, -3}$ to the line $\\frac{17 x}{5}+\\frac{4 y}{5}+\\frac{3}{5}=0$.", - "Output Answer": [ - "$\\frac{11}{5 \\sqrt{305}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (2/5), -3\nline = Poly(((17*x)/5)+((4*y)/5)+(3/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 8 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -9 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2 \\\\\n -1 \\\\\n 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [8],\n [-3]])\nb = np.array([\n [-3],\n [-9],\n [8]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{3}{5} & -\\frac{4}{5} & -\\frac{7}{5} & -\\frac{24}{5} \\\\\n \\frac{3}{5} & \\frac{11}{5} & -\\frac{49}{5} & 0 \\\\\n -\\frac{7}{5} & \\frac{33}{5} & \\frac{44}{5} & 7 \\\\\n 8 & \\frac{1}{5} & 10 & \\frac{4}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{6}{5} & 3 & -\\frac{4}{5} & -\\frac{32}{5} \\\\\n -\\frac{19}{5} & \\frac{37}{5} & -1 & \\frac{26}{5} \\\\\n -\\frac{14}{5} & \\frac{36}{5} & \\frac{11}{5} & \\frac{48}{5} \\\\\n -\\frac{44}{5} & \\frac{11}{5} & -\\frac{11}{5} & -\\frac{2}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{3}{5} & \\frac{11}{5} & -\\frac{11}{5} & -\\frac{56}{5} \\\\\n -\\frac{16}{5} & \\frac{48}{5} & -\\frac{54}{5} & \\frac{26}{5} \\\\\n -\\frac{21}{5} & \\frac{69}{5} & 11 & \\frac{83}{5} \\\\\n -\\frac{4}{5} & \\frac{12}{5} & \\frac{39}{5} & \\frac{2}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/5), -(4/5), -(7/5), -(24/5)],\n [(3/5), (11/5), -(49/5), 0],\n [-(7/5), (33/5), (44/5), 7],\n [8, (1/5), 10, (4/5)]])\nb = np.array([\n [(6/5), 3, -(4/5), -(32/5)],\n [-(19/5), (37/5), -1, (26/5)],\n [-(14/5), (36/5), (11/5), (48/5)],\n [-(44/5), (11/5), -(11/5), -(2/5)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 5 & 4 & -2 \\\\\n -5 & -2 & 1 \\\\\n -3 & -1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-45$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 4, -2],\n [-5, -2, 1],\n [-3, -1, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & 5 & 3 \\\\\n 0 & 0 & 10 \\\\\n -5 & 2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, 5, 3],\n [0, 0, 10],\n [-5, 2, -3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & -3 \\\\\n -2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\sqrt{10},\\sqrt{10}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3],\n [-2, 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & -2 & 1 & -3 & -3 \\\\\n 1 & 1 & -3 & -2 & -3 \\\\\n -1 & 2 & -2 & -2 & -1 \\\\\n -2 & 0 & 1 & -2 & 2 \\\\\n -1 & -3 & 1 & 2 & -3 \\\\\n 2 & 3 & 2 & 0 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.81 \\\\\n 2.07 \\\\\n 0.63 \\\\\n 0.86 \\\\\n 0.47 \\\\\n -0.52 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.128 \\\\\n -0.101 \\\\\n 0.18 \\\\\n -0.592 \\\\\n -0.331 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, 1, -3, -3],\n [1, 1, -3, -2, -3],\n [-1, 2, -2, -2, -1],\n [-2, 0, 1, -2, 2],\n [-1, -3, 1, 2, -3],\n [2, 3, 2, 0, 3]])\nb = np.array([\n [2.81],\n [2.07],\n [0.63],\n [0.86],\n [0.47],\n [-0.52]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -\\frac{11}{16} & \\frac{149}{16} \\\\\n -\\frac{5}{2} & -\\frac{43}{8} \\\\\n -\\frac{147}{16} & -\\frac{139}{16} \\\\\n \\frac{115}{16} & -\\frac{135}{16} \\\\\n -\\frac{157}{16} & -\\frac{37}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/16), (149/16)],\n [-(5/2), -(43/8)],\n [-(147/16), -(139/16)],\n [(115/16), -(135/16)],\n [-(157/16), -(37/8)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{871}{100} & \\frac{389}{50} & -\\frac{3}{25} \\\\\n -\\frac{1}{5} & \\frac{21}{4} & \\frac{419}{100} \\\\\n \\frac{543}{100} & \\frac{3}{2} & \\frac{172}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{171 x^2}{50}+\\frac{736097 x}{10000}-\\frac{17173111}{250000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(871/100), (389/50), -(3/25)],\n [-(1/5), (21/4), (419/100)],\n [(543/100), (3/2), (172/25)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n \\frac{3}{2} \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{2}{\\sqrt{17}} \\\\\n \\frac{3}{\\sqrt{17}} \\\\\n -\\frac{2}{\\sqrt{17}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [(3/2)],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{2} \\\\\n \\frac{1}{2} \\\\\n -4 \\\\\n \\frac{7}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -\\frac{9}{2} \\\\\n 10 \\\\\n 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n -4 \\\\\n 6 \\\\\n \\frac{9}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/2)],\n [(1/2)],\n [-4],\n [(7/2)]])\nb = np.array([\n [10],\n [-(9/2)],\n [10],\n [1]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{6}{5} \\\\\n \\frac{3}{2} \\\\\n \\frac{13}{5} \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{12}{\\sqrt{1145}} \\\\\n 3 \\sqrt{\\frac{5}{229}} \\\\\n \\frac{26}{\\sqrt{1145}} \\\\\n -2 \\sqrt{\\frac{5}{229}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(6/5)],\n [(3/2)],\n [(13/5)],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{13}{8} & -\\frac{35}{8} \\\\\n \\frac{71}{8} & \\frac{13}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{39 x}{8}+\\frac{1809}{64}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/8), -(35/8)],\n [(71/8), (13/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{20}{7} \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{33}{7} \\\\\n -\\frac{59}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{2312}{49}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/7)],\n [-4]])\nb = np.array([\n [-(33/7)],\n [-(59/7)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1}{\\sqrt{30}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [1],\n [-1],\n [1],\n [1],\n [-1],\n [0]]).squeeze()\nb = np.array([\n [0],\n [1],\n [0],\n [-1],\n [0],\n [-1],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{23}{4} & \\frac{23}{4} \\\\\n -\\frac{7}{2} & -\\frac{23}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{23 x}{2}+\\frac{851}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/4), (23/4)],\n [-(7/2), -(23/4)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{2} & 6 & 8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{2} & -\\frac{5}{2} & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & \\frac{17}{2} & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2), 6, 8]])\nb = np.array([\n [(13/2), -(5/2), 1]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{2}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 6 & -10 & -8 & -6 \\\\\n -2 & -5 & -3 & 0 \\\\\n -3 & 8 & -9 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 3 & -5 & -4 & -3 \\\\\n -1 & -\\frac{5}{2} & -\\frac{3}{2} & 0 \\\\\n -\\frac{3}{2} & 4 & -\\frac{9}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -10, -8, -6],\n [-2, -5, -3, 0],\n [-3, 8, -9, -1]])\nprint(a * (1/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{11}{9}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -4 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -11 \\\\\n \\frac{44}{9} \\\\\n -\\frac{88}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-4],\n [8]])\nprint(a * -(11/9))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -5 & -2 & 1 \\\\\n -4 & -4 & 5 \\\\\n -4 & 0 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$60$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -2, 1],\n [-4, -4, 5],\n [-4, 0, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -4 & 7 & -5 \\\\\n 3 & -10 & -6 \\\\\n -5 & -8 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-19 x^2-16 x+677$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 7, -5],\n [3, -10, -6],\n [-5, -8, -5]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{65}{8} & \\frac{31}{4} & -\\frac{43}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{17}{4} & \\frac{57}{8} & -\\frac{77}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{99}{8} & \\frac{119}{8} & -15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(65/8), (31/4), -(43/8)]])\nb = np.array([\n [-(17/4), (57/8), -(77/8)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-4, -\\frac{13}{3}, -1}$ to the plane $4 x+z+\\frac{14}{3}=0$.", - "Output Answer": [ - "$\\frac{37}{3 \\sqrt{17}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -4, -(13/3), -1\nplane = Poly(4*x+z+(14/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n \\frac{43}{8} \\\\\n -\\frac{121}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{43}{8} \\\\\n \\frac{107}{16} \\\\\n -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1939}{256} \\\\\n \\frac{12371}{128} \\\\\n \\frac{4845}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [(43/8)],\n [-(121/16)]])\nb = np.array([\n [-(43/8)],\n [(107/16)],\n [-8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 9 & -8 & 3 & 6 & -1 \\\\\n 0 & -9 & -3 & 1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-46.,9.,0.,81.,0.\\}, \\{-17.,-9.,27.,0.,0.\\}, \\{11.,9.,0.,0.,27.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, -8, 3, 6, -1],\n [0, -9, -3, 1, 3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -1 & -\\frac{19}{2} \\\\\n -\\frac{11}{2} & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{4} \\left(5-\\sqrt{917}\\right),\\frac{1}{4} \\left(5+\\sqrt{917}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -(19/2)],\n [-(11/2), (7/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -7 & \\frac{33}{5} & \\frac{12}{5} \\\\\n -8 & -\\frac{37}{5} & -\\frac{48}{5} \\\\\n 2 & -\\frac{22}{5} & -\\frac{29}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.944,-0.716,1.\\}, \\{-1.451-0.038 i,-0.198+0.652 i,1.\\}, \\{-1.451+0.038 i,-0.198-0.652 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, (33/5), (12/5)],\n [-8, -(37/5), -(48/5)],\n [2, -(22/5), -(29/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -3 & -\\frac{2}{3} & -8 & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -(2/3), -8, -(1/3)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 1 & 4 & 3 \\\\\n -4 & 4 & -4 \\\\\n 2 & 3 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{2}{45} & -\\frac{29}{180} & \\frac{7}{45} \\\\\n \\frac{7}{45} & \\frac{11}{180} & \\frac{2}{45} \\\\\n \\frac{1}{9} & -\\frac{1}{36} & -\\frac{1}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 4, 3],\n [-4, 4, -4],\n [2, 3, -5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$121$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-7]])\nb = np.array([\n [-9],\n [-7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{16}{7} & \\frac{64}{7} & \\frac{31}{7} \\\\\n \\frac{47}{7} & -\\frac{25}{7} & -4 \\\\\n -\\frac{41}{7} & \\frac{38}{7} & -\\frac{38}{7} \\\\\n \\frac{41}{7} & -10 & -\\frac{41}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{23}{7} & \\frac{39}{7} & \\frac{55}{7} \\\\\n \\frac{47}{7} & \\frac{29}{7} & \\frac{44}{7} \\\\\n -\\frac{68}{7} & -\\frac{50}{7} & -\\frac{20}{7} \\\\\n -\\frac{26}{7} & \\frac{2}{7} & \\frac{2}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{39}{7} & \\frac{103}{7} & \\frac{86}{7} \\\\\n \\frac{94}{7} & \\frac{4}{7} & \\frac{16}{7} \\\\\n -\\frac{109}{7} & -\\frac{12}{7} & -\\frac{58}{7} \\\\\n \\frac{15}{7} & -\\frac{68}{7} & -\\frac{39}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(16/7), (64/7), (31/7)],\n [(47/7), -(25/7), -4],\n [-(41/7), (38/7), -(38/7)],\n [(41/7), -10, -(41/7)]])\nb = np.array([\n [-(23/7), (39/7), (55/7)],\n [(47/7), (29/7), (44/7)],\n [-(68/7), -(50/7), -(20/7)],\n [-(26/7), (2/7), (2/7)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -3 & -3 & -3 & -3 & 1 \\\\\n -3 & 0 & -1 & -3 & 2 \\\\\n 2 & -1 & 0 & 0 & 2 \\\\\n 2 & 1 & 2 & -1 & 3 \\\\\n 0 & -2 & -2 & 1 & 0 \\\\\n 1 & 0 & -1 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.85 \\\\\n 1.58 \\\\\n -2.01 \\\\\n 1.42 \\\\\n 1.55 \\\\\n 0.31 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.424 \\\\\n 0.772 \\\\\n -0.25 \\\\\n 1.834 \\\\\n 1.564 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3, -3, -3, 1],\n [-3, 0, -1, -3, 2],\n [2, -1, 0, 0, 2],\n [2, 1, 2, -1, 3],\n [0, -2, -2, 1, 0],\n [1, 0, -1, -1, 2]])\nb = np.array([\n [-0.85],\n [1.58],\n [-2.01],\n [1.42],\n [1.55],\n [0.31]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 4 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -10 \\\\\n -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -112 \\\\\n 40 \\\\\n -50 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [4],\n [-8]])\nb = np.array([\n [0],\n [-10],\n [-8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{31}{4} \\\\\n \\frac{11}{8} \\\\\n \\frac{37}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{73}{8} \\\\\n -\\frac{13}{8} \\\\\n \\frac{25}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1031}{64} \\\\\n \\frac{5801}{64} \\\\\n \\frac{3}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(31/4)],\n [(11/8)],\n [(37/8)]])\nb = np.array([\n [(73/8)],\n [-(13/8)],\n [(25/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2 \\\\\n 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [5]])\nb = np.array([\n [6],\n [1]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{3,-\\frac{13}{3},-1\\right\\}, \\{0,-1,5\\}, \\left\\{4,\\frac{14}{3},\\frac{2}{3}\\right\\}}$.", - "Output Answer": [ - "$436 x-99 y+273 z-1464=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, -(13/3), -1],\n [0, -1, 5],\n [4, (14/3), (2/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n \\frac{1}{2} \\\\\n 0 \\\\\n -\\frac{5}{2} \\\\\n \\frac{3}{2} \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{4} \\\\\n \\frac{1}{8} \\\\\n 0 \\\\\n -\\frac{5}{8} \\\\\n \\frac{3}{8} \\\\\n -\\frac{5}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [(1/2)],\n [0],\n [-(5/2)],\n [(3/2)],\n [-(5/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 8 & 8 & -9 & 3 & -1 & 4 \\\\\n -7 & 2 & -7 & 8 & -6 & 4 \\\\\n 6 & 6 & 0 & -10 & 3 & 9 \\\\\n 2 & 6 & -1 & -5 & -9 & -2 \\\\\n 3 & 10 & -8 & -8 & 2 & -2 \\\\\n 7 & 10 & -10 & -9 & -10 & -6 \\\\\n -6 & -8 & 0 & -4 & -8 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, 8, -9, 3, -1, 4],\n [-7, 2, -7, 8, -6, 4],\n [6, 6, 0, -10, 3, 9],\n [2, 6, -1, -5, -9, -2],\n [3, 10, -8, -8, 2, -2],\n [7, 10, -10, -9, -10, -6],\n [-6, -8, 0, -4, -8, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n \\frac{369}{50} & -\\frac{3}{5} & -\\frac{489}{100} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{159}{100} & \\frac{299}{100} & -\\frac{631}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{897}{100} & \\frac{239}{100} & -\\frac{56}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(369/50), -(3/5), -(489/100)]])\nb = np.array([\n [(159/100), (299/100), -(631/100)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n \\frac{19}{6} & -\\frac{59}{6} \\\\\n 4 & -4 \\\\\n \\frac{13}{2} & -\\frac{43}{6} \\\\\n -\\frac{23}{6} & \\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/6), -(59/6)],\n [4, -4],\n [(13/2), -(43/6)],\n [-(23/6), (11/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n 8 & 9 & 8 \\\\\n -6 & 6 & -1 \\\\\n -5 & 8 & -4 \\\\\n 7 & -5 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 9, 8],\n [-6, 6, -1],\n [-5, 8, -4],\n [7, -5, 6]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -7 & -7 & -1 & 7 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-6.,0.,0.,0.,7.\\}, \\{-1.,0.,7.,0.,0.\\}, \\{-1.,1.,0.,0.,0.\\}, \\{1.,0.,0.,1.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, -7, -1, 7, -6]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{4}{5} & -\\frac{6}{5} \\\\\n -\\frac{11}{5} & -\\frac{13}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{65}{14} & -\\frac{15}{7} \\\\\n -\\frac{55}{14} & \\frac{10}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/5), -(6/5)],\n [-(11/5), -(13/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{40}{7} & \\frac{59}{7} & \\frac{2}{7} \\\\\n -\\frac{37}{7} & \\frac{33}{7} & \\frac{31}{7} \\\\\n -6 & \\frac{11}{7} & \\frac{48}{7} \\\\\n 2 & 9 & \\frac{9}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 4 & -\\frac{40}{7} & -8 \\\\\n -\\frac{11}{7} & \\frac{61}{7} & \\frac{23}{7} \\\\\n \\frac{57}{7} & -1 & -\\frac{9}{7} \\\\\n \\frac{30}{7} & \\frac{39}{7} & -\\frac{69}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{12}{7} & \\frac{99}{7} & \\frac{58}{7} \\\\\n -\\frac{26}{7} & -4 & \\frac{8}{7} \\\\\n -\\frac{99}{7} & \\frac{18}{7} & \\frac{57}{7} \\\\\n -\\frac{16}{7} & \\frac{24}{7} & \\frac{78}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(40/7), (59/7), (2/7)],\n [-(37/7), (33/7), (31/7)],\n [-6, (11/7), (48/7)],\n [2, 9, (9/7)]])\nb = np.array([\n [4, -(40/7), -8],\n [-(11/7), (61/7), (23/7)],\n [(57/7), -1, -(9/7)],\n [(30/7), (39/7), -(69/7)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-3,1,0\\}, \\{2,-1,2\\}, \\{0,2,0\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{3}{\\sqrt{10}},\\frac{1}{\\sqrt{10}},0\\right\\}, \\left\\{-\\frac{1}{\\sqrt{410}},-\\frac{3}{\\sqrt{410}},2 \\sqrt{\\frac{10}{41}}\\right\\}, \\left\\{\\frac{2}{\\sqrt{41}},\\frac{6}{\\sqrt{41}},\\frac{1}{\\sqrt{41}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-3, 1, 0), (2, -1, 2), (0, 2, 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n -4 \\sqrt{5} \\\\\n \\sqrt{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\sqrt{5} \\\\\n -4 \\sqrt{5} \\\\\n 3 \\sqrt{5} \\\\\n 2 \\sqrt{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{23}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.sqrt(5)],\n [4*math.sqrt(5)],\n [-4*math.sqrt(5)],\n [math.sqrt(5)]])\nb = np.array([\n [2*math.sqrt(5)],\n [-4*math.sqrt(5)],\n [3*math.sqrt(5)],\n [2*math.sqrt(5)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{2}{3},-4,-4\\right\\}, \\left\\{\\frac{10}{3},-\\frac{10}{3},-\\frac{2}{3}\\right\\}, \\left\\{-\\frac{5}{3},\\frac{7}{3},1\\right\\}}$.", - "Output Answer": [ - "$240 x+315 y-351 z+16=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(2/3), -4, -4],\n [(10/3), -(10/3), -(2/3)],\n [-(5/3), (7/3), 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{83}{25} \\\\\n -\\frac{669}{100} \\\\\n \\frac{641}{100} \\\\\n -\\frac{147}{20} \\\\\n \\frac{7}{100} \\\\\n \\frac{903}{100} \\\\\n \\frac{64}{25} \\\\\n \\frac{37}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{\\frac{587497}{5}}}{20}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(83/25)],\n [-(669/100)],\n [(641/100)],\n [-(147/20)],\n [(7/100)],\n [(903/100)],\n [(64/25)],\n [(37/5)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & 3 & -5 \\\\\n -4 & 3 & -4 \\\\\n 1 & 0 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{7} & -\\frac{1}{7} & \\frac{1}{7} \\\\\n 0 & \\frac{1}{3} & \\frac{4}{3} \\\\\n -\\frac{1}{7} & \\frac{1}{7} & \\frac{6}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 3, -5],\n [-4, 3, -4],\n [1, 0, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{33}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{48}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1584}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(33/5)]])\nb = np.array([\n [-(48/5)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 4 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [4],\n [4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n -2 \\\\\n -1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{2}{\\sqrt{17}} \\\\\n -\\frac{2}{\\sqrt{17}} \\\\\n -\\frac{2}{\\sqrt{17}} \\\\\n -\\frac{1}{\\sqrt{17}} \\\\\n \\frac{2}{\\sqrt{17}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-2],\n [-2],\n [-1],\n [2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{\\pi } \\\\\n -\\frac{16}{\\pi } \\\\\n 0 \\\\\n -\\frac{30}{\\pi } \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{25}{\\pi } \\\\\n -\\frac{2}{\\pi } \\\\\n \\frac{23}{\\pi } \\\\\n -\\frac{26}{\\pi } \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{537}{\\pi ^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(11/math.pi)],\n [-(16/math.pi)],\n [0],\n [-(30/math.pi)]])\nb = np.array([\n [(25/math.pi)],\n [-(2/math.pi)],\n [(23/math.pi)],\n [-(26/math.pi)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 0 & 1 & -3 \\\\\n 2 & -2 & -3 \\\\\n -1 & 0 & -3 \\\\\n 1 & -1 & 1 \\\\\n 1 & 2 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -2 & 1 \\\\\n 2 & -1 \\\\\n -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 5 & -7 \\\\\n -5 & -2 \\\\\n 5 & -7 \\\\\n -5 & 4 \\\\\n 4 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, -3],\n [2, -2, -3],\n [-1, 0, -3],\n [1, -1, 1],\n [1, 2, -2]])\nb = np.array([\n [-2, 1],\n [2, -1],\n [-1, 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n -\\sqrt{3} \\\\\n -3 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{402}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-5*math.sqrt(3)],\n [4*math.sqrt(3)],\n [-math.sqrt(3)],\n [-3*math.sqrt(3)]])\nb = np.array([\n [4*math.sqrt(3)],\n [3*math.sqrt(3)],\n [3*math.sqrt(3)],\n [3*math.sqrt(3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 1 & -6 & 6 \\\\\n 8 & -7 & 6 \\\\\n -5 & 2 & 3 \\\\\n -3 & -4 & -6 \\\\\n -3 & 1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, -6, 6],\n [8, -7, 6],\n [-5, 2, 3],\n [-3, -4, -6],\n [-3, 1, 2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{27}{7} & -\\frac{2}{7} \\\\\n \\frac{15}{7} & -\\frac{8}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{28}{93} & -\\frac{7}{93} \\\\\n \\frac{35}{62} & -\\frac{63}{62} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(27/7), -(2/7)],\n [(15/7), -(8/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{32}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 5 & -7 & 9 \\\\\n -5 & 1 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{15}{32} & \\frac{21}{32} & -\\frac{27}{32} \\\\\n \\frac{15}{32} & -\\frac{3}{32} & -\\frac{27}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -7, 9],\n [-5, 1, 9]])\nprint(a * -(3/32))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 2 & -2 & 3 \\\\\n -1 & -1 & 2 \\\\\n -3 & 5 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+5 x^2+x-48$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2, 3],\n [-1, -1, 2],\n [-3, 5, 4]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{32}{7} & -\\frac{25}{7} & -\\frac{2}{7} & -\\frac{22}{7} \\\\\n \\frac{11}{7} & 7 & \\frac{13}{7} & -\\frac{54}{7} \\\\\n \\frac{10}{7} & -10 & -\\frac{58}{7} & -\\frac{15}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n \\frac{48}{7} & -1 & -\\frac{9}{7} & -\\frac{12}{7} \\\\\n \\frac{67}{7} & \\frac{50}{7} & \\frac{20}{7} & \\frac{68}{7} \\\\\n \\frac{27}{7} & \\frac{37}{7} & \\frac{17}{7} & \\frac{13}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{16}{7} & -\\frac{18}{7} & 1 & -\\frac{10}{7} \\\\\n -8 & -\\frac{1}{7} & -1 & -\\frac{122}{7} \\\\\n -\\frac{17}{7} & -\\frac{107}{7} & -\\frac{75}{7} & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(32/7), -(25/7), -(2/7), -(22/7)],\n [(11/7), 7, (13/7), -(54/7)],\n [(10/7), -10, -(58/7), -(15/7)]])\nb = np.array([\n [(48/7), -1, -(9/7), -(12/7)],\n [(67/7), (50/7), (20/7), (68/7)],\n [(27/7), (37/7), (17/7), (13/7)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & 10 & 6 \\\\\n -1 & 1 & 6 \\\\\n -2 & 6 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-3.107,9.054\\, -4.722 i,9.054\\, +4.722 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 10, 6],\n [-1, 1, 6],\n [-2, 6, 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 1 \\\\\n -6 \\\\\n 5 \\\\\n 5 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{177}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [1],\n [-6],\n [5],\n [5],\n [-3]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{23}{4} \\\\\n \\frac{13}{4} \\\\\n \\frac{9}{4} \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{7}{4} \\\\\n -\\frac{13}{4} \\\\\n 4 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{997}}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/4)],\n [(13/4)],\n [(9/4)],\n [1]])\nb = np.array([\n [(7/4)],\n [-(13/4)],\n [4],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -1 \\\\\n 5 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1],\n [5, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{8}{7} \\\\\n -\\frac{15}{7} \\\\\n -1 \\\\\n -\\frac{4}{7} \\\\\n \\frac{4}{7} \\\\\n \\frac{5}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{8}{\\sqrt{395}} \\\\\n -3 \\sqrt{\\frac{5}{79}} \\\\\n -\\frac{7}{\\sqrt{395}} \\\\\n -\\frac{4}{\\sqrt{395}} \\\\\n \\frac{4}{\\sqrt{395}} \\\\\n \\sqrt{\\frac{5}{79}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(8/7)],\n [-(15/7)],\n [-1],\n [-(4/7)],\n [(4/7)],\n [(5/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -2 & -3 & 3 & -2 \\\\\n 3 & 1 & -2 & 0 \\\\\n 0 & 3 & -2 & -2 \\\\\n 2 & 2 & -2 & -1 \\\\\n -1 & -3 & -1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.66 \\\\\n -2.37 \\\\\n -0.72 \\\\\n 1.68 \\\\\n -2.78 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.215 \\\\\n 1.105 \\\\\n 0.689 \\\\\n 0.873 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, 3, -2],\n [3, 1, -2, 0],\n [0, 3, -2, -2],\n [2, 2, -2, -1],\n [-1, -3, -1, 1]])\nb = np.array([\n [-2.66],\n [-2.37],\n [-0.72],\n [1.68],\n [-2.78]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{8}{3} \\\\\n \\frac{1}{3} \\\\\n \\frac{13}{6} \\\\\n -\\frac{8}{3} \\\\\n \\frac{17}{6} \\\\\n -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -8 \\sqrt{\\frac{2}{537}} \\\\\n \\sqrt{\\frac{2}{537}} \\\\\n \\frac{13}{\\sqrt{1074}} \\\\\n -8 \\sqrt{\\frac{2}{537}} \\\\\n \\frac{17}{\\sqrt{1074}} \\\\\n -5 \\sqrt{\\frac{2}{537}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/3)],\n [(1/3)],\n [(13/6)],\n [-(8/3)],\n [(17/6)],\n [-(5/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{50}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 8 & -4 \\\\\n 2 & -1 \\\\\n -7 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{4}{25} & \\frac{2}{25} \\\\\n -\\frac{1}{25} & \\frac{1}{50} \\\\\n \\frac{7}{50} & -\\frac{1}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -4],\n [2, -1],\n [-7, 2]])\nprint(a * -(1/50))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -9 & -4 \\\\\n -9 & 4 \\\\\n 9 & -1 \\\\\n -9 & -9 \\\\\n -7 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -4],\n [-9, 4],\n [9, -1],\n [-9, -9],\n [-7, 4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{65}{16} & -\\frac{73}{16} \\\\\n -1 & \\frac{67}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1072}{5523} & -\\frac{1168}{5523} \\\\\n -\\frac{256}{5523} & \\frac{1040}{5523} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(65/16), -(73/16)],\n [-1, (67/16)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{23}{5}, -\\frac{19}{10}}$ to the line $\\frac{3 x}{2}-\\frac{31 y}{10}-\\frac{16}{5}=0$.", - "Output Answer": [ - "$\\frac{421}{10 \\sqrt{1186}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(23/5), -(19/10)\nline = Poly(((3*x)/2)-((31*y)/10)-(16/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -\\frac{5}{3} \\\\\n \\frac{4}{3} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{8}{3} \\\\\n -\\frac{4}{3} \\\\\n \\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{152}{63},-\\frac{76}{63},\\frac{38}{63}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-(5/3)],\n [(4/3)]]).squeeze()\nb = np.array([\n [-(8/3)],\n [-(4/3)],\n [(2/3)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{26}{5} & \\frac{36}{5} \\\\\n -9 & \\frac{43}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{30} i \\left(\\sqrt{191}-23 i\\right),1\\right\\}, \\left\\{-\\frac{1}{30} i \\left(\\sqrt{191}+23 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(26/5), (36/5)],\n [-9, (43/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -8 \\\\\n 0 \\\\\n -5 \\\\\n -2 \\\\\n 1 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -3 \\\\\n -1 \\\\\n -6 \\\\\n 7 \\\\\n -10 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-8],\n [0],\n [-5],\n [-2],\n [1],\n [-4]])\nb = np.array([\n [4],\n [-3],\n [-1],\n [-6],\n [7],\n [-10],\n [4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & -\\frac{57}{10} \\\\\n \\frac{9}{5} & \\frac{4}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{16 x}{5}+\\frac{353}{50}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -(57/10)],\n [(9/5), (4/5)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & -7 & 2 \\\\\n 0 & 5 & 4 \\\\\n 3 & 3 & -6 \\\\\n 10 & 2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, -7, 2],\n [0, 5, 4],\n [3, 3, -6],\n [10, 2, -2]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n \\frac{46}{9} & \\frac{86}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(46/9), (86/9)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -3 & 6 \\\\\n -5 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-5-i \\sqrt{26},-5+i \\sqrt{26}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 6],\n [-5, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -3 & -1 & 4 \\\\\n 8 & -3 & 6 \\\\\n 6 & 6 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-7 x^2+37 x+319$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1, 4],\n [8, -3, 6],\n [6, 6, -1]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{10}{3} & \\frac{29}{6} & -\\frac{23}{6} \\\\\n \\frac{23}{6} & \\frac{1}{3} & \\frac{11}{6} \\\\\n -\\frac{19}{6} & -\\frac{13}{3} & -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1548}{10997} & \\frac{6024}{10997} & \\frac{2190}{10997} \\\\\n \\frac{678}{10997} & -\\frac{942}{10997} & -\\frac{1854}{10997} \\\\\n -\\frac{480}{1571} & -\\frac{918}{1571} & -\\frac{606}{1571} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(10/3), (29/6), -(23/6)],\n [(23/6), (1/3), (11/6)],\n [-(19/6), -(13/3), -(7/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 1 & 1 \\\\\n 0 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & \\frac{1}{2} \\\\\n 0 & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1],\n [0, -2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -2 \\\\\n 0 \\\\\n 2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n -3 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{11},0,\\frac{3}{11},-\\frac{1}{11},0\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-2],\n [0],\n [2],\n [3]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [-3],\n [1],\n [0]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,-1,3\\}, \\{2,0,-3\\}, \\{1,-5,3\\}}$.", - "Output Answer": [ - "$4 x-2 y-z-11=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, -1, 3],\n [2, 0, -3],\n [1, -5, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{2}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & 4 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{2} & 2 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 4, 8]])\nprint(a * (1/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{\\sqrt{\\pi }} \\\\\n 0 \\\\\n \\frac{14}{\\sqrt{\\pi }} \\\\\n \\frac{13}{\\sqrt{\\pi }} \\\\\n \\frac{7}{\\sqrt{\\pi }} \\\\\n -\\frac{4}{\\sqrt{\\pi }} \\\\\n \\frac{1}{\\sqrt{\\pi }} \\\\\n -\\frac{18}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{7}{\\sqrt{\\pi }} \\\\\n -\\frac{5}{\\sqrt{\\pi }} \\\\\n \\frac{14}{\\sqrt{\\pi }} \\\\\n \\frac{13}{\\sqrt{\\pi }} \\\\\n \\frac{5}{\\sqrt{\\pi }} \\\\\n -\\frac{13}{\\sqrt{\\pi }} \\\\\n \\frac{16}{\\sqrt{\\pi }} \\\\\n \\frac{11}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{179}{\\pi }$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(13/(math.sqrt(math.pi)))],\n [0],\n [(14/(math.sqrt(math.pi)))],\n [(13/(math.sqrt(math.pi)))],\n [(7/(math.sqrt(math.pi)))],\n [-(4/(math.sqrt(math.pi)))],\n [(1/(math.sqrt(math.pi)))],\n [-(18/(math.sqrt(math.pi)))]])\nb = np.array([\n [(7/(math.sqrt(math.pi)))],\n [-(5/(math.sqrt(math.pi)))],\n [(14/(math.sqrt(math.pi)))],\n [(13/(math.sqrt(math.pi)))],\n [(5/(math.sqrt(math.pi)))],\n [-(13/(math.sqrt(math.pi)))],\n [(16/(math.sqrt(math.pi)))],\n [(11/(math.sqrt(math.pi)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 0 & -4 & -2 \\\\\n 5 & -1 & 4 \\\\\n -7 & 1 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.026,-0.43,1.\\}, \\{-1.508-0.251 i,-0.749+1.046 i,1.\\}, \\{-1.508+0.251 i,-0.749-1.046 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -4, -2],\n [5, -1, 4],\n [-7, 1, -10]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & -\\frac{1}{2} & \\frac{5}{2} \\\\\n \\frac{1}{2} & 0 & \\frac{1}{2} \\\\\n 0 & -\\frac{3}{2} & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{41}{8} & \\frac{3}{8} & \\frac{43}{4} \\\\\n \\frac{3}{2} & -\\frac{1}{2} & 2 \\\\\n \\frac{3}{8} & -\\frac{63}{8} & -\\frac{55}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(1/2), (5/2)],\n [(1/2), 0, (1/2)],\n [0, -(3/2), -(5/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -4 & -\\frac{39}{5} & \\frac{26}{5} \\\\\n -\\frac{19}{5} & -\\frac{41}{5} & -\\frac{47}{5} \\\\\n \\frac{14}{5} & 4 & -\\frac{38}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-10.174-5.153 i,-10.174+5.153 i,0.548\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -(39/5), (26/5)],\n [-(19/5), -(41/5), -(47/5)],\n [(14/5), 4, -(38/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 0 & 1 \\\\\n -2 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -2 & -\\frac{1}{2} \\\\\n 1 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1],\n [-2, -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{2,-5,-3\\}, \\{-3,2,-3\\}, \\{-3,-3,-1\\}}$.", - "Output Answer": [ - "$14 x+10 y+25 z+97=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, -5, -3],\n [-3, 2, -3],\n [-3, -3, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 6 \\\\\n 8 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 10 \\\\\n -3 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{9}{5 \\sqrt{43}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [6],\n [8],\n [-9]]).squeeze()\nb = np.array([\n [-9],\n [10],\n [-3],\n [5]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n \\frac{13}{3} & \\frac{17}{3} & \\frac{28}{3} & -4 & -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/3), (17/3), (28/3), -4, -(8/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{45}{8} & -\\frac{125}{16} & -\\frac{39}{4} & -\\frac{57}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{3}{8} & \\frac{31}{4} & -\\frac{9}{16} & -\\frac{15}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -6 & -\\frac{1}{16} & -\\frac{165}{16} & -\\frac{87}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(45/8), -(125/16), -(39/4), -(57/16)]])\nb = np.array([\n [-(3/8), (31/4), -(9/16), -(15/8)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n \\frac{5}{2} \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n \\frac{5}{2} \\\\\n \\frac{15}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{5}{4} \\\\\n -\\frac{83}{2} \\\\\n \\frac{55}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [(5/2)],\n [7]])\nb = np.array([\n [(1/2)],\n [(5/2)],\n [(15/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & -1 \\\\\n 2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -1],\n [2, 2]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 9 & 1 & -1 & -10 & 7 \\\\\n -10 & -1 & 5 & -8 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & -4 & 18 & -7 \\\\\n 0 & 1 & 35 & -172 & 70 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, 1, -1, -10, 7],\n [-10, -1, 5, -8, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{4} \\\\\n \\frac{1}{4} \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{7}{\\sqrt{66}} \\\\\n \\frac{1}{\\sqrt{66}} \\\\\n 2 \\sqrt{\\frac{2}{33}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/4)],\n [(1/4)],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 0 & -3 \\\\\n -2 & -2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -12 & -30 \\\\\n -20 & -32 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3],\n [-2, -2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 8 & 1 & 3 \\\\\n 7 & 8 & -1 \\\\\n 9 & -9 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+25 x^2-165 x+27$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 1, 3],\n [7, 8, -1],\n [9, -9, 9]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 4 \\\\\n 7 \\\\\n -5 \\\\\n 1 \\\\\n -5 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 7 \\\\\n 7 \\\\\n -4 \\\\\n 8 \\\\\n -4 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$133$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [4],\n [7],\n [-5],\n [1],\n [-5],\n [3]])\nb = np.array([\n [-1],\n [7],\n [7],\n [-4],\n [8],\n [-4],\n [3]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 0 & 8 \\\\\n 2 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 1 & -9 \\\\\n 7 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & -1 \\\\\n 9 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 8],\n [2, -3]])\nb = np.array([\n [1, -9],\n [7, 3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 2 \\\\\n 6 \\\\\n 5 \\\\\n -4 \\\\\n -6 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -10 \\\\\n -1 \\\\\n 3 \\\\\n 3 \\\\\n -8 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [2],\n [6],\n [5],\n [-4],\n [-6],\n [-3]])\nb = np.array([\n [-4],\n [-10],\n [-1],\n [3],\n [3],\n [-8],\n [-1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -2 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 2 & 2 & 1 & 1 & 1 \\\\\n 1 & 3 & 1 & -2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -7 & -13 & -5 & 4 & -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3]])\nb = np.array([\n [2, 2, 1, 1, 1],\n [1, 3, 1, -2, 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 8 & 7 & 10 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-7.,0.,0.,8.\\}, \\{-7.,8.,0.,0.\\}, \\{-5.,0.,4.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [8, 7, 10, 7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{4}{3} & \\frac{20}{3} \\\\\n -\\frac{14}{3} & \\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{28} i \\left(\\sqrt{1119}-i\\right),1\\right\\}, \\left\\{-\\frac{1}{28} i \\left(\\sqrt{1119}+i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3), (20/3)],\n [-(14/3), (5/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 2 \\\\\n 3 \\\\\n 1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{3}} \\\\\n \\frac{2}{3 \\sqrt{3}} \\\\\n \\frac{1}{\\sqrt{3}} \\\\\n \\frac{1}{3 \\sqrt{3}} \\\\\n \\frac{2}{3 \\sqrt{3}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [2],\n [3],\n [1],\n [2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1.2 \\\\\n -9.3 \\\\\n -9.8 \\\\\n -2.4 \\\\\n 9.9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2.6 \\\\\n -6.9 \\\\\n 3.8 \\\\\n 2.3 \\\\\n 3.2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$16.4967$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1.2],\n [-9.3],\n [-9.8],\n [-2.4],\n [9.9]])\nb = np.array([\n [-2.6],\n [-6.9],\n [3.8],\n [2.3],\n [3.2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 5 \\\\\n -8 \\\\\n -5 \\\\\n 8 \\\\\n -7 \\\\\n 0 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$41$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [5],\n [-8],\n [-5],\n [8],\n [-7],\n [0],\n [8]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{176}{25} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{176}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(176/25)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{3} \\\\\n -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2}{\\sqrt{29}} \\\\\n -\\frac{5}{\\sqrt{29}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3)],\n [-(5/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -8 & 2 & 7 \\\\\n -7 & -1 & -6 \\\\\n 8 & 4 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-11.135,4.067\\, -3.168 i,4.067\\, +3.168 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 2, 7],\n [-7, -1, -6],\n [8, 4, 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{2}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 1 & 6 \\\\\n -7 & 8 & -3 \\\\\n 4 & -2 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & -\\frac{1}{2} & -3 \\\\\n \\frac{7}{2} & -4 & \\frac{3}{2} \\\\\n -2 & 1 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 6],\n [-7, 8, -3],\n [4, -2, -8]])\nprint(a * -(1/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{21}{8} & -\\frac{29}{8} \\\\\n -\\frac{13}{8} & \\frac{15}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{240}{253} & \\frac{232}{253} \\\\\n \\frac{104}{253} & \\frac{168}{253} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(21/8), -(29/8)],\n [-(13/8), (15/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -10 & 2 & -2 & 8 & 0 & -9 & 7 \\\\\n 2 & 7 & 4 & 4 & -3 & 2 & 4 \\\\\n 6 & 2 & -6 & -1 & 6 & 9 & 9 \\\\\n -5 & -9 & 7 & -6 & 9 & 5 & 3 \\\\\n -2 & -6 & -4 & -5 & -2 & -10 & 9 \\\\\n -5 & -6 & 0 & 6 & -1 & 10 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & -\\frac{3500107}{50924} \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & \\frac{2544551}{50924} \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & -\\frac{1265765}{50924} \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & -\\frac{1707421}{25462} \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & -\\frac{1597679}{50924} \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & \\frac{830361}{25462} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, 2, -2, 8, 0, -9, 7],\n [2, 7, 4, 4, -3, 2, 4],\n [6, 2, -6, -1, 6, 9, 9],\n [-5, -9, 7, -6, 9, 5, 3],\n [-2, -6, -4, -5, -2, -10, 9],\n [-5, -6, 0, 6, -1, 10, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -4 & 6 & 6 & -9 & -7 & -8 & 2 \\\\\n 9 & -8 & -3 & -6 & 4 & -9 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & \\frac{15}{11} & -\\frac{54}{11} & -\\frac{16}{11} & -\\frac{59}{11} & -\\frac{16}{11} \\\\\n 0 & 1 & \\frac{21}{11} & -\\frac{105}{22} & -\\frac{47}{22} & -\\frac{54}{11} & -\\frac{7}{11} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-4, 6, 6, -9, -7, -8, 2],\n [9, -8, -3, -6, 4, -9, -8]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{11}{4}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 5 & -1 & 3 \\\\\n 5 & 2 & 6 \\\\\n -4 & 7 & 5 \\\\\n 8 & 1 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{55}{4} & \\frac{11}{4} & -\\frac{33}{4} \\\\\n -\\frac{55}{4} & -\\frac{11}{2} & -\\frac{33}{2} \\\\\n 11 & -\\frac{77}{4} & -\\frac{55}{4} \\\\\n -22 & -\\frac{11}{4} & -\\frac{99}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -1, 3],\n [5, 2, 6],\n [-4, 7, 5],\n [8, 1, 9]])\nprint(a * -(11/4))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{4}{3} & -\\frac{10}{3} \\\\\n 4 & \\frac{13}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{172}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3), -(10/3)],\n [4, (13/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{3} & -\\frac{14}{3} & 1 \\\\\n -5 & -\\frac{16}{3} & -\\frac{23}{3} \\\\\n -\\frac{16}{3} & -10 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.885,2.502,1.\\}, \\{0.197,-0.524,1.\\}, \\{0.9,1.542,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/3), -(14/3), 1],\n [-5, -(16/3), -(23/3)],\n [-(16/3), -10, 7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, 0}$ to the line $\\frac{16 x}{5}-\\frac{2 y}{5}+\\frac{4}{5}=0$.", - "Output Answer": [ - "$\\frac{14}{\\sqrt{65}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, 0\nline = Poly(((16*x)/5)-((2*y)/5)+(4/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{31}{6} & \\frac{19}{2} & \\frac{9}{2} \\\\\n \\frac{11}{3} & -\\frac{43}{6} & \\frac{15}{2} \\\\\n -\\frac{10}{3} & -\\frac{29}{6} & \\frac{13}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-8 x^2-\\frac{130147}{216}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(31/6), (19/2), (9/2)],\n [(11/3), -(43/6), (15/2)],\n [-(10/3), -(29/6), (13/3)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{7}{5}, \\frac{22}{5}}$ to the line $-\\frac{39 x}{10}+\\frac{16 y}{5}+\\frac{21}{10}=0$.", - "Output Answer": [ - "$\\frac{1082}{5 \\sqrt{2545}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(7/5), (22/5)\nline = Poly(-((39*x)/10)+((16*y)/5)+(21/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{14}{5}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -9 \\\\\n 5 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{42}{5} \\\\\n -\\frac{126}{5} \\\\\n 14 \\\\\n \\frac{14}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-9],\n [5],\n [1]])\nprint(a * (14/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{2}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n -6 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 5 \\\\\n 3 \\\\\n \\frac{1}{2} \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [-6],\n [-1],\n [0]])\nprint(a * -(1/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & 9 \\\\\n -\\frac{1}{2} & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{-11-\\sqrt{103},1\\right\\}, \\left\\{\\sqrt{103}-11,1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 9],\n [-(1/2), -5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & -3 & 2 & 3 \\\\\n -3 & -3 & 3 & 0 \\\\\n -1 & 0 & 1 & -2 \\\\\n -3 & 0 & -3 & -3 \\\\\n 3 & 2 & 0 & 1 \\\\\n -3 & -2 & 0 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.55 \\\\\n -2.29 \\\\\n 2.17 \\\\\n -0.29 \\\\\n 0.74 \\\\\n 0.2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.067 \\\\\n 0.926 \\\\\n 0.462 \\\\\n -0.473 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3, 2, 3],\n [-3, -3, 3, 0],\n [-1, 0, 1, -2],\n [-3, 0, -3, -3],\n [3, 2, 0, 1],\n [-3, -2, 0, -3]])\nb = np.array([\n [-2.55],\n [-2.29],\n [2.17],\n [-0.29],\n [0.74],\n [0.2]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 10 & -2 & -9 & 8 & -6 & 7 & 8 \\\\\n -2 & -9 & -4 & 5 & 6 & -9 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & -\\frac{73}{94} & \\frac{31}{47} & -\\frac{33}{47} & \\frac{81}{94} & \\frac{44}{47} \\\\\n 0 & 1 & \\frac{29}{47} & -\\frac{33}{47} & -\\frac{24}{47} & \\frac{38}{47} & \\frac{32}{47} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, -2, -9, 8, -6, 7, 8],\n [-2, -9, -4, 5, 6, -9, -8]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{307}{50} & \\frac{541}{100} \\\\\n \\frac{209}{50} & \\frac{57}{50} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{587}{100} & -\\frac{373}{100} \\\\\n \\frac{17}{4} & -\\frac{13}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1201}{100} & \\frac{42}{25} \\\\\n \\frac{843}{100} & -\\frac{4}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(307/50), (541/100)],\n [(209/50), (57/50)]])\nb = np.array([\n [(587/100), -(373/100)],\n [(17/4), -(13/10)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${5, 2}$ to the line $4 x-3 y+2=0$.", - "Output Answer": [ - "$\\frac{16}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 5, 2\nline = Poly(4*x-3*y+2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${1, -\\frac{1}{5}, -3}$ to the plane $\\frac{17 x}{5}+\\frac{2 y}{5}+3 z-\\frac{22}{5}=0$.", - "Output Answer": [ - "$\\frac{18 \\sqrt{\\frac{14}{37}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 1, -(1/5), -3\nplane = Poly(((17*x)/5)+((2*y)/5)+3*z-(22/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{14}{9}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -10 \\\\\n 3 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{140}{9} \\\\\n -\\frac{14}{3} \\\\\n -\\frac{112}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-10],\n [3],\n [8]])\nprint(a * -(14/9))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 6 & 10 & -8 & -10 \\\\\n 1 & 7 & -1 & 8 \\\\\n 5 & -4 & -8 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & -\\frac{679}{9} \\\\\n 0 & 1 & 0 & \\frac{44}{9} \\\\\n 0 & 0 & 1 & -\\frac{443}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, 10, -8, -10],\n [1, 7, -1, 8],\n [5, -4, -8, -3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -1 & 0 & -7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -2 & 6 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & -6 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, -7]])\nb = np.array([\n [-2, 6, -2]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{16}{3} \\\\\n -\\frac{19}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{617}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(16/3)],\n [-(19/3)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -9 & -3 & -9 \\\\\n -7 & -2 & 4 \\\\\n 0 & 8 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-11.922-5.134 i,-11.922+5.134 i,4.843\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -3, -9],\n [-7, -2, 4],\n [0, 8, -8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 10 & -3 & -4 \\\\\n 8 & -9 & 9 \\\\\n 9 & 5 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-14.803,4.401\\, -5.379 i,4.401\\, +5.379 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -3, -4],\n [8, -9, 9],\n [9, 5, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 1 & 0 & -1 \\\\\n 0 & 2 & -2 \\\\\n 2 & -1 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{2}{3} & \\frac{1}{12} & \\frac{1}{6} \\\\\n -\\frac{1}{3} & \\frac{7}{12} & \\frac{1}{6} \\\\\n -\\frac{1}{3} & \\frac{1}{12} & \\frac{1}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 0, -1],\n [0, 2, -2],\n [2, -1, 5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 6 \\\\\n 8 \\\\\n -3 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -1 \\\\\n 10 \\\\\n -5 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{22}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [6],\n [8],\n [-3],\n [10]])\nb = np.array([\n [-8],\n [-1],\n [10],\n [-5],\n [-3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2}+3 i & -1-\\frac{i}{2} \\\\\n -3-5 i & -\\frac{9 i}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{25}{4}+\\frac{31 i}{2} & -\\frac{9}{4}+\\frac{3 i}{4} \\\\\n -12-3 i & -\\frac{79}{4}+\\frac{13 i}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2)+3j, -1-(1j/2)],\n [-3-5j, -((9j)/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -6 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 9 \\\\\n -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -54 \\\\\n -6 \\\\\n 45 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-6],\n [10]])\nb = np.array([\n [-6],\n [9],\n [-6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & -2 \\\\\n 4 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2],\n [4, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -2 & 4 & -6 \\\\\n -10 & 3 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-3.,24.,17.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, 4, -6],\n [-10, 3, -6]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -\\frac{19}{16} & \\frac{53}{16} & \\frac{51}{8} & \\frac{15}{8} \\\\\n -\\frac{9}{16} & -\\frac{27}{16} & -\\frac{29}{8} & \\frac{33}{16} \\\\\n -\\frac{103}{16} & -\\frac{23}{4} & \\frac{29}{8} & \\frac{1}{16} \\\\\n \\frac{29}{4} & -\\frac{5}{8} & -\\frac{11}{8} & \\frac{31}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/16), (53/16), (51/8), (15/8)],\n [-(9/16), -(27/16), -(29/8), (33/16)],\n [-(103/16), -(23/4), (29/8), (1/16)],\n [(29/4), -(5/8), -(11/8), (31/4)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,5,-3\\}, \\{-2,3,-4\\}, \\{-2,-4,2\\}}$.", - "Output Answer": [ - "$19 x+12 y+14 z+58=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, 5, -3],\n [-2, 3, -4],\n [-2, -4, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{22}{7}, \\frac{2}{7}}$ to the line $-\\frac{x}{7}-\\frac{25 y}{7}-\\frac{19}{7}=0$.", - "Output Answer": [ - "$\\frac{23}{\\sqrt{626}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(22/7), (2/7)\nline = Poly(-(x/7)-((25*y)/7)-(19/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -1 & 0 & 2 & 1 & -3 \\\\\n 1 & -3 & 1 & 2 & -1 \\\\\n 3 & 1 & 2 & 2 & -1 \\\\\n -1 & 3 & -2 & -2 & 0 \\\\\n -3 & -2 & 2 & -1 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -1 & 0 & 3 & 2 & 3 \\\\\n -1 & 0 & 2 & 2 & 3 \\\\\n 0 & -1 & -1 & 0 & -1 \\\\\n -2 & -2 & -3 & -2 & -2 \\\\\n -2 & 2 & 0 & -3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 5 & -10 & -8 & 5 & -1 \\\\\n 0 & -7 & -10 & -5 & -9 \\\\\n -6 & -8 & 3 & 7 & 8 \\\\\n 2 & 6 & 11 & 8 & 12 \\\\\n 9 & -2 & -12 & -5 & -13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, 2, 1, -3],\n [1, -3, 1, 2, -1],\n [3, 1, 2, 2, -1],\n [-1, 3, -2, -2, 0],\n [-3, -2, 2, -1, -1]])\nb = np.array([\n [-1, 0, 3, 2, 3],\n [-1, 0, 2, 2, 3],\n [0, -1, -1, 0, -1],\n [-2, -2, -3, -2, -2],\n [-2, 2, 0, -3, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{6} & -\\frac{11}{6} \\\\\n -\\frac{25}{6} & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{185}{36}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/6), -(11/6)],\n [-(25/6), -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{11}{10}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 10 \\\\\n -2 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{11}{2} \\\\\n -11 \\\\\n \\frac{11}{5} \\\\\n \\frac{44}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [10],\n [-2],\n [-8]])\nprint(a * -(11/10))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 6 & -5 & 9 & 8 \\\\\n 6 & 1 & -10 & 0 \\\\\n -3 & -3 & -8 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{65.,1650.,204.,753.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [6, -5, 9, 8],\n [6, 1, -10, 0],\n [-3, -3, -8, 9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 2 \\\\\n -2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [2],\n [-2],\n [3]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -4 \\\\\n -2 \\\\\n -8 \\\\\n 6 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-4],\n [-2],\n [-8],\n [6],\n [4]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & 0 \\\\\n -7 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-10,7\\}, \\{0,1\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 0],\n [-7, -7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{11}{9} & -\\frac{40}{9} & \\frac{22}{3} & \\frac{79}{9} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 4 & -\\frac{67}{9} & -\\frac{23}{3} & -\\frac{16}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{25}{9} & 3 & 15 & \\frac{127}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/9), -(40/9), (22/3), (79/9)]])\nb = np.array([\n [4, -(67/9), -(23/3), -(16/3)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -2 \\\\\n -1 \\\\\n -5 \\\\\n 6 \\\\\n -1 \\\\\n 3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -5 \\\\\n 2 \\\\\n 1 \\\\\n -1 \\\\\n 3 \\\\\n -9 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{159}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-2],\n [-1],\n [-5],\n [6],\n [-1],\n [3],\n [-8]])\nb = np.array([\n [-2],\n [-5],\n [2],\n [1],\n [-1],\n [3],\n [-9],\n [10]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -9 & 10 & 9 & 4 \\\\\n 1 & -7 & -5 & 7 \\\\\n 1 & 9 & 2 & 4 \\\\\n 2 & -9 & -2 & 6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 3 & -1 & -9 & -3 \\\\\n -4 & 6 & 2 & 0 \\\\\n -2 & -3 & 6 & 7 \\\\\n -2 & -4 & -4 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -12 & 11 & 18 & 7 \\\\\n 5 & -13 & -7 & 7 \\\\\n 3 & 12 & -4 & -3 \\\\\n 4 & -5 & 2 & 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 10, 9, 4],\n [1, -7, -5, 7],\n [1, 9, 2, 4],\n [2, -9, -2, 6]])\nb = np.array([\n [3, -1, -9, -3],\n [-4, 6, 2, 0],\n [-2, -3, 6, 7],\n [-2, -4, -4, -4]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{28}{3} & \\frac{23}{3} & -\\frac{13}{3} \\\\\n 6 & 6 & -5 \\\\\n -\\frac{23}{3} & \\frac{22}{3} & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{17 x^2}{3}+\\frac{1157 x}{9}-\\frac{4069}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(28/3), (23/3), -(13/3)],\n [6, 6, -5],\n [-(23/3), (22/3), 9]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{15}{32}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 6 & 5 & 1 \\\\\n -8 & 9 & -10 \\\\\n 10 & -8 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{45}{16} & -\\frac{75}{32} & -\\frac{15}{32} \\\\\n \\frac{15}{4} & -\\frac{135}{32} & \\frac{75}{16} \\\\\n -\\frac{75}{16} & \\frac{15}{4} & \\frac{75}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 5, 1],\n [-8, 9, -10],\n [10, -8, -5]])\nprint(a * -(15/32))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{76}{27} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/3)]])\nb = np.array([\n [-(19/9)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${0, 3, 2}$ to the plane $-x+5 y-4 z+1=0$.", - "Output Answer": [ - "$4 \\sqrt{\\frac{2}{21}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 0, 3, 2\nplane = Poly(-x+5*y-4*z+1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & 2 & -\\frac{5}{2} \\\\\n -3 & 1 & \\frac{3}{2} \\\\\n 1 & -2 & 1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{93}{2} & 11 & \\frac{93}{4} \\\\\n \\frac{39}{2} & -44 & \\frac{69}{4} \\\\\n \\frac{39}{2} & 25 & -30 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, -(5/2)],\n [-3, 1, (3/2)],\n [1, -2, 1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 3 \\\\\n 7 \\\\\n -6 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 8 \\\\\n -5 \\\\\n -7 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{178}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [3],\n [7],\n [-6],\n [0]])\nb = np.array([\n [8],\n [8],\n [-5],\n [-7],\n [-2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -5 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 4 \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -54 \\\\\n 42 \\\\\n -37 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-5],\n [6]])\nb = np.array([\n [-1],\n [4],\n [6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{2}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -8 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -12 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 0]])\nprint(a * (3/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{33}{4} & -\\frac{3}{2} & -\\frac{15}{2} \\\\\n \\frac{19}{4} & \\frac{7}{2} & -7 \\\\\n -8 & -\\frac{1}{2} & -\\frac{19}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.902,0.134,1.\\}, \\{-1.694-0.293 i,5.574\\, +2.881 i,1.\\}, \\{-1.694+0.293 i,5.574\\, -2.881 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(33/4), -(3/2), -(15/2)],\n [(19/4), (7/2), -7],\n [-8, -(1/2), -(19/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\sqrt{3},\\frac{4}{\\sqrt{3}},-\\frac{2}{\\sqrt{3}}\\right\\}, \\left\\{-\\frac{5}{\\sqrt{3}},0,-\\sqrt{3}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}},\\frac{1}{\\sqrt{3}}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{3}{\\sqrt{29}},\\frac{4}{\\sqrt{29}},-\\frac{2}{\\sqrt{29}}\\right\\}, \\left\\{\\frac{\\frac{9 \\sqrt{3}}{29}-\\frac{5}{\\sqrt{3}}}{\\sqrt{\\frac{4107}{841}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}\\right)^2}},\\frac{12}{29} \\sqrt{\\frac{3}{\\frac{4107}{841}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}\\right)^2}},-\\frac{35}{29} \\sqrt{\\frac{3}{\\frac{4107}{841}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}\\right)^2}}\\right\\}, \\left\\{\\frac{-\\frac{1}{\\sqrt{3}}+\\frac{9 \\sqrt{3}}{29}-\\frac{\\left(-\\frac{5}{\\sqrt{3}}+\\frac{9 \\sqrt{3}}{29}\\right) \\left(-\\frac{47}{29}-\\frac{-\\frac{5}{\\sqrt{3}}+\\frac{9 \\sqrt{3}}{29}}{\\sqrt{3}}\\right)}{\\frac{4107}{841}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}\\right)^2}}{\\sqrt{\\left(-\\frac{1}{\\sqrt{3}}+\\frac{12 \\sqrt{3}}{29}-\\frac{12 \\sqrt{3} \\left(-\\frac{47}{29}-\\frac{-\\frac{5}{\\sqrt{3}}+\\frac{9 \\sqrt{3}}{29}}{\\sqrt{3}}\\right)}{29 \\left(\\frac{4107}{841}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}\\right)^2\\right)}\\right)^2+\\left(\\frac{1}{\\sqrt{3}}-\\frac{6 \\sqrt{3}}{29}+\\frac{35 \\sqrt{3} \\left(-\\frac{47}{29}-\\frac{-\\frac{5}{\\sqrt{3}}+\\frac{9 \\sqrt{3}}{29}}{\\sqrt{3}}\\right)}{29 \\left(\\frac{4107}{841}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}\\right)^2\\right)}\\right)^2+\\left(\\frac{1}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}-\\frac{\\left(\\frac{5}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}\\right) \\left(-\\frac{47}{29}-\\frac{-\\frac{5}{\\sqrt{3}}+\\frac{9 \\sqrt{3}}{29}}{\\sqrt{3}}\\right)}{\\frac{4107}{841}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}\\right)^2}\\right)^2}},\\frac{-\\frac{1}{\\sqrt{3}}+\\frac{12 \\sqrt{3}}{29}-\\frac{12 \\sqrt{3} \\left(-\\frac{47}{29}-\\frac{-\\frac{5}{\\sqrt{3}}+\\frac{9 \\sqrt{3}}{29}}{\\sqrt{3}}\\right)}{29 \\left(\\frac{4107}{841}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}\\right)^2\\right)}}{\\sqrt{\\left(-\\frac{1}{\\sqrt{3}}+\\frac{12 \\sqrt{3}}{29}-\\frac{12 \\sqrt{3} \\left(-\\frac{47}{29}-\\frac{-\\frac{5}{\\sqrt{3}}+\\frac{9 \\sqrt{3}}{29}}{\\sqrt{3}}\\right)}{29 \\left(\\frac{4107}{841}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}\\right)^2\\right)}\\right)^2+\\left(\\frac{1}{\\sqrt{3}}-\\frac{6 \\sqrt{3}}{29}+\\frac{35 \\sqrt{3} \\left(-\\frac{47}{29}-\\frac{-\\frac{5}{\\sqrt{3}}+\\frac{9 \\sqrt{3}}{29}}{\\sqrt{3}}\\right)}{29 \\left(\\frac{4107}{841}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}\\right)^2\\right)}\\right)^2+\\left(\\frac{1}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}-\\frac{\\left(\\frac{5}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}\\right) \\left(-\\frac{47}{29}-\\frac{-\\frac{5}{\\sqrt{3}}+\\frac{9 \\sqrt{3}}{29}}{\\sqrt{3}}\\right)}{\\frac{4107}{841}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}\\right)^2}\\right)^2}},\\frac{\\frac{1}{\\sqrt{3}}-\\frac{6 \\sqrt{3}}{29}+\\frac{35 \\sqrt{3} \\left(-\\frac{47}{29}-\\frac{-\\frac{5}{\\sqrt{3}}+\\frac{9 \\sqrt{3}}{29}}{\\sqrt{3}}\\right)}{29 \\left(\\frac{4107}{841}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}\\right)^2\\right)}}{\\sqrt{\\left(-\\frac{1}{\\sqrt{3}}+\\frac{12 \\sqrt{3}}{29}-\\frac{12 \\sqrt{3} \\left(-\\frac{47}{29}-\\frac{-\\frac{5}{\\sqrt{3}}+\\frac{9 \\sqrt{3}}{29}}{\\sqrt{3}}\\right)}{29 \\left(\\frac{4107}{841}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}\\right)^2\\right)}\\right)^2+\\left(\\frac{1}{\\sqrt{3}}-\\frac{6 \\sqrt{3}}{29}+\\frac{35 \\sqrt{3} \\left(-\\frac{47}{29}-\\frac{-\\frac{5}{\\sqrt{3}}+\\frac{9 \\sqrt{3}}{29}}{\\sqrt{3}}\\right)}{29 \\left(\\frac{4107}{841}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}\\right)^2\\right)}\\right)^2+\\left(\\frac{1}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}-\\frac{\\left(\\frac{5}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}\\right) \\left(-\\frac{47}{29}-\\frac{-\\frac{5}{\\sqrt{3}}+\\frac{9 \\sqrt{3}}{29}}{\\sqrt{3}}\\right)}{\\frac{4107}{841}+\\left(\\frac{5}{\\sqrt{3}}-\\frac{9 \\sqrt{3}}{29}\\right)^2}\\right)^2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((math.sqrt(3), (4/(math.sqrt(3))), -(2/(math.sqrt(3)))), (-(5/(math.sqrt(3))), 0, -math.sqrt(3)), (-(1/(math.sqrt(3))), -(1/(math.sqrt(3))), (1/(math.sqrt(3))))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 3 & -2 & 2 & -2 \\\\\n 0 & 3 & 3 & 3 \\\\\n 1 & 2 & 2 & 3 \\\\\n 1 & 1 & -2 & 0 \\\\\n 2 & -3 & -2 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.09 \\\\\n 2.53 \\\\\n -1.98 \\\\\n 1.01 \\\\\n -2.37 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.426 \\\\\n 0.628 \\\\\n 0.25 \\\\\n -0.677 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2, 2, -2],\n [0, 3, 3, 3],\n [1, 2, 2, 3],\n [1, 1, -2, 0],\n [2, -3, -2, 2]])\nb = np.array([\n [2.09],\n [2.53],\n [-1.98],\n [1.01],\n [-2.37]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -6 \\\\\n 6 \\\\\n -4 \\\\\n 7 \\\\\n -5 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 7 \\\\\n 2 \\\\\n -8 \\\\\n 7 \\\\\n -1 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{411}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-6],\n [6],\n [-4],\n [7],\n [-5],\n [-3]])\nb = np.array([\n [4],\n [7],\n [2],\n [-8],\n [7],\n [-1],\n [10]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -10 & 2 & 7 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-4.,0.,0.,5.\\}, \\{1.,5.,0.,0.\\}, \\{7.,0.,10.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, 2, 7, -8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{6}{7} & -1 & -\\frac{15}{7} \\\\\n -\\frac{25}{7} & -\\frac{3}{7} & -\\frac{23}{7} \\\\\n -\\frac{18}{7} & 0 & -\\frac{18}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{21}{41} & -\\frac{49}{41} & \\frac{406}{369} \\\\\n -\\frac{14}{41} & -\\frac{63}{41} & \\frac{553}{246} \\\\\n -\\frac{21}{41} & \\frac{49}{41} & -\\frac{1099}{738} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(6/7), -1, -(15/7)],\n [-(25/7), -(3/7), -(23/7)],\n [-(18/7), 0, -(18/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{13}{5}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & 3 & -7 \\\\\n 0 & -1 & -3 \\\\\n 4 & 5 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{5} & \\frac{39}{5} & -\\frac{91}{5} \\\\\n 0 & -\\frac{13}{5} & -\\frac{39}{5} \\\\\n \\frac{52}{5} & 13 & -\\frac{104}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, -7],\n [0, -1, -3],\n [4, 5, -8]])\nprint(a * (13/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -7 & \\frac{73}{8} & \\frac{117}{16} & -\\frac{39}{16} \\\\\n \\frac{129}{16} & \\frac{91}{16} & -\\frac{9}{4} & -\\frac{23}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{75}{16} & \\frac{43}{8} & \\frac{31}{16} & 8 \\\\\n -\\frac{55}{16} & \\frac{49}{8} & \\frac{25}{8} & \\frac{13}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{37}{16} & \\frac{15}{4} & \\frac{43}{8} & -\\frac{167}{16} \\\\\n \\frac{23}{2} & -\\frac{7}{16} & -\\frac{43}{8} & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, (73/8), (117/16), -(39/16)],\n [(129/16), (91/16), -(9/4), -(23/4)]])\nb = np.array([\n [-(75/16), (43/8), (31/16), 8],\n [-(55/16), (49/8), (25/8), (13/4)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 9 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [9],\n [-8]])\nb = np.array([\n [-3],\n [2],\n [3]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 0 & -2 \\\\\n 1 & 1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -2 & -2 \\\\\n 1 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2],\n [1, 1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{61}{20} \\\\\n -\\frac{114}{25} \\\\\n -\\frac{489}{100} \\\\\n \\frac{879}{100} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{193}{25} \\\\\n \\frac{209}{50} \\\\\n \\frac{137}{20} \\\\\n \\frac{23}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1077}{100} \\\\\n -\\frac{437}{50} \\\\\n -\\frac{587}{50} \\\\\n \\frac{649}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(61/20)],\n [-(114/25)],\n [-(489/100)],\n [(879/100)]])\nb = np.array([\n [(193/25)],\n [(209/50)],\n [(137/20)],\n [(23/10)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 10 & 3 & -2 & 8 & 6 & 1 \\\\\n -5 & 3 & -7 & 1 & 10 & 3 \\\\\n -7 & -4 & -8 & -1 & -2 & 5 \\\\\n 7 & -10 & 9 & 10 & -10 & 7 \\\\\n 4 & -9 & -7 & 9 & 5 & -5 \\\\\n -7 & -9 & 1 & -7 & -6 & -7 \\\\\n 2 & -10 & 3 & 2 & 10 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, 3, -2, 8, 6, 1],\n [-5, 3, -7, 1, 10, 3],\n [-7, -4, -8, -1, -2, 5],\n [7, -10, 9, 10, -10, 7],\n [4, -9, -7, 9, 5, -5],\n [-7, -9, 1, -7, -6, -7],\n [2, -10, 3, 2, 10, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n \\frac{14}{5} & -\\frac{11}{5} & -2 \\\\\n -\\frac{12}{5} & -\\frac{1}{5} & \\frac{4}{5} \\\\\n \\frac{1}{5} & \\frac{2}{5} & -\\frac{9}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{5} & -\\frac{1}{5} & \\frac{3}{5} \\\\\n -\\frac{8}{5} & -\\frac{11}{5} & \\frac{11}{5} \\\\\n -\\frac{13}{5} & \\frac{8}{5} & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{52}{5} & \\frac{27}{25} & -\\frac{179}{25} \\\\\n -\\frac{16}{5} & \\frac{11}{5} & -\\frac{7}{25} \\\\\n \\frac{104}{25} & -\\frac{19}{5} & -\\frac{13}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/5), -(11/5), -2],\n [-(12/5), -(1/5), (4/5)],\n [(1/5), (2/5), -(9/5)]])\nb = np.array([\n [(3/5), -(1/5), (3/5)],\n [-(8/5), -(11/5), (11/5)],\n [-(13/5), (8/5), 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{3} & 1 \\\\\n \\frac{13}{3} & \\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{16}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3), 1],\n [(13/3), (11/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 6 & 8 & -9 & -1 & -6 & -7 \\\\\n 0 & 3 & -10 & 6 & 8 & -1 \\\\\n -6 & 9 & -10 & 3 & 8 & 0 \\\\\n -4 & -1 & 4 & 5 & 8 & 1 \\\\\n 0 & 5 & 2 & -5 & -1 & -2 \\\\\n -9 & -5 & 6 & -7 & -7 & -1 \\\\\n -1 & -4 & 8 & 10 & 10 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, 8, -9, -1, -6, -7],\n [0, 3, -10, 6, 8, -1],\n [-6, 9, -10, 3, 8, 0],\n [-4, -1, 4, 5, 8, 1],\n [0, 5, 2, -5, -1, -2],\n [-9, -5, 6, -7, -7, -1],\n [-1, -4, 8, 10, 10, -3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 2 & -4 & 5 \\\\\n 7 & -6 & 9 \\\\\n 3 & -4 & 5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 0 & 3 & 9 \\\\\n 3 & -8 & -7 \\\\\n -3 & 0 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 2 & -7 & -4 \\\\\n 4 & 2 & 16 \\\\\n 6 & -4 & 13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -4, 5],\n [7, -6, 9],\n [3, -4, 5]])\nb = np.array([\n [0, 3, 9],\n [3, -8, -7],\n [-3, 0, -8]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -7 \\\\\n 2 \\\\\n 6 \\\\\n -3 \\\\\n -7 \\\\\n -3 \\\\\n -1 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -9 \\\\\n 9 \\\\\n -4 \\\\\n -5 \\\\\n 8 \\\\\n -8 \\\\\n -9 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{641}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-7],\n [2],\n [6],\n [-3],\n [-7],\n [-3],\n [-1],\n [-8]])\nb = np.array([\n [3],\n [-9],\n [9],\n [-4],\n [-5],\n [8],\n [-8],\n [-9],\n [-1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & \\frac{3}{2} & \\frac{1}{2} \\\\\n -\\frac{3}{2} & \\frac{3}{2} & \\frac{1}{2} \\\\\n 1 & 3 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{29}{4} & \\frac{21}{4} & \\frac{9}{8} \\\\\n -\\frac{17}{4} & -\\frac{15}{4} & \\frac{5}{8} \\\\\n -\\frac{3}{4} & \\frac{27}{4} & -\\frac{67}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), (3/2), (1/2)],\n [-(3/2), (3/2), (1/2)],\n [1, 3, -(3/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -1 \\\\\n -9 \\\\\n 1 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$26$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-1],\n [-9],\n [1],\n [9]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 4 \\\\\n -7 \\\\\n -6 \\\\\n -8 \\\\\n -3 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 2 \\\\\n 4 \\\\\n -8 \\\\\n 10 \\\\\n 4 \\\\\n 8 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-85$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [4],\n [-7],\n [-6],\n [-8],\n [-3],\n [-1],\n [-1]])\nb = np.array([\n [-7],\n [2],\n [4],\n [-8],\n [10],\n [4],\n [8],\n [-8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{8}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 2 \\\\\n 4 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{9}{8} \\\\\n -\\frac{1}{4} \\\\\n -\\frac{1}{2} \\\\\n -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [2],\n [4],\n [8]])\nprint(a * -(1/8))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2},-\\frac{1}{2}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1]]).squeeze()\nb = np.array([\n [1],\n [-1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{15}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{7}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{105}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/2)]])\nb = np.array([\n [(7/4)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -5 & -9 \\\\\n 1 & -9 \\\\\n -9 & -6 \\\\\n 6 & 2 \\\\\n 5 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, -9],\n [1, -9],\n [-9, -6],\n [6, 2],\n [5, 9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{16}{3} & -\\frac{26}{3} & \\frac{1}{3} \\\\\n 4 & \\frac{26}{3} & -8 \\\\\n \\frac{25}{3} & -\\frac{28}{3} & -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-5.073,2.311,13.095\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(16/3), -(26/3), (1/3)],\n [4, (26/3), -8],\n [(25/3), -(28/3), -(11/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{18}{7} \\\\\n -\\frac{25}{7} \\\\\n \\frac{8}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{1013}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(18/7)],\n [-(25/7)],\n [(8/7)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & 4 & 4 \\\\\n -4 & -1 & 0 \\\\\n 3 & -1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{21} & -\\frac{5}{21} & \\frac{1}{21} \\\\\n \\frac{4}{21} & -\\frac{1}{21} & -\\frac{4}{21} \\\\\n \\frac{1}{12} & \\frac{1}{6} & \\frac{1}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 4, 4],\n [-4, -1, 0],\n [3, -1, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{3}{2} & -\\frac{5}{2} & 3 & \\frac{5}{2} & 3 \\\\\n -2 & 0 & \\frac{1}{2} & -3 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 0 & -\\frac{1}{2} & 1 & \\frac{1}{2} \\\\\n -\\frac{1}{2} & -1 & -1 & -1 \\\\\n 2 & -\\frac{5}{2} & \\frac{1}{2} & \\frac{1}{2} \\\\\n -1 & 2 & -\\frac{5}{2} & -2 \\\\\n 0 & -\\frac{1}{2} & 0 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{19}{4} & -\\frac{3}{4} & -\\frac{15}{4} & -\\frac{25}{4} \\\\\n 4 & -\\frac{21}{4} & \\frac{23}{4} & \\frac{33}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), -(5/2), 3, (5/2), 3],\n [-2, 0, (1/2), -3, -2]])\nb = np.array([\n [0, -(1/2), 1, (1/2)],\n [-(1/2), -1, -1, -1],\n [2, -(5/2), (1/2), (1/2)],\n [-1, 2, -(5/2), -2],\n [0, -(1/2), 0, -(3/2)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{19}{5} & -8 \\\\\n 10 & \\frac{3}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{5} \\left(-8-i \\sqrt{1879}\\right),\\frac{1}{5} \\left(-8+i \\sqrt{1879}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/5), -8],\n [10, (3/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -1 \\\\\n 9 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -4 \\\\\n 4 \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 9 \\\\\n -5 \\\\\n 13 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-1],\n [9],\n [-2]])\nb = np.array([\n [1],\n [-4],\n [4],\n [2]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{187}{100} \\\\\n \\frac{587}{100} \\\\\n \\frac{897}{100} \\\\\n -\\frac{3}{25} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{897}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(187/100)],\n [(587/100)],\n [(897/100)],\n [-(3/25)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 9 & 10 & -5 & -5 & -3 & -2 & 5 \\\\\n -5 & -6 & 8 & 7 & 2 & 3 & 3 \\\\\n 6 & 5 & 2 & -8 & -3 & -8 & 7 \\\\\n 6 & -7 & 9 & -5 & -4 & 7 & 2 \\\\\n -5 & -5 & 3 & 2 & 7 & 1 & -9 \\\\\n -5 & 9 & 7 & 2 & 5 & -2 & -4 \\\\\n -10 & -1 & -5 & 5 & -1 & 1 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, 10, -5, -5, -3, -2, 5],\n [-5, -6, 8, 7, 2, 3, 3],\n [6, 5, 2, -8, -3, -8, 7],\n [6, -7, 9, -5, -4, 7, 2],\n [-5, -5, 3, 2, 7, 1, -9],\n [-5, 9, 7, 2, 5, -2, -4],\n [-10, -1, -5, 5, -1, 1, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 4 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -3 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -11 \\\\\n 10 \\\\\n 13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [4],\n [-9]])\nb = np.array([\n [2],\n [-3],\n [4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 1 \\\\\n -2 \\\\\n -1 \\\\\n 0 \\\\\n 2 \\\\\n 3 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -7 \\\\\n -2 \\\\\n 3 \\\\\n 0 \\\\\n 7 \\\\\n 1 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{113}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [1],\n [-2],\n [-1],\n [0],\n [2],\n [3],\n [-9]])\nb = np.array([\n [-5],\n [-7],\n [-2],\n [3],\n [0],\n [7],\n [1],\n [-9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 6 & 8 & 3 \\\\\n -3 & -8 & 1 \\\\\n 8 & -5 & 1 \\\\\n 7 & 5 & 10 \\\\\n 7 & -7 & 0 \\\\\n 0 & 10 & 8 \\\\\n 4 & -2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, 8, 3],\n [-3, -8, 1],\n [8, -5, 1],\n [7, 5, 10],\n [7, -7, 0],\n [0, 10, 8],\n [4, -2, -3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -4 & -2 \\\\\n 2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{4}{25} & \\frac{2}{25} \\\\\n -\\frac{2}{25} & \\frac{1}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -2],\n [2, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 1 & 2 & 0 \\\\\n 0 & 1 & 0 \\\\\n 1 & 0 & -3 \\\\\n 0 & 2 & 3 \\\\\n 2 & 1 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -3 & 1 & 0 & 2 \\\\\n -1 & -2 & 2 & 1 \\\\\n 1 & 0 & 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -5 & -3 & 4 & 4 \\\\\n -1 & -2 & 2 & 1 \\\\\n -6 & 1 & 0 & -4 \\\\\n 1 & -4 & 4 & 8 \\\\\n -9 & 0 & 2 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, 0],\n [0, 1, 0],\n [1, 0, -3],\n [0, 2, 3],\n [2, 1, -2]])\nb = np.array([\n [-3, 1, 0, 2],\n [-1, -2, 2, 1],\n [1, 0, 0, 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -5 & 7 & -10 & 10 \\\\\n -3 & -4 & 1 & -3 \\\\\n -8 & -2 & 1 & 3 \\\\\n -6 & 1 & 2 & -2 \\\\\n -6 & -3 & -4 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, 7, -10, 10],\n [-3, -4, 1, -3],\n [-8, -2, 1, 3],\n [-6, 1, 2, -2],\n [-6, -3, -4, -7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{143}{25} & \\frac{893}{100} \\\\\n \\frac{421}{50} & -\\frac{49}{25} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{72}{25} & -\\frac{7}{2} \\\\\n -\\frac{49}{50} & \\frac{143}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{43}{5} & \\frac{543}{100} \\\\\n \\frac{186}{25} & -\\frac{53}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(143/25), (893/100)],\n [(421/50), -(49/25)]])\nb = np.array([\n [-(72/25), -(7/2)],\n [-(49/50), (143/100)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{2} \\\\\n -9 \\\\\n 5 \\\\\n 6 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{63}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2)],\n [-9],\n [5],\n [6],\n [-3],\n [2]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{7}{5}, 3}$ to the line $\\frac{3 x}{5}-\\frac{12 y}{5}+\\frac{19}{5}=0$.", - "Output Answer": [ - "$\\frac{64}{15 \\sqrt{17}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (7/5), 3\nline = Poly(((3*x)/5)-((12*y)/5)+(19/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{2} & \\frac{7}{10} & -\\frac{47}{10} \\\\\n \\frac{11}{10} & -\\frac{3}{2} & \\frac{11}{10} \\\\\n \\frac{9}{5} & \\frac{1}{10} & \\frac{23}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{4733}{250}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), (7/10), -(47/10)],\n [(11/10), -(3/2), (11/10)],\n [(9/5), (1/10), (23/10)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -10 & -4 \\\\\n 8 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{2 \\left(-5-2 i \\sqrt{2}\\right),2 \\left(-5+2 i \\sqrt{2}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -4],\n [8, -10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -\\frac{13}{6} \\\\\n \\frac{2}{3} \\\\\n -\\frac{1}{6} \\\\\n \\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3 \\sqrt{\\frac{2}{113}} \\\\\n -\\frac{13}{\\sqrt{226}} \\\\\n 2 \\sqrt{\\frac{2}{113}} \\\\\n -\\frac{1}{\\sqrt{226}} \\\\\n \\sqrt{\\frac{2}{113}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-(13/6)],\n [(2/3)],\n [-(1/6)],\n [(1/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 2 \\\\\n -3 \\\\\n -1 \\\\\n 3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n \\frac{1}{3} \\\\\n -\\frac{1}{2} \\\\\n -\\frac{1}{6} \\\\\n \\frac{1}{2} \\\\\n \\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [2],\n [-3],\n [-1],\n [3],\n [2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{7}{2},-1,-2\\right\\}, \\left\\{-\\frac{9}{2},\\frac{7}{2},-4\\right\\}, \\left\\{\\frac{9}{2},-\\frac{1}{2},5\\right\\}}$.", - "Output Answer": [ - "$130 x+216 y-34 z-307=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(7/2), -1, -2],\n [-(9/2), (7/2), -4],\n [(9/2), -(1/2), 5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 3 \\\\\n -2 \\\\\n -2 \\\\\n -3 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n \\frac{1}{2} \\\\\n -\\frac{1}{3} \\\\\n -\\frac{1}{3} \\\\\n -\\frac{1}{2} \\\\\n -\\frac{1}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [3],\n [-2],\n [-2],\n [-3],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -3 & -3 & 2 & -2 \\\\\n -1 & -3 & 3 & -1 \\\\\n 2 & -3 & 0 & 1 \\\\\n 1 & 0 & 1 & 1 \\\\\n -2 & 3 & 1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 0 & 0 \\\\\n 2 & -1 \\\\\n -3 & 1 \\\\\n 1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -14 & 3 \\\\\n -16 & 5 \\\\\n -5 & 4 \\\\\n -2 & 2 \\\\\n 5 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3, 2, -2],\n [-1, -3, 3, -1],\n [2, -3, 0, 1],\n [1, 0, 1, 1],\n [-2, 3, 1, 2]])\nb = np.array([\n [0, 0],\n [2, -1],\n [-3, 1],\n [1, 1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2 & 0 & 0 \\\\\n 1 & 0 & -2 \\\\\n 2 & 2 & -1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -8 & 0 & 0 \\\\\n 12 & 4 & 6 \\\\\n 0 & -6 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, 0],\n [1, 0, -2],\n [2, 2, -1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{2} & 3 & \\frac{5}{2} \\\\\n 3 & -2 & -\\frac{1}{2} \\\\\n -\\frac{3}{2} & 1 & -1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{371}{8} & \\frac{185}{4} & \\frac{89}{2} \\\\\n \\frac{447}{8} & -\\frac{217}{4} & -\\frac{377}{8} \\\\\n -\\frac{153}{4} & \\frac{73}{2} & \\frac{221}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), 3, (5/2)],\n [3, -2, -(1/2)],\n [-(3/2), 1, -1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -1 & 6 \\\\\n -5 & 9 \\\\\n -4 & -1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 2 & 6 \\\\\n -4 & 4 \\\\\n -9 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -3 & 0 \\\\\n -1 & 5 \\\\\n 5 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 6],\n [-5, 9],\n [-4, -1]])\nb = np.array([\n [2, 6],\n [-4, 4],\n [-9, -6]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{59}{10} & -\\frac{7}{10} & -\\frac{11}{2} & -\\frac{24}{5} & \\frac{63}{10} \\\\\n \\frac{27}{5} & -\\frac{1}{2} & \\frac{47}{10} & \\frac{49}{10} & -\\frac{21}{5} \\\\\n -\\frac{19}{2} & \\frac{36}{5} & \\frac{49}{5} & \\frac{21}{10} & -\\frac{7}{2} \\\\\n \\frac{36}{5} & \\frac{28}{5} & -\\frac{49}{5} & -\\frac{23}{10} & \\frac{44}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(59/10), -(7/10), -(11/2), -(24/5), (63/10)],\n [(27/5), -(1/2), (47/10), (49/10), -(21/5)],\n [-(19/2), (36/5), (49/5), (21/10), -(7/2)],\n [(36/5), (28/5), -(49/5), -(23/10), (44/5)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 2 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{10}{13},\\frac{10}{13},-\\frac{10}{13},\\frac{5}{13}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [0],\n [-1],\n [-1]]).squeeze()\nb = np.array([\n [2],\n [2],\n [-2],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -4 & 5 & 4 & 2 & 6 \\\\\n -1 & 1 & 6 & 1 & -8 \\\\\n -4 & 8 & -3 & -5 & -10 \\\\\n 0 & 7 & 0 & 10 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{5389.,2930.,1693.,-2051.,706.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, 5, 4, 2, 6],\n [-1, 1, 6, 1, -8],\n [-4, 8, -3, -5, -10],\n [0, 7, 0, 10, 0]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{15}{2} & \\frac{29}{8} & -\\frac{3}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{29}{4} & \\frac{5}{8} & \\frac{79}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{59}{4} & 3 & -\\frac{41}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/2), (29/8), -(3/8)]])\nb = np.array([\n [-(29/4), (5/8), (79/8)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 3 & 5 & -6 & 8 & -2 \\\\\n 8 & -10 & -10 & 8 & -7 \\\\\n -3 & 9 & 8 & -4 & 6 \\\\\n -1 & 3 & -7 & -2 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1032.,-932.,350.,1603.,1484.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, 5, -6, 8, -2],\n [8, -10, -10, 8, -7],\n [-3, 9, 8, -4, 6],\n [-1, 3, -7, -2, 5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{2} & \\frac{59}{16} \\\\\n \\frac{59}{8} & -\\frac{63}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{83 x}{8}-\\frac{961}{128}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), (59/16)],\n [(59/8), -(63/8)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & -2 & 1 & 0 & 0 \\\\\n 2 & -3 & 2 & 1 & -1 \\\\\n -3 & 2 & 3 & 3 & 0 \\\\\n 3 & -2 & -2 & -3 & 2 \\\\\n -1 & 3 & -2 & 2 & -2 \\\\\n -1 & 2 & 2 & 3 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.71 \\\\\n -1.24 \\\\\n 0.14 \\\\\n -1.48 \\\\\n 1.01 \\\\\n -2.14 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.267 \\\\\n -0.693 \\\\\n -0.623 \\\\\n -0.245 \\\\\n -0.49 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, 1, 0, 0],\n [2, -3, 2, 1, -1],\n [-3, 2, 3, 3, 0],\n [3, -2, -2, -3, 2],\n [-1, 3, -2, 2, -2],\n [-1, 2, 2, 3, -1]])\nb = np.array([\n [1.71],\n [-1.24],\n [0.14],\n [-1.48],\n [1.01],\n [-2.14]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 2 & -\\frac{2}{3} & -\\frac{1}{3} & 2 \\\\\n -\\frac{2}{3} & \\frac{5}{3} & \\frac{5}{3} & \\frac{5}{3} \\\\\n -\\frac{8}{3} & -\\frac{5}{3} & \\frac{7}{3} & -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n \\frac{8}{3} & -1 & -\\frac{2}{3} & \\frac{5}{3} & 1 \\\\\n \\frac{7}{3} & \\frac{5}{3} & -\\frac{7}{3} & -\\frac{7}{3} & \\frac{1}{3} \\\\\n -\\frac{1}{3} & \\frac{2}{3} & -\\frac{4}{3} & -2 & 3 \\\\\n 0 & \\frac{2}{3} & -\\frac{4}{3} & \\frac{7}{3} & -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n \\frac{35}{9} & -2 & -2 & \\frac{92}{9} & -\\frac{41}{9} \\\\\n \\frac{14}{9} & \\frac{17}{3} & -\\frac{71}{9} & -\\frac{40}{9} & \\frac{4}{9} \\\\\n -\\frac{106}{9} & -\\frac{1}{3} & \\frac{55}{9} & -\\frac{103}{9} & \\frac{98}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(2/3), -(1/3), 2],\n [-(2/3), (5/3), (5/3), (5/3)],\n [-(8/3), -(5/3), (7/3), -(8/3)]])\nb = np.array([\n [(8/3), -1, -(2/3), (5/3), 1],\n [(7/3), (5/3), -(7/3), -(7/3), (1/3)],\n [-(1/3), (2/3), -(4/3), -2, 3],\n [0, (2/3), -(4/3), (7/3), -(8/3)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{2} \\\\\n -\\frac{31}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{39}{4} \\\\\n -\\frac{79}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{49}{4} \\\\\n -\\frac{55}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2)],\n [-(31/8)]])\nb = np.array([\n [-(39/4)],\n [-(79/8)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 5 & 5 & -6 & -1 & -1 \\\\\n 4 & 10 & 6 & 5 & -8 \\\\\n 2 & 3 & 5 & -8 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-127.,93.,-33.,0.,28.\\}, \\{967.,-625.,257.,168.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, 5, -6, -1, -1],\n [4, 10, 6, 5, -8],\n [2, 3, 5, -8, 5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{8}{7}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -6 \\\\\n -4 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{8}{7} \\\\\n \\frac{48}{7} \\\\\n \\frac{32}{7} \\\\\n -\\frac{40}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-6],\n [-4],\n [5]])\nprint(a * -(8/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{9} & \\frac{10}{9} \\\\\n -\\frac{14}{9} & -\\frac{5}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{3} & -\\frac{2}{3} \\\\\n \\frac{14}{15} & \\frac{1}{15} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/9), (10/9)],\n [-(14/9), -(5/9)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -5 & 2 \\\\\n 5 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-3-\\sqrt{89}\\right),\\frac{1}{2} \\left(\\sqrt{89}-3\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 2],\n [5, 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-1$ and the matrix\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 8 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 8 \\\\\n -8 \\\\\n -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [8],\n [1]])\nprint(a * -1)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -2 \\\\\n 0 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{2}{3} \\\\\n 0 \\\\\n \\frac{2}{3} \\\\\n \\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-2],\n [0],\n [2],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{8}{3},\\frac{7}{3},-\\frac{2}{3}\\right\\}, \\left\\{\\frac{11}{3},\\frac{5}{3},\\frac{4}{3}\\right\\}, \\left\\{-\\frac{11}{3},\\frac{8}{3},2\\right\\}}$.", - "Output Answer": [ - "$66 x+414 y+105 z-1072=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(8/3), (7/3), -(2/3)],\n [(11/3), (5/3), (4/3)],\n [-(11/3), (8/3), 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,-4,-5\\}, \\{4,-3,4\\}, \\{1,1,2\\}}$.", - "Output Answer": [ - "$38 x+25 y-7 (z+7)=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, -4, -5],\n [4, -3, 4],\n [1, 1, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{1,2,-3\\}, \\{1,-1,-3\\}, \\{2,1,2\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{14}},\\sqrt{\\frac{2}{7}},-\\frac{3}{\\sqrt{14}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{35}},-\\sqrt{\\frac{5}{7}},-\\frac{3}{\\sqrt{35}}\\right\\}, \\left\\{\\frac{3}{\\sqrt{10}},0,\\frac{1}{\\sqrt{10}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((1, 2, -3), (1, -1, -3), (2, 1, 2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{10}{3} & 5 \\\\\n 0 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{10}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(10/3), 5],\n [0, -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-3,\\frac{4}{3},-\\frac{7}{3}\\right\\}, \\left\\{\\frac{7}{3},3,\\frac{11}{3}\\right\\}, \\left\\{-\\frac{5}{3},-4,-\\frac{11}{3}\\right\\}}$.", - "Output Answer": [ - "$201 x+102 y-207 z-16=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, (4/3), -(7/3)],\n [(7/3), 3, (11/3)],\n [-(5/3), -4, -(11/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n -\\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n -4 \\sqrt{3} \\\\\n 5 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\sqrt{3} \\\\\n -3 \\sqrt{3} \\\\\n -3 \\sqrt{3} \\\\\n 5 \\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n 5 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{114}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-4*math.sqrt(3)],\n [4*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [4*math.sqrt(3)],\n [-math.sqrt(3)],\n [3*math.sqrt(3)],\n [-4*math.sqrt(3)],\n [5*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [math.sqrt(3)]])\nb = np.array([\n [-5*math.sqrt(3)],\n [-3*math.sqrt(3)],\n [-3*math.sqrt(3)],\n [5*math.sqrt(3)],\n [-2*math.sqrt(3)],\n [4*math.sqrt(3)],\n [3*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [5*math.sqrt(3)],\n [-5*math.sqrt(3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n 5 & -5 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -5, 9]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{12}{5}, \\frac{8}{5}}$ to the line $-\\frac{4 x}{5}-\\frac{3 y}{5}-\\frac{13}{5}=0$.", - "Output Answer": [ - "$\\frac{137}{25}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (12/5), (8/5)\nline = Poly(-((4*x)/5)-((3*y)/5)-(13/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{21}{10}, -\\frac{41}{10}}$ to the line $-\\frac{13 x}{5}-\\frac{13 y}{10}+\\frac{41}{10}=0$.", - "Output Answer": [ - "$\\frac{397}{130 \\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (21/10), -(41/10)\nline = Poly(-((13*x)/5)-((13*y)/10)+(41/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2 & 0 & 0 \\\\\n -1 & 0 & 3 \\\\\n -1 & -2 & -3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -8 & 0 & 0 \\\\\n 17 & 18 & 9 \\\\\n -23 & -6 & 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, 0],\n [-1, 0, 3],\n [-1, -2, -3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 0 & -1 & 8 & 7 \\\\\n 4 & 7 & 7 & 3 \\\\\n -10 & 7 & 1 & 6 \\\\\n -1 & 7 & -5 & -3 \\\\\n -8 & -1 & 7 & -1 \\\\\n -9 & 1 & 3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, -1, 8, 7],\n [4, 7, 7, 3],\n [-10, 7, 1, 6],\n [-1, 7, -5, -3],\n [-8, -1, 7, -1],\n [-9, 1, 3, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [2]])\nb = np.array([\n [4],\n [3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & 3 & 2 \\\\\n 0 & -2 & -2 \\\\\n 4 & -4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3, 2],\n [0, -2, -2],\n [4, -4, -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{75}{32}, \\frac{7}{8}}$ to the line $\\frac{73 x}{32}-\\frac{67 y}{16}+\\frac{9}{4}=0$.", - "Output Answer": [ - "$\\frac{4027}{32 \\sqrt{23285}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (75/32), (7/8)\nline = Poly(((73*x)/32)-((67*y)/16)+(9/4), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 14 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [14*math.log(2)]])\nb = np.array([\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{91}{16} & \\frac{55}{8} \\\\\n 6 & -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{87 x}{16}-\\frac{2731}{64}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(91/16), (55/8)],\n [6, -(1/4)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{21}{16}, \\frac{51}{32}}$ to the line $\\frac{133 x}{32}+\\frac{127 y}{32}+\\frac{147}{32}=0$.", - "Output Answer": [ - "$\\frac{16767}{32 \\sqrt{33818}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (21/16), (51/32)\nline = Poly(((133*x)/32)+((127*y)/32)+(147/32), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 3 & -4 & -2 \\\\\n -1 & 4 & 5 \\\\\n 3 & -5 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{11}{15} & \\frac{2}{5} & -\\frac{4}{15} \\\\\n \\frac{17}{45} & \\frac{4}{15} & -\\frac{13}{45} \\\\\n -\\frac{7}{45} & \\frac{1}{15} & \\frac{8}{45} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -4, -2],\n [-1, 4, 5],\n [3, -5, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -3 \\\\\n -2 & 2 \\\\\n -2 & 3 \\\\\n 2 & 3 \\\\\n 0 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.52 \\\\\n -0.11 \\\\\n 0.45 \\\\\n 0.81 \\\\\n 2.73 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.315 \\\\\n 0.467 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3],\n [-2, 2],\n [-2, 3],\n [2, 3],\n [0, 3]])\nb = np.array([\n [-2.52],\n [-0.11],\n [0.45],\n [0.81],\n [2.73]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 3 & -2 \\\\\n 3 & 6 \\\\\n -3 & -9 \\\\\n -3 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, -2],\n [3, 6],\n [-3, -9],\n [-3, 10]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{5}{3},-\\frac{2}{3},\\frac{7}{3}\\right\\}, \\left\\{\\frac{4}{3},-\\frac{8}{3},\\frac{8}{3}\\right\\}, \\left\\{-\\frac{2}{3},-2,1\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{5}{\\sqrt{78}},-\\sqrt{\\frac{2}{39}},\\frac{7}{\\sqrt{78}}\\right\\}, \\left\\{\\frac{11}{\\sqrt{246}},-5 \\sqrt{\\frac{2}{123}},\\frac{5}{\\sqrt{246}}\\right\\}, \\left\\{-\\frac{10}{\\sqrt{533}},-\\frac{17}{\\sqrt{533}},-\\frac{12}{\\sqrt{533}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-(5/3), -(2/3), (7/3)), ((4/3), -(8/3), (8/3)), (-(2/3), -2, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{41}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [2]])\nb = np.array([\n [2],\n [6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -5 & -2 \\\\\n 1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & 1 \\\\\n -\\frac{1}{2} & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -2],\n [1, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{23}{\\pi } \\\\\n -\\frac{16}{\\pi } \\\\\n \\frac{1}{\\pi } \\\\\n \\frac{23}{\\pi } \\\\\n -\\frac{22}{\\pi } \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\pi } \\\\\n \\frac{31}{\\pi } \\\\\n 0 \\\\\n -\\frac{11}{\\pi } \\\\\n -\\frac{7}{\\pi } \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{618}{\\pi ^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(23/math.pi)],\n [-(16/math.pi)],\n [(1/math.pi)],\n [(23/math.pi)],\n [-(22/math.pi)]])\nb = np.array([\n [-(1/math.pi)],\n [(31/math.pi)],\n [0],\n [-(11/math.pi)],\n [-(7/math.pi)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & -\\frac{7}{2} \\\\\n \\frac{19}{2} & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(8-i \\sqrt{33}\\right),\\frac{1}{2} \\left(8+i \\sqrt{33}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -(7/2)],\n [(19/2), -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -7 & 0 \\\\\n 2 & -9 \\\\\n 5 & 2 \\\\\n 3 & -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -4 & -6 \\\\\n -8 & 6 \\\\\n 9 & -9 \\\\\n -8 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -11 & -6 \\\\\n -6 & -3 \\\\\n 14 & -7 \\\\\n -5 & -10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 0],\n [2, -9],\n [5, 2],\n [3, -7]])\nb = np.array([\n [-4, -6],\n [-8, 6],\n [9, -9],\n [-8, -3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-5, 1, \\frac{7}{3}}$ to the plane $-\\frac{2 x}{3}+y+z-\\frac{5}{3}=0$.", - "Output Answer": [ - "$\\frac{15}{\\sqrt{22}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -5, 1, (7/3)\nplane = Poly(-((2*x)/3)+y+z-(5/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 1 \\\\\n -2 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{13}{9},-\\frac{13}{18},\\frac{13}{9},\\frac{13}{6}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-2],\n [2],\n [1]]).squeeze()\nb = np.array([\n [-2],\n [1],\n [-2],\n [-3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n \\frac{3}{4} \\\\\n \\frac{3}{2} \\\\\n \\frac{35}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [(3/4)],\n [(3/2)],\n [(35/4)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{2}{5}, \\frac{19}{5}}$ to the line $-\\frac{12 x}{5}+\\frac{11 y}{5}-\\frac{7}{5}=0$.", - "Output Answer": [ - "$6 \\sqrt{\\frac{5}{53}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (2/5), (19/5)\nline = Poly(-((12*x)/5)+((11*y)/5)-(7/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -4 & 0 & -1 \\\\\n -2 & 3 & -4 \\\\\n -4 & 2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 0, -1],\n [-2, 3, -4],\n [-4, 2, -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 4 \\\\\n 9 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-7 x-44$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 4],\n [9, -1]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{3}{2} & 1 & 2 & -3 \\\\\n -3 & -2 & 1 & 1 \\\\\n \\frac{3}{2} & -3 & -3 & \\frac{3}{2} \\\\\n -\\frac{1}{2} & -2 & -\\frac{1}{2} & \\frac{3}{2} \\\\\n \\frac{5}{2} & -\\frac{1}{2} & -\\frac{1}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -1 & 1 & \\frac{3}{2} & 2 \\\\\n 3 & 2 & -\\frac{3}{2} & \\frac{3}{2} \\\\\n -3 & 3 & -2 & -1 \\\\\n \\frac{3}{2} & 3 & 0 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -6 & -\\frac{5}{2} & -\\frac{31}{4} & -\\frac{7}{2} \\\\\n -\\frac{9}{2} & -1 & -\\frac{7}{2} & -10 \\\\\n \\frac{3}{4} & -9 & \\frac{51}{4} & \\frac{3}{2} \\\\\n -\\frac{7}{4} & -\\frac{3}{2} & \\frac{13}{4} & -\\frac{7}{2} \\\\\n \\frac{5}{4} & \\frac{15}{2} & \\frac{11}{2} & \\frac{19}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), 1, 2, -3],\n [-3, -2, 1, 1],\n [(3/2), -3, -3, (3/2)],\n [-(1/2), -2, -(1/2), (3/2)],\n [(5/2), -(1/2), -(1/2), (5/2)]])\nb = np.array([\n [-1, 1, (3/2), 2],\n [3, 2, -(3/2), (3/2)],\n [-3, 3, -2, -1],\n [(3/2), 3, 0, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 3 & -1 & -3 \\\\\n 0 & 2 & 3 \\\\\n 1 & -3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{3}{10} & \\frac{3}{10} & \\frac{1}{10} \\\\\n \\frac{1}{10} & \\frac{1}{10} & -\\frac{3}{10} \\\\\n -\\frac{1}{15} & \\frac{4}{15} & \\frac{1}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, -3],\n [0, 2, 3],\n [1, -3, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{677}{100} & \\frac{61}{10} & -\\frac{97}{20} \\\\\n -\\frac{497}{100} & \\frac{9}{2} & \\frac{471}{100} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{9}{2} & -\\frac{3}{50} & -\\frac{449}{100} \\\\\n -\\frac{453}{50} & -\\frac{713}{100} & \\frac{203}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1127}{100} & \\frac{154}{25} & -\\frac{9}{25} \\\\\n \\frac{409}{100} & \\frac{1163}{100} & \\frac{13}{20} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(677/100), (61/10), -(97/20)],\n [-(497/100), (9/2), (471/100)]])\nb = np.array([\n [(9/2), -(3/50), -(449/100)],\n [-(453/50), -(713/100), (203/50)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{9}{e} \\\\\n \\frac{20}{e} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{16}{e} \\\\\n \\frac{10}{e} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{149}}{e}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(9/math.e)],\n [(20/math.e)]])\nb = np.array([\n [(16/math.e)],\n [(10/math.e)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -9 \\\\\n 2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -3 \\\\\n 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 5 \\\\\n -6 \\\\\n -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-9],\n [2]])\nb = np.array([\n [-5],\n [-3],\n [3]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${4, -2}$ to the line $5 x-\\frac{y}{2}+\\frac{1}{2}=0$.", - "Output Answer": [ - "$\\frac{43}{\\sqrt{101}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 4, -2\nline = Poly(5*x-(y/2)+(1/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & -2 & -1 \\\\\n 0 & 1 & 1 \\\\\n -2 & -2 & -2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 16 & -12 & -6 \\\\\n -2 & 5 & 3 \\\\\n -8 & -2 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2, -1],\n [0, 1, 1],\n [-2, -2, -2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{1}{\\pi },\\frac{4}{\\pi },-\\frac{2}{\\pi }\\right\\}, \\left\\{-\\frac{1}{\\pi },\\frac{3}{\\pi },-\\frac{9}{\\pi }\\right\\}, \\left\\{\\frac{4}{\\pi },-\\frac{1}{\\pi },\\frac{4}{\\pi }\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{21}},\\frac{4}{\\sqrt{21}},-\\frac{2}{\\sqrt{21}}\\right\\}, \\left\\{\\sqrt{\\frac{2}{399}},-\\frac{61}{5 \\sqrt{798}},-\\frac{127}{5 \\sqrt{798}}\\right\\}, \\left\\{3 \\sqrt{\\frac{2}{19}},\\frac{7}{5 \\sqrt{38}},-\\frac{1}{5 \\sqrt{38}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-(1/math.pi), (4/math.pi), -(2/math.pi)), (-(1/math.pi), (3/math.pi), -(9/math.pi)), ((4/math.pi), -(1/math.pi), (4/math.pi))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-5,\\frac{7}{2},-2\\right\\}, \\left\\{1,-\\frac{9}{2},-\\frac{3}{2}\\right\\}, \\left\\{\\frac{5}{2},-\\frac{3}{2},\\frac{9}{2}\\right\\}}$.", - "Output Answer": [ - "$132 x+94 y-80 z+171=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-5, (7/2), -2],\n [1, -(9/2), -(3/2)],\n [(5/2), -(3/2), (9/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n \\frac{51}{10} & 5 & \\frac{51}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{91}{10} & \\frac{29}{5} & -\\frac{67}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -4 & \\frac{54}{5} & -\\frac{8}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(51/10), 5, (51/10)]])\nb = np.array([\n [-(91/10), (29/5), -(67/10)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 3 & 4 & 0 & 6 & 3 \\\\\n 1 & 2 & -6 & -2 & 3 \\\\\n -5 & -10 & 6 & 10 & -6 \\\\\n -7 & 4 & -5 & -8 & 7 \\\\\n -6 & -9 & 2 & -4 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, 4, 0, 6, 3],\n [1, 2, -6, -2, 3],\n [-5, -10, 6, 10, -6],\n [-7, 4, -5, -8, 7],\n [-6, -9, 2, -4, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & -6 \\\\\n -4 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-12,2\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -6],\n [-4, -10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{16}{\\pi } \\\\\n \\frac{9}{\\pi } \\\\\n -\\frac{24}{\\pi } \\\\\n \\frac{8}{\\pi } \\\\\n \\frac{17}{\\pi } \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{7}{\\pi } \\\\\n \\frac{8}{\\pi } \\\\\n -\\frac{16}{\\pi } \\\\\n \\frac{25}{\\pi } \\\\\n \\frac{28}{\\pi } \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1244}{\\pi ^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(16/math.pi)],\n [(9/math.pi)],\n [-(24/math.pi)],\n [(8/math.pi)],\n [(17/math.pi)]])\nb = np.array([\n [(7/math.pi)],\n [(8/math.pi)],\n [-(16/math.pi)],\n [(25/math.pi)],\n [(28/math.pi)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{80}{9} \\\\\n \\frac{70}{9} \\\\\n \\frac{29}{9} \\\\\n -\\frac{53}{9} \\\\\n -\\frac{71}{9} \\\\\n \\frac{23}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{80}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(80/9)],\n [(70/9)],\n [(29/9)],\n [-(53/9)],\n [-(71/9)],\n [(23/3)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -3 \\\\\n -\\frac{3}{2} \\\\\n -1 \\\\\n 2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -\\frac{3}{2} \\\\\n -2 \\\\\n -1 \\\\\n \\frac{5}{2} \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{5}{47},-\\frac{15}{94},-\\frac{10}{47},-\\frac{5}{47},\\frac{25}{94},-\\frac{15}{47}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-3],\n [-(3/2)],\n [-1],\n [2],\n [3]]).squeeze()\nb = np.array([\n [-1],\n [-(3/2)],\n [-2],\n [-1],\n [(5/2)],\n [-3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{7}{3}, \\frac{4}{3}, -\\frac{1}{3}}$ to the plane $-2 x-\\frac{8 y}{3}-2 z+\\frac{14}{3}=0$.", - "Output Answer": [ - "$\\frac{13}{3 \\sqrt{34}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (7/3), (4/3), -(1/3)\nplane = Poly(-2*x-((8*y)/3)-2*z+(14/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -2 & \\frac{1}{2} & \\frac{1}{2} \\\\\n \\frac{3}{2} & \\frac{1}{2} & 2 \\\\\n -\\frac{3}{2} & -\\frac{1}{2} & \\frac{5}{2} \\\\\n 0 & \\frac{5}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{3}{2} & \\frac{5}{2} & \\frac{1}{2} & -2 \\\\\n 2 & 1 & -\\frac{1}{2} & 3 \\\\\n -\\frac{5}{2} & 0 & \\frac{1}{2} & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{13}{4} & -\\frac{9}{2} & -1 & \\frac{9}{2} \\\\\n -\\frac{7}{4} & \\frac{17}{4} & \\frac{3}{2} & -\\frac{11}{2} \\\\\n -\\frac{19}{2} & -\\frac{17}{4} & \\frac{3}{4} & -\\frac{7}{2} \\\\\n \\frac{25}{4} & \\frac{5}{2} & -\\frac{3}{2} & \\frac{17}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, (1/2), (1/2)],\n [(3/2), (1/2), 2],\n [-(3/2), -(1/2), (5/2)],\n [0, (5/2), -(1/2)]])\nb = np.array([\n [(3/2), (5/2), (1/2), -2],\n [2, 1, -(1/2), 3],\n [-(5/2), 0, (1/2), -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 8 & 2 & 2 & 0 \\\\\n 7 & 5 & -2 & 4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -9 & 10 & 5 & -1 \\\\\n -8 & 10 & -5 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 17 & -8 & -3 & 1 \\\\\n 15 & -5 & 3 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 2, 2, 0],\n [7, 5, -2, 4]])\nb = np.array([\n [-9, 10, 5, -1],\n [-8, 10, -5, 1]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -9 & 8 & -7 \\\\\n -2 & 9 & -9 \\\\\n -4 & -9 & 2 \\\\\n -6 & 2 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 6 & -2 & 5 \\\\\n 2 & -7 & 2 \\\\\n -7 & 2 & 8 \\\\\n -6 & 7 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -3 & 6 & -2 \\\\\n 0 & 2 & -7 \\\\\n -11 & -7 & 10 \\\\\n -12 & 9 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 8, -7],\n [-2, 9, -9],\n [-4, -9, 2],\n [-6, 2, -3]])\nb = np.array([\n [6, -2, 5],\n [2, -7, 2],\n [-7, 2, 8],\n [-6, 7, -1]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{28}{3} & \\frac{26}{3} \\\\\n -\\frac{14}{3} & -\\frac{20}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{2}{3} \\left(2-\\sqrt{53}\\right),\\frac{2}{3} \\left(2+\\sqrt{53}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(28/3), (26/3)],\n [-(14/3), -(20/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & \\frac{7}{2} \\\\\n 8 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-3-2 \\sqrt{11},2 \\sqrt{11}-3\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, (7/2)],\n [8, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & \\frac{16}{3} \\\\\n 7 & -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{3} \\left(7-2 \\sqrt{133}\\right),\\frac{1}{3} \\left(7+2 \\sqrt{133}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, (16/3)],\n [7, -(7/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{2}{9}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & -9 \\\\\n -8 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{2}{3} & 2 \\\\\n \\frac{16}{9} & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -9],\n [-8, -3]])\nprint(a * -(2/9))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 1 \\\\\n -\\frac{5}{2} \\\\\n 0 \\\\\n 0 \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n -\\frac{1}{2} \\\\\n -2 \\\\\n \\frac{1}{2} \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{2}{7},\\frac{2}{7},\\frac{1}{7},\\frac{4}{7},-\\frac{1}{7},\\frac{3}{7}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [1],\n [-(5/2)],\n [0],\n [0],\n [(1/2)]]).squeeze()\nb = np.array([\n [1],\n [-1],\n [-(1/2)],\n [-2],\n [(1/2)],\n [-(3/2)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{2,-3,4\\}, \\{4,1,-4\\}, \\{3,1,-1\\}}$.", - "Output Answer": [ - "$6 x+y+2 z-17=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, -3, 4],\n [4, 1, -4],\n [3, 1, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -5 & -\\frac{17}{2} \\\\\n 9 & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{3 x}{2}+59$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -(17/2)],\n [9, (7/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{2} & 4 \\\\\n \\frac{1}{2} & -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+11 x+\\frac{97}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), 4],\n [(1/2), -(15/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{27}{4} & \\frac{7}{8} & -\\frac{1}{8} & \\frac{17}{8} \\\\\n -\\frac{111}{16} & \\frac{5}{2} & -\\frac{15}{4} & \\frac{29}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -7 & -\\frac{93}{16} & \\frac{31}{8} & -\\frac{37}{4} \\\\\n \\frac{77}{8} & -\\frac{77}{8} & -\\frac{101}{16} & -\\frac{147}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{55}{4} & \\frac{107}{16} & -4 & \\frac{91}{8} \\\\\n -\\frac{265}{16} & \\frac{97}{8} & \\frac{41}{16} & \\frac{263}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(27/4), (7/8), -(1/8), (17/8)],\n [-(111/16), (5/2), -(15/4), (29/4)]])\nb = np.array([\n [-7, -(93/16), (31/8), -(37/4)],\n [(77/8), -(77/8), -(101/16), -(147/16)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{2} & -\\frac{15}{2} \\\\\n -\\frac{17}{2} & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{34} \\left(-21-\\sqrt{1461}\\right),1\\right\\}, \\left\\{\\frac{1}{34} \\left(\\sqrt{1461}-21\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), -(15/2)],\n [-(17/2), -8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{18}{5} & -\\frac{17}{5} & \\frac{7}{5} \\\\\n -\\frac{11}{5} & -3 & \\frac{1}{5} \\\\\n -\\frac{18}{5} & 4 & -\\frac{6}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{742}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(18/5), -(17/5), (7/5)],\n [-(11/5), -3, (1/5)],\n [-(18/5), 4, -(6/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2}-3 i & -\\frac{3}{2}+5 i \\\\\n \\frac{9}{2}-2 i & -3+\\frac{i}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1263}{8}-\\frac{1313 i}{8} & -\\frac{1725}{8}-\\frac{27 i}{8} \\\\\n \\frac{1041}{8}+\\frac{1251 i}{8} & \\frac{15}{8}-\\frac{1475 i}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2)-3j, -(3/2)+5j],\n [(9/2)-2j, -3+(1j/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -3 \\\\\n -6 \\\\\n 0 \\\\\n 7 \\\\\n -4 \\\\\n -2 \\\\\n 9 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -3 \\\\\n -9 \\\\\n -7 \\\\\n -9 \\\\\n -9 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{554}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-3],\n [-6],\n [0],\n [7],\n [-4],\n [-2],\n [9],\n [-9]])\nb = np.array([\n [1],\n [-3],\n [-9],\n [-7],\n [-9],\n [-9],\n [1],\n [-1],\n [0]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -1 & \\frac{24}{5} \\\\\n \\frac{11}{5} & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{25}{157} & \\frac{60}{157} \\\\\n \\frac{55}{314} & \\frac{25}{314} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, (24/5)],\n [(11/5), 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 1 & -1 & -1 & -2 & 1 \\\\\n -2 & 0 & 1 & 2 & -3 \\\\\n 3 & -1 & -1 & 0 & 0 \\\\\n 0 & 0 & -3 & -1 & -2 \\\\\n 2 & 1 & 2 & 2 & 0 \\\\\n 3 & -3 & -3 & -1 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.12 \\\\\n 1.53 \\\\\n -0.69 \\\\\n -2.74 \\\\\n 2.37 \\\\\n -1.79 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.013 \\\\\n 0.571 \\\\\n 3.739 \\\\\n -3.755 \\\\\n -2.345 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, -1, -2, 1],\n [-2, 0, 1, 2, -3],\n [3, -1, -1, 0, 0],\n [0, 0, -3, -1, -2],\n [2, 1, 2, 2, 0],\n [3, -3, -3, -1, -2]])\nb = np.array([\n [2.12],\n [1.53],\n [-0.69],\n [-2.74],\n [2.37],\n [-1.79]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5.2 \\\\\n 0.9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -0.2 \\\\\n -3.2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-1.84$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5.2],\n [0.9]])\nb = np.array([\n [-0.2],\n [-3.2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & -8 \\\\\n 7 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-3-i \\sqrt{223}\\right),\\frac{1}{2} \\left(-3+i \\sqrt{223}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -8],\n [7, -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{13}{8}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 10 & 4 & 9 \\\\\n -10 & 1 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{65}{4} & \\frac{13}{2} & \\frac{117}{8} \\\\\n -\\frac{65}{4} & \\frac{13}{8} & -\\frac{39}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 4, 9],\n [-10, 1, -6]])\nprint(a * (13/8))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 3 & 4 & 7 \\\\\n 0 & 3 & -4 \\\\\n -6 & 9 & 7 \\\\\n 8 & -6 & 9 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -5 & -6 & -9 \\\\\n 8 & -7 & -3 \\\\\n -6 & -6 & -9 \\\\\n 9 & -2 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 8 & 10 & 16 \\\\\n -8 & 10 & -1 \\\\\n 0 & 15 & 16 \\\\\n -1 & -4 & 15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 4, 7],\n [0, 3, -4],\n [-6, 9, 7],\n [8, -6, 9]])\nb = np.array([\n [-5, -6, -9],\n [8, -7, -3],\n [-6, -6, -9],\n [9, -2, -6]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n \\frac{11}{9} \\\\\n -\\frac{2}{9} \\\\\n \\frac{5}{9} \\\\\n \\frac{14}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{14}{9} & \\frac{25}{9} & \\frac{17}{9} & \\frac{5}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{154}{81} & \\frac{275}{81} & \\frac{187}{81} & \\frac{55}{81} \\\\\n \\frac{28}{81} & -\\frac{50}{81} & -\\frac{34}{81} & -\\frac{10}{81} \\\\\n -\\frac{70}{81} & \\frac{125}{81} & \\frac{85}{81} & \\frac{25}{81} \\\\\n -\\frac{196}{81} & \\frac{350}{81} & \\frac{238}{81} & \\frac{70}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/9)],\n [-(2/9)],\n [(5/9)],\n [(14/9)]])\nb = np.array([\n [-(14/9), (25/9), (17/9), (5/9)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -8 & -8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 4 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -12 & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -8]])\nb = np.array([\n [4, -1]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n 2 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 0 \\\\\n -3 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{2}{5},0,0,-\\frac{6}{5},0\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-2],\n [2],\n [-2],\n [2]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [0],\n [-3],\n [0]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 \\\\\n 9 \\\\\n -7 \\\\\n 0 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 2 \\\\\n -10 \\\\\n 9 \\\\\n -3 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-147$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [3],\n [9],\n [-7],\n [0],\n [-8]])\nb = np.array([\n [9],\n [2],\n [-10],\n [9],\n [-3],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,-3,-3\\}, \\{-3,2,1\\}, \\{5,2,-4\\}}$.", - "Output Answer": [ - "$25 x-17 y+40 z+69=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, -3, -3],\n [-3, 2, 1],\n [5, 2, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 6 & -4 & 5 & -2 \\\\\n -2 & 5 & 4 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & \\frac{41}{22} & \\frac{3}{11} \\\\\n 0 & 1 & \\frac{17}{11} & \\frac{10}{11} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, -4, 5, -2],\n [-2, 5, 4, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${0, -1, \\frac{13}{3}}$ to the plane $-\\frac{x}{3}+\\frac{13 y}{3}+\\frac{11 z}{3}+\\frac{8}{3}=0$.", - "Output Answer": [ - "$\\frac{128}{3 \\sqrt{291}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 0, -1, (13/3)\nplane = Poly(-(x/3)+((13*y)/3)+((11*z)/3)+(8/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8.61 \\\\\n -3.47 \\\\\n -0.56 \\\\\n -4.62 \\\\\n 7.74 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2.29 \\\\\n -0.45 \\\\\n 7.47 \\\\\n -8.61 \\\\\n -3.42 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$30.4026$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8.61],\n [-3.47],\n [-0.56],\n [-4.62],\n [7.74]])\nb = np.array([\n [-2.29],\n [-0.45],\n [7.47],\n [-8.61],\n [-3.42]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{3} & -\\frac{14}{3} & \\frac{8}{3} \\\\\n \\frac{4}{3} & 0 & -\\frac{13}{3} \\\\\n 1 & \\frac{4}{3} & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{26}{73} & \\frac{58}{73} & \\frac{91}{73} \\\\\n -\\frac{63}{146} & -\\frac{45}{73} & -\\frac{111}{146} \\\\\n \\frac{8}{73} & \\frac{1}{73} & \\frac{28}{73} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/3), -(14/3), (8/3)],\n [(4/3), 0, -(13/3)],\n [1, (4/3), 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 2 \\\\\n \\frac{25}{3} \\\\\n -\\frac{19}{3} \\\\\n \\frac{16}{3} \\\\\n \\frac{28}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{7}{3} \\\\\n 1 \\\\\n \\frac{17}{3} \\\\\n -\\frac{1}{3} \\\\\n \\frac{14}{3} \\\\\n -\\frac{1}{3} \\\\\n -\\frac{25}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{5069}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [2],\n [(25/3)],\n [-(19/3)],\n [(16/3)],\n [(28/3)]])\nb = np.array([\n [(7/3)],\n [1],\n [(17/3)],\n [-(1/3)],\n [(14/3)],\n [-(1/3)],\n [-(25/3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & -1 & -3 & 0 \\\\\n 1 & 1 & -1 & -3 \\\\\n 0 & 0 & 0 & -3 \\\\\n -2 & 3 & 1 & 0 \\\\\n 2 & -2 & -2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.96 \\\\\n -1.28 \\\\\n 0.22 \\\\\n -0.38 \\\\\n -2.66 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2.082 \\\\\n -0.658 \\\\\n -1.24 \\\\\n 0.148 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, -3, 0],\n [1, 1, -1, -3],\n [0, 0, 0, -3],\n [-2, 3, 1, 0],\n [2, -2, -2, -2]])\nb = np.array([\n [2.96],\n [-1.28],\n [0.22],\n [-0.38],\n [-2.66]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{18}{5} \\\\\n \\frac{6}{5} \\\\\n 5 \\\\\n -\\frac{36}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{36}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(18/5)],\n [(6/5)],\n [5],\n [-(36/5)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-5, -1, -2}$ to the plane $-x-\\frac{y}{2}-\\frac{z}{2}+\\frac{9}{2}=0$.", - "Output Answer": [ - "$11 \\sqrt{\\frac{2}{3}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -5, -1, -2\nplane = Poly(-x-(y/2)-(z/2)+(9/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{27}{8} & \\frac{3}{8} & -\\frac{7}{2} \\\\\n -\\frac{27}{8} & \\frac{63}{16} & \\frac{37}{16} \\\\\n -\\frac{41}{16} & -\\frac{33}{8} & \\frac{39}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{3266}{3173} & -\\frac{2308}{3173} & -\\frac{2500}{3173} \\\\\n -\\frac{62}{501} & \\frac{20}{501} & -\\frac{36}{167} \\\\\n -\\frac{4098}{3173} & -\\frac{2212}{3173} & -\\frac{2484}{3173} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(27/8), (3/8), -(7/2)],\n [-(27/8), (63/16), (37/16)],\n [-(41/16), -(33/8), (39/16)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{3}{2} & 1 & -\\frac{1}{2} & \\frac{1}{2} \\\\\n \\frac{5}{2} & \\frac{3}{2} & \\frac{1}{2} & \\frac{5}{2} \\\\\n -1 & -\\frac{3}{2} & -\\frac{3}{2} & -1 \\\\\n -\\frac{5}{2} & \\frac{5}{2} & -\\frac{3}{2} & \\frac{3}{2} \\\\\n 2 & \\frac{3}{2} & \\frac{5}{2} & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 0 & -\\frac{3}{2} \\\\\n 0 & -\\frac{5}{2} \\\\\n -\\frac{3}{2} & 0 \\\\\n -1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{4} & -\\frac{3}{4} \\\\\n -\\frac{13}{4} & -10 \\\\\n \\frac{13}{4} & \\frac{25}{4} \\\\\n \\frac{3}{4} & -4 \\\\\n -\\frac{11}{4} & -\\frac{23}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), 1, -(1/2), (1/2)],\n [(5/2), (3/2), (1/2), (5/2)],\n [-1, -(3/2), -(3/2), -1],\n [-(5/2), (5/2), -(3/2), (3/2)],\n [2, (3/2), (5/2), -1]])\nb = np.array([\n [0, -(3/2)],\n [0, -(5/2)],\n [-(3/2), 0],\n [-1, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 1 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 7 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{182}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [1],\n [7]])\nb = np.array([\n [1],\n [7],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n \\frac{13}{3} & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/3), 6]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{8}{5} \\\\\n 0 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{13}{5} \\\\\n -1 \\\\\n -\\frac{6}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{52}{115},-\\frac{4}{23},-\\frac{24}{115}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-(8/5)],\n [0]]).squeeze()\nb = np.array([\n [(13/5)],\n [-1],\n [-(6/5)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{10}{3},\\frac{1}{3},-\\frac{13}{3}\\right\\}, \\left\\{\\frac{1}{3},\\frac{10}{3},\\frac{5}{3}\\right\\}, \\left\\{-3,\\frac{8}{3},1\\right\\}}$.", - "Output Answer": [ - "$27 x-237 y+102 z+611=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(10/3), (1/3), -(13/3)],\n [(1/3), (10/3), (5/3)],\n [-3, (8/3), 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 1 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 6 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -26 \\\\\n -10 \\\\\n -56 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [1],\n [4]])\nb = np.array([\n [2],\n [6],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 e \\\\\n 2 e \\\\\n -e \\\\\n -e \\\\\n 0 \\\\\n -3 e \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 e \\\\\n -2 e \\\\\n 0 \\\\\n e \\\\\n -e \\\\\n -e \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 e^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-2*math.e],\n [2*math.e],\n [-math.e],\n [-math.e],\n [0],\n [-3*math.e]])\nb = np.array([\n [-2*math.e],\n [-2*math.e],\n [0],\n [math.e],\n [-math.e],\n [-math.e]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -3 \\\\\n 2 \\\\\n 8 \\\\\n -6 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -9 \\\\\n -4 \\\\\n 4 \\\\\n 9 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{573}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-3],\n [2],\n [8],\n [-6],\n [-7]])\nb = np.array([\n [-9],\n [-9],\n [-4],\n [4],\n [9],\n [9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{2} & 1 & 2 \\\\\n \\frac{1}{2} & -\\frac{1}{2} & -4 \\\\\n -1 & -\\frac{13}{2} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6.22,-4.874,5.595\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/2), 1, 2],\n [(1/2), -(1/2), -4],\n [-1, -(13/2), (3/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{18}{25} \\\\\n \\frac{97}{25} \\\\\n -\\frac{349}{50} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{183}{20} \\\\\n -\\frac{27}{25} \\\\\n \\frac{741}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{53031}{2500} \\\\\n \\frac{346011}{5000} \\\\\n \\frac{90699}{2500} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(18/25)],\n [(97/25)],\n [-(349/50)]])\nb = np.array([\n [-(183/20)],\n [-(27/25)],\n [(741/100)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 3 \\\\\n -2 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n \\frac{3}{\\sqrt{13}} \\\\\n -\\frac{2}{\\sqrt{13}} \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [3],\n [-2],\n [0],\n [0]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -9 & 4 & 3 & 1 \\\\\n 6 & 8 & -2 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1.,0.,3.,0.\\}, \\{28.,39.,0.,96.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, 4, 3, 1],\n [6, 8, -2, -5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -4 & 9 & 6 & 1 \\\\\n 1 & -9 & -10 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-36.,-34.,27.,0.\\}, \\{27.,11.,0.,9.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, 9, 6, 1],\n [1, -9, -10, 8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{14}{5} & -\\frac{4}{5} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -7 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{21}{5} & \\frac{31}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(14/5), -(4/5)]])\nb = np.array([\n [-7, -7]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -5 & 4 & 7 \\\\\n 9 & -6 & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 5 & 7 & 4 \\\\\n 3 & 5 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 11 & 11 \\\\\n 12 & -1 & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 4, 7],\n [9, -6, 3]])\nb = np.array([\n [5, 7, 4],\n [3, 5, -9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{39}{4} \\\\\n \\frac{31}{4} \\\\\n -3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n 4 \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{33}{4} \\\\\n \\frac{15}{4} \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(39/4)],\n [(31/4)],\n [-3]])\nb = np.array([\n [(3/2)],\n [4],\n [-(1/2)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -1 \\\\\n 2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{2}{3} \\\\\n -\\frac{1}{3} \\\\\n \\frac{2}{3} \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-1],\n [2],\n [0]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{37}{5} & -\\frac{31}{5} \\\\\n \\frac{26}{5} & -\\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{52} \\left(-29-i \\sqrt{2383}\\right),1\\right\\}, \\left\\{\\frac{1}{52} \\left(-29+i \\sqrt{2383}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(37/5), -(31/5)],\n [(26/5), -(8/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 6 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 5 \\\\\n 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 26 \\\\\n 1 \\\\\n -31 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [6],\n [-4]])\nb = np.array([\n [1],\n [5],\n [1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & -2 \\\\\n 1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2],\n [1, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,-3,0\\}, \\{-2,-1,2\\}, \\{-1,0,5\\}}$.", - "Output Answer": [ - "$x+2 y-z+6=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, -3, 0],\n [-2, -1, 2],\n [-1, 0, 5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{7}{2} & -\\frac{9}{2} & \\frac{7}{2} \\\\\n -\\frac{5}{2} & -5 & -\\frac{3}{2} \\\\\n -\\frac{9}{2} & \\frac{3}{2} & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{33}{20} & -1 & \\frac{97}{60} \\\\\n -\\frac{3}{10} & 0 & -\\frac{7}{30} \\\\\n -\\frac{7}{4} & 1 & -\\frac{23}{12} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2), -(9/2), (7/2)],\n [-(5/2), -5, -(3/2)],\n [-(9/2), (3/2), -(9/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{53}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{53}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(53/7)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,4,3\\}, \\{-3,-4,1\\}, \\{-3,1,1\\}}$.", - "Output Answer": [ - "$2 x+z+5=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, 4, 3],\n [-3, -4, 1],\n [-3, 1, 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 10 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -6 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-30$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [10],\n [6]])\nb = np.array([\n [-3],\n [-6],\n [1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -6 & -6 \\\\\n -3 & -4 \\\\\n 5 & 3 \\\\\n 10 & 2 \\\\\n -2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -6],\n [-3, -4],\n [5, 3],\n [10, 2],\n [-2, 0]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{4,-3,\\frac{9}{2}\\right\\}, \\left\\{5,2,\\frac{5}{2}\\right\\}, \\left\\{2,-\\frac{7}{2},3\\right\\}}$.", - "Output Answer": [ - "$34 x-22 y-38 z-31=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, -3, (9/2)],\n [5, 2, (5/2)],\n [2, -(7/2), 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{6}{\\pi } \\\\\n \\frac{20}{\\pi } \\\\\n -\\frac{20}{\\pi } \\\\\n \\frac{10}{\\pi } \\\\\n -\\frac{18}{\\pi } \\\\\n -\\frac{8}{\\pi } \\\\\n -\\frac{31}{\\pi } \\\\\n -\\frac{29}{\\pi } \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{18}{\\pi } \\\\\n \\frac{5}{\\pi } \\\\\n -\\frac{21}{\\pi } \\\\\n -\\frac{12}{\\pi } \\\\\n \\frac{18}{\\pi } \\\\\n \\frac{9}{\\pi } \\\\\n 0 \\\\\n \\frac{20}{\\pi } \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{684}{\\pi ^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(6/math.pi)],\n [(20/math.pi)],\n [-(20/math.pi)],\n [(10/math.pi)],\n [-(18/math.pi)],\n [-(8/math.pi)],\n [-(31/math.pi)],\n [-(29/math.pi)]])\nb = np.array([\n [(18/math.pi)],\n [(5/math.pi)],\n [-(21/math.pi)],\n [-(12/math.pi)],\n [(18/math.pi)],\n [(9/math.pi)],\n [0],\n [(20/math.pi)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -8 & 3 & -\\frac{25}{3} \\\\\n \\frac{29}{3} & \\frac{11}{3} & \\frac{2}{3} \\\\\n -1 & 1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-11.538,-1.099,5.303\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 3, -(25/3)],\n [(29/3), (11/3), (2/3)],\n [-1, 1, -3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${2, 3, -4}$ to the plane $4 x+3 y-3 z=0$.", - "Output Answer": [ - "$\\frac{29}{\\sqrt{34}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 2, 3, -4\nplane = Poly(4*x+3*y-3*z, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{2} & \\frac{7}{2} & -\\frac{9}{2} \\\\\n 4 & \\frac{9}{2} & \\frac{3}{2} \\\\\n \\frac{3}{2} & 2 & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{6}{13} & \\frac{10}{13} & -\\frac{12}{13} \\\\\n \\frac{94}{221} & -\\frac{96}{221} & \\frac{162}{221} \\\\\n -\\frac{10}{221} & -\\frac{18}{221} & \\frac{58}{221} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), (7/2), -(9/2)],\n [4, (9/2), (3/2)],\n [(3/2), 2, (7/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 5 & 6 & -4 & -7 & 5 \\\\\n 8 & -10 & 4 & -6 & -6 \\\\\n 6 & -2 & -3 & -3 & -7 \\\\\n -10 & -1 & 4 & 9 & -1 \\\\\n 4 & 8 & 6 & -10 & -1 \\\\\n 0 & -2 & -1 & -4 & -1 \\\\\n -10 & 4 & -5 & 8 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, 6, -4, -7, 5],\n [8, -10, 4, -6, -6],\n [6, -2, -3, -3, -7],\n [-10, -1, 4, 9, -1],\n [4, 8, 6, -10, -1],\n [0, -2, -1, -4, -1],\n [-10, 4, -5, 8, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{33}{8} & \\frac{13}{2} & -\\frac{21}{4} \\\\\n 4 & \\frac{21}{8} & \\frac{63}{8} \\\\\n \\frac{7}{4} & -\\frac{1}{2} & -\\frac{29}{8} \\\\\n -\\frac{39}{8} & \\frac{61}{8} & \\frac{19}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{2} & \\frac{13}{2} & \\frac{65}{8} \\\\\n -\\frac{77}{8} & -\\frac{15}{8} & \\frac{57}{8} \\\\\n -\\frac{35}{8} & \\frac{7}{8} & -\\frac{19}{2} \\\\\n 4 & -\\frac{37}{8} & -\\frac{17}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{43}{8} & 0 & -\\frac{107}{8} \\\\\n \\frac{109}{8} & \\frac{9}{2} & \\frac{3}{4} \\\\\n \\frac{49}{8} & -\\frac{11}{8} & \\frac{47}{8} \\\\\n -\\frac{71}{8} & \\frac{49}{4} & \\frac{55}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(33/8), (13/2), -(21/4)],\n [4, (21/8), (63/8)],\n [(7/4), -(1/2), -(29/8)],\n [-(39/8), (61/8), (19/4)]])\nb = np.array([\n [-(19/2), (13/2), (65/8)],\n [-(77/8), -(15/8), (57/8)],\n [-(35/8), (7/8), -(19/2)],\n [4, -(37/8), -(17/8)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -7 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -7 \\\\\n 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 \\\\\n 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-7],\n [3]])\nb = np.array([\n [-4],\n [-7],\n [3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -3 & -3 \\\\\n -5 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{2}{21} & -\\frac{1}{7} \\\\\n -\\frac{5}{21} & \\frac{1}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3],\n [-5, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{26}{5} & 10 & \\frac{17}{5} \\\\\n 2 & -\\frac{1}{5} & \\frac{48}{5} \\\\\n \\frac{23}{5} & -\\frac{27}{5} & \\frac{11}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{36 x^2}{5}-\\frac{654 x}{25}+\\frac{78911}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/5), 10, (17/5)],\n [2, -(1/5), (48/5)],\n [(23/5), -(27/5), (11/5)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -2 & 2 & 2 & -2 \\\\\n 2 & 1 & 1 & -3 \\\\\n 1 & -2 & -1 & 2 \\\\\n 2 & 3 & 2 & -2 \\\\\n 1 & -1 & 2 & 1 \\\\\n -1 & 0 & 0 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.58 \\\\\n -2.49 \\\\\n 1.84 \\\\\n 2.52 \\\\\n -2.41 \\\\\n 2.17 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.329 \\\\\n 0.95 \\\\\n -0.527 \\\\\n 0.276 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2, 2, -2],\n [2, 1, 1, -3],\n [1, -2, -1, 2],\n [2, 3, 2, -2],\n [1, -1, 2, 1],\n [-1, 0, 0, -2]])\nb = np.array([\n [1.58],\n [-2.49],\n [1.84],\n [2.52],\n [-2.41],\n [2.17]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 3 & 2 & -3 & -2 & 0 \\\\\n 2 & 1 & 3 & 2 & -3 \\\\\n 1 & -3 & 2 & 0 & -1 \\\\\n -2 & 0 & 2 & 2 & 0 \\\\\n 0 & -1 & 0 & -1 & -3 \\\\\n 0 & 3 & 3 & -3 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.54 \\\\\n 1.26 \\\\\n -1.75 \\\\\n -2.21 \\\\\n -2.44 \\\\\n 2.17 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.132 \\\\\n 0.376 \\\\\n 0.457 \\\\\n 0.096 \\\\\n 0.548 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2, -3, -2, 0],\n [2, 1, 3, 2, -3],\n [1, -3, 2, 0, -1],\n [-2, 0, 2, 2, 0],\n [0, -1, 0, -1, -3],\n [0, 3, 3, -3, 0]])\nb = np.array([\n [-2.54],\n [1.26],\n [-1.75],\n [-2.21],\n [-2.44],\n [2.17]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{4} \\\\\n -\\frac{3}{4} \\\\\n -1 \\\\\n -\\frac{11}{4} \\\\\n -1 \\\\\n -\\frac{11}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{2 \\sqrt{73}} \\\\\n -\\frac{3}{2 \\sqrt{73}} \\\\\n -\\frac{2}{\\sqrt{73}} \\\\\n -\\frac{11}{2 \\sqrt{73}} \\\\\n -\\frac{2}{\\sqrt{73}} \\\\\n -\\frac{11}{2 \\sqrt{73}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/4)],\n [-(3/4)],\n [-1],\n [-(11/4)],\n [-1],\n [-(11/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n -2 \\\\\n -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [-2],\n [-10]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 2 & 0 & -2 & -3 \\\\\n -2 & 3 & 2 & -1 \\\\\n -3 & -2 & 1 & -1 \\\\\n 3 & 2 & 1 & 2 \\\\\n -2 & 1 & -2 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -2 & -1 & 2 & -1 \\\\\n -2 & 0 & 0 & -1 \\\\\n 2 & 2 & -3 & 0 \\\\\n 0 & 3 & 0 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -8 & -15 & 10 & 4 \\\\\n 2 & 3 & -10 & 1 \\\\\n 12 & 2 & -9 & 7 \\\\\n -8 & 5 & 3 & -9 \\\\\n -2 & 4 & 2 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, -2, -3],\n [-2, 3, 2, -1],\n [-3, -2, 1, -1],\n [3, 2, 1, 2],\n [-2, 1, -2, 2]])\nb = np.array([\n [-2, -1, 2, -1],\n [-2, 0, 0, -1],\n [2, 2, -3, 0],\n [0, 3, 0, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1}{\\sqrt{6}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [1],\n [0],\n [0]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [-1],\n [1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{2}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 5 \\\\\n -6 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -28 \\\\\n \\frac{35}{2} \\\\\n -21 \\\\\n 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [5],\n [-6],\n [2]])\nprint(a * (7/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 4 & -8 \\\\\n -4 & -2 \\\\\n -10 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, -8],\n [-4, -2],\n [-10, -8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{31}{16} \\\\\n \\frac{15}{16} \\\\\n \\frac{17}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{31}{5 \\sqrt{59}} \\\\\n \\frac{3}{\\sqrt{59}} \\\\\n \\frac{17}{5 \\sqrt{59}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(31/16)],\n [(15/16)],\n [(17/16)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & -9 \\\\\n 1 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{7-2 \\sqrt{10},1\\right\\}, \\left\\{7+2 \\sqrt{10},1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -9],\n [1, -7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & 3 \\\\\n -3 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-3 \\sqrt{3},3 \\sqrt{3}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 3],\n [-3, 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 3 & 1 \\\\\n -\\frac{5}{2} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{13}{2} & \\frac{9}{2} \\\\\n -\\frac{45}{4} & -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1],\n [-(5/2), (3/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{11}{4} & -\\frac{27}{16} & -\\frac{17}{8} & -\\frac{29}{16} \\\\\n \\frac{3}{8} & -\\frac{25}{16} & \\frac{9}{16} & -\\frac{27}{16} \\\\\n 3 & -\\frac{5}{8} & \\frac{5}{2} & -\\frac{11}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{11}{4} & -2 & \\frac{1}{2} & \\frac{21}{8} & -\\frac{1}{8} \\\\\n -\\frac{31}{16} & \\frac{3}{16} & -\\frac{47}{16} & \\frac{23}{8} & 0 \\\\\n -\\frac{3}{2} & \\frac{9}{8} & \\frac{9}{8} & \\frac{7}{16} & -\\frac{17}{16} \\\\\n \\frac{45}{16} & \\frac{13}{16} & \\frac{41}{16} & \\frac{3}{2} & \\frac{31}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n \\frac{571}{64} & \\frac{169}{128} & -\\frac{221}{64} & -\\frac{503}{32} & -\\frac{233}{256} \\\\\n -\\frac{115}{32} & -\\frac{57}{32} & \\frac{139}{128} & -\\frac{1483}{256} & -\\frac{501}{128} \\\\\n -\\frac{3257}{256} & -\\frac{989}{256} & \\frac{1123}{256} & \\frac{393}{64} & -\\frac{1117}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/4), -(27/16), -(17/8), -(29/16)],\n [(3/8), -(25/16), (9/16), -(27/16)],\n [3, -(5/8), (5/2), -(11/16)]])\nb = np.array([\n [-(11/4), -2, (1/2), (21/8), -(1/8)],\n [-(31/16), (3/16), -(47/16), (23/8), 0],\n [-(3/2), (9/8), (9/8), (7/16), -(17/16)],\n [(45/16), (13/16), (41/16), (3/2), (31/16)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -2 & -10 & 7 & 5 \\\\\n 6 & 5 & -9 & -10 \\\\\n -6 & 4 & 7 & 6 \\\\\n -2 & 7 & 10 & 9 \\\\\n 0 & -3 & 1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, -10, 7, 5],\n [6, 5, -9, -10],\n [-6, 4, 7, 6],\n [-2, 7, 10, 9],\n [0, -3, 1, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{7}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 5 & -8 & 5 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{15}{7} & \\frac{24}{7} & -\\frac{15}{7} & -\\frac{27}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -8, 5, 9]])\nprint(a * -(3/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(-2 \\sqrt{5}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [0],\n [0],\n [1],\n [0],\n [-1],\n [-1]]).squeeze()\nb = np.array([\n [-1],\n [-1],\n [-1],\n [0],\n [0],\n [0],\n [0],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{51}{7} & -\\frac{30}{7} & -\\frac{57}{7} & 0 \\\\\n -\\frac{17}{7} & -\\frac{62}{7} & \\frac{22}{7} & -\\frac{45}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{67}{7} & \\frac{17}{7} & \\frac{44}{7} & -\\frac{54}{7} \\\\\n -\\frac{6}{7} & \\frac{44}{7} & \\frac{58}{7} & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{16}{7} & -\\frac{13}{7} & -\\frac{13}{7} & -\\frac{54}{7} \\\\\n -\\frac{23}{7} & -\\frac{18}{7} & \\frac{80}{7} & -\\frac{101}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(51/7), -(30/7), -(57/7), 0],\n [-(17/7), -(62/7), (22/7), -(45/7)]])\nb = np.array([\n [(67/7), (17/7), (44/7), -(54/7)],\n [-(6/7), (44/7), (58/7), -8]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{8}{7}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{8}{7} & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -7]])\nprint(a * -(8/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -2 & 0 \\\\\n -3 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2} & 0 \\\\\n \\frac{1}{2} & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0],\n [-3, -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n \\frac{11}{2} \\\\\n -4 \\\\\n 0 \\\\\n -\\frac{11}{2} \\\\\n \\frac{17}{2} \\\\\n 6 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{947}}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [(11/2)],\n [-4],\n [0],\n [-(11/2)],\n [(17/2)],\n [6],\n [-4]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -10 & -4 \\\\\n -7 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{7} \\left(7-\\sqrt{77}\\right),1\\right\\}, \\left\\{\\frac{1}{7} \\left(7+\\sqrt{77}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -4],\n [-7, 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -5 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{138}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-5],\n [-7]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{61}{7} \\\\\n \\frac{31}{7} \\\\\n -5 \\\\\n -\\frac{30}{7} \\\\\n \\frac{59}{7} \\\\\n -5 \\\\\n -\\frac{19}{7} \\\\\n \\frac{51}{7} \\\\\n \\frac{47}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{7} \\\\\n \\frac{68}{7} \\\\\n -\\frac{65}{7} \\\\\n \\frac{37}{7} \\\\\n -\\frac{40}{7} \\\\\n 9 \\\\\n \\frac{26}{7} \\\\\n -\\frac{27}{7} \\\\\n \\frac{24}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{39157}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(61/7)],\n [(31/7)],\n [-5],\n [-(30/7)],\n [(59/7)],\n [-5],\n [-(19/7)],\n [(51/7)],\n [(47/7)]])\nb = np.array([\n [-(5/7)],\n [(68/7)],\n [-(65/7)],\n [(37/7)],\n [-(40/7)],\n [9],\n [(26/7)],\n [-(27/7)],\n [(24/7)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{11}{32}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{11}{32} \\\\\n \\frac{11}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [2]])\nprint(a * (11/32))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n \\frac{22}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{20}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{440}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(22/9)]])\nb = np.array([\n [-(20/9)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & 1 & -2 \\\\\n -1 & -1 & -1 \\\\\n -3 & 1 & 0 \\\\\n 3 & -3 & -3 \\\\\n 2 & 0 & -2 \\\\\n -1 & -2 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.82 \\\\\n 0.59 \\\\\n -2.31 \\\\\n -0.77 \\\\\n -0.86 \\\\\n 1.21 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.281 \\\\\n -0.31 \\\\\n 0.446 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1, -2],\n [-1, -1, -1],\n [-3, 1, 0],\n [3, -3, -3],\n [2, 0, -2],\n [-1, -2, -1]])\nb = np.array([\n [0.82],\n [0.59],\n [-2.31],\n [-0.77],\n [-0.86],\n [1.21]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -9 & -9 & 7 \\\\\n 2 & 10 & -4 \\\\\n 8 & 4 & -5 \\\\\n -6 & -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -9, 7],\n [2, 10, -4],\n [8, 4, -5],\n [-6, -1, 3]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\pi \\\\\n 0 \\\\\n 0 \\\\\n 2 \\pi \\\\\n \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\pi \\\\\n \\pi \\\\\n -\\pi \\\\\n 2 \\pi \\\\\n -2 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{11} \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-2*math.pi],\n [0],\n [0],\n [2*math.pi],\n [math.pi]])\nb = np.array([\n [-2*math.pi],\n [math.pi],\n [-math.pi],\n [2*math.pi],\n [-2*math.pi]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -7 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 8 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -128 \\\\\n 20 \\\\\n 44 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-7],\n [9]])\nb = np.array([\n [4],\n [8],\n [8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{62}{9} & -\\frac{19}{3} & \\frac{67}{9} \\\\\n -\\frac{22}{3} & -10 & \\frac{28}{3} \\\\\n \\frac{61}{9} & \\frac{86}{9} & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{152 x^2}{9}+\\frac{9493 x}{81}+\\frac{47786}{243}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(62/9), -(19/3), (67/9)],\n [-(22/3), -10, (28/3)],\n [(61/9), (86/9), 0]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 8 & 1 & -3 & 3 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-9.,0.,0.,0.,8.\\}, \\{-3.,0.,0.,8.,0.\\}, \\{-1.,8.,0.,0.,0.\\}, \\{3.,0.,8.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [8, 1, -3, 3, 9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -1 & -8 & 0 & -7 \\\\\n -8 & -5 & -6 & 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 0 & 0 & 0 & 0 \\\\\n 9 & -10 & -7 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -1 & -8 & 0 & -7 \\\\\n 1 & -15 & -13 & 15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -8, 0, -7],\n [-8, -5, -6, 9]])\nb = np.array([\n [0, 0, 0, 0],\n [9, -10, -7, 6]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 7 \\\\\n -\\frac{17}{2} \\\\\n -10 \\\\\n -\\frac{1}{2} \\\\\n -\\frac{1}{2} \\\\\n -\\frac{19}{2} \\\\\n -\\frac{5}{2} \\\\\n 4 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n -\\frac{15}{2} \\\\\n -8 \\\\\n -2 \\\\\n \\frac{9}{2} \\\\\n -7 \\\\\n \\frac{3}{2} \\\\\n -9 \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{1907}}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [7],\n [-(17/2)],\n [-10],\n [-(1/2)],\n [-(1/2)],\n [-(19/2)],\n [-(5/2)],\n [4],\n [6]])\nb = np.array([\n [1],\n [-2],\n [-(15/2)],\n [-8],\n [-2],\n [(9/2)],\n [-7],\n [(3/2)],\n [-9],\n [-(5/2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -4 & -1 & 5 & 1 & 0 & -3 & 1 \\\\\n 7 & -6 & -10 & 9 & -8 & 2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & -\\frac{40}{31} & \\frac{3}{31} & -\\frac{8}{31} & \\frac{20}{31} & -\\frac{4}{31} \\\\\n 0 & 1 & \\frac{5}{31} & -\\frac{43}{31} & \\frac{32}{31} & \\frac{13}{31} & -\\frac{15}{31} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-4, -1, 5, 1, 0, -3, 1],\n [7, -6, -10, 9, -8, 2, 2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 4 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 1 \\\\\n -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -14 \\\\\n 66 \\\\\n 25 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [4],\n [-10]])\nb = np.array([\n [-6],\n [1],\n [-6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n \\frac{7}{6} & \\frac{1}{6} & \\frac{7}{6} & \\frac{1}{6} \\\\\n -\\frac{1}{3} & \\frac{4}{3} & \\frac{17}{6} & -\\frac{4}{3} \\\\\n -\\frac{13}{6} & \\frac{2}{3} & -\\frac{7}{3} & -\\frac{3}{2} \\\\\n -\\frac{5}{3} & \\frac{1}{2} & -1 & -\\frac{7}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{6} & -\\frac{1}{3} \\\\\n -2 & \\frac{5}{6} \\\\\n -\\frac{1}{3} & -\\frac{7}{6} \\\\\n -\\frac{7}{3} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{89}{36} & -\\frac{61}{36} \\\\\n -\\frac{1}{9} & -\\frac{17}{12} \\\\\n \\frac{197}{36} & \\frac{19}{4} \\\\\n 4 & \\frac{49}{18} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/6), (1/6), (7/6), (1/6)],\n [-(1/3), (4/3), (17/6), -(4/3)],\n [-(13/6), (2/3), -(7/3), -(3/2)],\n [-(5/3), (1/2), -1, -(7/6)]])\nb = np.array([\n [-(7/6), -(1/3)],\n [-2, (5/6)],\n [-(1/3), -(7/6)],\n [-(7/3), -(1/2)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 2 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{2}{3},0,-\\frac{1}{3},-\\frac{1}{3}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [2],\n [1],\n [1]]).squeeze()\nb = np.array([\n [2],\n [0],\n [1],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -6 \\\\\n -9 \\\\\n 4 \\\\\n -9 \\\\\n 1 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 1 \\\\\n 7 \\\\\n -2 \\\\\n -5 \\\\\n 7 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-101$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-6],\n [-9],\n [4],\n [-9],\n [1],\n [-9]])\nb = np.array([\n [2],\n [1],\n [7],\n [-2],\n [-5],\n [7],\n [8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -\\frac{3}{2} \\\\\n \\frac{1}{2} \\\\\n \\frac{3}{4} \\\\\n -\\frac{7}{4} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -1 \\\\\n 2 \\\\\n -\\frac{7}{4} \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{118}{197},\\frac{59}{197},-\\frac{118}{197},\\frac{413}{788},-\\frac{59}{394}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-(3/2)],\n [(1/2)],\n [(3/4)],\n [-(7/4)]]).squeeze()\nb = np.array([\n [2],\n [-1],\n [2],\n [-(7/4)],\n [(1/2)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 0 & -\\frac{5}{2} \\\\\n 1 & \\frac{5}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{5}{2} & -\\frac{25}{4} \\\\\n \\frac{5}{2} & \\frac{15}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -(5/2)],\n [1, (5/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1-3 i & -i & 3+2 i \\\\\n 5+5 i & 3+4 i & -4+i \\\\\n -2-5 i & 5-2 i & -3 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1-18 i & 20+2 i & -5-13 i \\\\\n 18+33 i & -20+32 i & 1+9 i \\\\\n 28+41 i & 3+22 i & -5-6 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1-3j, - 1j, 3+2j],\n [5+5j, 3+4j, -4+ 1j],\n [-2-5j, 5-2j, -3]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -\\frac{26}{3} & \\frac{5}{3} \\\\\n \\frac{26}{3} & \\frac{4}{3} \\\\\n \\frac{20}{3} & \\frac{2}{3} \\\\\n \\frac{7}{3} & 4 \\\\\n \\frac{5}{3} & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(26/3), (5/3)],\n [(26/3), (4/3)],\n [(20/3), (2/3)],\n [(7/3), 4],\n [(5/3), 9]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -8 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 7 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-95$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-8],\n [3]])\nb = np.array([\n [6],\n [7],\n [5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -8 & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 6 & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -14 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -(7/2)]])\nb = np.array([\n [6, -(5/2)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 2 & -1 \\\\\n 6 & -8 \\\\\n -7 & -8 \\\\\n -4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, -1],\n [6, -8],\n [-7, -8],\n [-4, -3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -\\frac{11}{4} \\\\\n \\frac{11}{4} \\\\\n -\\frac{9}{4} \\\\\n -\\frac{7}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{4} & \\frac{5}{2} & \\frac{9}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{4} & \\frac{15}{2} & \\frac{27}{4} \\\\\n \\frac{11}{16} & -\\frac{55}{8} & -\\frac{99}{16} \\\\\n -\\frac{11}{16} & \\frac{55}{8} & \\frac{99}{16} \\\\\n \\frac{9}{16} & -\\frac{45}{8} & -\\frac{81}{16} \\\\\n \\frac{7}{16} & -\\frac{35}{8} & -\\frac{63}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-(11/4)],\n [(11/4)],\n [-(9/4)],\n [-(7/4)]])\nb = np.array([\n [-(1/4), (5/2), (9/4)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 3 \\\\\n 1 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [3],\n [1],\n [-7]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 8 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -72 \\\\\n 72 \\\\\n 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [8],\n [0]])\nb = np.array([\n [0],\n [1],\n [-9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{8}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -5 & -3 & -4 \\\\\n -2 & 1 & 8 \\\\\n 3 & 8 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{25}{8} & \\frac{15}{8} & \\frac{5}{2} \\\\\n \\frac{5}{4} & -\\frac{5}{8} & -5 \\\\\n -\\frac{15}{8} & -5 & \\frac{25}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -3, -4],\n [-2, 1, 8],\n [3, 8, -10]])\nprint(a * -(5/8))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -5 & -8 \\\\\n 9 & 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 3 & -1 \\\\\n -5 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -2 & -9 \\\\\n 4 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -8],\n [9, 6]])\nb = np.array([\n [3, -1],\n [-5, -3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{69}{8} \\\\\n \\frac{45}{8} \\\\\n \\frac{37}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{63}{8} \\\\\n 4 \\\\\n -\\frac{29}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{33}{2} \\\\\n \\frac{77}{8} \\\\\n 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(69/8)],\n [(45/8)],\n [(37/8)]])\nb = np.array([\n [-(63/8)],\n [4],\n [-(29/8)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -5 & 0 \\\\\n -5 & -5 \\\\\n 5 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, 0],\n [-5, -5],\n [5, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & \\frac{25}{4} \\\\\n -6 & -\\frac{13}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{8} \\left(-29-i \\sqrt{2391}\\right),\\frac{1}{8} \\left(-29+i \\sqrt{2391}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, (25/4)],\n [-6, -(13/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 3 & 3 & 3 & 2 & 3 \\\\\n -1 & 2 & -1 & 3 & 0 \\\\\n 3 & -2 & -1 & 1 & 3 \\\\\n 1 & -1 & -2 & 2 & 1 \\\\\n 1 & 1 & -3 & -1 & -1 \\\\\n -1 & 2 & 3 & 0 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.04 \\\\\n 1.91 \\\\\n -2.2 \\\\\n 0.05 \\\\\n -2.04 \\\\\n 1.89 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.214 \\\\\n -0.08 \\\\\n 0.022 \\\\\n 0.329 \\\\\n 0.364 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3, 3, 2, 3],\n [-1, 2, -1, 3, 0],\n [3, -2, -1, 1, 3],\n [1, -1, -2, 2, 1],\n [1, 1, -3, -1, -1],\n [-1, 2, 3, 0, 2]])\nb = np.array([\n [-2.04],\n [1.91],\n [-2.2],\n [0.05],\n [-2.04],\n [1.89]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -5 \\\\\n -9 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -6 \\\\\n -8 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$161$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-5],\n [-9],\n [-8]])\nb = np.array([\n [1],\n [-6],\n [-8],\n [-7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{23}{3} \\\\\n -\\frac{29}{3} \\\\\n -\\frac{17}{3} \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{3} \\\\\n 1 \\\\\n 5 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{793}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/3)],\n [-(29/3)],\n [-(17/3)],\n [3]])\nb = np.array([\n [-(29/3)],\n [1],\n [5],\n [8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & 0 & -2 & -3 \\\\\n -3 & 2 & 1 & 2 \\\\\n 0 & -1 & -1 & 1 \\\\\n 1 & -2 & 1 & 3 \\\\\n 3 & 0 & 0 & 1 \\\\\n -1 & 2 & -2 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.99 \\\\\n 1.04 \\\\\n -2.7 \\\\\n -0.74 \\\\\n -1.41 \\\\\n -0.57 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.19 \\\\\n 0.383 \\\\\n 1.051 \\\\\n -0.467 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 0, -2, -3],\n [-3, 2, 1, 2],\n [0, -1, -1, 1],\n [1, -2, 1, 3],\n [3, 0, 0, 1],\n [-1, 2, -2, 0]])\nb = np.array([\n [-0.99],\n [1.04],\n [-2.7],\n [-0.74],\n [-1.41],\n [-0.57]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -2 \\\\\n 7 \\\\\n 8 \\\\\n 7 \\\\\n -2 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -9 \\\\\n 4 \\\\\n 1 \\\\\n -4 \\\\\n -5 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{341}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-2],\n [7],\n [8],\n [7],\n [-2],\n [9]])\nb = np.array([\n [3],\n [-9],\n [4],\n [1],\n [-4],\n [-5],\n [-1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -1 & 1 & 2 \\\\\n 0 & 2 & 2 \\\\\n -1 & 0 & 3 \\\\\n 1 & -2 & -2 \\\\\n 0 & 3 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 1 & 2 & 2 \\\\\n -1 & -1 & 3 \\\\\n 1 & 2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 1 & 1 \\\\\n 0 & 2 & 6 \\\\\n 2 & 4 & -2 \\\\\n 1 & 0 & -4 \\\\\n -2 & -1 & 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, 2],\n [0, 2, 2],\n [-1, 0, 3],\n [1, -2, -2],\n [0, 3, 1]])\nb = np.array([\n [1, 2, 2],\n [-1, -1, 3],\n [1, 2, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [4]])\nb = np.array([\n [0],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $2$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & -4 \\\\\n 7 & 6 \\\\\n -8 & 0 \\\\\n 5 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 2 & -8 \\\\\n 14 & 12 \\\\\n -16 & 0 \\\\\n 10 & 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -4],\n [7, 6],\n [-8, 0],\n [5, 6]])\nprint(a * 2)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [(1/2)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & -2 \\\\\n -3 & 1 \\\\\n 2 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.44 \\\\\n -0.72 \\\\\n -1.35 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.146 \\\\\n 0.561 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2],\n [-3, 1],\n [2, -1]])\nb = np.array([\n [-1.44],\n [-0.72],\n [-1.35]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & -\\frac{3}{2} & 5 \\\\\n \\frac{1}{2} & -\\frac{9}{2} & 2 \\\\\n \\frac{7}{2} & -\\frac{7}{2} & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{33} & -\\frac{7}{33} & \\frac{26}{77} \\\\\n \\frac{1}{11} & -\\frac{3}{11} & \\frac{2}{77} \\\\\n \\frac{8}{33} & -\\frac{2}{33} & -\\frac{2}{77} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), -(3/2), 5],\n [(1/2), -(9/2), 2],\n [(7/2), -(7/2), (7/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{23}{5} & -\\frac{2}{5} & -2 \\\\\n \\frac{29}{10} & -\\frac{1}{2} & 3 \\\\\n \\frac{22}{5} & 1 & -\\frac{7}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{14241}{500}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/5), -(2/5), -2],\n [(29/10), -(1/2), 3],\n [(22/5), 1, -(7/10)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 0 & -2 & 5 \\\\\n 6 & -6 & -9 \\\\\n -2 & -1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.505,4.36,1.\\}, \\{0.113\\, -1.968 i,-1.911-0.564 i,1.\\}, \\{0.113\\, +1.968 i,-1.911+0.564 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2, 5],\n [6, -6, -9],\n [-2, -1, -2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{43}{8} & \\frac{17}{2} \\\\\n -\\frac{23}{4} & \\frac{3}{2} \\\\\n -4 & -\\frac{33}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 1 & -\\frac{29}{8} \\\\\n -\\frac{19}{8} & \\frac{55}{8} \\\\\n \\frac{73}{8} & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{35}{8} & \\frac{97}{8} \\\\\n -\\frac{27}{8} & -\\frac{43}{8} \\\\\n -\\frac{105}{8} & -\\frac{29}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(43/8), (17/2)],\n [-(23/4), (3/2)],\n [-4, -(33/4)]])\nb = np.array([\n [1, -(29/8)],\n [-(19/8), (55/8)],\n [(73/8), -1]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7.52 \\\\\n -1.55 \\\\\n -3.1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2.25 \\\\\n 4.4 \\\\\n 7.28 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-46.308$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7.52],\n [-1.55],\n [-3.1]])\nb = np.array([\n [-2.25],\n [4.4],\n [7.28]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{7} \\\\\n \\frac{13}{7} \\\\\n \\frac{16}{7} \\\\\n -\\frac{20}{7} \\\\\n -\\frac{3}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{5}{\\sqrt{859}} \\\\\n \\frac{13}{\\sqrt{859}} \\\\\n \\frac{16}{\\sqrt{859}} \\\\\n -\\frac{20}{\\sqrt{859}} \\\\\n -\\frac{3}{\\sqrt{859}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/7)],\n [(13/7)],\n [(16/7)],\n [-(20/7)],\n [-(3/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & -2 & 1 \\\\\n -4 & 0 & -4 \\\\\n 0 & 3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{7} & -\\frac{1}{28} & -\\frac{2}{7} \\\\\n \\frac{1}{7} & -\\frac{1}{14} & \\frac{3}{7} \\\\\n \\frac{3}{7} & -\\frac{3}{14} & \\frac{2}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2, 1],\n [-4, 0, -4],\n [0, 3, -1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -2 & 4 & 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 10 & 3 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 8 & 7 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 4, 7]])\nb = np.array([\n [10, 3, -5]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{7}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 5 & -6 & -7 & -1 \\\\\n 8 & 8 & 9 & 9 \\\\\n 5 & -6 & 2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{5}{7} & \\frac{6}{7} & 1 & \\frac{1}{7} \\\\\n -\\frac{8}{7} & -\\frac{8}{7} & -\\frac{9}{7} & -\\frac{9}{7} \\\\\n -\\frac{5}{7} & \\frac{6}{7} & -\\frac{2}{7} & \\frac{1}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -6, -7, -1],\n [8, 8, 9, 9],\n [5, -6, 2, -1]])\nprint(a * -(1/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 0 & 1 & 1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 0 & 1 & 1 & 3 \\\\\n 0 & -3 & -3 & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-3]])\nb = np.array([\n [0, 1, 1, 3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{14}{3} & \\frac{7}{3} & -\\frac{14}{3} \\\\\n -\\frac{4}{3} & -\\frac{8}{3} & \\frac{10}{3} \\\\\n -\\frac{14}{3} & 2 & \\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{280}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/3), (7/3), -(14/3)],\n [-(4/3), -(8/3), (10/3)],\n [-(14/3), 2, (11/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{2} & -\\frac{9}{2} & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{2} & -8 & -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -13 & -\\frac{25}{2} & -\\frac{19}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/2), -(9/2), -2]])\nb = np.array([\n [-(13/2), -8, -(15/2)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{3}{2},\\frac{5}{2},0\\right\\}, \\left\\{0,-\\frac{5}{2},-2\\right\\}, \\left\\{-\\frac{1}{2},0,-1\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{3}{\\sqrt{34}},\\frac{5}{\\sqrt{34}},0\\right\\}, \\left\\{-\\frac{75}{\\sqrt{26146}},-\\frac{45}{\\sqrt{26146}},-4 \\sqrt{\\frac{34}{769}}\\right\\}, \\left\\{\\frac{20}{\\sqrt{769}},\\frac{12}{\\sqrt{769}},-\\frac{15}{\\sqrt{769}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-(3/2), (5/2), 0), (0, -(5/2), -2), (-(1/2), 0, -1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 1 \\\\\n 2 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{0,\\frac{2}{3},\\frac{2}{3},-\\frac{2}{3},0\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [1],\n [2],\n [1],\n [1]]).squeeze()\nb = np.array([\n [0],\n [-1],\n [-1],\n [1],\n [0]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 9 \\\\\n 9 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -4 \\\\\n -9 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 11 \\\\\n 5 \\\\\n 0 \\\\\n 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [9],\n [9],\n [1]])\nb = np.array([\n [1],\n [-4],\n [-9],\n [5]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2} & -3 \\\\\n \\frac{5}{2} & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{59}{8} & \\frac{87}{4} \\\\\n -\\frac{145}{8} & \\frac{15}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), -3],\n [(5/2), 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -9 & 1 & 8 \\\\\n 0 & -4 & -8 \\\\\n -4 & -8 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 1, 8],\n [0, -4, -8],\n [-4, -8, 1]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -2 \\\\\n -2 \\\\\n -6 \\\\\n 9 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 7 \\\\\n 0 \\\\\n 3 \\\\\n 6 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{355}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-2],\n [-2],\n [-6],\n [9],\n [6]])\nb = np.array([\n [1],\n [7],\n [0],\n [3],\n [6],\n [-6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -\\frac{37}{5} & -\\frac{89}{10} \\\\\n \\frac{97}{10} & -\\frac{1}{2} \\\\\n 2 & \\frac{12}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(37/5), -(89/10)],\n [(97/10), -(1/2)],\n [2, (12/5)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{14}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{5}{\\sqrt{74}} \\\\\n \\frac{7}{\\sqrt{74}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [(14/5)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{2} & -\\frac{11}{2} & 6 \\\\\n \\frac{1}{2} & -\\frac{3}{2} & -3 \\\\\n 8 & \\frac{11}{2} & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.772,-0.27,1.\\}, \\{-1.262-0.085 i,0.501\\, +0.733 i,1.\\}, \\{-1.262+0.085 i,0.501\\, -0.733 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), -(11/2), 6],\n [(1/2), -(3/2), -3],\n [8, (11/2), (7/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{117}{16} \\\\\n \\frac{13}{4} \\\\\n \\frac{113}{16} \\\\\n \\frac{17}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{175}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(117/16)],\n [(13/4)],\n [(113/16)],\n [(17/4)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{2} & -\\frac{19}{2} \\\\\n -\\frac{7}{2} & \\frac{11}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{7} \\left(8-\\sqrt{197}\\right),1\\right\\}, \\left\\{\\frac{1}{7} \\left(8+\\sqrt{197}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), -(19/2)],\n [-(7/2), (11/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\sqrt{3} \\\\\n 2 \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n -4 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$84$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-2*math.sqrt(3)],\n [3*math.sqrt(3)],\n [-2*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [3*math.sqrt(3)],\n [3*math.sqrt(3)]])\nb = np.array([\n [math.sqrt(3)],\n [2*math.sqrt(3)],\n [math.sqrt(3)],\n [-4*math.sqrt(3)],\n [4*math.sqrt(3)],\n [-2*math.sqrt(3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{58}{7} \\\\\n -\\frac{17}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{47}{7} \\\\\n \\frac{27}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -15 \\\\\n -\\frac{44}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(58/7)],\n [-(17/7)]])\nb = np.array([\n [(47/7)],\n [(27/7)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -3 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 8 \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 66 \\\\\n 78 \\\\\n 18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-3],\n [-9]])\nb = np.array([\n [-10],\n [8],\n [2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 6 \\\\\n -5 \\\\\n -10 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{170}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [6],\n [-5],\n [-10],\n [0]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 5 & -9 & 1 \\\\\n 5 & 1 & -2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 9 & 4 & -4 \\\\\n 7 & -10 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -4 & -13 & 5 \\\\\n -2 & 11 & -10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -9, 1],\n [5, 1, -2]])\nb = np.array([\n [9, 4, -4],\n [7, -10, 8]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 8 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 7 \\\\\n -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -52 \\\\\n 51 \\\\\n 15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [8],\n [4]])\nb = np.array([\n [6],\n [7],\n [-3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{100}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 8 & 4 & -7 & -6 \\\\\n 10 & -9 & -9 & 0 \\\\\n -3 & 7 & -2 & 5 \\\\\n -6 & -1 & 9 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{6}{25} & \\frac{3}{25} & -\\frac{21}{100} & -\\frac{9}{50} \\\\\n \\frac{3}{10} & -\\frac{27}{100} & -\\frac{27}{100} & 0 \\\\\n -\\frac{9}{100} & \\frac{21}{100} & -\\frac{3}{50} & \\frac{3}{20} \\\\\n -\\frac{9}{50} & -\\frac{3}{100} & \\frac{27}{100} & \\frac{3}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 4, -7, -6],\n [10, -9, -9, 0],\n [-3, 7, -2, 5],\n [-6, -1, 9, 4]])\nprint(a * (3/100))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{4,-1,-\\frac{5}{3}\\right\\}, \\left\\{-\\frac{1}{3},-\\frac{1}{3},-4\\right\\}, \\left\\{-\\frac{4}{3},\\frac{2}{3},-\\frac{14}{3}\\right\\}}$.", - "Output Answer": [ - "$17 x-5 y-33 z-128=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, -1, -(5/3)],\n [-(1/3), -(1/3), -4],\n [-(4/3), (2/3), -(14/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 7 & 5 & 6 \\\\\n 5 & 5 & -5 \\\\\n -2 & -5 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+13 x^2-9 x-205$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 5, 6],\n [5, 5, -5],\n [-2, -5, 1]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 3 & 2 & 3 \\\\\n -2 & 2 & -1 \\\\\n 4 & 0 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{11} & \\frac{1}{11} & \\frac{4}{11} \\\\\n \\frac{1}{11} & \\frac{9}{22} & \\frac{3}{22} \\\\\n \\frac{4}{11} & -\\frac{4}{11} & -\\frac{5}{11} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2, 3],\n [-2, 2, -1],\n [4, 0, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 4+i & -2-i \\\\\n -3-4 i & 1+5 i \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -7+160 i & 66-92 i \\\\\n 224-118 i & -183-22 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4+ 1j, -2- 1j],\n [-3-4j, 1+5j]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 8 \\\\\n 5 \\\\\n -9 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -3 \\\\\n -1 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -6 \\\\\n 11 \\\\\n 6 \\\\\n -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [8],\n [5],\n [-9]])\nb = np.array([\n [-4],\n [-3],\n [-1],\n [-5]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{16}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -7 & -9 & -1 \\\\\n 2 & 10 & 9 \\\\\n 6 & -8 & -5 \\\\\n -8 & 9 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{21}{16} & -\\frac{27}{16} & -\\frac{3}{16} \\\\\n \\frac{3}{8} & \\frac{15}{8} & \\frac{27}{16} \\\\\n \\frac{9}{8} & -\\frac{3}{2} & -\\frac{15}{16} \\\\\n -\\frac{3}{2} & \\frac{27}{16} & -\\frac{15}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -9, -1],\n [2, 10, 9],\n [6, -8, -5],\n [-8, 9, -10]])\nprint(a * (3/16))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -9 & -10 & 6 & -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -5 & -7 & -6 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -14 & -17 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -10, 6, -6]])\nb = np.array([\n [-5, -7, -6, 6]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 0 & \\frac{16}{7} & 0 & \\frac{13}{7} & \\frac{1}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{18}{7} & 0 & -\\frac{18}{7} & -\\frac{5}{7} \\\\\n -\\frac{11}{7} & -\\frac{11}{7} & -\\frac{10}{7} & -\\frac{10}{7} \\\\\n \\frac{20}{7} & -\\frac{19}{7} & -\\frac{1}{7} & \\frac{1}{7} \\\\\n 1 & \\frac{17}{7} & -\\frac{3}{7} & 0 \\\\\n \\frac{3}{7} & 0 & \\frac{13}{7} & -\\frac{5}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{82}{49} & \\frac{45}{49} & -\\frac{186}{49} & -\\frac{165}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, (16/7), 0, (13/7), (1/7)]])\nb = np.array([\n [(18/7), 0, -(18/7), -(5/7)],\n [-(11/7), -(11/7), -(10/7), -(10/7)],\n [(20/7), -(19/7), -(1/7), (1/7)],\n [1, (17/7), -(3/7), 0],\n [(3/7), 0, (13/7), -(5/7)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 5 \\\\\n 0 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-16 x+64$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 5],\n [0, 8]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 9 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 5 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -15 \\\\\n 38 \\\\\n 47 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [9],\n [-6]])\nb = np.array([\n [-3],\n [5],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 9 \\\\\n -4 \\\\\n 4 \\\\\n -8 \\\\\n 1 \\\\\n 7 \\\\\n 1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 4 \\\\\n -5 \\\\\n 2 \\\\\n 0 \\\\\n -9 \\\\\n 7 \\\\\n 3 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{122}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [9],\n [-4],\n [4],\n [-8],\n [1],\n [7],\n [1],\n [-2]])\nb = np.array([\n [-10],\n [4],\n [-5],\n [2],\n [0],\n [-9],\n [7],\n [3],\n [-3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & 2 & 0 \\\\\n 3 & 3 & 3 \\\\\n 0 & -3 & 0 \\\\\n 1 & -1 & -2 \\\\\n 2 & 1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.82 \\\\\n -0.42 \\\\\n 1.13 \\\\\n -2.93 \\\\\n -2.63 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.059 \\\\\n -0.186 \\\\\n 0.671 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2, 0],\n [3, 3, 3],\n [0, -3, 0],\n [1, -1, -2],\n [2, 1, -1]])\nb = np.array([\n [2.82],\n [-0.42],\n [1.13],\n [-2.93],\n [-2.63]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -2 & \\frac{5}{2} & \\frac{37}{4} \\\\\n -\\frac{9}{2} & -\\frac{35}{4} & -\\frac{11}{2} \\\\\n \\frac{5}{4} & -1 & \\frac{27}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6.123-1.616 i,-6.123+1.616 i,8.246\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, (5/2), (37/4)],\n [-(9/2), -(35/4), -(11/2)],\n [(5/4), -1, (27/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 9 & 1 & 4 & -1 \\\\\n -1 & 10 & -9 & -8 \\\\\n 0 & 6 & -3 & -4 \\\\\n 9 & 5 & -4 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, 1, 4, -1],\n [-1, 10, -9, -8],\n [0, 6, -3, -4],\n [9, 5, -4, -8]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -9 & 7 & -1 & 5 \\\\\n 5 & 3 & 3 & 1 \\\\\n -8 & 10 & 1 & -10 \\\\\n -8 & -1 & 4 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, 7, -1, 5],\n [5, 3, 3, 1],\n [-8, 10, 1, -10],\n [-8, -1, 4, -8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{21}{5} & -\\frac{47}{5} \\\\\n -\\frac{29}{5} & -\\frac{28}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{58} \\left(-49-\\sqrt{7853}\\right),1\\right\\}, \\left\\{\\frac{1}{58} \\left(\\sqrt{7853}-49\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(21/5), -(47/5)],\n [-(29/5), -(28/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${1, -\\frac{19}{5}, 1}$ to the plane $\\frac{6 x}{5}+\\frac{21 y}{5}+3 z-\\frac{4}{5}=0$.", - "Output Answer": [ - "$\\frac{157 \\sqrt{\\frac{2}{39}}}{15}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 1, -(19/5), 1\nplane = Poly(((6*x)/5)+((21*y)/5)+3*z-(4/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{10}{\\sqrt{\\pi }} \\\\\n -\\frac{8}{\\sqrt{\\pi }} \\\\\n \\frac{14}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{17}{\\sqrt{\\pi }} \\\\\n \\frac{15}{\\sqrt{\\pi }} \\\\\n -\\frac{9}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{76}{\\pi }$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(10/(math.sqrt(math.pi)))],\n [-(8/(math.sqrt(math.pi)))],\n [(14/(math.sqrt(math.pi)))]])\nb = np.array([\n [(17/(math.sqrt(math.pi)))],\n [(15/(math.sqrt(math.pi)))],\n [-(9/(math.sqrt(math.pi)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n 46 & 56 & -22 & 65 \\\\\n 13 & 14 & -5 & 17 \\\\\n -36 & -45 & 18 & -51 \\\\\n -56 & -67 & 26 & -78 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{95}{2} & \\frac{113}{2} & -\\frac{133}{6} & \\frac{131}{2} \\\\\n 12 & 14 & -\\frac{14}{3} & 16 \\\\\n -60 & -\\frac{147}{2} & 30 & -84 \\\\\n -\\frac{127}{2} & -76 & \\frac{59}{2} & -\\frac{175}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [46, 56, -22, 65],\n [13, 14, -5, 17],\n [-36, -45, 18, -51],\n [-56, -67, 26, -78]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -6 & 1 & -3 & 2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 0 & -8 & -5 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -6 & 9 & 2 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 1, -3, 2]])\nb = np.array([\n [0, -8, -5, -4]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $1$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & -1 & -4 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & -1 & -4 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, -4, -5]])\nprint(a * 1)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -10 & -3 & 8 & 7 \\\\\n 3 & 1 & 10 & -9 \\\\\n -8 & -10 & -3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1366.,-971.,527.,933.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, -3, 8, 7],\n [3, 1, 10, -9],\n [-8, -10, -3, 3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 7 & -8 & 5 \\\\\n -8 & 0 & -1 \\\\\n -3 & 3 & 9 \\\\\n -7 & -2 & -7 \\\\\n -9 & -1 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, -8, 5],\n [-8, 0, -1],\n [-3, 3, 9],\n [-7, -2, -7],\n [-9, -1, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & 4 & -4 \\\\\n -5 & -9 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{3.,1.,4.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, 4, -4],\n [-5, -9, 6]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{4}{3} & -3 \\\\\n \\frac{8}{3} & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3), -3],\n [(8/3), -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n \\frac{3}{2} & \\frac{5}{2} & 2 & \\frac{5}{2} & \\frac{1}{2} \\\\\n \\frac{3}{2} & 0 & \\frac{5}{2} & -\\frac{1}{2} & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -\\frac{9}{4} & -\\frac{15}{4} & -3 & -\\frac{15}{4} & -\\frac{3}{4} \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), 0],\n [0, 0]])\nb = np.array([\n [(3/2), (5/2), 2, (5/2), (1/2)],\n [(3/2), 0, (5/2), -(1/2), -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{137}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [5]])\nb = np.array([\n [1],\n [9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $1$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -9 & -7 & -7 & 5 \\\\\n -8 & 4 & 5 & 4 \\\\\n 5 & 10 & 6 & -1 \\\\\n -10 & -9 & 3 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -9 & -7 & -7 & 5 \\\\\n -8 & 4 & 5 & 4 \\\\\n 5 & 10 & 6 & -1 \\\\\n -10 & -9 & 3 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -7, -7, 5],\n [-8, 4, 5, 4],\n [5, 10, 6, -1],\n [-10, -9, 3, 6]])\nprint(a * 1)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{32}{5} & -\\frac{12}{5} \\\\\n -\\frac{38}{5} & \\frac{33}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(1-\\sqrt{6049}\\right),\\frac{1}{10} \\left(1+\\sqrt{6049}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(32/5), -(12/5)],\n [-(38/5), (33/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -6 & -4 & -8 & 10 & -5 & -6 & 3 \\\\\n 7 & -2 & 9 & -4 & -6 & -5 & 9 \\\\\n -5 & 9 & -7 & 0 & 5 & -7 & -5 \\\\\n 2 & -10 & 7 & 10 & 10 & 10 & 7 \\\\\n 7 & -1 & -3 & -9 & -8 & -2 & 3 \\\\\n 9 & -6 & 6 & -9 & 10 & 0 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & \\frac{1541707}{1798334} \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & -\\frac{513069}{899167} \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & \\frac{102726}{899167} \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & \\frac{662467}{1798334} \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & \\frac{134032}{899167} \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & -\\frac{1149993}{1798334} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-6, -4, -8, 10, -5, -6, 3],\n [7, -2, 9, -4, -6, -5, 9],\n [-5, 9, -7, 0, 5, -7, -5],\n [2, -10, 7, 10, 10, 10, 7],\n [7, -1, -3, -9, -8, -2, 3],\n [9, -6, 6, -9, 10, 0, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -5 & -2 & -10 \\\\\n 4 & -6 & -6 \\\\\n 0 & 5 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, -2, -10],\n [4, -6, -6],\n [0, 5, -6]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 0 & -\\frac{9}{2} \\\\\n 3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{2}{9} & \\frac{1}{3} \\\\\n -\\frac{2}{9} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -(9/2)],\n [3, 3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 7 & 4 & 0 & -8 \\\\\n 0 & 8 & -3 & -3 \\\\\n -8 & -2 & 1 & 6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -1 & -8 & 2 & 10 \\\\\n -2 & 8 & -9 & 4 \\\\\n -7 & -8 & -9 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 8 & 12 & -2 & -18 \\\\\n 2 & 0 & 6 & -7 \\\\\n -1 & 6 & 10 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 4, 0, -8],\n [0, 8, -3, -3],\n [-8, -2, 1, 6]])\nb = np.array([\n [-1, -8, 2, 10],\n [-2, 8, -9, 4],\n [-7, -8, -9, 1]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,-5,3\\}, \\{4,0,-3\\}, \\{-5,2,-4\\}}$.", - "Output Answer": [ - "$7 x+55 y+47 z+113=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, -5, 3],\n [4, 0, -3],\n [-5, 2, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n \\frac{49}{8} \\\\\n \\frac{23}{8} \\\\\n -6 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(49/8)],\n [(23/8)],\n [-6],\n [-3]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{37}{16} \\\\\n -\\frac{9}{8} \\\\\n -\\frac{5}{16} \\\\\n -\\frac{19}{4} \\\\\n \\frac{63}{16} \\\\\n -\\frac{105}{16} \\\\\n \\frac{5}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{309}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/16)],\n [-(9/8)],\n [-(5/16)],\n [-(19/4)],\n [(63/16)],\n [-(105/16)],\n [(5/16)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $4$ and the matrix\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -5 \\\\\n 9 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -20 \\\\\n 36 \\\\\n -24 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-5],\n [9],\n [-6]])\nprint(a * 4)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${5, -1, 3}$ to the plane $-2 x-y-5 z-4=0$.", - "Output Answer": [ - "$14 \\sqrt{\\frac{2}{15}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 5, -1, 3\nplane = Poly(-2*x-y-5*z-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{23}{5} \\\\\n -\\frac{48}{5} \\\\\n -\\frac{16}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -\\frac{33}{5} \\\\\n \\frac{12}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{694}{\\sqrt{732093}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/5)],\n [-(48/5)],\n [-(16/5)]]).squeeze()\nb = np.array([\n [6],\n [-(33/5)],\n [(12/5)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 10 & -9 \\\\\n 3 & -\\frac{22}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{3} \\left(4-\\sqrt{433}\\right),\\frac{1}{3} \\left(4+\\sqrt{433}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -9],\n [3, -(22/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{16}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 3 & -2 & -9 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{21}{16} & -\\frac{7}{8} & -\\frac{63}{16} & -\\frac{7}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2, -9, -1]])\nprint(a * (7/16))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & -1 \\\\\n 8 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-1-2 \\sqrt{14},2 \\sqrt{14}-1\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -1],\n [8, -9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 10 & -2 \\\\\n 2 & -2 \\\\\n 7 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [10, -2],\n [2, -2],\n [7, -1]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 6 & 3 \\\\\n 10 & 8 \\\\\n -8 & 10 \\\\\n -2 & -9 \\\\\n 6 & -1 \\\\\n 1 & -1 \\\\\n 7 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, 3],\n [10, 8],\n [-8, 10],\n [-2, -9],\n [6, -1],\n [1, -1],\n [7, -10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{32}{5} & -\\frac{44}{5} & 0 \\\\\n \\frac{27}{5} & -\\frac{16}{5} & \\frac{4}{5} \\\\\n -6 & \\frac{26}{5} & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8.153,1.677\\, -4.67 i,1.677\\, +4.67 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(32/5), -(44/5), 0],\n [(27/5), -(16/5), (4/5)],\n [-6, (26/5), -8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [8]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{5} & -\\frac{18}{5} & 0 \\\\\n \\frac{44}{5} & 1 & -\\frac{4}{5} \\\\\n -\\frac{47}{5} & \\frac{49}{5} & 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{49}{5} & -\\frac{46}{5} & -2 \\\\\n \\frac{41}{5} & -\\frac{12}{5} & 3 \\\\\n -\\frac{18}{5} & -\\frac{39}{5} & -\\frac{43}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 10 & -\\frac{64}{5} & -2 \\\\\n 17 & -\\frac{7}{5} & \\frac{11}{5} \\\\\n -13 & 2 & -\\frac{18}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/5), -(18/5), 0],\n [(44/5), 1, -(4/5)],\n [-(47/5), (49/5), 5]])\nb = np.array([\n [(49/5), -(46/5), -2],\n [(41/5), -(12/5), 3],\n [-(18/5), -(39/5), -(43/5)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 3 & 0 & -6 \\\\\n 2 & -4 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{2.,0.,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, 0, -6],\n [2, -4, -4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{4}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -4 & 9 & -9 & -6 \\\\\n -9 & 3 & 7 & -7 \\\\\n -7 & -9 & 10 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -1 & \\frac{9}{4} & -\\frac{9}{4} & -\\frac{3}{2} \\\\\n -\\frac{9}{4} & \\frac{3}{4} & \\frac{7}{4} & -\\frac{7}{4} \\\\\n -\\frac{7}{4} & -\\frac{9}{4} & \\frac{5}{2} & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 9, -9, -6],\n [-9, 3, 7, -7],\n [-7, -9, 10, -8]])\nprint(a * (1/4))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 9 & -1 & -6 \\\\\n -1 & 1 & -3 \\\\\n -8 & 7 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.392,-0.132,1.\\}, \\{0.547\\, -0.322 i,0.181\\, -0.9 i,1.\\}, \\{0.547\\, +0.322 i,0.181\\, +0.9 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -1, -6],\n [-1, 1, -3],\n [-8, 7, 3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{3} \\\\\n -3 \\\\\n \\frac{56}{9} \\\\\n \\frac{25}{9} \\\\\n -2 \\\\\n -\\frac{40}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{56}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/3)],\n [-3],\n [(56/9)],\n [(25/9)],\n [-2],\n [-(40/9)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{2} & \\frac{27}{5} \\\\\n 1 & \\frac{57}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{11 x}{5}-\\frac{507}{20}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), (27/5)],\n [1, (57/10)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{19}{3} \\\\\n 1 \\\\\n \\frac{17}{2} \\\\\n \\frac{53}{6} \\\\\n \\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{79}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/3)],\n [1],\n [(17/2)],\n [(53/6)],\n [(5/3)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -2 & 6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 0 & -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -2 & 16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 6]])\nb = np.array([\n [0, -10]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -2 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -5 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 40 \\\\\n -74 \\\\\n 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-2],\n [6]])\nb = np.array([\n [-9],\n [-5],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{7} \\\\\n \\frac{3}{7} \\\\\n \\frac{4}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{19}{\\sqrt{386}} \\\\\n \\frac{3}{\\sqrt{386}} \\\\\n 2 \\sqrt{\\frac{2}{193}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/7)],\n [(3/7)],\n [(4/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{3} & -\\frac{14}{3} & \\frac{4}{3} \\\\\n 3 & -\\frac{10}{3} & -\\frac{1}{3} \\\\\n 4 & -1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{61}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/3), -(14/3), (4/3)],\n [3, -(10/3), -(1/3)],\n [4, -1, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & 3 \\\\\n -3 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-1-2 \\sqrt{10},2 \\sqrt{10}-1\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 3],\n [-3, -8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{27}{5} \\\\\n \\frac{49}{5} \\\\\n -\\frac{49}{5} \\\\\n -\\frac{12}{5} \\\\\n 2 \\\\\n \\frac{32}{5} \\\\\n -\\frac{1}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{5} \\\\\n 9 \\\\\n \\frac{7}{5} \\\\\n -\\frac{47}{5} \\\\\n -\\frac{4}{5} \\\\\n -\\frac{16}{5} \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1838}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(27/5)],\n [(49/5)],\n [-(49/5)],\n [-(12/5)],\n [2],\n [(32/5)],\n [-(1/5)]])\nb = np.array([\n [-(3/5)],\n [9],\n [(7/5)],\n [-(47/5)],\n [-(4/5)],\n [-(16/5)],\n [-9]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & -6 \\\\\n -2 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} \\left(-17-\\sqrt{337}\\right),1\\right\\}, \\left\\{\\frac{1}{4} \\left(\\sqrt{337}-17\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -6],\n [-2, -8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-1,-1,2\\}, \\{0,1,-1\\}, \\{1,1,0\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{6}},-\\frac{1}{\\sqrt{6}},\\sqrt{\\frac{2}{3}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{2}},\\frac{1}{\\sqrt{2}},0\\right\\}, \\left\\{\\frac{1}{\\sqrt{3}},\\frac{1}{\\sqrt{3}},\\frac{1}{\\sqrt{3}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, -1, 2), (0, 1, -1), (1, 1, 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -1 & 7 \\\\\n 10 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-1, 7],\n [10, 7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -10 & 10 & 3 & 10 & -9 & 1 \\\\\n -5 & 10 & 10 & -5 & -7 & -2 \\\\\n 9 & 10 & -8 & -1 & -4 & -5 \\\\\n 9 & 2 & -1 & -8 & -3 & 10 \\\\\n 0 & 9 & 6 & -2 & -10 & -8 \\\\\n 0 & 8 & -5 & 1 & -9 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, 10, 3, 10, -9, 1],\n [-5, 10, 10, -5, -7, -2],\n [9, 10, -8, -1, -4, -5],\n [9, 2, -1, -8, -3, 10],\n [0, 9, 6, -2, -10, -8],\n [0, 8, -5, 1, -9, -3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 5 & 9 & 2 & -6 \\\\\n -5 & -5 & -1 & -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -10 & -3 & 8 & 1 \\\\\n -6 & 0 & -4 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -5 & 6 & 10 & -5 \\\\\n -11 & -5 & -5 & -11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 9, 2, -6],\n [-5, -5, -1, -6]])\nb = np.array([\n [-10, -3, 8, 1],\n [-6, 0, -4, -5]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{10}{7} & \\frac{46}{7} & -\\frac{9}{7} & \\frac{18}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{17}{7} & -\\frac{44}{7} & -\\frac{31}{7} & -\\frac{57}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{27}{7} & \\frac{90}{7} & \\frac{22}{7} & \\frac{75}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(10/7), (46/7), -(9/7), (18/7)]])\nb = np.array([\n [-(17/7), -(44/7), -(31/7), -(57/7)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -1 & -3 \\\\\n 2 & 2 & 1 \\\\\n 2 & -2 & 2 \\\\\n 1 & -2 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.43 \\\\\n -2.01 \\\\\n -1.62 \\\\\n -2.32 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.921 \\\\\n 0.103 \\\\\n -0.17 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, -3],\n [2, 2, 1],\n [2, -2, 2],\n [1, -2, 1]])\nb = np.array([\n [1.43],\n [-2.01],\n [-1.62],\n [-2.32]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{8}{3} \\\\\n -\\frac{26}{3} \\\\\n -\\frac{25}{3} \\\\\n \\frac{2}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{10}{3} \\\\\n -9 \\\\\n \\frac{22}{3} \\\\\n -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{2}{3} \\\\\n \\frac{1}{3} \\\\\n -\\frac{47}{3} \\\\\n 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/3)],\n [-(26/3)],\n [-(25/3)],\n [(2/3)]])\nb = np.array([\n [-(10/3)],\n [-9],\n [(22/3)],\n [-(7/3)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -7 & 2 & -2 & 2 \\\\\n -4 & 4 & 6 & -8 \\\\\n 10 & -8 & 8 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 4 & -5 & 2 & 7 \\\\\n -7 & -3 & 0 & -8 \\\\\n -1 & 6 & 3 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -3 & -3 & 0 & 9 \\\\\n -11 & 1 & 6 & -16 \\\\\n 9 & -2 & 11 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 2, -2, 2],\n [-4, 4, 6, -8],\n [10, -8, 8, 8]])\nb = np.array([\n [4, -5, 2, 7],\n [-7, -3, 0, -8],\n [-1, 6, 3, -7]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n 0 & 0 \\\\\n 1 & -2 \\\\\n -3 & -9 \\\\\n -5 & -8 \\\\\n -7 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0],\n [1, -2],\n [-3, -9],\n [-5, -8],\n [-7, 3]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,-5,-1\\}, \\{3,4,-2\\}, \\{-2,5,-2\\}}$.", - "Output Answer": [ - "$x+5 y+49 z+75=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, -5, -1],\n [3, 4, -2],\n [-2, 5, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 5 \\\\\n 4 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-17$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 5],\n [4, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{136}{25} \\\\\n -\\frac{199}{25} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{931}{100} \\\\\n \\frac{41}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{59}{4} \\\\\n -\\frac{48}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(136/25)],\n [-(199/25)]])\nb = np.array([\n [-(931/100)],\n [(41/25)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{2} & -5 & -1 \\\\\n 7 & -\\frac{17}{2} & -10 \\\\\n 3 & 4 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1.351,-0.038,1.\\}, \\{-0.568-0.346 i,-0.811-1.415 i,1.\\}, \\{-0.568+0.346 i,-0.811+1.415 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2), -5, -1],\n [7, -(17/2), -10],\n [3, 4, 2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{5}{3}, \\frac{10}{3}}$ to the line $-\\frac{8 x}{3}-\\frac{14 y}{3}+\\frac{8}{3}=0$.", - "Output Answer": [ - "$2 \\sqrt{\\frac{13}{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (5/3), (10/3)\nline = Poly(-((8*x)/3)-((14*y)/3)+(8/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{33}{7}, -\\frac{1}{7}}$ to the line $-\\frac{10 x}{7}-\\frac{13 y}{7}-\\frac{6}{7}=0$.", - "Output Answer": [ - "$\\frac{359}{7 \\sqrt{269}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (33/7), -(1/7)\nline = Poly(-((10*x)/7)-((13*y)/7)-(6/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{13}{100}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -10 & -10 & 3 & 1 \\\\\n 9 & 8 & -10 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{13}{10} & -\\frac{13}{10} & \\frac{39}{100} & \\frac{13}{100} \\\\\n \\frac{117}{100} & \\frac{26}{25} & -\\frac{13}{10} & -\\frac{39}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -10, 3, 1],\n [9, 8, -10, -3]])\nprint(a * (13/100))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 6 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -9 \\\\\n 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 4 \\\\\n -3 \\\\\n 18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [6],\n [8]])\nb = np.array([\n [-1],\n [-9],\n [10]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{33}{8} & 3 \\\\\n -\\frac{11}{2} & -\\frac{25}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{29 x}{4}+\\frac{1881}{64}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(33/8), 3],\n [-(11/2), -(25/8)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -4 & -8 & 9 & 6 \\\\\n 9 & 7 & -5 & -2 \\\\\n 2 & -7 & 6 & 3 \\\\\n 2 & 3 & -4 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -8, 9, 6],\n [9, 7, -5, -2],\n [2, -7, 6, 3],\n [2, 3, -4, -4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,-1,2\\}, \\{5,0,1\\}, \\{0,-5,-4\\}}$.", - "Output Answer": [ - "$x-4 y+3 z-8=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, -1, 2],\n [5, 0, 1],\n [0, -5, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, 1, -\\frac{7}{2}}$ to the plane $-\\frac{9 x}{2}-\\frac{3 y}{2}+5 z+\\frac{9}{2}=0$.", - "Output Answer": [ - "$\\sqrt{\\frac{2}{95}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, 1, -(7/2)\nplane = Poly(-((9*x)/2)-((3*y)/2)+5*z+(9/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -6 & 0 & 6 & -8 & -5 & -10 & -7 \\\\\n 3 & 0 & 3 & 0 & -8 & -4 & -3 \\\\\n 5 & -5 & -8 & -10 & -8 & 7 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & \\frac{2}{3} & -\\frac{11}{12} & \\frac{1}{6} & \\frac{1}{12} \\\\\n 0 & 1 & 0 & \\frac{56}{15} & \\frac{209}{60} & \\frac{7}{6} & \\frac{73}{60} \\\\\n 0 & 0 & 1 & -\\frac{2}{3} & -\\frac{7}{4} & -\\frac{3}{2} & -\\frac{13}{12} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-6, 0, 6, -8, -5, -10, -7],\n [3, 0, 3, 0, -8, -4, -3],\n [5, -5, -8, -10, -8, 7, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -3 & -1 \\\\\n -3 & 4 \\\\\n 1 & -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 6 & 1 \\\\\n 7 & 3 \\\\\n 1 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 3 & 0 \\\\\n 4 & 7 \\\\\n 2 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1],\n [-3, 4],\n [1, -7]])\nb = np.array([\n [6, 1],\n [7, 3],\n [1, 4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{8} \\\\\n -\\frac{71}{8} \\\\\n \\frac{17}{4} \\\\\n \\frac{31}{8} \\\\\n -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{9935}}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/8)],\n [-(71/8)],\n [(17/4)],\n [(31/8)],\n [-(11/2)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 3 & 3 & 1 & 1 \\\\\n 0 & -3 & 0 & 0 \\\\\n -2 & 0 & -3 & 2 \\\\\n 1 & 3 & 2 & 0 \\\\\n -2 & 0 & 1 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.57 \\\\\n 1.73 \\\\\n 1.74 \\\\\n -2.26 \\\\\n -1.01 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.318 \\\\\n -0.582 \\\\\n -0.397 \\\\\n 0.598 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3, 1, 1],\n [0, -3, 0, 0],\n [-2, 0, -3, 2],\n [1, 3, 2, 0],\n [-2, 0, 1, 0]])\nb = np.array([\n [-0.57],\n [1.73],\n [1.74],\n [-2.26],\n [-1.01]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n \\frac{89}{10} & -\\frac{24}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(89/10), -(24/5)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{16}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -2 \\\\\n 8 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{9}{16} \\\\\n -\\frac{3}{8} \\\\\n \\frac{3}{2} \\\\\n \\frac{27}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-2],\n [8],\n [9]])\nprint(a * (3/16))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 0 & 9 & 4 \\\\\n 0 & -3 & 3 \\\\\n 4 & 6 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-4.926-1.546 i,-4.926+1.546 i,5.852\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 9, 4],\n [0, -3, 3],\n [4, 6, -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, -1, -2}$ to the plane $3 x+3 y-2 z-2=0$.", - "Output Answer": [ - "$5 \\sqrt{\\frac{2}{11}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, -1, -2\nplane = Poly(3*x+3*y-2*z-2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -3 & 0 & 0 & 3 \\\\\n -1 & 0 & 3 & 1 \\\\\n 0 & 0 & -2 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -3 & -3 & -1 & 0 \\\\\n 2 & -1 & 2 & -1 \\\\\n 2 & 2 & -3 & -2 \\\\\n 3 & -2 & 3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 18 & 3 & 12 & 0 \\\\\n 12 & 7 & -5 & -6 \\\\\n 2 & -8 & 12 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, 0, 3],\n [-1, 0, 3, 1],\n [0, 0, -2, 2]])\nb = np.array([\n [-3, -3, -1, 0],\n [2, -1, 2, -1],\n [2, 2, -3, -2],\n [3, -2, 3, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 2 & -2 & \\frac{4}{3} & \\frac{1}{3} & -\\frac{1}{3} \\\\\n \\frac{5}{3} & \\frac{8}{3} & 1 & -2 & -\\frac{5}{3} \\\\\n -\\frac{5}{3} & -2 & -\\frac{1}{3} & -1 & \\frac{2}{3} \\\\\n \\frac{2}{3} & \\frac{2}{3} & -\\frac{4}{3} & \\frac{4}{3} & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{3} & -\\frac{4}{3} & -\\frac{5}{3} \\\\\n 1 & -2 & \\frac{4}{3} \\\\\n 0 & 1 & \\frac{4}{3} \\\\\n -\\frac{7}{3} & 0 & -\\frac{5}{3} \\\\\n -1 & -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{52}{9} & 3 & -\\frac{49}{9} \\\\\n \\frac{56}{9} & -\\frac{44}{9} & \\frac{19}{9} \\\\\n \\frac{22}{9} & \\frac{47}{9} & \\frac{8}{3} \\\\\n -\\frac{38}{9} & -\\frac{38}{9} & -\\frac{26}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2, (4/3), (1/3), -(1/3)],\n [(5/3), (8/3), 1, -2, -(5/3)],\n [-(5/3), -2, -(1/3), -1, (2/3)],\n [(2/3), (2/3), -(4/3), (4/3), (2/3)]])\nb = np.array([\n [-(5/3), -(4/3), -(5/3)],\n [1, -2, (4/3)],\n [0, 1, (4/3)],\n [-(7/3), 0, -(5/3)],\n [-1, -1, 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 3 \\\\\n 2 \\\\\n 3 \\\\\n -2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 2 \\\\\n -2 \\\\\n -2 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{5}{4},-\\frac{5}{4},\\frac{5}{4},\\frac{5}{4},0,0\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [3],\n [2],\n [3],\n [-2],\n [-1]]).squeeze()\nb = np.array([\n [-2],\n [2],\n [-2],\n [-2],\n [0],\n [0]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 5 & -5 \\\\\n 2 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{2}{15} & \\frac{1}{6} \\\\\n -\\frac{1}{15} & \\frac{1}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -5],\n [2, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,-2,2\\}, \\{2,-1,2\\}, \\{-1,-1,2\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}},\\frac{1}{\\sqrt{3}}\\right\\}, \\left\\{\\frac{7}{\\sqrt{78}},-\\sqrt{\\frac{2}{39}},\\frac{5}{\\sqrt{78}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{26}},2 \\sqrt{\\frac{2}{13}},\\frac{3}{\\sqrt{26}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, -2, 2), (2, -1, 2), (-1, -1, 2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{2} & \\frac{13}{2} & -\\frac{7}{2} \\\\\n \\frac{15}{2} & -\\frac{25}{4} & -3 \\\\\n \\frac{17}{2} & \\frac{1}{2} & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.037,5.564,1.\\}, \\{0.278\\, -0.62 i,0.059\\, -0.317 i,1.\\}, \\{0.278\\, +0.62 i,0.059\\, +0.317 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2), (13/2), -(7/2)],\n [(15/2), -(25/4), -3],\n [(17/2), (1/2), 5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{55}{7} & -\\frac{5}{7} & \\frac{10}{7} & \\frac{61}{7} & \\frac{1}{7} \\\\\n -\\frac{15}{7} & \\frac{4}{7} & \\frac{13}{7} & -\\frac{58}{7} & \\frac{45}{7} \\\\\n \\frac{15}{7} & \\frac{12}{7} & \\frac{30}{7} & \\frac{4}{7} & \\frac{52}{7} \\\\\n -\\frac{11}{7} & -6 & -\\frac{51}{7} & \\frac{67}{7} & -\\frac{54}{7} \\\\\n -\\frac{17}{7} & \\frac{40}{7} & \\frac{41}{7} & 8 & -\\frac{9}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(55/7), -(5/7), (10/7), (61/7), (1/7)],\n [-(15/7), (4/7), (13/7), -(58/7), (45/7)],\n [(15/7), (12/7), (30/7), (4/7), (52/7)],\n [-(11/7), -6, -(51/7), (67/7), -(54/7)],\n [-(17/7), (40/7), (41/7), 8, -(9/7)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{3} & -\\frac{7}{3} & -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{4}{3} & 2 & -2 \\\\\n \\frac{1}{3} & -\\frac{1}{3} & -\\frac{7}{3} \\\\\n -1 & -\\frac{5}{3} & \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{10}{9} & \\frac{16}{3} & \\frac{5}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/3), -(7/3), -(7/3)]])\nb = np.array([\n [-(4/3), 2, -2],\n [(1/3), -(1/3), -(7/3)],\n [-1, -(5/3), (4/3)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 5 & -6 \\\\\n -5 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-3 x-40$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -6],\n [-5, -2]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{4}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -2 & -5 \\\\\n 3 & 4 & -6 \\\\\n 8 & 0 & -7 \\\\\n 0 & -8 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{5}{4} & -\\frac{5}{2} & -\\frac{25}{4} \\\\\n \\frac{15}{4} & 5 & -\\frac{15}{2} \\\\\n 10 & 0 & -\\frac{35}{4} \\\\\n 0 & -10 & -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2, -5],\n [3, 4, -6],\n [8, 0, -7],\n [0, -8, -6]])\nprint(a * (5/4))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{3}{8} & \\frac{17}{8} & \\frac{1}{4} & -\\frac{3}{8} & -\\frac{3}{2} \\\\\n -\\frac{3}{4} & -\\frac{13}{8} & \\frac{7}{8} & -\\frac{7}{4} & -\\frac{5}{8} \\\\\n -\\frac{11}{8} & \\frac{1}{8} & \\frac{21}{8} & \\frac{7}{4} & 2 \\\\\n \\frac{1}{8} & \\frac{7}{4} & \\frac{17}{8} & \\frac{23}{8} & \\frac{13}{8} \\\\\n \\frac{21}{8} & -\\frac{13}{8} & \\frac{1}{4} & \\frac{9}{8} & -\\frac{15}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{11}{4} & -\\frac{23}{8} & \\frac{21}{8} \\\\\n \\frac{5}{4} & -2 & -\\frac{1}{2} \\\\\n -\\frac{17}{8} & -\\frac{5}{8} & -\\frac{3}{4} \\\\\n \\frac{3}{8} & -\\frac{3}{2} & \\frac{5}{8} \\\\\n \\frac{3}{8} & \\frac{1}{8} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{25}{64} & -\\frac{189}{64} & -\\frac{55}{32} \\\\\n -\\frac{219}{32} & \\frac{237}{32} & -\\frac{83}{32} \\\\\n -\\frac{499}{64} & -\\frac{5}{16} & -\\frac{355}{64} \\\\\n -\\frac{19}{64} & -\\frac{595}{64} & -\\frac{37}{32} \\\\\n \\frac{35}{8} & -\\frac{51}{8} & \\frac{293}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/8), (17/8), (1/4), -(3/8), -(3/2)],\n [-(3/4), -(13/8), (7/8), -(7/4), -(5/8)],\n [-(11/8), (1/8), (21/8), (7/4), 2],\n [(1/8), (7/4), (17/8), (23/8), (13/8)],\n [(21/8), -(13/8), (1/4), (9/8), -(15/8)]])\nb = np.array([\n [(11/4), -(23/8), (21/8)],\n [(5/4), -2, -(1/2)],\n [-(17/8), -(5/8), -(3/4)],\n [(3/8), -(3/2), (5/8)],\n [(3/8), (1/8), -(1/2)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{4}{3},\\frac{1}{3},3\\right\\}, \\left\\{3,\\frac{11}{3},-\\frac{8}{3}\\right\\}, \\left\\{\\frac{13}{3},\\frac{1}{3},-1\\right\\}}$.", - "Output Answer": [ - "$360 x+399 y+510 z-1183=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(4/3), (1/3), 3],\n [3, (11/3), -(8/3)],\n [(13/3), (1/3), -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{70}{9} \\\\\n \\frac{16}{3} \\\\\n \\frac{5}{3} \\\\\n \\frac{26}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{13513}}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(70/9)],\n [(16/3)],\n [(5/3)],\n [(26/3)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{20}{7} & \\frac{5}{7} & -\\frac{4}{7} & -\\frac{2}{7} \\\\\n -\\frac{1}{7} & -\\frac{18}{7} & -\\frac{6}{7} & \\frac{2}{7} \\\\\n -\\frac{8}{7} & 0 & \\frac{20}{7} & -\\frac{20}{7} \\\\\n -\\frac{2}{7} & \\frac{12}{7} & \\frac{8}{7} & -\\frac{16}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n \\frac{9}{7} & -\\frac{19}{7} & -\\frac{18}{7} & -\\frac{17}{7} & \\frac{1}{7} \\\\\n \\frac{16}{7} & 1 & \\frac{6}{7} & -2 & \\frac{20}{7} \\\\\n \\frac{3}{7} & -\\frac{8}{7} & \\frac{6}{7} & -\\frac{16}{7} & \\frac{11}{7} \\\\\n \\frac{20}{7} & \\frac{12}{7} & -\\frac{15}{7} & -\\frac{2}{7} & -\\frac{18}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -\\frac{152}{49} & \\frac{423}{49} & \\frac{396}{49} & \\frac{338}{49} & \\frac{72}{49} \\\\\n -\\frac{275}{49} & -\\frac{5}{7} & -\\frac{156}{49} & \\frac{361}{49} & -\\frac{463}{49} \\\\\n -\\frac{412}{49} & -\\frac{248}{49} & \\frac{564}{49} & -\\frac{144}{49} & \\frac{572}{49} \\\\\n -\\frac{122}{49} & -\\frac{134}{49} & \\frac{396}{49} & -\\frac{230}{49} & \\frac{614}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/7), (5/7), -(4/7), -(2/7)],\n [-(1/7), -(18/7), -(6/7), (2/7)],\n [-(8/7), 0, (20/7), -(20/7)],\n [-(2/7), (12/7), (8/7), -(16/7)]])\nb = np.array([\n [(9/7), -(19/7), -(18/7), -(17/7), (1/7)],\n [(16/7), 1, (6/7), -2, (20/7)],\n [(3/7), -(8/7), (6/7), -(16/7), (11/7)],\n [(20/7), (12/7), -(15/7), -(2/7), -(18/7)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{e} \\\\\n \\frac{22}{e} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{4}{e} \\\\\n \\frac{21}{e} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{530}}{e}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(19/math.e)],\n [(22/math.e)]])\nb = np.array([\n [(4/math.e)],\n [(21/math.e)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -3 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 5]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -1 & 0 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 3 & 0 & 1 & -1 & 1 \\\\\n -2 & 2 & -1 & 3 & 0 \\\\\n -2 & 0 & 3 & 0 & -2 \\\\\n -2 & -1 & -2 & -2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -5 & -2 & -8 & -3 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, -1, 2]])\nb = np.array([\n [3, 0, 1, -1, 1],\n [-2, 2, -1, 3, 0],\n [-2, 0, 3, 0, -2],\n [-2, -1, -2, -2, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -\\frac{6}{5} \\\\\n \\frac{4}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{5}{\\sqrt{38}} \\\\\n -\\frac{3}{\\sqrt{38}} \\\\\n \\sqrt{\\frac{2}{19}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-(6/5)],\n [(4/5)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 8 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [8],\n [9]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & -7 & 7 \\\\\n -2 & 4 & -1 \\\\\n -7 & 6 & 9 \\\\\n -9 & 3 & -10 \\\\\n 4 & -6 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, -7, 7],\n [-2, 4, -1],\n [-7, 6, 9],\n [-9, 3, -10],\n [4, -6, -10]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 1 & -3 & -8 & -10 \\\\\n 1 & -5 & 3 & -8 \\\\\n -9 & -3 & 2 & -5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 6 & 6 & -7 & -5 \\\\\n 10 & 9 & 2 & -2 \\\\\n -9 & -10 & -3 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -5 & -9 & -1 & -5 \\\\\n -9 & -14 & 1 & -6 \\\\\n 0 & 7 & 5 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3, -8, -10],\n [1, -5, 3, -8],\n [-9, -3, 2, -5]])\nb = np.array([\n [6, 6, -7, -5],\n [10, 9, 2, -2],\n [-9, -10, -3, 0]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -2 & 2 & -1 \\\\\n 1 & 0 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -2 & 1 \\\\\n 1 & -3 \\\\\n -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 7 & -10 \\\\\n -2 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2, -1],\n [1, 0, 0]])\nb = np.array([\n [-2, 1],\n [1, -3],\n [-1, 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{28}{3} & 9 \\\\\n -4 & \\frac{22}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} \\left(-1-i \\sqrt{35}\\right),1\\right\\}, \\left\\{\\frac{1}{4} \\left(-1+i \\sqrt{35}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(28/3), 9],\n [-4, (22/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -2 & 3 \\\\\n 4 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{4} & \\frac{3}{8} \\\\\n \\frac{1}{2} & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 3],\n [4, -2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{10}{3} & \\frac{2}{3} \\\\\n -\\frac{4}{3} & \\frac{13}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{122}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(10/3), (2/3)],\n [-(4/3), (13/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 9 & 9 \\\\\n -10 & -10 \\\\\n -8 & 9 \\\\\n 4 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, 9],\n [-10, -10],\n [-8, 9],\n [4, -9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & -3 \\\\\n -1 & 3 \\\\\n -3 & -2 \\\\\n -2 & 2 \\\\\n 2 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.74 \\\\\n -0.72 \\\\\n 0.21 \\\\\n 2.57 \\\\\n 1.96 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.182 \\\\\n -0.204 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -3],\n [-1, 3],\n [-3, -2],\n [-2, 2],\n [2, 0]])\nb = np.array([\n [2.74],\n [-0.72],\n [0.21],\n [2.57],\n [1.96]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{19}{6} & -\\frac{7}{2} \\\\\n -\\frac{5}{2} & \\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{581}{36}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/6), -(7/2)],\n [-(5/2), (7/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\sqrt{5} \\\\\n -3 \\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n -2 \\sqrt{5} \\\\\n \\sqrt{5} \\\\\n \\sqrt{5} \\\\\n 3 \\sqrt{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\sqrt{5} \\\\\n -\\sqrt{5} \\\\\n -3 \\sqrt{5} \\\\\n -4 \\sqrt{5} \\\\\n -\\sqrt{5} \\\\\n 3 \\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{14}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-math.sqrt(5)],\n [-3*math.sqrt(5)],\n [4*math.sqrt(5)],\n [-2*math.sqrt(5)],\n [math.sqrt(5)],\n [math.sqrt(5)],\n [3*math.sqrt(5)]])\nb = np.array([\n [-3*math.sqrt(5)],\n [-math.sqrt(5)],\n [-3*math.sqrt(5)],\n [-4*math.sqrt(5)],\n [-math.sqrt(5)],\n [3*math.sqrt(5)],\n [4*math.sqrt(5)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -8 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 8 \\\\\n 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -72 \\\\\n 0 \\\\\n -16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-8],\n [9]])\nb = np.array([\n [0],\n [8],\n [0]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -3 & 0 \\\\\n -4 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+5 x+6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0],\n [-4, -2]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & 1 & 3 \\\\\n \\frac{1}{2} & -\\frac{5}{2} & -1 \\\\\n -\\frac{5}{2} & -3 & \\frac{3}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -6 & -\\frac{21}{2} & \\frac{13}{2} \\\\\n \\frac{7}{4} & \\frac{39}{4} & \\frac{5}{2} \\\\\n -\\frac{31}{4} & \\frac{1}{2} & -\\frac{9}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1, 3],\n [(1/2), -(5/2), -1],\n [-(5/2), -3, (3/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{3}{5}, -\\frac{2}{5}}$ to the line $\\frac{9 x}{5}+\\frac{24 y}{5}+\\frac{13}{5}=0$.", - "Output Answer": [ - "$\\frac{2}{3 \\sqrt{73}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(3/5), -(2/5)\nline = Poly(((9*x)/5)+((24*y)/5)+(13/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 1 & 2 & -2 \\\\\n 0 & 2 & -4 \\\\\n 0 & 0 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & -1 & \\frac{2}{3} \\\\\n 0 & \\frac{1}{2} & -\\frac{2}{3} \\\\\n 0 & 0 & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, -2],\n [0, 2, -4],\n [0, 0, -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & -5 \\\\\n -9 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+x-75$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -5],\n [-9, 5]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -2 & 8 & -9 & 0 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 1 & -4 & 7 & -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -3 & 12 & -16 & 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 8, -9, 0]])\nb = np.array([\n [1, -4, 7, -10]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 1 & 1 \\\\\n 1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{4}{3} & -\\frac{1}{3} \\\\\n -\\frac{1}{3} & \\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1],\n [1, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -2 & -5 \\\\\n -3 & 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 4 & -3 \\\\\n -6 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 2 & -8 \\\\\n -9 & 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -5],\n [-3, 10]])\nb = np.array([\n [4, -3],\n [-6, 2]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & 0 & -4 \\\\\n -1 & 3 & 3 \\\\\n 4 & -5 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{6}{5} & -1 & -\\frac{3}{5} \\\\\n -\\frac{3}{4} & -\\frac{1}{2} & -\\frac{1}{2} \\\\\n \\frac{7}{20} & \\frac{1}{2} & \\frac{3}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, -4],\n [-1, 3, 3],\n [4, -5, 3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{6}{5},0,\\frac{3}{5}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-1],\n [-1]]).squeeze()\nb = np.array([\n [2],\n [0],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & -1 & -3 \\\\\n 2 & -2 & 0 \\\\\n 3 & 1 & -1 \\\\\n -3 & 2 & -1 \\\\\n 3 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.1 \\\\\n -1.98 \\\\\n -2.92 \\\\\n -2.2 \\\\\n -1.93 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.523 \\\\\n -1.045 \\\\\n -0.58 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, -3],\n [2, -2, 0],\n [3, 1, -1],\n [-3, 2, -1],\n [3, -1, 2]])\nb = np.array([\n [2.1],\n [-1.98],\n [-2.92],\n [-2.2],\n [-1.93]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 3 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 5 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2 \\\\\n 8 \\\\\n 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [3],\n [6]])\nb = np.array([\n [-1],\n [5],\n [-5]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -2 \\\\\n -10 \\\\\n 8 \\\\\n 3 \\\\\n 4 \\\\\n -8 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-2],\n [-10],\n [8],\n [3],\n [4],\n [-8],\n [5]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -1 & 8 & -9 \\\\\n 7 & 7 & -10 \\\\\n -3 & -7 & -7 \\\\\n 9 & 8 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 2 & -1 & 3 \\\\\n -2 & -3 & 2 \\\\\n -9 & -1 & 3 \\\\\n 0 & -4 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 7 & -6 \\\\\n 5 & 4 & -8 \\\\\n -12 & -8 & -4 \\\\\n 9 & 4 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 8, -9],\n [7, 7, -10],\n [-3, -7, -7],\n [9, 8, 2]])\nb = np.array([\n [2, -1, 3],\n [-2, -3, 2],\n [-9, -1, 3],\n [0, -4, -3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\sqrt{\\frac{2}{7}} \\\\\n 0 \\\\\n 0 \\\\\n -\\frac{1}{\\sqrt{14}} \\\\\n -\\frac{3}{\\sqrt{14}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [0],\n [0],\n [-1],\n [-3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{35}{16} & \\frac{151}{16} \\\\\n -\\frac{5}{2} & \\frac{11}{4} \\\\\n -\\frac{5}{4} & -\\frac{51}{16} \\\\\n \\frac{41}{16} & \\frac{47}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{45}{8} & -\\frac{55}{8} \\\\\n \\frac{131}{16} & -1 \\\\\n \\frac{103}{16} & -\\frac{147}{16} \\\\\n \\frac{73}{8} & -\\frac{29}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{55}{16} & \\frac{261}{16} \\\\\n -\\frac{171}{16} & \\frac{15}{4} \\\\\n -\\frac{123}{16} & 6 \\\\\n -\\frac{105}{16} & \\frac{19}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(35/16), (151/16)],\n [-(5/2), (11/4)],\n [-(5/4), -(51/16)],\n [(41/16), (47/8)]])\nb = np.array([\n [(45/8), -(55/8)],\n [(131/16), -1],\n [(103/16), -(147/16)],\n [(73/8), -(29/8)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & 0 & 2 \\\\\n 0 & -1 & -2 \\\\\n -2 & 2 & 0 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -4 & 4 & 0 \\\\\n 4 & -3 & 2 \\\\\n 0 & -2 & -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0, 2],\n [0, -1, -2],\n [-2, 2, 0]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & -4 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-4.,0.,7.\\}, \\{4.,7.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, -4, 4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{9}{5} \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{9}{\\sqrt{281}} \\\\\n -\\frac{10}{\\sqrt{281}} \\\\\n \\frac{10}{\\sqrt{281}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/5)],\n [-2],\n [2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{2}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 5 & 2 \\\\\n 0 & 1 \\\\\n -3 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{5}{2} & 1 \\\\\n 0 & \\frac{1}{2} \\\\\n -\\frac{3}{2} & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 2],\n [0, 1],\n [-3, -4]])\nprint(a * (1/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 5 & -2 & 3 & 6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -2 & -4 & 8 & -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 7 & 2 & -5 & 16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -2, 3, 6]])\nb = np.array([\n [-2, -4, 8, -10]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{4} \\\\\n \\frac{11}{2} \\\\\n -\\frac{9}{2} \\\\\n \\frac{15}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{4} \\\\\n 9 \\\\\n 8 \\\\\n \\frac{15}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{921}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/4)],\n [(11/2)],\n [-(9/2)],\n [(15/2)]])\nb = np.array([\n [-(15/4)],\n [9],\n [8],\n [(15/2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{3} \\\\\n 1 \\\\\n \\frac{1}{3} \\\\\n 2 \\\\\n \\frac{5}{3} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n \\frac{5}{3} \\\\\n 3 \\\\\n -2 \\\\\n -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{2}{31},-\\frac{10}{93},-\\frac{6}{31},\\frac{4}{31},\\frac{4}{93}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/3)],\n [1],\n [(1/3)],\n [2],\n [(5/3)]]).squeeze()\nb = np.array([\n [-1],\n [(5/3)],\n [3],\n [-2],\n [-(2/3)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n \\frac{7}{3} \\\\\n -\\frac{1}{3} \\\\\n \\frac{4}{3} \\\\\n \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{\\sqrt{91}} \\\\\n \\sqrt{\\frac{7}{13}} \\\\\n -\\frac{1}{\\sqrt{91}} \\\\\n \\frac{4}{\\sqrt{91}} \\\\\n \\frac{4}{\\sqrt{91}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [(7/3)],\n [-(1/3)],\n [(4/3)],\n [(4/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & -1 & 2 & -1 & 3 \\\\\n 2 & 0 & 1 & 0 & -1 \\\\\n 1 & -1 & 3 & 2 & -2 \\\\\n -2 & -1 & -2 & 3 & 1 \\\\\n -3 & 3 & 3 & 1 & 3 \\\\\n -3 & 0 & 1 & -3 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.78 \\\\\n -2.01 \\\\\n -2.59 \\\\\n 2.58 \\\\\n -2.82 \\\\\n -2.47 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.016 \\\\\n 0.148 \\\\\n -1.118 \\\\\n 0.317 \\\\\n -0.044 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, 2, -1, 3],\n [2, 0, 1, 0, -1],\n [1, -1, 3, 2, -2],\n [-2, -1, -2, 3, 1],\n [-3, 3, 3, 1, 3],\n [-3, 0, 1, -3, 1]])\nb = np.array([\n [-2.78],\n [-2.01],\n [-2.59],\n [2.58],\n [-2.82],\n [-2.47]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, 1}$ to the line $3 x+\\frac{3 y}{2}+2=0$.", - "Output Answer": [ - "$\\frac{11}{3 \\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, 1\nline = Poly(3*x+((3*y)/2)+2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{97}{16} & \\frac{89}{16} & \\frac{37}{8} & -\\frac{13}{4} \\\\\n 3 & -4 & \\frac{83}{16} & 1 \\\\\n \\frac{7}{16} & -\\frac{55}{8} & -\\frac{39}{8} & \\frac{15}{4} \\\\\n -\\frac{45}{8} & \\frac{39}{4} & \\frac{61}{8} & -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{11}{2} & \\frac{49}{8} & -\\frac{117}{16} & -\\frac{97}{16} \\\\\n -\\frac{69}{16} & \\frac{5}{16} & -\\frac{27}{4} & \\frac{67}{16} \\\\\n -\\frac{77}{16} & \\frac{21}{4} & \\frac{39}{4} & \\frac{19}{8} \\\\\n \\frac{15}{2} & \\frac{25}{4} & \\frac{21}{16} & \\frac{39}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{9}{16} & -\\frac{9}{16} & \\frac{191}{16} & \\frac{45}{16} \\\\\n \\frac{117}{16} & -\\frac{69}{16} & \\frac{191}{16} & -\\frac{51}{16} \\\\\n \\frac{21}{4} & -\\frac{97}{8} & -\\frac{117}{8} & \\frac{11}{8} \\\\\n -\\frac{105}{8} & \\frac{7}{2} & \\frac{101}{16} & -\\frac{91}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(97/16), (89/16), (37/8), -(13/4)],\n [3, -4, (83/16), 1],\n [(7/16), -(55/8), -(39/8), (15/4)],\n [-(45/8), (39/4), (61/8), -(13/2)]])\nb = np.array([\n [-(11/2), (49/8), -(117/16), -(97/16)],\n [-(69/16), (5/16), -(27/4), (67/16)],\n [-(77/16), (21/4), (39/4), (19/8)],\n [(15/2), (25/4), (21/16), (39/8)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & 1 \\\\\n 0 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$12$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 1],\n [0, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{9}{2}, \\frac{3}{2}}$ to the line $-\\frac{9 x}{2}+\\frac{3 y}{2}+\\frac{1}{2}=0$.", - "Output Answer": [ - "$\\frac{7 \\sqrt{\\frac{5}{2}}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (9/2), (3/2)\nline = Poly(-((9*x)/2)+((3*y)/2)+(1/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 8 & 7 \\\\\n 5 & -8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 3 & 4 \\\\\n 0 & 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 5 & 3 \\\\\n 5 & -18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 7],\n [5, -8]])\nb = np.array([\n [3, 4],\n [0, 10]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{ccc}\n 2 & 0 & 0 \\\\\n 0 & 2 & 0 \\\\\n 2 & -2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n e^2 & 0 & 0 \\\\\n 0 & e^2 & 0 \\\\\n e^2-1 & 1-e^2 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [2, 0, 0],\n [0, 2, 0],\n [2, -2, 0]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{8}{5} & -\\frac{21}{5} \\\\\n -\\frac{23}{10} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{523}{50}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/5), -(21/5)],\n [-(23/10), (1/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -2 \\\\\n 1 \\\\\n -3 \\\\\n -3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -2 \\\\\n 0 \\\\\n 0 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{3}{2},-\\frac{3}{2},0,0,-\\frac{3}{2},\\frac{3}{2}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-2],\n [1],\n [-3],\n [-3],\n [-2]]).squeeze()\nb = np.array([\n [-2],\n [-2],\n [0],\n [0],\n [-2],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -6 & -7 & -7 & -10 & 8 & -2 & 5 \\\\\n 9 & 6 & -7 & 5 & 0 & 10 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & -\\frac{91}{27} & -\\frac{25}{27} & \\frac{16}{9} & \\frac{58}{27} & \\frac{44}{27} \\\\\n 0 & 1 & \\frac{35}{9} & \\frac{20}{9} & -\\frac{8}{3} & -\\frac{14}{9} & -\\frac{19}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-6, -7, -7, -10, 8, -2, 5],\n [9, 6, -7, 5, 0, 10, 2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{16}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 10 & 9 & 3 \\\\\n 2 & -9 & -4 \\\\\n 4 & -9 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{25}{8} & \\frac{45}{16} & \\frac{15}{16} \\\\\n \\frac{5}{8} & -\\frac{45}{16} & -\\frac{5}{4} \\\\\n \\frac{5}{4} & -\\frac{45}{16} & \\frac{25}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 9, 3],\n [2, -9, -4],\n [4, -9, 10]])\nprint(a * (5/16))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{38}{5} \\\\\n \\frac{7}{5} \\\\\n \\frac{24}{5} \\\\\n -\\frac{16}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n \\frac{16}{5} \\\\\n \\frac{1}{5} \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{392}{5 \\sqrt{28489}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(38/5)],\n [(7/5)],\n [(24/5)],\n [-(16/5)]]).squeeze()\nb = np.array([\n [-8],\n [(16/5)],\n [(1/5)],\n [6]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{8}{3},4,\\frac{10}{3}\\right\\}, \\left\\{1,\\frac{8}{3},5\\right\\}, \\left\\{-\\frac{13}{3},-\\frac{7}{3},\\frac{14}{3}\\right\\}}$.", - "Output Answer": [ - "$79 x-69 y-229 z+1250=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(8/3), 4, (10/3)],\n [1, (8/3), 5],\n [-(13/3), -(7/3), (14/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{93}{16} & \\frac{11}{4} & \\frac{121}{16} & \\frac{27}{8} \\\\\n \\frac{75}{8} & -\\frac{95}{16} & \\frac{51}{16} & \\frac{39}{16} \\\\\n 9 & \\frac{29}{4} & -4 & \\frac{135}{16} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n \\frac{51}{8} & -\\frac{39}{4} & -\\frac{77}{16} & \\frac{25}{4} \\\\\n -\\frac{129}{16} & -\\frac{33}{4} & 9 & -\\frac{29}{16} \\\\\n -\\frac{3}{8} & \\frac{105}{16} & \\frac{5}{4} & -\\frac{41}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{9}{16} & \\frac{25}{2} & \\frac{99}{8} & -\\frac{23}{8} \\\\\n \\frac{279}{16} & \\frac{37}{16} & -\\frac{93}{16} & \\frac{17}{4} \\\\\n \\frac{75}{8} & \\frac{11}{16} & -\\frac{21}{4} & \\frac{217}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(93/16), (11/4), (121/16), (27/8)],\n [(75/8), -(95/16), (51/16), (39/16)],\n [9, (29/4), -4, (135/16)]])\nb = np.array([\n [(51/8), -(39/4), -(77/16), (25/4)],\n [-(129/16), -(33/4), 9, -(29/16)],\n [-(3/8), (105/16), (5/4), -(41/8)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -5 & 5 \\\\\n -3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$15$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 5],\n [-3, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{28}{3} & \\frac{25}{3} & -7 \\\\\n \\frac{8}{3} & \\frac{17}{3} & 2 \\\\\n 3 & \\frac{22}{3} & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6.385,3.958,11.427\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(28/3), (25/3), -7],\n [(8/3), (17/3), 2],\n [3, (22/3), -6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n \\frac{22}{5} \\\\\n -\\frac{48}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(22/5)],\n [-(48/5)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 6 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 5 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$24$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [6],\n [3]])\nb = np.array([\n [1],\n [5],\n [-3]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{34}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [2]])\nb = np.array([\n [7],\n [-3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{73}{8} & -\\frac{29}{8} & -\\frac{31}{8} \\\\\n -\\frac{35}{4} & -\\frac{57}{16} & \\frac{27}{4} \\\\\n -\\frac{11}{16} & \\frac{65}{16} & \\frac{17}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{67 x^2}{16}+\\frac{8777 x}{64}+\\frac{862185}{2048}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(73/8), -(29/8), -(31/8)],\n [-(35/4), -(57/16), (27/4)],\n [-(11/16), (65/16), (17/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & 2 & 1 & -3 \\\\\n 0 & 2 & 0 & 1 \\\\\n 3 & -1 & -3 & 3 \\\\\n 3 & 3 & -1 & -1 \\\\\n -1 & 0 & -1 & 2 \\\\\n 0 & 0 & -2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.93 \\\\\n -0.47 \\\\\n -1.38 \\\\\n -2.37 \\\\\n 1.89 \\\\\n 1.91 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.027 \\\\\n -0.181 \\\\\n -0.778 \\\\\n -0.04 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2, 1, -3],\n [0, 2, 0, 1],\n [3, -1, -3, 3],\n [3, 3, -1, -1],\n [-1, 0, -1, 2],\n [0, 0, -2, -2]])\nb = np.array([\n [-0.93],\n [-0.47],\n [-1.38],\n [-2.37],\n [1.89],\n [1.91]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -\\frac{2}{3} & 1 \\\\\n \\frac{2}{3} & -2 \\\\\n 3 & \\frac{1}{3} \\\\\n \\frac{5}{3} & -3 \\\\\n \\frac{8}{3} & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 1 & -\\frac{5}{3} \\\\\n \\frac{7}{3} & \\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{5}{3} & \\frac{31}{9} \\\\\n -4 & -\\frac{52}{9} \\\\\n \\frac{34}{9} & -\\frac{38}{9} \\\\\n -\\frac{16}{3} & -\\frac{88}{9} \\\\\n \\frac{38}{9} & -\\frac{26}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3), 1],\n [(2/3), -2],\n [3, (1/3)],\n [(5/3), -3],\n [(8/3), (2/3)]])\nb = np.array([\n [1, -(5/3)],\n [(7/3), (7/3)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -9 & -\\frac{46}{5} \\\\\n -5 & -\\frac{26}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{50} \\left(19-11 \\sqrt{41}\\right),1\\right\\}, \\left\\{\\frac{1}{50} \\left(19+11 \\sqrt{41}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -(46/5)],\n [-5, -(26/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{5}{2},-\\frac{3}{2},-1\\right\\}, \\left\\{-2,-1,-\\frac{1}{2}\\right\\}, \\left\\{-1,\\frac{1}{2},\\frac{1}{2}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{5}{\\sqrt{38}},-\\frac{3}{\\sqrt{38}},-\\sqrt{\\frac{2}{19}}\\right\\}, \\left\\{-\\frac{6}{\\sqrt{133}},\\frac{4}{\\sqrt{133}},\\frac{9}{\\sqrt{133}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{14}},\\frac{3}{\\sqrt{14}},-\\sqrt{\\frac{2}{7}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-(5/2), -(3/2), -1), (-2, -1, -(1/2)), (-1, (1/2), (1/2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 7 \\\\\n -5 \\\\\n -1 \\\\\n 2 \\\\\n 0 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$26$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [7],\n [-5],\n [-1],\n [2],\n [0],\n [-4]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{7}{2} & \\frac{53}{6} & -\\frac{53}{6} \\\\\n -5 & \\frac{15}{2} & -\\frac{13}{6} \\\\\n -\\frac{11}{2} & 6 & \\frac{20}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{53 x^2}{3}-\\frac{649 x}{6}+\\frac{3125}{6}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2), (53/6), -(53/6)],\n [-5, (15/2), -(13/6)],\n [-(11/2), 6, (20/3)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -5 & 3 & 2 \\\\\n -7 & 2 & 4 \\\\\n 7 & 8 & -7 \\\\\n 2 & -9 & 5 \\\\\n 0 & 10 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, 3, 2],\n [-7, 2, 4],\n [7, 8, -7],\n [2, -9, 5],\n [0, 10, 5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 0 & 3 \\\\\n -2 & 1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -6 & -15 \\\\\n 10 & -11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 3],\n [-2, 1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{16}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 2 & -6 \\\\\n -5 & -9 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{7}{8} & \\frac{7}{8} & -\\frac{21}{8} \\\\\n -\\frac{35}{16} & -\\frac{63}{16} & -\\frac{7}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, -6],\n [-5, -9, -2]])\nprint(a * (7/16))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,-1,-2\\}, \\{-4,3,3\\}, \\{-3,2,0\\}}$.", - "Output Answer": [ - "$7 x+4 y+z+13=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, -1, -2],\n [-4, 3, 3],\n [-3, 2, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & 8 \\\\\n -2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-2 i \\sqrt{3},2 i \\sqrt{3}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 8],\n [-2, 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -\\frac{12}{5} \\\\\n \\frac{49}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(12/5)],\n [(49/5)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 5 & -4 \\\\\n -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -4],\n [-1, 2]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 7 & 10 & 4 & -9 \\\\\n -8 & 8 & -10 & 2 \\\\\n -5 & 10 & 1 & -5 \\\\\n 2 & -7 & -5 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, 10, 4, -9],\n [-8, 8, -10, 2],\n [-5, 10, 1, -5],\n [2, -7, -5, -3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{83}{16} & -\\frac{21}{4} \\\\\n \\frac{3}{8} & -\\frac{99}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+x-\\frac{7713}{256}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(83/16), -(21/4)],\n [(3/8), -(99/16)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{10} \\\\\n -\\frac{19}{10} \\\\\n \\frac{12}{5} \\\\\n \\frac{7}{5} \\\\\n \\frac{2}{5} \\\\\n \\frac{13}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{\\sqrt{1327}} \\\\\n -\\frac{19}{\\sqrt{1327}} \\\\\n \\frac{24}{\\sqrt{1327}} \\\\\n \\frac{14}{\\sqrt{1327}} \\\\\n \\frac{4}{\\sqrt{1327}} \\\\\n \\frac{13}{\\sqrt{1327}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/10)],\n [-(19/10)],\n [(12/5)],\n [(7/5)],\n [(2/5)],\n [(13/10)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 2 & 1 & -1 & -1 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 2 & -2 \\\\\n -1 & -1 \\\\\n 1 & 1 \\\\\n 1 & 1 \\\\\n -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 2 & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, -1, -1, -1]])\nb = np.array([\n [2, -2],\n [-1, -1],\n [1, 1],\n [1, 1],\n [-1, 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 8 & 4 & 4 \\\\\n 4 & -2 & 1 \\\\\n -7 & 9 & 3 \\\\\n -2 & -8 & -8 \\\\\n 1 & -9 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, 4, 4],\n [4, -2, 1],\n [-7, 9, 3],\n [-2, -8, -8],\n [1, -9, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4.62 \\\\\n 1.3 \\\\\n 9.19 \\\\\n 3.6 \\\\\n 5.41 \\\\\n 7.67 \\\\\n -1.16 \\\\\n -7.75 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2.84 \\\\\n -4.51 \\\\\n -3.82 \\\\\n 7.77 \\\\\n -9.25 \\\\\n -8.11 \\\\\n -5.5 \\\\\n 9.14 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-202.819$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4.62],\n [1.3],\n [9.19],\n [3.6],\n [5.41],\n [7.67],\n [-1.16],\n [-7.75]])\nb = np.array([\n [2.84],\n [-4.51],\n [-3.82],\n [7.77],\n [-9.25],\n [-8.11],\n [-5.5],\n [9.14]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{37}{5} & \\frac{18}{5} & 0 \\\\\n \\frac{33}{5} & -\\frac{21}{5} & -\\frac{16}{5} \\\\\n -\\frac{1}{5} & -\\frac{38}{5} & -\\frac{9}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-9.005,0.925,9.48\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/5), (18/5), 0],\n [(33/5), -(21/5), -(16/5)],\n [-(1/5), -(38/5), -(9/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n \\frac{7}{6} \\\\\n 1 \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{91}{36} \\\\\n -\\frac{13}{6} \\\\\n \\frac{13}{12} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/6)],\n [1],\n [-(1/2)]])\nb = np.array([\n [-(13/6)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -2 & 2 & 0 & -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -2 & 2 & 0 & -1 & 2 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n -2 & 2 & 0 & -1 & 2 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n 2 & -2 & 0 & 1 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [1],\n [0],\n [-1]])\nb = np.array([\n [-2, 2, 0, -1, 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{6}{25},-\\frac{9}{50}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2)],\n [-(5/2)]]).squeeze()\nb = np.array([\n [-2],\n [-(3/2)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{29}{8} & -\\frac{63}{8} \\\\\n -\\frac{127}{16} & -\\frac{151}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{209 x}{16}-\\frac{1811}{64}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/8), -(63/8)],\n [-(127/16), -(151/16)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 5 \\\\\n -4 \\\\\n -9 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -4 \\\\\n 8 \\\\\n -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -5 \\\\\n 9 \\\\\n -12 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [5],\n [-4],\n [-9]])\nb = np.array([\n [-3],\n [-4],\n [8],\n [-9]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{44}{5} & -\\frac{4}{5} \\\\\n \\frac{22}{5} & \\frac{39}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(83-i \\sqrt{327}\\right),\\frac{1}{10} \\left(83+i \\sqrt{327}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(44/5), -(4/5)],\n [(22/5), (39/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n -1 & 0 & 0 & 0 \\\\\n -1 & 0 & 0 & 0 \\\\\n -1 & 0 & 0 & 0 \\\\\n -1 & 1 & 0 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{1}{e} & 0 & 0 & 0 \\\\\n \\frac{1-e}{e} & 1 & 0 & 0 \\\\\n \\frac{1-e}{e} & 0 & 1 & 0 \\\\\n 1-e & e-1 & 0 & e \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [-1, 0, 0, 0],\n [-1, 0, 0, 0],\n [-1, 0, 0, 0],\n [-1, 1, 0, 1]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{4}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & -2 \\\\\n -10 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{3}{4} & -\\frac{1}{2} \\\\\n -\\frac{5}{2} & \\frac{3}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2],\n [-10, 3]])\nprint(a * (1/4))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -7 & 8 & 8 & 7 \\\\\n -3 & -9 & -6 & -8 \\\\\n -5 & -2 & -7 & -7 \\\\\n 3 & -3 & -8 & -3 \\\\\n -3 & -4 & -5 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, 8, 8, 7],\n [-3, -9, -6, -8],\n [-5, -2, -7, -7],\n [3, -3, -8, -3],\n [-3, -4, -5, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{14}{3} & \\frac{4}{3} \\\\\n \\frac{11}{6} & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{81}{334} & -\\frac{12}{167} \\\\\n -\\frac{33}{334} & \\frac{42}{167} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/3), (4/3)],\n [(11/6), (9/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,-4,3\\}, \\{3,-2,-1\\}, \\{2,3,3\\}}$.", - "Output Answer": [ - "$28 x-24 y+37 z-95=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, -4, 3],\n [3, -2, -1],\n [2, 3, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{8}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 9 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{9}{8} \\\\\n \\frac{9}{8} \\\\\n -\\frac{7}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [9],\n [-7]])\nprint(a * (1/8))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -10 \\\\\n -1 \\\\\n 1 \\\\\n 6 \\\\\n -9 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{13}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-10],\n [-1],\n [1],\n [6],\n [-9],\n [-9]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 0 & 2 & -2 \\\\\n -1 & 3 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -1 & -3 \\\\\n -1 & -2 \\\\\n -1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & -4 \\\\\n -4 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, -2],\n [-1, 3, 2]])\nb = np.array([\n [-1, -3],\n [-1, -2],\n [-1, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & 1 & -2 \\\\\n -3 & 2 & -1 \\\\\n 0 & -1 & 0 \\\\\n 2 & -2 & 0 \\\\\n 0 & 1 & 1 \\\\\n -2 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.99 \\\\\n 2.41 \\\\\n -1.72 \\\\\n 2.06 \\\\\n -0.41 \\\\\n -0.68 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.048 \\\\\n 0.106 \\\\\n -0.93 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1, -2],\n [-3, 2, -1],\n [0, -1, 0],\n [2, -2, 0],\n [0, 1, 1],\n [-2, -1, 2]])\nb = np.array([\n [2.99],\n [2.41],\n [-1.72],\n [2.06],\n [-0.41],\n [-0.68]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -3 & 0 & -2 & 2 & -3 \\\\\n 0 & -2 & 0 & 3 & 2 \\\\\n 3 & -3 & 3 & 1 & -1 \\\\\n -1 & -1 & 2 & 1 & -1 \\\\\n -2 & 2 & -3 & 0 & 3 \\\\\n 3 & -1 & 2 & 3 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.93 \\\\\n 1.27 \\\\\n 1.43 \\\\\n 2.64 \\\\\n 0.81 \\\\\n -0.42 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.724 \\\\\n 0.042 \\\\\n 1.323 \\\\\n -0.001 \\\\\n 0.864 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, -2, 2, -3],\n [0, -2, 0, 3, 2],\n [3, -3, 3, 1, -1],\n [-1, -1, 2, 1, -1],\n [-2, 2, -3, 0, 3],\n [3, -1, 2, 3, -1]])\nb = np.array([\n [-2.93],\n [1.27],\n [1.43],\n [2.64],\n [0.81],\n [-0.42]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 9 \\\\\n -6 \\\\\n -3 \\\\\n 0 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -1 \\\\\n 3 \\\\\n 8 \\\\\n 6 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{5}{3 \\sqrt{38}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [9],\n [-6],\n [-3],\n [0],\n [9]]).squeeze()\nb = np.array([\n [6],\n [-1],\n [3],\n [8],\n [6],\n [5]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{20}{3} \\\\\n -\\frac{28}{3} \\\\\n \\frac{41}{6} \\\\\n -\\frac{4}{3} \\\\\n \\frac{41}{6} \\\\\n -\\frac{16}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{28}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(20/3)],\n [-(28/3)],\n [(41/6)],\n [-(4/3)],\n [(41/6)],\n [-(16/3)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n 2 \\\\\n -2 \\\\\n -1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{53}} \\\\\n \\frac{4}{\\sqrt{53}} \\\\\n -\\frac{4}{\\sqrt{53}} \\\\\n -\\frac{2}{\\sqrt{53}} \\\\\n -\\frac{4}{\\sqrt{53}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2)],\n [2],\n [-2],\n [-1],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -2 & -4 \\\\\n -4 & -3 \\\\\n -10 & -9 \\\\\n -2 & -6 \\\\\n 10 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, -4],\n [-4, -3],\n [-10, -9],\n [-2, -6],\n [10, -9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{2} & -\\frac{1}{2} & \\frac{1}{6} \\\\\n -\\frac{7}{3} & 1 & \\frac{9}{2} \\\\\n \\frac{1}{6} & -\\frac{11}{6} & \\frac{19}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1233}{3448} & -\\frac{69}{1724} & \\frac{261}{3448} \\\\\n -\\frac{879}{3448} & \\frac{429}{1724} & -\\frac{1173}{3448} \\\\\n -\\frac{111}{862} & \\frac{63}{431} & \\frac{99}{862} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), -(1/2), (1/6)],\n [-(7/3), 1, (9/2)],\n [(1/6), -(11/6), (19/6)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2]])\nb = np.array([\n [5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{0,\\frac{4}{\\sqrt{5}},\\frac{7}{\\sqrt{5}}\\right\\}, \\left\\{\\frac{7}{\\sqrt{5}},0,\\frac{2}{\\sqrt{5}}\\right\\}, \\left\\{-\\frac{7}{\\sqrt{5}},-\\frac{4}{\\sqrt{5}},-\\sqrt{5}\\right\\}}$", - "Output Answer": [ - "${\\left\\{0,\\frac{4}{\\sqrt{65}},\\frac{7}{\\sqrt{65}}\\right\\}, \\left\\{\\frac{7 \\sqrt{65}}{57},-\\frac{56}{57 \\sqrt{65}},\\frac{32}{57 \\sqrt{65}}\\right\\}, \\left\\{-\\frac{896}{3249 \\sqrt{5 \\left(\\frac{6184192}{10556001}+\\left(\\frac{19381}{3249 \\sqrt{5}}-\\sqrt{5}\\right)^2\\right)}},-\\frac{5488}{3249 \\sqrt{5 \\left(\\frac{6184192}{10556001}+\\left(\\frac{19381}{3249 \\sqrt{5}}-\\sqrt{5}\\right)^2\\right)}},\\frac{\\frac{19381}{3249 \\sqrt{5}}-\\sqrt{5}}{\\sqrt{\\frac{6184192}{10556001}+\\left(\\frac{19381}{3249 \\sqrt{5}}-\\sqrt{5}\\right)^2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((0, (4/(math.sqrt(5))), (7/(math.sqrt(5)))), ((7/(math.sqrt(5))), 0, (2/(math.sqrt(5)))), (-(7/(math.sqrt(5))), -(4/(math.sqrt(5))), -math.sqrt(5))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 0 \\\\\n 2 \\\\\n -1 \\\\\n 0 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{2}} \\\\\n 0 \\\\\n \\frac{\\sqrt{2}}{3} \\\\\n -\\frac{1}{3 \\sqrt{2}} \\\\\n 0 \\\\\n -\\frac{\\sqrt{2}}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [0],\n [2],\n [-1],\n [0],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{13}{2} & -\\frac{3}{2} & -\\frac{1}{2} & -9 \\\\\n \\frac{13}{2} & -2 & -3 & -1 \\\\\n -\\frac{3}{2} & 5 & -6 & \\frac{17}{2} \\\\\n \\frac{7}{2} & -\\frac{5}{2} & 2 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{3}{2} & -\\frac{13}{2} & -9 & 4 \\\\\n -6 & -\\frac{15}{2} & 1 & -5 \\\\\n 1 & -\\frac{17}{2} & 0 & -\\frac{19}{2} \\\\\n -\\frac{7}{2} & \\frac{5}{2} & -5 & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 5 & -8 & -\\frac{19}{2} & -5 \\\\\n \\frac{1}{2} & -\\frac{19}{2} & -2 & -6 \\\\\n -\\frac{1}{2} & -\\frac{7}{2} & -6 & -1 \\\\\n 0 & 0 & -3 & -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2), -(3/2), -(1/2), -9],\n [(13/2), -2, -3, -1],\n [-(3/2), 5, -6, (17/2)],\n [(7/2), -(5/2), 2, -3]])\nb = np.array([\n [-(3/2), -(13/2), -9, 4],\n [-6, -(15/2), 1, -5],\n [1, -(17/2), 0, -(19/2)],\n [-(7/2), (5/2), -5, -(5/2)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & 1 \\\\\n -7 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-5-\\sqrt{2},\\sqrt{2}-5\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 1],\n [-7, -2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-4, -\\frac{3}{2}, -1}$ to the plane $-3 x-4 y+\\frac{9 z}{2}-1=0$.", - "Output Answer": [ - "$\\frac{25}{\\sqrt{181}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -4, -(3/2), -1\nplane = Poly(-3*x-4*y+((9*z)/2)-1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -6 & -2 & -2 & -4 \\\\\n -9 & 8 & 1 & -5 \\\\\n -2 & 9 & -4 & -1 \\\\\n 5 & -8 & 7 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 9 & -5 & 1 & -1 \\\\\n 6 & -6 & -9 & -9 \\\\\n -1 & 9 & -7 & 10 \\\\\n -5 & -9 & 3 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 3 & -7 & -1 & -5 \\\\\n -3 & 2 & -8 & -14 \\\\\n -3 & 18 & -11 & 9 \\\\\n 0 & -17 & 10 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -2, -2, -4],\n [-9, 8, 1, -5],\n [-2, 9, -4, -1],\n [5, -8, 7, -1]])\nb = np.array([\n [9, -5, 1, -1],\n [6, -6, -9, -9],\n [-1, 9, -7, 10],\n [-5, -9, 3, 6]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n 10 \\\\\n -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{19}{6} \\\\\n -\\frac{25}{6} \\\\\n \\frac{11}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{65}{9} \\\\\n -\\frac{337}{36} \\\\\n -\\frac{135}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2)],\n [10],\n [-(8/3)]])\nb = np.array([\n [(19/6)],\n [-(25/6)],\n [(11/6)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -3 \\\\\n 1 \\\\\n -10 \\\\\n -5 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -8 \\\\\n 3 \\\\\n -5 \\\\\n 0 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{305}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-3],\n [1],\n [-10],\n [-5],\n [8]])\nb = np.array([\n [-1],\n [-8],\n [3],\n [-5],\n [0],\n [-7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -10 & -4 & 10 & -9 & -3 & -1 \\\\\n -2 & 8 & 1 & 2 & -7 & 8 \\\\\n 4 & 3 & 1 & 9 & -9 & -8 \\\\\n 8 & -3 & 1 & -5 & 1 & 1 \\\\\n 1 & 10 & 7 & 1 & -5 & -10 \\\\\n 0 & 1 & -7 & 0 & -3 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, -4, 10, -9, -3, -1],\n [-2, 8, 1, 2, -7, 8],\n [4, 3, 1, 9, -9, -8],\n [8, -3, 1, -5, 1, 1],\n [1, 10, 7, 1, -5, -10],\n [0, 1, -7, 0, -3, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [1],\n [0],\n [0],\n [0]]).squeeze()\nb = np.array([\n [0],\n [0],\n [0],\n [-1],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{2}{\\sqrt{3}},\\frac{1}{\\sqrt{3}},\\frac{1}{\\sqrt{3}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}},-\\frac{4}{\\sqrt{3}}\\right\\}, \\left\\{\\frac{5}{\\sqrt{3}},\\frac{2}{\\sqrt{3}},\\frac{2}{\\sqrt{3}}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\sqrt{\\frac{2}{3}},\\frac{1}{\\sqrt{6}},\\frac{1}{\\sqrt{6}}\\right\\}, \\left\\{2 \\sqrt{\\frac{2}{33}},-\\frac{1}{\\sqrt{66}},-\\frac{7}{\\sqrt{66}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{11}},-\\frac{3}{\\sqrt{11}},\\frac{1}{\\sqrt{11}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((2/(math.sqrt(3))), (1/(math.sqrt(3))), (1/(math.sqrt(3)))), ((1/(math.sqrt(3))), -(1/(math.sqrt(3))), -(4/(math.sqrt(3)))), ((5/(math.sqrt(3))), (2/(math.sqrt(3))), (2/(math.sqrt(3))))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & -\\frac{1}{6} \\\\\n \\frac{47}{6} & \\frac{14}{3} \\\\\n \\frac{13}{6} & \\frac{11}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{17}{3} & \\frac{25}{3} \\\\\n -\\frac{7}{2} & -\\frac{1}{6} \\\\\n -\\frac{2}{3} & -\\frac{49}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{25}{6} & \\frac{49}{6} \\\\\n \\frac{13}{3} & \\frac{9}{2} \\\\\n \\frac{3}{2} & -\\frac{19}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), -(1/6)],\n [(47/6), (14/3)],\n [(13/6), (11/6)]])\nb = np.array([\n [-(17/3), (25/3)],\n [-(7/2), -(1/6)],\n [-(2/3), -(49/6)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -7 & -9 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -9 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 2 & -11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -9]])\nb = np.array([\n [-9, 2]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 2 & -3 & -2 & -1 \\\\\n -3 & 3 & 2 & 1 \\\\\n 0 & 3 & 3 & -1 \\\\\n -2 & 0 & -3 & 0 \\\\\n -2 & -2 & -2 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -2 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 10 \\\\\n -10 \\\\\n -17 \\\\\n 9 \\\\\n 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3, -2, -1],\n [-3, 3, 2, 1],\n [0, 3, 3, -1],\n [-2, 0, -3, 0],\n [-2, -2, -2, -2]])\nb = np.array([\n [0],\n [-2],\n [-3],\n [2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -3 & 0 & 2 & 0 \\\\\n -1 & 3 & 2 & 3 \\\\\n -1 & 2 & -1 & 1 \\\\\n 0 & 2 & -3 & -1 \\\\\n 2 & 1 & 0 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 3 & 3 & 3 & -1 \\\\\n -1 & 2 & 0 & 0 \\\\\n -2 & 1 & 0 & -1 \\\\\n 2 & 1 & 0 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -13 & -7 & -9 & 1 \\\\\n -4 & 8 & -3 & 2 \\\\\n -1 & 1 & -3 & 3 \\\\\n 2 & 0 & 0 & 2 \\\\\n 7 & 9 & 6 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, 2, 0],\n [-1, 3, 2, 3],\n [-1, 2, -1, 1],\n [0, 2, -3, -1],\n [2, 1, 0, 1]])\nb = np.array([\n [3, 3, 3, -1],\n [-1, 2, 0, 0],\n [-2, 1, 0, -1],\n [2, 1, 0, 1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -6 \\\\\n 4 \\\\\n 2 \\\\\n 3 \\\\\n -5 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 3 \\\\\n 9 \\\\\n 1 \\\\\n -8 \\\\\n 8 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$31$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-6],\n [4],\n [2],\n [3],\n [-5],\n [9]])\nb = np.array([\n [6],\n [3],\n [9],\n [1],\n [-8],\n [8],\n [9]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 9 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1.,3.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, -3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -10 & -8 \\\\\n 6 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-15-i \\sqrt{167}\\right),\\frac{1}{2} \\left(-15+i \\sqrt{167}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -8],\n [6, -5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -1 & 2 \\\\\n -2 & 1 \\\\\n 1 & 3 \\\\\n 1 & 1 \\\\\n 3 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 3 & -3 \\\\\n 1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -1 & 5 \\\\\n -5 & 7 \\\\\n 6 & 0 \\\\\n 4 & -2 \\\\\n 9 & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2],\n [-2, 1],\n [1, 3],\n [1, 1],\n [3, 0]])\nb = np.array([\n [3, -3],\n [1, 1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -1 & 6 & 8 & 7 & 3 & 4 \\\\\n 9 & -6 & 2 & -1 & -5 & -8 \\\\\n 5 & 0 & 8 & 2 & 2 & -6 \\\\\n 9 & 2 & -8 & 2 & 1 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & \\frac{34}{89} & -\\frac{124}{89} \\\\\n 0 & 1 & 0 & 0 & \\frac{2217}{1246} & -\\frac{203}{178} \\\\\n 0 & 0 & 1 & 0 & \\frac{237}{623} & -\\frac{27}{89} \\\\\n 0 & 0 & 0 & 1 & -\\frac{920}{623} & \\frac{151}{89} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-1, 6, 8, 7, 3, 4],\n [9, -6, 2, -1, -5, -8],\n [5, 0, 8, 2, 2, -6],\n [9, 2, -8, 2, 1, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 2 & 4 \\\\\n -3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{6} & -\\frac{2}{9} \\\\\n \\frac{1}{6} & \\frac{1}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 4],\n [-3, 3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{4}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}},\\frac{5}{\\sqrt{3}}\\right\\}, \\left\\{\\sqrt{3},\\frac{1}{\\sqrt{3}},0\\right\\}, \\left\\{\\sqrt{3},-\\frac{1}{\\sqrt{3}},0\\right\\}}$", - "Output Answer": [ - "${\\left\\{2 \\sqrt{\\frac{2}{21}},-\\frac{1}{\\sqrt{42}},\\frac{5}{\\sqrt{42}}\\right\\}, \\left\\{\\frac{\\sqrt{3}-\\frac{22}{21 \\sqrt{3}}}{\\sqrt{\\frac{2917}{2646}+\\left(\\sqrt{3}-\\frac{22}{21 \\sqrt{3}}\\right)^2}},\\frac{53}{42 \\sqrt{3 \\left(\\frac{2917}{2646}+\\left(\\sqrt{3}-\\frac{22}{21 \\sqrt{3}}\\right)^2\\right)}},-\\frac{55}{42 \\sqrt{3 \\left(\\frac{2917}{2646}+\\left(\\sqrt{3}-\\frac{22}{21 \\sqrt{3}}\\right)^2\\right)}}\\right\\}, \\left\\{\\frac{-\\frac{26}{21 \\sqrt{3}}+\\sqrt{3}-\\frac{\\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right) \\left(-\\frac{53}{126}+\\sqrt{3} \\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{\\frac{2917}{2646}+\\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)^2}}{\\sqrt{\\left(\\frac{65}{42 \\sqrt{3}}-\\frac{55 \\left(-\\frac{53}{126}+\\sqrt{3} \\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{42 \\sqrt{3} \\left(\\frac{2917}{2646}+\\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)^2\\right)}\\right)^2+\\left(\\frac{29}{42 \\sqrt{3}}+\\frac{53 \\left(-\\frac{53}{126}+\\sqrt{3} \\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{42 \\sqrt{3} \\left(\\frac{2917}{2646}+\\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)^2\\right)}\\right)^2+\\left(-\\frac{26}{21 \\sqrt{3}}+\\sqrt{3}+\\frac{\\left(\\frac{22}{21 \\sqrt{3}}-\\sqrt{3}\\right) \\left(-\\frac{53}{126}+\\sqrt{3} \\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{\\frac{2917}{2646}+\\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)^2}\\right)^2}},\\frac{-\\frac{29}{42 \\sqrt{3}}-\\frac{53 \\left(-\\frac{53}{126}+\\sqrt{3} \\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{42 \\sqrt{3} \\left(\\frac{2917}{2646}+\\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)^2\\right)}}{\\sqrt{\\left(\\frac{65}{42 \\sqrt{3}}-\\frac{55 \\left(-\\frac{53}{126}+\\sqrt{3} \\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{42 \\sqrt{3} \\left(\\frac{2917}{2646}+\\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)^2\\right)}\\right)^2+\\left(\\frac{29}{42 \\sqrt{3}}+\\frac{53 \\left(-\\frac{53}{126}+\\sqrt{3} \\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{42 \\sqrt{3} \\left(\\frac{2917}{2646}+\\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)^2\\right)}\\right)^2+\\left(-\\frac{26}{21 \\sqrt{3}}+\\sqrt{3}+\\frac{\\left(\\frac{22}{21 \\sqrt{3}}-\\sqrt{3}\\right) \\left(-\\frac{53}{126}+\\sqrt{3} \\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{\\frac{2917}{2646}+\\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)^2}\\right)^2}},\\frac{-\\frac{65}{42 \\sqrt{3}}+\\frac{55 \\left(-\\frac{53}{126}+\\sqrt{3} \\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{42 \\sqrt{3} \\left(\\frac{2917}{2646}+\\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)^2\\right)}}{\\sqrt{\\left(\\frac{65}{42 \\sqrt{3}}-\\frac{55 \\left(-\\frac{53}{126}+\\sqrt{3} \\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{42 \\sqrt{3} \\left(\\frac{2917}{2646}+\\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)^2\\right)}\\right)^2+\\left(\\frac{29}{42 \\sqrt{3}}+\\frac{53 \\left(-\\frac{53}{126}+\\sqrt{3} \\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{42 \\sqrt{3} \\left(\\frac{2917}{2646}+\\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)^2\\right)}\\right)^2+\\left(-\\frac{26}{21 \\sqrt{3}}+\\sqrt{3}+\\frac{\\left(\\frac{22}{21 \\sqrt{3}}-\\sqrt{3}\\right) \\left(-\\frac{53}{126}+\\sqrt{3} \\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)\\right)}{\\frac{2917}{2646}+\\left(-\\frac{22}{21 \\sqrt{3}}+\\sqrt{3}\\right)^2}\\right)^2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((4/(math.sqrt(3))), -(1/(math.sqrt(3))), (5/(math.sqrt(3)))), (math.sqrt(3), (1/(math.sqrt(3))), 0), (math.sqrt(3), -(1/(math.sqrt(3))), 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [10]])\nb = np.array([\n [0],\n [9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{3} & \\frac{10}{3} \\\\\n \\frac{22}{9} & -\\frac{89}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{104 x}{9}+\\frac{25}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/3), (10/3)],\n [(22/9), -(89/9)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 5 & -8 \\\\\n 6 & -8 \\\\\n -4 & -8 \\\\\n 9 & 6 \\\\\n -2 & 5 \\\\\n 7 & 7 \\\\\n -6 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, -8],\n [6, -8],\n [-4, -8],\n [9, 6],\n [-2, 5],\n [7, 7],\n [-6, 5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -4 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 4 \\\\\n 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 24 \\\\\n -12 \\\\\n -24 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-4],\n [-6]])\nb = np.array([\n [2],\n [4],\n [0]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{8}{7} & \\frac{51}{7} & \\frac{27}{7} \\\\\n -\\frac{61}{7} & \\frac{8}{7} & \\frac{60}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{4}{7} & -\\frac{59}{7} & -5 \\\\\n \\frac{34}{7} & -\\frac{37}{7} & \\frac{30}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{12}{7} & \\frac{110}{7} & \\frac{62}{7} \\\\\n -\\frac{95}{7} & \\frac{45}{7} & \\frac{30}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(8/7), (51/7), (27/7)],\n [-(61/7), (8/7), (60/7)]])\nb = np.array([\n [-(4/7), -(59/7), -5],\n [(34/7), -(37/7), (30/7)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -9 \\\\\n 4 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -9 \\\\\n -8 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{11}{\\sqrt{5187}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-9],\n [4],\n [-5]]).squeeze()\nb = np.array([\n [8],\n [-9],\n [-8],\n [-8]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n \\frac{9}{2} \\\\\n -\\frac{17}{4} \\\\\n -\\frac{27}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{27}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [(9/2)],\n [-(17/4)],\n [-(27/4)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n 1 & -1 \\\\\n -5 & -4 \\\\\n 4 & -3 \\\\\n 0 & 3 \\\\\n 7 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1],\n [-5, -4],\n [4, -3],\n [0, 3],\n [7, -1]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -8 & 1 & -9 \\\\\n 1 & 8 & -2 \\\\\n 5 & -6 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+32 x+500$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 1, -9],\n [1, 8, -2],\n [5, -6, 0]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 7 \\\\\n \\frac{2}{5} \\\\\n \\frac{8}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{4}{5} \\\\\n 6 \\\\\n \\frac{24}{5} \\\\\n \\frac{18}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1102}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [7],\n [(2/5)],\n [(8/5)]])\nb = np.array([\n [(4/5)],\n [6],\n [(24/5)],\n [(18/5)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,3,3\\}, \\left\\{-4,3,-\\frac{3}{2}\\right\\}, \\left\\{3,-3,\\frac{5}{2}\\right\\}}$.", - "Output Answer": [ - "$6 x+7 y+3=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, 3, 3],\n [-4, 3, -(3/2)],\n [3, -3, (5/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & 0 & 3 \\\\\n 3 & -1 & 1 \\\\\n 3 & -3 & -1 \\\\\n 3 & -3 & 1 \\\\\n 1 & -3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.66 \\\\\n -0.36 \\\\\n -0.13 \\\\\n -2.85 \\\\\n -0.14 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.638 \\\\\n -0.247 \\\\\n 0.165 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, 3],\n [3, -1, 1],\n [3, -3, -1],\n [3, -3, 1],\n [1, -3, -3]])\nb = np.array([\n [2.66],\n [-0.36],\n [-0.13],\n [-2.85],\n [-0.14]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -9 & -2 & 8 \\\\\n -10 & 1 & -2 \\\\\n 1 & -5 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-11.562-4.218 i,-11.562+4.218 i,5.123\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -2, 8],\n [-10, 1, -2],\n [1, -5, -10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -5 \\\\\n -6 \\\\\n -1 \\\\\n -2 \\\\\n 1 \\\\\n 7 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$31$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-5],\n [-6],\n [-1],\n [-2],\n [1],\n [7],\n [-4]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${1, -3}$ to the line $x+2 y-2=0$.", - "Output Answer": [ - "$\\frac{7}{\\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 1, -3\nline = Poly(x+2*y-2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, 3}$ to the line $2 x-\\frac{16 y}{5}+\\frac{3}{10}=0$.", - "Output Answer": [ - "$\\frac{153}{4 \\sqrt{89}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, 3\nline = Poly(2*x-((16*y)/5)+(3/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-18$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [1]])\nb = np.array([\n [-2],\n [-4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 9 & -6 & 3 \\\\\n 7 & -2 & 0 \\\\\n 9 & 9 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-0.488-5.335 i,-0.488+5.335 i,10.975\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -6, 3],\n [7, -2, 0],\n [9, 9, 3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-3]])\nb = np.array([\n [-7],\n [5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,-4,0\\}, \\{-4,-4,4\\}, \\{0,-5,4\\}}$.", - "Output Answer": [ - "$4 x+16 y+3 z+68=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, -4, 0],\n [-4, -4, 4],\n [0, -5, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{7}{2}, -\\frac{7}{2}, \\frac{1}{2}}$ to the plane $\\frac{7 x}{2}-2 y+3 z+\\frac{7}{2}=0$.", - "Output Answer": [ - "$\\frac{97}{2 \\sqrt{101}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (7/2), -(7/2), (1/2)\nplane = Poly(((7*x)/2)-2*y+3*z+(7/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -1 & -1 & 2 \\\\\n -1 & -1 & 1 \\\\\n 3 & -2 & 2 \\\\\n -1 & -2 & 2 \\\\\n -2 & 2 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 0 & 3 & 1 & 1 & 1 \\\\\n -1 & 1 & 0 & 1 & 3 \\\\\n -1 & -2 & 0 & -3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -1 & -8 & -1 & -8 & -6 \\\\\n 0 & -6 & -1 & -5 & -5 \\\\\n 0 & 3 & 3 & -5 & -5 \\\\\n 0 & -9 & -1 & -9 & -9 \\\\\n -4 & -8 & -2 & -6 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, 2],\n [-1, -1, 1],\n [3, -2, 2],\n [-1, -2, 2],\n [-2, 2, 2]])\nb = np.array([\n [0, 3, 1, 1, 1],\n [-1, 1, 0, 1, 3],\n [-1, -2, 0, -3, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -6 & -7 & 7 & 0 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 6 & 5 & -9 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -12 & -12 & 16 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -7, 7, 0]])\nb = np.array([\n [6, 5, -9, -8]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{3}{2}, 5, -\\frac{7}{2}}$ to the plane $-\\frac{3 x}{2}-\\frac{5 y}{2}-z-\\frac{9}{2}=0$.", - "Output Answer": [ - "$\\frac{45}{2 \\sqrt{38}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(3/2), 5, -(7/2)\nplane = Poly(-((3*x)/2)-((5*y)/2)-z-(9/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & -8 \\\\\n 0 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2,1\\}, \\{1,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -8],\n [0, -4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{2}{7}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 10 & 0 & 9 & -9 \\\\\n 6 & 9 & 6 & -1 \\\\\n -2 & -10 & -4 & -10 \\\\\n -10 & -4 & 8 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{20}{7} & 0 & \\frac{18}{7} & -\\frac{18}{7} \\\\\n \\frac{12}{7} & \\frac{18}{7} & \\frac{12}{7} & -\\frac{2}{7} \\\\\n -\\frac{4}{7} & -\\frac{20}{7} & -\\frac{8}{7} & -\\frac{20}{7} \\\\\n -\\frac{20}{7} & -\\frac{8}{7} & \\frac{16}{7} & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 0, 9, -9],\n [6, 9, 6, -1],\n [-2, -10, -4, -10],\n [-10, -4, 8, 7]])\nprint(a * (2/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{35}{16} \\\\\n -\\frac{9}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{35}{\\sqrt{2521}} \\\\\n -\\frac{36}{\\sqrt{2521}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(35/16)],\n [-(9/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -3 & -4 & 2 \\\\\n -4 & 0 & 3 \\\\\n -4 & 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & \\frac{1}{2} & -\\frac{3}{4} \\\\\n -\\frac{1}{4} & \\frac{1}{8} & \\frac{1}{16} \\\\\n 0 & 1 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -4, 2],\n [-4, 0, 3],\n [-4, 0, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\log (2) \\\\\n 14 \\log (2) \\\\\n 11 \\log (2) \\\\\n 9 \\log (2) \\\\\n -13 \\log (2) \\\\\n -7 \\log (2) \\\\\n -4 \\log (2) \\\\\n -10 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\log (2) \\\\\n -\\log (2) \\\\\n -4 \\log (2) \\\\\n 4 \\log (2) \\\\\n -14 \\log (2) \\\\\n -6 \\log (2) \\\\\n \\log (2) \\\\\n 5 \\log (2) \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$156 \\log ^2(2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-4*math.log(2)],\n [14*math.log(2)],\n [11*math.log(2)],\n [9*math.log(2)],\n [-13*math.log(2)],\n [-7*math.log(2)],\n [-4*math.log(2)],\n [-10*math.log(2)]])\nb = np.array([\n [-2*math.log(2)],\n [-math.log(2)],\n [-4*math.log(2)],\n [4*math.log(2)],\n [-14*math.log(2)],\n [-6*math.log(2)],\n [math.log(2)],\n [5*math.log(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{3 \\log (2),-\\log (2),0\\}, \\{3 \\log (2),-3 \\log (2),0\\}, \\{4 \\log (2),-3 \\log (2),3 \\log (2)\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{3}{\\sqrt{10}},-\\frac{1}{\\sqrt{10}},0\\right\\}, \\left\\{-\\frac{1}{\\sqrt{10}},-\\frac{3}{\\sqrt{10}},0\\right\\}, \\{0,0,1\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((3*math.log(2), -math.log(2), 0), (3*math.log(2), -3*math.log(2), 0), (4*math.log(2), -3*math.log(2), 3*math.log(2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,-1,4\\}, \\left\\{-\\frac{2}{3},4,\\frac{1}{3}\\right\\}, \\left\\{\\frac{5}{3},-\\frac{4}{3},\\frac{14}{3}\\right\\}}$.", - "Output Answer": [ - "$19 x-129 y-169 z+585=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, -1, 4],\n [-(2/3), 4, (1/3)],\n [(5/3), -(4/3), (14/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{5}{2}, -\\frac{9}{2}, -3}$ to the plane $-\\frac{3 x}{2}-y+\\frac{z}{2}-\\frac{1}{2}=0$.", - "Output Answer": [ - "$\\frac{5}{2 \\sqrt{14}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (5/2), -(9/2), -3\nplane = Poly(-((3*x)/2)-y+(z/2)-(1/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 0 & -3 \\\\\n -2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & -\\frac{1}{2} \\\\\n -\\frac{1}{3} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3],\n [-2, -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,1,1\\}, \\{2,0,1\\}, \\{0,2,-3\\}}$", - "Output Answer": [ - "${\\left\\{-\\sqrt{\\frac{2}{3}},\\frac{1}{\\sqrt{6}},\\frac{1}{\\sqrt{6}}\\right\\}, \\left\\{\\sqrt{\\frac{2}{7}},\\frac{1}{\\sqrt{14}},\\frac{3}{\\sqrt{14}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{21}},\\frac{4}{\\sqrt{21}},-\\frac{2}{\\sqrt{21}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, 1, 1), (2, 0, 1), (0, 2, -3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{4} & 4 & 2 \\\\\n -\\frac{7}{4} & \\frac{15}{4} & 0 \\\\\n -\\frac{5}{2} & -\\frac{13}{4} & -\\frac{11}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{220}{177} & \\frac{32}{59} & -\\frac{160}{177} \\\\\n -\\frac{308}{531} & \\frac{92}{177} & -\\frac{224}{531} \\\\\n \\frac{964}{531} & -\\frac{196}{177} & \\frac{508}{531} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/4), 4, 2],\n [-(7/4), (15/4), 0],\n [-(5/2), -(13/4), -(11/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -1 & -8 & 10 \\\\\n -8 & 10 & 5 \\\\\n 3 & 6 & 5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 4 & -5 & 5 \\\\\n -7 & -3 & -3 \\\\\n -2 & -8 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -5 & -3 & 5 \\\\\n -1 & 13 & 8 \\\\\n 5 & 14 & 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -8, 10],\n [-8, 10, 5],\n [3, 6, 5]])\nb = np.array([\n [4, -5, 5],\n [-7, -3, -3],\n [-2, -8, -5]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{23}{5} & \\frac{8}{5} & 0 \\\\\n \\frac{2}{5} & -1 & 2 \\\\\n -\\frac{16}{5} & -\\frac{1}{5} & -\\frac{21}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{3589}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/5), (8/5), 0],\n [(2/5), -1, 2],\n [-(16/5), -(1/5), -(21/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{46}{7} \\\\\n 6 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -\\frac{39}{7} \\\\\n \\frac{40}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{201}{7} \\\\\n \\frac{2036}{49} \\\\\n \\frac{2970}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(46/7)],\n [6],\n [-1]])\nb = np.array([\n [-4],\n [-(39/7)],\n [(40/7)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 0 \\\\\n -8 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$19$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [0],\n [-8],\n [-8]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{9}{2} & \\frac{19}{2} & \\frac{11}{2} \\\\\n \\frac{19}{2} & -\\frac{11}{2} & \\frac{3}{2} \\\\\n -\\frac{1}{2} & 2 & -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.045,-0.599,1.\\}, \\{2.068,-2.58,1.\\}, \\{9.158,8.497,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2), (19/2), (11/2)],\n [(19/2), -(11/2), (3/2)],\n [-(1/2), 2, -(15/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $3$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 5 & -5 & -6 \\\\\n 7 & -9 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 15 & -15 & -18 \\\\\n 21 & -27 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -5, -6],\n [7, -9, 0]])\nprint(a * 3)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $2$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -9 & 2 & 10 & 4 \\\\\n 6 & 1 & -4 & -9 \\\\\n 7 & -2 & -6 & -4 \\\\\n 1 & 4 & 7 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -18 & 4 & 20 & 8 \\\\\n 12 & 2 & -8 & -18 \\\\\n 14 & -4 & -12 & -8 \\\\\n 2 & 8 & 14 & -16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 2, 10, 4],\n [6, 1, -4, -9],\n [7, -2, -6, -4],\n [1, 4, 7, -8]])\nprint(a * 2)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -2 & 3 & -1 & 2 \\\\\n 3 & -2 & 0 & -2 \\\\\n -1 & 3 & 1 & 0 \\\\\n -3 & -2 & -1 & 0 \\\\\n 2 & 3 & 0 & 0 \\\\\n 1 & -2 & 3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.26 \\\\\n -2.82 \\\\\n 0.24 \\\\\n -0.91 \\\\\n -1.96 \\\\\n -1.4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.09 \\\\\n -0.391 \\\\\n 0.775 \\\\\n 1.976 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 3, -1, 2],\n [3, -2, 0, -2],\n [-1, 3, 1, 0],\n [-3, -2, -1, 0],\n [2, 3, 0, 0],\n [1, -2, 3, -2]])\nb = np.array([\n [1.26],\n [-2.82],\n [0.24],\n [-0.91],\n [-1.96],\n [-1.4]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -1 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 4 \\\\\n -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 41 \\\\\n 44 \\\\\n 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-1],\n [-10]])\nb = np.array([\n [-4],\n [4],\n [-1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & 2 & -5 \\\\\n 0 & 1 & -3 \\\\\n -6 & -5 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.987,4.907,1.\\}, \\{-0.567,-0.278,1.\\}, \\{0.745,0.943,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, -5],\n [0, 1, -3],\n [-6, -5, 7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{43}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{26}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{17}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(43/9)]])\nb = np.array([\n [(26/9)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 7 & -10 & -6 \\\\\n -8 & 5 & -5 \\\\\n -9 & -6 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+17 x^2+69 x-1443$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -10, -6],\n [-8, 5, -5],\n [-9, -6, 5]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(2 \\sqrt{6}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [0],\n [0],\n [-1],\n [1],\n [1],\n [0]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [0],\n [1],\n [1],\n [1],\n [1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\sqrt{2} \\\\\n -5 \\sqrt{2} \\\\\n -4 \\sqrt{2} \\\\\n 3 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\sqrt{2} \\\\\n 0 \\\\\n -4 \\sqrt{2} \\\\\n \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$62$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [2*math.sqrt(2)],\n [-5*math.sqrt(2)],\n [-4*math.sqrt(2)],\n [3*math.sqrt(2)]])\nb = np.array([\n [6*math.sqrt(2)],\n [0],\n [-4*math.sqrt(2)],\n [math.sqrt(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -2 \\\\\n 0 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{0,\\frac{1}{11},\\frac{1}{11},0,\\frac{3}{11}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-2],\n [0],\n [2],\n [1]]).squeeze()\nb = np.array([\n [0],\n [1],\n [1],\n [0],\n [3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 10 & -4 \\\\\n 2 & 9 \\\\\n -7 & 5 \\\\\n 1 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [10, -4],\n [2, 9],\n [-7, 5],\n [1, 9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{49}{5} \\\\\n -\\frac{38}{5} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{14}{5} \\\\\n -\\frac{68}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(49/5)],\n [-(38/5)]])\nb = np.array([\n [7],\n [6]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -4 & 9 & -9 & 2 \\\\\n 7 & -7 & -3 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -5 & -3 & 10 & 1 \\\\\n 5 & -1 & -6 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -9 & 6 & 1 & 3 \\\\\n 12 & -8 & -9 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 9, -9, 2],\n [7, -7, -3, 1]])\nb = np.array([\n [-5, -3, 10, 1],\n [5, -1, -6, -3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -8 & \\frac{31}{4} \\\\\n -\\frac{19}{4} & -\\frac{29}{4} \\\\\n -\\frac{25}{4} & -10 \\\\\n -\\frac{11}{4} & \\frac{9}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{4} & \\frac{5}{4} \\\\\n \\frac{13}{2} & 2 \\\\\n 5 & \\frac{21}{4} \\\\\n -6 & \\frac{39}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{37}{4} & \\frac{13}{2} \\\\\n -\\frac{45}{4} & -\\frac{37}{4} \\\\\n -\\frac{45}{4} & -\\frac{61}{4} \\\\\n \\frac{13}{4} & -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, (31/4)],\n [-(19/4), -(29/4)],\n [-(25/4), -10],\n [-(11/4), (9/4)]])\nb = np.array([\n [(5/4), (5/4)],\n [(13/2), 2],\n [5, (21/4)],\n [-6, (39/4)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$33$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-3]])\nb = np.array([\n [-2],\n [-5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 9 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 8 \\\\\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 9 \\\\\n 135 \\\\\n -126 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [9],\n [9]])\nb = np.array([\n [6],\n [8],\n [9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n 2 \\sqrt{3} \\\\\n -3 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n -4 \\sqrt{3} \\\\\n -\\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\sqrt{3} \\\\\n 2 \\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n -4 \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n -3 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n 6 \\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$12 \\sqrt{6}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-3*math.sqrt(3)],\n [3*math.sqrt(3)],\n [2*math.sqrt(3)],\n [-3*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [-4*math.sqrt(3)],\n [-math.sqrt(3)],\n [3*math.sqrt(3)]])\nb = np.array([\n [-4*math.sqrt(3)],\n [2*math.sqrt(3)],\n [-2*math.sqrt(3)],\n [-4*math.sqrt(3)],\n [math.sqrt(3)],\n [-3*math.sqrt(3)],\n [3*math.sqrt(3)],\n [6*math.sqrt(3)],\n [-2*math.sqrt(3)],\n [-5*math.sqrt(3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -10 \\\\\n 9 \\\\\n 6 \\\\\n -6 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$34$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-10],\n [9],\n [6],\n [-6],\n [2]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 1 & -\\frac{1}{3} \\\\\n -\\frac{4}{3} & -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{17}{3} & \\frac{11}{3} \\\\\n -\\frac{13}{3} & \\frac{17}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{14}{3} & \\frac{10}{3} \\\\\n -\\frac{17}{3} & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(1/3)],\n [-(4/3), -(11/3)]])\nb = np.array([\n [-(17/3), (11/3)],\n [-(13/3), (17/3)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n \\frac{5}{3} & -\\frac{14}{9} & \\frac{7}{3} & \\frac{17}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{22}{9} & -\\frac{8}{3} & \\frac{5}{3} \\\\\n -\\frac{1}{3} & -\\frac{11}{9} & -\\frac{1}{9} \\\\\n \\frac{23}{9} & \\frac{5}{3} & \\frac{5}{3} \\\\\n -\\frac{16}{9} & -\\frac{5}{9} & -\\frac{1}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{583}{81} & \\frac{8}{27} & \\frac{179}{27} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3), -(14/9), (7/3), (17/9)]])\nb = np.array([\n [(22/9), -(8/3), (5/3)],\n [-(1/3), -(11/9), -(1/9)],\n [(23/9), (5/3), (5/3)],\n [-(16/9), -(5/9), -(1/9)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n 8 & 2 & -8 \\\\\n -4 & -9 & -1 \\\\\n 5 & 8 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 2, -8],\n [-4, -9, -1],\n [5, 8, 4]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & \\frac{17}{4} \\\\\n \\frac{3}{4} & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{3} \\left(-10-\\sqrt{151}\\right),1\\right\\}, \\left\\{\\frac{1}{3} \\left(\\sqrt{151}-10\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, (17/4)],\n [(3/4), 8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 5 & 10 & -7 \\\\\n 7 & -4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & -\\frac{14}{45} \\\\\n 0 & 1 & -\\frac{49}{90} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, 10, -7],\n [7, -4, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{13}{3},0,\\frac{13}{3}\\right\\}, \\left\\{\\frac{4}{3},\\frac{1}{3},\\frac{10}{3}\\right\\}, \\left\\{\\frac{4}{3},-\\frac{13}{3},-\\frac{7}{3}\\right\\}}$.", - "Output Answer": [ - "$177 x+459 y-378 z+871=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(13/3), 0, (13/3)],\n [(4/3), (1/3), (10/3)],\n [(4/3), -(13/3), -(7/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,1,2\\}, \\{-3,-2,-2\\}, \\{-3,3,-3\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{2}{3},\\frac{1}{3},\\frac{2}{3}\\right\\}, \\left\\{-\\frac{3}{\\sqrt{17}},-\\frac{2}{\\sqrt{17}},-\\frac{2}{\\sqrt{17}}\\right\\}, \\left\\{-\\frac{2}{3 \\sqrt{17}},\\frac{10}{3 \\sqrt{17}},-\\frac{7}{3 \\sqrt{17}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, 1, 2), (-3, -2, -2), (-3, 3, -3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{5} \\\\\n \\frac{7}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n \\frac{13}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{156}{197},-\\frac{676}{985}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/5)],\n [(7/5)]]).squeeze()\nb = np.array([\n [-3],\n [(13/5)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{5}{\\sqrt{3}},0,\\sqrt{3}\\right\\}, \\left\\{-\\sqrt{3},-\\frac{2}{\\sqrt{3}},\\frac{5}{\\sqrt{3}}\\right\\}, \\left\\{0,0,\\frac{4}{\\sqrt{3}}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{5}{\\sqrt{34}},0,\\frac{3}{\\sqrt{34}}\\right\\}, \\left\\{-\\frac{3}{\\sqrt{38}},-\\sqrt{\\frac{2}{19}},\\frac{5}{\\sqrt{38}}\\right\\}, \\left\\{-\\frac{20}{323} \\sqrt{\\frac{3}{\\frac{119200}{312987}+\\left(\\frac{26}{19 \\sqrt{3}}-\\frac{6 \\sqrt{3}}{17}\\right)^2}},\\frac{20}{19 \\sqrt{3 \\left(\\frac{119200}{312987}+\\left(\\frac{26}{19 \\sqrt{3}}-\\frac{6 \\sqrt{3}}{17}\\right)^2\\right)}},\\frac{\\frac{26}{19 \\sqrt{3}}-\\frac{6 \\sqrt{3}}{17}}{\\sqrt{\\frac{119200}{312987}+\\left(\\frac{26}{19 \\sqrt{3}}-\\frac{6 \\sqrt{3}}{17}\\right)^2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((5/(math.sqrt(3))), 0, math.sqrt(3)), (-math.sqrt(3), -(2/(math.sqrt(3))), (5/(math.sqrt(3)))), (0, 0, (4/(math.sqrt(3))))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 3 \\\\\n -4 \\\\\n 1 \\\\\n -4 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 3 \\\\\n -8 \\\\\n 9 \\\\\n 1 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$41$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [3],\n [-4],\n [1],\n [-4],\n [0]])\nb = np.array([\n [1],\n [3],\n [-8],\n [9],\n [1],\n [-3]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & -6 \\\\\n -1 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-17 x+66$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -6],\n [-1, 8]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & -7 & -1 \\\\\n -3 & 5 & -3 \\\\\n -5 & -1 & 4 \\\\\n 5 & 8 & -4 \\\\\n -10 & 8 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, -7, -1],\n [-3, 5, -3],\n [-5, -1, 4],\n [5, 8, -4],\n [-10, 8, -7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -4 & 3 \\\\\n 3 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{5}{29} & \\frac{3}{29} \\\\\n \\frac{3}{29} & \\frac{4}{29} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 3],\n [3, 5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{9}{4}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -4 & -1 & -2 & -5 \\\\\n -4 & -10 & -10 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -9 & -\\frac{9}{4} & -\\frac{9}{2} & -\\frac{45}{4} \\\\\n -9 & -\\frac{45}{2} & -\\frac{45}{2} & 18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -1, -2, -5],\n [-4, -10, -10, 8]])\nprint(a * (9/4))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{27}{5} & \\frac{19}{5} \\\\\n -\\frac{34}{5} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{68} \\left(-47-5 i \\sqrt{15}\\right),1\\right\\}, \\left\\{\\frac{1}{68} \\left(-47+5 i \\sqrt{15}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(27/5), (19/5)],\n [-(34/5), -4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{5} \\\\\n -\\frac{2}{5} \\\\\n \\frac{1}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{8}{5} \\\\\n \\frac{13}{5} \\\\\n -\\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{80}{297},-\\frac{130}{297},\\frac{80}{297}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/5)],\n [-(2/5)],\n [(1/5)]]).squeeze()\nb = np.array([\n [(8/5)],\n [(13/5)],\n [-(8/5)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n -1 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{3}{2} \\\\\n 0 \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{0,\\frac{3}{17},0,\\frac{5}{17}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2)],\n [-1],\n [-2],\n [1]]).squeeze()\nb = np.array([\n [0],\n [-(3/2)],\n [0],\n [-(5/2)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{39}{10} & -\\frac{177}{100} & -\\frac{351}{100} \\\\\n \\frac{17}{25} & \\frac{19}{10} & -\\frac{89}{25} \\\\\n -\\frac{559}{100} & \\frac{447}{100} & -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{27 x^2}{10}+\\frac{443941 x}{10000}-\\frac{47163267}{500000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(39/10), -(177/100), -(351/100)],\n [(17/25), (19/10), -(89/25)],\n [-(559/100), (447/100), -(17/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -1 & 1 & 6 \\\\\n -1 & -3 & -7 \\\\\n -7 & 9 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+4 x^2-77 x-162$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, 6],\n [-1, -3, -7],\n [-7, 9, 8]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{34}{5} & \\frac{34}{5} & -\\frac{39}{5} \\\\\n \\frac{23}{5} & -\\frac{23}{5} & \\frac{12}{5} \\\\\n -\\frac{46}{5} & \\frac{26}{5} & -\\frac{3}{5} \\\\\n -\\frac{38}{5} & -\\frac{33}{5} & -\\frac{23}{5} \\\\\n \\frac{34}{5} & -\\frac{4}{5} & \\frac{33}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(34/5), (34/5), -(39/5)],\n [(23/5), -(23/5), (12/5)],\n [-(46/5), (26/5), -(3/5)],\n [-(38/5), -(33/5), -(23/5)],\n [(34/5), -(4/5), (33/5)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{3} & -\\frac{1}{3} \\\\\n \\frac{11}{3} & \\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{2}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/3), -(1/3)],\n [(11/3), (5/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -5 & -6 & -4 \\\\\n 3 & 3 & 8 \\\\\n 10 & -7 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, -6, -4],\n [3, 3, 8],\n [10, -7, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 5 & -5 \\\\\n -2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -5],\n [-2, 2]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n -5 \\\\\n 5 \\\\\n -2 \\\\\n -6 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -10 \\\\\n 3 \\\\\n -4 \\\\\n 6 \\\\\n 5 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{103}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [-5],\n [5],\n [-2],\n [-6],\n [-3]])\nb = np.array([\n [1],\n [-10],\n [3],\n [-4],\n [6],\n [5],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{13}{5}, 0, -\\frac{21}{5}}$ to the plane $\\frac{7 x}{5}-\\frac{6 y}{5}-\\frac{7 z}{5}-\\frac{12}{5}=0$.", - "Output Answer": [ - "$\\frac{89 \\sqrt{\\frac{2}{67}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (13/5), 0, -(21/5)\nplane = Poly(((7*x)/5)-((6*y)/5)-((7*z)/5)-(12/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 3 & -3 & 0 & -2 & 1 \\\\\n -2 & 3 & 1 & -2 & 0 \\\\\n 2 & -1 & 0 & 2 & -3 \\\\\n -3 & 3 & -2 & -1 & 2 \\\\\n -1 & -3 & 2 & -2 & -3 \\\\\n 0 & -2 & -1 & -1 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.14 \\\\\n 0.61 \\\\\n 2.31 \\\\\n -0.13 \\\\\n 0.27 \\\\\n -0.35 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.246 \\\\\n 0.458 \\\\\n 0.016 \\\\\n 0.08 \\\\\n -0.57 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -3, 0, -2, 1],\n [-2, 3, 1, -2, 0],\n [2, -1, 0, 2, -3],\n [-3, 3, -2, -1, 2],\n [-1, -3, 2, -2, -3],\n [0, -2, -1, -1, -2]])\nb = np.array([\n [-1.14],\n [0.61],\n [2.31],\n [-0.13],\n [0.27],\n [-0.35]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -4 \\\\\n 4 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -6 \\\\\n 7 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-4],\n [4],\n [1]])\nb = np.array([\n [10],\n [-6],\n [7],\n [7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -2 & -3 & -3 & 3 & -2 \\\\\n -1 & 0 & 3 & 3 & 2 \\\\\n 0 & -1 & 1 & 0 & 3 \\\\\n 3 & 3 & 2 & -1 & 0 \\\\\n -1 & -3 & -3 & -3 & 2 \\\\\n 0 & 3 & -1 & 2 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.47 \\\\\n 2.61 \\\\\n -0.48 \\\\\n 2.15 \\\\\n 2.08 \\\\\n 1.81 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.786 \\\\\n -0.251 \\\\\n -0.224 \\\\\n 0.419 \\\\\n 0.509 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, -3, 3, -2],\n [-1, 0, 3, 3, 2],\n [0, -1, 1, 0, 3],\n [3, 3, 2, -1, 0],\n [-1, -3, -3, -3, 2],\n [0, 3, -1, 2, 3]])\nb = np.array([\n [0.47],\n [2.61],\n [-0.48],\n [2.15],\n [2.08],\n [1.81]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & 0 & -3 & -3 & -1 \\\\\n -1 & -1 & -1 & -2 & -1 \\\\\n -2 & 2 & 3 & -1 & -1 \\\\\n -3 & -3 & -1 & 2 & 0 \\\\\n -3 & 1 & -1 & 3 & -2 \\\\\n 2 & -1 & -3 & 2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.18 \\\\\n 1.7 \\\\\n -0.81 \\\\\n -1.35 \\\\\n 2.84 \\\\\n 2.63 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.055 \\\\\n 0.59 \\\\\n -0.71 \\\\\n -0.014 \\\\\n -0.499 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, -3, -3, -1],\n [-1, -1, -1, -2, -1],\n [-2, 2, 3, -1, -1],\n [-3, -3, -1, 2, 0],\n [-3, 1, -1, 3, -2],\n [2, -1, -3, 2, -3]])\nb = np.array([\n [2.18],\n [1.7],\n [-0.81],\n [-1.35],\n [2.84],\n [2.63]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{4}{\\sqrt{3}},\\frac{2}{\\sqrt{3}},-\\sqrt{3}\\right\\}, \\left\\{-\\frac{5}{\\sqrt{3}},\\frac{4}{\\sqrt{3}},-\\sqrt{3}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{3}},\\frac{4}{\\sqrt{3}},\\frac{1}{\\sqrt{3}}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{4}{\\sqrt{29}},\\frac{2}{\\sqrt{29}},-\\frac{3}{\\sqrt{29}}\\right\\}, \\left\\{\\frac{1}{3 \\sqrt{29}},\\frac{14}{3 \\sqrt{29}},\\frac{8}{3 \\sqrt{29}}\\right\\}, \\{0,0,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-(4/(math.sqrt(3))), (2/(math.sqrt(3))), -math.sqrt(3)), (-(5/(math.sqrt(3))), (4/(math.sqrt(3))), -math.sqrt(3)), (-(1/(math.sqrt(3))), (4/(math.sqrt(3))), (1/(math.sqrt(3))))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{8} \\\\\n -\\frac{17}{8} \\\\\n 1 \\\\\n \\frac{3}{2} \\\\\n \\frac{5}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{13}{\\sqrt{691}} \\\\\n -\\frac{17}{\\sqrt{691}} \\\\\n \\frac{8}{\\sqrt{691}} \\\\\n \\frac{12}{\\sqrt{691}} \\\\\n \\frac{5}{\\sqrt{691}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/8)],\n [-(17/8)],\n [1],\n [(3/2)],\n [(5/8)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & 3 \\\\\n 1 & -2 & 0 \\\\\n 1 & -3 & 3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 7 & -23 & 45 \\\\\n 5 & -14 & 6 \\\\\n 9 & -29 & 39 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, 3],\n [1, -2, 0],\n [1, -3, 3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -5 & -1 & 8 & 7 & 10 \\\\\n 9 & -6 & -6 & 7 & 8 \\\\\n -9 & 6 & 3 & 3 & 4 \\\\\n -8 & -8 & 2 & -1 & 10 \\\\\n 0 & -1 & -2 & -10 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, -1, 8, 7, 10],\n [9, -6, -6, 7, 8],\n [-9, 6, 3, 3, 4],\n [-8, -8, 2, -1, 10],\n [0, -1, -2, -10, 2]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n -\\frac{11}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{5}{\\sqrt{146}} \\\\\n 0 \\\\\n -\\frac{11}{\\sqrt{146}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [-(11/5)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{2}{5} \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n \\frac{2}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{18}{5} \\\\\n \\frac{2}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/5)],\n [0]])\nb = np.array([\n [-4],\n [(2/5)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 5 \\\\\n -9 \\\\\n -8 \\\\\n -3 \\\\\n -3 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 6 \\\\\n 7 \\\\\n -9 \\\\\n 1 \\\\\n -5 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{379}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [5],\n [-9],\n [-8],\n [-3],\n [-3],\n [-7]])\nb = np.array([\n [3],\n [6],\n [7],\n [-9],\n [1],\n [-5],\n [-8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 3 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 7 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 82 \\\\\n 2 \\\\\n -65 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [3],\n [-10]])\nb = np.array([\n [3],\n [7],\n [4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, -1}$ to the line $-4 x+4 y-2=0$.", - "Output Answer": [ - "$\\frac{9}{2 \\sqrt{2}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, -1\nline = Poly(-4*x+4*y-2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 8 & \\frac{28}{3} \\\\\n -\\frac{22}{3} & -\\frac{5}{3} \\\\\n 2 & -\\frac{11}{3} \\\\\n \\frac{35}{6} & -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{31}{6} & \\frac{49}{6} \\\\\n -\\frac{17}{3} & 5 \\\\\n \\frac{25}{3} & \\frac{17}{6} \\\\\n \\frac{53}{6} & -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{79}{6} & \\frac{35}{2} \\\\\n -13 & \\frac{10}{3} \\\\\n \\frac{31}{3} & -\\frac{5}{6} \\\\\n \\frac{44}{3} & -\\frac{10}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, (28/3)],\n [-(22/3), -(5/3)],\n [2, -(11/3)],\n [(35/6), -(8/3)]])\nb = np.array([\n [(31/6), (49/6)],\n [-(17/3), 5],\n [(25/3), (17/6)],\n [(53/6), -(2/3)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 2 \\\\\n -3 \\\\\n -6 \\\\\n -4 \\\\\n -9 \\\\\n 10 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -1 \\\\\n 2 \\\\\n -8 \\\\\n -8 \\\\\n -5 \\\\\n -8 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [2],\n [-3],\n [-6],\n [-4],\n [-9],\n [10],\n [5]])\nb = np.array([\n [2],\n [-1],\n [2],\n [-8],\n [-8],\n [-5],\n [-8],\n [-6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -3 & -\\frac{3}{2} \\\\\n -2 & \\frac{5}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 12 & \\frac{3}{4} \\\\\n 1 & \\frac{37}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -(3/2)],\n [-2, (5/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 5 \\\\\n 5 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{2} \\left(3-\\sqrt{13}\\right),1\\right\\}, \\left\\{\\frac{1}{2} \\left(3+\\sqrt{13}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 5],\n [5, -7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{4}{3} \\\\\n 2 \\\\\n \\frac{4}{3} \\\\\n 3 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{3} \\\\\n 2 \\\\\n \\frac{8}{3} \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{280}{447},\\frac{80}{149},\\frac{320}{447},0\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3)],\n [2],\n [(4/3)],\n [3]]).squeeze()\nb = np.array([\n [-(7/3)],\n [2],\n [(8/3)],\n [0]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n -\\frac{3}{16} \\\\\n -\\frac{39}{16} \\\\\n -\\frac{41}{16} \\\\\n -\\frac{25}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{4}{5 \\sqrt{39}} \\\\\n -\\frac{\\sqrt{\\frac{3}{13}}}{10} \\\\\n -\\frac{\\sqrt{39}}{10} \\\\\n -\\frac{41}{10 \\sqrt{39}} \\\\\n -\\frac{5}{2 \\sqrt{39}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2)],\n [-(3/16)],\n [-(39/16)],\n [-(41/16)],\n [-(25/16)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 4 & 1 & 6 & 6 & -4 \\\\\n 6 & -4 & -9 & -8 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-15.,-72.,22.,0.,0.\\}, \\{-8.,-34.,0.,11.,0.\\}, \\{8.,12.,0.,0.,11.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, 1, 6, 6, -4],\n [6, -4, -9, -8, 0]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 2 \\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n 3 \\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n 3 \\sqrt{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\sqrt{5} \\\\\n 0 \\\\\n -4 \\sqrt{5} \\\\\n -2 \\sqrt{5} \\\\\n -3 \\sqrt{5} \\\\\n \\sqrt{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-155$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [2*math.sqrt(5)],\n [4*math.sqrt(5)],\n [3*math.sqrt(5)],\n [4*math.sqrt(5)],\n [3*math.sqrt(5)]])\nb = np.array([\n [2*math.sqrt(5)],\n [0],\n [-4*math.sqrt(5)],\n [-2*math.sqrt(5)],\n [-3*math.sqrt(5)],\n [math.sqrt(5)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 3 & -\\frac{11}{3} & \\frac{10}{3} \\\\\n \\frac{13}{3} & 7 & -\\frac{5}{3} \\\\\n 0 & \\frac{28}{3} & \\frac{22}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{4.211\\, -5.744 i,4.211\\, +5.744 i,8.911\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -(11/3), (10/3)],\n [(13/3), 7, -(5/3)],\n [0, (28/3), (22/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & -\\frac{17}{4} & -\\frac{19}{4} \\\\\n -\\frac{3}{2} & \\frac{17}{2} & \\frac{13}{4} \\\\\n \\frac{25}{4} & 9 & \\frac{31}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.769,1.074,1.\\}, \\{-0.192-0.689 i,-0.497+0.102 i,1.\\}, \\{-0.192+0.689 i,-0.497-0.102 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), -(17/4), -(19/4)],\n [-(3/2), (17/2), (13/4)],\n [(25/4), 9, (31/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{11}{2}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & 8 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 22 & 44 & \\frac{99}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 8, 9]])\nprint(a * (11/2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -2 & -\\frac{3}{2} \\\\\n 0 & -2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 4 & 6 \\\\\n 0 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -(3/2)],\n [0, -2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(-3 \\sqrt{2}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [1],\n [0],\n [-1],\n [0],\n [0]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [-1],\n [1],\n [-1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{6} \\\\\n -\\frac{4}{3} \\\\\n -\\frac{1}{2} \\\\\n \\frac{13}{6} \\\\\n -\\frac{7}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{7}{4} & \\frac{7}{6} \\\\\n 2 & \\frac{4}{3} \\\\\n \\frac{3}{4} & \\frac{1}{2} \\\\\n -\\frac{13}{4} & -\\frac{13}{6} \\\\\n \\frac{7}{4} & \\frac{7}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/6)],\n [-(4/3)],\n [-(1/2)],\n [(13/6)],\n [-(7/6)]])\nb = np.array([\n [-(3/2), -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 22 \\\\\n -58 \\\\\n -41 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [3],\n [-8]])\nb = np.array([\n [9],\n [2],\n [2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -9 \\\\\n -2 \\\\\n 7 \\\\\n -10 \\\\\n -6 \\\\\n 0 \\\\\n 1 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 1 \\\\\n -6 \\\\\n -7 \\\\\n 8 \\\\\n 9 \\\\\n 7 \\\\\n 7 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9 \\sqrt{15}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-9],\n [-2],\n [7],\n [-10],\n [-6],\n [0],\n [1],\n [-5]])\nb = np.array([\n [8],\n [1],\n [-6],\n [-7],\n [8],\n [9],\n [7],\n [7],\n [8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{17}{4} & -\\frac{21}{4} \\\\\n \\frac{29}{4} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{8} \\left(19-i \\sqrt{2211}\\right),\\frac{1}{8} \\left(19+i \\sqrt{2211}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/4), -(21/4)],\n [(29/4), (1/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n -9 & 8 & -8 \\\\\n 7 & -2 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 8, -8],\n [7, -2, -8]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -9 & -9 & 7 & -3 & 4 & 8 \\\\\n 6 & 5 & 2 & -1 & 7 & 1 \\\\\n 5 & 2 & -2 & 9 & -6 & -9 \\\\\n -2 & -3 & -3 & 2 & -3 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & \\frac{623}{242} & \\frac{5497}{726} \\\\\n 0 & 1 & 0 & 0 & -\\frac{525}{242} & -\\frac{6397}{726} \\\\\n 0 & 0 & 1 & 0 & \\frac{107}{242} & -\\frac{493}{242} \\\\\n 0 & 0 & 0 & 1 & -\\frac{367}{242} & -\\frac{2687}{726} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-9, -9, 7, -3, 4, 8],\n [6, 5, 2, -1, 7, 1],\n [5, 2, -2, 9, -6, -9],\n [-2, -3, -3, 2, -3, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 7 \\\\\n 7 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-1-\\sqrt{485}\\right),\\frac{1}{2} \\left(\\sqrt{485}-1\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 7],\n [7, -9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{50}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 0 & 0 \\\\\n 9 & 4 & 4 \\\\\n 4 & 1 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{25} & 0 & 0 \\\\\n -\\frac{9}{50} & -\\frac{2}{25} & -\\frac{2}{25} \\\\\n -\\frac{2}{25} & -\\frac{1}{50} & -\\frac{4}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, 0],\n [9, 4, 4],\n [4, 1, 8]])\nprint(a * -(1/50))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 4 \\\\\n 3 \\\\\n -5 \\\\\n 5 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -9 \\\\\n 6 \\\\\n -4 \\\\\n -7 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-39$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [4],\n [3],\n [-5],\n [5],\n [4]])\nb = np.array([\n [-7],\n [-9],\n [6],\n [-4],\n [-7],\n [-5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{349}{50} & \\frac{329}{50} & -\\frac{631}{100} & \\frac{149}{20} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{389}{100} & -\\frac{73}{100} & -\\frac{103}{20} & \\frac{369}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{1087}{100} & \\frac{117}{20} & -\\frac{573}{50} & \\frac{557}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(349/50), (329/50), -(631/100), (149/20)]])\nb = np.array([\n [(389/100), -(73/100), -(103/20), (369/100)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & -7 \\\\\n -6 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+8 x-30$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -7],\n [-6, -6]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{3} \\\\\n \\frac{7}{3} \\\\\n -\\frac{5}{6} \\\\\n \\frac{35}{6} \\\\\n \\frac{25}{3} \\\\\n -\\frac{16}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{73}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/3)],\n [(7/3)],\n [-(5/6)],\n [(35/6)],\n [(25/3)],\n [-(16/3)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -7 & -10 & -\\frac{29}{4} \\\\\n -8 & \\frac{11}{4} & \\frac{7}{2} \\\\\n -\\frac{21}{4} & -\\frac{35}{4} & \\frac{5}{2} \\\\\n -\\frac{37}{4} & \\frac{5}{2} & \\frac{23}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{2} & -\\frac{15}{2} & -9 \\\\\n \\frac{13}{2} & -\\frac{39}{4} & -4 \\\\\n -\\frac{35}{4} & -\\frac{13}{4} & -\\frac{17}{4} \\\\\n -\\frac{19}{2} & \\frac{23}{4} & \\frac{13}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{25}{2} & -\\frac{35}{2} & -\\frac{65}{4} \\\\\n -\\frac{3}{2} & -7 & -\\frac{1}{2} \\\\\n -14 & -12 & -\\frac{7}{4} \\\\\n -\\frac{75}{4} & \\frac{33}{4} & \\frac{49}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -10, -(29/4)],\n [-8, (11/4), (7/2)],\n [-(21/4), -(35/4), (5/2)],\n [-(37/4), (5/2), (23/4)]])\nb = np.array([\n [-(11/2), -(15/2), -9],\n [(13/2), -(39/4), -4],\n [-(35/4), -(13/4), -(17/4)],\n [-(19/2), (23/4), (13/2)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 5 & 5 \\\\\n -4 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{9} & -\\frac{1}{9} \\\\\n \\frac{4}{45} & \\frac{1}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 5],\n [-4, 5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{8}{5}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & -10 & 10 \\\\\n 4 & -7 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{32}{5} & -16 & 16 \\\\\n \\frac{32}{5} & -\\frac{56}{5} & -\\frac{24}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -10, 10],\n [4, -7, -3]])\nprint(a * (8/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{10}{3} & -1 & -\\frac{10}{3} \\\\\n \\frac{23}{6} & \\frac{1}{3} & -\\frac{5}{3} \\\\\n \\frac{5}{6} & -1 & \\frac{7}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{2573}{108}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(10/3), -1, -(10/3)],\n [(23/6), (1/3), -(5/3)],\n [(5/6), -1, (7/6)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n 1 & 1 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 2 & 2 & -2 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n e & e-1 & 0 & e-1 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & e^2-1 & e^2 & 1-e^2 \\\\\n 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [1, 1, 0, 1],\n [0, 0, 0, 0],\n [0, 2, 2, -2],\n [0, 0, 0, 0]])\nprint(expm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 2 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -7 \\\\\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -3 \\\\\n -5 \\\\\n 14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [2],\n [5]])\nb = np.array([\n [-1],\n [-7],\n [9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{17}{5} & 6 & 1 \\\\\n \\frac{22}{5} & 10 & \\frac{11}{5} \\\\\n -\\frac{17}{5} & \\frac{4}{5} & \\frac{3}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-0.385,1.815,12.57\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/5), 6, 1],\n [(22/5), 10, (11/5)],\n [-(17/5), (4/5), (3/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 5 & -10 & -9 \\\\\n -4 & 2 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 9 & 5 & -7 \\\\\n -1 & 3 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 14 & -5 & -16 \\\\\n -5 & 5 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -10, -9],\n [-4, 2, 1]])\nb = np.array([\n [9, 5, -7],\n [-1, 3, -2]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -3 & -7 \\\\\n -4 & -9 \\\\\n 6 & -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -3 & -6 \\\\\n 2 & 4 \\\\\n -2 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -6 & -13 \\\\\n -2 & -5 \\\\\n 4 & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -7],\n [-4, -9],\n [6, -9]])\nb = np.array([\n [-3, -6],\n [2, 4],\n [-2, 0]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{16}{5} & \\frac{37}{10} & -\\frac{7}{10} \\\\\n \\frac{17}{10} & \\frac{18}{5} & -\\frac{21}{5} \\\\\n \\frac{37}{10} & -1 & \\frac{27}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{81631}{1000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(16/5), (37/10), -(7/10)],\n [(17/10), (18/5), -(21/5)],\n [(37/10), -1, (27/10)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{53}{9} & \\frac{4}{3} & 4 \\\\\n -\\frac{16}{9} & -\\frac{73}{9} & -\\frac{37}{9} \\\\\n \\frac{13}{3} & \\frac{19}{9} & 0 \\\\\n -\\frac{37}{9} & \\frac{43}{9} & \\frac{35}{9} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{41}{9} & \\frac{13}{9} & \\frac{68}{9} \\\\\n -\\frac{11}{9} & -\\frac{53}{9} & \\frac{46}{9} \\\\\n \\frac{29}{3} & -\\frac{17}{9} & -\\frac{13}{9} \\\\\n -\\frac{13}{3} & -\\frac{20}{3} & \\frac{44}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{4}{3} & -\\frac{1}{9} & -\\frac{32}{9} \\\\\n -\\frac{5}{9} & -\\frac{20}{9} & -\\frac{83}{9} \\\\\n -\\frac{16}{3} & 4 & \\frac{13}{9} \\\\\n \\frac{2}{9} & \\frac{103}{9} & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(53/9), (4/3), 4],\n [-(16/9), -(73/9), -(37/9)],\n [(13/3), (19/9), 0],\n [-(37/9), (43/9), (35/9)]])\nb = np.array([\n [-(41/9), (13/9), (68/9)],\n [-(11/9), -(53/9), (46/9)],\n [(29/3), -(17/9), -(13/9)],\n [-(13/3), -(20/3), (44/9)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 4 & 0 & -2 \\\\\n -2 & 1 & -2 \\\\\n 3 & -5 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{9}{50} & -\\frac{1}{5} & -\\frac{1}{25} \\\\\n \\frac{2}{25} & -\\frac{1}{5} & -\\frac{6}{25} \\\\\n -\\frac{7}{50} & -\\frac{2}{5} & -\\frac{2}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 0, -2],\n [-2, 1, -2],\n [3, -5, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & -9 \\\\\n 1 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{3}{2} i \\left(\\sqrt{3}-i\\right),1\\right\\}, \\left\\{-\\frac{3}{2} i \\left(\\sqrt{3}+i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -9],\n [1, -5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,3,-4\\}, \\{1,1,-3\\}, \\{3,3,-5\\}}$.", - "Output Answer": [ - "$x+3 y+4 z+8=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, 3, -4],\n [1, 1, -3],\n [3, 3, -5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,-1,-3\\}, \\{-5,-3,0\\}, \\{-4,2,1\\}}$.", - "Output Answer": [ - "$17 x-9 y+28 z+58=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -1, -3],\n [-5, -3, 0],\n [-4, 2, 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{29}{4} & \\frac{3}{4} & -\\frac{17}{2} \\\\\n \\frac{17}{2} & 0 & -\\frac{21}{4} \\\\\n -\\frac{21}{4} & -\\frac{17}{2} & \\frac{25}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.425,-0.637,1.\\}, \\{-0.268-2.217 i,1.777\\, +1.752 i,1.\\}, \\{-0.268+2.217 i,1.777\\, -1.752 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/4), (3/4), -(17/2)],\n [(17/2), 0, -(21/4)],\n [-(21/4), -(17/2), (25/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{37}{7} & \\frac{61}{7} & \\frac{59}{7} & \\frac{12}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{39}{7} & \\frac{13}{7} & \\frac{3}{7} & -\\frac{46}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{76}{7} & \\frac{74}{7} & \\frac{62}{7} & -\\frac{34}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(37/7), (61/7), (59/7), (12/7)]])\nb = np.array([\n [-(39/7), (13/7), (3/7), -(46/7)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -2 & \\frac{22}{3} & -3 & -\\frac{16}{3} & \\frac{14}{3} \\\\\n \\frac{14}{3} & 9 & \\frac{13}{3} & \\frac{25}{3} & \\frac{26}{3} \\\\\n -\\frac{17}{3} & \\frac{29}{3} & -\\frac{25}{3} & -\\frac{26}{3} & \\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, (22/3), -3, -(16/3), (14/3)],\n [(14/3), 9, (13/3), (25/3), (26/3)],\n [-(17/3), (29/3), -(25/3), -(26/3), (8/3)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{5} & -\\frac{21}{5} \\\\\n 5 & \\frac{16}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{80}{669} & \\frac{35}{223} \\\\\n -\\frac{125}{669} & \\frac{15}{223} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/5), -(21/5)],\n [5, (16/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{2} \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{19}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{162}{\\sqrt{56173}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2)],\n [5]]).squeeze()\nb = np.array([\n [2],\n [(19/2)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -8 & 8 & -10 \\\\\n -4 & 3 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{39.,44.,4.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-8, 8, -10],\n [-4, 3, 6]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -3 & -1 & 5 & 0 & -10 & -3 & 7 \\\\\n -9 & -5 & -4 & -10 & -9 & -7 & 6 \\\\\n 0 & 9 & -2 & -3 & -8 & 6 & 2 \\\\\n -3 & 8 & 10 & -8 & -1 & 3 & 3 \\\\\n 2 & 2 & 10 & -7 & -6 & -7 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & -\\frac{100559}{166972} & \\frac{70143}{166972} \\\\\n 0 & 1 & 0 & 0 & 0 & \\frac{43482}{41743} & -\\frac{15477}{41743} \\\\\n 0 & 0 & 1 & 0 & 0 & -\\frac{37951}{166972} & \\frac{59171}{166972} \\\\\n 0 & 0 & 0 & 1 & 0 & \\frac{48049}{83486} & -\\frac{32047}{83486} \\\\\n 0 & 0 & 0 & 0 & 1 & \\frac{43891}{166972} & -\\frac{102147}{166972} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, -1, 5, 0, -10, -3, 7],\n [-9, -5, -4, -10, -9, -7, 6],\n [0, 9, -2, -3, -8, 6, 2],\n [-3, 8, 10, -8, -1, 3, 3],\n [2, 2, 10, -7, -6, -7, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 2 & -2 & -1 & -2 & -1 \\\\\n -3 & 3 & 3 & -1 & -1 \\\\\n 1 & -2 & -3 & -1 & -3 \\\\\n -3 & 2 & 0 & 3 & 2 \\\\\n 0 & -3 & 2 & 2 & -2 \\\\\n 3 & 2 & -3 & 2 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.26 \\\\\n 1.36 \\\\\n -2.6 \\\\\n 1.82 \\\\\n -1.2 \\\\\n 0.82 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.135 \\\\\n 0.103 \\\\\n 0.208 \\\\\n -0.183 \\\\\n 0.588 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2, -1, -2, -1],\n [-3, 3, 3, -1, -1],\n [1, -2, -3, -1, -3],\n [-3, 2, 0, 3, 2],\n [0, -3, 2, 2, -2],\n [3, 2, -3, 2, 3]])\nb = np.array([\n [0.26],\n [1.36],\n [-2.6],\n [1.82],\n [-1.2],\n [0.82]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{7}{3},-\\frac{11}{3},\\frac{10}{3}\\right\\}, \\left\\{0,\\frac{7}{3},4\\right\\}, \\left\\{\\frac{14}{3},\\frac{10}{3},-5\\right\\}}$.", - "Output Answer": [ - "$1476 x+483 y+819 z-4403=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(7/3), -(11/3), (10/3)],\n [0, (7/3), 4],\n [(14/3), (10/3), -5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{17}{2} \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{205}}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [5]])\nb = np.array([\n [(17/2)],\n [8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -1 & 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -9 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -10 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 4]])\nb = np.array([\n [-9, 4]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -3 & -4 & 2 \\\\\n 2 & 3 & -1 \\\\\n 0 & -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & -1 & 1 \\\\\n 1 & \\frac{3}{2} & -\\frac{1}{2} \\\\\n 1 & \\frac{3}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -4, 2],\n [2, 3, -1],\n [0, -1, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-2,-\\frac{5}{3},\\frac{4}{3}\\right\\}, \\left\\{\\frac{5}{3},-\\frac{2}{3},-1\\right\\}, \\left\\{\\frac{5}{3},2,\\frac{5}{3}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{6}{\\sqrt{77}},-\\frac{5}{\\sqrt{77}},\\frac{4}{\\sqrt{77}}\\right\\}, \\left\\{\\frac{193}{\\sqrt{146454}},-157 \\sqrt{\\frac{2}{73227}},-\\frac{103}{\\sqrt{146454}}\\right\\}, \\left\\{\\frac{23}{\\sqrt{1902}},\\sqrt{\\frac{2}{951}},\\frac{37}{\\sqrt{1902}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, -(5/3), (4/3)), ((5/3), -(2/3), -1), ((5/3), 2, (5/3))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 8 & 6 \\\\\n -5 & -9 \\\\\n -1 & -5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 4 & 7 \\\\\n 10 & 7 \\\\\n -9 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 4 & -1 \\\\\n -15 & -16 \\\\\n 8 & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 6],\n [-5, -9],\n [-1, -5]])\nb = np.array([\n [4, 7],\n [10, 7],\n [-9, 4]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -8 & -1 & 1 & -9 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-9.,0.,0.,8.,0.\\}, \\{-1.,8.,0.,0.,0.\\}, \\{1.,0.,8.,0.,0.\\}, \\{7.,0.,0.,0.,8.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-8, -1, 1, -9, 7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -10 & -9 & 4 \\\\\n 7 & -3 & -7 \\\\\n -2 & 5 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-22 x^2-253 x-1197$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -9, 4],\n [7, -3, -7],\n [-2, 5, -9]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -2 & 7 & -4 & -4 & 2 & 9 \\\\\n -7 & -5 & -3 & 5 & 4 & 5 \\\\\n -7 & 4 & 5 & 9 & 1 & -1 \\\\\n 3 & 5 & 3 & 4 & 3 & -1 \\\\\n -6 & 3 & -10 & -7 & -2 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & -\\frac{42449}{20048} \\\\\n 0 & 1 & 0 & 0 & 0 & -\\frac{7607}{10024} \\\\\n 0 & 0 & 1 & 0 & 0 & \\frac{77829}{20048} \\\\\n 0 & 0 & 0 & 1 & 0 & -\\frac{41007}{10024} \\\\\n 0 & 0 & 0 & 0 & 1 & \\frac{46323}{10024} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, 7, -4, -4, 2, 9],\n [-7, -5, -3, 5, 4, 5],\n [-7, 4, 5, 9, 1, -1],\n [3, 5, 3, 4, 3, -1],\n [-6, 3, -10, -7, -2, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 2 \\\\\n 0 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{1}{\\sqrt{13}} \\\\\n \\frac{2}{\\sqrt{13}} \\\\\n 0 \\\\\n -\\frac{2}{\\sqrt{13}} \\\\\n \\frac{2}{\\sqrt{13}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [2],\n [0],\n [-2],\n [2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-5, -\\frac{5}{2}, 4}$ to the plane $-2 x-\\frac{y}{2}-4 z=0$.", - "Output Answer": [ - "$\\frac{19}{18}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -5, -(5/2), 4\nplane = Poly(-2*x-(y/2)-4*z, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -2 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\pi \\\\\n -2 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [-2*math.pi]])\nb = np.array([\n [math.pi],\n [-2*math.pi]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 3 & 0 \\\\\n 3 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1]])\nb = np.array([\n [-3, 0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -2 & 10 \\\\\n 0 & -6 \\\\\n -5 & -5 \\\\\n -9 & -5 \\\\\n 7 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, 10],\n [0, -6],\n [-5, -5],\n [-9, -5],\n [7, 5]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{10}{3} & \\frac{29}{3} & -4 & \\frac{22}{3} & \\frac{10}{3} \\\\\n -\\frac{25}{3} & \\frac{16}{3} & 0 & -\\frac{1}{3} & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(10/3), (29/3), -4, (22/3), (10/3)],\n [-(25/3), (16/3), 0, -(1/3), -3]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{60}{7} \\\\\n \\frac{10}{7} \\\\\n \\frac{67}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{12}{7} \\\\\n \\frac{17}{7} \\\\\n \\frac{36}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{72}{7} \\\\\n -1 \\\\\n \\frac{31}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(60/7)],\n [(10/7)],\n [(67/7)]])\nb = np.array([\n [(12/7)],\n [(17/7)],\n [(36/7)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 7 & 2 \\\\\n 9 & -2 \\\\\n -2 & 8 \\\\\n 9 & -9 \\\\\n 8 & -5 \\\\\n -9 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, 2],\n [9, -2],\n [-2, 8],\n [9, -9],\n [8, -5],\n [-9, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -10 & -5 & -10 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.,0.,1.,0.\\}, \\{-1.,2.,0.,0.\\}, \\{1.,0.,0.,5.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, -5, -10, 2]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 5 \\\\\n -1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 9 \\\\\n 3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{93}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [5],\n [-1],\n [-2]])\nb = np.array([\n [-2],\n [9],\n [3],\n [-8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{43}{8} \\\\\n \\frac{7}{8} \\\\\n -\\frac{33}{8} \\\\\n \\frac{15}{4} \\\\\n \\frac{1}{2} \\\\\n 1 \\\\\n \\frac{77}{8} \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{5 \\sqrt{\\frac{61}{2}}}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(43/8)],\n [(7/8)],\n [-(33/8)],\n [(15/4)],\n [(1/2)],\n [1],\n [(77/8)],\n [6]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2 \\\\\n 14 \\\\\n 36 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-1],\n [0]])\nb = np.array([\n [8],\n [4],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n \\frac{8}{3} & -\\frac{5}{3} & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{8}{3} \\\\\n \\frac{5}{3} \\\\\n -\\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{43}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(8/3), -(5/3), -(1/3)]])\nb = np.array([\n [(8/3)],\n [(5/3)],\n [-(4/3)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{31}{4} & \\frac{9}{2} & 6 \\\\\n -\\frac{15}{4} & -\\frac{7}{2} & \\frac{15}{4} \\\\\n \\frac{1}{4} & -\\frac{25}{4} & -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.919,0.108,1.\\}, \\{-0.055-1.736 i,0.822\\, -0.975 i,1.\\}, \\{-0.055+1.736 i,0.822\\, +0.975 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(31/4), (9/2), 6],\n [-(15/4), -(7/2), (15/4)],\n [(1/4), -(25/4), -(1/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 1 & 3 & 4 & 2 \\\\\n 8 & 6 & 6 & -9 \\\\\n 9 & -1 & 9 & 6 \\\\\n 0 & 9 & 2 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [1, 3, 4, 2],\n [8, 6, 6, -9],\n [9, -1, 9, 6],\n [0, 9, 2, 5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${1, 0, -3}$ to the plane $-x+4 y-z-4=0$.", - "Output Answer": [ - "$\\frac{\\sqrt{2}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 1, 0, -3\nplane = Poly(-x+4*y-z-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -5 & 4 & -1 \\\\\n -1 & 5 & 2 \\\\\n -4 & 4 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{25} & \\frac{6}{25} & -\\frac{13}{50} \\\\\n \\frac{3}{25} & \\frac{7}{25} & -\\frac{11}{50} \\\\\n -\\frac{8}{25} & -\\frac{2}{25} & \\frac{21}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 4, -1],\n [-1, 5, 2],\n [-4, 4, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{37}{4} \\\\\n 3 \\\\\n \\frac{1}{2} \\\\\n \\frac{29}{4} \\\\\n -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -\\frac{1}{4} \\\\\n -\\frac{1}{4} \\\\\n \\frac{7}{4} \\\\\n \\frac{7}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{1015}}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(37/4)],\n [3],\n [(1/2)],\n [(29/4)],\n [-(1/4)]])\nb = np.array([\n [-5],\n [-(1/4)],\n [-(1/4)],\n [(7/4)],\n [(7/4)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,3,4\\}, \\{-4,-1,-1\\}, \\{0,-2,1\\}}$.", - "Output Answer": [ - "$13 x+12 y-20 z+44=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, 3, 4],\n [-4, -1, -1],\n [0, -2, 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{37}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{32}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{23}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/9)]])\nb = np.array([\n [(32/9)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(\\sqrt{15}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [1],\n [0],\n [0],\n [0],\n [-1]]).squeeze()\nb = np.array([\n [1],\n [-1],\n [1],\n [0],\n [0],\n [-1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 0 & 1 & -3 & 3 & 0 \\\\\n 3 & 2 & 2 & -3 & 0 \\\\\n -1 & -2 & 2 & 0 & 3 \\\\\n 1 & -3 & 0 & -1 & -3 \\\\\n 1 & 3 & -1 & -2 & 3 \\\\\n -1 & -1 & 3 & 2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.28 \\\\\n 0.41 \\\\\n 0.55 \\\\\n 1.69 \\\\\n 1.21 \\\\\n -1.78 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.026 \\\\\n -0.393 \\\\\n -0.307 \\\\\n -0.621 \\\\\n 0.13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, -3, 3, 0],\n [3, 2, 2, -3, 0],\n [-1, -2, 2, 0, 3],\n [1, -3, 0, -1, -3],\n [1, 3, -1, -2, 3],\n [-1, -1, 3, 2, -2]])\nb = np.array([\n [-1.28],\n [0.41],\n [0.55],\n [1.69],\n [1.21],\n [-1.78]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{5} & -3 & \\frac{33}{10} \\\\\n 3 & -1 & \\frac{29}{10} \\\\\n \\frac{7}{2} & \\frac{39}{10} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1512}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/5), -3, (33/10)],\n [3, -1, (29/10)],\n [(7/2), (39/10), -(3/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4.02 \\\\\n -6.33 \\\\\n -4.41 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -0.11 \\\\\n 6.53 \\\\\n 9.1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$19.1038$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4.02],\n [-6.33],\n [-4.41]])\nb = np.array([\n [-0.11],\n [6.53],\n [9.1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -10 & -1 & 6 \\\\\n 7 & 5 & 8 \\\\\n 3 & 3 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -1, 6],\n [7, 5, 8],\n [3, 3, -8]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & -\\frac{5}{3} & -\\frac{10}{3} \\\\\n -\\frac{4}{3} & -\\frac{7}{3} & -\\frac{10}{3} \\\\\n 2 & -\\frac{5}{3} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{51}{142} & \\frac{15}{142} & \\frac{15}{71} \\\\\n \\frac{81}{71} & -\\frac{99}{71} & \\frac{15}{71} \\\\\n -\\frac{93}{142} & \\frac{45}{71} & -\\frac{33}{142} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -(5/3), -(10/3)],\n [-(4/3), -(7/3), -(10/3)],\n [2, -(5/3), -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{16}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{5}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1]])\nprint(a * -(5/16))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -7 \\\\\n -7 \\\\\n -\\frac{5}{2} \\\\\n 7 \\\\\n 6 \\\\\n 5 \\\\\n \\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$42$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-7],\n [-7],\n [-(5/2)],\n [7],\n [6],\n [5],\n [(9/2)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${5, -1, 2}$ to the plane $-5 x-3 y-2 z+2=0$.", - "Output Answer": [ - "$12 \\sqrt{\\frac{2}{19}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 5, -1, 2\nplane = Poly(-5*x-3*y-2*z+2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n \\frac{18}{5} \\\\\n -\\frac{44}{5} \\\\\n -\\frac{14}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{16}{5} \\\\\n \\frac{38}{5} \\\\\n -\\frac{11}{5} \\\\\n \\frac{34}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{108}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [(18/5)],\n [-(44/5)],\n [-(14/5)]])\nb = np.array([\n [(16/5)],\n [(38/5)],\n [-(11/5)],\n [(34/5)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 1 \\\\\n 10 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [1],\n [10],\n [-9]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{12}{5} & \\frac{8}{5} \\\\\n \\frac{39}{5} & -\\frac{39}{5} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{8}{5} & -\\frac{37}{5} \\\\\n -\\frac{12}{5} & \\frac{21}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -4 & 9 \\\\\n \\frac{51}{5} & -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(12/5), (8/5)],\n [(39/5), -(39/5)]])\nb = np.array([\n [(8/5), -(37/5)],\n [-(12/5), (21/5)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\pi \\\\\n 3 \\pi \\\\\n 2 \\pi \\\\\n 3 \\pi \\\\\n -3 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\pi \\\\\n \\pi \\\\\n -2 \\pi \\\\\n -\\pi \\\\\n -3 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\pi ^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.pi],\n [3*math.pi],\n [2*math.pi],\n [3*math.pi],\n [-3*math.pi]])\nb = np.array([\n [-2*math.pi],\n [math.pi],\n [-2*math.pi],\n [-math.pi],\n [-3*math.pi]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 1-2 i & -1-5 i \\\\\n -2-4 i & 1-5 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -21+10 i & -37-3 i \\\\\n -32+6 i & -42+4 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1-2j, -1-5j],\n [-2-4j, 1-5j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 9 & -\\frac{11}{2} & \\frac{9}{2} \\\\\n \\frac{7}{2} & -\\frac{7}{2} & \\frac{15}{2} \\\\\n \\frac{15}{2} & -7 & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-0.812-4.579 i,-0.812+4.579 i,7.624\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -(11/2), (9/2)],\n [(7/2), -(7/2), (15/2)],\n [(15/2), -7, (1/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n \\frac{11}{4} \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{4}{\\sqrt{217}} \\\\\n \\frac{11}{\\sqrt{217}} \\\\\n -\\frac{8}{\\sqrt{217}} \\\\\n \\frac{4}{\\sqrt{217}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [(11/4)],\n [-2],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{10} & -\\frac{12}{5} & -\\frac{11}{5} \\\\\n -\\frac{49}{10} & -\\frac{22}{5} & \\frac{18}{5} \\\\\n -\\frac{19}{5} & \\frac{47}{10} & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{7589}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/10), -(12/5), -(11/5)],\n [-(49/10), -(22/5), (18/5)],\n [-(19/5), (47/10), (7/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,2,2\\}, \\{-3,4,-1\\}, \\{3,-1,0\\}}$.", - "Output Answer": [ - "$13 x+18 y+12 z-21=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, 2, 2],\n [-3, 4, -1],\n [3, -1, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -6 \\\\\n -6 \\\\\n 2 \\\\\n -6 \\\\\n -5 \\\\\n -8 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{262}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-6],\n [-6],\n [2],\n [-6],\n [-5],\n [-8],\n [-6]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n 5 & 7 & -7 & -9 \\\\\n -3 & -8 & -4 & 2 \\\\\n -7 & -10 & 9 & 7 \\\\\n 9 & 8 & -4 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 7, -7, -9],\n [-3, -8, -4, 2],\n [-7, -10, 9, 7],\n [9, 8, -4, -1]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{2} & \\frac{5}{2} \\\\\n \\frac{5}{2} & -3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{225}{8} & 35 \\\\\n 35 & -\\frac{391}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), (5/2)],\n [(5/2), -3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & -8 \\\\\n 6 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{12} i \\left(\\sqrt{183}-3 i\\right),1\\right\\}, \\left\\{-\\frac{1}{12} i \\left(\\sqrt{183}+3 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -8],\n [6, -2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${0, -1}$ to the line $\\frac{5 x}{2}-\\frac{5 y}{2}-\\frac{1}{2}=0$.", - "Output Answer": [ - "$\\frac{2 \\sqrt{2}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 0, -1\nline = Poly(((5*x)/2)-((5*y)/2)-(1/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 2 & -1 \\\\\n -\\frac{3}{2} & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{11}{2} & \\frac{1}{2} \\\\\n \\frac{3}{4} & \\frac{31}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1],\n [-(3/2), -(5/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{2}{3},\\frac{1}{3},-3\\right\\}, \\left\\{-\\frac{11}{3},\\frac{7}{3},-\\frac{8}{3}\\right\\}, \\left\\{0,-3,-\\frac{4}{3}\\right\\}}$.", - "Output Answer": [ - "$120 x+189 y+426 z+1135=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(2/3), (1/3), -3],\n [-(11/3), (7/3), -(8/3)],\n [0, -3, -(4/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 3 & 0 & 3 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -9 & 0 & -9 & 9 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [0]])\nb = np.array([\n [3, 0, 3, -3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{9}{2},-4,-3\\right\\}, \\left\\{\\frac{3}{2},-2,\\frac{5}{2}\\right\\}, \\left\\{\\frac{3}{2},-3,2\\right\\}}$.", - "Output Answer": [ - "$6 x+4 y-8 z+19=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(9/2), -4, -3],\n [(3/2), -2, (5/2)],\n [(3/2), -3, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{30}{7} \\\\\n -\\frac{4}{7} \\\\\n \\frac{2}{7} \\\\\n -\\frac{40}{7} \\\\\n \\frac{68}{7} \\\\\n \\frac{66}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{10 \\sqrt{115}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(30/7)],\n [-(4/7)],\n [(2/7)],\n [-(40/7)],\n [(68/7)],\n [(66/7)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -10 & 9 \\\\\n 9 & 4 \\\\\n -2 & 6 \\\\\n 1 & 3 \\\\\n -10 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, 9],\n [9, 4],\n [-2, 6],\n [1, 3],\n [-10, 9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -12 \\log (2) \\\\\n -8 \\log (2) \\\\\n -10 \\log (2) \\\\\n -10 \\log (2) \\\\\n -8 \\log (2) \\\\\n 4 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -13 \\log (2) \\\\\n -3 \\log (2) \\\\\n -2 \\log (2) \\\\\n 4 \\log (2) \\\\\n 8 \\log (2) \\\\\n -4 \\log (2) \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$80 \\log ^2(2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-12*math.log(2)],\n [-8*math.log(2)],\n [-10*math.log(2)],\n [-10*math.log(2)],\n [-8*math.log(2)],\n [4*math.log(2)]])\nb = np.array([\n [-13*math.log(2)],\n [-3*math.log(2)],\n [-2*math.log(2)],\n [4*math.log(2)],\n [8*math.log(2)],\n [-4*math.log(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{2}-\\frac{7 i}{2} & -2+2 i & 2+\\frac{3 i}{2} \\\\\n -\\frac{9}{2}-\\frac{9 i}{2} & -\\frac{3}{2}-\\frac{5 i}{2} & -\\frac{7}{2}-\\frac{3 i}{2} \\\\\n 2-3 i & 2+\\frac{3 i}{2} & -5+\\frac{7 i}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1221}{8}-\\frac{2587 i}{8} & -\\frac{201}{2}-\\frac{843 i}{8} & \\frac{173}{4}+\\frac{627 i}{8} \\\\\n 226-\\frac{1067 i}{4} & -\\frac{79}{2}-154 i & -\\frac{911}{4}+\\frac{813 i}{4} \\\\\n \\frac{497}{8}-\\frac{501 i}{8} & \\frac{583}{4}-\\frac{783 i}{8} & \\frac{587}{8}+\\frac{581 i}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2)-((7j)/2), -2+2j, 2+((3j)/2)],\n [-(9/2)-((9j)/2), -(3/2)-((5j)/2), -(7/2)-((3j)/2)],\n [2-3j, 2+((3j)/2), -5+((7j)/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -3 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 27 \\\\\n 21 \\\\\n -36 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-3],\n [-7]])\nb = np.array([\n [-5],\n [3],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{31}{5} & \\frac{22}{5} & 7 \\\\\n \\frac{23}{5} & -\\frac{11}{5} & \\frac{39}{5} \\\\\n \\frac{3}{5} & -8 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-4.943,2.061,1.\\}, \\{0.496\\, -0.591 i,0.597\\, -0.85 i,1.\\}, \\{0.496\\, +0.591 i,0.597\\, +0.85 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(31/5), (22/5), 7],\n [(23/5), -(11/5), (39/5)],\n [(3/5), -8, 10]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{11}{\\sqrt{2}} \\\\\n -\\frac{3}{\\sqrt{2}} \\\\\n -\\sqrt{2} \\\\\n -\\frac{7}{\\sqrt{2}} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{\\sqrt{2}} \\\\\n -\\frac{3}{\\sqrt{2}} \\\\\n -\\frac{9}{\\sqrt{2}} \\\\\n -3 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(11/(math.sqrt(2)))],\n [-(3/(math.sqrt(2)))],\n [-math.sqrt(2)],\n [-(7/(math.sqrt(2)))]])\nb = np.array([\n [-(5/(math.sqrt(2)))],\n [-(3/(math.sqrt(2)))],\n [-(9/(math.sqrt(2)))],\n [-3*math.sqrt(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{13}{7}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & 10 & 7 \\\\\n 10 & 4 & 9 \\\\\n -9 & 7 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{26}{7} & \\frac{130}{7} & 13 \\\\\n \\frac{130}{7} & \\frac{52}{7} & \\frac{117}{7} \\\\\n -\\frac{117}{7} & 13 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 10, 7],\n [10, 4, 9],\n [-9, 7, 0]])\nprint(a * (13/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -2 \\\\\n 5 \\\\\n 2 \\\\\n -7 \\\\\n 2 \\\\\n -4 \\\\\n -2 \\\\\n 7 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -2 \\\\\n 5 \\\\\n 8 \\\\\n -5 \\\\\n -2 \\\\\n -7 \\\\\n 9 \\\\\n 8 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{587}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-2],\n [5],\n [2],\n [-7],\n [2],\n [-4],\n [-2],\n [7],\n [6]])\nb = np.array([\n [-6],\n [-2],\n [5],\n [8],\n [-5],\n [-2],\n [-7],\n [9],\n [8],\n [-6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -10 & 10 & 0 \\\\\n -1 & 9 & -3 \\\\\n -8 & -4 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.18,-2.334,1.\\}, \\{0.032\\, -0.447 i,0.159\\, +0.006 i,1.\\}, \\{0.032\\, +0.447 i,0.159\\, -0.006 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 10, 0],\n [-1, 9, -3],\n [-8, -4, -9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,-1,2\\}, \\{2,3,2\\}, \\{0,0,1\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{2}{3},-\\frac{1}{3},\\frac{2}{3}\\right\\}, \\left\\{\\frac{1}{3},\\frac{2}{3},\\frac{2}{3}\\right\\}, \\left\\{\\frac{2}{3},-\\frac{2}{3},\\frac{1}{3}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, -1, 2), (2, 3, 2), (0, 0, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${4, -4}$ to the line $5 x+4 y-4=0$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 4, -4\nline = Poly(5*x+4*y-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n \\frac{7}{2} & \\frac{9}{5} & -\\frac{39}{10} & -\\frac{81}{10} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2), (9/5), -(39/10), -(81/10), -4]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{5,-2,0\\}, \\{-3,-2,-1\\}, \\{0,2,-3\\}}$.", - "Output Answer": [ - "$4 x-19 y-32 z-58=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [5, -2, 0],\n [-3, -2, -1],\n [0, 2, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 2 & -2 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 8 & -8 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2],\n [0, 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{417}{100} & \\frac{461}{50} \\\\\n -\\frac{31}{10} & -\\frac{377}{50} \\\\\n \\frac{111}{20} & -\\frac{423}{50} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{279}{100} & \\frac{161}{100} \\\\\n \\frac{242}{25} & \\frac{146}{25} \\\\\n \\frac{781}{100} & \\frac{7}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{69}{50} & \\frac{761}{100} \\\\\n -\\frac{639}{50} & -\\frac{669}{50} \\\\\n -\\frac{113}{50} & -\\frac{493}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(417/100), (461/50)],\n [-(31/10), -(377/50)],\n [(111/20), -(423/50)]])\nb = np.array([\n [-(279/100), (161/100)],\n [(242/25), (146/25)],\n [(781/100), (7/5)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 1 \\\\\n 3 & -2 \\\\\n -3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.64 \\\\\n -2.32 \\\\\n 1.62 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.304 \\\\\n 0.439 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1],\n [3, -2],\n [-3, -2]])\nb = np.array([\n [1.64],\n [-2.32],\n [1.62]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 0 & 0 & 7 & -5 & -6 & 10 \\\\\n 10 & 2 & -10 & 1 & 4 & 8 \\\\\n 3 & -2 & 9 & 2 & -9 & -6 \\\\\n -10 & 3 & -10 & 4 & 7 & 1 \\\\\n 7 & 3 & 7 & -4 & 4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & -\\frac{1663}{37890} \\\\\n 0 & 1 & 0 & 0 & 0 & \\frac{82801}{37890} \\\\\n 0 & 0 & 1 & 0 & 0 & -\\frac{4441}{3789} \\\\\n 0 & 0 & 0 & 1 & 0 & -\\frac{36406}{18945} \\\\\n 0 & 0 & 0 & 0 & 1 & -\\frac{3619}{2526} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, 0, 7, -5, -6, 10],\n [10, 2, -10, 1, 4, 8],\n [3, -2, 9, 2, -9, -6],\n [-10, 3, -10, 4, 7, 1],\n [7, 3, 7, -4, 4, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 1 & \\frac{29}{3} & \\frac{16}{3} \\\\\n 5 & \\frac{26}{3} & -\\frac{25}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 1 & 9 & -1 \\\\\n -\\frac{7}{3} & 7 & \\frac{23}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & \\frac{2}{3} & \\frac{19}{3} \\\\\n \\frac{22}{3} & \\frac{5}{3} & -16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, (29/3), (16/3)],\n [5, (26/3), -(25/3)]])\nb = np.array([\n [1, 9, -1],\n [-(7/3), 7, (23/3)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 1 \\\\\n -1 \\\\\n 7 \\\\\n -1 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -4 \\\\\n -8 \\\\\n -4 \\\\\n -5 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-63$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [1],\n [-1],\n [7],\n [-1],\n [4]])\nb = np.array([\n [8],\n [-4],\n [-8],\n [-4],\n [-5],\n [7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 7 & -8 & -1 \\\\\n 2 & 10 & -6 \\\\\n -3 & -6 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+13 x^2+21 x-758$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -8, -1],\n [2, 10, -6],\n [-3, -6, -4]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -\\frac{19}{9} & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{9} \\\\\n -\\frac{19}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{95}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/9), -(1/3)]])\nb = np.array([\n [-(2/9)],\n [-(19/9)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{12}{5},\\frac{8}{5},-\\frac{8}{5}\\right\\}, \\left\\{-\\frac{12}{5},-\\frac{1}{5},-\\frac{12}{5}\\right\\}, \\left\\{-\\frac{2}{5},\\frac{7}{5},\\frac{14}{5}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{3}{\\sqrt{17}},\\frac{2}{\\sqrt{17}},-\\frac{2}{\\sqrt{17}}\\right\\}, \\left\\{-\\frac{30}{\\sqrt{26333}},-\\frac{133}{\\sqrt{26333}},-\\frac{88}{\\sqrt{26333}}\\right\\}, \\left\\{-\\frac{26}{\\sqrt{1549}},-\\frac{12}{\\sqrt{1549}},\\frac{27}{\\sqrt{1549}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-(12/5), (8/5), -(8/5)), (-(12/5), -(1/5), -(12/5)), (-(2/5), (7/5), (14/5))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -8 & -4 \\\\\n -2 & 5 \\\\\n 4 & -2 \\\\\n 6 & 8 \\\\\n -10 & -9 \\\\\n 6 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-8, -4],\n [-2, 5],\n [4, -2],\n [6, 8],\n [-10, -9],\n [6, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{6}{5}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & 6 & -1 & -5 \\\\\n 3 & 9 & -4 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{6}{5} & \\frac{36}{5} & -\\frac{6}{5} & -6 \\\\\n \\frac{18}{5} & \\frac{54}{5} & -\\frac{24}{5} & \\frac{36}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 6, -1, -5],\n [3, 9, -4, 6]])\nprint(a * (6/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 2 & -10 \\\\\n 0 & 0 \\\\\n -9 & -1 \\\\\n 0 & -3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -3 & 2 \\\\\n -9 & 0 \\\\\n 9 & -5 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 5 & -12 \\\\\n 9 & 0 \\\\\n -18 & 4 \\\\\n 0 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -10],\n [0, 0],\n [-9, -1],\n [0, -3]])\nb = np.array([\n [-3, 2],\n [-9, 0],\n [9, -5],\n [0, 1]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n -5 & -10 & 1 \\\\\n -3 & 9 & 5 \\\\\n -5 & -2 & -5 \\\\\n 5 & -1 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -10, 1],\n [-3, 9, 5],\n [-5, -2, -5],\n [5, -1, -8]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{6}{5}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -1 \\\\\n 3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{24}{5} \\\\\n -\\frac{6}{5} \\\\\n \\frac{18}{5} \\\\\n -\\frac{48}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-1],\n [3],\n [-8]])\nprint(a * (6/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 7 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -7 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 14 \\\\\n 86 \\\\\n -70 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [7],\n [9]])\nb = np.array([\n [8],\n [-7],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(-2 \\sqrt{3}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [1],\n [-1],\n [0]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -4 & 5 \\\\\n 6 & 2 \\\\\n 5 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 5],\n [6, 2],\n [5, -6]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 1 \\\\\n -5 \\\\\n 7 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -9 \\\\\n 9 \\\\\n 10 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [1],\n [-5],\n [7],\n [-1]])\nb = np.array([\n [5],\n [-9],\n [9],\n [10],\n [8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{33}{4} & -\\frac{7}{4} & -\\frac{39}{4} & \\frac{39}{4} \\\\\n -\\frac{17}{2} & \\frac{15}{4} & -\\frac{27}{4} & -\\frac{15}{2} \\\\\n -\\frac{7}{2} & 4 & 7 & \\frac{19}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{17}{4} & -8 & \\frac{7}{2} & -\\frac{39}{4} \\\\\n 3 & -\\frac{1}{4} & \\frac{9}{4} & -9 \\\\\n -\\frac{19}{2} & 4 & \\frac{9}{2} & \\frac{19}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -4 & -\\frac{39}{4} & -\\frac{25}{4} & 0 \\\\\n -\\frac{11}{2} & \\frac{7}{2} & -\\frac{9}{2} & -\\frac{33}{2} \\\\\n -13 & 8 & \\frac{23}{2} & \\frac{57}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(33/4), -(7/4), -(39/4), (39/4)],\n [-(17/2), (15/4), -(27/4), -(15/2)],\n [-(7/2), 4, 7, (19/2)]])\nb = np.array([\n [(17/4), -8, (7/2), -(39/4)],\n [3, -(1/4), (9/4), -9],\n [-(19/2), 4, (9/2), (19/4)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -10 & 5 & 5 & 8 \\\\\n 5 & -10 & -3 & -5 \\\\\n 9 & -6 & -2 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 5, 5, 8],\n [5, -10, -3, -5],\n [9, -6, -2, -8]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-1$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 2 \\\\\n -6 & -9 \\\\\n 5 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -1 & -2 \\\\\n 6 & 9 \\\\\n -5 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2],\n [-6, -9],\n [5, -5]])\nprint(a * -1)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 2 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 3 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{291}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [2],\n [-7]])\nb = np.array([\n [7],\n [3],\n [4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{5}{2},-\\frac{1}{2},-\\frac{3}{2}\\right\\}, \\left\\{-1,-\\frac{9}{2},1\\right\\}, \\left\\{-\\frac{7}{2},-\\frac{3}{2},-1\\right\\}}$.", - "Output Answer": [ - "$4 x-106 y-164 z-309=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(5/2), -(1/2), -(3/2)],\n [-1, -(9/2), 1],\n [-(7/2), -(3/2), -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [2],\n [3]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 5 & 5 \\\\\n -3 & -7 \\\\\n 4 & 5 \\\\\n -8 & -7 \\\\\n 4 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, 5],\n [-3, -7],\n [4, 5],\n [-8, -7],\n [4, -4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{11}{16}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{11}{16} \\\\\n -\\frac{33}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-6]])\nprint(a * (11/16))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -3 & 6 & 9 & -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 9 & -3 & 7 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 6 & 3 & 16 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 6, 9, -5]])\nb = np.array([\n [9, -3, 7, 3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{50}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{49}{50} \\\\\n -\\frac{28}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-8]])\nprint(a * (7/50))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -1 & 6 \\\\\n -7 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{1-i \\sqrt{38},1+i \\sqrt{38}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 6],\n [-7, 3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{0,\\frac{1}{2},1\\right\\}, \\left\\{\\frac{1}{2},3,4\\right\\}, \\left\\{4,\\frac{7}{2},-3\\right\\}}$.", - "Output Answer": [ - "$38 x-28 y+17 z-3=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, (1/2), 1],\n [(1/2), 3, 4],\n [4, (7/2), -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,-1,0\\}, \\{-3,-5,-5\\}, \\{-3,2,1\\}}$.", - "Output Answer": [ - "$x+3=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, -1, 0],\n [-3, -5, -5],\n [-3, 2, 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -7 & -5 & -\\frac{22}{3} \\\\\n -4 & -6 & -\\frac{25}{3} \\\\\n -6 & \\frac{28}{3} & \\frac{17}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-12.782,-9.929,1.\\}, \\{-0.443-0.026 i,-0.732+0.332 i,1.\\}, \\{-0.443+0.026 i,-0.732-0.332 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -5, -(22/3)],\n [-4, -6, -(25/3)],\n [-6, (28/3), (17/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,1,2\\}, \\left\\{-\\frac{5}{3},-\\frac{5}{3},-\\frac{13}{3}\\right\\}, \\left\\{-\\frac{14}{3},\\frac{7}{3},-\\frac{5}{3}\\right\\}}$.", - "Output Answer": [ - "$164 x+283 y-240 z-295=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, 1, 2],\n [-(5/3), -(5/3), -(13/3)],\n [-(14/3), (7/3), -(5/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,-3,3\\}, \\left\\{\\frac{2}{3},-\\frac{2}{3},0\\right\\}, \\left\\{-\\frac{8}{3},1,\\frac{14}{3}\\right\\}}$.", - "Output Answer": [ - "$143 x-2 (53 y-70 z+83)=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, -3, 3],\n [(2/3), -(2/3), 0],\n [-(8/3), 1, (14/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -1 & 3 & -10 & 8 \\\\\n -10 & 2 & -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.,-11.,0.,4.\\}, \\{17.,99.,28.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, 3, -10, 8],\n [-10, 2, -1, 3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 5 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{122}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [5],\n [9]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -\\frac{1}{5} \\\\\n -\\frac{24}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{42}{5} \\\\\n \\frac{22}{5} \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{553}{25} \\\\\n \\frac{1883}{25} \\\\\n \\frac{728}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-(1/5)],\n [-(24/5)]])\nb = np.array([\n [-(42/5)],\n [(22/5)],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{61}{8} \\\\\n -\\frac{141}{16} \\\\\n -\\frac{153}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{31}{4} \\\\\n \\frac{115}{16} \\\\\n -\\frac{37}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{28029}{256} \\\\\n \\frac{875}{8} \\\\\n -\\frac{1727}{128} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(61/8)],\n [-(141/16)],\n [-(153/16)]])\nb = np.array([\n [-(31/4)],\n [(115/16)],\n [-(37/8)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1}{\\sqrt{5}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [-1],\n [1],\n [1],\n [1]]).squeeze()\nb = np.array([\n [0],\n [-1],\n [0],\n [1],\n [-1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -3 & 8 & 2 \\\\\n -7 & 6 & 4 \\\\\n -2 & -6 & -6 \\\\\n 6 & 3 & -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 3 & 6 & 3 \\\\\n 0 & -4 & 7 \\\\\n -5 & 4 & 2 \\\\\n -10 & 0 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 14 & 5 \\\\\n -7 & 2 & 11 \\\\\n -7 & -2 & -4 \\\\\n -4 & 3 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 8, 2],\n [-7, 6, 4],\n [-2, -6, -6],\n [6, 3, -6]])\nb = np.array([\n [3, 6, 3],\n [0, -4, 7],\n [-5, 4, 2],\n [-10, 0, 1]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{2}{3} & -7 \\\\\n 3 & \\frac{20}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{3} \\left(9-2 i \\sqrt{17}\\right),\\frac{1}{3} \\left(9+2 i \\sqrt{17}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3), -7],\n [3, (20/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -\\frac{15}{4} \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{25}{4} \\\\\n \\frac{19}{4} \\\\\n \\frac{25}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{185}{16} \\\\\n -\\frac{125}{8} \\\\\n \\frac{5}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-(15/4)],\n [-(5/2)]])\nb = np.array([\n [-(25/4)],\n [(19/4)],\n [(25/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -9 & -8 \\\\\n 2 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-8-i \\sqrt{15},-8+i \\sqrt{15}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -8],\n [2, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{2}{3} & 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{4}{3} & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -2 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3), 6]])\nb = np.array([\n [-(4/3), -5]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{0,1\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [1]]).squeeze()\nb = np.array([\n [0],\n [3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -9 \\\\\n 6 \\\\\n 3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{134}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-9],\n [6],\n [3],\n [-2]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{14}{3},-\\frac{10}{3},\\frac{4}{3}\\right\\}, \\left\\{-\\frac{2}{3},\\frac{1}{3},-\\frac{5}{3}\\right\\}, \\left\\{-\\frac{2}{3},\\frac{7}{3},-\\frac{7}{3}\\right\\}}$.", - "Output Answer": [ - "$x-y-3 z-4=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(14/3), -(10/3), (4/3)],\n [-(2/3), (1/3), -(5/3)],\n [-(2/3), (7/3), -(7/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -2 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 4 & 6 \\\\\n 4 & 6 \\\\\n -2 & -3 \\\\\n -2 & -3 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-2],\n [1],\n [1],\n [0]])\nb = np.array([\n [-2, -3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,1,3\\}, \\{-2,-3,3\\}, \\{5,-1,-3\\}}$.", - "Output Answer": [ - "$4 x+y+5 z-4=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, 1, 3],\n [-2, -3, 3],\n [5, -1, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 8 \\\\\n -6 \\\\\n -3 \\\\\n -2 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -2 \\\\\n 4 \\\\\n 9 \\\\\n 5 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-144$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [8],\n [-6],\n [-3],\n [-2],\n [-7]])\nb = np.array([\n [-3],\n [-2],\n [4],\n [9],\n [5],\n [10]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 9 & -4 & -5 & -3 & -6 \\\\\n 10 & -10 & -3 & 3 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{38.,23.,50.,0.,0.\\}, \\{42.,57.,0.,0.,25.\\}, \\{42.,57.,0.,50.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, -4, -5, -3, -6],\n [10, -10, -3, 3, 6]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n \\frac{5}{4} \\\\\n \\frac{11}{4} \\\\\n \\frac{3}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2 \\sqrt{\\frac{5}{51}} \\\\\n \\sqrt{\\frac{5}{51}} \\\\\n \\frac{11}{\\sqrt{255}} \\\\\n \\sqrt{\\frac{3}{85}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2)],\n [(5/4)],\n [(11/4)],\n [(3/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{39}{4} & -\\frac{23}{4} \\\\\n 1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{8} \\left(35-\\sqrt{857}\\right),1\\right\\}, \\left\\{\\frac{1}{8} \\left(35+\\sqrt{857}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(39/4), -(23/4)],\n [1, 1]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 6 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 8 \\\\\n -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 34 \\\\\n -14 \\\\\n -78 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [6],\n [-5]])\nb = np.array([\n [1],\n [8],\n [-1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -9 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 4 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{178}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-9],\n [3]])\nb = np.array([\n [8],\n [4],\n [3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{2}{5}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 7 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{4}{5} \\\\\n -\\frac{14}{5} \\\\\n \\frac{16}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [7],\n [-8]])\nprint(a * -(2/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -8 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{2} \\\\\n -\\frac{17}{2} \\\\\n -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -21 \\\\\n 65 \\\\\n -\\frac{125}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-8],\n [-10]])\nb = np.array([\n [-(5/2)],\n [-(17/2)],\n [-8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -8 \\\\\n -8 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n 3 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{182}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-8],\n [-8],\n [-7]])\nb = np.array([\n [2],\n [-2],\n [3],\n [-7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{20}{3} & -\\frac{17}{3} \\\\\n -\\frac{1}{3} & -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{6} \\left(-25-\\sqrt{293}\\right),\\frac{1}{6} \\left(\\sqrt{293}-25\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/3), -(17/3)],\n [-(1/3), -(5/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{9}{2} & -\\frac{3}{2} & 9 \\\\\n -10 & \\frac{7}{2} & -\\frac{19}{2} \\\\\n -\\frac{17}{2} & \\frac{9}{2} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-4.172,0.836\\, -9.812 i,0.836\\, +9.812 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2), -(3/2), 9],\n [-10, (7/2), -(19/2)],\n [-(17/2), (9/2), -(3/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 0 & 0 & -1 & 1 & 2 \\\\\n 2 & 1 & 2 & 2 & -2 \\\\\n -3 & -2 & 1 & -1 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n 2 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -4 \\\\\n -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0, -1, 1, 2],\n [2, 1, 2, 2, -2],\n [-3, -2, 1, -1, -3]])\nb = np.array([\n [1],\n [-2],\n [2],\n [-2],\n [2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{23}{8} \\\\\n -\\frac{15}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{1429}}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/8)],\n [-(15/4)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, -\\frac{14}{5}}$ to the line $\\frac{22 x}{5}+\\frac{23 y}{5}-5=0$.", - "Output Answer": [ - "$\\frac{117}{5 \\sqrt{1013}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, -(14/5)\nline = Poly(((22*x)/5)+((23*y)/5)-5, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{7}{2} \\\\\n 5 \\\\\n -2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n \\frac{7}{2} \\\\\n \\frac{11}{2} \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n 0 \\\\\n -\\frac{1}{2} \\\\\n -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [(7/2)],\n [5],\n [-2]])\nb = np.array([\n [(1/2)],\n [(7/2)],\n [(11/2)],\n [6]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -3 & -2 & -1 \\\\\n 2 & 2 & 3 \\\\\n -2 & -3 & -2 \\\\\n 2 & 3 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -2 & 2 \\\\\n 1 & 2 \\\\\n -2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 6 & -8 \\\\\n -8 & 2 \\\\\n 5 & -6 \\\\\n -5 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2, -1],\n [2, 2, 3],\n [-2, -3, -2],\n [2, 3, 2]])\nb = np.array([\n [-2, 2],\n [1, 2],\n [-2, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -2 & \\frac{31}{4} & \\frac{7}{4} \\\\\n -2 & -\\frac{27}{4} & -\\frac{11}{2} \\\\\n -\\frac{23}{4} & -4 & \\frac{19}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.132,-0.38,1.\\}, \\{1.5\\, -2.144 i,0.41\\, +1.893 i,1.\\}, \\{1.5\\, +2.144 i,0.41\\, -1.893 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, (31/4), (7/4)],\n [-2, -(27/4), -(11/2)],\n [-(23/4), -4, (19/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{14}{3} & \\frac{13}{9} \\\\\n \\frac{71}{9} & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{14 x}{3}-\\frac{923}{81}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/3), (13/9)],\n [(71/9), 0]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -7 \\\\\n 8 \\\\\n 7 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-7],\n [8],\n [7],\n [-4]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{4}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -5 & 9 & -10 & -4 \\\\\n 8 & 8 & -10 & -10 \\\\\n -1 & -10 & -10 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{25}{4} & \\frac{45}{4} & -\\frac{25}{2} & -5 \\\\\n 10 & 10 & -\\frac{25}{2} & -\\frac{25}{2} \\\\\n -\\frac{5}{4} & -\\frac{25}{2} & -\\frac{25}{2} & \\frac{5}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 9, -10, -4],\n [8, 8, -10, -10],\n [-1, -10, -10, 1]])\nprint(a * (5/4))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 9 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 5 \\\\\n 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 18 \\\\\n 14 \\\\\n 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [9],\n [9]])\nb = np.array([\n [8],\n [5],\n [1]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 0 & \\frac{9}{8} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -1 & -\\frac{5}{2} & 0 \\\\\n -\\frac{3}{8} & \\frac{5}{4} & \\frac{21}{8} \\\\\n 0 & \\frac{5}{2} & \\frac{17}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{27}{64} & \\frac{5}{32} & \\frac{121}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, (9/8), -(1/2)]])\nb = np.array([\n [-1, -(5/2), 0],\n [-(3/8), (5/4), (21/8)],\n [0, (5/2), (17/8)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{7}{3} & \\frac{5}{3} & \\frac{2}{3} & \\frac{8}{3} \\\\\n -\\frac{5}{3} & -\\frac{2}{3} & \\frac{8}{3} & -2 \\\\\n -\\frac{7}{3} & \\frac{5}{3} & \\frac{4}{3} & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{5}{3} & \\frac{4}{3} & 0 & -\\frac{5}{3} & -\\frac{1}{3} \\\\\n -1 & \\frac{5}{3} & \\frac{1}{3} & \\frac{2}{3} & -\\frac{8}{3} \\\\\n \\frac{8}{3} & -\\frac{8}{3} & -\\frac{8}{3} & \\frac{8}{3} & \\frac{4}{3} \\\\\n 0 & 3 & \\frac{7}{3} & \\frac{4}{3} & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 4 & \\frac{53}{9} & 5 & \\frac{31}{3} & -\\frac{11}{3} \\\\\n \\frac{95}{9} & -\\frac{148}{9} & -12 & \\frac{61}{9} & \\frac{59}{9} \\\\\n \\frac{52}{9} & -\\frac{62}{9} & -\\frac{16}{3} & \\frac{65}{9} & -\\frac{14}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/3), (5/3), (2/3), (8/3)],\n [-(5/3), -(2/3), (8/3), -2],\n [-(7/3), (5/3), (4/3), -1]])\nb = np.array([\n [-(5/3), (4/3), 0, -(5/3), -(1/3)],\n [-1, (5/3), (1/3), (2/3), -(8/3)],\n [(8/3), -(8/3), -(8/3), (8/3), (4/3)],\n [0, 3, (7/3), (4/3), -(1/3)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 0 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n -5 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 40 \\\\\n -65 \\\\\n 15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [0],\n [8]])\nb = np.array([\n [-10],\n [-5],\n [5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & 1 \\\\\n -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1],\n [-1, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{2} & -1 \\\\\n -4 & -\\frac{37}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{8} \\left(-23-\\sqrt{2857}\\right),\\frac{1}{8} \\left(\\sqrt{2857}-23\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2), -1],\n [-4, -(37/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{22}{3} & \\frac{4}{3} & -\\frac{4}{3} & \\frac{15}{2} \\\\\n \\frac{59}{6} & \\frac{15}{2} & -\\frac{7}{6} & \\frac{2}{3} \\\\\n \\frac{5}{3} & -\\frac{5}{2} & -\\frac{59}{6} & \\frac{53}{6} \\\\\n -8 & -2 & \\frac{11}{3} & -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -5 & -\\frac{55}{6} & \\frac{7}{6} & -\\frac{5}{3} \\\\\n -\\frac{20}{3} & -\\frac{31}{6} & -\\frac{16}{3} & -\\frac{17}{3} \\\\\n 8 & 0 & -10 & 7 \\\\\n -\\frac{13}{3} & -1 & \\frac{4}{3} & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{37}{3} & \\frac{21}{2} & -\\frac{5}{2} & \\frac{55}{6} \\\\\n \\frac{33}{2} & \\frac{38}{3} & \\frac{25}{6} & \\frac{19}{3} \\\\\n -\\frac{19}{3} & -\\frac{5}{2} & \\frac{1}{6} & \\frac{11}{6} \\\\\n -\\frac{11}{3} & -1 & \\frac{7}{3} & \\frac{16}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(22/3), (4/3), -(4/3), (15/2)],\n [(59/6), (15/2), -(7/6), (2/3)],\n [(5/3), -(5/2), -(59/6), (53/6)],\n [-8, -2, (11/3), -(5/3)]])\nb = np.array([\n [-5, -(55/6), (7/6), -(5/3)],\n [-(20/3), -(31/6), -(16/3), -(17/3)],\n [8, 0, -10, 7],\n [-(13/3), -1, (4/3), -7]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{8}{3} & \\frac{10}{3} & \\frac{7}{3} \\\\\n -\\frac{14}{3} & -\\frac{2}{3} & -\\frac{10}{3} \\\\\n -4 & 3 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{57}{103} & -\\frac{183}{206} & \\frac{43}{103} \\\\\n \\frac{24}{103} & \\frac{6}{103} & \\frac{9}{103} \\\\\n \\frac{75}{103} & \\frac{96}{103} & -\\frac{62}{103} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(8/3), (10/3), (7/3)],\n [-(14/3), -(2/3), -(10/3)],\n [-4, 3, -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [0],\n [0],\n [0],\n [-1],\n [0]]).squeeze()\nb = np.array([\n [1],\n [1],\n [1],\n [-1],\n [1],\n [0],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -8 & 8 & 8 & 10 & 6 & -3 \\\\\n 2 & -10 & -3 & 10 & -8 & -10 \\\\\n 0 & -7 & -1 & 4 & 4 & 7 \\\\\n -7 & -3 & 8 & 0 & -6 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & -\\frac{3036}{199} & -\\frac{3030}{199} \\\\\n 0 & 1 & 0 & 0 & \\frac{446}{597} & -\\frac{262}{597} \\\\\n 0 & 0 & 1 & 0 & -\\frac{2750}{199} & -\\frac{2485}{199} \\\\\n 0 & 0 & 0 & 1 & -\\frac{685}{597} & -\\frac{2555}{1194} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-8, 8, 8, 10, 6, -3],\n [2, -10, -3, 10, -8, -10],\n [0, -7, -1, 4, 4, 7],\n [-7, -3, 8, 0, -6, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{21}{5} & \\frac{13}{5} \\\\\n \\frac{49}{10} & \\frac{27}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{27}{14} & \\frac{13}{7} \\\\\n \\frac{7}{2} & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(21/5), (13/5)],\n [(49/10), (27/10)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{47}{16} & \\frac{5}{4} \\\\\n \\frac{73}{16} & \\frac{7}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{112}{401} & \\frac{160}{401} \\\\\n \\frac{584}{401} & -\\frac{376}{401} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(47/16), (5/4)],\n [(73/16), (7/8)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -1 & 0 & 0 & 1 \\\\\n 2 & 0 & 0 & -2 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [2],\n [0]])\nb = np.array([\n [1, 0, 0, -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & -3 & -4 \\\\\n 2 & 8 & 2 \\\\\n -2 & 1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.799,-0.506,1.\\}, \\{-1.809-0.168 i,0.435\\, +0.942 i,1.\\}, \\{-1.809+0.168 i,0.435\\, -0.942 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -3, -4],\n [2, 8, 2],\n [-2, 1, 3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{4} \\\\\n -\\frac{11}{4} \\\\\n -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{7}{22},-\\frac{7}{22},\\frac{35}{44}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/4)],\n [-(11/4)],\n [-(3/4)]]).squeeze()\nb = np.array([\n [1],\n [-1],\n [(5/2)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{81}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{25}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2)]])\nb = np.array([\n [-(81/16)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -6 \\\\\n -3 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-1],\n [0]])\nb = np.array([\n [3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{79}{16} & -\\frac{39}{16} \\\\\n -\\frac{79}{16} & -\\frac{17}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{544}{5767} & -\\frac{624}{5767} \\\\\n -\\frac{16}{73} & -\\frac{16}{73} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(79/16), -(39/16)],\n [-(79/16), -(17/8)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{55}{7} & \\frac{51}{7} & -\\frac{9}{7} & -\\frac{11}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{52}{7} & \\frac{19}{7} & -\\frac{17}{7} & \\frac{20}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{107}{7} & \\frac{32}{7} & \\frac{8}{7} & -\\frac{31}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(55/7), (51/7), -(9/7), -(11/7)]])\nb = np.array([\n [-(52/7), (19/7), -(17/7), (20/7)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 2 & -\\frac{2}{3} \\\\\n -5 & 4 & \\frac{11}{3} \\\\\n -\\frac{2}{3} & 1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{32}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, -(2/3)],\n [-5, 4, (11/3)],\n [-(2/3), 1, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,4,5\\}, \\{-1,3,-4\\}, \\{0,-1,5\\}}$.", - "Output Answer": [ - "$45 x-27 y-17 z+58=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, 4, 5],\n [-1, 3, -4],\n [0, -1, 5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${4, -5, -2}$ to the plane $-2 x+4 y+4 z+2=0$.", - "Output Answer": [ - "$\\frac{17}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 4, -5, -2\nplane = Poly(-2*x+4*y+4*z+2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 2 & \\frac{5}{2} \\\\\n \\frac{5}{2} & 0 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{41}{4} & 5 \\\\\n 5 & \\frac{25}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, (5/2)],\n [(5/2), 0]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -3 & 5 & 1 & 6 & -3 & -10 \\\\\n -2 & 7 & -7 & -6 & -2 & -8 \\\\\n 9 & -5 & 7 & -10 & -6 & 1 \\\\\n 7 & -7 & -6 & -8 & -4 & -9 \\\\\n 0 & 9 & -7 & -2 & -1 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & \\frac{25}{71} \\\\\n 0 & 1 & 0 & 0 & 0 & \\frac{8}{71} \\\\\n 0 & 0 & 1 & 0 & 0 & \\frac{69}{71} \\\\\n 0 & 0 & 0 & 1 & 0 & -\\frac{81}{142} \\\\\n 0 & 0 & 0 & 0 & 1 & \\frac{167}{71} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 5, 1, 6, -3, -10],\n [-2, 7, -7, -6, -2, -8],\n [9, -5, 7, -10, -6, 1],\n [7, -7, -6, -8, -4, -9],\n [0, 9, -7, -2, -1, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & -1 & 6 \\\\\n -1 & 5 & 2 \\\\\n 10 & 7 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6.237,6.053,12.184\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -1, 6],\n [-1, 5, 2],\n [10, 7, 0]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{13}{32}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 5 & -3 \\\\\n 10 & -4 \\\\\n 10 & 3 \\\\\n -6 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{65}{32} & \\frac{39}{32} \\\\\n -\\frac{65}{16} & \\frac{13}{8} \\\\\n -\\frac{65}{16} & -\\frac{39}{32} \\\\\n \\frac{39}{16} & \\frac{13}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -3],\n [10, -4],\n [10, 3],\n [-6, -1]])\nprint(a * -(13/32))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 7 \\\\\n -1 \\\\\n -8 \\\\\n \\frac{22}{3} \\\\\n 2 \\\\\n -\\frac{11}{3} \\\\\n \\frac{26}{3} \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -\\frac{20}{3} \\\\\n \\frac{14}{3} \\\\\n -5 \\\\\n -3 \\\\\n -\\frac{16}{3} \\\\\n -\\frac{14}{3} \\\\\n 2 \\\\\n \\frac{13}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{\\frac{1910}{3}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [7],\n [-1],\n [-8],\n [(22/3)],\n [2],\n [-(11/3)],\n [(26/3)],\n [-9]])\nb = np.array([\n [-4],\n [-(20/3)],\n [(14/3)],\n [-5],\n [-3],\n [-(16/3)],\n [-(14/3)],\n [2],\n [(13/3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{47}{8} & -\\frac{65}{8} \\\\\n \\frac{43}{8} & \\frac{3}{8} \\\\\n \\frac{9}{8} & -\\frac{13}{8} \\\\\n -\\frac{17}{4} & \\frac{39}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{8} & \\frac{1}{4} \\\\\n -\\frac{21}{8} & -\\frac{27}{4} \\\\\n -\\frac{31}{4} & \\frac{49}{8} \\\\\n \\frac{75}{8} & -\\frac{33}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -5 & -\\frac{63}{8} \\\\\n \\frac{11}{4} & -\\frac{51}{8} \\\\\n -\\frac{53}{8} & \\frac{9}{2} \\\\\n \\frac{41}{8} & \\frac{3}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(47/8), -(65/8)],\n [(43/8), (3/8)],\n [(9/8), -(13/8)],\n [-(17/4), (39/8)]])\nb = np.array([\n [(7/8), (1/4)],\n [-(21/8), -(27/4)],\n [-(31/4), (49/8)],\n [(75/8), -(33/8)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & -2 & -2 & 3 \\\\\n 0 & -3 & 2 & -3 \\\\\n 2 & -3 & 0 & 2 \\\\\n 0 & 2 & -3 & -1 \\\\\n 0 & -3 & 3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.64 \\\\\n 0.91 \\\\\n 0.05 \\\\\n -2.42 \\\\\n 0.14 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.42 \\\\\n 0.202 \\\\\n 0.613 \\\\\n -0.091 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2, -2, 3],\n [0, -3, 2, -3],\n [2, -3, 0, 2],\n [0, 2, -3, -1],\n [0, -3, 3, 2]])\nb = np.array([\n [-1.64],\n [0.91],\n [0.05],\n [-2.42],\n [0.14]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & -2 & 1 \\\\\n 3 & -1 & -2 \\\\\n 1 & 3 & 1 \\\\\n -1 & 1 & 0 \\\\\n 2 & -2 & 2 \\\\\n 0 & 1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.56 \\\\\n -2.99 \\\\\n 2.94 \\\\\n -1.19 \\\\\n -2.46 \\\\\n 1.45 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.447 \\\\\n 0.816 \\\\\n 0.384 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2, 1],\n [3, -1, -2],\n [1, 3, 1],\n [-1, 1, 0],\n [2, -2, 2],\n [0, 1, 1]])\nb = np.array([\n [0.56],\n [-2.99],\n [2.94],\n [-1.19],\n [-2.46],\n [1.45]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{5}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 0 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{5} \\\\\n 0 \\\\\n -\\frac{7}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [0],\n [-7]])\nprint(a * (1/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 9 & -8 & \\frac{19}{4} \\\\\n 4 & 3 & -\\frac{9}{4} \\\\\n \\frac{15}{2} & \\frac{3}{2} & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{0.964\\, -2.988 i,0.964\\, +2.988 i,10.323\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -8, (19/4)],\n [4, 3, -(9/4)],\n [(15/2), (3/2), (1/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{68}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(4/(math.sqrt(3)))]])\nb = np.array([\n [-(17/(math.sqrt(3)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 8 & -10 & -8 & -10 \\\\\n 8 & 9 & 10 & -7 \\\\\n -4 & -6 & 2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{15.,-12.,10.,16.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [8, -10, -8, -10],\n [8, 9, 10, -7],\n [-4, -6, 2, -2]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-2,-2,1\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [-2],\n [-2],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{22}{5} & \\frac{43}{5} & 4 \\\\\n \\frac{1}{5} & -\\frac{9}{5} & -4 \\\\\n \\frac{8}{5} & -\\frac{6}{5} & \\frac{42}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-3.18,5.047,9.133\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(22/5), (43/5), 4],\n [(1/5), -(9/5), -4],\n [(8/5), -(6/5), (42/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & -1 \\\\\n 2 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+x-10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1],\n [2, -4]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,-1,-2\\}, \\{-2,2,3\\}, \\{-3,-3,1\\}}$", - "Output Answer": [ - "${\\left\\{0,-\\frac{1}{\\sqrt{5}},-\\frac{2}{\\sqrt{5}}\\right\\}, \\left\\{-2 \\sqrt{\\frac{5}{21}},\\frac{2}{\\sqrt{105}},-\\frac{1}{\\sqrt{105}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{21}},-\\frac{4}{\\sqrt{21}},\\frac{2}{\\sqrt{21}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, -1, -2), (-2, 2, 3), (-3, -3, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{4} & \\frac{35}{8} \\\\\n -\\frac{15}{8} & -\\frac{25}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{8}{31} & -\\frac{56}{155} \\\\\n \\frac{24}{155} & -\\frac{16}{155} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/4), (35/8)],\n [-(15/8), -(25/8)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{2} & -9 & \\frac{13}{2} \\\\\n 8 & -\\frac{11}{2} & -4 \\\\\n \\frac{7}{2} & \\frac{1}{2} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-2.269-6.618 i,-2.269+6.618 i,7.039\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2), -9, (13/2)],\n [8, -(11/2), -4],\n [(7/2), (1/2), (3/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 2 & \\frac{2}{3} & -\\frac{8}{3} \\\\\n 1 & -1 & \\frac{1}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n \\frac{4}{3} \\\\\n -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{34}{9} \\\\\n -\\frac{4}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, (2/3), -(8/3)],\n [1, -1, (1/3)]])\nb = np.array([\n [1],\n [(4/3)],\n [-(1/3)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -1 & -2 \\\\\n -2 & 2 & 2 \\\\\n 1 & 1 & -2 \\\\\n 3 & 2 & 0 \\\\\n 3 & -3 & -1 \\\\\n -1 & -3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.2 \\\\\n 2.07 \\\\\n -1.99 \\\\\n 1.75 \\\\\n 2.97 \\\\\n 0.87 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.726 \\\\\n -0.016 \\\\\n 0.881 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, -2],\n [-2, 2, 2],\n [1, 1, -2],\n [3, 2, 0],\n [3, -3, -1],\n [-1, -3, 3]])\nb = np.array([\n [-2.2],\n [2.07],\n [-1.99],\n [1.75],\n [2.97],\n [0.87]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & 1 & -6 \\\\\n -4 & -6 & -9 \\\\\n -5 & -7 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.418,-0.181,1.\\}, \\{0.212,1.986,1.\\}, \\{2.266,-1.704,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 1, -6],\n [-4, -6, -9],\n [-5, -7, 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{7}{3} & \\frac{8}{3} & -\\frac{8}{3} \\\\\n \\frac{2}{3} & 4 & -\\frac{10}{3} \\\\\n \\frac{2}{3} & -\\frac{4}{3} & -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{39}{71} & -\\frac{27}{71} & -\\frac{3}{71} \\\\\n -\\frac{3}{142} & \\frac{123}{568} & -\\frac{81}{568} \\\\\n \\frac{6}{71} & -\\frac{33}{284} & -\\frac{51}{284} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/3), (8/3), -(8/3)],\n [(2/3), 4, -(10/3)],\n [(2/3), -(4/3), -(14/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -9 & 10 \\\\\n -5 & 3 \\\\\n -5 & 6 \\\\\n 3 & 0 \\\\\n -2 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-9, 10],\n [-5, 3],\n [-5, 6],\n [3, 0],\n [-2, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -2 & 2 & -3 & -3 & 2 \\\\\n -2 & 3 & 2 & 2 & 3 \\\\\n -2 & -2 & -3 & 0 & -1 \\\\\n 0 & 0 & 3 & 3 & 0 \\\\\n -2 & -1 & -1 & 2 & -1 \\\\\n 3 & 0 & -3 & 2 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.64 \\\\\n 1.27 \\\\\n -0.65 \\\\\n -1. \\\\\n -0.26 \\\\\n 0.6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.051 \\\\\n 0.545 \\\\\n -0.141 \\\\\n 0.031 \\\\\n -0.119 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2, -3, -3, 2],\n [-2, 3, 2, 2, 3],\n [-2, -2, -3, 0, -1],\n [0, 0, 3, 3, 0],\n [-2, -1, -1, 2, -1],\n [3, 0, -3, 2, 0]])\nb = np.array([\n [0.64],\n [1.27],\n [-0.65],\n [-1.],\n [-0.26],\n [0.6]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -3 & 5 & 1 \\\\\n 2 & -4 & 1 \\\\\n -4 & 2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{5}{11} & \\frac{4}{11} & -\\frac{9}{22} \\\\\n \\frac{4}{11} & \\frac{1}{11} & -\\frac{5}{22} \\\\\n \\frac{6}{11} & \\frac{7}{11} & -\\frac{1}{11} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 5, 1],\n [2, -4, 1],\n [-4, 2, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{20}{9} & \\frac{4}{3} & -\\frac{14}{9} & \\frac{19}{9} \\\\\n \\frac{22}{9} & -\\frac{13}{9} & \\frac{8}{9} & -\\frac{16}{9} \\\\\n \\frac{1}{3} & \\frac{16}{9} & \\frac{1}{9} & \\frac{10}{9} \\\\\n 1 & \\frac{1}{9} & -2 & -\\frac{23}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{8}{9} \\\\\n \\frac{23}{9} \\\\\n \\frac{23}{9} \\\\\n \\frac{4}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{190}{81} \\\\\n -\\frac{355}{81} \\\\\n \\frac{407}{81} \\\\\n -\\frac{185}{27} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/9), (4/3), -(14/9), (19/9)],\n [(22/9), -(13/9), (8/9), -(16/9)],\n [(1/3), (16/9), (1/9), (10/9)],\n [1, (1/9), -2, -(23/9)]])\nb = np.array([\n [-(8/9)],\n [(23/9)],\n [(23/9)],\n [(4/9)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{9} \\\\\n \\frac{20}{9} \\\\\n \\frac{20}{9} \\\\\n \\frac{1}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{19}{9} \\\\\n \\frac{17}{9} \\\\\n -\\frac{8}{9} \\\\\n \\frac{64}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{16}{3} \\\\\n \\frac{1}{3} \\\\\n \\frac{28}{9} \\\\\n -\\frac{61}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/9)],\n [(20/9)],\n [(20/9)],\n [(1/3)]])\nb = np.array([\n [(19/9)],\n [(17/9)],\n [-(8/9)],\n [(64/9)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & -3 & -3 \\\\\n -2 & -2 & -2 \\\\\n 0 & 1 & -3 \\\\\n -2 & 0 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.42 \\\\\n 0.15 \\\\\n 0.84 \\\\\n 1.07 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.5 \\\\\n 0.553 \\\\\n -0.094 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, -3],\n [-2, -2, -2],\n [0, 1, -3],\n [-2, 0, -1]])\nb = np.array([\n [-0.42],\n [0.15],\n [0.84],\n [1.07]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{33}{5} & \\frac{39}{5} & -\\frac{17}{5} \\\\\n \\frac{8}{5} & \\frac{43}{5} & -1 \\\\\n -\\frac{24}{5} & \\frac{49}{5} & \\frac{18}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.193,0.447,1.\\}, \\{0.583,0.009,1.\\}, \\{5.418,3.395,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(33/5), (39/5), -(17/5)],\n [(8/5), (43/5), -1],\n [-(24/5), (49/5), (18/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{4}{3} & \\frac{8}{3} \\\\\n \\frac{17}{3} & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{17} \\left(-11-\\sqrt{257}\\right),1\\right\\}, \\left\\{\\frac{1}{17} \\left(\\sqrt{257}-11\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/3), (8/3)],\n [(17/3), 6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 10 & -5 & -1 & 0 & 10 & 5 & -2 \\\\\n -9 & 7 & -7 & -10 & -5 & -5 & 8 \\\\\n -1 & 0 & 3 & -9 & -6 & 2 & 0 \\\\\n 2 & 5 & 3 & -1 & 5 & 8 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & \\frac{9447}{6853} & \\frac{6730}{6853} & -\\frac{246}{979} \\\\\n 0 & 1 & 0 & 0 & \\frac{862}{979} & \\frac{840}{979} & \\frac{12}{979} \\\\\n 0 & 0 & 1 & 0 & -\\frac{4230}{6853} & \\frac{3635}{6853} & -\\frac{562}{979} \\\\\n 0 & 0 & 0 & 1 & \\frac{2109}{6853} & -\\frac{1059}{6853} & -\\frac{160}{979} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, -5, -1, 0, 10, 5, -2],\n [-9, 7, -7, -10, -5, -5, 8],\n [-1, 0, 3, -9, -6, 2, 0],\n [2, 5, 3, -1, 5, 8, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 4 & -10 & 8 & 3 & 9 & 4 & -1 \\\\\n -4 & -7 & -4 & -4 & 3 & 6 & -5 \\\\\n -5 & 3 & -10 & 0 & 7 & 5 & 5 \\\\\n -5 & -8 & 2 & -4 & 8 & -4 & 5 \\\\\n 2 & -9 & 0 & 7 & 1 & -7 & 9 \\\\\n 0 & 9 & -3 & -5 & 9 & 9 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & -\\frac{1192211}{758753} \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & \\frac{195971}{758753} \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & \\frac{246155}{758753} \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & \\frac{1141793}{758753} \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & \\frac{238266}{758753} \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & -\\frac{392303}{758753} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, -10, 8, 3, 9, 4, -1],\n [-4, -7, -4, -4, 3, 6, -5],\n [-5, 3, -10, 0, 7, 5, 5],\n [-5, -8, 2, -4, 8, -4, 5],\n [2, -9, 0, 7, 1, -7, 9],\n [0, 9, -3, -5, 9, 9, -8]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -7 & 2 \\\\\n -9 & 4 \\\\\n 5 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, 2],\n [-9, 4],\n [5, 6]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & 9 \\\\\n -4 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0,0\\}, \\{3,2\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 9],\n [-4, 6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -8 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -4 \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -16 \\\\\n -94 \\\\\n -84 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-8],\n [8]])\nb = np.array([\n [-8],\n [-4],\n [6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -1 & 8 \\\\\n -8 & 1 \\\\\n 6 & -4 \\\\\n 5 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-1, 8],\n [-8, 1],\n [6, -4],\n [5, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\pi \\\\\n 2 \\pi \\\\\n \\pi \\\\\n 3 \\pi \\\\\n 3 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\pi \\\\\n 0 \\\\\n \\pi \\\\\n -2 \\pi \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{38} \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-math.pi],\n [2*math.pi],\n [math.pi],\n [3*math.pi],\n [3*math.pi]])\nb = np.array([\n [-math.pi],\n [0],\n [math.pi],\n [-2*math.pi],\n [0]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & -8 \\\\\n 8 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-9 x+78$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -8],\n [8, 7]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 5 & 3 \\\\\n 8 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(13-\\sqrt{105}\\right),\\frac{1}{2} \\left(13+\\sqrt{105}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 3],\n [8, 8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 7 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -32 \\\\\n 37 \\\\\n -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [7],\n [3]])\nb = np.array([\n [-1],\n [-1],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & -1 & -8 \\\\\n 8 & -7 & -3 \\\\\n -3 & 5 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-9.469,-4.111,7.579\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -1, -8],\n [8, -7, -3],\n [-3, 5, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -\\frac{1}{3} & \\frac{29}{6} \\\\\n 2 & -\\frac{7}{6} & \\frac{3}{2} \\\\\n -\\frac{4}{3} & \\frac{10}{3} & -\\frac{1}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{3247}{108}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -(1/3), (29/6)],\n [2, -(7/6), (3/2)],\n [-(4/3), (10/3), -(1/6)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -3 & 10 & 7 & -6 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 10, 7, -6, -5]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{41}{5} & -\\frac{11}{5} \\\\\n 6 & \\frac{34}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{60} i \\left(\\sqrt{1271}-7 i\\right),1\\right\\}, \\left\\{-\\frac{1}{60} i \\left(\\sqrt{1271}+7 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(41/5), -(11/5)],\n [6, (34/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{5}{3 \\sqrt{7}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [1],\n [-1],\n [1],\n [-1],\n [1],\n [1],\n [1],\n [1]]).squeeze()\nb = np.array([\n [0],\n [1],\n [-1],\n [0],\n [-1],\n [-1],\n [1],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -10 & 8 \\\\\n -4 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, 8],\n [-4, 9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{6} & -3 & \\frac{11}{6} \\\\\n \\frac{5}{6} & \\frac{3}{2} & \\frac{13}{6} \\\\\n -1 & \\frac{7}{6} & \\frac{11}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 0 & -\\frac{1}{6} \\\\\n \\frac{5}{6} & -\\frac{2}{3} \\\\\n \\frac{7}{3} & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{16}{9} & \\frac{17}{36} \\\\\n \\frac{227}{36} & -\\frac{119}{36} \\\\\n \\frac{21}{4} & -\\frac{22}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/6), -3, (11/6)],\n [(5/6), (3/2), (13/6)],\n [-1, (7/6), (11/6)]])\nb = np.array([\n [0, -(1/6)],\n [(5/6), -(2/3)],\n [(7/3), -1]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & -4 \\\\\n 0 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+6 x$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -4],\n [0, -6]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & -4 \\\\\n 10 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{20} \\left(17-\\sqrt{129}\\right),1\\right\\}, \\left\\{\\frac{1}{20} \\left(17+\\sqrt{129}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -4],\n [10, -8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 3 & 2 & -1 & -1 & 0 \\\\\n 1 & -3 & -1 & -1 & -1 \\\\\n 0 & -3 & 3 & -3 & 3 \\\\\n 2 & 3 & 1 & 0 & -1 \\\\\n -3 & 1 & 1 & 3 & -3 \\\\\n -3 & -1 & 3 & 1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.64 \\\\\n -1.24 \\\\\n 1.46 \\\\\n -0.44 \\\\\n -2.81 \\\\\n 0.47 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -7.645 \\\\\n 4.67 \\\\\n -3.343 \\\\\n -12.891 \\\\\n -4.182 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2, -1, -1, 0],\n [1, -3, -1, -1, -1],\n [0, -3, 3, -3, 3],\n [2, 3, 1, 0, -1],\n [-3, 1, 1, 3, -3],\n [-3, -1, 3, 1, -1]])\nb = np.array([\n [2.64],\n [-1.24],\n [1.46],\n [-0.44],\n [-2.81],\n [0.47]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & -3 \\\\\n 3 & 0 \\\\\n -3 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.95 \\\\\n 2.49 \\\\\n -2.67 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.86 \\\\\n 1.557 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3],\n [3, 0],\n [-3, 0]])\nb = np.array([\n [-2.95],\n [2.49],\n [-2.67]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n 10 & -8 & -5 & 0 \\\\\n -10 & -5 & 9 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -8, -5, 0],\n [-10, -5, 9, -9]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -5 & 4 & -7 & 0 \\\\\n 1 & 6 & 4 & -10 \\\\\n 6 & -9 & 3 & 5 \\\\\n -10 & 10 & 9 & -9 \\\\\n -6 & 1 & 5 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, 4, -7, 0],\n [1, 6, 4, -10],\n [6, -9, 3, 5],\n [-10, 10, 9, -9],\n [-6, 1, 5, -7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 1 \\\\\n 1 \\\\\n -3 \\\\\n 2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 2 \\\\\n 0 \\\\\n 2 \\\\\n 3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{2}{11},\\frac{4}{11},0,\\frac{4}{11},\\frac{6}{11},-\\frac{4}{11}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [1],\n [1],\n [-3],\n [2],\n [-2]]).squeeze()\nb = np.array([\n [-1],\n [2],\n [0],\n [2],\n [3],\n [-2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{32}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -6 & 9 & 9 & 0 \\\\\n 7 & -7 & 2 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{21}{16} & -\\frac{63}{32} & -\\frac{63}{32} & 0 \\\\\n -\\frac{49}{32} & \\frac{49}{32} & -\\frac{7}{16} & \\frac{35}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 9, 9, 0],\n [7, -7, 2, -10]])\nprint(a * -(7/32))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -7 & -\\frac{28}{9} & \\frac{61}{9} \\\\\n \\frac{23}{3} & \\frac{22}{3} & -\\frac{25}{9} \\\\\n \\frac{10}{3} & -6 & \\frac{11}{9} \\\\\n -\\frac{22}{3} & -7 & -\\frac{26}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{31}{9} & -\\frac{10}{3} & 8 \\\\\n \\frac{41}{9} & -\\frac{35}{9} & -\\frac{8}{3} \\\\\n \\frac{25}{3} & 10 & -\\frac{50}{9} \\\\\n \\frac{82}{9} & \\frac{16}{9} & -\\frac{88}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{32}{9} & -\\frac{58}{9} & \\frac{133}{9} \\\\\n \\frac{110}{9} & \\frac{31}{9} & -\\frac{49}{9} \\\\\n \\frac{35}{3} & 4 & -\\frac{13}{3} \\\\\n \\frac{16}{9} & -\\frac{47}{9} & -\\frac{166}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -(28/9), (61/9)],\n [(23/3), (22/3), -(25/9)],\n [(10/3), -6, (11/9)],\n [-(22/3), -7, -(26/3)]])\nb = np.array([\n [(31/9), -(10/3), 8],\n [(41/9), -(35/9), -(8/3)],\n [(25/3), 10, -(50/9)],\n [(82/9), (16/9), -(88/9)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & 1 & -\\frac{3}{2} \\\\\n 0 & \\frac{1}{2} & 0 \\\\\n -1 & -\\frac{3}{2} & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{3}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 1, -(3/2)],\n [0, (1/2), 0],\n [-1, -(3/2), 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -7 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -1 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 49 \\\\\n 70 \\\\\n -73 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-7],\n [0]])\nb = np.array([\n [-9],\n [-1],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -\\frac{3}{2} \\\\\n -1 \\\\\n -\\frac{5}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{4}{\\sqrt{93}} \\\\\n -2 \\sqrt{\\frac{3}{31}} \\\\\n -\\frac{4}{\\sqrt{93}} \\\\\n -\\frac{5}{\\sqrt{93}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-(3/2)],\n [-1],\n [-(5/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,-2,5\\}, \\{-2,3,-2\\}, \\{-3,2,-3\\}}$.", - "Output Answer": [ - "$4 x-3 y-z+15=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, -2, 5],\n [-2, 3, -2],\n [-3, 2, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{4,-1,\\frac{11}{3}\\right\\}, \\left\\{-\\frac{2}{3},\\frac{5}{3},-\\frac{10}{3}\\right\\}, \\left\\{-\\frac{2}{3},\\frac{14}{3},\\frac{2}{3}\\right\\}}$.", - "Output Answer": [ - "$95 x+56 y-42 z-170=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, -1, (11/3)],\n [-(2/3), (5/3), -(10/3)],\n [-(2/3), (14/3), (2/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & -2 \\\\\n -1 & -2 & 2 \\\\\n 0 & 0 & -2 \\\\\n -1 & 3 & -3 \\\\\n -3 & -2 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.49 \\\\\n 1.5 \\\\\n -2.52 \\\\\n 0.73 \\\\\n -1.43 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.149 \\\\\n 0.532 \\\\\n 0.587 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, -2],\n [-1, -2, 2],\n [0, 0, -2],\n [-1, 3, -3],\n [-3, -2, 1]])\nb = np.array([\n [-0.49],\n [1.5],\n [-2.52],\n [0.73],\n [-1.43]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{11}{7} \\\\\n -3 \\\\\n -\\frac{1}{7} \\\\\n \\frac{13}{7} \\\\\n \\frac{11}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{11}{\\sqrt{853}} \\\\\n -\\frac{21}{\\sqrt{853}} \\\\\n -\\frac{1}{\\sqrt{853}} \\\\\n \\frac{13}{\\sqrt{853}} \\\\\n \\frac{11}{\\sqrt{853}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/7)],\n [-3],\n [-(1/7)],\n [(13/7)],\n [(11/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & 9 \\\\\n -3 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(5-\\sqrt{61}\\right),\\frac{1}{2} \\left(5+\\sqrt{61}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 9],\n [-3, 9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & 2 & 0 \\\\\n -1 & -3 & -2 \\\\\n -1 & -1 & 1 \\\\\n -1 & -2 & -2 \\\\\n 0 & 3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.85 \\\\\n 0.25 \\\\\n 1.02 \\\\\n 0.5 \\\\\n -2.66 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.394 \\\\\n -1.218 \\\\\n 0.515 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, 0],\n [-1, -3, -2],\n [-1, -1, 1],\n [-1, -2, -2],\n [0, 3, 3]])\nb = np.array([\n [-0.85],\n [0.25],\n [1.02],\n [0.5],\n [-2.66]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n \\frac{43}{16} & -\\frac{1}{4} \\\\\n -\\frac{9}{8} & -\\frac{13}{16} \\\\\n \\frac{43}{16} & \\frac{47}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{13}{8} & \\frac{31}{16} & -\\frac{11}{16} & \\frac{1}{8} \\\\\n \\frac{11}{4} & \\frac{13}{8} & \\frac{7}{8} & -\\frac{15}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{471}{128} & \\frac{1229}{256} & -\\frac{529}{256} & \\frac{103}{128} \\\\\n -\\frac{65}{16} & -\\frac{7}{2} & \\frac{1}{16} & \\frac{177}{128} \\\\\n \\frac{1593}{128} & \\frac{2555}{256} & \\frac{185}{256} & -\\frac{331}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(43/16), -(1/4)],\n [-(9/8), -(13/16)],\n [(43/16), (47/16)]])\nb = np.array([\n [(13/8), (31/16), -(11/16), (1/8)],\n [(11/4), (13/8), (7/8), -(15/8)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,0,1\\}, \\{0,-2,-2\\}, \\{-1,-1,-2\\}}$", - "Output Answer": [ - "${\\{0,0,1\\}, \\{0,-1,0\\}, \\{-1,0,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, 0, 1), (0, -2, -2), (-1, -1, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\sqrt{2} \\\\\n -4 \\sqrt{2} \\\\\n -2 \\sqrt{2} \\\\\n 0 \\\\\n -4 \\sqrt{2} \\\\\n 2 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\sqrt{2} \\\\\n 3 \\sqrt{2} \\\\\n 0 \\\\\n -2 \\sqrt{2} \\\\\n -2 \\sqrt{2} \\\\\n 4 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.sqrt(2)],\n [-4*math.sqrt(2)],\n [-2*math.sqrt(2)],\n [0],\n [-4*math.sqrt(2)],\n [2*math.sqrt(2)]])\nb = np.array([\n [-3*math.sqrt(2)],\n [3*math.sqrt(2)],\n [0],\n [-2*math.sqrt(2)],\n [-2*math.sqrt(2)],\n [4*math.sqrt(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & 4 & 7 \\\\\n -1 & -4 & 5 \\\\\n 10 & 3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1.071,0.226,1.\\}, \\{-0.173-0.914 i,-1.654+2.513 i,1.\\}, \\{-0.173+0.914 i,-1.654-2.513 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 4, 7],\n [-1, -4, 5],\n [10, 3, 2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 5 & -9 \\\\\n 3 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(11-i \\sqrt{107}\\right),\\frac{1}{2} \\left(11+i \\sqrt{107}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -9],\n [3, 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{11}{32}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{99}{32} \\\\\n -\\frac{99}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-9]])\nprint(a * (11/32))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -10 & -8 \\\\\n 9 & -9 \\\\\n -9 & -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 5 & 2 \\\\\n 1 & -4 \\\\\n -2 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -5 & -6 \\\\\n 10 & -13 \\\\\n -11 & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -8],\n [9, -9],\n [-9, -5]])\nb = np.array([\n [5, 2],\n [1, -4],\n [-2, -1]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & 7 \\\\\n 5 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{10} \\left(13-\\sqrt{309}\\right),1\\right\\}, \\left\\{\\frac{1}{10} \\left(13+\\sqrt{309}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 7],\n [5, -6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{6}{5}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -6 \\\\\n -6 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{36}{5} \\\\\n \\frac{36}{5} \\\\\n -\\frac{48}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-6],\n [-6],\n [8]])\nprint(a * -(6/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{11}{3}, -\\frac{2}{3}, \\frac{2}{3}}$ to the plane $-4 x-\\frac{5 y}{3}+\\frac{11 z}{3}+4=0$.", - "Output Answer": [ - "$\\frac{20 \\sqrt{\\frac{10}{29}}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(11/3), -(2/3), (2/3)\nplane = Poly(-4*x-((5*y)/3)+((11*z)/3)+4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{37}{4} & -1 & -\\frac{1}{4} & \\frac{31}{4} & \\frac{13}{4} \\\\\n \\frac{7}{2} & \\frac{11}{4} & -\\frac{13}{2} & -7 & \\frac{9}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(37/4), -1, -(1/4), (31/4), (13/4)],\n [(7/2), (11/4), -(13/2), -7, (9/4)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{9}{2}, \\frac{21}{8}}$ to the line $-2 x+\\frac{129 y}{32}-\\frac{55}{16}=0$.", - "Output Answer": [ - "$\\frac{475}{8 \\sqrt{20737}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (9/2), (21/8)\nline = Poly(-2*x+((129*y)/32)-(55/16), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 0 & 10 \\\\\n 2 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, 10],\n [2, -6]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,0,-4\\}, \\{0,-2,-2\\}, \\{4,-5,2\\}}$.", - "Output Answer": [ - "$2 x-4 y-5 z-18=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, 0, -4],\n [0, -2, -2],\n [4, -5, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -1 & -1 & 2 & -1 & 1 \\\\\n -1 & 3 & 2 & 2 & 0 \\\\\n 0 & 1 & -2 & -2 & -2 \\\\\n -1 & 1 & -3 & -2 & -2 \\\\\n -1 & -1 & 2 & 1 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & 2 & -2 & 3 \\\\\n -2 & 1 & -1 & -1 \\\\\n 2 & 1 & -1 & 2 \\\\\n 2 & -3 & -2 & -3 \\\\\n -3 & 0 & 1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -1 & 2 & 4 & 3 \\\\\n 0 & -3 & -7 & -8 \\\\\n -4 & 5 & 3 & 5 \\\\\n -8 & 2 & 6 & 0 \\\\\n 3 & -4 & 0 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, 2, -1, 1],\n [-1, 3, 2, 2, 0],\n [0, 1, -2, -2, -2],\n [-1, 1, -3, -2, -2],\n [-1, -1, 2, 1, 1]])\nb = np.array([\n [2, 2, -2, 3],\n [-2, 1, -1, -1],\n [2, 1, -1, 2],\n [2, -3, -2, -3],\n [-3, 0, 1, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -6 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -5 \\\\\n -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 26 \\\\\n 24 \\\\\n 36 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-6],\n [4]])\nb = np.array([\n [6],\n [-5],\n [-1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{5} \\\\\n \\frac{5}{2} \\\\\n \\frac{19}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2 \\sqrt{\\frac{2}{501}} \\\\\n \\frac{25}{\\sqrt{1002}} \\\\\n \\frac{19}{\\sqrt{1002}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/5)],\n [(5/2)],\n [(19/10)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{29}{3} & \\frac{26}{3} \\\\\n -\\frac{19}{2} & \\frac{29}{3} \\\\\n -\\frac{25}{6} & -\\frac{37}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{8}{3} & \\frac{16}{3} \\\\\n \\frac{35}{6} & \\frac{11}{3} \\\\\n 6 & -\\frac{41}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{37}{3} & 14 \\\\\n -\\frac{11}{3} & \\frac{40}{3} \\\\\n \\frac{11}{6} & -13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/3), (26/3)],\n [-(19/2), (29/3)],\n [-(25/6), -(37/6)]])\nb = np.array([\n [-(8/3), (16/3)],\n [(35/6), (11/3)],\n [6, -(41/6)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{7}{3} & -7 & \\frac{59}{6} \\\\\n \\frac{11}{6} & -\\frac{25}{6} & \\frac{37}{6} \\\\\n -\\frac{9}{2} & -\\frac{25}{6} & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{37 x^2}{6}-\\frac{1051 x}{18}+\\frac{2117}{108}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/3), -7, (59/6)],\n [(11/6), -(25/6), (37/6)],\n [-(9/2), -(25/6), 8]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & -\\frac{13}{3} \\\\\n 4 & \\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{85}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -(13/3)],\n [4, (11/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{79}{10} \\\\\n -4 \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{43}{10} \\\\\n 8 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -4 \\\\\n -\\frac{89}{4} \\\\\n -\\frac{402}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(79/10)],\n [-4],\n [(3/2)]])\nb = np.array([\n [-(43/10)],\n [8],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 1 & 3 \\\\\n 0 & -4 & 2 \\\\\n 3 & -4 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$42$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 3],\n [0, -4, 2],\n [3, -4, -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 2 \\\\\n 9 \\\\\n -5 \\\\\n 5 \\\\\n 2 \\\\\n -1 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -9 \\\\\n -6 \\\\\n 4 \\\\\n 5 \\\\\n 1 \\\\\n -6 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-33$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [2],\n [9],\n [-5],\n [5],\n [2],\n [-1],\n [-8]])\nb = np.array([\n [-7],\n [-9],\n [-6],\n [4],\n [5],\n [1],\n [-6],\n [2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{2} \\\\\n 6 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -6 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 60 \\\\\n \\frac{65}{2} \\\\\n 27 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/2)],\n [6],\n [5]])\nb = np.array([\n [1],\n [-6],\n [5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{7}{2},-3,-4\\right\\}, \\left\\{\\frac{3}{2},-4,3\\right\\}, \\left\\{2,\\frac{7}{2},\\frac{3}{2}\\right\\}}$.", - "Output Answer": [ - "$102 x-22 y-76 z-13=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(7/2), -3, -4],\n [(3/2), -4, 3],\n [2, (7/2), (3/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -3 & 0 \\\\\n 4 & -3 \\\\\n 2 & -8 \\\\\n -7 & -5 \\\\\n 4 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 0],\n [4, -3],\n [2, -8],\n [-7, -5],\n [4, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 9 & 5 & -4 \\\\\n -3 & 5 & -6 \\\\\n 6 & -9 & -7 \\\\\n -3 & 0 & 4 \\\\\n 10 & -9 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, 5, -4],\n [-3, 5, -6],\n [6, -9, -7],\n [-3, 0, 4],\n [10, -9, -1]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${4, 2}$ to the line $-x+4 y-1=0$.", - "Output Answer": [ - "$\\frac{3}{\\sqrt{17}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 4, 2\nline = Poly(-x+4*y-1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & 1 \\\\\n 5 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1],\n [5, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{48}{5} & -\\frac{13}{5} & \\frac{53}{10} \\\\\n 10 & -\\frac{19}{10} & -2 \\\\\n -\\frac{12}{5} & \\frac{87}{10} & \\frac{9}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{97 x^2}{10}-\\frac{2683 x}{50}+\\frac{84261}{250}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(48/5), -(13/5), (53/10)],\n [10, -(19/10), -2],\n [-(12/5), (87/10), (9/5)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{2}} \\\\\n -\\frac{1}{\\sqrt{2}} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{7}{\\sqrt{2}} \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{7}{2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(1/(math.sqrt(2)))],\n [-(1/(math.sqrt(2)))]])\nb = np.array([\n [(7/(math.sqrt(2)))],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -1 \\\\\n -8 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 9 \\\\\n 3 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{26}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-1],\n [-8],\n [-4]])\nb = np.array([\n [7],\n [9],\n [3],\n [-6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\pi \\\\\n -2 \\pi \\\\\n -\\pi \\\\\n \\pi \\\\\n \\pi \\\\\n -\\pi \\\\\n -2 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\pi \\\\\n 2 \\pi \\\\\n -2 \\pi \\\\\n 2 \\pi \\\\\n -3 \\pi \\\\\n 2 \\pi \\\\\n -2 \\pi \\\\\n -3 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{38} \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [-math.pi],\n [-2*math.pi],\n [-math.pi],\n [math.pi],\n [math.pi],\n [-math.pi],\n [-2*math.pi]])\nb = np.array([\n [-math.pi],\n [2*math.pi],\n [-2*math.pi],\n [2*math.pi],\n [-3*math.pi],\n [2*math.pi],\n [-2*math.pi],\n [-3*math.pi]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 9 & -1 & -8 \\\\\n 5 & -9 & -6 \\\\\n -1 & -4 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-13.782,-5.819,9.601\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -1, -8],\n [5, -9, -6],\n [-1, -4, -10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -6 \\\\\n 9 \\\\\n 0 \\\\\n -9 \\\\\n 1 \\\\\n -5 \\\\\n 9 \\\\\n 4 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 8 \\\\\n 7 \\\\\n 7 \\\\\n -5 \\\\\n 5 \\\\\n -5 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6 \\sqrt{19}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-6],\n [9],\n [0],\n [-9],\n [1],\n [-5],\n [9],\n [4],\n [0]])\nb = np.array([\n [1],\n [-1],\n [8],\n [7],\n [7],\n [-5],\n [5],\n [-5],\n [0],\n [1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -2 & -3 & -1 & 3 \\\\\n 1 & 3 & 2 & 0 \\\\\n -1 & -1 & 2 & 1 \\\\\n 0 & 1 & -2 & -2 \\\\\n 1 & 2 & 0 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 1 \\\\\n -2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3 \\\\\n -3 \\\\\n -3 \\\\\n 5 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, -1, 3],\n [1, 3, 2, 0],\n [-1, -1, 2, 1],\n [0, 1, -2, -2],\n [1, 2, 0, -2]])\nb = np.array([\n [-2],\n [1],\n [-2],\n [0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 5 & -10 \\\\\n -5 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, -10],\n [-5, 8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,-3,4\\}, \\{4,-2,-2\\}, \\{-4,3,2\\}}$.", - "Output Answer": [ - "$34 x+20 y+43 z-10=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, -3, 4],\n [4, -2, -2],\n [-4, 3, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{7}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -5 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{7} & -\\frac{5}{7} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -5, 0]])\nprint(a * (1/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -1 & -4 & -1 & 0 \\\\\n 4 & -7 & -6 & -2 \\\\\n 8 & -8 & -1 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & -\\frac{127}{193} \\\\\n 0 & 1 & 0 & \\frac{52}{193} \\\\\n 0 & 0 & 1 & -\\frac{81}{193} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-1, -4, -1, 0],\n [4, -7, -6, -2],\n [8, -8, -1, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 0 & -2 & 2 \\\\\n 3 & -1 & 0 \\\\\n 0 & 1 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2 \\\\\n 7 \\\\\n -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2, 2],\n [3, -1, 0],\n [0, 1, 1]])\nb = np.array([\n [2],\n [-1],\n [0]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n -4 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n -6 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$111$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [3*math.sqrt(3)],\n [-2*math.sqrt(3)],\n [-4*math.sqrt(3)]])\nb = np.array([\n [3*math.sqrt(3)],\n [-2*math.sqrt(3)],\n [-6*math.sqrt(3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{4,-3,-4\\}, \\{2,1,3\\}, \\{5,-2,-4\\}}$.", - "Output Answer": [ - "$7 x-7 y+6 z-25=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, -3, -4],\n [2, 1, 3],\n [5, -2, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{26}{3} & \\frac{11}{9} & \\frac{83}{9} \\\\\n \\frac{61}{9} & \\frac{58}{9} & -\\frac{17}{9} \\\\\n -\\frac{22}{9} & -\\frac{43}{9} & \\frac{13}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{175 x^2}{9}-\\frac{10252 x}{81}-\\frac{14438}{729}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/3), (11/9), (83/9)],\n [(61/9), (58/9), -(17/9)],\n [-(22/9), -(43/9), (13/3)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{32}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -6 & -2 \\\\\n 5 & 6 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{32} & \\frac{21}{16} & \\frac{7}{16} \\\\\n -\\frac{35}{32} & -\\frac{21}{16} & -\\frac{21}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -6, -2],\n [5, 6, 3]])\nprint(a * -(7/32))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -e \\\\\n e \\\\\n -2 e \\\\\n -3 e \\\\\n -3 e \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 e \\\\\n -2 e \\\\\n 3 e \\\\\n 4 e \\\\\n 2 e \\\\\n e \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-12 e^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [-math.e],\n [math.e],\n [-2*math.e],\n [-3*math.e],\n [-3*math.e]])\nb = np.array([\n [2*math.e],\n [-2*math.e],\n [3*math.e],\n [4*math.e],\n [2*math.e],\n [math.e]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{37}{10} & -\\frac{19}{5} & -\\frac{3}{2} \\\\\n -3 & \\frac{29}{10} & -\\frac{5}{2} \\\\\n \\frac{11}{5} & -\\frac{19}{10} & -\\frac{24}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{18670}{7561} & -\\frac{15390}{7561} & \\frac{13850}{7561} \\\\\n -\\frac{19900}{7561} & -\\frac{14460}{7561} & \\frac{13750}{7561} \\\\\n -\\frac{680}{7561} & -\\frac{1330}{7561} & -\\frac{670}{7561} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/10), -(19/5), -(3/2)],\n [-3, (29/10), -(5/2)],\n [(11/5), -(19/10), -(24/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n \\frac{7}{3} & -7 & -1 & -1 & \\frac{4}{3} \\\\\n 9 & -\\frac{1}{3} & 10 & -1 & -\\frac{7}{3} \\\\\n \\frac{26}{3} & \\frac{7}{3} & \\frac{25}{3} & -\\frac{16}{3} & -4 \\\\\n \\frac{23}{3} & \\frac{20}{3} & -\\frac{13}{3} & 7 & -\\frac{17}{3} \\\\\n -\\frac{22}{3} & -7 & \\frac{26}{3} & 4 & -\\frac{16}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/3), -7, -1, -1, (4/3)],\n [9, -(1/3), 10, -1, -(7/3)],\n [(26/3), (7/3), (25/3), -(16/3), -4],\n [(23/3), (20/3), -(13/3), 7, -(17/3)],\n [-(22/3), -7, (26/3), 4, -(16/3)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{23}{4} \\\\\n -\\frac{977}{100} \\\\\n \\frac{883}{100} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{23}{10} \\\\\n -\\frac{33}{50} \\\\\n \\frac{109}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{183847}{5000} \\\\\n -\\frac{4761}{1000} \\\\\n \\frac{4669}{250} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/4)],\n [-(977/100)],\n [(883/100)]])\nb = np.array([\n [(23/10)],\n [-(33/50)],\n [(109/25)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{2} \\\\\n \\frac{3}{2} \\\\\n -\\frac{11}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -4 \\sqrt{\\frac{5}{133}} \\\\\n \\frac{12}{\\sqrt{665}} \\\\\n -\\frac{11}{\\sqrt{665}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2)],\n [(3/2)],\n [-(11/8)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 8 & 7 & 1 & -1 & 8 \\\\\n 1 & -4 & 10 & 10 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-74.,79.,39.,0.,0.\\}, \\{-22.,27.,0.,13.,0.\\}, \\{10.,-56.,0.,0.,39.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [8, 7, 1, -1, 8],\n [1, -4, 10, 10, -6]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -7 \\\\\n 5 \\\\\n -7 \\\\\n 9 \\\\\n -1 \\\\\n 7 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{299}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-7],\n [5],\n [-7],\n [9],\n [-1],\n [7],\n [3]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 8 & 9 & 4 & 4 \\\\\n 2 & 1 & 8 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -2 & -8 & -4 & -7 \\\\\n 1 & 3 & 8 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 6 & 1 & 0 & -3 \\\\\n 3 & 4 & 16 & 16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 9, 4, 4],\n [2, 1, 8, 8]])\nb = np.array([\n [-2, -8, -4, -7],\n [1, 3, 8, 8]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 3 & 6 & 5 \\\\\n -6 & 6 & 6 \\\\\n 6 & 2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, 6, 5],\n [-6, 6, 6],\n [6, 2, 0]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{17}{10} & -\\frac{91}{10} & \\frac{7}{5} & \\frac{63}{10} & \\frac{93}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/10), -(91/10), (7/5), (63/10), (93/10)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-3,\\frac{5}{2},-1\\right\\}, \\left\\{-\\frac{7}{2},-2,-\\frac{5}{2}\\right\\}, \\left\\{3,-\\frac{7}{2},1\\right\\}}$.", - "Output Answer": [ - "$9 x+4 y-15 z+2=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, (5/2), -1],\n [-(7/2), -2, -(5/2)],\n [3, -(7/2), 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -4 & -10 & 5 \\\\\n -2 & -1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & \\frac{25}{16} \\\\\n 0 & 1 & -\\frac{9}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-4, -10, 5],\n [-2, -1, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\pi \\\\\n -2 \\pi \\\\\n \\pi \\\\\n 3 \\pi \\\\\n 0 \\\\\n 2 \\pi \\\\\n -\\pi \\\\\n -2 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 \\pi \\\\\n -2 \\pi \\\\\n -3 \\pi \\\\\n -3 \\pi \\\\\n 2 \\pi \\\\\n -2 \\pi \\\\\n 2 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-15 \\pi ^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [2*math.pi],\n [-2*math.pi],\n [math.pi],\n [3*math.pi],\n [0],\n [2*math.pi],\n [-math.pi],\n [-2*math.pi]])\nb = np.array([\n [0],\n [3*math.pi],\n [-2*math.pi],\n [-3*math.pi],\n [-3*math.pi],\n [2*math.pi],\n [-2*math.pi],\n [2*math.pi]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -4 \\\\\n 8 \\\\\n -2 \\\\\n -7 \\\\\n 4 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$30$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-4],\n [8],\n [-2],\n [-7],\n [4],\n [2]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n \\frac{5}{3} \\\\\n \\frac{11}{6} \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{5}{3} & -\\frac{3}{2} & -\\frac{7}{6} & -\\frac{17}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{25}{9} & -\\frac{5}{2} & -\\frac{35}{18} & -\\frac{85}{18} \\\\\n -\\frac{55}{18} & -\\frac{11}{4} & -\\frac{77}{36} & -\\frac{187}{36} \\\\\n 5 & \\frac{9}{2} & \\frac{7}{2} & \\frac{17}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3)],\n [(11/6)],\n [-3]])\nb = np.array([\n [-(5/3), -(3/2), -(7/6), -(17/6)]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{41}{10} \\\\\n \\frac{21}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{41}{10}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(41/10)],\n [(21/10)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -5 & -2 & -4 & -10 & 0 \\\\\n -6 & 4 & -2 & -2 & 0 \\\\\n 9 & -5 & 10 & -6 & 1 \\\\\n 4 & 10 & -1 & -4 & 9 \\\\\n -3 & 7 & 1 & 2 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -2, -4, -10, 0],\n [-6, 4, -2, -2, 0],\n [9, -5, 10, -6, 1],\n [4, 10, -1, -4, 9],\n [-3, 7, 1, 2, 5]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & 0 & 3 \\\\\n 2 & 1 & -3 \\\\\n 0 & -1 & 0 \\\\\n 0 & 2 & 1 \\\\\n -1 & 3 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.06 \\\\\n -2.17 \\\\\n -2.12 \\\\\n 1.77 \\\\\n -2.55 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2.51 \\\\\n -0.423 \\\\\n 2.346 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, 3],\n [2, 1, -3],\n [0, -1, 0],\n [0, 2, 1],\n [-1, 3, 1]])\nb = np.array([\n [0.06],\n [-2.17],\n [-2.12],\n [1.77],\n [-2.55]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 10 & \\frac{47}{5} & \\frac{28}{5} \\\\\n \\frac{36}{5} & -5 & -\\frac{43}{5} \\\\\n \\frac{37}{5} & -5 & -\\frac{33}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.603,1.113,1.\\}, \\{0.385,-0.962,1.\\}, \\{3.327,0.809,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, (47/5), (28/5)],\n [(36/5), -5, -(43/5)],\n [(37/5), -5, -(33/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -2 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 4 \\\\\n -40 \\\\\n -19 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [1],\n [0]])\nb = np.array([\n [-1],\n [-2],\n [4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{49}{6} \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{23}{6} \\\\\n 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{13}{3} \\\\\n 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(49/6)],\n [3]])\nb = np.array([\n [-(23/6)],\n [3]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{9}{5}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 2 \\\\\n 4 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{18}{5} \\\\\n -\\frac{18}{5} \\\\\n -\\frac{36}{5} \\\\\n \\frac{63}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [2],\n [4],\n [-7]])\nprint(a * -(9/5))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{2} & -\\frac{8}{3} \\\\\n \\frac{25}{6} & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{967}{36}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2), -(8/3)],\n [(25/6), (9/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & 0 & 3 & 2 \\\\\n -2 & 0 & -1 & -1 \\\\\n 1 & 3 & 3 & -3 \\\\\n 2 & -3 & -3 & -2 \\\\\n 2 & -1 & -3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.55 \\\\\n -0.34 \\\\\n 0.04 \\\\\n -1.24 \\\\\n 1.83 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.2 \\\\\n 0.216 \\\\\n 0.088 \\\\\n 0.49 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, 3, 2],\n [-2, 0, -1, -1],\n [1, 3, 3, -3],\n [2, -3, -3, -2],\n [2, -1, -3, 3]])\nb = np.array([\n [1.55],\n [-0.34],\n [0.04],\n [-1.24],\n [1.83]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -7 & -8 & 7 & -5 & 3 \\\\\n -8 & 1 & 5 & -7 & 6 \\\\\n 3 & 1 & -8 & 10 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & -\\frac{3}{203} & -\\frac{26}{203} \\\\\n 0 & 1 & 0 & -\\frac{15}{29} & \\frac{15}{29} \\\\\n 0 & 0 & 1 & -\\frac{268}{203} & \\frac{181}{203} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, -8, 7, -5, 3],\n [-8, 1, 5, -7, 6],\n [3, 1, -8, 10, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & 3 \\\\\n -1 & -1 \\\\\n -2 & 3 \\\\\n 2 & -2 \\\\\n 2 & 1 \\\\\n 3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.68 \\\\\n 0.29 \\\\\n 1.59 \\\\\n 0.12 \\\\\n 2.39 \\\\\n 0.1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.469 \\\\\n 0.368 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 3],\n [-1, -1],\n [-2, 3],\n [2, -2],\n [2, 1],\n [3, -2]])\nb = np.array([\n [-1.68],\n [0.29],\n [1.59],\n [0.12],\n [2.39],\n [0.1]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{11}{10}, -\\frac{8}{5}}$ to the line $\\frac{22 x}{5}-2 y-\\frac{7}{10}=0$.", - "Output Answer": [ - "$\\frac{367}{20 \\sqrt{146}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (11/10), -(8/5)\nline = Poly(((22*x)/5)-2*y-(7/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 0 & 6 & 10 & 6 & -1 \\\\\n 0 & -2 & 5 & 8 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.,5.,-6.,5.,0.\\}, \\{0.,95.,-52.,0.,50.\\}, \\{1.,0.,0.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, 6, 10, 6, -1],\n [0, -2, 5, 8, 9]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{29}{32}, \\frac{43}{32}}$ to the line $-\\frac{21 x}{32}-\\frac{27 y}{8}-\\frac{63}{32}=0$.", - "Output Answer": [ - "$\\frac{2423}{32 \\sqrt{1345}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (29/32), (43/32)\nline = Poly(-((21*x)/32)-((27*y)/8)-(63/32), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -2 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{114}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-2],\n [7]])\nb = np.array([\n [2],\n [3],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, 2}$ to the line $-x-3 y-1=0$.", - "Output Answer": [ - "$2 \\sqrt{\\frac{2}{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, 2\nline = Poly(-x-3*y-1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{3} & \\frac{1}{3} \\\\\n -1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/3), (1/3)],\n [-1, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -1 \\\\\n 2 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1],\n [2, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\sqrt{2} \\\\\n \\sqrt{2} \\\\\n -5 \\sqrt{2} \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\sqrt{2} \\\\\n 3 \\sqrt{2} \\\\\n -6 \\sqrt{2} \\\\\n \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$70$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.sqrt(2)],\n [math.sqrt(2)],\n [-5*math.sqrt(2)],\n [0]])\nb = np.array([\n [2*math.sqrt(2)],\n [3*math.sqrt(2)],\n [-6*math.sqrt(2)],\n [math.sqrt(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 1 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -2 \\\\\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -5 \\\\\n 31 \\\\\n 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [1],\n [-7]])\nb = np.array([\n [-7],\n [-2],\n [9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 6 & 5 & 2 & -1 \\\\\n 10 & -4 & -5 & 4 \\\\\n 8 & 0 & -4 & -2 \\\\\n 6 & -9 & 0 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, 5, 2, -1],\n [10, -4, -5, 4],\n [8, 0, -4, -2],\n [6, -9, 0, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -3 & 4 & -7 & 7 & -7 \\\\\n -2 & 6 & -2 & 9 & -6 \\\\\n 5 & -6 & -7 & -2 & 0 \\\\\n -3 & -6 & 10 & -1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 4, -7, 7, -7],\n [-2, 6, -2, 9, -6],\n [5, -6, -7, -2, 0],\n [-3, -6, 10, -1, -1]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{9}{5} \\\\\n 0 \\\\\n -1 \\\\\n \\frac{2}{5} \\\\\n -\\frac{11}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3 \\sqrt{\\frac{3}{77}} \\\\\n 0 \\\\\n -\\frac{5}{\\sqrt{231}} \\\\\n \\frac{2}{\\sqrt{231}} \\\\\n -\\sqrt{\\frac{11}{21}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/5)],\n [0],\n [-1],\n [(2/5)],\n [-(11/5)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & -\\frac{3}{4} & 9 \\\\\n \\frac{7}{4} & \\frac{35}{4} & -\\frac{19}{4} \\\\\n \\frac{37}{4} & -\\frac{5}{2} & -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.631,0.247,1.\\}, \\{1.077,-3.265,1.\\}, \\{1.547,0.49,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -(3/4), 9],\n [(7/4), (35/4), -(19/4)],\n [(37/4), -(5/2), -(17/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 3 & 6 & -2 \\\\\n 10 & 2 & 8 \\\\\n -10 & 10 & -7 \\\\\n -4 & 1 & 4 \\\\\n -1 & -6 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, 6, -2],\n [10, 2, 8],\n [-10, 10, -7],\n [-4, 1, 4],\n [-1, -6, 4]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{23}{4} \\\\\n -\\frac{5}{4} \\\\\n \\frac{13}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n \\frac{15}{2} \\\\\n \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-5 \\sqrt{\\frac{6}{33499}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/4)],\n [-(5/4)],\n [(13/4)]]).squeeze()\nb = np.array([\n [-1],\n [(15/2)],\n [(7/2)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{18}{7} \\\\\n -\\frac{19}{7} \\\\\n -\\frac{12}{7} \\\\\n -\\frac{13}{7} \\\\\n -\\frac{13}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -6 \\sqrt{\\frac{3}{389}} \\\\\n -\\frac{19}{\\sqrt{1167}} \\\\\n -4 \\sqrt{\\frac{3}{389}} \\\\\n -\\frac{13}{\\sqrt{1167}} \\\\\n -\\frac{13}{\\sqrt{1167}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(18/7)],\n [-(19/7)],\n [-(12/7)],\n [-(13/7)],\n [-(13/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & 0 & -2 \\\\\n -2 & 3 & 7 \\\\\n -5 & 1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-5.328,-28.267,1.\\}, \\{-0.362,1.709,1.\\}, \\{0.691,-1.442,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, -2],\n [-2, 3, 7],\n [-5, 1, 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{12}{7}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -6 & 1 & 1 & 8 \\\\\n 5 & -9 & -2 & -2 \\\\\n 7 & -2 & 6 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{72}{7} & -\\frac{12}{7} & -\\frac{12}{7} & -\\frac{96}{7} \\\\\n -\\frac{60}{7} & \\frac{108}{7} & \\frac{24}{7} & \\frac{24}{7} \\\\\n -12 & \\frac{24}{7} & -\\frac{72}{7} & 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 1, 1, 8],\n [5, -9, -2, -2],\n [7, -2, 6, -7]])\nprint(a * -(12/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,-4,5\\}, \\{-2,3,2\\}, \\{4,-5,-3\\}}$.", - "Output Answer": [ - "$59 x+13 y+50 z-21=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, -4, 5],\n [-2, 3, 2],\n [4, -5, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -8 \\\\\n -7 \\\\\n -6 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -3 \\\\\n 2 \\\\\n -4 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{43}{9 \\sqrt{138}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-8],\n [-7],\n [-6],\n [-7]]).squeeze()\nb = np.array([\n [4],\n [-3],\n [2],\n [-4],\n [-3]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -2 & -9 & -9 & -4 & -6 \\\\\n 2 & -2 & 2 & 4 & -7 \\\\\n -4 & -10 & -10 & 9 & 6 \\\\\n 4 & -5 & 4 & -3 & 1 \\\\\n -2 & -8 & -4 & 2 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, -9, -9, -4, -6],\n [2, -2, 2, 4, -7],\n [-4, -10, -10, 9, 6],\n [4, -5, 4, -3, 1],\n [-2, -8, -4, 2, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & 1 \\\\\n 1 & 0 \\\\\n 1 & 0 \\\\\n -2 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.88 \\\\\n -1.43 \\\\\n -1.87 \\\\\n -2.78 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.747 \\\\\n -1.987 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1],\n [1, 0],\n [1, 0],\n [-2, 2]])\nb = np.array([\n [-2.88],\n [-1.43],\n [-1.87],\n [-2.78]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{1,0,-1\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-2],\n [-2]]).squeeze()\nb = np.array([\n [1],\n [0],\n [-1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{3} \\\\\n \\frac{2}{3} \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{14}} \\\\\n \\sqrt{\\frac{2}{7}} \\\\\n -\\frac{3}{\\sqrt{14}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/3)],\n [(2/3)],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{14}{3},\\frac{11}{3},\\frac{1}{3}\\right\\}, \\left\\{1,\\frac{14}{3},\\frac{14}{3}\\right\\}, \\left\\{-\\frac{8}{3},-4,\\frac{2}{3}\\right\\}}$.", - "Output Answer": [ - "$302 x+61 y-409 z+1322=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(14/3), (11/3), (1/3)],\n [1, (14/3), (14/3)],\n [-(8/3), -4, (2/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{6} \\\\\n -\\frac{7}{6} \\\\\n 0 \\\\\n \\frac{1}{3} \\\\\n -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{7}{\\sqrt{106}} \\\\\n -\\frac{7}{\\sqrt{106}} \\\\\n 0 \\\\\n \\sqrt{\\frac{2}{53}} \\\\\n -\\sqrt{\\frac{2}{53}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/6)],\n [-(7/6)],\n [0],\n [(1/3)],\n [-(1/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -10 & 5 \\\\\n 8 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, 5],\n [8, 8]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 1 & 1 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & 2 & 2 & 2 \\\\\n -3 & 0 & 2 & 0 \\\\\n 1 & 2 & -3 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -3 & -2 & 10 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1, -2]])\nb = np.array([\n [2, 2, 2, 2],\n [-3, 0, 2, 0],\n [1, 2, -3, -3]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 0 & -2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 0 & 0 \\\\\n 0 & -2 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1]])\nb = np.array([\n [0, -2, -2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -\\frac{237}{25} \\\\\n \\frac{331}{50} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{71}{50} \\\\\n -\\frac{33}{25} \\\\\n \\frac{139}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{54963}{1250} \\\\\n \\frac{32099}{2500} \\\\\n -\\frac{10227}{1250} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-(237/25)],\n [(331/50)]])\nb = np.array([\n [-(71/50)],\n [-(33/25)],\n [(139/25)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n -2 & -7 & -6 \\\\\n 1 & -5 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -7, -6],\n [1, -5, 5]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 3 & -10 & 6 & -7 \\\\\n -2 & 7 & 1 & -3 \\\\\n 4 & -2 & -4 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{598.,211.,265.,182.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, -10, 6, -7],\n [-2, 7, 1, -3],\n [4, -2, -4, -5]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{17}{4} & -\\frac{17}{8} & -\\frac{37}{8} \\\\\n -\\frac{27}{8} & \\frac{19}{4} & -\\frac{9}{4} \\\\\n \\frac{15}{8} & \\frac{19}{8} & -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{304}{14513} & -\\frac{280}{1893} & \\frac{13696}{43539} \\\\\n -\\frac{1152}{14513} & \\frac{88}{631} & \\frac{1032}{14513} \\\\\n -\\frac{2888}{14513} & \\frac{136}{1893} & -\\frac{14008}{43539} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/4), -(17/8), -(37/8)],\n [-(27/8), (19/4), -(9/4)],\n [(15/8), (19/8), -(3/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 3 & -3 & 0 & 1 \\\\\n 0 & 2 & 2 & -1 \\\\\n 2 & -2 & 3 & 2 \\\\\n -1 & 1 & 1 & 3 \\\\\n -1 & -2 & 3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.92 \\\\\n -1.97 \\\\\n -2. \\\\\n 2. \\\\\n -1.15 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.188 \\\\\n -0.147 \\\\\n -0.461 \\\\\n 0.56 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -3, 0, 1],\n [0, 2, 2, -1],\n [2, -2, 3, 2],\n [-1, 1, 1, 3],\n [-1, -2, 3, -2]])\nb = np.array([\n [-2.92],\n [-1.97],\n [-2.],\n [2.],\n [-1.15]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 7 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{138}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [7],\n [5]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 2 & 5 & -9 & -6 \\\\\n -5 & -9 & 3 & -7 \\\\\n 1 & 1 & 2 & -5 \\\\\n 6 & -9 & 9 & -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 5 & -9 & 9 & -6 \\\\\n -4 & 4 & -7 & 2 \\\\\n 9 & 8 & 5 & -8 \\\\\n 8 & 9 & 9 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 7 & -4 & 0 & -12 \\\\\n -9 & -5 & -4 & -5 \\\\\n 10 & 9 & 7 & -13 \\\\\n 14 & 0 & 18 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 5, -9, -6],\n [-5, -9, 3, -7],\n [1, 1, 2, -5],\n [6, -9, 9, -10]])\nb = np.array([\n [5, -9, 9, -6],\n [-4, 4, -7, 2],\n [9, 8, 5, -8],\n [8, 9, 9, 9]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{3} \\\\\n -\\frac{43}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{43}{6}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/3)],\n [-(43/6)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 10 & -3 & -10 & -3 & -7 & -4 \\\\\n -9 & -8 & 3 & -9 & -9 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & -\\frac{89}{107} & \\frac{3}{107} & -\\frac{29}{107} & -\\frac{26}{107} \\\\\n 0 & 1 & \\frac{60}{107} & \\frac{117}{107} & \\frac{153}{107} & \\frac{56}{107} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, -3, -10, -3, -7, -4],\n [-9, -8, 3, -9, -9, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & -3 & 2 \\\\\n -2 & 1 & -1 \\\\\n 2 & 1 & 2 \\\\\n 1 & 1 & -3 \\\\\n -2 & -1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.04 \\\\\n 1.43 \\\\\n 1.23 \\\\\n -1.65 \\\\\n 0.5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.352 \\\\\n 0.305 \\\\\n 0.614 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3, 2],\n [-2, 1, -1],\n [2, 1, 2],\n [1, 1, -3],\n [-2, -1, 1]])\nb = np.array([\n [1.04],\n [1.43],\n [1.23],\n [-1.65],\n [0.5]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{13}{6} \\\\\n 0 \\\\\n \\frac{1}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 6 \\sqrt{\\frac{2}{157}} \\\\\n \\frac{13}{\\sqrt{314}} \\\\\n 0 \\\\\n \\frac{1}{\\sqrt{314}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [(13/6)],\n [0],\n [(1/6)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{7} \\\\\n -\\frac{3}{7} \\\\\n -\\frac{12}{7} \\\\\n -\\frac{18}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{17}{\\sqrt{766}} \\\\\n -\\frac{3}{\\sqrt{766}} \\\\\n -6 \\sqrt{\\frac{2}{383}} \\\\\n -9 \\sqrt{\\frac{2}{383}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/7)],\n [-(3/7)],\n [-(12/7)],\n [-(18/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & -4 & -6 \\\\\n -10 & 8 & 6 \\\\\n 8 & 4 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{31.625,-58.934,1.\\}, \\{0.437\\, -0.375 i,-0.283-0.27 i,1.\\}, \\{0.437\\, +0.375 i,-0.283+0.27 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -4, -6],\n [-10, 8, 6],\n [8, 4, -4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{26}{5} & -\\frac{7}{10} & 3 & \\frac{36}{5} \\\\\n -\\frac{8}{5} & -\\frac{1}{10} & \\frac{44}{5} & -\\frac{33}{5} \\\\\n \\frac{21}{5} & -\\frac{71}{10} & \\frac{41}{5} & -\\frac{33}{5} \\\\\n \\frac{22}{5} & -\\frac{31}{5} & \\frac{33}{5} & -6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{13}{2} & 3 & -\\frac{1}{2} & -\\frac{17}{5} \\\\\n \\frac{23}{5} & \\frac{34}{5} & -\\frac{22}{5} & \\frac{19}{2} \\\\\n \\frac{23}{5} & \\frac{43}{10} & -\\frac{53}{10} & \\frac{44}{5} \\\\\n -\\frac{27}{10} & -\\frac{43}{10} & -\\frac{19}{5} & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{117}{10} & -\\frac{37}{10} & \\frac{7}{2} & \\frac{53}{5} \\\\\n -\\frac{31}{5} & -\\frac{69}{10} & \\frac{66}{5} & -\\frac{161}{10} \\\\\n -\\frac{2}{5} & -\\frac{57}{5} & \\frac{27}{2} & -\\frac{77}{5} \\\\\n \\frac{71}{10} & -\\frac{19}{10} & \\frac{52}{5} & -13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/5), -(7/10), 3, (36/5)],\n [-(8/5), -(1/10), (44/5), -(33/5)],\n [(21/5), -(71/10), (41/5), -(33/5)],\n [(22/5), -(31/5), (33/5), -6]])\nb = np.array([\n [-(13/2), 3, -(1/2), -(17/5)],\n [(23/5), (34/5), -(22/5), (19/2)],\n [(23/5), (43/10), -(53/10), (44/5)],\n [-(27/10), -(43/10), -(19/5), 7]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 1 & \\frac{17}{2} \\\\\n \\frac{47}{6} & \\frac{53}{6} \\\\\n \\frac{19}{6} & -\\frac{23}{3} \\\\\n -\\frac{13}{3} & -\\frac{23}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{13}{3} & \\frac{47}{6} \\\\\n -\\frac{17}{6} & \\frac{31}{6} \\\\\n \\frac{10}{3} & -\\frac{17}{2} \\\\\n \\frac{37}{6} & -\\frac{41}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{16}{3} & \\frac{49}{3} \\\\\n 5 & 14 \\\\\n \\frac{13}{2} & -\\frac{97}{6} \\\\\n \\frac{11}{6} & -\\frac{32}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, (17/2)],\n [(47/6), (53/6)],\n [(19/6), -(23/3)],\n [-(13/3), -(23/6)]])\nb = np.array([\n [(13/3), (47/6)],\n [-(17/6), (31/6)],\n [(10/3), -(17/2)],\n [(37/6), -(41/6)]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 10 & 2 & -7 \\\\\n -7 & -5 & 9 \\\\\n 10 & -1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [10, 2, -7],\n [-7, -5, 9],\n [10, -1, -3]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{7}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 5 & 9 & 0 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{15}{7} & \\frac{27}{7} & 0 & -\\frac{27}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 9, 0, -9]])\nprint(a * (3/7))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{8}{5} \\\\\n \\frac{44}{5} \\\\\n \\frac{18}{5} \\\\\n 9 \\\\\n -\\frac{6}{5} \\\\\n \\frac{3}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{47}{5} \\\\\n -\\frac{43}{5} \\\\\n \\frac{3}{5} \\\\\n \\frac{2}{5} \\\\\n -\\frac{46}{5} \\\\\n -\\frac{48}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{996 \\sqrt{\\frac{2}{110383}}}{13}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/5)],\n [(44/5)],\n [(18/5)],\n [9],\n [-(6/5)],\n [(3/5)]]).squeeze()\nb = np.array([\n [(47/5)],\n [-(43/5)],\n [(3/5)],\n [(2/5)],\n [-(46/5)],\n [-(48/5)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 5 & -5 & -2 \\\\\n -8 & 10 & 4 \\\\\n 0 & 5 & 8 \\\\\n 1 & -7 & 2 \\\\\n 2 & 7 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, -5, -2],\n [-8, 10, 4],\n [0, 5, 8],\n [1, -7, 2],\n [2, 7, 7]]))\nprint(a.nullspace())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{23}{4} & 7 \\\\\n \\frac{17}{2} & \\frac{35}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{34} \\left(-29-\\sqrt{1793}\\right),1\\right\\}, \\left\\{\\frac{1}{34} \\left(\\sqrt{1793}-29\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/4), 7],\n [(17/2), (35/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{\\sqrt{2}} \\\\\n -\\frac{7}{\\sqrt{2}} \\\\\n -4 \\sqrt{2} \\\\\n 0 \\\\\n 2 \\sqrt{2} \\\\\n \\frac{7}{\\sqrt{2}} \\\\\n -7 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{\\sqrt{2}} \\\\\n \\frac{3}{\\sqrt{2}} \\\\\n \\frac{11}{\\sqrt{2}} \\\\\n -4 \\sqrt{2} \\\\\n -2 \\sqrt{2} \\\\\n -3 \\sqrt{2} \\\\\n -7 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(3/(math.sqrt(2)))],\n [-(7/(math.sqrt(2)))],\n [-4*math.sqrt(2)],\n [0],\n [2*math.sqrt(2)],\n [(7/(math.sqrt(2)))],\n [-7*math.sqrt(2)]])\nb = np.array([\n [-(11/(math.sqrt(2)))],\n [(3/(math.sqrt(2)))],\n [(11/(math.sqrt(2)))],\n [-4*math.sqrt(2)],\n [-2*math.sqrt(2)],\n [-3*math.sqrt(2)],\n [-7*math.sqrt(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{3} \\\\\n 0 \\\\\n 4 \\\\\n \\frac{17}{3} \\\\\n -8 \\\\\n 7 \\\\\n -1 \\\\\n \\frac{16}{3} \\\\\n \\frac{20}{3} \\\\\n \\frac{25}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{26}{3} \\\\\n \\frac{28}{3} \\\\\n \\frac{8}{3} \\\\\n \\frac{29}{3} \\\\\n -\\frac{22}{3} \\\\\n 2 \\\\\n 8 \\\\\n -8 \\\\\n -3 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{151}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/3)],\n [0],\n [4],\n [(17/3)],\n [-8],\n [7],\n [-1],\n [(16/3)],\n [(20/3)],\n [(25/3)]])\nb = np.array([\n [(26/3)],\n [(28/3)],\n [(8/3)],\n [(29/3)],\n [-(22/3)],\n [2],\n [8],\n [-8],\n [-3],\n [9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & -1 \\\\\n -\\frac{11}{4} & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{3}{4} \\left(-5-\\sqrt{5}\\right),\\frac{3}{4} \\left(\\sqrt{5}-5\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -1],\n [-(11/4), -(7/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{2} \\\\\n \\frac{9}{8} \\\\\n \\frac{5}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{55}{8} \\\\\n -\\frac{21}{4} \\\\\n \\frac{31}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{489}{32} \\\\\n \\frac{1089}{32} \\\\\n \\frac{2343}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/2)],\n [(9/8)],\n [(5/4)]])\nb = np.array([\n [-(55/8)],\n [-(21/4)],\n [(31/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-3,-\\frac{7}{3},\\frac{8}{3}\\right\\}, \\left\\{1,4,-\\frac{1}{3}\\right\\}, \\left\\{\\frac{11}{3},-\\frac{13}{3},-\\frac{7}{3}\\right\\}}$.", - "Output Answer": [ - "$9 x+12 z-5=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, -(7/3), (8/3)],\n [1, 4, -(1/3)],\n [(11/3), -(13/3), -(7/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -3 & -3 \\\\\n 4 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{9} & \\frac{1}{6} \\\\\n -\\frac{2}{9} & -\\frac{1}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3],\n [4, -2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -3 & 2 & 2 & 2 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 1 & -3 \\\\\n -1 & -1 \\\\\n -1 & 3 \\\\\n 0 & 2 \\\\\n 1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -5 & 21 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2, 2, 2, 2]])\nb = np.array([\n [1, -3],\n [-1, -1],\n [-1, 3],\n [0, 2],\n [1, 2]])\nprint(a @ b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{3}{\\sqrt{2}},-\\frac{3}{\\sqrt{2}},\\frac{1}{\\sqrt{2}}\\right\\}, \\left\\{2 \\sqrt{2},\\frac{3}{\\sqrt{2}},-\\sqrt{2}\\right\\}, \\left\\{0,-\\frac{1}{\\sqrt{2}},-\\frac{1}{\\sqrt{2}}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{3}{\\sqrt{19}},-\\frac{3}{\\sqrt{19}},\\frac{1}{\\sqrt{19}}\\right\\}, \\left\\{\\frac{2 \\sqrt{2}-\\frac{69}{19 \\sqrt{2}}}{\\sqrt{\\frac{72}{361}+\\left(\\sqrt{2}-\\frac{23}{19 \\sqrt{2}}\\right)^2+\\left(2 \\sqrt{2}-\\frac{69}{19 \\sqrt{2}}\\right)^2}},-\\frac{6}{19} \\sqrt{\\frac{2}{\\frac{72}{361}+\\left(\\sqrt{2}-\\frac{23}{19 \\sqrt{2}}\\right)^2+\\left(2 \\sqrt{2}-\\frac{69}{19 \\sqrt{2}}\\right)^2}},\\frac{\\frac{23}{19 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{\\frac{72}{361}+\\left(\\sqrt{2}-\\frac{23}{19 \\sqrt{2}}\\right)^2+\\left(2 \\sqrt{2}-\\frac{69}{19 \\sqrt{2}}\\right)^2}}\\right\\}, \\left\\{\\frac{\\frac{3 \\sqrt{2}}{19}-\\frac{\\left(-\\frac{69}{19 \\sqrt{2}}+2 \\sqrt{2}\\right) \\left(\\frac{6}{19}-\\frac{\\frac{23}{19 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{\\frac{72}{361}+\\left(-\\frac{23}{19 \\sqrt{2}}+\\sqrt{2}\\right)^2+\\left(-\\frac{69}{19 \\sqrt{2}}+2 \\sqrt{2}\\right)^2}}{\\sqrt{\\left(-\\frac{1}{\\sqrt{2}}+\\frac{3 \\sqrt{2}}{19}+\\frac{6 \\sqrt{2} \\left(\\frac{6}{19}-\\frac{\\frac{23}{19 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{19 \\left(\\frac{72}{361}+\\left(-\\frac{23}{19 \\sqrt{2}}+\\sqrt{2}\\right)^2+\\left(-\\frac{69}{19 \\sqrt{2}}+2 \\sqrt{2}\\right)^2\\right)}\\right)^2+\\left(-\\frac{3 \\sqrt{2}}{19}-\\frac{\\left(\\frac{69}{19 \\sqrt{2}}-2 \\sqrt{2}\\right) \\left(\\frac{6}{19}-\\frac{\\frac{23}{19 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{\\frac{72}{361}+\\left(-\\frac{23}{19 \\sqrt{2}}+\\sqrt{2}\\right)^2+\\left(-\\frac{69}{19 \\sqrt{2}}+2 \\sqrt{2}\\right)^2}\\right)^2+\\left(\\frac{1}{\\sqrt{2}}+\\frac{\\sqrt{2}}{19}-\\frac{\\left(-\\frac{23}{19 \\sqrt{2}}+\\sqrt{2}\\right) \\left(\\frac{6}{19}-\\frac{\\frac{23}{19 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{\\frac{72}{361}+\\left(-\\frac{23}{19 \\sqrt{2}}+\\sqrt{2}\\right)^2+\\left(-\\frac{69}{19 \\sqrt{2}}+2 \\sqrt{2}\\right)^2}\\right)^2}},\\frac{-\\frac{1}{\\sqrt{2}}+\\frac{3 \\sqrt{2}}{19}+\\frac{6 \\sqrt{2} \\left(\\frac{6}{19}-\\frac{\\frac{23}{19 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{19 \\left(\\frac{72}{361}+\\left(-\\frac{23}{19 \\sqrt{2}}+\\sqrt{2}\\right)^2+\\left(-\\frac{69}{19 \\sqrt{2}}+2 \\sqrt{2}\\right)^2\\right)}}{\\sqrt{\\left(-\\frac{1}{\\sqrt{2}}+\\frac{3 \\sqrt{2}}{19}+\\frac{6 \\sqrt{2} \\left(\\frac{6}{19}-\\frac{\\frac{23}{19 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{19 \\left(\\frac{72}{361}+\\left(-\\frac{23}{19 \\sqrt{2}}+\\sqrt{2}\\right)^2+\\left(-\\frac{69}{19 \\sqrt{2}}+2 \\sqrt{2}\\right)^2\\right)}\\right)^2+\\left(-\\frac{3 \\sqrt{2}}{19}-\\frac{\\left(\\frac{69}{19 \\sqrt{2}}-2 \\sqrt{2}\\right) \\left(\\frac{6}{19}-\\frac{\\frac{23}{19 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{\\frac{72}{361}+\\left(-\\frac{23}{19 \\sqrt{2}}+\\sqrt{2}\\right)^2+\\left(-\\frac{69}{19 \\sqrt{2}}+2 \\sqrt{2}\\right)^2}\\right)^2+\\left(\\frac{1}{\\sqrt{2}}+\\frac{\\sqrt{2}}{19}-\\frac{\\left(-\\frac{23}{19 \\sqrt{2}}+\\sqrt{2}\\right) \\left(\\frac{6}{19}-\\frac{\\frac{23}{19 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{\\frac{72}{361}+\\left(-\\frac{23}{19 \\sqrt{2}}+\\sqrt{2}\\right)^2+\\left(-\\frac{69}{19 \\sqrt{2}}+2 \\sqrt{2}\\right)^2}\\right)^2}},\\frac{-\\frac{1}{\\sqrt{2}}-\\frac{\\sqrt{2}}{19}-\\frac{\\left(\\frac{23}{19 \\sqrt{2}}-\\sqrt{2}\\right) \\left(\\frac{6}{19}-\\frac{\\frac{23}{19 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{\\frac{72}{361}+\\left(-\\frac{23}{19 \\sqrt{2}}+\\sqrt{2}\\right)^2+\\left(-\\frac{69}{19 \\sqrt{2}}+2 \\sqrt{2}\\right)^2}}{\\sqrt{\\left(-\\frac{1}{\\sqrt{2}}+\\frac{3 \\sqrt{2}}{19}+\\frac{6 \\sqrt{2} \\left(\\frac{6}{19}-\\frac{\\frac{23}{19 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{19 \\left(\\frac{72}{361}+\\left(-\\frac{23}{19 \\sqrt{2}}+\\sqrt{2}\\right)^2+\\left(-\\frac{69}{19 \\sqrt{2}}+2 \\sqrt{2}\\right)^2\\right)}\\right)^2+\\left(-\\frac{3 \\sqrt{2}}{19}-\\frac{\\left(\\frac{69}{19 \\sqrt{2}}-2 \\sqrt{2}\\right) \\left(\\frac{6}{19}-\\frac{\\frac{23}{19 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{\\frac{72}{361}+\\left(-\\frac{23}{19 \\sqrt{2}}+\\sqrt{2}\\right)^2+\\left(-\\frac{69}{19 \\sqrt{2}}+2 \\sqrt{2}\\right)^2}\\right)^2+\\left(\\frac{1}{\\sqrt{2}}+\\frac{\\sqrt{2}}{19}-\\frac{\\left(-\\frac{23}{19 \\sqrt{2}}+\\sqrt{2}\\right) \\left(\\frac{6}{19}-\\frac{\\frac{23}{19 \\sqrt{2}}-\\sqrt{2}}{\\sqrt{2}}\\right)}{\\frac{72}{361}+\\left(-\\frac{23}{19 \\sqrt{2}}+\\sqrt{2}\\right)^2+\\left(-\\frac{69}{19 \\sqrt{2}}+2 \\sqrt{2}\\right)^2}\\right)^2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-(3/(math.sqrt(2))), -(3/(math.sqrt(2))), (1/(math.sqrt(2)))), (2*math.sqrt(2), (3/(math.sqrt(2))), -math.sqrt(2)), (0, -(1/(math.sqrt(2))), -(1/(math.sqrt(2))))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,2,-2\\}, \\{-5,-4,-3\\}, \\{-4,-5,3\\}}$.", - "Output Answer": [ - "$37 x-23 y-10 z+63=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, 2, -2],\n [-5, -4, -3],\n [-4, -5, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -2 & 8 & -\\frac{8}{3} \\\\\n -\\frac{55}{6} & 0 & -\\frac{23}{3} \\\\\n \\frac{11}{6} & \\frac{2}{3} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{5 x^2}{2}-\\frac{253 x}{3}-\\frac{3862}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 8, -(8/3)],\n [-(55/6), 0, -(23/3)],\n [(11/6), (2/3), -(1/2)]])\nprint(np.poly(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & -2 & 1 \\\\\n 1 & -3 & 1 \\\\\n -2 & 3 & -2 \\\\\n 0 & -2 & 3 \\\\\n 1 & -2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.91 \\\\\n -0.98 \\\\\n 2.96 \\\\\n 0.94 \\\\\n 1.81 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.67 \\\\\n -0.375 \\\\\n -0.437 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2, 1],\n [1, -3, 1],\n [-2, 3, -2],\n [0, -2, 3],\n [1, -2, -2]])\nb = np.array([\n [0.91],\n [-0.98],\n [2.96],\n [0.94],\n [1.81]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -9 & 9 & 6 & -8 & -8 & 1 & -10 \\\\\n 6 & -4 & -3 & 7 & 8 & -7 & 9 \\\\\n 4 & -8 & -2 & -7 & 5 & -7 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & \\frac{61}{48} & \\frac{127}{48} & -\\frac{215}{48} & \\frac{49}{24} \\\\\n 0 & 1 & 0 & \\frac{35}{16} & \\frac{1}{16} & \\frac{7}{16} & \\frac{15}{8} \\\\\n 0 & 0 & 1 & -\\frac{65}{24} & \\frac{61}{24} & -\\frac{173}{24} & -\\frac{17}{12} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-9, 9, 6, -8, -8, 1, -10],\n [6, -4, -3, 7, 8, -7, 9],\n [4, -8, -2, -7, 5, -7, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & 0 \\\\\n -3 & 2 \\\\\n -1 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.36 \\\\\n -1.82 \\\\\n -1.63 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.2 \\\\\n 0.142 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0],\n [-3, 2],\n [-1, -3]])\nb = np.array([\n [-2.36],\n [-1.82],\n [-1.63]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{39}{8} \\\\\n \\frac{77}{8} \\\\\n \\frac{15}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{143}{16} \\\\\n \\frac{19}{16} \\\\\n -\\frac{107}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{8809}{128} \\\\\n -\\frac{117}{128} \\\\\n \\frac{1469}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(39/8)],\n [(77/8)],\n [(15/4)]])\nb = np.array([\n [-(143/16)],\n [(19/16)],\n [-(107/16)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -7 & -\\frac{4}{3} & -\\frac{29}{6} & \\frac{47}{6} & -\\frac{22}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -(4/3), -(29/6), (47/6), -(22/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -9 & -7 & 3 & -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 3 & -7 & 2 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -6 & -14 & 5 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -7, 3, -9]])\nb = np.array([\n [3, -7, 2, 5]])\nprint(a + b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{55}{16} & \\frac{53}{16} \\\\\n -\\frac{47}{8} & -\\frac{15}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{69}{16} & \\frac{119}{16} \\\\\n \\frac{15}{16} & -\\frac{33}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{31}{4} & -\\frac{33}{8} \\\\\n -\\frac{109}{16} & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(55/16), (53/16)],\n [-(47/8), -(15/4)]])\nb = np.array([\n [(69/16), (119/16)],\n [(15/16), -(33/4)]])\nprint(a - b)\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{17}{3} & \\frac{1}{3} \\\\\n -1 & -\\frac{20}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{6} \\left(-3-\\sqrt{1357}\\right),\\frac{1}{6} \\left(\\sqrt{1357}-3\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/3), (1/3)],\n [-1, -(20/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 3 \\\\\n 5 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 2 \\\\\n 8 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$105$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [3],\n [5],\n [-5]])\nb = np.array([\n [7],\n [2],\n [8],\n [-2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "train" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{2,-2,0\\}, \\{-3,3,4\\}, \\{4,1,2\\}}$.", - "Output Answer": [ - "$2 x-18 y+25 z-40=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, -2, 0],\n [-3, 3, 4],\n [4, 1, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 1 & 10 & 7 & 2 & -4 & -9 \\\\\n -3 & 2 & 8 & 2 & -4 & 6 \\\\\n -5 & -1 & -1 & -1 & -4 & 5 \\\\\n -1 & -1 & 6 & 8 & -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & \\frac{1884}{2077} & -\\frac{1654}{2077} \\\\\n 0 & 1 & 0 & 0 & -\\frac{951}{2077} & -\\frac{2823}{2077} \\\\\n 0 & 0 & 1 & 0 & -\\frac{72}{2077} & \\frac{1955}{2077} \\\\\n 0 & 0 & 0 & 1 & -\\frac{89}{2077} & -\\frac{1247}{2077} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, 10, 7, 2, -4, -9],\n [-3, 2, 8, 2, -4, 6],\n [-5, -1, -1, -1, -4, 5],\n [-1, -1, 6, 8, -1, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1}{\\sqrt{42}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [1],\n [-1],\n [-1],\n [1],\n [0],\n [0],\n [0],\n [1]]).squeeze()\nb = np.array([\n [1],\n [0],\n [1],\n [1],\n [-1],\n [-1],\n [0],\n [-1],\n [0],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-4, 2, -\\frac{3}{2}}$ to the plane $-x-\\frac{y}{2}+5=0$.", - "Output Answer": [ - "$\\frac{16}{\\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -4, 2, -(3/2)\nplane = Poly(-x-(y/2)+5, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & -2 \\\\\n -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -2],\n [-1, 2]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{5} \\\\\n \\frac{26}{5} \\\\\n -\\frac{19}{5} \\\\\n \\frac{39}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{39}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/5)],\n [(26/5)],\n [-(19/5)],\n [(39/5)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -6 \\\\\n -1 \\\\\n -8 \\\\\n -4 \\\\\n -9 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 3 \\\\\n 10 \\\\\n 0 \\\\\n 3 \\\\\n 8 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$26$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-6],\n [-1],\n [-8],\n [-4],\n [-9],\n [-10]])\nb = np.array([\n [8],\n [3],\n [10],\n [0],\n [3],\n [8],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, -4, -\\frac{9}{2}}$ to the plane $-\\frac{9 x}{2}-\\frac{9 y}{2}-\\frac{3 z}{2}-\\frac{5}{2}=0$.", - "Output Answer": [ - "$\\frac{125}{6 \\sqrt{19}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, -4, -(9/2)\nplane = Poly(-((9*x)/2)-((9*y)/2)-((3*z)/2)-(5/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & -1 & -2 \\\\\n -1 & -2 & -1 \\\\\n 0 & 0 & -3 \\\\\n -3 & 1 & -1 \\\\\n 1 & 1 & 2 \\\\\n 0 & -1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.7 \\\\\n 1.37 \\\\\n -1.81 \\\\\n -0.38 \\\\\n -1.98 \\\\\n -1.27 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.483 \\\\\n -0.695 \\\\\n 0.119 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1, -2],\n [-1, -2, -1],\n [0, 0, -3],\n [-3, 1, -1],\n [1, 1, 2],\n [0, -1, 1]])\nb = np.array([\n [2.7],\n [1.37],\n [-1.81],\n [-0.38],\n [-1.98],\n [-1.27]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{37}{10}, -\\frac{24}{5}}$ to the line $-\\frac{19 x}{5}+\\frac{4 y}{5}-\\frac{41}{10}=0$.", - "Output Answer": [ - "$\\frac{110}{\\sqrt{377}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (37/10), -(24/5)\nline = Poly(-((19*x)/5)+((4*y)/5)-(41/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{6}{\\pi } \\\\\n \\frac{16}{\\pi } \\\\\n \\frac{15}{\\pi } \\\\\n \\frac{12}{\\pi } \\\\\n \\frac{8}{\\pi } \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{23}{\\pi } \\\\\n -\\frac{30}{\\pi } \\\\\n \\frac{8}{\\pi } \\\\\n -\\frac{27}{\\pi } \\\\\n \\frac{8}{\\pi } \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{482}{\\pi ^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(6/math.pi)],\n [(16/math.pi)],\n [(15/math.pi)],\n [(12/math.pi)],\n [(8/math.pi)]])\nb = np.array([\n [(23/math.pi)],\n [-(30/math.pi)],\n [(8/math.pi)],\n [-(27/math.pi)],\n [(8/math.pi)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 6 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -6 \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 60 \\\\\n 0 \\\\\n 90 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [6],\n [4]])\nb = np.array([\n [-9],\n [-6],\n [6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -3 \\\\\n 2 \\\\\n 7 \\\\\n -4 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$23$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-3],\n [2],\n [7],\n [-4],\n [5]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -10 & 3 & -7 & -6 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-7.,0.,10.,0.,0.\\}, \\{-3.,0.,0.,5.,0.\\}, \\{3.,0.,0.,0.,10.\\}, \\{3.,10.,0.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, 3, -7, -6, 3]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{24}{5} & \\frac{19}{10} & -\\frac{7}{10} \\\\\n \\frac{1}{10} & -3 & \\frac{31}{10} \\\\\n -\\frac{22}{5} & -\\frac{2}{5} & -\\frac{6}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1210}{9913} & -\\frac{640}{9913} & -\\frac{1895}{19826} \\\\\n \\frac{3380}{9913} & -\\frac{670}{9913} & -\\frac{7405}{19826} \\\\\n \\frac{3310}{9913} & \\frac{2570}{9913} & -\\frac{7105}{19826} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(24/5), (19/10), -(7/10)],\n [(1/10), -3, (31/10)],\n [-(22/5), -(2/5), -(6/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{0,\\frac{3}{2},\\frac{7}{2}\\right\\}, \\left\\{-\\frac{9}{2},-\\frac{9}{2},2\\right\\}, \\{-3,-3,3\\}}$.", - "Output Answer": [ - "$5 x-3 (y+z-5)=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, (3/2), (7/2)],\n [-(9/2), -(9/2), 2],\n [-3, -3, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{32}{5} & \\frac{32}{5} & -\\frac{37}{5} \\\\\n \\frac{9}{5} & -\\frac{3}{5} & 6 \\\\\n -9 & -\\frac{32}{5} & \\frac{44}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{2.984,-1.074,1.\\}, \\{-0.241-0.082 i,0.7\\, -0.254 i,1.\\}, \\{-0.241+0.082 i,0.7\\, +0.254 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(32/5), (32/5), -(37/5)],\n [(9/5), -(3/5), 6],\n [-9, -(32/5), (44/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{13}{3},\\frac{7}{3},\\frac{2}{3}\\right\\}, \\left\\{\\frac{2}{3},2,\\frac{4}{3}\\right\\}, \\left\\{4,\\frac{13}{3},\\frac{7}{3}\\right\\}}$.", - "Output Answer": [ - "$17 x+25 y-115 z+92=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(13/3), (7/3), (2/3)],\n [(2/3), 2, (4/3)],\n [4, (13/3), (7/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6.39 \\\\\n 0.89 \\\\\n -3.49 \\\\\n -3.71 \\\\\n -7.05 \\\\\n -2.32 \\\\\n 7.47 \\\\\n 0.52 \\\\\n 5.54 \\\\\n -0.43 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8.39 \\\\\n -9.43 \\\\\n 4.56 \\\\\n 1.07 \\\\\n -5.5 \\\\\n -1.89 \\\\\n -8.4 \\\\\n -6.01 \\\\\n -1.19 \\\\\n -7.95 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$24.4353$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6.39],\n [0.89],\n [-3.49],\n [-3.71],\n [-7.05],\n [-2.32],\n [7.47],\n [0.52],\n [5.54],\n [-0.43]])\nb = np.array([\n [-8.39],\n [-9.43],\n [4.56],\n [1.07],\n [-5.5],\n [-1.89],\n [-8.4],\n [-6.01],\n [-1.19],\n [-7.95]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{16}{3} & -\\frac{22}{3} & -\\frac{28}{3} & -\\frac{29}{3} \\\\\n -1 & -\\frac{17}{3} & \\frac{4}{3} & -\\frac{19}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{10}{3} & -\\frac{25}{3} & \\frac{5}{3} & \\frac{11}{3} \\\\\n \\frac{19}{3} & 5 & 7 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 2 & -\\frac{47}{3} & -\\frac{23}{3} & -6 \\\\\n \\frac{16}{3} & -\\frac{2}{3} & \\frac{25}{3} & -\\frac{22}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(16/3), -(22/3), -(28/3), -(29/3)],\n [-1, -(17/3), (4/3), -(19/3)]])\nb = np.array([\n [-(10/3), -(25/3), (5/3), (11/3)],\n [(19/3), 5, 7, -1]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 3 & -2 & 0 & 0 & 0 \\\\\n 0 & 1 & -1 & -2 & 0 \\\\\n 0 & 1 & 3 & 1 & 2 \\\\\n -1 & 1 & -1 & -3 & -2 \\\\\n -1 & -3 & 0 & -1 & -2 \\\\\n 0 & -2 & -1 & 3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.8 \\\\\n 1.94 \\\\\n -0.65 \\\\\n -0.17 \\\\\n 1.34 \\\\\n -0.28 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.622 \\\\\n -0.212 \\\\\n -0.136 \\\\\n -0.489 \\\\\n 0.38 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2, 0, 0, 0],\n [0, 1, -1, -2, 0],\n [0, 1, 3, 1, 2],\n [-1, 1, -1, -3, -2],\n [-1, -3, 0, -1, -2],\n [0, -2, -1, 3, 3]])\nb = np.array([\n [-1.8],\n [1.94],\n [-0.65],\n [-0.17],\n [1.34],\n [-0.28]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -4 \\\\\n 9 \\\\\n -4 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 1 \\\\\n 7 \\\\\n 8 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{262}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-4],\n [9],\n [-4],\n [3]])\nb = np.array([\n [2],\n [1],\n [7],\n [8],\n [-2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{46}{9} & -\\frac{83}{9} & \\frac{77}{9} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{50}{9} & \\frac{23}{3} & \\frac{77}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{4}{9} & -\\frac{152}{9} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(46/9), -(83/9), (77/9)]])\nb = np.array([\n [(50/9), (23/3), (77/9)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -5 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{2.,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, 10]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{43}{20} & -\\frac{317}{100} \\\\\n -\\frac{61}{50} & -\\frac{33}{20} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{19 x}{5}-\\frac{3199}{10000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(43/20), -(317/100)],\n [-(61/50), -(33/20)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -1 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 5 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{13}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-1],\n [-9]])\nb = np.array([\n [9],\n [5],\n [-9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & 2 \\\\\n 0 & 3 \\\\\n -2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1. \\\\\n 0.54 \\\\\n -1.75 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.038 \\\\\n 0.403 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2],\n [0, 3],\n [-2, -3]])\nb = np.array([\n [1.],\n [0.54],\n [-1.75]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & \\frac{2}{5} \\\\\n -\\frac{19}{5} & -\\frac{1}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{38}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, (2/5)],\n [-(19/5), -(1/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{16}{5} & \\frac{7}{5} \\\\\n \\frac{23}{5} & \\frac{9}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{17}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(16/5), (7/5)],\n [(23/5), (9/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n 2 \\\\\n 0 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n -\\frac{1}{2} \\\\\n \\frac{1}{2} \\\\\n 0 \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-2],\n [2],\n [0],\n [2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{4}{3} & -\\frac{5}{3} & \\frac{4}{3} & \\frac{8}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -1 & -\\frac{5}{3} & -\\frac{4}{3} & \\frac{7}{3} & -3 \\\\\n -2 & -1 & 2 & -2 & \\frac{1}{3} \\\\\n -2 & 1 & 0 & -2 & -\\frac{2}{3} \\\\\n -2 & 0 & \\frac{7}{3} & -3 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -\\frac{10}{3} & \\frac{47}{9} & \\frac{14}{3} & -\\frac{94}{9} & -\\frac{49}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/3), -(5/3), (4/3), (8/3)]])\nb = np.array([\n [-1, -(5/3), -(4/3), (7/3), -3],\n [-2, -1, 2, -2, (1/3)],\n [-2, 1, 0, -2, -(2/3)],\n [-2, 0, (7/3), -3, -3]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 1 & \\frac{5}{2} \\\\\n 2 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{7}{2} & \\frac{135}{8} \\\\\n \\frac{27}{2} & -\\frac{107}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, (5/2)],\n [2, -(3/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{23}{4} & 7 \\\\\n \\frac{1}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} \\left(-33-\\sqrt{1313}\\right),1\\right\\}, \\left\\{\\frac{1}{4} \\left(\\sqrt{1313}-33\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/4), 7],\n [(1/2), (5/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 8 \\\\\n -3 \\\\\n -9 \\\\\n -2 \\\\\n 2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -3 \\\\\n 10 \\\\\n -9 \\\\\n 3 \\\\\n -2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$35$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [8],\n [-3],\n [-9],\n [-2],\n [2],\n [-2]])\nb = np.array([\n [-8],\n [-3],\n [10],\n [-9],\n [3],\n [-2],\n [-1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 6 & 0 & -1 & -4 \\\\\n 3 & 0 & -1 & -3 \\\\\n 7 & -9 & 6 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{9.,-29.,-54.,27.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [6, 0, -1, -4],\n [3, 0, -1, -3],\n [7, -9, 6, 0]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{37}{4} \\\\\n \\frac{21}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{15}{4} \\\\\n -\\frac{17}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{99}{\\sqrt{232585}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/4)],\n [(21/4)]]).squeeze()\nb = np.array([\n [(15/4)],\n [-(17/4)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n \\frac{5}{2} \\\\\n -\\frac{17}{4} \\\\\n -2 \\\\\n -\\frac{39}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{15}{4} \\\\\n -\\frac{9}{2} \\\\\n -\\frac{27}{4} \\\\\n \\frac{17}{2} \\\\\n \\frac{19}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1955}{2 \\sqrt{2906561}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [(5/2)],\n [-(17/4)],\n [-2],\n [-(39/4)]]).squeeze()\nb = np.array([\n [(15/4)],\n [-(9/2)],\n [-(27/4)],\n [(17/2)],\n [(19/2)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{7}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 4 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{27}{7} \\\\\n \\frac{12}{7} \\\\\n \\frac{30}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [4],\n [10]])\nprint(a * (3/7))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 9 \\\\\n 0 \\\\\n -9 \\\\\n 6 \\\\\n 8 \\\\\n -4 \\\\\n -6 \\\\\n 0 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -6 \\\\\n 4 \\\\\n 4 \\\\\n 3 \\\\\n -6 \\\\\n 7 \\\\\n -6 \\\\\n 9 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{917}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [9],\n [0],\n [-9],\n [6],\n [8],\n [-4],\n [-6],\n [0],\n [4]])\nb = np.array([\n [-1],\n [-6],\n [4],\n [4],\n [3],\n [-6],\n [7],\n [-6],\n [9],\n [4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{10}{3}, \\frac{13}{3}, \\frac{7}{3}}$ to the plane $4 x+\\frac{8 y}{3}-2 z-\\frac{4}{3}=0$.", - "Output Answer": [ - "$\\frac{35}{3 \\sqrt{61}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(10/3), (13/3), (7/3)\nplane = Poly(4*x+((8*y)/3)-2*z-(4/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\pi \\\\\n -\\pi \\\\\n 0 \\\\\n \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\pi \\\\\n -3 \\pi \\\\\n \\pi \\\\\n 3 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.pi],\n [-math.pi],\n [0],\n [math.pi]])\nb = np.array([\n [math.pi],\n [-3*math.pi],\n [math.pi],\n [3*math.pi]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{14}{5} & \\frac{3}{5} \\\\\n -\\frac{17}{5} & \\frac{7}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{35}{47} & \\frac{15}{47} \\\\\n -\\frac{85}{47} & \\frac{70}{47} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(14/5), (3/5)],\n [-(17/5), (7/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{2} & 1 & -\\frac{1}{2} \\\\\n 1 & 0 & 1 \\\\\n \\frac{5}{2} & -\\frac{3}{2} & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{5}{8} & -\\frac{5}{8} & -\\frac{7}{4} \\\\\n -\\frac{13}{4} & \\frac{7}{4} & -1 \\\\\n \\frac{7}{2} & -\\frac{9}{8} & \\frac{41}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), 1, -(1/2)],\n [1, 0, 1],\n [(5/2), -(3/2), 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{7}} \\\\\n -\\frac{1}{\\sqrt{7}} \\\\\n \\frac{2}{\\sqrt{7}} \\\\\n -\\frac{1}{\\sqrt{7}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [2],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -5 & 2 & 3 & -7 \\\\\n 3 & -3 & -6 & -2 \\\\\n 0 & -9 & 3 & 6 \\\\\n -5 & 6 & -2 & 5 \\\\\n -6 & -7 & -10 & 4 \\\\\n 4 & -7 & 6 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, 2, 3, -7],\n [3, -3, -6, -2],\n [0, -9, 3, 6],\n [-5, 6, -2, 5],\n [-6, -7, -10, 4],\n [4, -7, 6, -8]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 5 \\\\\n 5 \\\\\n -5 \\\\\n -8 \\\\\n 2 \\\\\n 0 \\\\\n 6 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -4 \\\\\n 6 \\\\\n -2 \\\\\n 1 \\\\\n 5 \\\\\n -10 \\\\\n 10 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{334}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [5],\n [5],\n [-5],\n [-8],\n [2],\n [0],\n [6],\n [-2]])\nb = np.array([\n [-6],\n [-4],\n [6],\n [-2],\n [1],\n [5],\n [-10],\n [10],\n [-8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 0 & -3 & 0 & 3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 0 & 3 & 0 & -3 & -2 \\\\\n 0 & 3 & 0 & -3 & -2 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 3 & 0 & -3 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [0],\n [0],\n [-1]])\nb = np.array([\n [0, -3, 0, 3, 2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\sqrt{5} \\\\\n 3 \\sqrt{5} \\\\\n -3 \\sqrt{5} \\\\\n -2 \\sqrt{5} \\\\\n 0 \\\\\n -3 \\sqrt{5} \\\\\n -4 \\sqrt{5} \\\\\n 3 \\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n -2 \\sqrt{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\sqrt{5} \\\\\n -\\sqrt{5} \\\\\n 3 \\sqrt{5} \\\\\n 0 \\\\\n 4 \\sqrt{5} \\\\\n -3 \\sqrt{5} \\\\\n -4 \\sqrt{5} \\\\\n -2 \\sqrt{5} \\\\\n 3 \\sqrt{5} \\\\\n -\\sqrt{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{185}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-3*math.sqrt(5)],\n [3*math.sqrt(5)],\n [-3*math.sqrt(5)],\n [-2*math.sqrt(5)],\n [0],\n [-3*math.sqrt(5)],\n [-4*math.sqrt(5)],\n [3*math.sqrt(5)],\n [4*math.sqrt(5)],\n [-2*math.sqrt(5)]])\nb = np.array([\n [4*math.sqrt(5)],\n [-math.sqrt(5)],\n [3*math.sqrt(5)],\n [0],\n [4*math.sqrt(5)],\n [-3*math.sqrt(5)],\n [-4*math.sqrt(5)],\n [-2*math.sqrt(5)],\n [3*math.sqrt(5)],\n [-math.sqrt(5)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,0,-1\\}, \\{2,-1,-1\\}, \\{-2,2,2\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{2}{\\sqrt{5}},0,-\\frac{1}{\\sqrt{5}}\\right\\}, \\{0,-1,0\\}, \\left\\{\\frac{1}{\\sqrt{5}},0,\\frac{2}{\\sqrt{5}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, 0, -1), (2, -1, -1), (-2, 2, 2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -4 & 6 & 1 & -6 & 0 \\\\\n -10 & -6 & -10 & 9 & 10 \\\\\n -6 & -8 & -5 & 6 & 7 \\\\\n -2 & 9 & -1 & -2 & 3 \\\\\n -9 & -2 & -9 & 5 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, 6, 1, -6, 0],\n [-10, -6, -10, 9, 10],\n [-6, -8, -5, 6, 7],\n [-2, 9, -1, -2, 3],\n [-9, -2, -9, 5, 10]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -7 & -10 & 6 \\\\\n 4 & 7 & 0 \\\\\n 9 & 5 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-x^2+63 x-249$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -10, 6],\n [4, 7, 0],\n [9, 5, -1]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & -2 \\\\\n -\\frac{5}{2} & -3 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{29}{4} & 9 \\\\\n \\frac{45}{4} & 14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), -2],\n [-(5/2), -3]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{9}{8}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 6 & 9 & 8 \\\\\n -6 & 6 & -6 \\\\\n 8 & -10 & 2 \\\\\n 2 & 7 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{27}{4} & \\frac{81}{8} & 9 \\\\\n -\\frac{27}{4} & \\frac{27}{4} & -\\frac{27}{4} \\\\\n 9 & -\\frac{45}{4} & \\frac{9}{4} \\\\\n \\frac{9}{4} & \\frac{63}{8} & -\\frac{27}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 9, 8],\n [-6, 6, -6],\n [8, -10, 2],\n [2, 7, -3]])\nprint(a * (9/8))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -8 & -4 \\\\\n -3 & 4 \\\\\n 5 & 10 \\\\\n -7 & 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 4 & -4 \\\\\n 1 & 2 \\\\\n -10 & 10 \\\\\n 2 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -4 & -8 \\\\\n -2 & 6 \\\\\n -5 & 20 \\\\\n -5 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -4],\n [-3, 4],\n [5, 10],\n [-7, 5]])\nb = np.array([\n [4, -4],\n [1, 2],\n [-10, 10],\n [2, -5]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 3 & -7 & 6 & -5 & 1 \\\\\n 2 & -4 & 3 & -5 & -5 \\\\\n -8 & -9 & -5 & 9 & 1 \\\\\n 7 & 2 & 3 & 5 & -7 \\\\\n -1 & -6 & 10 & -1 & 8 \\\\\n 3 & 10 & -10 & 1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, -7, 6, -5, 1],\n [2, -4, 3, -5, -5],\n [-8, -9, -5, 9, 1],\n [7, 2, 3, 5, -7],\n [-1, -6, 10, -1, 8],\n [3, 10, -10, 1, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 2 & -8 & 3 & 1 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-3.,0.,0.,0.,1.\\}, \\{-3.,0.,2.,0.,0.\\}, \\{-1.,0.,0.,2.,0.\\}, \\{4.,1.,0.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, -8, 3, 1, 6]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2.6 \\\\\n 6.3 \\\\\n 7.2 \\\\\n -2.3 \\\\\n -2.7 \\\\\n 1. \\\\\n 1.1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9.4 \\\\\n 7.8 \\\\\n 0. \\\\\n 6.8 \\\\\n 7.5 \\\\\n 2. \\\\\n -3.8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$17.6689$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2.6],\n [6.3],\n [7.2],\n [-2.3],\n [-2.7],\n [1.],\n [1.1]])\nb = np.array([\n [-9.4],\n [7.8],\n [0.],\n [6.8],\n [7.5],\n [2.],\n [-3.8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{20}{3} & -\\frac{11}{3} \\\\\n \\frac{2}{3} & \\frac{19}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{x}{3}-\\frac{358}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/3), -(11/3)],\n [(2/3), (19/3)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & \\frac{15}{2} \\\\\n -\\frac{13}{2} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{4} \\left(-11-i \\sqrt{755}\\right),\\frac{1}{4} \\left(-11+i \\sqrt{755}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, (15/2)],\n [-(13/2), -(3/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{16}{7}, \\frac{15}{7}}$ to the line $-\\frac{2 x}{7}-3 y-\\frac{31}{7}=0$.", - "Output Answer": [ - "$\\frac{564}{7 \\sqrt{445}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (16/7), (15/7)\nline = Poly(-((2*x)/7)-3*y-(31/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -9 & 4 & -2 & 10 & -8 & 3 & 4 \\\\\n 7 & -9 & 6 & -9 & 2 & -6 & -4 \\\\\n -1 & 3 & 6 & 7 & -4 & -7 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & -\\frac{17}{18} & \\frac{41}{36} & -\\frac{13}{72} & -\\frac{4}{9} \\\\\n 0 & 1 & 0 & \\frac{19}{27} & \\frac{7}{27} & -\\frac{11}{54} & -\\frac{8}{27} \\\\\n 0 & 0 & 1 & \\frac{71}{108} & -\\frac{131}{216} & -\\frac{473}{432} & -\\frac{16}{27} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-9, 4, -2, 10, -8, 3, 4],\n [7, -9, 6, -9, 2, -6, -4],\n [-1, 3, 6, 7, -4, -7, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 e \\\\\n 0 \\\\\n e \\\\\n e \\\\\n -4 e \\\\\n -4 e \\\\\n 2 e \\\\\n e \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 e \\\\\n 2 e \\\\\n -e \\\\\n -e \\\\\n -e \\\\\n -4 e \\\\\n 3 e \\\\\n 2 e \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$30 e^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [2*math.e],\n [0],\n [math.e],\n [math.e],\n [-4*math.e],\n [-4*math.e],\n [2*math.e],\n [math.e]])\nb = np.array([\n [2*math.e],\n [2*math.e],\n [-math.e],\n [-math.e],\n [-math.e],\n [-4*math.e],\n [3*math.e],\n [2*math.e]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-2,1,-\\frac{3}{2}\\right\\}, \\left\\{-\\frac{7}{2},4,2\\right\\}, \\left\\{-\\frac{9}{2},-4,\\frac{9}{2}\\right\\}}$.", - "Output Answer": [ - "$142 x+y+60 z+373=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, 1, -(3/2)],\n [-(7/2), 4, 2],\n [-(9/2), -4, (9/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -\\frac{49}{5} \\\\\n -2 \\\\\n -\\frac{33}{5} \\\\\n -\\frac{49}{10} \\\\\n -\\frac{29}{10} \\\\\n 0 \\\\\n -\\frac{17}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{19491}}{10}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-(49/5)],\n [-2],\n [-(33/5)],\n [-(49/10)],\n [-(29/10)],\n [0],\n [-(17/10)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{1}{2}, \\frac{9}{2}, -4}$ to the plane $-\\frac{9 x}{2}+\\frac{5 y}{2}+2 z-\\frac{1}{2}=0$.", - "Output Answer": [ - "$\\frac{1}{\\sqrt{122}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (1/2), (9/2), -4\nplane = Poly(-((9*x)/2)+((5*y)/2)+2*z-(1/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -2 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 25 \\\\\n -20 \\\\\n -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [9]])\nb = np.array([\n [-3],\n [-2],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 8 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -3 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 34 \\\\\n -2 \\\\\n -42 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [8],\n [-2]])\nb = np.array([\n [6],\n [-3],\n [5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{191}{50} & -\\frac{31}{25} & \\frac{67}{100} & \\frac{39}{100} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n \\frac{733}{100} & \\frac{27}{4} & -\\frac{33}{100} & -\\frac{203}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{351}{100} & -\\frac{799}{100} & 1 & \\frac{89}{20} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(191/50), -(31/25), (67/100), (39/100)]])\nb = np.array([\n [(733/100), (27/4), -(33/100), -(203/50)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & 4 & 3 \\\\\n -2 & -1 & -4 \\\\\n 4 & 0 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{5}{22} & \\frac{10}{11} & \\frac{13}{22} \\\\\n \\frac{3}{11} & \\frac{1}{11} & -\\frac{1}{11} \\\\\n -\\frac{2}{11} & -\\frac{8}{11} & -\\frac{3}{11} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 4, 3],\n [-2, -1, -4],\n [4, 0, 5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 7 \\\\\n 0 \\\\\n -2 \\\\\n -10 \\\\\n 0 \\\\\n 0 \\\\\n 3 \\\\\n 4 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 8 \\\\\n 4 \\\\\n 3 \\\\\n 6 \\\\\n 7 \\\\\n -7 \\\\\n 1 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{199}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [7],\n [0],\n [-2],\n [-10],\n [0],\n [0],\n [3],\n [4],\n [-4]])\nb = np.array([\n [-9],\n [8],\n [4],\n [3],\n [6],\n [7],\n [-7],\n [1],\n [-2],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{8} \\\\\n \\frac{5}{4} \\\\\n -\\frac{41}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{8} \\\\\n \\frac{31}{8} \\\\\n \\frac{23}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1731}{64} \\\\\n -\\frac{65}{64} \\\\\n \\frac{533}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/8)],\n [(5/4)],\n [-(41/8)]])\nb = np.array([\n [-(13/8)],\n [(31/8)],\n [(23/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 0 & -9 & 0 \\\\\n 5 & -1 & -3 \\\\\n 3 & 5 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.211,-0.202,1.\\}, \\{-2.216-0.547 i,-0.532+1.828 i,1.\\}, \\{-2.216+0.547 i,-0.532-1.828 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -9, 0],\n [5, -1, -3],\n [3, 5, 9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{17}{6} & \\frac{10}{3} \\\\\n -\\frac{2}{3} & \\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{19}{6}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/6), (10/3)],\n [-(2/3), (1/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -9 & 9 & -7 & 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -7 & -3 & 3 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -16 & 6 & -4 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 9, -7, 9]])\nb = np.array([\n [-7, -3, 3, -1]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -4 & -10 & -1 \\\\\n -3 & -8 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & -31 \\\\\n 0 & 1 & \\frac{25}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-4, -10, -1],\n [-3, -8, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 6 & 1 & -3 \\\\\n 2 & 1 & -4 \\\\\n 4 & 7 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+6 x^2-37 x+118$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 1, -3],\n [2, 1, -4],\n [4, 7, -1]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{1,-2,3\\}, \\{-1,-3,0\\}, \\{-1,-1,-2\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{14}},-\\sqrt{\\frac{2}{7}},\\frac{3}{\\sqrt{14}}\\right\\}, \\left\\{-\\frac{19}{\\sqrt{1610}},-16 \\sqrt{\\frac{2}{805}},-3 \\sqrt{\\frac{5}{322}}\\right\\}, \\left\\{\\frac{9}{\\sqrt{115}},-\\frac{3}{\\sqrt{115}},-\\sqrt{\\frac{5}{23}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((1, -2, 3), (-1, -3, 0), (-1, -1, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 9 \\\\\n 1 \\\\\n -4 \\\\\n 1 \\\\\n 10 \\\\\n 4 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -7 \\\\\n -4 \\\\\n 2 \\\\\n -7 \\\\\n 7 \\\\\n -10 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-50$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [9],\n [1],\n [-4],\n [1],\n [10],\n [4],\n [1]])\nb = np.array([\n [2],\n [-7],\n [-4],\n [2],\n [-7],\n [7],\n [-10],\n [4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{43}{8} \\\\\n \\frac{37}{8} \\\\\n -\\frac{35}{4} \\\\\n \\frac{25}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{63}{8} \\\\\n 8 \\\\\n -\\frac{31}{4} \\\\\n \\frac{9}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{5}{2} \\\\\n -\\frac{27}{8} \\\\\n -1 \\\\\n \\frac{41}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(43/8)],\n [(37/8)],\n [-(35/4)],\n [(25/4)]])\nb = np.array([\n [(63/8)],\n [8],\n [-(31/4)],\n [(9/8)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{43}{9} & \\frac{43}{9} \\\\\n -\\frac{28}{3} & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{38 x}{9}+\\frac{43}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(43/9), (43/9)],\n [-(28/3), 9]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{8}{3},\\frac{4}{3},0\\right\\}, \\left\\{-1,\\frac{11}{3},-3\\right\\}, \\left\\{\\frac{11}{3},2,4\\right\\}}$.", - "Output Answer": [ - "$102 x-231 y-123 z+580=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(8/3), (4/3), 0],\n [-1, (11/3), -3],\n [(11/3), 2, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{21}{8} \\\\\n \\frac{33}{16} \\\\\n -2 \\\\\n \\frac{27}{16} \\\\\n \\frac{11}{8} \\\\\n \\frac{43}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{14}{\\sqrt{771}} \\\\\n \\frac{11}{\\sqrt{771}} \\\\\n -\\frac{32}{3 \\sqrt{771}} \\\\\n 3 \\sqrt{\\frac{3}{257}} \\\\\n \\frac{22}{3 \\sqrt{771}} \\\\\n \\frac{43}{3 \\sqrt{771}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(21/8)],\n [(33/16)],\n [-2],\n [(27/16)],\n [(11/8)],\n [(43/16)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & 8 \\\\\n -1 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{4} \\left(-19-\\sqrt{41}\\right),\\frac{1}{4} \\left(\\sqrt{41}-19\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), 8],\n [-1, -8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -6 & -\\frac{3}{4} & -9 & \\frac{31}{4} \\\\\n -\\frac{25}{4} & \\frac{17}{4} & -\\frac{21}{4} & -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{11}{4} & -\\frac{27}{4} & \\frac{7}{4} & \\frac{39}{4} \\\\\n -8 & -\\frac{33}{4} & \\frac{27}{4} & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{13}{4} & 6 & -\\frac{43}{4} & -2 \\\\\n \\frac{7}{4} & \\frac{25}{2} & -12 & -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -(3/4), -9, (31/4)],\n [-(25/4), (17/4), -(21/4), -(11/2)]])\nb = np.array([\n [-(11/4), -(27/4), (7/4), (39/4)],\n [-8, -(33/4), (27/4), 1]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{33}{10} & -\\frac{23}{5} \\\\\n -\\frac{19}{5} & \\frac{13}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{2177}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(33/10), -(23/5)],\n [-(19/5), (13/10)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & 4 & 4 \\\\\n -10 & -10 & 10 \\\\\n 1 & -4 & 0 \\\\\n 9 & -5 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, 4, 4],\n [-10, -10, 10],\n [1, -4, 0],\n [9, -5, -6]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{9}{2} & -\\frac{22}{5} & \\frac{2}{5} \\\\\n -\\frac{5}{2} & -\\frac{21}{10} & -\\frac{5}{2} \\\\\n -\\frac{37}{10} & -2 & -\\frac{17}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{7019}{500}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2), -(22/5), (2/5)],\n [-(5/2), -(21/10), -(5/2)],\n [-(37/10), -2, -(17/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -1 & 0 \\\\\n -10 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-1,5\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0],\n [-10, 5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{15}{2} \\\\\n -\\frac{3}{2} \\\\\n -\\frac{53}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{28}{3} \\\\\n \\frac{37}{6} \\\\\n \\frac{14}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1709}{36} \\\\\n \\frac{427}{9} \\\\\n \\frac{129}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/2)],\n [-(3/2)],\n [-(53/6)]])\nb = np.array([\n [-(28/3)],\n [(37/6)],\n [(14/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 1 & -4 & -2 \\\\\n 1 & -1 & 2 \\\\\n -2 & 3 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & \\frac{11}{2} & \\frac{5}{2} \\\\\n 0 & 2 & 1 \\\\\n -\\frac{1}{4} & -\\frac{5}{4} & -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -4, -2],\n [1, -1, 2],\n [-2, 3, -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & -1 \\\\\n -2 & -3 \\\\\n -3 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.51 \\\\\n 2.32 \\\\\n 2.03 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.231 \\\\\n -0.185 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1],\n [-2, -3],\n [-3, 1]])\nb = np.array([\n [-1.51],\n [2.32],\n [2.03]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 1 & -1 & -1 & 2 \\\\\n 2 & 0 & -1 & -3 \\\\\n -3 & -2 & -2 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -1 & 0 \\\\\n 2 & 1 \\\\\n -2 & -2 \\\\\n 2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 3 & -5 \\\\\n -6 & 11 \\\\\n 3 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, -1, 2],\n [2, 0, -1, -3],\n [-3, -2, -2, 0]])\nb = np.array([\n [-1, 0],\n [2, 1],\n [-2, -2],\n [2, -3]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 6 & -5 & -5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -3 & 4 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 9 & -9 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -5, -5]])\nb = np.array([\n [-3, 4, -6]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & 5 \\\\\n 3 & 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-17 x+55$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 5],\n [3, 10]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{14}{5} & -\\frac{32}{5} \\\\\n \\frac{34}{5} & \\frac{44}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{5} \\left(29-i \\sqrt{863}\\right),\\frac{1}{5} \\left(29+i \\sqrt{863}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/5), -(32/5)],\n [(34/5), (44/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 0 & 8 & 1 \\\\\n -4 & -4 & 9 \\\\\n 5 & -5 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -5 & -3 & 2 \\\\\n 7 & -4 & 8 \\\\\n 8 & -4 & -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -5 & 5 & 3 \\\\\n 3 & -8 & 17 \\\\\n 13 & -9 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 8, 1],\n [-4, -4, 9],\n [5, -5, 8]])\nb = np.array([\n [-5, -3, 2],\n [7, -4, 8],\n [8, -4, -10]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -3 & 0 & 2 & 6 \\\\\n -8 & -6 & 8 & 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -7 & 8 & -6 & -2 \\\\\n 10 & -8 & 2 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -10 & 8 & -4 & 4 \\\\\n 2 & -14 & 10 & 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, 2, 6],\n [-8, -6, 8, 5]])\nb = np.array([\n [-7, 8, -6, -2],\n [10, -8, 2, 4]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{7} & -\\frac{13}{7} & -\\frac{26}{7} \\\\\n -1 & -\\frac{10}{7} & -\\frac{4}{7} \\\\\n -\\frac{24}{7} & 2 & -\\frac{11}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1162}{7711} & -\\frac{3549}{7711} & -\\frac{1456}{7711} \\\\\n \\frac{133}{7711} & -\\frac{3983}{7711} & \\frac{1134}{7711} \\\\\n -\\frac{2366}{7711} & \\frac{2674}{7711} & -\\frac{287}{7711} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/7), -(13/7), -(26/7)],\n [-1, -(10/7), -(4/7)],\n [-(24/7), 2, -(11/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 1 \\\\\n 1 \\\\\n 5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 2 \\\\\n -8 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 9 \\\\\n 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [1],\n [1],\n [5]])\nb = np.array([\n [-7],\n [2],\n [-8],\n [4]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -10 & \\frac{8}{3} \\\\\n -\\frac{11}{3} & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{22} \\left(45-\\sqrt{1673}\\right),1\\right\\}, \\left\\{\\frac{1}{22} \\left(45+\\sqrt{1673}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, (8/3)],\n [-(11/3), 5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-6]])\nb = np.array([\n [2],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{9}{2},0,0\\right\\}, \\left\\{1,-4,-\\frac{5}{2}\\right\\}, \\left\\{-4,\\frac{7}{2},-\\frac{5}{2}\\right\\}}$.", - "Output Answer": [ - "$30 x+20 y-74 z-135=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(9/2), 0, 0],\n [1, -4, -(5/2)],\n [-4, (7/2), -(5/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -5 & -7 \\\\\n 3 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+4 x+16$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -7],\n [3, 1]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -\\frac{7}{2} \\\\\n -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 10 \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{119}{4} \\\\\n -32 \\\\\n \\frac{149}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-(7/2)],\n [-(7/2)]])\nb = np.array([\n [7],\n [10],\n [(3/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\sqrt{5} \\\\\n \\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n -2 \\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n 2 \\sqrt{5} \\\\\n -\\sqrt{5} \\\\\n -3 \\sqrt{5} \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n 0 \\\\\n -\\sqrt{5} \\\\\n -3 \\sqrt{5} \\\\\n -3 \\sqrt{5} \\\\\n -4 \\sqrt{5} \\\\\n 2 \\sqrt{5} \\\\\n -3 \\sqrt{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{715}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.sqrt(5)],\n [math.sqrt(5)],\n [4*math.sqrt(5)],\n [-2*math.sqrt(5)],\n [4*math.sqrt(5)],\n [2*math.sqrt(5)],\n [-math.sqrt(5)],\n [-3*math.sqrt(5)],\n [0]])\nb = np.array([\n [math.sqrt(5)],\n [4*math.sqrt(5)],\n [0],\n [-math.sqrt(5)],\n [-3*math.sqrt(5)],\n [-3*math.sqrt(5)],\n [-4*math.sqrt(5)],\n [2*math.sqrt(5)],\n [-3*math.sqrt(5)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{20}{9} & -\\frac{4}{3} & \\frac{38}{9} & \\frac{86}{9} \\\\\n \\frac{1}{3} & -\\frac{1}{3} & 4 & \\frac{58}{9} \\\\\n -\\frac{11}{9} & \\frac{68}{9} & \\frac{13}{9} & -\\frac{22}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{2}{9} & 7 & -\\frac{31}{9} & -\\frac{52}{9} \\\\\n \\frac{14}{9} & -\\frac{59}{9} & 5 & \\frac{83}{9} \\\\\n -\\frac{16}{3} & \\frac{29}{9} & -\\frac{7}{3} & -\\frac{68}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -2 & \\frac{17}{3} & \\frac{7}{9} & \\frac{34}{9} \\\\\n \\frac{17}{9} & -\\frac{62}{9} & 9 & \\frac{47}{3} \\\\\n -\\frac{59}{9} & \\frac{97}{9} & -\\frac{8}{9} & -\\frac{134}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/9), -(4/3), (38/9), (86/9)],\n [(1/3), -(1/3), 4, (58/9)],\n [-(11/9), (68/9), (13/9), -(22/3)]])\nb = np.array([\n [(2/9), 7, -(31/9), -(52/9)],\n [(14/9), -(59/9), 5, (83/9)],\n [-(16/3), (29/9), -(7/3), -(68/9)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -5 & 10 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-3.,0.,5.\\}, \\{2.,1.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, 10, -3]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{2} & -\\frac{9}{2} & -\\frac{5}{2} \\\\\n -\\frac{1}{2} & -\\frac{3}{2} & 1 \\\\\n -\\frac{9}{2} & \\frac{7}{2} & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{225}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), -(9/2), -(5/2)],\n [-(1/2), -(3/2), 1],\n [-(9/2), (7/2), 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(3 \\sqrt{10}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [1],\n [-1],\n [1],\n [-1],\n [1],\n [1],\n [-1],\n [-1]]).squeeze()\nb = np.array([\n [-1],\n [-1],\n [1],\n [1],\n [-1],\n [-1],\n [-1],\n [-1],\n [-1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -4 & 1 & 1 \\\\\n -2 & -1 & 2 \\\\\n -2 & -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{6} & \\frac{1}{3} & -\\frac{1}{2} \\\\\n \\frac{1}{3} & \\frac{1}{3} & -1 \\\\\n 0 & 1 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 1, 1],\n [-2, -1, 2],\n [-2, -1, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & -7 \\\\\n -5 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(1-\\sqrt{165}\\right),\\frac{1}{2} \\left(1+\\sqrt{165}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -7],\n [-5, -2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{991}{100} & -\\frac{17}{100} & \\frac{23}{20} \\\\\n -\\frac{703}{100} & \\frac{209}{50} & -\\frac{183}{100} \\\\\n -\\frac{77}{100} & \\frac{131}{20} & \\frac{202}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{47 x^2}{20}+\\frac{760453 x}{10000}-\\frac{512638559}{1000000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(991/100), -(17/100), (23/20)],\n [-(703/100), (209/50), -(183/100)],\n [-(77/100), (131/20), (202/25)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{15}{8}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 4 & -9 & 2 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{15}{2} & \\frac{135}{8} & -\\frac{15}{4} & -15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -9, 2, 8]])\nprint(a * -(15/8))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{46}{5} & \\frac{29}{5} \\\\\n -\\frac{16}{5} & -\\frac{23}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(-69-i \\sqrt{1327}\\right),\\frac{1}{10} \\left(-69+i \\sqrt{1327}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(46/5), (29/5)],\n [-(16/5), -(23/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 6 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{38}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [3],\n [2]])\nb = np.array([\n [-3],\n [6],\n [4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{9}{10}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{9}{10} & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -5]])\nprint(a * -(9/10))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & 2 & 10 \\\\\n 7 & 6 & 7 \\\\\n -4 & 4 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{1.5\\, -5.074 i,1.5\\, +5.074 i,13.\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, 10],\n [7, 6, 7],\n [-4, 4, 9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{1}{9} \\\\\n \\frac{26}{9} \\\\\n -\\frac{5}{9} \\\\\n -\\frac{16}{9} \\\\\n \\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{18}{\\sqrt{1291}} \\\\\n \\frac{1}{\\sqrt{1291}} \\\\\n \\frac{26}{\\sqrt{1291}} \\\\\n -\\frac{5}{\\sqrt{1291}} \\\\\n -\\frac{16}{\\sqrt{1291}} \\\\\n \\frac{3}{\\sqrt{1291}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [(1/9)],\n [(26/9)],\n [-(5/9)],\n [-(16/9)],\n [(1/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{17}{6} & -\\frac{7}{2} \\\\\n \\frac{7}{6} & -\\frac{13}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{156}{295} & -\\frac{126}{295} \\\\\n \\frac{42}{295} & -\\frac{102}{295} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/6), -(7/2)],\n [(7/6), -(13/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 e \\\\\n e \\\\\n -2 e \\\\\n 2 e \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 e \\\\\n 0 \\\\\n e \\\\\n -2 e \\\\\n -e \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{43} e$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-2*math.e],\n [math.e],\n [-2*math.e],\n [2*math.e],\n [0]])\nb = np.array([\n [2*math.e],\n [0],\n [math.e],\n [-2*math.e],\n [-math.e]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{2}{5} & \\frac{37}{10} & \\frac{5}{2} \\\\\n -\\frac{37}{10} & -\\frac{41}{10} & \\frac{21}{5} \\\\\n \\frac{9}{5} & -\\frac{22}{5} & \\frac{17}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{114999}{1000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/5), (37/10), (5/2)],\n [-(37/10), -(41/10), (21/5)],\n [(9/5), -(22/5), (17/10)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 8 & 2 & 6 & 9 & -4 & -4 \\\\\n 0 & -10 & -6 & -9 & 1 & 2 \\\\\n 0 & -4 & -8 & 1 & 9 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & \\frac{39}{28} & \\frac{25}{56} & \\frac{3}{7} \\\\\n 0 & 1 & 0 & \\frac{39}{28} & \\frac{23}{28} & \\frac{19}{28} \\\\\n 0 & 0 & 1 & -\\frac{23}{28} & -\\frac{43}{28} & -\\frac{41}{28} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, 2, 6, 9, -4, -4],\n [0, -10, -6, -9, 1, 2],\n [0, -4, -8, 1, 9, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{14}{5}, \\frac{22}{5}, -\\frac{22}{5}}$ to the plane $-3 x+\\frac{3 y}{5}+\\frac{9 z}{5}-\\frac{18}{5}=0$.", - "Output Answer": [ - "$\\frac{4}{5 \\sqrt{35}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(14/5), (22/5), -(22/5)\nplane = Poly(-3*x+((3*y)/5)+((9*z)/5)-(18/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{54}{7} \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{43}{7} \\\\\n -\\frac{34}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{9634}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(54/7)],\n [-7]])\nb = np.array([\n [(43/7)],\n [-(34/7)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,-4,-1\\}, \\{5,4,-4\\}, \\{-2,1,3\\}}$.", - "Output Answer": [ - "$47 x+7 y+50 z-63=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, -4, -1],\n [5, 4, -4],\n [-2, 1, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & 7 \\\\\n -4 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-13 x+70$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 7],\n [-4, 6]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 1 \\\\\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 15 \\\\\n 72 \\\\\n -18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [2],\n [3]])\nb = np.array([\n [6],\n [1],\n [9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 5 & 6 & 10 \\\\\n 5 & 0 & 10 \\\\\n 0 & -10 & 5 \\\\\n 4 & 0 & 9 \\\\\n 2 & -5 & -6 \\\\\n 7 & -10 & -1 \\\\\n 0 & 9 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, 6, 10],\n [5, 0, 10],\n [0, -10, 5],\n [4, 0, 9],\n [2, -5, -6],\n [7, -10, -1],\n [0, 9, 5]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 7 & -3 & 1 & -2 & -6 & -9 & -7 \\\\\n 10 & -5 & 10 & 6 & 10 & 7 & 0 \\\\\n 9 & 2 & 7 & 2 & 4 & 7 & -3 \\\\\n 4 & 0 & 2 & 3 & -10 & -3 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & -\\frac{82}{29} & -\\frac{401}{232} & -\\frac{212}{145} \\\\\n 0 & 1 & 0 & 0 & -\\frac{22}{29} & \\frac{19}{29} & -\\frac{6}{29} \\\\\n 0 & 0 & 1 & 0 & \\frac{154}{29} & \\frac{763}{232} & \\frac{239}{145} \\\\\n 0 & 0 & 0 & 1 & -\\frac{90}{29} & -\\frac{103}{116} & -\\frac{14}{29} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, -3, 1, -2, -6, -9, -7],\n [10, -5, 10, 6, 10, 7, 0],\n [9, 2, 7, 2, 4, 7, -3],\n [4, 0, 2, 3, -10, -3, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n \\frac{1}{2} \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{7}{2} \\\\\n 7 \\\\\n -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{233}{4} \\\\\n \\frac{11}{2} \\\\\n -\\frac{147}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [(1/2)],\n [8]])\nb = np.array([\n [(7/2)],\n [7],\n [-(9/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2 & -\\frac{3}{2} & -\\frac{3}{2} \\\\\n -2 & 3 & 2 \\\\\n \\frac{5}{2} & -3 & \\frac{5}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{175}{8} & \\frac{123}{8} & -\\frac{33}{4} \\\\\n 17 & -\\frac{57}{2} & \\frac{85}{2} \\\\\n \\frac{69}{4} & -\\frac{489}{8} & -\\frac{481}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -(3/2), -(3/2)],\n [-2, 3, 2],\n [(5/2), -3, (5/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{5} & \\frac{17}{5} & 8 \\\\\n \\frac{48}{5} & \\frac{31}{5} & \\frac{34}{5} \\\\\n -\\frac{7}{5} & 2 & -\\frac{7}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-2.787-3.543 i,-2.787+3.543 i,10.974\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/5), (17/5), 8],\n [(48/5), (31/5), (34/5)],\n [-(7/5), 2, -(7/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{34}{7}, -\\frac{33}{7}}$ to the line $-\\frac{19 x}{7}+\\frac{22 y}{7}-\\frac{11}{7}=0$.", - "Output Answer": [ - "$\\frac{157}{91 \\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(34/7), -(33/7)\nline = Poly(-((19*x)/7)+((22*y)/7)-(11/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${2, -5}$ to the line $-2 x-5 y-1=0$.", - "Output Answer": [ - "$\\frac{20}{\\sqrt{29}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 2, -5\nline = Poly(-2*x-5*y-1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & 2 \\\\\n -2 & 3 \\\\\n 2 & -1 \\\\\n 1 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.02 \\\\\n -2.99 \\\\\n -0.01 \\\\\n 2.93 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.368 \\\\\n -0.507 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2],\n [-2, 3],\n [2, -1],\n [1, -3]])\nb = np.array([\n [1.02],\n [-2.99],\n [-0.01],\n [2.93]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -4 & \\frac{9}{2} & -\\frac{9}{2} \\\\\n -\\frac{3}{2} & -\\frac{7}{2} & -4 \\\\\n 3 & -1 & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{1483}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, (9/2), -(9/2)],\n [-(3/2), -(7/2), -4],\n [3, -1, -(9/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & 0 \\\\\n 7 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+3 x-10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0],\n [7, -5]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & 7 \\\\\n 5 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{3}{2} \\left(-1-\\sqrt{21}\\right),\\frac{3}{2} \\left(\\sqrt{21}-1\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 7],\n [5, -5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{4} \\\\\n -\\frac{5}{2} \\\\\n \\frac{5}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{6}} \\\\\n -\\sqrt{\\frac{2}{3}} \\\\\n \\frac{1}{\\sqrt{6}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/4)],\n [-(5/2)],\n [(5/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -6 & 6 \\\\\n 4 & 1 \\\\\n -3 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 6],\n [4, 1],\n [-3, 4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{4}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -6 & 9 & 5 \\\\\n -4 & 5 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{21}{2} & -\\frac{63}{4} & -\\frac{35}{4} \\\\\n 7 & -\\frac{35}{4} & \\frac{21}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 9, 5],\n [-4, 5, -3]])\nprint(a * -(7/4))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -4 & -1 & -10 \\\\\n -1 & 1 & 7 \\\\\n 9 & 10 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.977,1.229,1.\\}, \\{-0.067-1.448 i,-0.664+0.662 i,1.\\}, \\{-0.067+1.448 i,-0.664-0.662 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -1, -10],\n [-1, 1, 7],\n [9, 10, 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(\\sqrt{15}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [1],\n [1],\n [1]]).squeeze()\nb = np.array([\n [0],\n [1],\n [1],\n [-1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{34}{5} & -\\frac{38}{5} & 2 \\\\\n -\\frac{41}{5} & \\frac{34}{5} & \\frac{12}{5} \\\\\n -\\frac{27}{5} & -\\frac{48}{5} & \\frac{38}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{3.292\\, -3.749 i,3.292\\, +3.749 i,14.617\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(34/5), -(38/5), 2],\n [-(41/5), (34/5), (12/5)],\n [-(27/5), -(48/5), (38/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{287}{50} \\\\\n \\frac{213}{25} \\\\\n -\\frac{777}{100} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{979}{100} \\\\\n \\frac{739}{100} \\\\\n \\frac{99}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{742899}{10000} \\\\\n -\\frac{647031}{10000} \\\\\n -\\frac{629147}{5000} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(287/50)],\n [(213/25)],\n [-(777/100)]])\nb = np.array([\n [(979/100)],\n [(739/100)],\n [(99/50)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\sqrt{3} \\\\\n -\\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n 5 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\sqrt{3} \\\\\n -4 \\sqrt{3} \\\\\n 5 \\sqrt{3} \\\\\n 2 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$36$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [2*math.sqrt(3)],\n [-math.sqrt(3)],\n [-2*math.sqrt(3)],\n [5*math.sqrt(3)]])\nb = np.array([\n [4*math.sqrt(3)],\n [-4*math.sqrt(3)],\n [5*math.sqrt(3)],\n [2*math.sqrt(3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 10 & 10 & 2 & -10 \\\\\n 3 & -2 & 9 & 5 \\\\\n -2 & 2 & -6 & 1 \\\\\n 5 & 10 & 4 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [10, 10, 2, -10],\n [3, -2, 9, 5],\n [-2, 2, -6, 1],\n [5, 10, 4, -9]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{399}{100} & -\\frac{749}{100} & \\frac{577}{100} \\\\\n \\frac{291}{100} & \\frac{9}{100} & \\frac{283}{100} \\\\\n -\\frac{273}{50} & \\frac{393}{50} & \\frac{723}{100} \\\\\n -\\frac{227}{50} & -\\frac{47}{25} & -\\frac{89}{25} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{87}{20} & \\frac{437}{50} & -\\frac{101}{100} \\\\\n -\\frac{639}{100} & -\\frac{158}{25} & -\\frac{82}{25} \\\\\n -\\frac{212}{25} & \\frac{43}{100} & \\frac{12}{5} \\\\\n -\\frac{983}{100} & -\\frac{207}{100} & \\frac{111}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{417}{50} & -\\frac{1623}{100} & \\frac{339}{50} \\\\\n \\frac{93}{10} & \\frac{641}{100} & \\frac{611}{100} \\\\\n \\frac{151}{50} & \\frac{743}{100} & \\frac{483}{100} \\\\\n \\frac{529}{100} & \\frac{19}{100} & -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(399/100), -(749/100), (577/100)],\n [(291/100), (9/100), (283/100)],\n [-(273/50), (393/50), (723/100)],\n [-(227/50), -(47/25), -(89/25)]])\nb = np.array([\n [(87/20), (437/50), -(101/100)],\n [-(639/100), -(158/25), -(82/25)],\n [-(212/25), (43/100), (12/5)],\n [-(983/100), -(207/100), (111/25)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\sqrt{2} \\\\\n 0 \\\\\n -4 \\sqrt{2} \\\\\n 5 \\sqrt{2} \\\\\n \\sqrt{2} \\\\\n -\\sqrt{2} \\\\\n 3 \\sqrt{2} \\\\\n 5 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\sqrt{2} \\\\\n -7 \\sqrt{2} \\\\\n 4 \\sqrt{2} \\\\\n -\\sqrt{2} \\\\\n 5 \\sqrt{2} \\\\\n 5 \\sqrt{2} \\\\\n -3 \\sqrt{2} \\\\\n 6 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$40$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-5*math.sqrt(2)],\n [0],\n [-4*math.sqrt(2)],\n [5*math.sqrt(2)],\n [math.sqrt(2)],\n [-math.sqrt(2)],\n [3*math.sqrt(2)],\n [5*math.sqrt(2)]])\nb = np.array([\n [-4*math.sqrt(2)],\n [-7*math.sqrt(2)],\n [4*math.sqrt(2)],\n [-math.sqrt(2)],\n [5*math.sqrt(2)],\n [5*math.sqrt(2)],\n [-3*math.sqrt(2)],\n [6*math.sqrt(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -\\frac{6}{5} & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{4}{5} & -\\frac{13}{5} \\\\\n -\\frac{3}{5} & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{6}{25} & \\frac{178}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(6/5), -2]])\nb = np.array([\n [(4/5), -(13/5)],\n [-(3/5), -2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 2 \\\\\n 1 \\\\\n -2 \\\\\n 3 \\\\\n -4 \\\\\n -1 \\\\\n 8 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -10 \\\\\n 4 \\\\\n 4 \\\\\n 2 \\\\\n 3 \\\\\n 2 \\\\\n 7 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{274}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [2],\n [1],\n [-2],\n [3],\n [-4],\n [-1],\n [8],\n [8]])\nb = np.array([\n [8],\n [-10],\n [4],\n [4],\n [2],\n [3],\n [2],\n [7],\n [4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -5 & 0 & \\frac{7}{6} \\\\\n 4 & -\\frac{13}{3} & 1 \\\\\n -\\frac{17}{6} & \\frac{1}{6} & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{6817}{108}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 0, (7/6)],\n [4, -(13/3), 1],\n [-(17/6), (1/6), (7/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n 6 & 10 & -2 & 3 \\\\\n 2 & 3 & 2 & -3 \\\\\n -4 & -8 & 0 & -8 \\\\\n 6 & 8 & 1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 10, -2, 3],\n [2, 3, 2, -3],\n [-4, -8, 0, -8],\n [6, 8, 1, -2]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{8}{3} & 2 \\\\\n \\frac{10}{3} & -\\frac{28}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{13}{3} & 9 \\\\\n \\frac{25}{3} & -\\frac{16}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -7 & 11 \\\\\n \\frac{35}{3} & -\\frac{44}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/3), 2],\n [(10/3), -(28/3)]])\nb = np.array([\n [-(13/3), 9],\n [(25/3), -(16/3)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 8 & -5 & -9 & 10 & -6 \\\\\n -4 & -7 & 1 & 3 & 0 \\\\\n -6 & 8 & -2 & 0 & -5 \\\\\n -8 & 6 & 9 & -6 & -4 \\\\\n -6 & 1 & 0 & 10 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [8, -5, -9, 10, -6],\n [-4, -7, 1, 3, 0],\n [-6, 8, -2, 0, -5],\n [-8, 6, 9, -6, -4],\n [-6, 1, 0, 10, 0]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{7}{2}, \\frac{3}{2}}$ to the line $-3 x-2 y+1=0$.", - "Output Answer": [ - "$\\frac{17}{2 \\sqrt{13}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(7/2), (3/2)\nline = Poly(-3*x-2*y+1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 0 \\\\\n -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -6 \\\\\n -13 \\\\\n 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [1]])\nb = np.array([\n [-7],\n [0],\n [-6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${1, -3, -3}$ to the plane $3 x+y+2 z-1=0$.", - "Output Answer": [ - "$\\sqrt{\\frac{7}{2}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 1, -3, -3\nplane = Poly(3*x+y+2*z-1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{8}{3},-2,-\\frac{1}{3}\\right\\}, \\left\\{5,\\frac{13}{3},\\frac{10}{3}\\right\\}, \\left\\{-\\frac{10}{3},-\\frac{11}{3},2\\right\\}}$.", - "Output Answer": [ - "$188 x-247 y+307 z-893=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(8/3), -2, -(1/3)],\n [5, (13/3), (10/3)],\n [-(10/3), -(11/3), 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{12}{5} \\\\\n -\\frac{1}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{11}{5} \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{12}{5},0\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(12/5)],\n [-(1/5)]]).squeeze()\nb = np.array([\n [(11/5)],\n [0]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -5 \\\\\n -4 \\\\\n -5 \\\\\n 2 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -9 \\\\\n 2 \\\\\n 0 \\\\\n 3 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4 \\sqrt{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-5],\n [-4],\n [-5],\n [2],\n [-9]])\nb = np.array([\n [7],\n [-9],\n [2],\n [0],\n [3],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & 1 & 1 & -2 \\\\\n 0 & -1 & 2 & -1 \\\\\n -1 & -1 & -2 & -3 \\\\\n 3 & -1 & -2 & -2 \\\\\n -3 & 1 & -1 & 1 \\\\\n -1 & -1 & 2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.97 \\\\\n -1.62 \\\\\n -1.71 \\\\\n -2.36 \\\\\n 2.73 \\\\\n 1.97 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.69 \\\\\n 0.091 \\\\\n 0.186 \\\\\n 0.272 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 1, -2],\n [0, -1, 2, -1],\n [-1, -1, -2, -3],\n [3, -1, -2, -2],\n [-3, 1, -1, 1],\n [-1, -1, 2, -3]])\nb = np.array([\n [-0.97],\n [-1.62],\n [-1.71],\n [-2.36],\n [2.73],\n [1.97]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -3 & 3 & 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 9 & -9 & -3 & 3 \\\\\n -3 & 3 & 1 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [1]])\nb = np.array([\n [-3, 3, 1, -1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{48}{5} \\\\\n -5 \\\\\n \\frac{32}{5} \\\\\n \\frac{33}{5} \\\\\n 2 \\\\\n -\\frac{9}{5} \\\\\n \\frac{38}{5} \\\\\n \\frac{38}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{43}{5} \\\\\n -2 \\\\\n -\\frac{4}{5} \\\\\n \\frac{22}{5} \\\\\n \\frac{49}{5} \\\\\n -9 \\\\\n -\\frac{29}{5} \\\\\n -\\frac{34}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1413}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(48/5)],\n [-5],\n [(32/5)],\n [(33/5)],\n [2],\n [-(9/5)],\n [(38/5)],\n [(38/5)]])\nb = np.array([\n [(43/5)],\n [-2],\n [-(4/5)],\n [(22/5)],\n [(49/5)],\n [-9],\n [-(29/5)],\n [-(34/5)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{28}{5} & \\frac{83}{10} & -\\frac{12}{5} \\\\\n -8 & \\frac{15}{2} & -\\frac{83}{10} \\\\\n \\frac{6}{5} & \\frac{71}{10} & \\frac{42}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{103 x^2}{10}-\\frac{10217 x}{100}-\\frac{12449}{250}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(28/5), (83/10), -(12/5)],\n [-8, (15/2), -(83/10)],\n [(6/5), (71/10), (42/5)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 2 & -5 & 9 & 0 \\\\\n 2 & -1 & -1 & -4 \\\\\n -4 & 2 & 0 & 3 \\\\\n 10 & -3 & -2 & 10 \\\\\n -4 & -2 & 10 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, -5, 9, 0],\n [2, -1, -1, -4],\n [-4, 2, 0, 3],\n [10, -3, -2, 10],\n [-4, -2, 10, 0]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 2 & -7 & 3 & 3 & -2 & -10 & -5 \\\\\n 6 & 8 & -10 & -3 & -1 & -8 & -3 \\\\\n 6 & 1 & 3 & -8 & 8 & -2 & 0 \\\\\n 2 & 4 & 8 & 1 & -2 & 0 & 5 \\\\\n -3 & 1 & 7 & -3 & 8 & -4 & 6 \\\\\n -1 & -3 & 4 & -5 & 2 & -10 & 10 \\\\\n -5 & 5 & -4 & -3 & 9 & -7 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, -7, 3, 3, -2, -10, -5],\n [6, 8, -10, -3, -1, -8, -3],\n [6, 1, 3, -8, 8, -2, 0],\n [2, 4, 8, 1, -2, 0, 5],\n [-3, 1, 7, -3, 8, -4, 6],\n [-1, -3, 4, -5, 2, -10, 10],\n [-5, 5, -4, -3, 9, -7, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-3,2,1\\}, \\{1,-1,1\\}, \\{3,1,1\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{3}{\\sqrt{14}},\\sqrt{\\frac{2}{7}},\\frac{1}{\\sqrt{14}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{91}},-\\frac{3}{\\sqrt{91}},\\frac{9}{\\sqrt{91}}\\right\\}, \\left\\{\\frac{3}{\\sqrt{26}},2 \\sqrt{\\frac{2}{13}},\\frac{1}{\\sqrt{26}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-3, 2, 1), (1, -1, 1), (3, 1, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -8 & -6 \\\\\n 7 & 5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -5 & -3 \\\\\n 1 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -3 & -3 \\\\\n 6 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -6],\n [7, 5]])\nb = np.array([\n [-5, -3],\n [1, 4]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{8} & -1 \\\\\n -\\frac{15}{16} & \\frac{35}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{56}{19} & -\\frac{64}{95} \\\\\n -\\frac{12}{19} & \\frac{8}{95} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/8), -1],\n [-(15/16), (35/8)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{51}{8} \\\\\n \\frac{19}{2} \\\\\n \\frac{41}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{3}{4} \\\\\n \\frac{17}{4} \\\\\n \\frac{3}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{57}{8} \\\\\n \\frac{55}{4} \\\\\n \\frac{47}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(51/8)],\n [(19/2)],\n [(41/8)]])\nb = np.array([\n [(3/4)],\n [(17/4)],\n [(3/4)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{7} \\\\\n -\\frac{5}{7} \\\\\n -\\frac{1}{7} \\\\\n 1 \\\\\n \\frac{5}{7} \\\\\n -\\frac{12}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{19}{11 \\sqrt{5}} \\\\\n -\\frac{\\sqrt{5}}{11} \\\\\n -\\frac{1}{11 \\sqrt{5}} \\\\\n \\frac{7}{11 \\sqrt{5}} \\\\\n \\frac{\\sqrt{5}}{11} \\\\\n -\\frac{12}{11 \\sqrt{5}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/7)],\n [-(5/7)],\n [-(1/7)],\n [1],\n [(5/7)],\n [-(12/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{8}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 7 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{21}{8} & -\\frac{21}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 7]])\nprint(a * -(3/8))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{237}{50} \\\\\n \\frac{39}{25} \\\\\n \\frac{166}{25} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{729}{100} \\\\\n \\frac{559}{100} \\\\\n -\\frac{79}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{30901}{625} \\\\\n \\frac{27399}{2500} \\\\\n -\\frac{37869}{1000} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(237/50)],\n [(39/25)],\n [(166/25)]])\nb = np.array([\n [(729/100)],\n [(559/100)],\n [-(79/10)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{2} \\\\\n -2 \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{5}{\\sqrt{42}} \\\\\n -2 \\sqrt{\\frac{2}{21}} \\\\\n \\frac{1}{\\sqrt{42}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2)],\n [-2],\n [(1/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{4}{3},-3,-2\\right\\}, \\left\\{-\\frac{1}{3},-\\frac{14}{3},-\\frac{5}{3}\\right\\}, \\left\\{-3,-\\frac{14}{3},\\frac{10}{3}\\right\\}}$.", - "Output Answer": [ - "$75 x-67 y+40 z-221=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(4/3), -3, -2],\n [-(1/3), -(14/3), -(5/3)],\n [-3, -(14/3), (10/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & 3 \\\\\n 1 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-9 x-3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 3],\n [1, 9]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{16}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -8 & 10 & -10 \\\\\n -10 & 4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{2} & \\frac{15}{8} & -\\frac{15}{8} \\\\\n -\\frac{15}{8} & \\frac{3}{4} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 10, -10],\n [-10, 4, 0]])\nprint(a * (3/16))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -8 & 3 & 5 & -8 \\\\\n -1 & 3 & 5 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-36.,-40.,0.,21.\\}, \\{0.,-5.,3.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-8, 3, 5, -8],\n [-1, 3, 5, 4]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 0 \\\\\n -8 \\\\\n 1 \\\\\n 2 \\\\\n -6 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 6 \\\\\n 6 \\\\\n 6 \\\\\n 4 \\\\\n -8 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{65}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [0],\n [-8],\n [1],\n [2],\n [-6],\n [-6]])\nb = np.array([\n [-2],\n [6],\n [6],\n [6],\n [4],\n [-8],\n [10]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{4} & -\\frac{1}{2} & -\\frac{27}{4} \\\\\n -3 & -\\frac{1}{4} & \\frac{1}{2} \\\\\n \\frac{23}{4} & \\frac{15}{2} & -\\frac{39}{4} \\\\\n \\frac{29}{4} & -\\frac{13}{4} & -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{31}{4} & -\\frac{3}{2} & -\\frac{23}{4} \\\\\n \\frac{15}{4} & -\\frac{7}{4} & -\\frac{27}{4} \\\\\n -6 & \\frac{11}{2} & \\frac{39}{4} \\\\\n -10 & 0 & \\frac{23}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{9}{2} & -2 & -\\frac{25}{2} \\\\\n \\frac{3}{4} & -2 & -\\frac{25}{4} \\\\\n -\\frac{1}{4} & 13 & 0 \\\\\n -\\frac{11}{4} & -\\frac{13}{4} & -\\frac{13}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/4), -(1/2), -(27/4)],\n [-3, -(1/4), (1/2)],\n [(23/4), (15/2), -(39/4)],\n [(29/4), -(13/4), -9]])\nb = np.array([\n [-(31/4), -(3/2), -(23/4)],\n [(15/4), -(7/4), -(27/4)],\n [-6, (11/2), (39/4)],\n [-10, 0, (23/4)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{5}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{5} \\\\\n \\frac{2}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [2]])\nprint(a * (1/5))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -1 & 4 & -3 \\\\\n 1 & 3 & -4 \\\\\n 1 & -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{7} & \\frac{1}{7} & 1 \\\\\n \\frac{5}{7} & -\\frac{2}{7} & 1 \\\\\n \\frac{4}{7} & -\\frac{3}{7} & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 4, -3],\n [1, 3, -4],\n [1, -1, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -2 & -4 & 8 \\\\\n 2 & -7 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -4, 8],\n [2, -7, -2]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n \\frac{5}{2} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n -\\frac{9}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{425}{181},\\frac{765}{362}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [(5/2)]]).squeeze()\nb = np.array([\n [(5/2)],\n [-(9/4)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{7}{5}, -\\frac{11}{5}}$ to the line $-\\frac{33 x}{10}-\\frac{21 y}{5}-\\frac{27}{10}=0$.", - "Output Answer": [ - "$\\frac{186}{5 \\sqrt{317}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(7/5), -(11/5)\nline = Poly(-((33*x)/10)-((21*y)/5)-(27/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -8 & 9 & 1 \\\\\n 7 & -2 & 5 \\\\\n 7 & 6 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-13.128,-1.426,12.554\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 9, 1],\n [7, -2, 5],\n [7, 6, 8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -10 & 2 \\\\\n 3 & -1 \\\\\n 9 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 2],\n [3, -1],\n [9, 7]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 9 \\\\\n 6 \\\\\n 2 \\\\\n -2 \\\\\n 1 \\\\\n -4 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 0 \\\\\n -3 \\\\\n -1 \\\\\n -9 \\\\\n -9 \\\\\n 6 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{107}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [9],\n [6],\n [2],\n [-2],\n [1],\n [-4],\n [-4]])\nb = np.array([\n [8],\n [0],\n [-3],\n [-1],\n [-9],\n [-9],\n [6],\n [-6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}+\\cot ^{-1}(3)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-2]]).squeeze()\nb = np.array([\n [0],\n [8]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -\\frac{4}{3} & -\\frac{26}{3} & -\\frac{1}{3} & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/3), -(26/3), -(1/3), 5]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,-2,-1\\}, \\{5,-3,0\\}, \\{4,-1,4\\}}$.", - "Output Answer": [ - "$6 x+37 y-17 z+81=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, -2, -1],\n [5, -3, 0],\n [4, -1, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{833}{100} & \\frac{113}{100} & \\frac{96}{25} \\\\\n -\\frac{171}{100} & \\frac{137}{100} & \\frac{143}{25} \\\\\n -\\frac{403}{100} & -\\frac{287}{100} & \\frac{847}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{1817 x^2}{100}-\\frac{25479 x}{200}+\\frac{65943491}{250000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(833/100), (113/100), (96/25)],\n [-(171/100), (137/100), (143/25)],\n [-(403/100), -(287/100), (847/100)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & \\frac{11}{2} \\\\\n 4 & \\frac{15}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{16} \\left(-15-\\sqrt{577}\\right),1\\right\\}, \\left\\{\\frac{1}{16} \\left(\\sqrt{577}-15\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, (11/2)],\n [4, (15/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{2} & -\\frac{41}{16} \\\\\n \\frac{109}{16} & -\\frac{113}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{57 x}{16}-\\frac{1859}{256}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2), -(41/16)],\n [(109/16), -(113/16)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n \\frac{13}{5} \\\\\n \\frac{3}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{5} \\\\\n -\\frac{21}{5} \\\\\n \\frac{18}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{297}{25} \\\\\n -\\frac{816}{25} \\\\\n -\\frac{919}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [(13/5)],\n [(3/5)]])\nb = np.array([\n [-(2/5)],\n [-(21/5)],\n [(18/5)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 e \\\\\n -4 e \\\\\n -3 e \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 e \\\\\n 0 \\\\\n e \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-12 e^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [3*math.e],\n [-4*math.e],\n [-3*math.e]])\nb = np.array([\n [-3*math.e],\n [0],\n [math.e]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{15}{64}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & 2 & 1 \\\\\n 0 & -7 & -9 \\\\\n -3 & -1 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{15}{64} & \\frac{15}{32} & \\frac{15}{64} \\\\\n 0 & -\\frac{105}{64} & -\\frac{135}{64} \\\\\n -\\frac{45}{64} & -\\frac{15}{64} & \\frac{75}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2, 1],\n [0, -7, -9],\n [-3, -1, 10]])\nprint(a * (15/64))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-2,-\\frac{5}{3},1\\right\\}, \\left\\{-\\frac{2}{3},-4,-1\\right\\}, \\left\\{\\frac{7}{3},-\\frac{10}{3},1\\right\\}}$.", - "Output Answer": [ - "$30 x+78 y-71 z+261=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, -(5/3), 1],\n [-(2/3), -4, -1],\n [(7/3), -(10/3), 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{3}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [2*math.sqrt(3)],\n [4*math.sqrt(3)]])\nb = np.array([\n [-3*math.sqrt(3)],\n [4*math.sqrt(3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -8 & 0 & 5 \\\\\n 2 & -10 & -2 \\\\\n 8 & -3 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-6.699,-12.283,1.\\}, \\{-1.372,2.888,1.\\}, \\{0.272,-0.071,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 0, 5],\n [2, -10, -2],\n [8, -3, 8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{2} & -1 \\\\\n \\frac{9}{2} & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$12$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), -1],\n [(9/2), -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -10 & 7 & 5 & -10 \\\\\n 5 & -6 & 8 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & -\\frac{86}{25} & \\frac{74}{25} \\\\\n 0 & 1 & -\\frac{21}{5} & \\frac{14}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, 7, 5, -10],\n [5, -6, 8, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 3 & 8 \\\\\n 5 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, 8],\n [5, 4]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{20}{7} \\\\\n -\\frac{19}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{20}{\\sqrt{761}} \\\\\n -\\frac{19}{\\sqrt{761}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/7)],\n [-(19/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{29}{16}, -\\frac{37}{16}}$ to the line $\\frac{159 x}{32}+\\frac{3}{16}=0$.", - "Output Answer": [ - "$\\frac{1505}{848}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(29/16), -(37/16)\nline = Poly(((159*x)/32)+(3/16), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 2 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-2,\\frac{2}{3},\\frac{2}{3},-\\frac{2}{3},0\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [2],\n [-1],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [3],\n [-1],\n [-1],\n [1],\n [0]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & -5 \\\\\n -3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-12$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -5],\n [-3, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${1, 0}$ to the line $2 x+5 y+5=0$.", - "Output Answer": [ - "$\\frac{7}{\\sqrt{29}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 1, 0\nline = Poly(2*x+5*y+5, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{10}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & -4 \\\\\n -2 & -8 \\\\\n -4 & 5 \\\\\n -5 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{2}{5} & \\frac{2}{5} \\\\\n \\frac{1}{5} & \\frac{4}{5} \\\\\n \\frac{2}{5} & -\\frac{1}{2} \\\\\n \\frac{1}{2} & -\\frac{9}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -4],\n [-2, -8],\n [-4, 5],\n [-5, 9]])\nprint(a * -(1/10))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & 0 & -2 & -2 \\\\\n 2 & 2 & 3 & -3 \\\\\n -3 & 1 & -3 & 3 \\\\\n 2 & -2 & 2 & -2 \\\\\n -1 & -3 & 3 & 2 \\\\\n 3 & 0 & 2 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.53 \\\\\n 2.53 \\\\\n -0.66 \\\\\n -0.09 \\\\\n -0.14 \\\\\n 1.16 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.186 \\\\\n 0.344 \\\\\n 0.302 \\\\\n -0.364 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, -2, -2],\n [2, 2, 3, -3],\n [-3, 1, -3, 3],\n [2, -2, 2, -2],\n [-1, -3, 3, 2],\n [3, 0, 2, 0]])\nb = np.array([\n [1.53],\n [2.53],\n [-0.66],\n [-0.09],\n [-0.14],\n [1.16]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n 3 \\sqrt{5} \\\\\n -4 \\sqrt{5} \\\\\n 2 \\sqrt{5} \\\\\n 3 \\sqrt{5} \\\\\n -4 \\sqrt{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n 2 \\sqrt{5} \\\\\n -2 \\sqrt{5} \\\\\n -\\sqrt{5} \\\\\n -3 \\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{30}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [3*math.sqrt(5)],\n [4*math.sqrt(5)],\n [3*math.sqrt(5)],\n [-4*math.sqrt(5)],\n [2*math.sqrt(5)],\n [3*math.sqrt(5)],\n [-4*math.sqrt(5)]])\nb = np.array([\n [-3*math.sqrt(5)],\n [4*math.sqrt(5)],\n [2*math.sqrt(5)],\n [-2*math.sqrt(5)],\n [-math.sqrt(5)],\n [-3*math.sqrt(5)],\n [4*math.sqrt(5)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{15}{2} & -5 \\\\\n -\\frac{3}{2} & -2 \\\\\n \\frac{7}{2} & \\frac{19}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -6 & \\frac{5}{2} \\\\\n \\frac{9}{2} & -5 \\\\\n 9 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{27}{2} & -\\frac{15}{2} \\\\\n -6 & 3 \\\\\n -\\frac{11}{2} & \\frac{23}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/2), -5],\n [-(3/2), -2],\n [(7/2), (19/2)]])\nb = np.array([\n [-6, (5/2)],\n [(9/2), -5],\n [9, -2]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -2 & -2 & 2 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -3 & -2 \\\\\n -2 & 2 \\\\\n 1 & 0 \\\\\n -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 14 & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2, 2, -2]])\nb = np.array([\n [-3, -2],\n [-2, 2],\n [1, 0],\n [-1, 3]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 8 \\\\\n -\\frac{27}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n \\frac{31}{4} \\\\\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1989}{16} \\\\\n \\frac{531}{4} \\\\\n 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [8],\n [-(27/4)]])\nb = np.array([\n [-9],\n [(31/4)],\n [9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{2} \\\\\n 8 \\\\\n 9 \\\\\n -9 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{13}{2} \\\\\n -\\frac{7}{2} \\\\\n \\frac{15}{2} \\\\\n 3 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{89}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/2)],\n [8],\n [9],\n [-9],\n [-10]])\nb = np.array([\n [(13/2)],\n [-(7/2)],\n [(15/2)],\n [3],\n [9]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n \\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{27}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [(9/2)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -1 & 3 & 1 \\\\\n 4 & 5 & -3 \\\\\n 3 & -5 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{15}{47} & \\frac{5}{47} & \\frac{14}{47} \\\\\n \\frac{9}{47} & \\frac{3}{47} & -\\frac{1}{47} \\\\\n \\frac{35}{47} & -\\frac{4}{47} & \\frac{17}{47} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, 1],\n [4, 5, -3],\n [3, -5, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{49}{6} & \\frac{11}{3} \\\\\n -9 & 0 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{20}{3} & \\frac{9}{2} \\\\\n -\\frac{17}{3} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{89}{6} & -\\frac{5}{6} \\\\\n -\\frac{10}{3} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(49/6), (11/3)],\n [-9, 0]])\nb = np.array([\n [(20/3), (9/2)],\n [-(17/3), -(3/2)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{21}{4} \\\\\n -\\frac{19}{2} \\\\\n -\\frac{63}{8} \\\\\n -\\frac{61}{8} \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{125}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(21/4)],\n [-(19/2)],\n [-(63/8)],\n [-(61/8)],\n [-1]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{\\sqrt{\\pi }} \\\\\n -\\frac{4}{\\sqrt{\\pi }} \\\\\n \\frac{13}{\\sqrt{\\pi }} \\\\\n -\\frac{2}{\\sqrt{\\pi }} \\\\\n \\frac{9}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{8}{\\sqrt{\\pi }} \\\\\n -\\frac{3}{\\sqrt{\\pi }} \\\\\n -\\frac{11}{\\sqrt{\\pi }} \\\\\n -\\frac{2}{\\sqrt{\\pi }} \\\\\n -\\frac{11}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{106}{\\pi }$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(15/(math.sqrt(math.pi)))],\n [-(4/(math.sqrt(math.pi)))],\n [(13/(math.sqrt(math.pi)))],\n [-(2/(math.sqrt(math.pi)))],\n [(9/(math.sqrt(math.pi)))]])\nb = np.array([\n [-(8/(math.sqrt(math.pi)))],\n [-(3/(math.sqrt(math.pi)))],\n [-(11/(math.sqrt(math.pi)))],\n [-(2/(math.sqrt(math.pi)))],\n [-(11/(math.sqrt(math.pi)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,-2,-3\\}, \\{-1,5,0\\}, \\{-1,-2,-2\\}}$.", - "Output Answer": [ - "$x+1=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, -2, -3],\n [-1, 5, 0],\n [-1, -2, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & 0 & 0 \\\\\n 0 & 1 & 2 \\\\\n -1 & 0 & 1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n -2 & 1 & 4 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, 0],\n [0, 1, 2],\n [-1, 0, 1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -9 & -1 & 5 \\\\\n 3 & 9 & 8 \\\\\n 3 & -1 & 8 \\\\\n -9 & 0 & 10 \\\\\n -1 & 1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, -1, 5],\n [3, 9, 8],\n [3, -1, 8],\n [-9, 0, 10],\n [-1, 1, 1]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 5 & 2 \\\\\n 1 & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{31}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 2],\n [1, (7/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 3 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [3],\n [3]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{4,2,3\\}, \\{0,1,-5\\}, \\{-4,0,4\\}}$.", - "Output Answer": [ - "$x-4 y+4=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, 2, 3],\n [0, 1, -5],\n [-4, 0, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 9 & -1 & -3 \\\\\n 6 & -7 & 5 \\\\\n 6 & 4 & -3 \\\\\n -3 & 4 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, -1, -3],\n [6, -7, 5],\n [6, 4, -3],\n [-3, 4, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & -6 \\\\\n -3 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-1-3 \\sqrt{3},3 \\sqrt{3}-1\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -6],\n [-3, -4]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,1,0\\}, \\{-2,-1,-1\\}, \\{-1,-2,-1\\}}$", - "Output Answer": [ - "${\\{0,1,0\\}, \\left\\{-\\frac{2}{\\sqrt{5}},0,-\\frac{1}{\\sqrt{5}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{5}},0,-\\frac{2}{\\sqrt{5}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, 1, 0), (-2, -1, -1), (-1, -2, -1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\pi \\\\\n -2 \\pi \\\\\n 2 \\pi \\\\\n \\pi \\\\\n 3 \\pi \\\\\n 0 \\\\\n -2 \\pi \\\\\n -2 \\pi \\\\\n -2 \\pi \\\\\n -\\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\pi \\\\\n -\\pi \\\\\n \\pi \\\\\n 0 \\\\\n 2 \\pi \\\\\n -\\pi \\\\\n -2 \\pi \\\\\n -\\pi \\\\\n \\pi \\\\\n -\\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{6} \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-math.pi],\n [-2*math.pi],\n [2*math.pi],\n [math.pi],\n [3*math.pi],\n [0],\n [-2*math.pi],\n [-2*math.pi],\n [-2*math.pi],\n [-math.pi]])\nb = np.array([\n [2*math.pi],\n [-math.pi],\n [math.pi],\n [0],\n [2*math.pi],\n [-math.pi],\n [-2*math.pi],\n [-math.pi],\n [math.pi],\n [-math.pi]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{19}{5} & \\frac{7}{2} \\\\\n \\frac{29}{10} & \\frac{27}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{11}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/5), (7/2)],\n [(29/10), (27/10)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $4$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -10 & -5 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -40 & -20 & -28 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -5, -7]])\nprint(a * 4)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -10 & 9 & 4 & -9 \\\\\n 3 & -7 & 1 & -9 \\\\\n -9 & -6 & 0 & 0 \\\\\n 7 & -1 & -5 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 9, 4, -9],\n [3, -7, 1, -9],\n [-9, -6, 0, 0],\n [7, -1, -5, -2]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -10 \\\\\n -8 \\\\\n 4 \\\\\n 2 \\\\\n -7 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-10],\n [-8],\n [4],\n [2],\n [-7],\n [-7]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{4}{3}, \\frac{13}{3}}$ to the line $2 x-\\frac{11 y}{3}-\\frac{4}{3}=0$.", - "Output Answer": [ - "$\\frac{179}{3 \\sqrt{157}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(4/3), (13/3)\nline = Poly(2*x-((11*y)/3)-(4/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 0 \\\\\n 2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{4}{11},\\frac{4}{11},\\frac{12}{11}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [0],\n [2]]).squeeze()\nb = np.array([\n [1],\n [1],\n [3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 1 & -1 & 2 & -\\frac{1}{2} \\\\\n 0 & -\\frac{3}{2} & \\frac{3}{2} & \\frac{1}{2} \\\\\n 1 & \\frac{3}{2} & -\\frac{3}{2} & 2 \\\\\n 1 & \\frac{5}{2} & -2 & -\\frac{3}{2} \\\\\n -\\frac{3}{2} & -2 & -2 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -2 \\\\\n -\\frac{3}{2} \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{11}{4} \\\\\n \\frac{1}{2} \\\\\n -\\frac{15}{4} \\\\\n -\\frac{13}{4} \\\\\n \\frac{19}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, 2, -(1/2)],\n [0, -(3/2), (3/2), (1/2)],\n [1, (3/2), -(3/2), 2],\n [1, (5/2), -2, -(3/2)],\n [-(3/2), -2, -2, 1]])\nb = np.array([\n [-2],\n [-2],\n [-(3/2)],\n [-(1/2)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 0 & 1 & 2 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -3 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 2, 0]])\nb = np.array([\n [1],\n [-3],\n [-1],\n [1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{7}{\\pi },-\\frac{2}{\\pi },\\frac{1}{\\pi }\\right\\}, \\left\\{-\\frac{6}{\\pi },\\frac{2}{\\pi },\\frac{3}{\\pi }\\right\\}, \\left\\{\\frac{4}{\\pi },\\frac{6}{\\pi },\\frac{6}{\\pi }\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{7}{3 \\sqrt{6}},-\\frac{\\sqrt{\\frac{2}{3}}}{3},\\frac{1}{3 \\sqrt{6}}\\right\\}, \\left\\{-\\frac{23}{3 \\sqrt{4782}},\\frac{11 \\sqrt{\\frac{2}{2391}}}{3},\\frac{205}{3 \\sqrt{4782}}\\right\\}, \\left\\{\\frac{8}{\\sqrt{797}},\\frac{27}{\\sqrt{797}},-\\frac{2}{\\sqrt{797}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((7/math.pi), -(2/math.pi), (1/math.pi)), (-(6/math.pi), (2/math.pi), (3/math.pi)), ((4/math.pi), (6/math.pi), (6/math.pi))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 3 & -9 & -6 & -1 \\\\\n 6 & 6 & -4 & 3 \\\\\n 1 & -4 & -9 & 0 \\\\\n 4 & -6 & 9 & -1 \\\\\n -4 & -6 & -1 & 3 \\\\\n -5 & -9 & -9 & 0 \\\\\n -7 & 7 & -7 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, -9, -6, -1],\n [6, 6, -4, 3],\n [1, -4, -9, 0],\n [4, -6, 9, -1],\n [-4, -6, -1, 3],\n [-5, -9, -9, 0],\n [-7, 7, -7, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{16}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{10}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{160}{49}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(16/7)]])\nb = np.array([\n [-(10/7)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & -3 & 2 \\\\\n -2 & 3 & -1 \\\\\n -2 & 3 & -2 \\\\\n 3 & 1 & 2 \\\\\n 1 & -3 & 3 \\\\\n 3 & 1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.35 \\\\\n -2.17 \\\\\n 1.12 \\\\\n 1.92 \\\\\n 1.26 \\\\\n 2.08 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.018 \\\\\n 0.423 \\\\\n 0.613 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -3, 2],\n [-2, 3, -1],\n [-2, 3, -2],\n [3, 1, 2],\n [1, -3, 3],\n [3, 1, 2]])\nb = np.array([\n [-2.35],\n [-2.17],\n [1.12],\n [1.92],\n [1.26],\n [2.08]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 4 & 10 & -1 \\\\\n -6 & -8 & 7 \\\\\n 6 & 6 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-x^2+20 x+324$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 10, -1],\n [-6, -8, 7],\n [6, 6, 3]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & 8 & 8 \\\\\n 7 & -4 & -4 \\\\\n 8 & 3 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-9.416,2.143,14.274\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 8, 8],\n [7, -4, -4],\n [8, 3, 7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{0,0,-\\sqrt{2}\\right\\}, \\left\\{-2 \\sqrt{2},-\\frac{1}{\\sqrt{2}},\\frac{3}{\\sqrt{2}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{2}},\\frac{3}{\\sqrt{2}},2 \\sqrt{2}\\right\\}}$", - "Output Answer": [ - "${\\{0,0,-1\\}, \\left\\{-\\frac{4}{\\sqrt{17}},-\\frac{1}{\\sqrt{17}},0\\right\\}, \\left\\{\\frac{\\frac{2 \\sqrt{2}}{17}-\\frac{1}{\\sqrt{2}}}{\\sqrt{\\frac{1352}{289}+\\left(\\frac{1}{\\sqrt{2}}-\\frac{2 \\sqrt{2}}{17}\\right)^2}},\\frac{26}{17} \\sqrt{\\frac{2}{\\frac{1352}{289}+\\left(\\frac{1}{\\sqrt{2}}-\\frac{2 \\sqrt{2}}{17}\\right)^2}},0\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((0, 0, -math.sqrt(2)), (-2*math.sqrt(2), -(1/(math.sqrt(2))), (3/(math.sqrt(2)))), (-(1/(math.sqrt(2))), (3/(math.sqrt(2))), 2*math.sqrt(2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{65}{9} \\\\\n -\\frac{41}{9} \\\\\n \\frac{26}{9} \\\\\n \\frac{14}{3} \\\\\n \\frac{83}{9} \\\\\n -\\frac{52}{9} \\\\\n \\frac{53}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{362}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(65/9)],\n [-(41/9)],\n [(26/9)],\n [(14/3)],\n [(83/9)],\n [-(52/9)],\n [(53/9)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{11}{4} & -\\frac{25}{4} \\\\\n \\frac{1}{2} & -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{2} i \\left(\\sqrt{14}-6 i\\right),1\\right\\}, \\left\\{-\\frac{1}{2} i \\left(\\sqrt{14}+6 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/4), -(25/4)],\n [(1/2), -(1/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{1}{2},\\frac{1}{2},\\frac{5}{2}\\right\\}, \\left\\{\\frac{5}{2},0,-1\\right\\}, \\left\\{-\\frac{5}{2},-\\frac{1}{2},0\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{3 \\sqrt{3}},\\frac{1}{3 \\sqrt{3}},\\frac{5}{3 \\sqrt{3}}\\right\\}, \\left\\{\\frac{70 \\sqrt{\\frac{2}{1137}}}{3},\\frac{5}{3 \\sqrt{2274}},-\\frac{29}{3 \\sqrt{2274}}\\right\\}, \\left\\{\\sqrt{\\frac{2}{379}},-\\frac{27}{\\sqrt{758}},\\frac{5}{\\sqrt{758}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack((((1/2), (1/2), (5/2)), ((5/2), 0, -1), (-(5/2), -(1/2), 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{5} \\\\\n 0 \\\\\n 2 \\\\\n \\frac{2}{5} \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{8}{5} \\\\\n \\frac{13}{5} \\\\\n \\frac{6}{5} \\\\\n 1 \\\\\n \\frac{8}{5} \\\\\n -\\frac{13}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{184}{2635},\\frac{299}{2635},\\frac{138}{2635},\\frac{23}{527},\\frac{184}{2635},-\\frac{299}{2635}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/5)],\n [0],\n [2],\n [(2/5)],\n [-1],\n [-1]]).squeeze()\nb = np.array([\n [(8/5)],\n [(13/5)],\n [(6/5)],\n [1],\n [(8/5)],\n [-(13/5)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -8 & -6 & -2 & 5 & -6 \\\\\n -7 & -7 & 8 & 10 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & \\frac{31}{7} & \\frac{25}{14} & \\frac{36}{7} \\\\\n 0 & 1 & -\\frac{39}{7} & -\\frac{45}{14} & -\\frac{41}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-8, -6, -2, 5, -6],\n [-7, -7, 8, 10, 5]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & -1 & -1 \\\\\n 2 & -2 & 0 \\\\\n -3 & 0 & 1 \\\\\n 3 & -1 & 1 \\\\\n -3 & 3 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.83 \\\\\n 0.85 \\\\\n 1.69 \\\\\n -1.49 \\\\\n 2.21 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.025 \\\\\n 0.757 \\\\\n 0.81 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1, -1],\n [2, -2, 0],\n [-3, 0, 1],\n [3, -1, 1],\n [-3, 3, -1]])\nb = np.array([\n [-2.83],\n [0.85],\n [1.69],\n [-1.49],\n [2.21]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -1 & \\frac{17}{2} & -\\frac{5}{2} \\\\\n -8 & -\\frac{5}{2} & -\\frac{5}{2} \\\\\n -8 & 10 & -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{11}{2} & \\frac{1}{2} & 6 \\\\\n 7 & \\frac{5}{2} & -\\frac{17}{2} \\\\\n \\frac{5}{2} & -7 & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{2} & 8 & -\\frac{17}{2} \\\\\n -15 & -5 & 6 \\\\\n -\\frac{21}{2} & 17 & -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, (17/2), -(5/2)],\n [-8, -(5/2), -(5/2)],\n [-8, 10, -(13/2)]])\nb = np.array([\n [(11/2), (1/2), 6],\n [7, (5/2), -(17/2)],\n [(5/2), -7, (3/2)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{15}{2} & \\frac{29}{8} \\\\\n \\frac{13}{4} & \\frac{1}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{61 x}{8}-\\frac{347}{32}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/2), (29/8)],\n [(13/4), (1/8)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -5 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 2 \\\\\n -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{5}{\\sqrt{18318}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-5],\n [-6]]).squeeze()\nb = np.array([\n [5],\n [2],\n [-10]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 2 & -\\frac{9}{5} \\\\\n -3 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{20}{13} & \\frac{9}{13} \\\\\n \\frac{15}{13} & \\frac{10}{13} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(9/5)],\n [-3, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{4} \\\\\n \\frac{19}{4} \\\\\n -\\frac{35}{4} \\\\\n -\\frac{1}{2} \\\\\n -2 \\\\\n -\\frac{33}{4} \\\\\n 4 \\\\\n \\frac{5}{2} \\\\\n -\\frac{11}{2} \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n \\frac{33}{4} \\\\\n -\\frac{9}{4} \\\\\n -\\frac{15}{2} \\\\\n \\frac{5}{2} \\\\\n 4 \\\\\n \\frac{33}{4} \\\\\n -\\frac{39}{4} \\\\\n -\\frac{17}{2} \\\\\n \\frac{13}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{2353}}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/4)],\n [(19/4)],\n [-(35/4)],\n [-(1/2)],\n [-2],\n [-(33/4)],\n [4],\n [(5/2)],\n [-(11/2)],\n [-5]])\nb = np.array([\n [-(3/2)],\n [(33/4)],\n [-(9/4)],\n [-(15/2)],\n [(5/2)],\n [4],\n [(33/4)],\n [-(39/4)],\n [-(17/2)],\n [(13/2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{1}{2} & -\\frac{3}{2} & 1 & 2 & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n \\frac{5}{4} & \\frac{15}{4} & -\\frac{5}{2} & -5 & \\frac{5}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2)]])\nb = np.array([\n [-(1/2), -(3/2), 1, 2, -(1/2)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n \\frac{23}{3} \\\\\n 3 \\\\\n -6 \\\\\n -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$26$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [(23/3)],\n [3],\n [-6],\n [-(7/3)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & -8 \\\\\n -7 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{7-\\sqrt{57},7+\\sqrt{57}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -8],\n [-7, 8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{27}{e} \\\\\n -\\frac{15}{e} \\\\\n -\\frac{14}{e} \\\\\n -\\frac{4}{e} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{20}{e} \\\\\n -\\frac{7}{e} \\\\\n \\frac{1}{e} \\\\\n -\\frac{22}{e} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{2822}}{e}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(27/math.e)],\n [-(15/math.e)],\n [-(14/math.e)],\n [-(4/math.e)]])\nb = np.array([\n [-(20/math.e)],\n [-(7/math.e)],\n [(1/math.e)],\n [-(22/math.e)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{18}{7} \\\\\n \\frac{18}{7} \\\\\n \\frac{6}{7} \\\\\n \\frac{20}{7} \\\\\n \\frac{1}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{18}{\\sqrt{1085}} \\\\\n \\frac{18}{\\sqrt{1085}} \\\\\n \\frac{6}{\\sqrt{1085}} \\\\\n 4 \\sqrt{\\frac{5}{217}} \\\\\n \\frac{1}{\\sqrt{1085}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(18/7)],\n [(18/7)],\n [(6/7)],\n [(20/7)],\n [(1/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,2,0\\}, \\{-1,1,-1\\}, \\{-1,-3,2\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{2}},\\frac{1}{\\sqrt{2}},0\\right\\}, \\left\\{-\\frac{1}{\\sqrt{3}},\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{6}},\\frac{1}{\\sqrt{6}},\\sqrt{\\frac{2}{3}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, 2, 0), (-1, 1, -1), (-1, -3, 2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{2}{3}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 10 & 9 & 2 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{20}{3} & -6 & -\\frac{4}{3} & \\frac{16}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 9, 2, -8]])\nprint(a * -(2/3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -\\frac{11}{4} \\\\\n -\\frac{19}{4} \\\\\n -\\frac{3}{4} \\\\\n -\\frac{35}{4} \\\\\n -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{33}{4} \\\\\n 1 \\\\\n -1 \\\\\n -\\frac{7}{4} \\\\\n -10 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{2341}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-(11/4)],\n [-(19/4)],\n [-(3/4)],\n [-(35/4)],\n [-(15/2)]])\nb = np.array([\n [-(33/4)],\n [1],\n [-1],\n [-(7/4)],\n [-10],\n [-3]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -1 & -1 & -2 & -1 & 0 \\\\\n -2 & 0 & -3 & -1 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 1 & -1 & 3 & 1 \\\\\n 1 & 3 & 1 & -1 \\\\\n 0 & -2 & -2 & 0 \\\\\n -1 & 2 & -1 & 0 \\\\\n -1 & -3 & -2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -1 & 0 & 1 & 0 \\\\\n 0 & 9 & 3 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, -2, -1, 0],\n [-2, 0, -3, -1, -1]])\nb = np.array([\n [1, -1, 3, 1],\n [1, 3, 1, -1],\n [0, -2, -2, 0],\n [-1, 2, -1, 0],\n [-1, -3, -2, 0]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 1 & -1 \\\\\n -1 & 0 & 0 \\\\\n -2 & 0 & 2 \\\\\n 3 & 0 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.51 \\\\\n 1.15 \\\\\n 2.38 \\\\\n -0.07 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.153 \\\\\n 2.69 \\\\\n 1.18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, -1],\n [-1, 0, 0],\n [-2, 0, 2],\n [3, 0, -1]])\nb = np.array([\n [1.51],\n [1.15],\n [2.38],\n [-0.07]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -9 & 6 & 4 \\\\\n 3 & -4 & -5 \\\\\n -4 & 3 & -5 \\\\\n -7 & -5 & -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 4 & -5 & 2 \\\\\n -8 & -9 & 9 \\\\\n 3 & 4 & -9 \\\\\n 0 & 8 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -5 & 1 & 6 \\\\\n -5 & -13 & 4 \\\\\n -1 & 7 & -14 \\\\\n -7 & 3 & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 6, 4],\n [3, -4, -5],\n [-4, 3, -5],\n [-7, -5, -5]])\nb = np.array([\n [4, -5, 2],\n [-8, -9, 9],\n [3, 4, -9],\n [0, 8, -1]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & -7 & -3 \\\\\n 7 & -6 & 9 \\\\\n -4 & -8 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-3.409-10.464 i,-3.409+10.464 i,8.818\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -7, -3],\n [7, -6, 9],\n [-4, -8, 0]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{12}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{8}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4]])\nb = np.array([\n [-(12/5)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [1],\n [1],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [0],\n [0],\n [-1],\n [1],\n [0],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n 7 & 4 & -3 & 1 \\\\\n 2 & -6 & -6 & 9 \\\\\n -9 & 3 & -8 & 9 \\\\\n -5 & 6 & -4 & -6 \\\\\n 6 & -3 & 0 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 4, -3, 1],\n [2, -6, -6, 9],\n [-9, 3, -8, 9],\n [-5, 6, -4, -6],\n [6, -3, 0, 8]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{2} \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-30$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/2)],\n [-5]])\nb = np.array([\n [0],\n [6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 10 & \\frac{25}{3} & -\\frac{20}{3} & -\\frac{23}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -4 & \\frac{1}{3} & \\frac{1}{3} & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 14 & 8 & -7 & -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, (25/3), -(20/3), -(23/3)]])\nb = np.array([\n [-4, (1/3), (1/3), -3]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{10}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & 5 & -8 \\\\\n -5 & -5 & 6 \\\\\n 10 & 1 & -6 \\\\\n 4 & -9 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{10} & \\frac{1}{2} & -\\frac{4}{5} \\\\\n -\\frac{1}{2} & -\\frac{1}{2} & \\frac{3}{5} \\\\\n 1 & \\frac{1}{10} & -\\frac{3}{5} \\\\\n \\frac{2}{5} & -\\frac{9}{10} & \\frac{1}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 5, -8],\n [-5, -5, 6],\n [10, 1, -6],\n [4, -9, 1]])\nprint(a * (1/10))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 10 & -\\frac{1}{2} \\\\\n -\\frac{9}{2} & -\\frac{19}{2} \\\\\n \\frac{15}{2} & \\frac{15}{2} \\\\\n 2 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{2} & \\frac{3}{2} \\\\\n -2 & \\frac{11}{2} \\\\\n 9 & -3 \\\\\n -8 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{11}{2} & -2 \\\\\n -\\frac{5}{2} & -15 \\\\\n -\\frac{3}{2} & \\frac{21}{2} \\\\\n 10 & -\\frac{21}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -(1/2)],\n [-(9/2), -(19/2)],\n [(15/2), (15/2)],\n [2, -(3/2)]])\nb = np.array([\n [(9/2), (3/2)],\n [-2, (11/2)],\n [9, -3],\n [-8, 9]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 2 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 8 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -70 \\\\\n 100 \\\\\n -90 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [2],\n [10]])\nb = np.array([\n [5],\n [8],\n [5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -3 & -\\frac{5}{2} & \\frac{3}{2} \\\\\n -\\frac{5}{2} & 0 & \\frac{5}{2} \\\\\n 0 & 0 & \\frac{1}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{61}{4} & \\frac{15}{2} & -10 \\\\\n \\frac{15}{2} & \\frac{25}{4} & -\\frac{5}{2} \\\\\n 0 & 0 & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -(5/2), (3/2)],\n [-(5/2), 0, (5/2)],\n [0, 0, (1/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{5} \\\\\n \\frac{27}{5} \\\\\n -\\frac{19}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/5)],\n [(27/5)],\n [-(19/5)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -5 & 10 & 1 & -8 \\\\\n 6 & 8 & 8 & 0 \\\\\n 4 & 3 & 0 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-384.,-56.,344.,213.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, 10, 1, -8],\n [6, 8, 8, 0],\n [4, 3, 0, 8]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{14}{5}, 4, \\frac{8}{5}}$ to the plane $-\\frac{13 x}{5}+\\frac{y}{5}-\\frac{22 z}{5}-\\frac{1}{5}=0$.", - "Output Answer": [ - "$\\frac{7 \\sqrt{\\frac{3}{218}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(14/5), 4, (8/5)\nplane = Poly(-((13*x)/5)+(y/5)-((22*z)/5)-(1/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{8}{7} \\\\\n -\\frac{2}{7} \\\\\n \\frac{29}{7} \\\\\n \\frac{5}{7} \\\\\n \\frac{37}{7} \\\\\n \\frac{2}{7} \\\\\n \\frac{30}{7} \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{37}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(8/7)],\n [-(2/7)],\n [(29/7)],\n [(5/7)],\n [(37/7)],\n [(2/7)],\n [(30/7)],\n [2]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -2 & 0 & -4 & -10 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-5.,0.,0.,1.,0.\\}, \\{-2.,0.,1.,0.,0.\\}, \\{0.,0.,0.,0.,1.\\}, \\{0.,1.,0.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, 0, -4, -10, 0]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{2} \\\\\n \\frac{11}{4} \\\\\n -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{23}{4} \\\\\n -6 \\\\\n -\\frac{17}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{211}{16} \\\\\n -\\frac{419}{16} \\\\\n \\frac{877}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/2)],\n [(11/4)],\n [-(1/4)]])\nb = np.array([\n [-(23/4)],\n [-6],\n [-(17/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -9 & 10 & -2 & 3 & -7 \\\\\n -8 & 0 & -9 & -2 & -2 \\\\\n 7 & -1 & -2 & -1 & -9 \\\\\n -3 & -3 & 8 & 2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & -\\frac{1131}{677} \\\\\n 0 & 1 & 0 & 0 & \\frac{3430}{677} \\\\\n 0 & 0 & 1 & 0 & \\frac{4182}{677} \\\\\n 0 & 0 & 0 & 1 & -\\frac{13618}{677} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-9, 10, -2, 3, -7],\n [-8, 0, -9, -2, -2],\n [7, -1, -2, -1, -9],\n [-3, -3, 8, 2, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -1 & -2 \\\\\n 4 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & \\frac{1}{2} \\\\\n -1 & -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2],\n [4, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{11}{5} & 8 \\\\\n -\\frac{48}{5} & \\frac{22}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(11-13 i \\sqrt{39}\\right),\\frac{1}{10} \\left(11+13 i \\sqrt{39}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/5), 8],\n [-(48/5), (22/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 4 & 8 & 10 & 9 & -6 & -5 & -9 \\\\\n -9 & -7 & -2 & 10 & -5 & -1 & 4 \\\\\n 5 & -7 & 3 & 9 & -2 & 8 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & -\\frac{769}{976} & \\frac{143}{244} & \\frac{701}{976} & -\\frac{331}{976} \\\\\n 0 & 1 & 0 & -\\frac{965}{976} & \\frac{63}{244} & -\\frac{703}{976} & \\frac{105}{976} \\\\\n 0 & 0 & 1 & \\frac{979}{488} & -\\frac{127}{122} & -\\frac{103}{488} & -\\frac{415}{488} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, 8, 10, 9, -6, -5, -9],\n [-9, -7, -2, 10, -5, -1, 4],\n [5, -7, 3, 9, -2, 8, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{2} \\\\\n -\\frac{39}{4} \\\\\n \\frac{3}{4} \\\\\n -\\frac{7}{4} \\\\\n \\frac{15}{4} \\\\\n \\frac{37}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{23}{4} \\\\\n \\frac{19}{4} \\\\\n -\\frac{17}{2} \\\\\n -\\frac{15}{4} \\\\\n \\frac{31}{4} \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1759}{4 \\sqrt{916062}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2)],\n [-(39/4)],\n [(3/4)],\n [-(7/4)],\n [(15/4)],\n [(37/4)]]).squeeze()\nb = np.array([\n [-(23/4)],\n [(19/4)],\n [-(17/2)],\n [-(15/4)],\n [(31/4)],\n [-6]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{137}{16} \\\\\n -\\frac{81}{16} \\\\\n -\\frac{105}{16} \\\\\n \\frac{129}{16} \\\\\n \\frac{133}{16} \\\\\n \\frac{55}{8} \\\\\n -\\frac{51}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{137}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(137/16)],\n [-(81/16)],\n [-(105/16)],\n [(129/16)],\n [(133/16)],\n [(55/8)],\n [-(51/16)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,3,1\\}, \\{5,-5,2\\}, \\{-3,1,-3\\}}$.", - "Output Answer": [ - "$17 x+6 y-20 z-15=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, 3, 1],\n [5, -5, 2],\n [-3, 1, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -1 & \\frac{1}{3} & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{7}{3} & \\frac{5}{6} & -\\frac{17}{6} & \\frac{11}{6} \\\\\n -\\frac{7}{3} & -\\frac{5}{6} & -\\frac{3}{2} & 0 \\\\\n 3 & \\frac{1}{6} & -\\frac{11}{6} & -\\frac{11}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{41}{9} & -\\frac{17}{18} & \\frac{1}{2} & -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, (1/3), 1]])\nb = np.array([\n [-(7/3), (5/6), -(17/6), (11/6)],\n [-(7/3), -(5/6), -(3/2), 0],\n [3, (1/6), -(11/6), -(11/6)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 4 \\\\\n -8 \\\\\n -4 \\\\\n 2 \\\\\n -1 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 \\\\\n 7 \\\\\n 9 \\\\\n -2 \\\\\n 7 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-82$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [4],\n [-8],\n [-4],\n [2],\n [-1],\n [-9]])\nb = np.array([\n [0],\n [3],\n [7],\n [9],\n [-2],\n [7],\n [-1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 5 & -4 & -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 2 & -5 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 7 & -9 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -4, -8]])\nb = np.array([\n [2, -5, 4]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{8}{9}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 8 \\\\\n \\frac{80}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [10]])\nprint(a * (8/9))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,0,2\\}, \\{-5,4,4\\}, \\{0,4,-1\\}}$.", - "Output Answer": [ - "$x+z+1=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, 0, 2],\n [-5, 4, 4],\n [0, 4, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -5 & -9 \\\\\n -5 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{10} \\left(11-\\sqrt{301}\\right),1\\right\\}, \\left\\{\\frac{1}{10} \\left(11+\\sqrt{301}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -9],\n [-5, 6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,-1,-2\\}, \\{0,-3,1\\}, \\{2,0,-3\\}}$.", - "Output Answer": [ - "$x-2 (7 y+5 z+16)=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, -1, -2],\n [0, -3, 1],\n [2, 0, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -2 & -9 & 3 & 2 \\\\\n -7 & 2 & 0 & 3 \\\\\n -2 & 5 & -1 & 4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -8 & 7 & -8 & -1 \\\\\n -1 & -6 & -3 & 5 \\\\\n -3 & 1 & 6 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 6 & -16 & 11 & 3 \\\\\n -6 & 8 & 3 & -2 \\\\\n 1 & 4 & -7 & 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -9, 3, 2],\n [-7, 2, 0, 3],\n [-2, 5, -1, 4]])\nb = np.array([\n [-8, 7, -8, -1],\n [-1, -6, -3, 5],\n [-3, 1, 6, -6]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -10 & 2 & -6 \\\\\n 3 & 6 & 0 \\\\\n 7 & -4 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.785,-3.54,1.\\}, \\{-0.522-0.704 i,0.169\\, +0.098 i,1.\\}, \\{-0.522+0.704 i,0.169\\, -0.098 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 2, -6],\n [3, 6, 0],\n [7, -4, -2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{66}{7} \\\\\n \\frac{4}{7} \\\\\n \\frac{64}{7} \\\\\n -\\frac{3}{7} \\\\\n \\frac{66}{7} \\\\\n \\frac{20}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{13233}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(66/7)],\n [(4/7)],\n [(64/7)],\n [-(3/7)],\n [(66/7)],\n [(20/7)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{5}{3}, -\\frac{10}{3}, -\\frac{4}{3}}$ to the plane $-\\frac{10 x}{3}-2 y+\\frac{13 z}{3}+\\frac{11}{3}=0$.", - "Output Answer": [ - "$\\frac{91}{3 \\sqrt{305}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(5/3), -(10/3), -(4/3)\nplane = Poly(-((10*x)/3)-2*y+((13*z)/3)+(11/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{11}{4} & -\\frac{19}{4} & \\frac{11}{4} & -\\frac{13}{8} \\\\\n -7 & -\\frac{77}{8} & -\\frac{7}{4} & -\\frac{27}{8} \\\\\n \\frac{71}{8} & -2 & -\\frac{27}{4} & -\\frac{39}{4} \\\\\n -\\frac{31}{4} & -\\frac{73}{8} & \\frac{33}{4} & -\\frac{5}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 2 & -\\frac{15}{8} & \\frac{63}{8} & -\\frac{33}{8} \\\\\n 4 & \\frac{11}{4} & \\frac{5}{4} & -\\frac{23}{4} \\\\\n -1 & -\\frac{17}{8} & 2 & \\frac{1}{2} \\\\\n \\frac{33}{8} & \\frac{35}{8} & -\\frac{19}{8} & -\\frac{35}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{3}{4} & -\\frac{23}{8} & -\\frac{41}{8} & \\frac{5}{2} \\\\\n -11 & -\\frac{99}{8} & -3 & \\frac{19}{8} \\\\\n \\frac{79}{8} & \\frac{1}{8} & -\\frac{35}{4} & -\\frac{41}{4} \\\\\n -\\frac{95}{8} & -\\frac{27}{2} & \\frac{85}{8} & \\frac{15}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/4), -(19/4), (11/4), -(13/8)],\n [-7, -(77/8), -(7/4), -(27/8)],\n [(71/8), -2, -(27/4), -(39/4)],\n [-(31/4), -(73/8), (33/4), -(5/4)]])\nb = np.array([\n [2, -(15/8), (63/8), -(33/8)],\n [4, (11/4), (5/4), -(23/4)],\n [-1, -(17/8), 2, (1/2)],\n [(33/8), (35/8), -(19/8), -(35/4)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n 44 & -50 & -9 & -4 \\\\\n 35 & -40 & -7 & -3 \\\\\n 9 & -9 & -3 & -2 \\\\\n 12 & -13 & -2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{457}{6} & -\\frac{260}{3} & -15 & -\\frac{37}{6} \\\\\n \\frac{349}{6} & -\\frac{397}{6} & -\\frac{23}{2} & -\\frac{14}{3} \\\\\n \\frac{56}{3} & -\\frac{127}{6} & -\\frac{7}{2} & -\\frac{13}{6} \\\\\n \\frac{83}{2} & -47 & -8 & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [44, -50, -9, -4],\n [35, -40, -7, -3],\n [9, -9, -3, -2],\n [12, -13, -2, -1]])\nprint(expm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{2 \\sqrt{2},-\\frac{1}{\\sqrt{2}},-\\sqrt{2}\\right\\}, \\left\\{\\frac{1}{\\sqrt{2}},-2 \\sqrt{2},-\\frac{1}{\\sqrt{2}}\\right\\}, \\left\\{\\frac{3}{\\sqrt{2}},\\frac{3}{\\sqrt{2}},-\\sqrt{2}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{4}{\\sqrt{21}},-\\frac{1}{\\sqrt{21}},-\\frac{2}{\\sqrt{21}}\\right\\}, \\left\\{\\frac{\\frac{1}{\\sqrt{2}}-\\frac{20 \\sqrt{2}}{21}}{\\sqrt{\\frac{2738}{441}+\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{21}\\right)^2+\\left(\\frac{20 \\sqrt{2}}{21}-\\frac{1}{\\sqrt{2}}\\right)^2}},-\\frac{37}{21} \\sqrt{\\frac{2}{\\frac{2738}{441}+\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{21}\\right)^2+\\left(\\frac{20 \\sqrt{2}}{21}-\\frac{1}{\\sqrt{2}}\\right)^2}},\\frac{\\frac{10 \\sqrt{2}}{21}-\\frac{1}{\\sqrt{2}}}{\\sqrt{\\frac{2738}{441}+\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{21}\\right)^2+\\left(\\frac{20 \\sqrt{2}}{21}-\\frac{1}{\\sqrt{2}}\\right)^2}}\\right\\}, \\left\\{\\frac{\\frac{3}{\\sqrt{2}}-\\frac{26 \\sqrt{2}}{21}-\\frac{\\left(\\frac{1}{\\sqrt{2}}-\\frac{20 \\sqrt{2}}{21}\\right) \\left(-\\frac{37}{7}+\\frac{3 \\left(\\frac{1}{\\sqrt{2}}-\\frac{20 \\sqrt{2}}{21}\\right)}{\\sqrt{2}}-\\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\frac{10 \\sqrt{2}}{21}\\right)\\right)}{\\frac{2738}{441}+\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{21}\\right)^2+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{20 \\sqrt{2}}{21}\\right)^2}}{\\sqrt{\\left(\\frac{38 \\sqrt{2}}{21}+\\frac{37 \\sqrt{2} \\left(-\\frac{37}{7}+\\frac{3 \\left(\\frac{1}{\\sqrt{2}}-\\frac{20 \\sqrt{2}}{21}\\right)}{\\sqrt{2}}-\\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\frac{10 \\sqrt{2}}{21}\\right)\\right)}{21 \\left(\\frac{2738}{441}+\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{21}\\right)^2+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{20 \\sqrt{2}}{21}\\right)^2\\right)}\\right)^2+\\left(\\frac{8 \\sqrt{2}}{21}-\\frac{\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{21}\\right) \\left(-\\frac{37}{7}+\\frac{3 \\left(\\frac{1}{\\sqrt{2}}-\\frac{20 \\sqrt{2}}{21}\\right)}{\\sqrt{2}}-\\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\frac{10 \\sqrt{2}}{21}\\right)\\right)}{\\frac{2738}{441}+\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{21}\\right)^2+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{20 \\sqrt{2}}{21}\\right)^2}\\right)^2+\\left(-\\frac{3}{\\sqrt{2}}+\\frac{26 \\sqrt{2}}{21}-\\frac{\\left(-\\frac{1}{\\sqrt{2}}+\\frac{20 \\sqrt{2}}{21}\\right) \\left(-\\frac{37}{7}+\\frac{3 \\left(\\frac{1}{\\sqrt{2}}-\\frac{20 \\sqrt{2}}{21}\\right)}{\\sqrt{2}}-\\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\frac{10 \\sqrt{2}}{21}\\right)\\right)}{\\frac{2738}{441}+\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{21}\\right)^2+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{20 \\sqrt{2}}{21}\\right)^2}\\right)^2}},\\frac{\\frac{38 \\sqrt{2}}{21}+\\frac{37 \\sqrt{2} \\left(-\\frac{37}{7}+\\frac{3 \\left(\\frac{1}{\\sqrt{2}}-\\frac{20 \\sqrt{2}}{21}\\right)}{\\sqrt{2}}-\\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\frac{10 \\sqrt{2}}{21}\\right)\\right)}{21 \\left(\\frac{2738}{441}+\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{21}\\right)^2+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{20 \\sqrt{2}}{21}\\right)^2\\right)}}{\\sqrt{\\left(\\frac{38 \\sqrt{2}}{21}+\\frac{37 \\sqrt{2} \\left(-\\frac{37}{7}+\\frac{3 \\left(\\frac{1}{\\sqrt{2}}-\\frac{20 \\sqrt{2}}{21}\\right)}{\\sqrt{2}}-\\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\frac{10 \\sqrt{2}}{21}\\right)\\right)}{21 \\left(\\frac{2738}{441}+\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{21}\\right)^2+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{20 \\sqrt{2}}{21}\\right)^2\\right)}\\right)^2+\\left(\\frac{8 \\sqrt{2}}{21}-\\frac{\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{21}\\right) \\left(-\\frac{37}{7}+\\frac{3 \\left(\\frac{1}{\\sqrt{2}}-\\frac{20 \\sqrt{2}}{21}\\right)}{\\sqrt{2}}-\\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\frac{10 \\sqrt{2}}{21}\\right)\\right)}{\\frac{2738}{441}+\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{21}\\right)^2+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{20 \\sqrt{2}}{21}\\right)^2}\\right)^2+\\left(-\\frac{3}{\\sqrt{2}}+\\frac{26 \\sqrt{2}}{21}-\\frac{\\left(-\\frac{1}{\\sqrt{2}}+\\frac{20 \\sqrt{2}}{21}\\right) \\left(-\\frac{37}{7}+\\frac{3 \\left(\\frac{1}{\\sqrt{2}}-\\frac{20 \\sqrt{2}}{21}\\right)}{\\sqrt{2}}-\\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\frac{10 \\sqrt{2}}{21}\\right)\\right)}{\\frac{2738}{441}+\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{21}\\right)^2+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{20 \\sqrt{2}}{21}\\right)^2}\\right)^2}},\\frac{-\\frac{8 \\sqrt{2}}{21}-\\frac{\\left(-\\frac{1}{\\sqrt{2}}+\\frac{10 \\sqrt{2}}{21}\\right) \\left(-\\frac{37}{7}+\\frac{3 \\left(\\frac{1}{\\sqrt{2}}-\\frac{20 \\sqrt{2}}{21}\\right)}{\\sqrt{2}}-\\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\frac{10 \\sqrt{2}}{21}\\right)\\right)}{\\frac{2738}{441}+\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{21}\\right)^2+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{20 \\sqrt{2}}{21}\\right)^2}}{\\sqrt{\\left(\\frac{38 \\sqrt{2}}{21}+\\frac{37 \\sqrt{2} \\left(-\\frac{37}{7}+\\frac{3 \\left(\\frac{1}{\\sqrt{2}}-\\frac{20 \\sqrt{2}}{21}\\right)}{\\sqrt{2}}-\\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\frac{10 \\sqrt{2}}{21}\\right)\\right)}{21 \\left(\\frac{2738}{441}+\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{21}\\right)^2+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{20 \\sqrt{2}}{21}\\right)^2\\right)}\\right)^2+\\left(\\frac{8 \\sqrt{2}}{21}-\\frac{\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{21}\\right) \\left(-\\frac{37}{7}+\\frac{3 \\left(\\frac{1}{\\sqrt{2}}-\\frac{20 \\sqrt{2}}{21}\\right)}{\\sqrt{2}}-\\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\frac{10 \\sqrt{2}}{21}\\right)\\right)}{\\frac{2738}{441}+\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{21}\\right)^2+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{20 \\sqrt{2}}{21}\\right)^2}\\right)^2+\\left(-\\frac{3}{\\sqrt{2}}+\\frac{26 \\sqrt{2}}{21}-\\frac{\\left(-\\frac{1}{\\sqrt{2}}+\\frac{20 \\sqrt{2}}{21}\\right) \\left(-\\frac{37}{7}+\\frac{3 \\left(\\frac{1}{\\sqrt{2}}-\\frac{20 \\sqrt{2}}{21}\\right)}{\\sqrt{2}}-\\sqrt{2} \\left(-\\frac{1}{\\sqrt{2}}+\\frac{10 \\sqrt{2}}{21}\\right)\\right)}{\\frac{2738}{441}+\\left(\\frac{1}{\\sqrt{2}}-\\frac{10 \\sqrt{2}}{21}\\right)^2+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{20 \\sqrt{2}}{21}\\right)^2}\\right)^2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((2*math.sqrt(2), -(1/(math.sqrt(2))), -math.sqrt(2)), ((1/(math.sqrt(2))), -2*math.sqrt(2), -(1/(math.sqrt(2)))), ((3/(math.sqrt(2))), (3/(math.sqrt(2))), -math.sqrt(2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,0,1\\}, \\{3,-4,5\\}, \\{3,3,5\\}}$.", - "Output Answer": [ - "$x-3=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, 0, 1],\n [3, -4, 5],\n [3, 3, 5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & 2 & -3 & 0 \\\\\n -1 & -3 & 0 & 1 \\\\\n -2 & -3 & 1 & 2 \\\\\n 0 & 2 & 0 & 1 \\\\\n 1 & -2 & -3 & 3 \\\\\n -2 & 3 & -1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.44 \\\\\n -1.85 \\\\\n -2.28 \\\\\n -1.71 \\\\\n -2.79 \\\\\n 2.17 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.189 \\\\\n 0.036 \\\\\n 0.03 \\\\\n -1.119 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2, -3, 0],\n [-1, -3, 0, 1],\n [-2, -3, 1, 2],\n [0, 2, 0, 1],\n [1, -2, -3, 3],\n [-2, 3, -1, -1]])\nb = np.array([\n [-1.44],\n [-1.85],\n [-2.28],\n [-1.71],\n [-2.79],\n [2.17]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{6}{7}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -9 & 7 \\\\\n 0 & -3 \\\\\n 9 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{54}{7} & -6 \\\\\n 0 & \\frac{18}{7} \\\\\n -\\frac{54}{7} & -\\frac{54}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 7],\n [0, -3],\n [9, 9]])\nprint(a * -(6/7))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n \\frac{14}{5} \\\\\n -\\frac{9}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{15}{\\sqrt{502}} \\\\\n 7 \\sqrt{\\frac{2}{251}} \\\\\n -\\frac{9}{\\sqrt{502}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [(14/5)],\n [-(9/5)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-8]])\nb = np.array([\n [-1],\n [-6]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{43}{5} & \\frac{6}{5} & -\\frac{16}{5} \\\\\n \\frac{22}{5} & \\frac{3}{5} & 10 \\\\\n \\frac{2}{5} & \\frac{37}{5} & -\\frac{7}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{39 x^2}{5}+\\frac{2143 x}{25}-\\frac{91857}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(43/5), (6/5), -(16/5)],\n [(22/5), (3/5), 10],\n [(2/5), (37/5), -(7/5)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{77}{16} \\\\\n \\frac{123}{16} \\\\\n -\\frac{79}{16} \\\\\n \\frac{35}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{157}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(77/16)],\n [(123/16)],\n [-(79/16)],\n [(35/16)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 0 & 2 & 3 & 2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 0 & 6 & 9 & 6 & 3 \\\\\n 0 & 2 & 3 & 2 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 2 & 3 & 2 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [1],\n [0],\n [1]])\nb = np.array([\n [0, 2, 3, 2, 1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{10} & -\\frac{2}{5} \\\\\n \\frac{29}{10} & \\frac{6}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{32}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/10), -(2/5)],\n [(29/10), (6/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{25}{4} & \\frac{17}{2} \\\\\n \\frac{19}{4} & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{8} \\left(-5-\\sqrt{4609}\\right),\\frac{1}{8} \\left(\\sqrt{4609}-5\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/4), (17/2)],\n [(19/4), 5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n -2 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n 0 \\\\\n 0 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{0,0,0,0,0\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [-2],\n [2],\n [1]]).squeeze()\nb = np.array([\n [1],\n [2],\n [0],\n [0],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,2,3\\}, \\{-3,-4,-3\\}, \\{4,-2,3\\}}$.", - "Output Answer": [ - "$6 x+9 y-10 z+24=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, 2, 3],\n [-3, -4, -3],\n [4, -2, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n \\frac{933}{100} & \\frac{13}{4} & \\frac{31}{5} \\\\\n -\\frac{25}{4} & \\frac{17}{25} & -\\frac{166}{25} \\\\\n -\\frac{289}{100} & \\frac{131}{50} & -\\frac{223}{100} \\\\\n -\\frac{913}{100} & \\frac{89}{10} & \\frac{649}{100} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{109}{25} & -\\frac{109}{100} & -\\frac{401}{100} \\\\\n -\\frac{291}{100} & \\frac{39}{10} & \\frac{841}{100} \\\\\n -\\frac{111}{20} & \\frac{399}{50} & -\\frac{603}{100} \\\\\n -\\frac{309}{100} & \\frac{19}{20} & \\frac{397}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{497}{100} & \\frac{54}{25} & \\frac{219}{100} \\\\\n -\\frac{229}{25} & \\frac{229}{50} & \\frac{177}{100} \\\\\n -\\frac{211}{25} & \\frac{53}{5} & -\\frac{413}{50} \\\\\n -\\frac{611}{50} & \\frac{197}{20} & \\frac{1443}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(933/100), (13/4), (31/5)],\n [-(25/4), (17/25), -(166/25)],\n [-(289/100), (131/50), -(223/100)],\n [-(913/100), (89/10), (649/100)]])\nb = np.array([\n [-(109/25), -(109/100), -(401/100)],\n [-(291/100), (39/10), (841/100)],\n [-(111/20), (399/50), -(603/100)],\n [-(309/100), (19/20), (397/50)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${2, 0, 1}$ to the plane $-3 x+2 y+2 z+4=0$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 2, 0, 1\nplane = Poly(-3*x+2*y+2*z+4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 8 & -8 & 3 \\\\\n 10 & 4 & -5 \\\\\n -6 & 1 & -7 \\\\\n 6 & 5 & -2 \\\\\n 7 & 2 & 10 \\\\\n -7 & -5 & -8 \\\\\n -6 & 7 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, -8, 3],\n [10, 4, -5],\n [-6, 1, -7],\n [6, 5, -2],\n [7, 2, 10],\n [-7, -5, -8],\n [-6, 7, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -4 \\\\\n -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-9]])\nb = np.array([\n [4],\n [6]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 3 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -6 \\\\\n -49 \\\\\n 21 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [3],\n [7]])\nb = np.array([\n [-7],\n [3],\n [5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 5 i & -4+4 i & -4+3 i \\\\\n -1+2 i & 3 i & i \\\\\n -2-3 i & -i & 2-3 i \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 133-24 i & 150-93 i & 40+i \\\\\n 63-53 i & 119-46 i & 63-23 i \\\\\n -23+31 i & 8+99 i & 17+17 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5j, -4+4j, -4+3j],\n [-1+2j, 3j,1j],\n [-2-3j, - 1j, 2-3j]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n \\frac{5}{2} \\\\\n -\\frac{1}{2} \\\\\n 1 \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2}{\\sqrt{35}} \\\\\n \\sqrt{\\frac{5}{7}} \\\\\n -\\frac{1}{\\sqrt{35}} \\\\\n \\frac{2}{\\sqrt{35}} \\\\\n -\\frac{1}{\\sqrt{35}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [(5/2)],\n [-(1/2)],\n [1],\n [-(1/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -6 & -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -9 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -15 & -14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -9]])\nb = np.array([\n [-9, -5]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, -\\frac{10}{3}, -\\frac{8}{3}}$ to the plane $-2 x-4 y-\\frac{5 z}{3}-\\frac{2}{3}=0$.", - "Output Answer": [ - "$\\frac{38 \\sqrt{\\frac{5}{41}}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, -(10/3), -(8/3)\nplane = Poly(-2*x-4*y-((5*z)/3)-(2/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{1}{8} & -\\frac{15}{8} & \\frac{13}{8} & 2 & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{4} & -\\frac{1}{2} \\\\\n \\frac{11}{8} & \\frac{15}{8} \\\\\n -\\frac{1}{4} & \\frac{3}{2} \\\\\n -\\frac{9}{4} & -\\frac{3}{8} \\\\\n -2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{145}{64} & -\\frac{121}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/8), -(15/8), (13/8), 2, -(5/2)]])\nb = np.array([\n [(7/4), -(1/2)],\n [(11/8), (15/8)],\n [-(1/4), (3/2)],\n [-(9/4), -(3/8)],\n [-2, 0]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & \\frac{1}{2} \\\\\n \\frac{3}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & \\frac{3}{2} \\\\\n \\frac{9}{2} & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), (1/2)],\n [(3/2), (5/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 8 \\\\\n 6 \\\\\n 8 \\\\\n 0 \\\\\n -1 \\\\\n -6 \\\\\n 6 \\\\\n 7 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -2 \\\\\n 3 \\\\\n 4 \\\\\n -9 \\\\\n 4 \\\\\n 0 \\\\\n -4 \\\\\n -5 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{129}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [8],\n [6],\n [8],\n [0],\n [-1],\n [-6],\n [6],\n [7],\n [1]])\nb = np.array([\n [6],\n [-2],\n [3],\n [4],\n [-9],\n [4],\n [0],\n [-4],\n [-5],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{34}{7}, -\\frac{27}{7}}$ to the line $\\frac{4 x}{7}-\\frac{34 y}{7}+\\frac{13}{7}=0$.", - "Output Answer": [ - "$\\frac{873}{14 \\sqrt{293}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(34/7), -(27/7)\nline = Poly(((4*x)/7)-((34*y)/7)+(13/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 4 \\\\\n -\\frac{1}{2} \\\\\n 4 \\\\\n -\\frac{19}{2} \\\\\n 5 \\\\\n -\\frac{15}{2} \\\\\n -4 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -\\frac{15}{2} \\\\\n -\\frac{11}{2} \\\\\n \\frac{1}{2} \\\\\n \\frac{19}{2} \\\\\n -3 \\\\\n 3 \\\\\n \\frac{19}{2} \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4 \\sqrt{57}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [4],\n [-(1/2)],\n [4],\n [-(19/2)],\n [5],\n [-(15/2)],\n [-4],\n [2]])\nb = np.array([\n [3],\n [-(15/2)],\n [-(11/2)],\n [(1/2)],\n [(19/2)],\n [-3],\n [3],\n [(19/2)],\n [7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 0 \\\\\n -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 16 \\\\\n 72 \\\\\n -18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-2],\n [0]])\nb = np.array([\n [-9],\n [0],\n [-8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 3 & 1 \\\\\n 5 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 2 & -1 \\\\\n -5 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1],\n [5, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{8}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & 0 & 2 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{21}{8} & 0 & -\\frac{7}{4} & \\frac{21}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, 2, -6]])\nprint(a * -(7/8))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{8} \\\\\n \\frac{15}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{19}{\\sqrt{586}} \\\\\n \\frac{15}{\\sqrt{586}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/8)],\n [(15/8)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & -5 & 6 \\\\\n -2 & 7 & 5 \\\\\n 2 & 5 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-16.131,9.998,1.\\}, \\{-0.44,-0.353,1.\\}, \\{2.571,1.756,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -5, 6],\n [-2, 7, 5],\n [2, 5, -7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{11}{3},\\frac{8}{3},-\\frac{7}{3}\\right\\}, \\left\\{-\\frac{14}{3},\\frac{14}{3},-4\\right\\}, \\left\\{\\frac{2}{3},-\\frac{4}{3},\\frac{14}{3}\\right\\}}$.", - "Output Answer": [ - "$99 x-3 y-63 z+224=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(11/3), (8/3), -(7/3)],\n [-(14/3), (14/3), -4],\n [(2/3), -(4/3), (14/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{125}{16} \\\\\n \\frac{11}{4} \\\\\n -\\frac{17}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{139}{16} \\\\\n \\frac{131}{16} \\\\\n \\frac{11}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3195}{64} \\\\\n -\\frac{387}{64} \\\\\n \\frac{22491}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(125/16)],\n [(11/4)],\n [-(17/4)]])\nb = np.array([\n [-(139/16)],\n [(131/16)],\n [(11/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{46}{7} & \\frac{51}{7} & \\frac{38}{7} \\\\\n \\frac{68}{7} & -\\frac{31}{7} & \\frac{1}{7} \\\\\n \\frac{20}{7} & -\\frac{55}{7} & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-9 x^2+\\frac{3825 x}{49}-\\frac{148658}{343}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(46/7), (51/7), (38/7)],\n [(68/7), -(31/7), (1/7)],\n [(20/7), -(55/7), 2]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{12}{5} & -3 & -\\frac{16}{5} \\\\\n 3 & -\\frac{7}{5} & \\frac{21}{5} \\\\\n -\\frac{6}{5} & -\\frac{4}{5} & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{259}{201} & -\\frac{311}{201} & -\\frac{427}{201} \\\\\n \\frac{83}{67} & -\\frac{132}{67} & -\\frac{164}{67} \\\\\n -\\frac{34}{67} & \\frac{46}{67} & \\frac{47}{67} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(12/5), -3, -(16/5)],\n [3, -(7/5), (21/5)],\n [-(6/5), -(4/5), -5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{4}{3}, -\\frac{10}{3}, -\\frac{11}{3}}$ to the plane $3 x-\\frac{5 y}{3}+\\frac{2 z}{3}+\\frac{5}{3}=0$.", - "Output Answer": [ - "$\\frac{79}{3 \\sqrt{110}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (4/3), -(10/3), -(11/3)\nplane = Poly(3*x-((5*y)/3)+((2*z)/3)+(5/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -8 & -7 & 2 & 4 \\\\\n 3 & -1 & 8 & -9 \\\\\n 7 & 1 & 7 & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -9 & 0 & 7 & -4 \\\\\n 4 & 9 & 3 & -1 \\\\\n -2 & -1 & -1 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -17 & -7 & 9 & 0 \\\\\n 7 & 8 & 11 & -10 \\\\\n 5 & 0 & 6 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -7, 2, 4],\n [3, -1, 8, -9],\n [7, 1, 7, 3]])\nb = np.array([\n [-9, 0, 7, -4],\n [4, 9, 3, -1],\n [-2, -1, -1, 2]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 6 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 5 \\\\\n -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -54 \\\\\n 81 \\\\\n 51 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [6],\n [0]])\nb = np.array([\n [-1],\n [5],\n [-9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{16}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -7 & 10 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{21}{16} & -\\frac{15}{8} & -\\frac{15}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 10, 10]])\nprint(a * -(3/16))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -4 & -1 \\\\\n 4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$16$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -1],\n [4, -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{69}{16}, -\\frac{21}{16}}$ to the line $\\frac{21 x}{16}+\\frac{31 y}{8}-\\frac{7}{4}=0$.", - "Output Answer": [ - "$\\frac{3199}{16 \\sqrt{4285}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(69/16), -(21/16)\nline = Poly(((21*x)/16)+((31*y)/8)-(7/4), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -9 & 1 & 0 \\\\\n -4 & 6 & -3 \\\\\n 0 & 8 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8.789,1.394\\, -2.359 i,1.394\\, +2.359 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 1, 0],\n [-4, 6, -3],\n [0, 8, -3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{459}{100} & \\frac{169}{100} & -\\frac{11}{25} & \\frac{31}{20} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{319}{100} & \\frac{263}{100} & \\frac{911}{100} & \\frac{493}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{7}{5} & -\\frac{47}{50} & -\\frac{191}{20} & -\\frac{831}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(459/100), (169/100), -(11/25), (31/20)]])\nb = np.array([\n [-(319/100), (263/100), (911/100), (493/50)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{65}{8} \\\\\n \\frac{47}{8} \\\\\n -\\frac{7}{4} \\\\\n -\\frac{39}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{165}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(65/8)],\n [(47/8)],\n [-(7/4)],\n [-(39/8)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{8} \\\\\n \\frac{47}{16} \\\\\n \\frac{39}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -17 \\sqrt{\\frac{2}{2443}} \\\\\n \\frac{47}{\\sqrt{4886}} \\\\\n \\frac{39}{\\sqrt{4886}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/8)],\n [(47/16)],\n [(39/16)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{3} \\\\\n -\\frac{7}{3} \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -\\frac{25}{3} \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{131}{3} \\\\\n -\\frac{76}{3} \\\\\n -\\frac{41}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3)],\n [-(7/3)],\n [-3]])\nb = np.array([\n [4],\n [-(25/3)],\n [8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1}{\\sqrt{3}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [0],\n [0]]).squeeze()\nb = np.array([\n [0],\n [1],\n [-1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{6} & 0 \\\\\n -\\frac{7}{6} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{7}{12}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/6), 0],\n [-(7/6), -(1/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -7 & 9 & -5 & 10 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-5.,0.,7.,0.,0.\\}, \\{4.,0.,0.,0.,7.\\}, \\{9.,7.,0.,0.,0.\\}, \\{10.,0.,0.,7.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, 9, -5, 10, 4]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\pi \\\\\n 2 \\pi \\\\\n \\pi \\\\\n 0 \\\\\n 3 \\pi \\\\\n -\\pi \\\\\n \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\pi \\\\\n 0 \\\\\n -2 \\pi \\\\\n -3 \\pi \\\\\n -3 \\pi \\\\\n 0 \\\\\n -2 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-10 \\pi ^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-math.pi],\n [2*math.pi],\n [math.pi],\n [0],\n [3*math.pi],\n [-math.pi],\n [math.pi]])\nb = np.array([\n [-3*math.pi],\n [0],\n [-2*math.pi],\n [-3*math.pi],\n [-3*math.pi],\n [0],\n [-2*math.pi]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{4} & \\frac{3}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{17}{32} & -\\frac{51}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/8)]])\nb = np.array([\n [-(1/4), (3/4)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & 0 & -2 \\\\\n 2 & -4 & 2 \\\\\n 3 & 0 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 0 & \\frac{1}{3} \\\\\n -\\frac{1}{4} & -\\frac{1}{4} & 0 \\\\\n -\\frac{1}{2} & 0 & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, -2],\n [2, -4, 2],\n [3, 0, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{4}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -4 & 2 & 5 & 7 \\\\\n -4 & -7 & -6 & -6 \\\\\n 10 & 2 & 10 & -8 \\\\\n -3 & -6 & -10 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -7 & \\frac{7}{2} & \\frac{35}{4} & \\frac{49}{4} \\\\\n -7 & -\\frac{49}{4} & -\\frac{21}{2} & -\\frac{21}{2} \\\\\n \\frac{35}{2} & \\frac{7}{2} & \\frac{35}{2} & -14 \\\\\n -\\frac{21}{4} & -\\frac{21}{2} & -\\frac{35}{2} & \\frac{21}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 2, 5, 7],\n [-4, -7, -6, -6],\n [10, 2, 10, -8],\n [-3, -6, -10, 6]])\nprint(a * (7/4))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 2 & 8 & -7 & 4 \\\\\n -5 & -2 & -10 & -10 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 8 & 3 & 0 & -9 \\\\\n -1 & 9 & 6 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -6 & 5 & -7 & 13 \\\\\n -4 & -11 & -16 & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 8, -7, 4],\n [-5, -2, -10, -10]])\nb = np.array([\n [8, 3, 0, -9],\n [-1, 9, 6, -1]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & 3 & -10 \\\\\n 8 & -7 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{47.,32.,19.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, 3, -10],\n [8, -7, -8]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & -2 \\\\\n -\\frac{13}{2} & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(1-\\sqrt{101}\\right),\\frac{1}{2} \\left(1+\\sqrt{101}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -2],\n [-(13/2), -3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, 0}$ to the line $3 x+4 y=0$.", - "Output Answer": [ - "$\\frac{6}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, 0\nline = Poly(3*x+4*y, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 2 & 7 \\\\\n 5 & 5 \\\\\n 8 & 2 \\\\\n -7 & 2 \\\\\n 7 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, 7],\n [5, 5],\n [8, 2],\n [-7, 2],\n [7, -8]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -8 & -5 & 7 & 7 \\\\\n 10 & 4 & -10 & 10 \\\\\n 3 & -6 & -1 & -6 \\\\\n -10 & -3 & -4 & 1 \\\\\n -10 & 1 & -2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-8, -5, 7, 7],\n [10, 4, -10, 10],\n [3, -6, -1, -6],\n [-10, -3, -4, 1],\n [-10, 1, -2, 0]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 0 & 3 & 2 & 0 & -1 \\\\\n -2 & 2 & 1 & -1 & 2 \\\\\n 2 & 3 & 2 & 3 & 1 \\\\\n 2 & -2 & -1 & 0 & -1 \\\\\n 0 & -1 & 3 & 1 & 0 \\\\\n 3 & 0 & -3 & 2 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.85 \\\\\n -1.23 \\\\\n 2.76 \\\\\n 2.64 \\\\\n 0.24 \\\\\n 2.47 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.865 \\\\\n 0.133 \\\\\n 0.487 \\\\\n -0.96 \\\\\n 0.403 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 3, 2, 0, -1],\n [-2, 2, 1, -1, 2],\n [2, 3, 2, 3, 1],\n [2, -2, -1, 0, -1],\n [0, -1, 3, 1, 0],\n [3, 0, -3, 2, 1]])\nb = np.array([\n [0.85],\n [-1.23],\n [2.76],\n [2.64],\n [0.24],\n [2.47]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,-1,2\\}, \\{-1,-2,0\\}, \\{-1,3,-1\\}}$", - "Output Answer": [ - "${\\left\\{0,-\\frac{1}{\\sqrt{5}},\\frac{2}{\\sqrt{5}}\\right\\}, \\left\\{-\\sqrt{\\frac{5}{21}},-\\frac{8}{\\sqrt{105}},-\\frac{4}{\\sqrt{105}}\\right\\}, \\left\\{-\\frac{4}{\\sqrt{21}},\\frac{2}{\\sqrt{21}},\\frac{1}{\\sqrt{21}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, -1, 2), (-1, -2, 0), (-1, 3, -1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{5}{2},-\\frac{7}{2},-3\\right\\}, \\left\\{0,-\\frac{3}{2},-\\frac{5}{2}\\right\\}, \\{4,2,1\\}}$.", - "Output Answer": [ - "$7 x-9 y+z-11=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(5/2), -(7/2), -3],\n [0, -(3/2), -(5/2)],\n [4, 2, 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{1}{3}, \\frac{1}{3}, -\\frac{7}{3}}$ to the plane $-\\frac{8 x}{3}-\\frac{y}{3}+\\frac{z}{3}+\\frac{14}{3}=0$.", - "Output Answer": [ - "$\\frac{13 \\sqrt{\\frac{2}{33}}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (1/3), (1/3), -(7/3)\nplane = Poly(-((8*x)/3)-(y/3)+(z/3)+(14/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n \\frac{41}{5} \\\\\n -\\frac{53}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n \\frac{49}{5} \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1401}{25} \\\\\n -\\frac{13}{20} \\\\\n -\\frac{433}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [(41/5)],\n [-(53/10)]])\nb = np.array([\n [(1/2)],\n [(49/5)],\n [(1/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -7 & 8 & 10 & 0 & 3 & -9 \\\\\n 5 & 2 & 10 & 10 & 4 & 0 \\\\\n -3 & 8 & 10 & 7 & 7 & -10 \\\\\n 0 & 3 & -5 & -8 & -10 & -8 \\\\\n 10 & 5 & 8 & -2 & 0 & 5 \\\\\n 9 & 0 & 5 & 4 & 5 & 5 \\\\\n 8 & 3 & 8 & -9 & 4 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, 8, 10, 0, 3, -9],\n [5, 2, 10, 10, 4, 0],\n [-3, 8, 10, 7, 7, -10],\n [0, 3, -5, -8, -10, -8],\n [10, 5, 8, -2, 0, 5],\n [9, 0, 5, 4, 5, 5],\n [8, 3, 8, -9, 4, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 2 & -\\frac{1}{4} & -\\frac{11}{4} & -2 & -\\frac{1}{2} \\\\\n 3 & \\frac{7}{4} & -\\frac{1}{2} & 2 & -2 \\\\\n -\\frac{7}{4} & \\frac{7}{4} & \\frac{11}{4} & -\\frac{7}{4} & 1 \\\\\n -\\frac{1}{2} & 0 & \\frac{7}{4} & -\\frac{7}{4} & -\\frac{5}{4} \\\\\n -\\frac{3}{4} & -\\frac{5}{2} & \\frac{3}{4} & 0 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 0 & \\frac{5}{2} & \\frac{3}{4} \\\\\n \\frac{1}{2} & \\frac{9}{4} & -\\frac{11}{4} \\\\\n -\\frac{1}{4} & 0 & \\frac{11}{4} \\\\\n -\\frac{11}{4} & -\\frac{5}{2} & -\\frac{3}{4} \\\\\n -\\frac{11}{4} & -\\frac{5}{4} & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{119}{16} & \\frac{161}{16} & -4 \\\\\n 1 & \\frac{143}{16} & -\\frac{95}{16} \\\\\n \\frac{9}{4} & \\frac{43}{16} & 3 \\\\\n \\frac{125}{16} & \\frac{75}{16} & \\frac{87}{16} \\\\\n -\\frac{67}{16} & -\\frac{35}{4} & \\frac{69}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(1/4), -(11/4), -2, -(1/2)],\n [3, (7/4), -(1/2), 2, -2],\n [-(7/4), (7/4), (11/4), -(7/4), 1],\n [-(1/2), 0, (7/4), -(7/4), -(5/4)],\n [-(3/4), -(5/2), (3/4), 0, 1]])\nb = np.array([\n [0, (5/2), (3/4)],\n [(1/2), (9/4), -(11/4)],\n [-(1/4), 0, (11/4)],\n [-(11/4), -(5/2), -(3/4)],\n [-(11/4), -(5/4), (1/4)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -1 & 3 \\\\\n -2 & -2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 23 & 3 \\\\\n -2 & 22 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3],\n [-2, -2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & -2 & -2 \\\\\n 2 & 1 & 2 \\\\\n -3 & 3 & 2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 2 & -8 & -8 \\\\\n -4 & 3 & 2 \\\\\n 0 & 15 & 16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2, -2],\n [2, 1, 2],\n [-3, 3, 2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -3 & 1 & 0 & -3 \\\\\n 0 & -1 & 0 & 0 \\\\\n 1 & -1 & -1 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 2 & -3 \\\\\n -3 & 2 \\\\\n 1 & -1 \\\\\n 2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -15 & 11 \\\\\n 3 & -2 \\\\\n 4 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1, 0, -3],\n [0, -1, 0, 0],\n [1, -1, -1, 0]])\nb = np.array([\n [2, -3],\n [-3, 2],\n [1, -1],\n [2, 0]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{28}{3} & -\\frac{4}{3} & -\\frac{19}{9} \\\\\n -\\frac{41}{9} & -\\frac{4}{9} & 2 \\\\\n -\\frac{44}{9} & -\\frac{37}{9} & \\frac{4}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{89}{9} & \\frac{77}{9} & \\frac{17}{9} \\\\\n -\\frac{53}{9} & \\frac{29}{9} & -\\frac{28}{9} \\\\\n -\\frac{67}{9} & \\frac{8}{9} & \\frac{16}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{173}{9} & \\frac{65}{9} & -\\frac{2}{9} \\\\\n -\\frac{94}{9} & \\frac{25}{9} & -\\frac{10}{9} \\\\\n -\\frac{37}{3} & -\\frac{29}{9} & \\frac{52}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(28/3), -(4/3), -(19/9)],\n [-(41/9), -(4/9), 2],\n [-(44/9), -(37/9), (4/9)]])\nb = np.array([\n [-(89/9), (77/9), (17/9)],\n [-(53/9), (29/9), -(28/9)],\n [-(67/9), (8/9), (16/3)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{4} \\\\\n -\\frac{15}{8} \\\\\n -\\frac{17}{8} \\\\\n -\\frac{5}{2} \\\\\n \\frac{3}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{3}{2} & \\frac{19}{8} & \\frac{11}{8} & \\frac{13}{8} & \\frac{9}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n \\frac{3}{8} & -\\frac{19}{32} & -\\frac{11}{32} & -\\frac{13}{32} & -\\frac{9}{16} \\\\\n \\frac{45}{16} & -\\frac{285}{64} & -\\frac{165}{64} & -\\frac{195}{64} & -\\frac{135}{32} \\\\\n \\frac{51}{16} & -\\frac{323}{64} & -\\frac{187}{64} & -\\frac{221}{64} & -\\frac{153}{32} \\\\\n \\frac{15}{4} & -\\frac{95}{16} & -\\frac{55}{16} & -\\frac{65}{16} & -\\frac{45}{8} \\\\\n -\\frac{9}{8} & \\frac{57}{32} & \\frac{33}{32} & \\frac{39}{32} & \\frac{27}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/4)],\n [-(15/8)],\n [-(17/8)],\n [-(5/2)],\n [(3/4)]])\nb = np.array([\n [-(3/2), (19/8), (11/8), (13/8), (9/4)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{30}{\\pi } \\\\\n -\\frac{19}{\\pi } \\\\\n -\\frac{18}{\\pi } \\\\\n \\frac{30}{\\pi } \\\\\n -\\frac{25}{\\pi } \\\\\n -\\frac{6}{\\pi } \\\\\n -\\frac{24}{\\pi } \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{\\pi } \\\\\n -\\frac{22}{\\pi } \\\\\n -\\frac{5}{\\pi } \\\\\n -\\frac{8}{\\pi } \\\\\n -\\frac{22}{\\pi } \\\\\n \\frac{3}{\\pi } \\\\\n -\\frac{9}{\\pi } \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1526}{\\pi ^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(30/math.pi)],\n [-(19/math.pi)],\n [-(18/math.pi)],\n [(30/math.pi)],\n [-(25/math.pi)],\n [-(6/math.pi)],\n [-(24/math.pi)]])\nb = np.array([\n [-(17/math.pi)],\n [-(22/math.pi)],\n [-(5/math.pi)],\n [-(8/math.pi)],\n [-(22/math.pi)],\n [(3/math.pi)],\n [-(9/math.pi)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-1, -5, 1}$ to the plane $x-4 z+1=0$.", - "Output Answer": [ - "$\\frac{4}{\\sqrt{17}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -1, -5, 1\nplane = Poly(x-4*z+1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 0 \\\\\n -1 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\sqrt{\\frac{2}{7}} \\\\\n 0 \\\\\n -\\frac{1}{\\sqrt{14}} \\\\\n \\frac{3}{\\sqrt{14}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [0],\n [-1],\n [3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{4}{5} & \\frac{9}{5} & -1 \\\\\n \\frac{16}{5} & \\frac{8}{5} & -\\frac{24}{5} \\\\\n \\frac{1}{5} & -\\frac{1}{5} & -\\frac{6}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{4} & \\frac{59}{96} & -\\frac{11}{6} \\\\\n \\frac{3}{4} & -\\frac{19}{96} & \\frac{1}{6} \\\\\n -\\frac{1}{4} & \\frac{13}{96} & -\\frac{7}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/5), (9/5), -1],\n [(16/5), (8/5), -(24/5)],\n [(1/5), -(1/5), -(6/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{23}{5}, \\frac{9}{5}}$ to the line $\\frac{7 x}{5}-\\frac{16 y}{5}-\\frac{19}{5}=0$.", - "Output Answer": [ - "$16 \\sqrt{\\frac{5}{61}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(23/5), (9/5)\nline = Poly(((7*x)/5)-((16*y)/5)-(19/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n 0 \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n -\\frac{3}{2} \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{7}{92},\\frac{21}{92},-\\frac{21}{46}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2)],\n [0],\n [-(1/2)]]).squeeze()\nb = np.array([\n [(1/2)],\n [-(3/2)],\n [3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{2} & -3 & 0 \\\\\n 1 & -\\frac{3}{2} & 0 \\\\\n 2 & -1 & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{81}{8} & -\\frac{45}{4} & 0 \\\\\n \\frac{15}{4} & \\frac{81}{8} & 0 \\\\\n \\frac{3}{2} & \\frac{75}{4} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), -3, 0],\n [1, -(3/2), 0],\n [2, -1, 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{10}{3} \\\\\n \\frac{4}{3} \\\\\n -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{7}{3} \\\\\n -\\frac{25}{3} \\\\\n \\frac{26}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{352}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(10/3)],\n [(4/3)],\n [-(7/3)]])\nb = np.array([\n [(7/3)],\n [-(25/3)],\n [(26/3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{7}{3}, \\frac{2}{3}, -\\frac{10}{3}}$ to the plane $x-2 y+\\frac{11 z}{3}+\\frac{8}{3}=0$.", - "Output Answer": [ - "$\\frac{119}{3 \\sqrt{166}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(7/3), (2/3), -(10/3)\nplane = Poly(x-2*y+((11*z)/3)+(8/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{7}{4} & -\\frac{7}{2} & 0 \\\\\n 6 & -\\frac{15}{4} & -6 \\\\\n -\\frac{5}{2} & -\\frac{19}{2} & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.208,0.719,1.\\}, \\{0.37\\, -0.61 i,-0.695-0.2 i,1.\\}, \\{0.37\\, +0.61 i,-0.695+0.2 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/4), -(7/2), 0],\n [6, -(15/4), -6],\n [-(5/2), -(19/2), -3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [0],\n [0],\n [1],\n [0],\n [1],\n [0],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [0],\n [-1],\n [1],\n [1],\n [1],\n [-1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 2 \\\\\n -3 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 1 \\\\\n -2 \\\\\n -1 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{16}{19},\\frac{8}{19},-\\frac{16}{19},-\\frac{8}{19},\\frac{24}{19}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [2],\n [-3],\n [1],\n [-1]]).squeeze()\nb = np.array([\n [2],\n [1],\n [-2],\n [-1],\n [3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 1 & 1 & -3 & 3 & 2 \\\\\n 1 & -2 & 1 & 3 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 0 & 3 & -3 & 3 \\\\\n 2 & 0 & -2 & -1 \\\\\n -1 & 1 & 0 & 0 \\\\\n -2 & -1 & 0 & -2 \\\\\n -2 & 2 & 2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -5 & 1 & -1 & -4 \\\\\n -5 & -5 & -5 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1, -3, 3, 2],\n [1, -2, 1, 3, -3]])\nb = np.array([\n [0, 3, -3, 3],\n [2, 0, -2, -1],\n [-1, 1, 0, 0],\n [-2, -1, 0, -2],\n [-2, 2, 2, 0]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{79}{50} & -\\frac{439}{100} & \\frac{164}{25} \\\\\n \\frac{51}{20} & -\\frac{313}{100} & \\frac{23}{5} \\\\\n -\\frac{3}{100} & -\\frac{237}{25} & \\frac{97}{25} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{513}{100} & \\frac{661}{100} & \\frac{609}{100} \\\\\n -\\frac{23}{10} & \\frac{871}{100} & \\frac{159}{100} \\\\\n -\\frac{23}{20} & -\\frac{177}{100} & \\frac{159}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{671}{100} & -11 & \\frac{47}{100} \\\\\n \\frac{97}{20} & -\\frac{296}{25} & \\frac{301}{100} \\\\\n \\frac{28}{25} & -\\frac{771}{100} & \\frac{229}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(79/50), -(439/100), (164/25)],\n [(51/20), -(313/100), (23/5)],\n [-(3/100), -(237/25), (97/25)]])\nb = np.array([\n [(513/100), (661/100), (609/100)],\n [-(23/10), (871/100), (159/100)],\n [-(23/20), -(177/100), (159/100)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{19}{3} \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{40}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/3)],\n [-7]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -3 & 2 & 2 \\\\\n 3 & -3 & 0 \\\\\n -2 & -1 & -2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -55 & 74 & 42 \\\\\n 87 & -87 & -48 \\\\\n -18 & 11 & 14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2, 2],\n [3, -3, 0],\n [-2, -1, -2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1-4 i & -2+i & 3+4 i \\\\\n 2-i & 4-5 i & 2 \\\\\n -1+4 i & 3-i & 3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 169+246 i & 320-61 i & -105-34 i \\\\\n -101+64 i & -124-140 i & 97-150 i \\\\\n -14-181 i & -150-167 i & 45+53 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1-4j, -2+ 1j, 3+4j],\n [2- 1j, 4-5j, 2],\n [-1+4j, 3- 1j, 3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 9 & 9 & -5 & 4 \\\\\n 3 & -1 & 1 & -5 \\\\\n -8 & 9 & -5 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{20.,237.,517.,68.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, 9, -5, 4],\n [3, -1, 1, -5],\n [-8, 9, -5, 9]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 0 & \\frac{15}{7} \\\\\n 0 & 0 \\\\\n \\frac{18}{7} & -\\frac{17}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{4}{7} & -\\frac{17}{7} & \\frac{8}{7} \\\\\n -\\frac{17}{7} & -\\frac{13}{7} & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{255}{49} & -\\frac{195}{49} & -\\frac{15}{7} \\\\\n 0 & 0 & 0 \\\\\n \\frac{361}{49} & -\\frac{85}{49} & \\frac{263}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, (15/7)],\n [0, 0],\n [(18/7), -(17/7)]])\nb = np.array([\n [(4/7), -(17/7), (8/7)],\n [-(17/7), -(13/7), -1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{2,1,-1\\}, \\{0,4,3\\}, \\{4,2,-4\\}}$.", - "Output Answer": [ - "$13 x-2 (y-4 z+8)=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, 1, -1],\n [0, 4, 3],\n [4, 2, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 4 & -5+3 i & 3+3 i \\\\\n 3 i & 2-2 i & 4+3 i \\\\\n 3 i & -4-3 i & -4+4 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -2-6 i & -27+7 i & -41+9 i \\\\\n -3+30 i & -16-47 i & -23+11 i \\\\\n -3-12 i & 5-17 i & -16-47 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -5+3j, 3+3j],\n [3j, 2-2j, 4+3j],\n [3j, -4-3j, -4+4j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -9 & -7 & -6 \\\\\n -2 & 7 & 6 \\\\\n 10 & 0 & -5 \\\\\n -7 & -9 & -6 \\\\\n 5 & -7 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, -7, -6],\n [-2, 7, 6],\n [10, 0, -5],\n [-7, -9, -6],\n [5, -7, -9]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & 1 \\\\\n -8 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-3 x-46$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 1],\n [-8, -6]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{17}{10}, -\\frac{47}{10}}$ to the line $-\\frac{16 x}{5}+\\frac{7 y}{2}-\\frac{1}{5}=0$.", - "Output Answer": [ - "$\\frac{2209}{10 \\sqrt{2249}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (17/10), -(47/10)\nline = Poly(-((16*x)/5)+((7*y)/2)-(1/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{25}{6} \\\\\n -\\frac{11}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{25}{6}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/6)],\n [-(11/6)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 0 & 2 \\\\\n 2 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & -1 & -2 & -2 \\\\\n 2 & 1 & 1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 4 & 2 & 2 & 4 \\\\\n 6 & -1 & -3 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2],\n [2, 1]])\nb = np.array([\n [2, -1, -2, -2],\n [2, 1, 1, 2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -6 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -5 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 47 \\\\\n 40 \\\\\n 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-6],\n [1]])\nb = np.array([\n [5],\n [-5],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -6 \\\\\n 5 \\\\\n -2 \\\\\n -5 \\\\\n 8 \\\\\n -1 \\\\\n -6 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -9 \\\\\n 2 \\\\\n 7 \\\\\n -6 \\\\\n -8 \\\\\n -2 \\\\\n -3 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{683}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-6],\n [5],\n [-2],\n [-5],\n [8],\n [-1],\n [-6],\n [7]])\nb = np.array([\n [6],\n [-9],\n [2],\n [7],\n [-6],\n [-8],\n [-2],\n [-3],\n [-7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 0 & 7 & 10 \\\\\n 0 & -7 & -8 \\\\\n -9 & -7 & -8 \\\\\n -7 & -7 & 1 \\\\\n 9 & 3 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, 7, 10],\n [0, -7, -8],\n [-9, -7, -8],\n [-7, -7, 1],\n [9, 3, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-1$ and the matrix\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -9 \\\\\n 9 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -5 \\\\\n 9 \\\\\n -9 \\\\\n -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-9],\n [9],\n [7]])\nprint(a * -1)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(\\sqrt{15}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [1],\n [0],\n [-1],\n [0],\n [1],\n [1],\n [0]]).squeeze()\nb = np.array([\n [0],\n [0],\n [0],\n [1],\n [0],\n [0],\n [0],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 1 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -5 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -20 \\\\\n -47 \\\\\n 51 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [1],\n [-3]])\nb = np.array([\n [-1],\n [-5],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{4}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 10 & 7 & 7 \\\\\n -3 & 4 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{15}{2} & \\frac{21}{4} & \\frac{21}{4} \\\\\n -\\frac{9}{4} & 3 & -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 7, 7],\n [-3, 4, -10]])\nprint(a * (3/4))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{1}{3} & \\frac{1}{2} & -\\frac{17}{6} & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n -\\frac{1}{2} \\\\\n \\frac{1}{2} \\\\\n -\\frac{13}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{53}{18} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/3), (1/2), -(17/6), (2/3)]])\nb = np.array([\n [-(1/2)],\n [-(1/2)],\n [(1/2)],\n [-(13/6)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{65}{7} \\\\\n -\\frac{45}{7} \\\\\n \\frac{17}{7} \\\\\n -3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{204}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(65/7)],\n [-(45/7)],\n [(17/7)],\n [-3],\n [-8]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 5 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -4 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-34$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [5],\n [-1]])\nb = np.array([\n [5],\n [-4],\n [4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 6 & \\frac{71}{9} & 8 \\\\\n \\frac{52}{9} & \\frac{1}{9} & -\\frac{53}{9} \\\\\n -\\frac{11}{3} & -\\frac{77}{9} & -\\frac{55}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{8368 x}{81}-\\frac{182017}{729}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, (71/9), 8],\n [(52/9), (1/9), -(53/9)],\n [-(11/3), -(77/9), -(55/9)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -\\frac{19}{5} & \\frac{44}{5} & -\\frac{11}{5} & \\frac{42}{5} \\\\\n -\\frac{34}{5} & -\\frac{1}{5} & -\\frac{11}{5} & \\frac{32}{5} \\\\\n -\\frac{3}{2} & \\frac{63}{10} & \\frac{12}{5} & -5 \\\\\n 8 & 0 & \\frac{27}{10} & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/5), (44/5), -(11/5), (42/5)],\n [-(34/5), -(1/5), -(11/5), (32/5)],\n [-(3/2), (63/10), (12/5), -5],\n [8, 0, (27/10), 6]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{1}{2} \\\\\n \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2 \\sqrt{\\frac{2}{21}} \\\\\n \\frac{1}{\\sqrt{42}} \\\\\n \\frac{5}{\\sqrt{42}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [(1/2)],\n [(5/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n \\frac{93}{10} \\\\\n -\\frac{41}{10} \\\\\n \\frac{23}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{187}{10}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [(93/10)],\n [-(41/10)],\n [(23/10)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -9 & 4 & 9 \\\\\n -6 & -3 & 0 \\\\\n -6 & -5 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-4 x^2-9 x+516$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 4, 9],\n [-6, -3, 0],\n [-6, -5, 8]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 2 & 0 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -2 & 0 & -1 \\\\\n 2 & 0 & 1 \\\\\n 4 & 0 & 2 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [2],\n [0]])\nb = np.array([\n [2, 0, 1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\sqrt{3} \\\\\n 0 \\\\\n 2 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n 2 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n -3 \\sqrt{3} \\\\\n 2 \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{37}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-math.sqrt(3)],\n [0],\n [2*math.sqrt(3)],\n [3*math.sqrt(3)],\n [2*math.sqrt(3)],\n [3*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [math.sqrt(3)]])\nb = np.array([\n [math.sqrt(3)],\n [-2*math.sqrt(3)],\n [4*math.sqrt(3)],\n [4*math.sqrt(3)],\n [-3*math.sqrt(3)],\n [2*math.sqrt(3)],\n [math.sqrt(3)],\n [-5*math.sqrt(3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -9 \\\\\n 9 \\\\\n 3 \\\\\n 1 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -2 \\\\\n -2 \\\\\n -5 \\\\\n -1 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{571}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-9],\n [9],\n [3],\n [1],\n [-4]])\nb = np.array([\n [-8],\n [-2],\n [-2],\n [-5],\n [-1],\n [-7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,2,1\\}, \\{5,-1,4\\}, \\{2,-2,2\\}}$.", - "Output Answer": [ - "$x+y-2 z+4=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, 2, 1],\n [5, -1, 4],\n [2, -2, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -\\frac{21}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-(21/4)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -\\frac{36}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-(36/7)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -5 \\\\\n -4 \\\\\n -2 \\\\\n 2 \\\\\n 7 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 6 \\\\\n 0 \\\\\n 8 \\\\\n -9 \\\\\n -5 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-90$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-5],\n [-4],\n [-2],\n [2],\n [7],\n [-10]])\nb = np.array([\n [-7],\n [6],\n [0],\n [8],\n [-9],\n [-5],\n [-3]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{17}{3} & \\frac{25}{9} \\\\\n \\frac{19}{3} & \\frac{11}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{62 x}{9}-\\frac{32}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/3), (25/9)],\n [(19/3), (11/9)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -\\frac{1}{3} \\\\\n -\\frac{25}{9} \\\\\n \\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{61}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-(1/3)],\n [-(25/9)],\n [(2/3)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 3 & 6 & -1 \\\\\n 3 & -10 & -1 \\\\\n 4 & 10 & 9 \\\\\n -5 & 3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, 6, -1],\n [3, -10, -1],\n [4, 10, 9],\n [-5, 3, 0]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{19}{5} & -\\frac{12}{5} & \\frac{2}{5} \\\\\n \\frac{17}{5} & \\frac{41}{10} & \\frac{39}{10} \\\\\n -\\frac{12}{5} & -\\frac{18}{5} & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{735}{5329} & \\frac{2040}{5329} & \\frac{5500}{15987} \\\\\n -\\frac{990}{5329} & \\frac{2690}{5329} & \\frac{6730}{15987} \\\\\n \\frac{400}{5329} & -\\frac{3240}{5329} & -\\frac{11870}{15987} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/5), -(12/5), (2/5)],\n [(17/5), (41/10), (39/10)],\n [-(12/5), -(18/5), -(9/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{13}{8}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & -8 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 13 & -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -8, 4]])\nprint(a * -(13/8))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & -9 \\\\\n 3 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+5 x-9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -9],\n [3, -9]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -6 \\\\\n 6 \\\\\n 5 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{210}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-6],\n [6],\n [5],\n [8]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 2 \\\\\n 5 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2],\n [5, 2]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 2 & 6 & -8 & 4 \\\\\n 5 & -3 & 8 & 8 \\\\\n 6 & -5 & -1 & -3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -1 & 4 & -3 & 7 \\\\\n -5 & -8 & 3 & 0 \\\\\n -8 & -9 & 5 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 3 & 2 & -5 & -3 \\\\\n 10 & 5 & 5 & 8 \\\\\n 14 & 4 & -6 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 6, -8, 4],\n [5, -3, 8, 8],\n [6, -5, -1, -3]])\nb = np.array([\n [-1, 4, -3, 7],\n [-5, -8, 3, 0],\n [-8, -9, 5, -9]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{2}{3}, 2, -4}$ to the plane $-\\frac{13 x}{3}-\\frac{2 y}{3}-\\frac{10 z}{3}+\\frac{8}{3}=0$.", - "Output Answer": [ - "$\\frac{106}{3 \\sqrt{273}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (2/3), 2, -4\nplane = Poly(-((13*x)/3)-((2*y)/3)-((10*z)/3)+(8/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{14}{5},-\\frac{7}{5},\\frac{12}{5}\\right\\}, \\left\\{-\\frac{13}{5},\\frac{4}{5},\\frac{7}{5}\\right\\}, \\left\\{\\frac{9}{5},\\frac{12}{5},-\\frac{13}{5}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{14}{\\sqrt{389}},-\\frac{7}{\\sqrt{389}},\\frac{12}{\\sqrt{389}}\\right\\}, \\left\\{-\\frac{1725}{\\sqrt{13374598}},1611 \\sqrt{\\frac{2}{6687299}},-\\frac{133}{\\sqrt{13374598}}\\right\\}, \\left\\{-\\frac{97}{\\sqrt{34382}},-29 \\sqrt{\\frac{2}{17191}},-\\frac{147}{\\sqrt{34382}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-(14/5), -(7/5), (12/5)), (-(13/5), (4/5), (7/5)), ((9/5), (12/5), -(13/5))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{6} \\\\\n \\frac{5}{3} \\\\\n -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{357}} \\\\\n \\frac{10}{\\sqrt{357}} \\\\\n -\\frac{16}{\\sqrt{357}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/6)],\n [(5/3)],\n [-(8/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{24}{5} & -\\frac{29}{5} \\\\\n \\frac{7}{5} & \\frac{19}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(-5-\\sqrt{1037}\\right),\\frac{1}{10} \\left(\\sqrt{1037}-5\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(24/5), -(29/5)],\n [(7/5), (19/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 3 & 3 & 1 & 2 \\\\\n 0 & 0 & 0 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 2 & 1 & -1 & -2 & 0 \\\\\n 2 & 0 & 1 & -1 & 3 \\\\\n -2 & -2 & -2 & 0 & 0 \\\\\n -1 & 2 & 2 & -2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 8 & 5 & 2 & -13 & 3 \\\\\n 1 & -2 & -2 & 2 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3, 1, 2],\n [0, 0, 0, -1]])\nb = np.array([\n [2, 1, -1, -2, 0],\n [2, 0, 1, -1, 3],\n [-2, -2, -2, 0, 0],\n [-1, 2, 2, -2, -3]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{9}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 3 & -10 & -10 & 6 \\\\\n 7 & -5 & -2 & 8 \\\\\n 2 & 9 & -7 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{1}{3} & -\\frac{10}{9} & -\\frac{10}{9} & \\frac{2}{3} \\\\\n \\frac{7}{9} & -\\frac{5}{9} & -\\frac{2}{9} & \\frac{8}{9} \\\\\n \\frac{2}{9} & 1 & -\\frac{7}{9} & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -10, -10, 6],\n [7, -5, -2, 8],\n [2, 9, -7, 9]])\nprint(a * (1/9))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -2 & -1 \\\\\n 0 & 1 \\\\\n 0 & -2 \\\\\n -1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 8 \\\\\n -2 \\\\\n 4 \\\\\n -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1],\n [0, 1],\n [0, -2],\n [-1, 2]])\nb = np.array([\n [-3],\n [-2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 1 \\\\\n \\frac{5}{2} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{19 x}{2}+\\frac{19}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 1],\n [(5/2), (3/2)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}+\\tan ^{-1}\\left(\\frac{2}{5}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-3]]).squeeze()\nb = np.array([\n [5],\n [-5]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -7 & 3 & 1 \\\\\n 9 & 5 & -7 \\\\\n 4 & -9 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-5 x^2+123 x+442$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 3, 1],\n [9, 5, -7],\n [4, -9, -3]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -10 & -3 & -2 \\\\\n -3 & 4 & 6 \\\\\n -8 & 0 & -6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -10 & 9 & -3 \\\\\n -2 & -1 & -4 \\\\\n 6 & -3 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & -12 & 1 \\\\\n -1 & 5 & 10 \\\\\n -14 & 3 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -3, -2],\n [-3, 4, 6],\n [-8, 0, -6]])\nb = np.array([\n [-10, 9, -3],\n [-2, -1, -4],\n [6, -3, -9]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 2 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -2 & 0 \\\\\n 1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -7 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3]])\nb = np.array([\n [-2, 0],\n [1, -2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{59}{10} & \\frac{17}{10} & \\frac{2}{5} \\\\\n -\\frac{49}{5} & \\frac{11}{2} & \\frac{38}{5} \\\\\n \\frac{81}{10} & \\frac{26}{5} & -\\frac{57}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{61 x^2}{10}+\\frac{5627 x}{100}+\\frac{389619}{1000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(59/10), (17/10), (2/5)],\n [-(49/5), (11/2), (38/5)],\n [(81/10), (26/5), -(57/10)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & 3 & \\frac{13}{2} \\\\\n 6 & \\frac{1}{2} & 7 \\\\\n 9 & -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1.541,1.237,1.\\}, \\{-0.479-0.151 i,-0.749+0.833 i,1.\\}, \\{-0.479+0.151 i,-0.749-0.833 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 3, (13/2)],\n [6, (1/2), 7],\n [9, -1, 1]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{8} \\\\\n \\frac{5}{8} \\\\\n \\frac{7}{8} \\\\\n \\frac{13}{8} \\\\\n \\frac{23}{8} \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{3 \\sqrt{93}} \\\\\n \\frac{5}{3 \\sqrt{93}} \\\\\n \\frac{7}{3 \\sqrt{93}} \\\\\n \\frac{13}{3 \\sqrt{93}} \\\\\n \\frac{23}{3 \\sqrt{93}} \\\\\n \\frac{8}{3 \\sqrt{93}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/8)],\n [(5/8)],\n [(7/8)],\n [(13/8)],\n [(23/8)],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -3 & 2 \\\\\n -3 & 0 & 1 \\\\\n 3 & -1 & 3 \\\\\n 0 & -2 & 1 \\\\\n 3 & 1 & 2 \\\\\n -1 & -1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.56 \\\\\n -1.91 \\\\\n 1.28 \\\\\n 0.15 \\\\\n 1.47 \\\\\n 2.16 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.331 \\\\\n 0.536 \\\\\n 0.375 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -3, 2],\n [-3, 0, 1],\n [3, -1, 3],\n [0, -2, 1],\n [3, 1, 2],\n [-1, -1, 3]])\nb = np.array([\n [-2.56],\n [-1.91],\n [1.28],\n [0.15],\n [1.47],\n [2.16]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n \\frac{15}{2} \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/2)],\n [-4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & \\frac{16}{3} & 3 \\\\\n -9 & -4 & \\frac{14}{3} \\\\\n \\frac{1}{3} & -\\frac{16}{3} & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.574,-0.093,1.\\}, \\{-1.098-0.719 i,0.777\\, -1.667 i,1.\\}, \\{-1.098+0.719 i,0.777\\, +1.667 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, (16/3), 3],\n [-9, -4, (14/3)],\n [(1/3), -(16/3), (2/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{2}{5},-\\frac{13}{5},\\frac{6}{5}\\right\\}, \\left\\{-\\frac{14}{5},\\frac{11}{5},\\frac{1}{5}\\right\\}, \\left\\{\\frac{13}{5},-\\frac{3}{5},-\\frac{8}{5}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{2}{\\sqrt{209}},-\\frac{13}{\\sqrt{209}},\\frac{6}{\\sqrt{209}}\\right\\}, \\left\\{-\\frac{3144}{\\sqrt{11407429}},\\frac{882}{\\sqrt{11407429}},\\frac{863}{\\sqrt{11407429}}\\right\\}, \\left\\{-\\frac{79}{\\sqrt{54581}},-\\frac{82}{\\sqrt{54581}},-\\frac{204}{\\sqrt{54581}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-(2/5), -(13/5), (6/5)), (-(14/5), (11/5), (1/5)), ((13/5), -(3/5), -(8/5))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n \\frac{42}{5} \\\\\n -\\frac{12}{5} \\\\\n \\frac{26}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{5} \\\\\n 2 \\\\\n -\\frac{42}{5} \\\\\n -\\frac{3}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{2151}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [(42/5)],\n [-(12/5)],\n [(26/5)]])\nb = np.array([\n [-(29/5)],\n [2],\n [-(42/5)],\n [-(3/5)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & 0 & 2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0]])\nb = np.array([\n [2, 0, 2, 1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-1$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & 9 \\\\\n 4 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -4 & -9 \\\\\n -4 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 9],\n [4, 1]])\nprint(a * -1)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 2 & 0 & 1 & -3 & 3 \\\\\n 1 & -3 & 0 & -3 & 3 \\\\\n -3 & 2 & 0 & 1 & 1 \\\\\n 3 & 3 & 1 & 0 & 0 \\\\\n -1 & 0 & -1 & -3 & -3 \\\\\n 1 & 1 & 3 & -2 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.85 \\\\\n -1.47 \\\\\n 1.22 \\\\\n 2.87 \\\\\n -1.95 \\\\\n 1.07 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.224 \\\\\n 0.83 \\\\\n 0.199 \\\\\n -0.002 \\\\\n 0.496 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, 1, -3, 3],\n [1, -3, 0, -3, 3],\n [-3, 2, 0, 1, 1],\n [3, 3, 1, 0, 0],\n [-1, 0, -1, -3, -3],\n [1, 1, 3, -2, -1]])\nb = np.array([\n [2.85],\n [-1.47],\n [1.22],\n [2.87],\n [-1.95],\n [1.07]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 7 & -2 & -8 \\\\\n 1 & 3 & -9 \\\\\n -1 & -7 & -10 \\\\\n -6 & 7 & 8 \\\\\n -8 & 9 & -5 \\\\\n 9 & -3 & -4 \\\\\n 4 & -9 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, -2, -8],\n [1, 3, -9],\n [-1, -7, -10],\n [-6, 7, 8],\n [-8, 9, -5],\n [9, -3, -4],\n [4, -9, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{13}{3} & -\\frac{8}{3} \\\\\n -\\frac{11}{3} & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{10}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/3), -(8/3)],\n [-(11/3), -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 1 & -3 & 1 & -2 & 2 \\\\\n 1 & 3 & 3 & 2 & 2 \\\\\n 0 & -2 & 2 & -2 & 1 \\\\\n 1 & -1 & 1 & 2 & -2 \\\\\n 1 & 3 & -1 & 0 & -2 \\\\\n 0 & -2 & 2 & 1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.73 \\\\\n 2.6 \\\\\n 1.55 \\\\\n 0.17 \\\\\n -2.6 \\\\\n 0.71 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.811 \\\\\n 0.224 \\\\\n 1.268 \\\\\n 0.082 \\\\\n -0.267 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3, 1, -2, 2],\n [1, 3, 3, 2, 2],\n [0, -2, 2, -2, 1],\n [1, -1, 1, 2, -2],\n [1, 3, -1, 0, -2],\n [0, -2, 2, 1, 2]])\nb = np.array([\n [-1.73],\n [2.6],\n [1.55],\n [0.17],\n [-2.6],\n [0.71]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{11}{2}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 7 & -9 & 1 & 9 \\\\\n -1 & -7 & -8 & -10 \\\\\n 6 & -4 & -5 & 1 \\\\\n 2 & -4 & -2 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{77}{2} & -\\frac{99}{2} & \\frac{11}{2} & \\frac{99}{2} \\\\\n -\\frac{11}{2} & -\\frac{77}{2} & -44 & -55 \\\\\n 33 & -22 & -\\frac{55}{2} & \\frac{11}{2} \\\\\n 11 & -22 & -11 & \\frac{33}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -9, 1, 9],\n [-1, -7, -8, -10],\n [6, -4, -5, 1],\n [2, -4, -2, 3]])\nprint(a * (11/2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{10} & \\frac{7}{5} \\\\\n -\\frac{16}{5} & -\\frac{14}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{119}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/10), (7/5)],\n [-(16/5), -(14/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{7}{6} & -\\frac{11}{6} & -\\frac{8}{3} \\\\\n \\frac{13}{3} & -\\frac{11}{3} & -\\frac{13}{3} \\\\\n \\frac{8}{3} & -\\frac{1}{3} & -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{31}{6}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/6), -(11/6), -(8/3)],\n [(13/3), -(11/3), -(13/3)],\n [(8/3), -(1/3), -(2/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${2, -4, -2}$ to the plane $-5 x-3 z+1=0$.", - "Output Answer": [ - "$\\frac{3}{\\sqrt{34}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 2, -4, -2\nplane = Poly(-5*x-3*z+1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{6} \\\\\n \\frac{23}{6} \\\\\n \\frac{29}{3} \\\\\n -\\frac{55}{6} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n 3 \\\\\n \\frac{23}{3} \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{14}{3} \\\\\n \\frac{5}{6} \\\\\n 2 \\\\\n -\\frac{25}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/6)],\n [(23/6)],\n [(29/3)],\n [-(55/6)]])\nb = np.array([\n [(5/2)],\n [3],\n [(23/3)],\n [-5]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n 8 & 3 & -7 \\\\\n -1 & 4 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 3, -7],\n [-1, 4, 2]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 10 \\\\\n -\\frac{23}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{20}{3} \\\\\n -\\frac{23}{3} \\\\\n \\frac{4}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{409}{9} \\\\\n \\frac{352}{9} \\\\\n -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [10],\n [-(23/3)]])\nb = np.array([\n [-(20/3)],\n [-(23/3)],\n [(4/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{4}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -9 & -7 \\\\\n 3 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{9}{4} & -\\frac{7}{4} \\\\\n \\frac{3}{4} & \\frac{5}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -7],\n [3, 5]])\nprint(a * (1/4))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 0 \\\\\n 0 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [0],\n [0],\n [4]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & -4 & -7 \\\\\n 1 & -6 & 0 \\\\\n 10 & -1 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [6, -4, -7],\n [1, -6, 0],\n [10, -1, -8]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 4 & -9 & 8 & 10 & 6 \\\\\n -9 & -6 & -9 & 1 & -8 \\\\\n 4 & 7 & -1 & 10 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2027.,846.,1504.,369.,0.\\}, \\{478.,-162.,-698.,0.,369.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, -9, 8, 10, 6],\n [-9, -6, -9, 1, -8],\n [4, 7, -1, 10, -4]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & 4 \\\\\n 5 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-2-3 \\sqrt{5},3 \\sqrt{5}-2\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 4],\n [5, 3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n \\frac{20}{3} \\\\\n 6 \\\\\n -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{4}{3} \\\\\n -\\frac{16}{3} \\\\\n 3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{2102}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [(20/3)],\n [6],\n [-(11/3)]])\nb = np.array([\n [(4/3)],\n [-(16/3)],\n [3],\n [1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -8 & 8 & 5 \\\\\n 6 & -10 & -3 \\\\\n -1 & -2 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-16.334,-3.333-1.007 i,-3.333+1.007 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 8, 5],\n [6, -10, -3],\n [-1, -2, -5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -9 & 9 & -4 & -2 & -1 & -8 & 3 \\\\\n 5 & -6 & 3 & 6 & -9 & -9 & 5 \\\\\n -6 & 8 & -6 & 10 & 7 & -4 & 4 \\\\\n -6 & 8 & -5 & -3 & 4 & -6 & 6 \\\\\n -7 & -3 & 10 & 9 & 9 & 0 & -4 \\\\\n 4 & -1 & 3 & -3 & -2 & 9 & 3 \\\\\n 0 & 1 & 4 & 9 & -1 & 6 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-9, 9, -4, -2, -1, -8, 3],\n [5, -6, 3, 6, -9, -9, 5],\n [-6, 8, -6, 10, 7, -4, 4],\n [-6, 8, -5, -3, 4, -6, 6],\n [-7, -3, 10, 9, 9, 0, -4],\n [4, -1, 3, -3, -2, 9, 3],\n [0, 1, 4, 9, -1, 6, 7]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{2} \\\\\n \\frac{19}{2} \\\\\n -\\frac{17}{2} \\\\\n -8 \\\\\n \\frac{15}{2} \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{2} \\\\\n -\\frac{11}{2} \\\\\n -\\frac{17}{2} \\\\\n \\frac{7}{2} \\\\\n 6 \\\\\n -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{126}{\\sqrt{871537}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2)],\n [(19/2)],\n [-(17/2)],\n [-8],\n [(15/2)],\n [-(3/2)]]).squeeze()\nb = np.array([\n [-(7/2)],\n [-(11/2)],\n [-(17/2)],\n [(7/2)],\n [6],\n [-(9/2)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & 1 & -2 \\\\\n 2 & 1 & 2 \\\\\n 0 & -2 & 1 \\\\\n 3 & 1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.03 \\\\\n -0.37 \\\\\n -0.1 \\\\\n -0.69 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.124 \\\\\n -0.005 \\\\\n -0.135 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1, -2],\n [2, 1, 2],\n [0, -2, 1],\n [3, 1, 1]])\nb = np.array([\n [-0.03],\n [-0.37],\n [-0.1],\n [-0.69]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -8 & 1 & -1 & 5 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 1, -1, 5, -1]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{1}{3},\\frac{1}{3},-\\frac{1}{3}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [2],\n [1]]).squeeze()\nb = np.array([\n [2],\n [-2],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 2 \\\\\n -3 \\\\\n 3 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{4 \\sqrt{2}} \\\\\n \\frac{1}{2 \\sqrt{2}} \\\\\n -\\frac{3}{4 \\sqrt{2}} \\\\\n \\frac{3}{4 \\sqrt{2}} \\\\\n -\\frac{1}{4 \\sqrt{2}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [2],\n [-3],\n [3],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{125}{32}, \\frac{65}{16}}$ to the line $\\frac{47 x}{32}-\\frac{55 y}{32}-\\frac{47}{16}=0$.", - "Output Answer": [ - "$\\frac{4283}{32 \\sqrt{5234}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (125/32), (65/16)\nline = Poly(((47*x)/32)-((55*y)/32)-(47/16), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 0 & 4 & -5 \\\\\n 3 & 3 & 1 \\\\\n -5 & -2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{4}{41} & -\\frac{18}{41} & -\\frac{19}{41} \\\\\n -\\frac{1}{41} & \\frac{25}{41} & \\frac{15}{41} \\\\\n -\\frac{9}{41} & \\frac{20}{41} & \\frac{12}{41} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 4, -5],\n [3, 3, 1],\n [-5, -2, -2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{59}{7} & -\\frac{12}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{30}{7} & \\frac{34}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{29}{7} & \\frac{22}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(59/7), -(12/7)]])\nb = np.array([\n [(30/7), (34/7)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $3$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & 10 & 7 \\\\\n -3 & 1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 12 & 30 & 21 \\\\\n -9 & 3 & 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 10, 7],\n [-3, 1, 3]])\nprint(a * 3)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 10 & -\\frac{15}{2} & -8 \\\\\n \\frac{9}{2} & -\\frac{3}{2} & -2 \\\\\n \\frac{1}{2} & -6 & 3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{2} & 7 & -4 \\\\\n \\frac{15}{2} & \\frac{15}{2} & \\frac{19}{2} \\\\\n \\frac{5}{2} & \\frac{11}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{25}{2} & -\\frac{29}{2} & -4 \\\\\n -3 & -9 & -\\frac{23}{2} \\\\\n -2 & -\\frac{23}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -(15/2), -8],\n [(9/2), -(3/2), -2],\n [(1/2), -6, 3]])\nb = np.array([\n [-(5/2), 7, -4],\n [(15/2), (15/2), (19/2)],\n [(5/2), (11/2), (1/2)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{2}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & -1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & \\frac{1}{2} & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1, -2]])\nprint(a * -(1/2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{19}{5}, \\frac{2}{5}, 1}$ to the plane $\\frac{7 x}{5}+2 y-\\frac{13 z}{5}-\\frac{21}{5}=0$.", - "Output Answer": [ - "$\\frac{283}{5 \\sqrt{318}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(19/5), (2/5), 1\nplane = Poly(((7*x)/5)+2*y-((13*z)/5)-(21/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\pi \\\\\n -2 \\pi \\\\\n -2 \\pi \\\\\n -3 \\pi \\\\\n -3 \\pi \\\\\n \\pi \\\\\n -2 \\pi \\\\\n 0 \\\\\n \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\pi \\\\\n 0 \\\\\n \\pi \\\\\n -2 \\pi \\\\\n -2 \\pi \\\\\n 0 \\\\\n 2 \\pi \\\\\n \\pi \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{2} \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-math.pi],\n [-2*math.pi],\n [-2*math.pi],\n [-3*math.pi],\n [-3*math.pi],\n [math.pi],\n [-2*math.pi],\n [0],\n [math.pi]])\nb = np.array([\n [3*math.pi],\n [0],\n [math.pi],\n [-2*math.pi],\n [-2*math.pi],\n [0],\n [2*math.pi],\n [math.pi],\n [0]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{19}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/5)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{19}{2} & \\frac{15}{4} & -\\frac{27}{4} & \\frac{7}{2} \\\\\n -\\frac{3}{2} & 0 & \\frac{17}{2} & \\frac{7}{2} \\\\\n -\\frac{5}{2} & -\\frac{9}{4} & \\frac{23}{4} & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{21}{4} & \\frac{31}{4} & -\\frac{5}{2} & \\frac{7}{2} \\\\\n 2 & -\\frac{33}{4} & -\\frac{11}{2} & -\\frac{23}{4} \\\\\n -\\frac{31}{4} & -7 & \\frac{5}{4} & \\frac{13}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{17}{4} & \\frac{23}{2} & -\\frac{37}{4} & 7 \\\\\n \\frac{1}{2} & -\\frac{33}{4} & 3 & -\\frac{9}{4} \\\\\n -\\frac{41}{4} & -\\frac{37}{4} & 7 & -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/2), (15/4), -(27/4), (7/2)],\n [-(3/2), 0, (17/2), (7/2)],\n [-(5/2), -(9/4), (23/4), -(7/2)]])\nb = np.array([\n [(21/4), (31/4), -(5/2), (7/2)],\n [2, -(33/4), -(11/2), -(23/4)],\n [-(31/4), -7, (5/4), (13/4)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 9 \\\\\n -\\frac{46}{5} \\\\\n -\\frac{1}{5} \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{27}{5} \\\\\n -\\frac{36}{5} \\\\\n -\\frac{7}{5} \\\\\n 2 \\\\\n \\frac{9}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{273}{\\sqrt{14357585}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [9],\n [-(46/5)],\n [-(1/5)],\n [8]]).squeeze()\nb = np.array([\n [(27/5)],\n [-(36/5)],\n [-(7/5)],\n [2],\n [(9/5)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n \\frac{7}{3} \\\\\n \\frac{29}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{28}{3} \\\\\n \\frac{14}{3} \\\\\n -\\frac{19}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{539}{9} \\\\\n \\frac{1325}{9} \\\\\n \\frac{182}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [(7/3)],\n [(29/3)]])\nb = np.array([\n [(28/3)],\n [(14/3)],\n [-(19/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -1 \\\\\n 0 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1],\n [0, -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n -1 \\\\\n -2 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{3} \\\\\n -\\frac{1}{3} \\\\\n -\\frac{1}{3} \\\\\n -\\frac{2}{3} \\\\\n -\\frac{1}{3} \\\\\n -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [-1],\n [-2],\n [-1],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [1],\n [0],\n [-1],\n [0],\n [0]]).squeeze()\nb = np.array([\n [0],\n [1],\n [0],\n [0],\n [1],\n [-1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{23}{5}, 5, \\frac{3}{5}}$ to the plane $-\\frac{11 x}{5}-\\frac{21 y}{5}-\\frac{19 z}{5}-\\frac{9}{5}=0$.", - "Output Answer": [ - "$\\frac{176}{\\sqrt{923}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (23/5), 5, (3/5)\nplane = Poly(-((11*x)/5)-((21*y)/5)-((19*z)/5)-(9/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{199}{25} & -\\frac{263}{100} & \\frac{409}{50} \\\\\n \\frac{123}{50} & \\frac{191}{50} & -\\frac{591}{100} \\\\\n -\\frac{243}{25} & \\frac{17}{4} & \\frac{433}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{511 x^2}{25}-\\frac{2435189 x}{10000}+\\frac{94682227}{125000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(199/25), -(263/100), (409/50)],\n [(123/50), (191/50), -(591/100)],\n [-(243/25), (17/4), (433/50)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 5 & 8 & -9 & -9 \\\\\n 0 & 4 & -3 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{12.,15.,20.,0.\\}, \\{108.,-45.,0.,20.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, 8, -9, -9],\n [0, 4, -3, 9]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-4,\\frac{7}{2},\\frac{9}{2}\\right\\}, \\left\\{-\\frac{5}{2},2,-\\frac{5}{2}\\right\\}, \\left\\{\\frac{1}{2},\\frac{9}{2},-2\\right\\}}$.", - "Output Answer": [ - "$67 x-87 y+33 z+424=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, (7/2), (9/2)],\n [-(5/2), 2, -(5/2)],\n [(1/2), (9/2), -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{45}{7} \\\\\n -\\frac{15}{7} \\\\\n \\frac{68}{7} \\\\\n \\frac{64}{7} \\\\\n -\\frac{43}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{235}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(45/7)],\n [-(15/7)],\n [(68/7)],\n [(64/7)],\n [-(43/7)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{5} \\\\\n \\frac{11}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{3}{5} \\\\\n -\\frac{13}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{219}{445},\\frac{949}{445}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/5)],\n [(11/5)]]).squeeze()\nb = np.array([\n [(3/5)],\n [-(13/5)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{6}{7} & -5 & -\\frac{34}{7} & -\\frac{43}{7} \\\\\n -\\frac{65}{7} & \\frac{22}{7} & -\\frac{2}{7} & \\frac{61}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{29}{7} & -\\frac{25}{7} & -7 & \\frac{54}{7} \\\\\n -\\frac{45}{7} & \\frac{68}{7} & \\frac{20}{7} & \\frac{24}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{23}{7} & -\\frac{60}{7} & -\\frac{83}{7} & \\frac{11}{7} \\\\\n -\\frac{110}{7} & \\frac{90}{7} & \\frac{18}{7} & \\frac{85}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(6/7), -5, -(34/7), -(43/7)],\n [-(65/7), (22/7), -(2/7), (61/7)]])\nb = np.array([\n [(29/7), -(25/7), -7, (54/7)],\n [-(45/7), (68/7), (20/7), (24/7)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & 9 \\\\\n -8 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-7 x+72$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 9],\n [-8, 0]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 2 & -6 & 9 & 0 & -9 & 2 \\\\\n -6 & 9 & -7 & -6 & -5 & -5 \\\\\n -9 & -5 & 3 & -2 & 4 & -3 \\\\\n -4 & 8 & 7 & -5 & -4 & 7 \\\\\n -7 & 6 & 6 & -1 & 7 & -10 \\\\\n 6 & 2 & 1 & -4 & 7 & 8 \\\\\n 5 & -9 & -6 & 4 & -1 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, -6, 9, 0, -9, 2],\n [-6, 9, -7, -6, -5, -5],\n [-9, -5, 3, -2, 4, -3],\n [-4, 8, 7, -5, -4, 7],\n [-7, 6, 6, -1, 7, -10],\n [6, 2, 1, -4, 7, 8],\n [5, -9, -6, 4, -1, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -3 & 0 \\\\\n 4 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{3} & 0 \\\\\n \\frac{4}{3} & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0],\n [4, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 8 \\\\\n -4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [8],\n [-4],\n [-2]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & 0 & 1 \\\\\n -5 & 3 & 0 \\\\\n -2 & -5 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{6}{43} & -\\frac{5}{43} & -\\frac{3}{43} \\\\\n -\\frac{10}{43} & \\frac{6}{43} & -\\frac{5}{43} \\\\\n \\frac{31}{43} & -\\frac{10}{43} & -\\frac{6}{43} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, 1],\n [-5, 3, 0],\n [-2, -5, -2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{7}{9} \\\\\n -\\frac{13}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{88}{9} \\\\\n -\\frac{19}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -9 \\\\\n -\\frac{32}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/9)],\n [-(13/3)]])\nb = np.array([\n [-(88/9)],\n [-(19/3)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -6 & -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 9 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 3 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -9]])\nb = np.array([\n [9, 9]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{39}{5} & \\frac{14}{5} \\\\\n \\frac{79}{10} & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{79 x}{5}+\\frac{1007}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(39/5), (14/5)],\n [(79/10), 8]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{23}{4} & \\frac{3}{2} & -\\frac{25}{4} \\\\\n -\\frac{37}{4} & -6 & \\frac{7}{2} \\\\\n \\frac{23}{4} & -\\frac{3}{2} & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-5.431,1.091\\, -5.654 i,1.091\\, +5.654 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/4), (3/2), -(25/4)],\n [-(37/4), -6, (7/2)],\n [(23/4), -(3/2), -3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & -8 \\\\\n 4 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{8} i \\left(\\sqrt{79}-7 i\\right),1\\right\\}, \\left\\{-\\frac{1}{8} i \\left(\\sqrt{79}+7 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -8],\n [4, 2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & -7 \\\\\n 5 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+4 x+14$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -7],\n [5, -7]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{9}{64}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & 1 & 7 \\\\\n -3 & -3 & -7 \\\\\n 3 & 10 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{27}{64} & \\frac{9}{64} & \\frac{63}{64} \\\\\n -\\frac{27}{64} & -\\frac{27}{64} & -\\frac{63}{64} \\\\\n \\frac{27}{64} & \\frac{45}{32} & \\frac{27}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1, 7],\n [-3, -3, -7],\n [3, 10, 3]])\nprint(a * (9/64))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -4 & -\\frac{5}{4} & \\frac{21}{4} \\\\\n \\frac{9}{4} & -10 & -\\frac{7}{4} \\\\\n \\frac{5}{2} & -\\frac{39}{4} & \\frac{15}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-11.436,-4.014,8.95\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -(5/4), (21/4)],\n [(9/4), -10, -(7/4)],\n [(5/2), -(39/4), (15/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 0 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 2 & -4 \\\\\n 0 & 0 \\\\\n -3 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [0],\n [3]])\nb = np.array([\n [-1, 2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, \\frac{13}{5}}$ to the line $\\frac{8 x}{5}+\\frac{8 y}{5}-\\frac{7}{5}=0$.", - "Output Answer": [ - "$\\frac{51}{40 \\sqrt{2}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, (13/5)\nline = Poly(((8*x)/5)+((8*y)/5)-(7/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -5 & -7 \\\\\n 5 & -10 \\\\\n -1 & -7 \\\\\n 2 & 6 \\\\\n 7 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, -7],\n [5, -10],\n [-1, -7],\n [2, 6],\n [7, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [-1],\n [1],\n [1],\n [1]]).squeeze()\nb = np.array([\n [0],\n [0],\n [-1],\n [0],\n [-1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -3 & 7 & 8 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 7, 8, -5]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,-2,1\\}, \\{-2,-4,2\\}, \\{-2,-4,2\\}}$.", - "Output Answer": [ - "$\\text{Symbol}[\\text{True},0]$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -2, 1],\n [-2, -4, 2],\n [-2, -4, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 3 & 3 & 1 & 1 \\\\\n 2 & -2 & -1 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -1 & -2 & 3 \\\\\n -1 & 2 & -1 \\\\\n 0 & -3 & 3 \\\\\n 2 & -3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -4 & -6 & 8 \\\\\n -2 & -2 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3, 1, 1],\n [2, -2, -1, -1]])\nb = np.array([\n [-1, -2, 3],\n [-1, 2, -1],\n [0, -3, 3],\n [2, -3, -1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [0],\n [-1],\n [1],\n [-1]]).squeeze()\nb = np.array([\n [1],\n [1],\n [0],\n [-1],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & 1 \\\\\n 0 & -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{-\\frac{2}{23},1\\right\\}, \\{1,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1],\n [0, -(17/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{7}{6} & -\\frac{4}{3} & \\frac{7}{6} & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{7}{6} & -\\frac{4}{3} & \\frac{7}{6} & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1]])\nb = np.array([\n [-(7/6), -(4/3), (7/6), (2/3)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{4}{5} & -\\frac{23}{5} & -3 \\\\\n 0 & \\frac{42}{5} & \\frac{32}{5} \\\\\n \\frac{32}{5} & \\frac{48}{5} & \\frac{36}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.617,1.127,1.\\}, \\{-0.17,-0.706,1.\\}, \\{1.115,-1.182,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/5), -(23/5), -3],\n [0, (42/5), (32/5)],\n [(32/5), (48/5), (36/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 7 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -8 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-42$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [7],\n [0]])\nb = np.array([\n [7],\n [-8],\n [4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 0 & 2 & 1 & 0 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 1 & 2 & -3 \\\\\n -3 & 0 & -2 \\\\\n -1 & -2 & -2 \\\\\n 0 & 2 & 0 \\\\\n -3 & 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -13 & -2 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, 1, 0, 2]])\nb = np.array([\n [1, 2, -3],\n [-3, 0, -2],\n [-1, -2, -2],\n [0, 2, 0],\n [-3, 0, 2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${4, -5, 4}$ to the plane $3 x-4 y-2 z+2=0$.", - "Output Answer": [ - "$\\frac{26}{\\sqrt{29}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 4, -5, 4\nplane = Poly(3*x-4*y-2*z+2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n 2 \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -\\frac{3}{2} \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{4}{17},-\\frac{6}{17},-\\frac{4}{17}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2)],\n [2],\n [-(5/2)]]).squeeze()\nb = np.array([\n [1],\n [-(3/2)],\n [-1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -4 \\\\\n 9 \\\\\n -9 \\\\\n -9 \\\\\n 7 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n -5 \\\\\n 4 \\\\\n -6 \\\\\n -3 \\\\\n -7 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{317}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-4],\n [9],\n [-9],\n [-9],\n [7],\n [0]])\nb = np.array([\n [-10],\n [-5],\n [4],\n [-6],\n [-3],\n [-7],\n [7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n \\frac{13}{16} \\\\\n -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{32}{\\sqrt{1337}} \\\\\n \\frac{13}{\\sqrt{1337}} \\\\\n -\\frac{12}{\\sqrt{1337}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [(13/16)],\n [-(3/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 10 \\\\\n 8 \\\\\n 9 \\\\\n -7 \\\\\n 1 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [10],\n [8],\n [9],\n [-7],\n [1],\n [7]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 8 \\\\\n 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 11 \\\\\n -21 \\\\\n 56 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [1],\n [-1]])\nb = np.array([\n [0],\n [8],\n [3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -2 & 0 & 1 & 0 & -1 \\\\\n 0 & 2 & 2 & 2 & 0 \\\\\n 0 & 3 & 3 & 2 & 1 \\\\\n -1 & -2 & -2 & 2 & -3 \\\\\n 0 & 0 & 0 & -2 & 2 \\\\\n 1 & 1 & 3 & 3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.73 \\\\\n 0.5 \\\\\n 0.78 \\\\\n 0.93 \\\\\n -2.95 \\\\\n 1.56 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.713 \\\\\n -1.587 \\\\\n 2.474 \\\\\n -0.314 \\\\\n -1.682 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, 1, 0, -1],\n [0, 2, 2, 2, 0],\n [0, 3, 3, 2, 1],\n [-1, -2, -2, 2, -3],\n [0, 0, 0, -2, 2],\n [1, 1, 3, 3, 3]])\nb = np.array([\n [0.73],\n [0.5],\n [0.78],\n [0.93],\n [-2.95],\n [1.56]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{85}{\\sqrt{8989}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-5]]).squeeze()\nb = np.array([\n [10],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -7 & 4 & -8 \\\\\n -7 & -1 & 7 \\\\\n -8 & 0 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, 4, -8],\n [-7, -1, 7],\n [-8, 0, -10]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{60}{7} & \\frac{1}{7} \\\\\n -\\frac{66}{7} & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{74 x}{7}+\\frac{906}{49}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(60/7), (1/7)],\n [-(66/7), 2]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & -1 & -5 \\\\\n 2 & 6 & 4 \\\\\n 0 & -8 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-3.986,-1.364,1.\\}, \\{0.493\\, -0.28 i,-0.443+0.614 i,1.\\}, \\{0.493\\, +0.28 i,-0.443-0.614 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -1, -5],\n [2, 6, 4],\n [0, -8, -2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 5 & 9 & -5 & 1 & 5 & 3 \\\\\n 1 & 5 & 2 & -6 & 5 & -8 \\\\\n 5 & 1 & -8 & 6 & 4 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & -\\frac{31}{12} & \\frac{33}{8} & -\\frac{245}{36} \\\\\n 0 & 1 & 0 & \\frac{1}{4} & -\\frac{5}{8} & \\frac{19}{12} \\\\\n 0 & 0 & 1 & -\\frac{7}{3} & 2 & -\\frac{41}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, 9, -5, 1, 5, 3],\n [1, 5, 2, -6, 5, -8],\n [5, 1, -8, 6, 4, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 7 \\\\\n -7 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 7 \\\\\n -8 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [7],\n [-7],\n [8]])\nb = np.array([\n [-4],\n [7],\n [-8],\n [4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 9 \\\\\n 7 \\\\\n 5 \\\\\n 3 \\\\\n -4 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -6 \\\\\n -8 \\\\\n -2 \\\\\n -3 \\\\\n -3 \\\\\n -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-161$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [9],\n [7],\n [5],\n [3],\n [-4],\n [5]])\nb = np.array([\n [3],\n [-6],\n [-8],\n [-2],\n [-3],\n [-3],\n [-10]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{48}{5} & \\frac{1}{5} \\\\\n -\\frac{21}{5} & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{23 x}{5}-\\frac{1179}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(48/5), (1/5)],\n [-(21/5), -5]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n 8 & -6 & 0 & 3 \\\\\n -6 & -3 & 8 & 6 \\\\\n -7 & 9 & 9 & 0 \\\\\n 9 & -5 & -5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -6, 0, 3],\n [-6, -3, 8, 6],\n [-7, 9, 9, 0],\n [9, -5, -5, -4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & -1 & 2 & 2 \\\\\n -2 & -2 & -3 & 0 \\\\\n -2 & -3 & 2 & 3 \\\\\n 0 & -3 & 3 & 3 \\\\\n 2 & 3 & 2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.75 \\\\\n 2.16 \\\\\n 1.72 \\\\\n 0.82 \\\\\n -0.72 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.617 \\\\\n -1.259 \\\\\n 0.57 \\\\\n -1.517 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1, 2, 2],\n [-2, -2, -3, 0],\n [-2, -3, 2, 3],\n [0, -3, 3, 3],\n [2, 3, 2, -2]])\nb = np.array([\n [-1.75],\n [2.16],\n [1.72],\n [0.82],\n [-0.72]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 4 & 4 \\\\\n -3 & 3 & -2 \\\\\n 1 & 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$16$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 4, 4],\n [-3, 3, -2],\n [1, 0, 2]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, \\frac{4}{3}}$ to the line $-\\frac{10 x}{3}+3 y-1=0$.", - "Output Answer": [ - "$\\frac{29}{\\sqrt{181}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, (4/3)\nline = Poly(-((10*x)/3)+3*y-1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & -3 & -8 \\\\\n -2 & 5 & 0 \\\\\n -5 & 8 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-4.255,2.6,12.654\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -3, -8],\n [-2, 5, 0],\n [-5, 8, -2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & 3 \\\\\n 1 & -2 \\\\\n 1 & 3 \\\\\n 0 & 3 \\\\\n -1 & -2 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.05 \\\\\n 1.74 \\\\\n -2.9 \\\\\n -2.55 \\\\\n 0.42 \\\\\n 2.47 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.163 \\\\\n -0.69 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 3],\n [1, -2],\n [1, 3],\n [0, 3],\n [-1, -2],\n [0, 1]])\nb = np.array([\n [-2.05],\n [1.74],\n [-2.9],\n [-2.55],\n [0.42],\n [2.47]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{2} & 3 \\\\\n -\\frac{1}{2} & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & -2 \\\\\n \\frac{1}{3} & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/2), 3],\n [-(1/2), 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & -\\frac{11}{2} & \\frac{3}{2} \\\\\n -2 & -\\frac{5}{2} & -\\frac{13}{2} \\\\\n 10 & -\\frac{19}{2} & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.127,-1.743,1.\\}, \\{0.472,-0.485,1.\\}, \\{0.902,2.015,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -(11/2), (3/2)],\n [-2, -(5/2), -(13/2)],\n [10, -(19/2), (7/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -3 & \\frac{5}{2} \\\\\n -2 & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 3 & 10 \\\\\n -8 & 15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, (5/2)],\n [-2, 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{5} \\\\\n \\frac{12}{5} \\\\\n \\frac{14}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{\\sqrt{349}} \\\\\n \\frac{12}{\\sqrt{349}} \\\\\n \\frac{14}{\\sqrt{349}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/5)],\n [(12/5)],\n [(14/5)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9.212 \\\\\n -0.931 \\\\\n -2.858 \\\\\n -8.188 \\\\\n 0.442 \\\\\n -4.165 \\\\\n 7.783 \\\\\n 5.148 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4.915 \\\\\n 3.04 \\\\\n 4.028 \\\\\n 7.158 \\\\\n 6.703 \\\\\n -1.987 \\\\\n 7.927 \\\\\n -5.447 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-73.3357$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9.212],\n [-0.931],\n [-2.858],\n [-8.188],\n [0.442],\n [-4.165],\n [7.783],\n [5.148]])\nb = np.array([\n [4.915],\n [3.04],\n [4.028],\n [7.158],\n [6.703],\n [-1.987],\n [7.927],\n [-5.447]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & 9 \\\\\n 6 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+3 x-82$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 9],\n [6, -7]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -4 \\\\\n 4 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -4 \\\\\n -7 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-34$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-4],\n [4],\n [4]])\nb = np.array([\n [7],\n [-4],\n [-7],\n [5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 4 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 0 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -8 \\\\\n -7 \\\\\n 36 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [4],\n [3]])\nb = np.array([\n [-9],\n [0],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{29}{4} & -8 \\\\\n \\frac{15}{4} & -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{-\\frac{2}{15} \\left(7-i \\sqrt{71}\\right),1\\right\\}, \\left\\{-\\frac{2}{15} \\left(7+i \\sqrt{71}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/4), -8],\n [(15/4), -(1/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 1 & -\\frac{5}{2} \\\\\n -3 & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{17}{2} & 0 \\\\\n 0 & \\frac{17}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(5/2)],\n [-3, -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -1 & 9 & 8 \\\\\n 0 & -5 & -9 \\\\\n 8 & -10 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-12 x^2+113 x-268$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 9, 8],\n [0, -5, -9],\n [8, -10, -6]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & \\frac{9}{2} & -\\frac{5}{2} \\\\\n -\\frac{3}{2} & -\\frac{3}{2} & \\frac{3}{2} \\\\\n \\frac{1}{2} & -\\frac{3}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{3}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, (9/2), -(5/2)],\n [-(3/2), -(3/2), (3/2)],\n [(1/2), -(3/2), (1/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -4 & 7 & -6 \\\\\n -4 & -8 & 4 \\\\\n 8 & -9 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-5.702,-5.149-10.333 i,-5.149+10.333 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 7, -6],\n [-4, -8, 4],\n [8, -9, -4]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{219}{100} & -\\frac{639}{100} & \\frac{149}{100} & -\\frac{911}{100} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{3}{50} & -\\frac{43}{100} & -\\frac{443}{100} & -\\frac{61}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{213}{100} & -\\frac{341}{50} & -\\frac{147}{50} & -\\frac{243}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(219/100), -(639/100), (149/100), -(911/100)]])\nb = np.array([\n [-(3/50), -(43/100), -(443/100), -(61/100)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 7 \\\\\n 5 \\\\\n 7 \\\\\n -6 \\\\\n -5 \\\\\n -4 \\\\\n 0 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 8 \\\\\n 5 \\\\\n 0 \\\\\n 0 \\\\\n 7 \\\\\n 0 \\\\\n -2 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{511}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [7],\n [5],\n [7],\n [-6],\n [-5],\n [-4],\n [0],\n [-8]])\nb = np.array([\n [5],\n [8],\n [5],\n [0],\n [0],\n [7],\n [0],\n [-2],\n [7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{146}{25} & \\frac{23}{20} \\\\\n \\frac{1}{10} & -\\frac{69}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{223 x}{50}-\\frac{40871}{5000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(146/25), (23/20)],\n [(1/10), -(69/50)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [5]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{2,-2,2\\}, \\{5,2,-2\\}, \\{-4,-2,4\\}}$.", - "Output Answer": [ - "$4 x+9 y+12 z-14=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, -2, 2],\n [5, 2, -2],\n [-4, -2, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -8 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -6 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 34 \\\\\n -4 \\\\\n 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-8],\n [3]])\nb = np.array([\n [0],\n [-6],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -6 \\\\\n 1 \\\\\n -8 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -3 \\\\\n -9 \\\\\n 6 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-43$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-6],\n [1],\n [-8],\n [-6]])\nb = np.array([\n [-4],\n [-3],\n [-9],\n [6],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{2}{5} \\\\\n -6 \\\\\n \\frac{38}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{27}{5} \\\\\n \\frac{18}{5} \\\\\n \\frac{16}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1164}{25} \\\\\n \\frac{994}{25} \\\\\n \\frac{846}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/5)],\n [-6],\n [(38/5)]])\nb = np.array([\n [(27/5)],\n [(18/5)],\n [(16/5)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & 4 & 0 \\\\\n 4 & 1 & 5 \\\\\n -2 & 3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-124$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 4, 0],\n [4, 1, 5],\n [-2, 3, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -6 & -9 & -6 & 3 & -9 & 10 & 5 \\\\\n -4 & -6 & 2 & 3 & -7 & -10 & -7 \\\\\n 5 & -6 & -8 & -10 & 10 & -3 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & -\\frac{34}{27} & \\frac{46}{27} & -\\frac{187}{81} & -\\frac{20}{81} \\\\\n 0 & 1 & 0 & \\frac{32}{81} & -\\frac{2}{81} & \\frac{554}{243} & \\frac{184}{243} \\\\\n 0 & 0 & 1 & \\frac{1}{6} & -\\frac{1}{6} & -\\frac{25}{9} & -\\frac{31}{18} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-6, -9, -6, 3, -9, 10, 5],\n [-4, -6, 2, 3, -7, -10, -7],\n [5, -6, -8, -10, 10, -3, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -3 \\\\\n 8 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n -7 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{559}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-3],\n [8],\n [9]])\nb = np.array([\n [-1],\n [0],\n [-7],\n [-8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 9 & 7 & -9 & 9 & 2 \\\\\n -5 & 0 & 10 & -4 & 8 \\\\\n -2 & -6 & -4 & 8 & 5 \\\\\n 7 & 5 & 5 & 7 & 8 \\\\\n -8 & -2 & -10 & 0 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, 7, -9, 9, 2],\n [-5, 0, 10, -4, 8],\n [-2, -6, -4, 8, 5],\n [7, 5, 5, 7, 8],\n [-8, -2, -10, 0, -4]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{10}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 10 \\\\\n -10 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{21}{10} & 7 \\\\\n -7 & -\\frac{21}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 10],\n [-10, -3]])\nprint(a * (7/10))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -4 & -2 \\\\\n 1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -2],\n [1, 2]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n -\\frac{13}{2} \\\\\n -8 \\\\\n 5 \\\\\n -2 \\\\\n 3 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$34$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2)],\n [-(13/2)],\n [-8],\n [5],\n [-2],\n [3],\n [7]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{5}{2}, -4, 2}$ to the plane $3 x-\\frac{3 y}{2}-\\frac{3 z}{2}-4=0$.", - "Output Answer": [ - "$\\frac{17}{3 \\sqrt{6}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(5/2), -4, 2\nplane = Poly(3*x-((3*y)/2)-((3*z)/2)-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{27}{10} \\\\\n -1 \\\\\n -\\frac{6}{5} \\\\\n \\frac{7}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{27}{\\sqrt{1022}} \\\\\n -5 \\sqrt{\\frac{2}{511}} \\\\\n -6 \\sqrt{\\frac{2}{511}} \\\\\n \\sqrt{\\frac{7}{146}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(27/10)],\n [-1],\n [-(6/5)],\n [(7/10)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 3 & -3 \\\\\n 1 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 0 & 2 & 0 & -3 \\\\\n 2 & -3 & 1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -6 & 15 & -3 & -12 \\\\\n -2 & 5 & -1 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -3],\n [1, -1]])\nb = np.array([\n [0, 2, 0, -3],\n [2, -3, 1, 1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{11}{4},-\\frac{5}{4},\\frac{5}{2}\\right\\}, \\left\\{-\\frac{7}{4},-\\frac{7}{4},\\frac{9}{4}\\right\\}, \\left\\{2,-\\frac{7}{4},-\\frac{11}{4}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{11}{\\sqrt{246}},-\\frac{5}{\\sqrt{246}},5 \\sqrt{\\frac{2}{123}}\\right\\}, \\left\\{50 \\sqrt{\\frac{5}{39729}},-\\frac{356}{\\sqrt{198645}},\\frac{97}{\\sqrt{198645}}\\right\\}, \\left\\{-5 \\sqrt{\\frac{5}{646}},-\\frac{29}{\\sqrt{3230}},-21 \\sqrt{\\frac{2}{1615}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-(11/4), -(5/4), (5/2)), (-(7/4), -(7/4), (9/4)), (2, -(7/4), -(11/4))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{64}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & 4 \\\\\n 3 & 3 \\\\\n -2 & 4 \\\\\n 10 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{32} & \\frac{1}{16} \\\\\n \\frac{3}{64} & \\frac{3}{64} \\\\\n -\\frac{1}{32} & \\frac{1}{16} \\\\\n \\frac{5}{32} & -\\frac{5}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 4],\n [3, 3],\n [-2, 4],\n [10, -10]])\nprint(a * (1/64))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 8 & -10 & 0 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.,0.,1.,0.\\}, \\{1.,0.,0.,2.\\}, \\{5.,4.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [8, -10, 0, -4]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{38}{5} \\\\\n \\frac{47}{5} \\\\\n -\\frac{31}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{47}{5} \\\\\n \\frac{11}{5} \\\\\n -\\frac{7}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{12}{25} \\\\\n -\\frac{1191}{25} \\\\\n -\\frac{1791}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(38/5)],\n [(47/5)],\n [-(31/5)]])\nb = np.array([\n [(47/5)],\n [(11/5)],\n [-(7/5)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{23}{8} & -7 & -\\frac{79}{8} & 4 \\\\\n -10 & \\frac{139}{16} & -\\frac{69}{8} & \\frac{5}{16} \\\\\n -\\frac{133}{16} & \\frac{11}{16} & \\frac{65}{8} & -\\frac{17}{16} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n \\frac{33}{16} & -\\frac{23}{8} & -\\frac{145}{16} & -\\frac{45}{16} \\\\\n \\frac{133}{16} & 2 & -8 & -\\frac{77}{8} \\\\\n -\\frac{5}{16} & -1 & -1 & -\\frac{147}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{13}{16} & -\\frac{33}{8} & -\\frac{13}{16} & \\frac{109}{16} \\\\\n -\\frac{293}{16} & \\frac{107}{16} & -\\frac{5}{8} & \\frac{159}{16} \\\\\n -8 & \\frac{27}{16} & \\frac{73}{8} & \\frac{65}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/8), -7, -(79/8), 4],\n [-10, (139/16), -(69/8), (5/16)],\n [-(133/16), (11/16), (65/8), -(17/16)]])\nb = np.array([\n [(33/16), -(23/8), -(145/16), -(45/16)],\n [(133/16), 2, -8, -(77/8)],\n [-(5/16), -1, -1, -(147/16)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{3} \\\\\n 5 \\\\\n 6 \\\\\n \\frac{7}{3} \\\\\n \\frac{23}{3} \\\\\n \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{23}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/3)],\n [5],\n [6],\n [(7/3)],\n [(23/3)],\n [(4/3)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 2 & 1 & 1 & 0 & -2 \\\\\n 2 & -1 & 0 & -1 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -2 & 3 & 2 \\\\\n -1 & 2 & 1 \\\\\n -2 & 0 & 0 \\\\\n 1 & -2 & 2 \\\\\n -3 & 0 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & 8 & 7 \\\\\n 2 & 6 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, 1, 0, -2],\n [2, -1, 0, -1, -2]])\nb = np.array([\n [-2, 3, 2],\n [-1, 2, 1],\n [-2, 0, 0],\n [1, -2, 2],\n [-3, 0, -1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{9}{5}, -\\frac{18}{5}, \\frac{3}{5}}$ to the plane $\\frac{11 x}{5}+\\frac{7 y}{5}+\\frac{18 z}{5}-\\frac{17}{5}=0$.", - "Output Answer": [ - "$\\frac{29 \\sqrt{\\frac{2}{247}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (9/5), -(18/5), (3/5)\nplane = Poly(((11*x)/5)+((7*y)/5)+((18*z)/5)-(17/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -2 & -1 & 3 & 0 \\\\\n 3 & -2 & 1 & -3 \\\\\n 1 & 0 & -3 & 1 \\\\\n 0 & -3 & -2 & -2 \\\\\n 1 & 1 & 1 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.54 \\\\\n -0.27 \\\\\n -2.4 \\\\\n 0.68 \\\\\n 1.16 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.686 \\\\\n 0.584 \\\\\n -0.151 \\\\\n -1.032 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1, 3, 0],\n [3, -2, 1, -3],\n [1, 0, -3, 1],\n [0, -3, -2, -2],\n [1, 1, 1, -2]])\nb = np.array([\n [-0.54],\n [-0.27],\n [-2.4],\n [0.68],\n [1.16]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 9 \\\\\n -3 \\\\\n -7 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$29$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [9],\n [-3],\n [-7],\n [0]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{5,\\frac{2}{3},-\\frac{11}{3}\\right\\}, \\left\\{\\frac{14}{3},\\frac{2}{3},\\frac{5}{3}\\right\\}, \\left\\{\\frac{11}{3},-\\frac{5}{3},-\\frac{10}{3}\\right\\}}$.", - "Output Answer": [ - "$-48 x+27 y-3 z+211=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [5, (2/3), -(11/3)],\n [(14/3), (2/3), (5/3)],\n [(11/3), -(5/3), -(10/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{11}{2} \\\\\n -8 \\\\\n -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{29}{3} \\\\\n \\frac{11}{3} \\\\\n -\\frac{23}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{607}{9} \\\\\n \\frac{469}{18} \\\\\n \\frac{195}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/2)],\n [-8],\n [-(5/3)]])\nb = np.array([\n [(29/3)],\n [(11/3)],\n [-(23/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{14}{5} & -2 \\\\\n -3 & -\\frac{26}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{5} \\left(-6-5 \\sqrt{22}\\right),\\frac{1}{5} \\left(5 \\sqrt{22}-6\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/5), -2],\n [-3, -(26/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 4 & -9 & 6 & 2 & -7 \\\\\n -4 & 4 & 5 & 0 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & -\\frac{69}{20} & -\\frac{2}{5} & -\\frac{2}{5} \\\\\n 0 & 1 & -\\frac{11}{5} & -\\frac{2}{5} & \\frac{3}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, -9, 6, 2, -7],\n [-4, 4, 5, 0, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 0 & -2 \\\\\n -2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -4 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2]])\nb = np.array([\n [0, -2],\n [-2, 1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -4 \\\\\n 5 \\\\\n 8 \\\\\n 6 \\\\\n -3 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{295}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-4],\n [5],\n [8],\n [6],\n [-3],\n [-9]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -1 \\\\\n -3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-1],\n [-3],\n [1]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -1 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 5 \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -17 \\\\\n -4 \\\\\n -41 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-1],\n [3]])\nb = np.array([\n [-6],\n [5],\n [2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-1$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 5 & 10 & -6 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -5 & -10 & 6 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 10, -6, -3]])\nprint(a * -1)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-1$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -4 & 9 & -1 \\\\\n 3 & 9 & 7 \\\\\n -9 & -9 & -5 \\\\\n -4 & -4 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 4 & -9 & 1 \\\\\n -3 & -9 & -7 \\\\\n 9 & 9 & 5 \\\\\n 4 & 4 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 9, -1],\n [3, 9, 7],\n [-9, -9, -5],\n [-4, -4, 4]])\nprint(a * -1)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & -5 \\\\\n -2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} \\left(7-\\sqrt{89}\\right),1\\right\\}, \\left\\{\\frac{1}{4} \\left(7+\\sqrt{89}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -5],\n [-2, -1]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & -1 & -2 & -1 \\\\\n 2 & 2 & 0 & -2 \\\\\n -3 & 0 & -3 & 0 \\\\\n -2 & -1 & 3 & 1 \\\\\n 2 & 0 & 0 & 1 \\\\\n 2 & 1 & -1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.11 \\\\\n -1.3 \\\\\n -2.13 \\\\\n -2.42 \\\\\n -0.96 \\\\\n 2.1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.775 \\\\\n -1.021 \\\\\n -0.406 \\\\\n -0.057 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, -2, -1],\n [2, 2, 0, -2],\n [-3, 0, -3, 0],\n [-2, -1, 3, 1],\n [2, 0, 0, 1],\n [2, 1, -1, 1]])\nb = np.array([\n [1.11],\n [-1.3],\n [-2.13],\n [-2.42],\n [-0.96],\n [2.1]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 9 & 1 & -2 \\\\\n 6 & 10 & -1 \\\\\n 7 & -8 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+15 x^2-14 x-179$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 1, -2],\n [6, 10, -1],\n [7, -8, -4]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & 3 & -3 \\\\\n -3 & 1 & 3 \\\\\n -1 & -2 & -1 \\\\\n 2 & 3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.92 \\\\\n -2.44 \\\\\n -0.37 \\\\\n 1.5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.105 \\\\\n 0.073 \\\\\n -0.562 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 3, -3],\n [-3, 1, 3],\n [-1, -2, -1],\n [2, 3, -3]])\nb = np.array([\n [1.92],\n [-2.44],\n [-0.37],\n [1.5]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -9 & -2 \\\\\n -7 & 4 \\\\\n 0 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, -2],\n [-7, 4],\n [0, 10]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -1 & 8 & 2 & 10 \\\\\n -1 & -3 & 1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & -\\frac{14}{11} & -\\frac{14}{11} \\\\\n 0 & 1 & \\frac{1}{11} & \\frac{12}{11} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-1, 8, 2, 10],\n [-1, -3, 1, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & -3 \\\\\n 8 & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{13 x}{2}+27$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -3],\n [8, (1/2)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & 7 \\\\\n -4 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(5-i \\sqrt{111}\\right),\\frac{1}{2} \\left(5+i \\sqrt{111}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 7],\n [-4, 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -4 \\\\\n -3 \\\\\n -1 \\\\\n -9 \\\\\n 10 \\\\\n -6 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -2 \\\\\n 2 \\\\\n -5 \\\\\n 6 \\\\\n -5 \\\\\n 3 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7 \\sqrt{17}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-4],\n [-3],\n [-1],\n [-9],\n [10],\n [-6],\n [-8]])\nb = np.array([\n [-8],\n [-2],\n [2],\n [-5],\n [6],\n [-5],\n [3],\n [-7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -6 \\\\\n -4 \\\\\n 4 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-6],\n [-4],\n [4],\n [5]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{111}{16} & \\frac{31}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{121}{16} & \\frac{23}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{29}{2} & \\frac{77}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(111/16), (31/16)]])\nb = np.array([\n [(121/16), (23/8)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & -3 & 4 \\\\\n 1 & 2 & -3 \\\\\n -2 & -2 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-22$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3, 4],\n [1, 2, -3],\n [-2, -2, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -0.773 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7.913 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-6.11675$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-0.773]])\nb = np.array([\n [7.913]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & 0 & -4 \\\\\n -4 & 3 & -3 \\\\\n -5 & 2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-46$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, -4],\n [-4, 3, -3],\n [-5, 2, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -7 & -5 & 10 \\\\\n -10 & 2 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & \\frac{25}{64} \\\\\n 0 & 1 & -\\frac{163}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, -5, 10],\n [-10, 2, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 5 & 5 & -1 \\\\\n 4 & 9 & 1 \\\\\n -1 & 0 & 0 \\\\\n 8 & 4 & -3 \\\\\n -7 & -4 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, 5, -1],\n [4, 9, 1],\n [-1, 0, 0],\n [8, 4, -3],\n [-7, -4, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -7 & 6 & 8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -2 & 5 & -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -5 & 1 & \\frac{27}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 6, 8]])\nb = np.array([\n [-2, 5, -(11/2)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & 3 & -8 \\\\\n -2 & -9 & -6 \\\\\n -2 & 1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-7.042-2.518 i,-7.042+2.518 i,9.083\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 3, -8],\n [-2, -9, -6],\n [-2, 1, -4]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -9 & 9 & 6 \\\\\n 4 & 8 & -9 \\\\\n -5 & -9 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-9.945-4.833 i,-9.945+4.833 i,13.889\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 9, 6],\n [4, 8, -9],\n [-5, -9, -5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & -8 & 0 \\\\\n 4 & 0 & 3 \\\\\n -4 & 6 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [1, -8, 0],\n [4, 0, 3],\n [-4, 6, 5]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 0 & 1 \\\\\n -3 & -2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -3 & -2 \\\\\n 6 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1],\n [-3, -2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 0 & 1 & 0 & -2 & -2 \\\\\n -1 & 1 & -2 & -3 & 1 \\\\\n -1 & -2 & -1 & -3 & 3 \\\\\n -2 & -3 & 2 & 1 & 3 \\\\\n 2 & -3 & 3 & -1 & -3 \\\\\n -2 & -1 & -1 & -3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.32 \\\\\n 0.41 \\\\\n 2.62 \\\\\n -1.56 \\\\\n 0.57 \\\\\n -1.27 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.263 \\\\\n -0.871 \\\\\n -1.226 \\\\\n 0.005 \\\\\n 0.276 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 0, -2, -2],\n [-1, 1, -2, -3, 1],\n [-1, -2, -1, -3, 3],\n [-2, -3, 2, 1, 3],\n [2, -3, 3, -1, -3],\n [-2, -1, -1, -3, -3]])\nb = np.array([\n [-1.32],\n [0.41],\n [2.62],\n [-1.56],\n [0.57],\n [-1.27]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{2} & -\\frac{21}{5} \\\\\n \\frac{21}{10} & -\\frac{6}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{231}{50}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2), -(21/5)],\n [(21/10), -(6/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{1}{\\sqrt{3}} \\\\\n -\\frac{16}{\\sqrt{3}} \\\\\n 2 \\sqrt{3} \\\\\n \\frac{10}{\\sqrt{3}} \\\\\n -4 \\sqrt{3} \\\\\n 2 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\sqrt{3} \\\\\n \\frac{8}{\\sqrt{3}} \\\\\n \\frac{14}{\\sqrt{3}} \\\\\n -2 \\sqrt{3} \\\\\n \\frac{8}{\\sqrt{3}} \\\\\n 2 \\sqrt{3} \\\\\n \\frac{11}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{194}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [-(1/(math.sqrt(3)))],\n [-(16/(math.sqrt(3)))],\n [2*math.sqrt(3)],\n [(10/(math.sqrt(3)))],\n [-4*math.sqrt(3)],\n [2*math.sqrt(3)]])\nb = np.array([\n [-4*math.sqrt(3)],\n [(8/(math.sqrt(3)))],\n [(14/(math.sqrt(3)))],\n [-2*math.sqrt(3)],\n [(8/(math.sqrt(3)))],\n [2*math.sqrt(3)],\n [(11/(math.sqrt(3)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{7}{6} & -\\frac{8}{3} & -\\frac{17}{6} \\\\\n \\frac{7}{3} & -\\frac{11}{6} & -\\frac{13}{3} \\\\\n \\frac{25}{6} & -5 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{5076}{8287} & \\frac{3636}{8287} & \\frac{1374}{8287} \\\\\n -\\frac{4404}{8287} & \\frac{2802}{8287} & -\\frac{336}{8287} \\\\\n -\\frac{870}{8287} & -\\frac{1140}{8287} & \\frac{882}{8287} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/6), -(8/3), -(17/6)],\n [(7/3), -(11/6), -(13/3)],\n [(25/6), -5, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{5}{\\sqrt{3}},0,-\\frac{4}{\\sqrt{3}}\\right\\}, \\left\\{\\frac{4}{\\sqrt{3}},\\frac{4}{\\sqrt{3}},\\frac{2}{\\sqrt{3}}\\right\\}, \\left\\{\\frac{4}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}},\\frac{4}{\\sqrt{3}}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{5}{\\sqrt{41}},0,-\\frac{4}{\\sqrt{41}}\\right\\}, \\left\\{\\frac{\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}}{\\sqrt{\\frac{16}{3}+\\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)^2+\\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)^2}},\\frac{4}{\\sqrt{3 \\left(\\frac{16}{3}+\\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)^2+\\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)^2\\right)}},\\frac{\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}}{\\sqrt{\\frac{16}{3}+\\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)^2+\\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)^2}}\\right\\}, \\left\\{\\frac{\\frac{48 \\sqrt{3}}{41}-\\frac{\\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right) \\left(-\\frac{4}{3}+\\frac{4 \\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}+\\frac{4 \\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}\\right)}{\\frac{16}{3}+\\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)^2+\\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)^2}}{\\sqrt{\\left(\\frac{1}{\\sqrt{3}}+\\frac{4 \\left(-\\frac{4}{3}+\\frac{4 \\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}+\\frac{4 \\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}\\right)}{\\sqrt{3} \\left(\\frac{16}{3}+\\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)^2+\\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)^2\\right)}\\right)^2+\\left(\\frac{60 \\sqrt{3}}{41}+\\frac{\\left(-\\frac{2}{\\sqrt{3}}-\\frac{16 \\sqrt{3}}{41}\\right) \\left(-\\frac{4}{3}+\\frac{4 \\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}+\\frac{4 \\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}\\right)}{\\frac{16}{3}+\\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)^2+\\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)^2}\\right)^2+\\left(\\frac{48 \\sqrt{3}}{41}+\\frac{\\left(-\\frac{4}{\\sqrt{3}}+\\frac{20 \\sqrt{3}}{41}\\right) \\left(-\\frac{4}{3}+\\frac{4 \\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}+\\frac{4 \\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}\\right)}{\\frac{16}{3}+\\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)^2+\\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)^2}\\right)^2}},\\frac{-\\frac{1}{\\sqrt{3}}-\\frac{4 \\left(-\\frac{4}{3}+\\frac{4 \\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}+\\frac{4 \\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}\\right)}{\\sqrt{3} \\left(\\frac{16}{3}+\\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)^2+\\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)^2\\right)}}{\\sqrt{\\left(\\frac{1}{\\sqrt{3}}+\\frac{4 \\left(-\\frac{4}{3}+\\frac{4 \\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}+\\frac{4 \\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}\\right)}{\\sqrt{3} \\left(\\frac{16}{3}+\\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)^2+\\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)^2\\right)}\\right)^2+\\left(\\frac{60 \\sqrt{3}}{41}+\\frac{\\left(-\\frac{2}{\\sqrt{3}}-\\frac{16 \\sqrt{3}}{41}\\right) \\left(-\\frac{4}{3}+\\frac{4 \\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}+\\frac{4 \\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}\\right)}{\\frac{16}{3}+\\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)^2+\\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)^2}\\right)^2+\\left(\\frac{48 \\sqrt{3}}{41}+\\frac{\\left(-\\frac{4}{\\sqrt{3}}+\\frac{20 \\sqrt{3}}{41}\\right) \\left(-\\frac{4}{3}+\\frac{4 \\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}+\\frac{4 \\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}\\right)}{\\frac{16}{3}+\\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)^2+\\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)^2}\\right)^2}},\\frac{\\frac{60 \\sqrt{3}}{41}-\\frac{\\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right) \\left(-\\frac{4}{3}+\\frac{4 \\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}+\\frac{4 \\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}\\right)}{\\frac{16}{3}+\\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)^2+\\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)^2}}{\\sqrt{\\left(\\frac{1}{\\sqrt{3}}+\\frac{4 \\left(-\\frac{4}{3}+\\frac{4 \\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}+\\frac{4 \\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}\\right)}{\\sqrt{3} \\left(\\frac{16}{3}+\\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)^2+\\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)^2\\right)}\\right)^2+\\left(\\frac{60 \\sqrt{3}}{41}+\\frac{\\left(-\\frac{2}{\\sqrt{3}}-\\frac{16 \\sqrt{3}}{41}\\right) \\left(-\\frac{4}{3}+\\frac{4 \\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}+\\frac{4 \\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}\\right)}{\\frac{16}{3}+\\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)^2+\\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)^2}\\right)^2+\\left(\\frac{48 \\sqrt{3}}{41}+\\frac{\\left(-\\frac{4}{\\sqrt{3}}+\\frac{20 \\sqrt{3}}{41}\\right) \\left(-\\frac{4}{3}+\\frac{4 \\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}+\\frac{4 \\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)}{\\sqrt{3}}\\right)}{\\frac{16}{3}+\\left(\\frac{4}{\\sqrt{3}}-\\frac{20 \\sqrt{3}}{41}\\right)^2+\\left(\\frac{2}{\\sqrt{3}}+\\frac{16 \\sqrt{3}}{41}\\right)^2}\\right)^2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((5/(math.sqrt(3))), 0, -(4/(math.sqrt(3)))), ((4/(math.sqrt(3))), (4/(math.sqrt(3))), (2/(math.sqrt(3)))), ((4/(math.sqrt(3))), -(1/(math.sqrt(3))), (4/(math.sqrt(3))))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{1}{5}, 0, 3}$ to the plane $-\\frac{23 x}{5}+\\frac{3 z}{5}+\\frac{9}{5}=0$.", - "Output Answer": [ - "$\\frac{113}{5 \\sqrt{538}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(1/5), 0, 3\nplane = Poly(-((23*x)/5)+((3*z)/5)+(9/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{23}{5} & -\\frac{22}{5} \\\\\n \\frac{7}{5} & \\frac{18}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{568}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/5), -(22/5)],\n [(7/5), (18/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -6 & 0 \\\\\n -7 & 10 \\\\\n -5 & 6 \\\\\n 7 & 1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 7 & -9 \\\\\n -1 & 4 \\\\\n 9 & -7 \\\\\n 6 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -13 & 9 \\\\\n -6 & 6 \\\\\n -14 & 13 \\\\\n 1 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 0],\n [-7, 10],\n [-5, 6],\n [7, 1]])\nb = np.array([\n [7, -9],\n [-1, 4],\n [9, -7],\n [6, 3]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{3} \\\\\n -\\frac{9}{2} \\\\\n -\\frac{17}{2} \\\\\n 9 \\\\\n \\frac{25}{6} \\\\\n -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3)],\n [-(9/2)],\n [-(17/2)],\n [9],\n [(25/6)],\n [-(11/3)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{22}{3} & 6 & -\\frac{5}{2} & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{5}{3} & -\\frac{1}{3} & \\frac{7}{6} & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 9 & \\frac{17}{3} & -\\frac{4}{3} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(22/3), 6, -(5/2), 2]])\nb = np.array([\n [(5/3), -(1/3), (7/6), -(5/2)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 0 & 3 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -8 & -9 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -8 & -6 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 3, 2]])\nb = np.array([\n [-8, -9, -2]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{16}{5} & -\\frac{22}{5} & -\\frac{17}{5} \\\\\n \\frac{19}{5} & \\frac{7}{5} & \\frac{16}{5} \\\\\n -\\frac{4}{5} & \\frac{9}{5} & \\frac{21}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{3}{1351} & \\frac{309}{1351} & -\\frac{233}{1351} \\\\\n -\\frac{463}{1351} & -\\frac{404}{1351} & -\\frac{67}{1351} \\\\\n \\frac{199}{1351} & \\frac{232}{1351} & \\frac{306}{1351} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(16/5), -(22/5), -(17/5)],\n [(19/5), (7/5), (16/5)],\n [-(4/5), (9/5), (21/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{7} & -\\frac{33}{7} & -\\frac{30}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{46}{7} & -\\frac{55}{7} & -\\frac{3}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -7 & \\frac{22}{7} & -\\frac{27}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/7), -(33/7), -(30/7)]])\nb = np.array([\n [(46/7), -(55/7), -(3/7)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 8 \\\\\n -9 \\\\\n -1 \\\\\n -7 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 7 \\\\\n -5 \\\\\n 8 \\\\\n 0 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{57}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [8],\n [-9],\n [-1],\n [-7],\n [5]])\nb = np.array([\n [3],\n [7],\n [-5],\n [8],\n [0],\n [5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{2} \\\\\n \\frac{85}{16} \\\\\n \\frac{1}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{85}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2)],\n [(85/16)],\n [(1/16)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & 1 & -3 \\\\\n 2 & 1 & 1 \\\\\n 1 & -4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{32} & \\frac{15}{32} & \\frac{1}{8} \\\\\n \\frac{7}{32} & \\frac{9}{32} & -\\frac{1}{8} \\\\\n -\\frac{9}{32} & -\\frac{7}{32} & -\\frac{1}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 1, -3],\n [2, 1, 1],\n [1, -4, -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n \\frac{11}{4} \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -\\frac{3}{2} \\\\\n \\frac{5}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{60}{77},\\frac{90}{77},-\\frac{75}{77}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2)],\n [(11/4)],\n [(3/2)]]).squeeze()\nb = np.array([\n [-1],\n [-(3/2)],\n [(5/4)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & 5 \\\\\n 2 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{2} \\left(-4-\\sqrt{26}\\right),1\\right\\}, \\left\\{\\frac{1}{2} \\left(\\sqrt{26}-4\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 5],\n [2, 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{3} \\\\\n \\frac{5}{6} \\\\\n -\\frac{59}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{17}{6} \\\\\n -\\frac{19}{2} \\\\\n \\frac{14}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3223}{36} \\\\\n -\\frac{611}{36} \\\\\n \\frac{713}{36} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/3)],\n [(5/6)],\n [-(59/6)]])\nb = np.array([\n [(17/6)],\n [-(19/2)],\n [(14/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{3} & \\frac{8}{3} & 3 \\\\\n -\\frac{2}{3} & -4 & 0 \\\\\n -\\frac{1}{3} & 4 & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{280}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3), (8/3), 3],\n [-(2/3), -4, 0],\n [-(1/3), 4, -(1/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{51}{7} & \\frac{50}{7} & -\\frac{48}{7} & -\\frac{41}{7} \\\\\n 3 & -\\frac{26}{7} & 3 & \\frac{24}{7} \\\\\n -\\frac{66}{7} & -\\frac{65}{7} & \\frac{65}{7} & -\\frac{40}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{65}{7} & -\\frac{36}{7} & -\\frac{27}{7} & \\frac{19}{7} \\\\\n -\\frac{33}{7} & -\\frac{3}{7} & -\\frac{10}{7} & \\frac{25}{7} \\\\\n -\\frac{38}{7} & -\\frac{11}{7} & -2 & -\\frac{64}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 2 & \\frac{86}{7} & -3 & -\\frac{60}{7} \\\\\n \\frac{54}{7} & -\\frac{23}{7} & \\frac{31}{7} & -\\frac{1}{7} \\\\\n -4 & -\\frac{54}{7} & \\frac{79}{7} & \\frac{24}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(51/7), (50/7), -(48/7), -(41/7)],\n [3, -(26/7), 3, (24/7)],\n [-(66/7), -(65/7), (65/7), -(40/7)]])\nb = np.array([\n [-(65/7), -(36/7), -(27/7), (19/7)],\n [-(33/7), -(3/7), -(10/7), (25/7)],\n [-(38/7), -(11/7), -2, -(64/7)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -1 \\\\\n \\frac{19}{2} \\\\\n 0 \\\\\n -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n -3 \\\\\n \\frac{5}{2} \\\\\n -\\frac{19}{2} \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{269}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-1],\n [(19/2)],\n [0],\n [-(13/2)]])\nb = np.array([\n [-(1/2)],\n [-3],\n [(5/2)],\n [-(19/2)],\n [-6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -5 & 8 \\\\\n 9 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{6} \\left(-3-\\sqrt{41}\\right),1\\right\\}, \\left\\{\\frac{1}{6} \\left(\\sqrt{41}-3\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 8],\n [9, 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & -9 & 4 \\\\\n -3 & -9 & 6 \\\\\n 0 & -5 & -1 \\\\\n -6 & -9 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, -9, 4],\n [-3, -9, 6],\n [0, -5, -1],\n [-6, -9, -9]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{22}{\\pi } \\\\\n -\\frac{29}{\\pi } \\\\\n \\frac{24}{\\pi } \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{20}{\\pi } \\\\\n \\frac{6}{\\pi } \\\\\n -\\frac{6}{\\pi } \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{758}{\\pi ^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(22/math.pi)],\n [-(29/math.pi)],\n [(24/math.pi)]])\nb = np.array([\n [-(20/math.pi)],\n [(6/math.pi)],\n [-(6/math.pi)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{10}{3},-\\frac{4}{3},\\frac{2}{3}\\right\\}, \\left\\{-\\frac{8}{3},-\\frac{1}{3},-\\frac{8}{3}\\right\\}, \\left\\{3,-\\frac{5}{3},5\\right\\}}$.", - "Output Answer": [ - "$29 x-216 y-59 z-152=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(10/3), -(4/3), (2/3)],\n [-(8/3), -(1/3), -(8/3)],\n [3, -(5/3), 5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -3 & 0 & 0 \\\\\n 2 & 3 & 1 \\\\\n -1 & -1 & -3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -27 & 0 & 0 \\\\\n 19 & 24 & 8 \\\\\n -20 & -8 & -24 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, 0],\n [2, 3, 1],\n [-1, -1, -3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{22}{7}, \\frac{4}{7}}$ to the line $-x+4 y-\\frac{9}{7}=0$.", - "Output Answer": [ - "$\\frac{29}{7 \\sqrt{17}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(22/7), (4/7)\nline = Poly(-x+4*y-(9/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -10 & 1 \\\\\n 1 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+10 x-1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 1],\n [1, 0]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 0 & 2 \\\\\n 5 & -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 2 & 3 \\\\\n -9 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 2 & 5 \\\\\n -4 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2],\n [5, -9]])\nb = np.array([\n [2, 3],\n [-9, 7]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{4} \\\\\n -\\frac{23}{4} \\\\\n -\\frac{85}{16} \\\\\n \\frac{17}{4} \\\\\n -\\frac{21}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{291}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/4)],\n [-(23/4)],\n [-(85/16)],\n [(17/4)],\n [-(21/8)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{5} \\\\\n -\\frac{2}{5} \\\\\n \\frac{13}{5} \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{174}} \\\\\n -\\sqrt{\\frac{2}{87}} \\\\\n \\frac{13}{\\sqrt{174}} \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/5)],\n [-(2/5)],\n [(13/5)],\n [0]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{29}{7}, 4}$ to the line $-\\frac{24 x}{7}-\\frac{8 y}{7}+\\frac{30}{7}=0$.", - "Output Answer": [ - "$\\frac{71 \\sqrt{\\frac{5}{2}}}{28}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (29/7), 4\nline = Poly(-((24*x)/7)-((8*y)/7)+(30/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -9 & 2 \\\\\n -6 & -5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 2 & -1 \\\\\n 4 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -11 & 3 \\\\\n -10 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 2],\n [-6, -5]])\nb = np.array([\n [2, -1],\n [4, -1]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 3 & 3 \\\\\n 5 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{2}{21} & \\frac{1}{7} \\\\\n \\frac{5}{21} & -\\frac{1}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3],\n [5, -2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & 1 \\\\\n -9 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(13-i \\sqrt{11}\\right),\\frac{1}{2} \\left(13+i \\sqrt{11}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 1],\n [-9, 4]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & -3 & 0 \\\\\n -1 & -2 & -2 \\\\\n -1 & -2 & -1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 8 & -33 & -6 \\\\\n -13 & -40 & -28 \\\\\n -12 & -31 & -23 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3, 0],\n [-1, -2, -2],\n [-1, -2, -1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & 1 & \\frac{3}{2} \\\\\n 0 & 2 & -\\frac{5}{2} \\\\\n 2 & -1 & \\frac{3}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{21}{8} & \\frac{19}{4} & \\frac{25}{8} \\\\\n -20 & \\frac{67}{4} & -\\frac{295}{8} \\\\\n \\frac{35}{2} & -\\frac{27}{4} & \\frac{171}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), 1, (3/2)],\n [0, 2, -(5/2)],\n [2, -1, (3/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{71}{8} & -\\frac{3}{8} & -\\frac{37}{4} & -\\frac{11}{2} & -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(71/8), -(3/8), -(37/4), -(11/2), -(15/2)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -10 & 6 & -5 & 9 \\\\\n 2 & -2 & 2 & -5 \\\\\n 9 & 6 & 4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-84.,-35.,324.,110.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, 6, -5, 9],\n [2, -2, 2, -5],\n [9, 6, 4, -3]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & 2 \\\\\n 8 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-x-88$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 2],\n [8, 9]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 10 & -4 \\\\\n 3 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-2,9\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -4],\n [3, -3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{29}{3} & \\frac{22}{3} & \\frac{11}{3} & \\frac{13}{3} \\\\\n -\\frac{26}{3} & -\\frac{23}{3} & -5 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{11}{3} & 5 & \\frac{8}{3} & -\\frac{23}{3} \\\\\n -\\frac{4}{3} & -\\frac{16}{3} & -1 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{40}{3} & \\frac{37}{3} & \\frac{19}{3} & -\\frac{10}{3} \\\\\n -10 & -13 & -6 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/3), (22/3), (11/3), (13/3)],\n [-(26/3), -(23/3), -5, 2]])\nb = np.array([\n [-(11/3), 5, (8/3), -(23/3)],\n [-(4/3), -(16/3), -1, -5]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,0,-1\\}, \\{-2,1,0\\}, \\{1,-4,-4\\}}$.", - "Output Answer": [ - "$x-17 y+22 z+19=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, 0, -1],\n [-2, 1, 0],\n [1, -4, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 1 \\\\\n 0 & 3 \\\\\n 2 & 1 \\\\\n -2 & -1 \\\\\n 0 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.32 \\\\\n -0.86 \\\\\n -0.83 \\\\\n 0.16 \\\\\n -0.83 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.071 \\\\\n -0.06 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1],\n [0, 3],\n [2, 1],\n [-2, -1],\n [0, -1]])\nb = np.array([\n [2.32],\n [-0.86],\n [-0.83],\n [0.16],\n [-0.83]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{3,2,-3\\}, \\left\\{3,2,-\\frac{3}{2}\\right\\}, \\{-2,2,1\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{3}{\\sqrt{22}},\\sqrt{\\frac{2}{11}},-\\frac{3}{\\sqrt{22}}\\right\\}, \\left\\{\\frac{9}{\\sqrt{286}},3 \\sqrt{\\frac{2}{143}},\\sqrt{\\frac{13}{22}}\\right\\}, \\left\\{-\\frac{2}{\\sqrt{13}},\\frac{3}{\\sqrt{13}},0\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((3, 2, -3), (3, 2, -(3/2)), (-2, 2, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n \\frac{7}{2} \\\\\n -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -\\frac{7}{2} \\\\\n -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{37}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [(7/2)],\n [-(9/2)]])\nb = np.array([\n [-7],\n [-(7/2)],\n [-10]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & -1 \\\\\n \\frac{7}{2} & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(10-i \\sqrt{10}\\right),\\frac{1}{2} \\left(10+i \\sqrt{10}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -1],\n [(7/2), 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{77}{16}, -\\frac{87}{32}}$ to the line $\\frac{109 x}{32}-\\frac{7 y}{8}+\\frac{7}{8}=0$.", - "Output Answer": [ - "$\\frac{6727}{16 \\sqrt{12665}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(77/16), -(87/32)\nline = Poly(((109*x)/32)-((7*y)/8)+(7/8), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{34}{9} & -\\frac{32}{9} & -\\frac{1}{9} \\\\\n -\\frac{70}{9} & -\\frac{7}{9} & \\frac{82}{9} \\\\\n -\\frac{19}{9} & \\frac{73}{9} & -\\frac{88}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{61 x^2}{9}+\\frac{10859 x}{81}+\\frac{23213}{243}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(34/9), -(32/9), -(1/9)],\n [-(70/9), -(7/9), (82/9)],\n [-(19/9), (73/9), -(88/9)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & -1 & 0 \\\\\n -3 & 1 & -3 \\\\\n 1 & -1 & 1 \\\\\n -1 & 3 & 1 \\\\\n 0 & 2 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.18 \\\\\n 1.41 \\\\\n 0.36 \\\\\n 0.87 \\\\\n -0.36 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.19 \\\\\n 0.163 \\\\\n -0.159 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1, 0],\n [-3, 1, -3],\n [1, -1, 1],\n [-1, 3, 1],\n [0, 2, 3]])\nb = np.array([\n [0.18],\n [1.41],\n [0.36],\n [0.87],\n [-0.36]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & 0 & -4 \\\\\n -1 & 1 & -1 \\\\\n -4 & -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-20$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 0, -4],\n [-1, 1, -1],\n [-4, -1, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{11}{7}, \\frac{4}{7}}$ to the line $\\frac{6 x}{7}+\\frac{25 y}{7}-\\frac{23}{7}=0$.", - "Output Answer": [ - "$\\frac{5}{7 \\sqrt{661}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (11/7), (4/7)\nline = Poly(((6*x)/7)+((25*y)/7)-(23/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n -\\frac{29}{4} \\\\\n -\\frac{61}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{61}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2)],\n [-(29/4)],\n [-(61/8)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 0 \\\\\n -2 \\\\\n 7 \\\\\n -3 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -8 \\\\\n -3 \\\\\n -6 \\\\\n 2 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-60$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [0],\n [-2],\n [7],\n [-3],\n [0]])\nb = np.array([\n [9],\n [-8],\n [-3],\n [-6],\n [2],\n [8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{14}{9} & -\\frac{10}{3} & \\frac{8}{9} \\\\\n -\\frac{7}{3} & 0 & -\\frac{29}{9} \\\\\n \\frac{4}{3} & -3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{783}{1444} & -\\frac{297}{722} & -\\frac{435}{722} \\\\\n -\\frac{219}{1444} & -\\frac{141}{722} & -\\frac{119}{722} \\\\\n -\\frac{567}{1444} & -\\frac{9}{722} & \\frac{315}{722} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/9), -(10/3), (8/9)],\n [-(7/3), 0, -(29/9)],\n [(4/3), -3, 3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -2 & -3 \\\\\n -1 & 1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 7 & 3 \\\\\n 1 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3],\n [-1, 1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -10 \\\\\n -8 \\\\\n 0 \\\\\n 5 \\\\\n 5 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 4 \\\\\n -3 \\\\\n 10 \\\\\n -9 \\\\\n -4 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-106$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-10],\n [-8],\n [0],\n [5],\n [5],\n [-9]])\nb = np.array([\n [-7],\n [4],\n [-3],\n [10],\n [-9],\n [-4],\n [2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & -1 & -2 & 2 \\\\\n 2 & -1 & 1 & -3 \\\\\n 3 & -2 & 3 & 3 \\\\\n 1 & 1 & 3 & -3 \\\\\n 2 & 3 & 1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.54 \\\\\n -0.14 \\\\\n 2.26 \\\\\n -2.88 \\\\\n 2.8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.396 \\\\\n 0.165 \\\\\n -0.032 \\\\\n 0.462 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -1, -2, 2],\n [2, -1, 1, -3],\n [3, -2, 3, 3],\n [1, 1, 3, -3],\n [2, 3, 1, 3]])\nb = np.array([\n [-1.54],\n [-0.14],\n [2.26],\n [-2.88],\n [2.8]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{5}{2},-\\frac{7}{2},\\frac{9}{2}\\right\\}, \\left\\{-\\frac{7}{2},1,-3\\right\\}, \\left\\{-\\frac{5}{2},\\frac{5}{2},-4\\right\\}}$.", - "Output Answer": [ - "$2 x-4 y-4 z-1=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(5/2), -(7/2), (9/2)],\n [-(7/2), 1, -3],\n [-(5/2), (5/2), -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{2} & -\\frac{9}{2} \\\\\n -3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{27}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), -(9/2)],\n [-3, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -\\frac{9}{2} \\\\\n \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{\\frac{115}{2}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-(9/2)],\n [(7/2)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{9}{2},-\\frac{1}{2},4\\right\\}, \\left\\{0,\\frac{9}{2},\\frac{7}{2}\\right\\}, \\left\\{3,-\\frac{1}{2},-\\frac{1}{2}\\right\\}}$.", - "Output Answer": [ - "$15 x+13 y-5 z-41=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(9/2), -(1/2), 4],\n [0, (9/2), (7/2)],\n [3, -(1/2), -(1/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{10}{3},\\frac{7}{3},-3\\right\\}, \\left\\{-\\frac{2}{3},\\frac{4}{3},2\\right\\}, \\left\\{-1,\\frac{11}{3},\\frac{11}{3}\\right\\}}$.", - "Output Answer": [ - "$120 x-45 y+87 z-34=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(10/3), (7/3), -3],\n [-(2/3), (4/3), 2],\n [-1, (11/3), (11/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 0 & 0 & 1 & 0 & 1 \\\\\n 0 & 1 & -2 & -3 & -2 \\\\\n -3 & 1 & 1 & 1 & -1 \\\\\n 1 & 1 & 0 & -1 & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -3 \\\\\n -2 \\\\\n 0 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -5 \\\\\n 7 \\\\\n -5 \\\\\n -11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0, 1, 0, 1],\n [0, 1, -2, -3, -2],\n [-3, 1, 1, 1, -1],\n [1, 1, 0, -1, 3]])\nb = np.array([\n [1],\n [-3],\n [-2],\n [0],\n [-3]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{80}{9} \\\\\n \\frac{8}{3} \\\\\n -\\frac{4}{3} \\\\\n \\frac{23}{9} \\\\\n -\\frac{43}{9} \\\\\n \\frac{10}{3} \\\\\n -\\frac{53}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{13207}}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(80/9)],\n [(8/3)],\n [-(4/3)],\n [(23/9)],\n [-(43/9)],\n [(10/3)],\n [-(53/9)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,-5,-3\\}, \\{-4,-3,-5\\}, \\{2,-2,-4\\}}$.", - "Output Answer": [ - "$4 x-7 y-17 z-90=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -5, -3],\n [-4, -3, -5],\n [2, -2, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{5} \\\\\n 0 \\\\\n \\frac{4}{5} \\\\\n \\frac{6}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -\\frac{11}{5} \\\\\n \\frac{3}{5} \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{216}{355},-\\frac{792}{1775},\\frac{216}{1775},0\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/5)],\n [0],\n [(4/5)],\n [(6/5)]]).squeeze()\nb = np.array([\n [-3],\n [-(11/5)],\n [(3/5)],\n [0]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 9 & 5 \\\\\n 4 & 5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -8 & 6 \\\\\n 7 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 17 & -1 \\\\\n -3 & 14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 5],\n [4, 5]])\nb = np.array([\n [-8, 6],\n [7, -9]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n -2 & -\\frac{17}{4} & -\\frac{19}{2} \\\\\n -3 & \\frac{19}{2} & 1 \\\\\n \\frac{11}{2} & -1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -(17/4), -(19/2)],\n [-3, (19/2), 1],\n [(11/2), -1, -4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\sqrt{\\frac{2}{5}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [-1],\n [-1],\n [1],\n [-1],\n [0]]).squeeze()\nb = np.array([\n [0],\n [0],\n [0],\n [1],\n [0],\n [1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 2 & -1 \\\\\n 2 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1 \\\\\n -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1],\n [2, 2]])\nb = np.array([\n [-1],\n [-1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -3 & -5 & -1 \\\\\n -4 & 3 & 4 \\\\\n -5 & -4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{7}{108} & -\\frac{11}{108} & -\\frac{17}{108} \\\\\n -\\frac{8}{27} & \\frac{1}{27} & \\frac{4}{27} \\\\\n \\frac{31}{108} & \\frac{13}{108} & -\\frac{29}{108} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -5, -1],\n [-4, 3, 4],\n [-5, -4, -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -4 & -10 & -7 & -10 & 8 \\\\\n 0 & -5 & -7 & 9 & 4 \\\\\n 3 & -8 & -10 & 2 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-42.,68.,-24.,0.,43.\\}, \\{266.,-703.,668.,129.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, -10, -7, -10, 8],\n [0, -5, -7, 9, 4],\n [3, -8, -10, 2, 10]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{5} \\\\\n \\frac{7}{5} \\\\\n -\\frac{6}{5} \\\\\n -\\frac{4}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{7}{5} \\\\\n -\\frac{8}{5} \\\\\n \\frac{7}{5} \\\\\n -\\frac{1}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{161}{163},\\frac{184}{163},-\\frac{161}{163},\\frac{23}{163}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/5)],\n [(7/5)],\n [-(6/5)],\n [-(4/5)]]).squeeze()\nb = np.array([\n [(7/5)],\n [-(8/5)],\n [(7/5)],\n [-(1/5)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -\\frac{28}{9} & -\\frac{20}{3} \\\\\n \\frac{31}{9} & 7 \\\\\n \\frac{46}{9} & -\\frac{25}{3} \\\\\n -\\frac{70}{9} & \\frac{4}{3} \\\\\n -\\frac{19}{3} & \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(28/9), -(20/3)],\n [(31/9), 7],\n [(46/9), -(25/3)],\n [-(70/9), (4/3)],\n [-(19/3), (4/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{2}-\\frac{5 i}{2} & \\frac{1}{2}-\\frac{i}{2} \\\\\n 2+\\frac{9 i}{2} & 2+\\frac{3 i}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{207}{8}-\\frac{371 i}{8} & \\frac{59}{8}+\\frac{29 i}{8} \\\\\n -42+\\frac{311 i}{8} & -\\frac{5}{4}+\\frac{145 i}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2)-((5j)/2), (1/2)-(1j/2)],\n [2+((9j)/2), 2+((3j)/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & 2 & -4 \\\\\n -2 & 0 & 3 \\\\\n -5 & -3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-63$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2, -4],\n [-2, 0, 3],\n [-5, -3, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n -5 \\\\\n -5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -9 \\\\\n -8 \\\\\n 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2 \\\\\n 7 \\\\\n 3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-2],\n [-5],\n [-5]])\nb = np.array([\n [0],\n [-9],\n [-8],\n [3]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & 2 \\\\\n 1 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(7-\\sqrt{57}\\right),\\frac{1}{2} \\left(7+\\sqrt{57}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2],\n [1, 7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -2 & 0 & -2 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -2 & 3 & 1 & -1 \\\\\n -2 & -2 & -1 & 1 \\\\\n 0 & 1 & 2 & -2 \\\\\n 2 & 3 & 1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 0 & -14 & -8 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, -2, -2]])\nb = np.array([\n [-2, 3, 1, -1],\n [-2, -2, -1, 1],\n [0, 1, 2, -2],\n [2, 3, 1, 0]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 9 & -2 & -1 & -5 & -3 & -1 \\\\\n -9 & -5 & 6 & 5 & -5 & 4 \\\\\n 1 & -8 & -4 & -10 & -4 & -5 \\\\\n -7 & 5 & -4 & 3 & 1 & 1 \\\\\n -2 & 10 & 4 & 3 & 4 & 10 \\\\\n 8 & 5 & -4 & 3 & -8 & 9 \\\\\n 9 & -10 & -7 & -10 & 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, -2, -1, -5, -3, -1],\n [-9, -5, 6, 5, -5, 4],\n [1, -8, -4, -10, -4, -5],\n [-7, 5, -4, 3, 1, 1],\n [-2, 10, 4, 3, 4, 10],\n [8, 5, -4, 3, -8, 9],\n [9, -10, -7, -10, 1, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 5 & -3 & 4 \\\\\n 0 & -2 & -2 \\\\\n 4 & -1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$46$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -3, 4],\n [0, -2, -2],\n [4, -1, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2.24 \\\\\n -5.44 \\\\\n 4.7 \\\\\n -6.11 \\\\\n 5.08 \\\\\n -9.78 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8.39 \\\\\n -8.36 \\\\\n 8.77 \\\\\n 7.32 \\\\\n -2.9 \\\\\n 7.89 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-68.7176$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2.24],\n [-5.44],\n [4.7],\n [-6.11],\n [5.08],\n [-9.78]])\nb = np.array([\n [8.39],\n [-8.36],\n [8.77],\n [7.32],\n [-2.9],\n [7.89]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -7 \\\\\n -3 \\\\\n -4 \\\\\n 7 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -6 \\\\\n 5 \\\\\n 9 \\\\\n 3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{10}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-7],\n [-3],\n [-4],\n [7],\n [-8]])\nb = np.array([\n [-6],\n [-6],\n [5],\n [9],\n [3],\n [-8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & -2 \\\\\n -2 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} \\left(1-\\sqrt{17}\\right),1\\right\\}, \\left\\{\\frac{1}{4} \\left(1+\\sqrt{17}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -2],\n [-2, -6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{9} \\\\\n -\\frac{89}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{34}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/9)],\n [-(89/9)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & -5 \\\\\n 3 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$20$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -5],\n [3, 5]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{2} \\\\\n -\\frac{28}{5} \\\\\n -\\frac{51}{10} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -\\frac{36}{5} \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n \\frac{8}{5} \\\\\n -\\frac{1}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2)],\n [-(28/5)],\n [-(51/10)]])\nb = np.array([\n [-6],\n [-(36/5)],\n [-5]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{20}{7}, -\\frac{24}{7}}$ to the line $\\frac{22 x}{7}-\\frac{19 y}{7}+\\frac{8}{7}=0$.", - "Output Answer": [ - "$\\frac{72}{91 \\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(20/7), -(24/7)\nline = Poly(((22*x)/7)-((19*y)/7)+(8/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & 5 & -3 \\\\\n -4 & 0 & 3 \\\\\n 0 & 5 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$80$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 5, -3],\n [-4, 0, 3],\n [0, 5, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{4} & -\\frac{21}{4} & -\\frac{21}{4} \\\\\n \\frac{19}{4} & -\\frac{13}{2} & -\\frac{3}{4} \\\\\n -\\frac{35}{4} & \\frac{7}{4} & \\frac{13}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-4.421-2.696 i,-4.421+2.696 i,8.843\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/4), -(21/4), -(21/4)],\n [(19/4), -(13/2), -(3/4)],\n [-(35/4), (7/4), (13/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{13}{2} & -\\frac{13}{6} \\\\\n -\\frac{19}{6} & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{25 x}{2}+\\frac{1157}{36}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2), -(13/6)],\n [-(19/6), 6]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{2}{3},\\frac{13}{3},3\\right\\}, \\left\\{\\frac{4}{3},-5,-\\frac{2}{3}\\right\\}, \\left\\{-\\frac{13}{3},-\\frac{8}{3},4\\right\\}}$.", - "Output Answer": [ - "$315 x-159 y+462 z-907=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(2/3), (13/3), 3],\n [(4/3), -5, -(2/3)],\n [-(13/3), -(8/3), 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & -1 & -3 \\\\\n 0 & -1 & -1 \\\\\n 2 & -2 & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -2 & 5 & -2 \\\\\n -2 & 3 & 2 \\\\\n 2 & 2 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1, -3],\n [0, -1, -1],\n [2, -2, -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & -\\frac{17}{2} & -\\frac{5}{2} \\\\\n 8 & 1 & \\frac{1}{2} \\\\\n -\\frac{9}{2} & \\frac{5}{2} & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{1.763\\, -7.409 i,1.763\\, +7.409 i,3.474\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), -(17/2), -(5/2)],\n [8, 1, (1/2)],\n [-(9/2), (5/2), (7/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & -4 & -5 \\\\\n 2 & -2 & 3 \\\\\n 3 & 2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{4}{47} & \\frac{3}{47} & \\frac{11}{47} \\\\\n -\\frac{7}{94} & -\\frac{17}{94} & \\frac{8}{47} \\\\\n -\\frac{5}{47} & \\frac{8}{47} & -\\frac{2}{47} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -4, -5],\n [2, -2, 3],\n [3, 2, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{13}{32}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{39}{32} & \\frac{13}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1]])\nprint(a * (13/32))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -7 & \\frac{15}{2} & \\frac{5}{2} \\\\\n 3 & \\frac{7}{2} & -\\frac{1}{2} \\\\\n -4 & 5 & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-7.684,2.272,5.412\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, (15/2), (5/2)],\n [3, (7/2), -(1/2)],\n [-4, 5, (7/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{63}{8} & \\frac{7}{2} & -2 \\\\\n \\frac{5}{8} & \\frac{77}{8} & -\\frac{21}{4} \\\\\n -\\frac{21}{8} & \\frac{11}{2} & -\\frac{21}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{7 x^2}{2}+\\frac{4067 x}{64}+\\frac{44251}{256}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(63/8), (7/2), -2],\n [(5/8), (77/8), -(21/4)],\n [-(21/8), (11/2), -(21/4)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 9 & -4 & -1 & -4 \\\\\n 6 & 1 & -4 & 9 \\\\\n 6 & -5 & -3 & 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -3 & 7 & 2 & -1 \\\\\n 0 & -8 & 1 & -2 \\\\\n -7 & -9 & 7 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 6 & 3 & 1 & -5 \\\\\n 6 & -7 & -3 & 7 \\\\\n -1 & -14 & 4 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -4, -1, -4],\n [6, 1, -4, 9],\n [6, -5, -3, 6]])\nb = np.array([\n [-3, 7, 2, -1],\n [0, -8, 1, -2],\n [-7, -9, 7, -3]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 0 & 0 \\\\\n 3 & 2 & 2 \\\\\n -1 & -3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$20$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, 0],\n [3, 2, 2],\n [-1, -3, 2]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{39}{5} \\\\\n \\frac{31}{5} \\\\\n -\\frac{27}{10} \\\\\n \\frac{36}{5} \\\\\n \\frac{3}{10} \\\\\n \\frac{15}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{39}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(39/5)],\n [(31/5)],\n [-(27/10)],\n [(36/5)],\n [(3/10)],\n [(15/2)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -1 & 8 \\\\\n -2 & -6 \\\\\n 1 & 4 \\\\\n 8 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-1, 8],\n [-2, -6],\n [1, 4],\n [8, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 10 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-7.,10.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [10, 7]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{8} \\\\\n -\\frac{47}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2}{\\sqrt{2213}} \\\\\n -\\frac{47}{\\sqrt{2213}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/8)],\n [-(47/16)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2]])\nb = np.array([\n [5]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & -4 \\\\\n -5 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-7 x-14$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -4],\n [-5, 6]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{21}{5} & -\\frac{18}{5} \\\\\n -3 & -\\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{438}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(21/5), -(18/5)],\n [-3, -(8/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -8 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 0 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 16 \\\\\n 18 \\\\\n 72 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-8],\n [4]])\nb = np.array([\n [9],\n [0],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${2, -4, 4}$ to the plane $-x-2 y-5 z-4=0$.", - "Output Answer": [ - "$3 \\sqrt{\\frac{6}{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 2, -4, 4\nplane = Poly(-x-2*y-5*z-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{3} \\\\\n \\frac{77}{9} \\\\\n -\\frac{16}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{3} \\\\\n \\frac{67}{9} \\\\\n -\\frac{16}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1984}{81} \\\\\n \\frac{1280}{27} \\\\\n \\frac{196}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/3)],\n [(77/9)],\n [-(16/3)]])\nb = np.array([\n [-(29/3)],\n [(67/9)],\n [-(16/9)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{35}{8} & -\\frac{29}{8} & -\\frac{27}{4} \\\\\n \\frac{123}{16} & -\\frac{47}{16} & -\\frac{39}{8} \\\\\n -\\frac{145}{16} & -\\frac{103}{16} & -\\frac{5}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{137 x^2}{16}+\\frac{5465 x}{128}+\\frac{112637}{256}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(35/8), -(29/8), -(27/4)],\n [(123/16), -(47/16), -(39/8)],\n [-(145/16), -(103/16), -(5/4)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6.227 \\\\\n 2.874 \\\\\n -3.486 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7.033 \\\\\n -4.865 \\\\\n -8.371 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$16.1116$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6.227],\n [2.874],\n [-3.486]])\nb = np.array([\n [-7.033],\n [-4.865],\n [-8.371]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 7 \\\\\n 2 \\\\\n -1 \\\\\n 2 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$19$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [7],\n [2],\n [-1],\n [2],\n [-4]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{2}{3}, -\\frac{13}{3}, -\\frac{2}{3}}$ to the plane $-3 x-3 y-\\frac{8 z}{3}+\\frac{4}{3}=0$.", - "Output Answer": [ - "$\\frac{163}{3 \\sqrt{226}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(2/3), -(13/3), -(2/3)\nplane = Poly(-3*x-3*y-((8*z)/3)+(4/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 2 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 7 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{107}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [2],\n [-5]])\nb = np.array([\n [-7],\n [7],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{61}{10} & -\\frac{71}{10} & \\frac{73}{10} \\\\\n \\frac{34}{5} & -5 & -\\frac{39}{5} \\\\\n \\frac{69}{10} & -\\frac{4}{5} & \\frac{77}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{44 x^2}{5}+\\frac{759 x}{25}+\\frac{346551}{500}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(61/10), -(71/10), (73/10)],\n [(34/5), -5, -(39/5)],\n [(69/10), -(4/5), (77/10)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -4 & 2 & -3 \\\\\n -3 & -1 & 3 \\\\\n 3 & -4 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{2}{11} & -\\frac{8}{55} & -\\frac{3}{55} \\\\\n -\\frac{3}{11} & -\\frac{1}{55} & -\\frac{21}{55} \\\\\n -\\frac{3}{11} & \\frac{2}{11} & -\\frac{2}{11} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 2, -3],\n [-3, -1, 3],\n [3, -4, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{18}{5}, -\\frac{17}{5}}$ to the line $4 x+\\frac{9 y}{5}+\\frac{9}{5}=0$.", - "Output Answer": [ - "$\\frac{36 \\sqrt{\\frac{13}{37}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(18/5), -(17/5)\nline = Poly(4*x+((9*y)/5)+(9/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{16}{7}, \\frac{30}{7}}$ to the line $-\\frac{15 x}{7}+\\frac{27 y}{7}-\\frac{11}{7}=0$.", - "Output Answer": [ - "$\\frac{493}{21 \\sqrt{106}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (16/7), (30/7)\nline = Poly(-((15*x)/7)+((27*y)/7)-(11/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{4} \\\\\n -\\frac{9}{4} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{4} \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{47}{148},-\\frac{141}{74}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/4)],\n [-(9/4)]]).squeeze()\nb = np.array([\n [-(1/4)],\n [(3/2)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -\\frac{51}{8} & \\frac{75}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(51/8), (75/8)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & 9 \\\\\n 1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{2-\\sqrt{13},1\\right\\}, \\left\\{2+\\sqrt{13},1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 9],\n [1, -3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 3 \\\\\n 2 \\\\\n -2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -3 & -3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 6 & 6 & 4 \\\\\n -9 & -9 & -6 \\\\\n -6 & -6 & -4 \\\\\n 6 & 6 & 4 \\\\\n 6 & 6 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [3],\n [2],\n [-2],\n [-2]])\nb = np.array([\n [-3, -3, -2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{12}{17},-\\frac{18}{17},\\frac{12}{17}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-2],\n [0]]).squeeze()\nb = np.array([\n [2],\n [-3],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -4 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -6 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 50 \\\\\n -10 \\\\\n -70 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-4],\n [7]])\nb = np.array([\n [-4],\n [-6],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -3 & -8 & 4 & -9 & 3 & 4 \\\\\n 2 & -3 & 1 & 1 & 4 & -10 \\\\\n -1 & 7 & -7 & -9 & -8 & -5 \\\\\n -1 & -7 & -8 & -10 & -4 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & \\frac{3342}{2867} & -\\frac{18451}{2867} \\\\\n 0 & 1 & 0 & 0 & -\\frac{956}{2867} & -\\frac{2508}{2867} \\\\\n 0 & 0 & 1 & 0 & \\frac{2171}{2867} & -\\frac{4429}{2867} \\\\\n 0 & 0 & 0 & 1 & -\\frac{255}{2867} & \\frac{5137}{2867} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, -8, 4, -9, 3, 4],\n [2, -3, 1, 1, 4, -10],\n [-1, 7, -7, -9, -8, -5],\n [-1, -7, -8, -10, -4, 7]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n \\frac{5}{4} \\\\\n -\\frac{37}{4} \\\\\n -5 \\\\\n -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{63}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [(5/4)],\n [-(37/4)],\n [-5],\n [-10]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{31}{5} & -\\frac{36}{5} & \\frac{47}{5} \\\\\n -7 & \\frac{1}{5} & -\\frac{14}{5} \\\\\n -\\frac{16}{5} & 5 & -\\frac{33}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{483.873,308.843,1.\\}, \\{-0.043-0.48 i,1.11\\, +0.373 i,1.\\}, \\{-0.043+0.48 i,1.11\\, -0.373 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(31/5), -(36/5), (47/5)],\n [-7, (1/5), -(14/5)],\n [-(16/5), 5, -(33/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & -2 & -1 & 1 \\\\\n -2 & 3 & -2 & 0 \\\\\n -3 & 0 & 1 & -2 \\\\\n 1 & 3 & -2 & -2 \\\\\n -2 & -3 & -2 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.72 \\\\\n 0.72 \\\\\n -1.19 \\\\\n 1.89 \\\\\n 1.22 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.352 \\\\\n -0.393 \\\\\n -1.108 \\\\\n -0.402 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2, -1, 1],\n [-2, 3, -2, 0],\n [-3, 0, 1, -2],\n [1, 3, -2, -2],\n [-2, -3, -2, 3]])\nb = np.array([\n [2.72],\n [0.72],\n [-1.19],\n [1.89],\n [1.22]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{20}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{4} \\\\\n -\\frac{3}{20} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [3]])\nprint(a * -(1/20))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 0 & 1 \\\\\n -2 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 3 & 1 & 0 \\\\\n -1 & 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & 1 & -1 \\\\\n -8 & 0 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1],\n [-2, 2]])\nb = np.array([\n [3, 1, 0],\n [-1, 1, -1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{11}{5}, \\frac{23}{5}}$ to the line $-\\frac{13 x}{5}+\\frac{23 y}{5}-2=0$.", - "Output Answer": [ - "$\\frac{311 \\sqrt{\\frac{2}{349}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(11/5), (23/5)\nline = Poly(-((13*x)/5)+((23*y)/5)-2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{4}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 5 & 1 & -1 & -10 \\\\\n 1 & 2 & -10 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{5}{4} & \\frac{1}{4} & -\\frac{1}{4} & -\\frac{5}{2} \\\\\n \\frac{1}{4} & \\frac{1}{2} & -\\frac{5}{2} & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 1, -1, -10],\n [1, 2, -10, 4]])\nprint(a * (1/4))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\sqrt{2} \\\\\n 4 \\sqrt{2} \\\\\n -2 \\sqrt{2} \\\\\n 4 \\sqrt{2} \\\\\n 3 \\sqrt{2} \\\\\n -5 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\sqrt{2} \\\\\n -2 \\sqrt{2} \\\\\n 5 \\sqrt{2} \\\\\n \\sqrt{2} \\\\\n 3 \\sqrt{2} \\\\\n -\\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{382}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [7*math.sqrt(2)],\n [4*math.sqrt(2)],\n [-2*math.sqrt(2)],\n [4*math.sqrt(2)],\n [3*math.sqrt(2)],\n [-5*math.sqrt(2)]])\nb = np.array([\n [-2*math.sqrt(2)],\n [-2*math.sqrt(2)],\n [5*math.sqrt(2)],\n [math.sqrt(2)],\n [3*math.sqrt(2)],\n [-math.sqrt(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n \\frac{18}{7} & \\frac{8}{7} \\\\\n -\\frac{5}{7} & 1 \\\\\n 1 & -\\frac{9}{7} \\\\\n \\frac{13}{7} & -\\frac{10}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{15}{7} & \\frac{3}{7} & \\frac{4}{7} & \\frac{19}{7} \\\\\n -\\frac{19}{7} & -\\frac{9}{7} & \\frac{5}{7} & \\frac{18}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{118}{49} & -\\frac{18}{49} & \\frac{16}{7} & \\frac{486}{49} \\\\\n -\\frac{208}{49} & -\\frac{78}{49} & \\frac{15}{49} & \\frac{31}{49} \\\\\n \\frac{276}{49} & \\frac{102}{49} & -\\frac{17}{49} & -\\frac{29}{49} \\\\\n \\frac{55}{7} & \\frac{129}{49} & \\frac{2}{49} & \\frac{67}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(18/7), (8/7)],\n [-(5/7), 1],\n [1, -(9/7)],\n [(13/7), -(10/7)]])\nb = np.array([\n [(15/7), (3/7), (4/7), (19/7)],\n [-(19/7), -(9/7), (5/7), (18/7)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{10}{3} & \\frac{26}{3} \\\\\n -\\frac{29}{3} & \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{3} \\left(7-i \\sqrt{745}\\right),\\frac{1}{3} \\left(7+i \\sqrt{745}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(10/3), (26/3)],\n [-(29/3), (4/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 2 & 5 & -6 & -10 \\\\\n 7 & 3 & 5 & 1 \\\\\n 3 & -4 & 2 & 7 \\\\\n -9 & -9 & -1 & 10 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -6 & 0 & -4 & 6 \\\\\n -8 & 5 & -6 & -3 \\\\\n 9 & -5 & 6 & -9 \\\\\n -2 & 1 & 4 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 8 & 5 & -2 & -16 \\\\\n 15 & -2 & 11 & 4 \\\\\n -6 & 1 & -4 & 16 \\\\\n -7 & -10 & -5 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 5, -6, -10],\n [7, 3, 5, 1],\n [3, -4, 2, 7],\n [-9, -9, -1, 10]])\nb = np.array([\n [-6, 0, -4, 6],\n [-8, 5, -6, -3],\n [9, -5, 6, -9],\n [-2, 1, 4, 7]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -3 & 5 & 8 \\\\\n -9 & 7 & -2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -7 & 9 & 8 \\\\\n -5 & 6 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 4 & -4 & 0 \\\\\n -4 & 1 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 5, 8],\n [-9, 7, -2]])\nb = np.array([\n [-7, 9, 8],\n [-5, 6, 2]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{20}{9} & \\frac{62}{9} & -\\frac{25}{3} & \\frac{14}{3} & \\frac{61}{9} \\\\\n \\frac{32}{9} & -\\frac{37}{9} & \\frac{64}{9} & 2 & \\frac{5}{3} \\\\\n -9 & \\frac{29}{3} & 1 & -\\frac{16}{9} & -\\frac{86}{9} \\\\\n -\\frac{11}{3} & -\\frac{16}{9} & -\\frac{37}{9} & \\frac{17}{9} & \\frac{56}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/9), (62/9), -(25/3), (14/3), (61/9)],\n [(32/9), -(37/9), (64/9), 2, (5/3)],\n [-9, (29/3), 1, -(16/9), -(86/9)],\n [-(11/3), -(16/9), -(37/9), (17/9), (56/9)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{13}{2}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 7 \\\\\n -5 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{13}{2} & \\frac{91}{2} \\\\\n -\\frac{65}{2} & \\frac{91}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 7],\n [-5, 7]])\nprint(a * (13/2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{2} \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{25}{52},\\frac{5}{52}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-(5/2)]]).squeeze()\nb = np.array([\n [-(5/2)],\n [(1/2)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{15}{2} & \\frac{17}{4} \\\\\n \\frac{7}{2} & \\frac{19}{4} \\\\\n \\frac{3}{4} & \\frac{7}{4} \\\\\n \\frac{1}{2} & \\frac{19}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & \\frac{13}{2} \\\\\n \\frac{17}{4} & \\frac{35}{4} \\\\\n \\frac{29}{4} & \\frac{11}{2} \\\\\n \\frac{3}{4} & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 9 & -\\frac{9}{4} \\\\\n -\\frac{3}{4} & -4 \\\\\n -\\frac{13}{2} & -\\frac{15}{4} \\\\\n -\\frac{1}{4} & \\frac{15}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/2), (17/4)],\n [(7/2), (19/4)],\n [(3/4), (7/4)],\n [(1/2), (19/4)]])\nb = np.array([\n [-(3/2), (13/2)],\n [(17/4), (35/4)],\n [(29/4), (11/2)],\n [(3/4), 1]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n \\frac{25}{3} & \\frac{25}{3} & 4 \\\\\n -\\frac{20}{3} & 0 & -2 \\\\\n \\frac{11}{3} & \\frac{14}{3} & \\frac{1}{3} \\\\\n -\\frac{26}{3} & -8 & -\\frac{16}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(25/3), (25/3), 4],\n [-(20/3), 0, -2],\n [(11/3), (14/3), (1/3)],\n [-(26/3), -8, -(16/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & 3 & 1 \\\\\n 3 & -1 & -3 \\\\\n -1 & -2 & -1 \\\\\n 1 & 2 & 0 \\\\\n 1 & -1 & -2 \\\\\n 1 & 0 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.95 \\\\\n 1. \\\\\n -1.58 \\\\\n -0.12 \\\\\n 0.16 \\\\\n 1.37 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.29 \\\\\n 0.499 \\\\\n -0.014 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 3, 1],\n [3, -1, -3],\n [-1, -2, -1],\n [1, 2, 0],\n [1, -1, -2],\n [1, 0, 1]])\nb = np.array([\n [1.95],\n [1.],\n [-1.58],\n [-0.12],\n [0.16],\n [1.37]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -4+2 i & 3 \\\\\n 2+2 i & -1-4 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 18-10 i & -15-6 i \\\\\n -6-14 i & -9+14 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4+2j, 3],\n [2+2j, -1-4j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -9 & -4 & 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -2 & -8 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -11 & -12 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -4, 7]])\nb = np.array([\n [-2, -8, -8]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 9 \\\\\n 7 \\\\\n 6 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [9],\n [7],\n [6],\n [2]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & 9 \\\\\n -3 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+3 x-1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 9],\n [-3, 4]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8]])\nb = np.array([\n [6]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -2 & -3 \\\\\n -3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{11} & -\\frac{3}{11} \\\\\n -\\frac{3}{11} & \\frac{2}{11} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3],\n [-3, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 4 & -1 & -6 & 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 5 & 9 & 6 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 9 & 8 & 0 & 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -1, -6, 7]])\nb = np.array([\n [5, 9, 6, 5]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 3 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 2 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -3 \\\\\n 49 \\\\\n 22 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [3],\n [-6]])\nb = np.array([\n [-4],\n [2],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${2, -2, 5}$ to the plane $-2 x+2 y+2 z+3=0$.", - "Output Answer": [ - "$\\frac{5}{2 \\sqrt{3}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 2, -2, 5\nplane = Poly(-2*x+2*y+2*z+3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 3 & -\\frac{41}{5} & \\frac{27}{10} \\\\\n \\frac{6}{5} & 8 & -\\frac{7}{2} \\\\\n -\\frac{19}{2} & -\\frac{38}{5} & -\\frac{93}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{17 x^2}{10}+\\frac{6941 x}{100}-\\frac{243293}{500}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -(41/5), (27/10)],\n [(6/5), 8, -(7/2)],\n [-(19/2), -(38/5), -(93/10)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{5}{2} & 1 & 3 & 3 & 0 \\\\\n -\\frac{5}{2} & -4 & -6 & 7 & 8 \\\\\n -4 & -\\frac{5}{2} & \\frac{1}{2} & -9 & \\frac{9}{2} \\\\\n 10 & -\\frac{9}{2} & 2 & \\frac{19}{2} & -1 \\\\\n 0 & \\frac{15}{2} & -\\frac{5}{2} & -\\frac{9}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), 1, 3, 3, 0],\n [-(5/2), -4, -6, 7, 8],\n [-4, -(5/2), (1/2), -9, (9/2)],\n [10, -(9/2), 2, (19/2), -1],\n [0, (15/2), -(5/2), -(9/2), (1/2)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 0 & 2 & 4 \\\\\n -4 & -1 & 10 \\\\\n 5 & 4 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-11.085,-0.17,4.254\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, 4],\n [-4, -1, 10],\n [5, 4, -6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & \\frac{10}{3} & 1 \\\\\n 4 & 2 & -\\frac{10}{3} \\\\\n \\frac{8}{3} & 0 & \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{1424}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, (10/3), 1],\n [4, 2, -(10/3)],\n [(8/3), 0, (4/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{38}{5} \\\\\n \\frac{44}{5} \\\\\n -\\frac{43}{5} \\\\\n \\frac{27}{5} \\\\\n -\\frac{9}{5} \\\\\n -6 \\\\\n \\frac{39}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6 \\sqrt{\\frac{47}{5}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(38/5)],\n [(44/5)],\n [-(43/5)],\n [(27/5)],\n [-(9/5)],\n [-6],\n [(39/5)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n \\frac{13}{2} & \\frac{5}{6} \\\\\n -\\frac{4}{3} & -\\frac{13}{2} \\\\\n -\\frac{49}{6} & -\\frac{23}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2), (5/6)],\n [-(4/3), -(13/2)],\n [-(49/6), -(23/6)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{4} \\\\\n -\\frac{7}{4} \\\\\n \\frac{3}{2} \\\\\n -\\frac{5}{2} \\\\\n \\frac{9}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{\\sqrt{\\frac{7}{5}}}{3} \\\\\n -\\frac{\\sqrt{\\frac{7}{5}}}{3} \\\\\n \\frac{2}{\\sqrt{35}} \\\\\n -\\frac{2 \\sqrt{\\frac{5}{7}}}{3} \\\\\n \\frac{3}{\\sqrt{35}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/4)],\n [-(7/4)],\n [(3/2)],\n [-(5/2)],\n [(9/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, \\frac{10}{3}, \\frac{8}{3}}$ to the plane $2 x-\\frac{11 y}{3}-\\frac{8 z}{3}-\\frac{1}{3}=0$.", - "Output Answer": [ - "$\\frac{77}{\\sqrt{221}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, (10/3), (8/3)\nplane = Poly(2*x-((11*y)/3)-((8*z)/3)-(1/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & 1 \\\\\n -1 & \\frac{1}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{5}{4} & 2 \\\\\n -2 & -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), 1],\n [-1, (1/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{167}{20} \\\\\n -\\frac{15}{4} \\\\\n \\frac{103}{20} \\\\\n \\frac{439}{50} \\\\\n \\frac{197}{100} \\\\\n -\\frac{107}{50} \\\\\n -\\frac{343}{50} \\\\\n -\\frac{443}{100} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{2625409}}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(167/20)],\n [-(15/4)],\n [(103/20)],\n [(439/50)],\n [(197/100)],\n [-(107/50)],\n [-(343/50)],\n [-(443/100)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n 2 & -4 & -3 & 1 \\\\\n 0 & -1 & -3 & -3 \\\\\n 0 & -1 & 1 & 3 \\\\\n 0 & 1 & 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n e^2 & \\frac{1-e^4}{e^2} & \\frac{1}{e^2} & e^2 \\\\\n 0 & \\frac{1}{e} & \\frac{1-e^3}{e} & \\frac{1-e^3}{e} \\\\\n 0 & \\frac{1-e}{e^2} & \\frac{1-e+e^4}{e^2} & \\frac{e^3-1}{e} \\\\\n 0 & \\frac{e-1}{e^2} & \\frac{e-1}{e^2} & \\frac{1}{e} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [2, -4, -3, 1],\n [0, -1, -3, -3],\n [0, -1, 1, 3],\n [0, 1, 1, -1]])\nprint(expm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -5 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -3 \\\\\n 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -59 \\\\\n 75 \\\\\n -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-5],\n [-3]])\nb = np.array([\n [-5],\n [-3],\n [10]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -10 & 0 & 8 \\\\\n -3 & 4 & -1 \\\\\n 7 & -7 & 8 \\\\\n 2 & 7 & 5 \\\\\n 1 & -7 & -7 \\\\\n -3 & 7 & -1 \\\\\n 5 & -7 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, 0, 8],\n [-3, 4, -1],\n [7, -7, 8],\n [2, 7, 5],\n [1, -7, -7],\n [-3, 7, -1],\n [5, -7, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{2} & -\\frac{13}{4} & \\frac{3}{2} \\\\\n 8 & -\\frac{1}{4} & -\\frac{1}{4} \\\\\n 6 & 8 & -\\frac{37}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8.837,-0.581-3.931 i,-0.581+3.931 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), -(13/4), (3/2)],\n [8, -(1/4), -(1/4)],\n [6, 8, -(37/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 8 \\\\\n -3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -7 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-70$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [8],\n [-3],\n [-8]])\nb = np.array([\n [0],\n [-7],\n [2],\n [1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & 1 & -1 \\\\\n -1 & 0 & -3 \\\\\n -3 & 1 & 2 \\\\\n 1 & -2 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.95 \\\\\n -0.03 \\\\\n 1.89 \\\\\n -1.37 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.524 \\\\\n 0.161 \\\\\n 0.206 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1, -1],\n [-1, 0, -3],\n [-3, 1, 2],\n [1, -2, -1]])\nb = np.array([\n [-0.95],\n [-0.03],\n [1.89],\n [-1.37]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -4 & 1 \\\\\n -4 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2} & \\frac{1}{4} \\\\\n -1 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 1],\n [-4, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{59}{16} \\\\\n -\\frac{17}{8} \\\\\n -\\frac{59}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{59}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(59/16)],\n [-(17/8)],\n [-(59/16)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 4 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n -7 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -24 \\\\\n 0 \\\\\n -30 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [4],\n [-8]])\nb = np.array([\n [-10],\n [-7],\n [8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n -1 \\\\\n -1 \\\\\n -3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{17}} \\\\\n \\frac{2}{\\sqrt{17}} \\\\\n -\\frac{1}{\\sqrt{17}} \\\\\n -\\frac{1}{\\sqrt{17}} \\\\\n -\\frac{3}{\\sqrt{17}} \\\\\n \\frac{1}{\\sqrt{17}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [2],\n [-1],\n [-1],\n [-3],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 4 & 2 & 4 & -2 & 0 \\\\\n -4 & -1 & 9 & -1 & 5 \\\\\n 6 & -7 & -5 & -5 & -8 \\\\\n -2 & -10 & 6 & -7 & -5 \\\\\n -7 & -1 & 8 & -10 & -5 \\\\\n -5 & 1 & 5 & 0 & 0 \\\\\n 1 & 8 & 8 & 0 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, 2, 4, -2, 0],\n [-4, -1, 9, -1, 5],\n [6, -7, -5, -5, -8],\n [-2, -10, 6, -7, -5],\n [-7, -1, 8, -10, -5],\n [-5, 1, 5, 0, 0],\n [1, 8, 8, 0, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 1 & -1 \\\\\n -4 & 3 & 2 \\\\\n -4 & 4 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-70$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, -1],\n [-4, 3, 2],\n [-4, 4, -5]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -3 & -5 & -4 \\\\\n \\frac{5}{3} & 0 & -1 \\\\\n \\frac{8}{3} & \\frac{13}{3} & -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{39}{532} & \\frac{321}{532} & -\\frac{45}{532} \\\\\n -\\frac{31}{532} & -\\frac{195}{532} & \\frac{87}{532} \\\\\n -\\frac{65}{532} & \\frac{3}{532} & -\\frac{75}{532} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -5, -4],\n [(5/3), 0, -1],\n [(8/3), (13/3), -(11/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{11}{3},1,-\\frac{2}{3}\\right\\}, \\left\\{-\\frac{1}{3},-\\frac{7}{3},\\frac{4}{3}\\right\\}, \\left\\{-2,-\\frac{10}{3},\\frac{7}{3}\\right\\}}$.", - "Output Answer": [ - "$-18 x+9 y-21 z+43=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(11/3), 1, -(2/3)],\n [-(1/3), -(7/3), (4/3)],\n [-2, -(10/3), (7/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -2 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -10 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(5 \\sqrt{\\frac{3}{4186}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-2],\n [5]]).squeeze()\nb = np.array([\n [5],\n [-10],\n [6]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{25}{4} & -\\frac{5}{4} & \\frac{5}{2} \\\\\n \\frac{19}{4} & \\frac{7}{4} & \\frac{7}{2} \\\\\n \\frac{19}{4} & 3 & -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-9.096,3.685,5.911\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(25/4), -(5/4), (5/2)],\n [(19/4), (7/4), (7/2)],\n [(19/4), 3, -(15/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{19}{2} & 8 & \\frac{69}{8} & 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{7}{8} & \\frac{3}{4} & \\frac{19}{2} & \\frac{77}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{69}{8} & \\frac{35}{4} & \\frac{145}{8} & \\frac{125}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/2), 8, (69/8), 6]])\nb = np.array([\n [-(7/8), (3/4), (19/2), (77/8)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n -1 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{1}{\\sqrt{11}} \\\\\n -\\frac{1}{\\sqrt{11}} \\\\\n -\\frac{3}{\\sqrt{11}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [-1],\n [-3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2}+\\frac{7 i}{2} & -\\frac{1}{2}-3 i \\\\\n -2+i & -3-\\frac{9 i}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -8+2 i & -\\frac{5}{4}+11 i \\\\\n 8-\\frac{3 i}{2} & -\\frac{29}{4}+\\frac{65 i}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2)+((7j)/2), -(1/2)-3j],\n [-2+ 1j, -3-((9j)/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n 8 & -4 & -5 & -9 & 1 \\\\\n 2 & 10 & -5 & -6 & 0 \\\\\n -6 & -3 & 1 & 7 & -9 \\\\\n 7 & 2 & -3 & -7 & -6 \\\\\n 3 & 3 & -4 & 2 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -4, -5, -9, 1],\n [2, 10, -5, -6, 0],\n [-6, -3, 1, 7, -9],\n [7, 2, -3, -7, -6],\n [3, 3, -4, 2, -6]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{7}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{10}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10]])\nprint(a * (1/7))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 1 & 9 \\\\\n 8 & -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 8 & -2 \\\\\n 2 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 9 & 7 \\\\\n 10 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 9],\n [8, -9]])\nb = np.array([\n [8, -2],\n [2, 4]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n 3 \\\\\n 2 \\\\\n 1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\sqrt{\\frac{2}{13}} \\\\\n -\\sqrt{\\frac{2}{13}} \\\\\n \\frac{3}{\\sqrt{26}} \\\\\n \\sqrt{\\frac{2}{13}} \\\\\n \\frac{1}{\\sqrt{26}} \\\\\n -\\sqrt{\\frac{2}{13}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-2],\n [3],\n [2],\n [1],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [1],\n [1],\n [0],\n [-1]]).squeeze()\nb = np.array([\n [1],\n [-1],\n [-1],\n [1],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{19}{5} & \\frac{22}{5} & \\frac{33}{5} \\\\\n -\\frac{47}{5} & 6 & \\frac{44}{5} \\\\\n -\\frac{18}{5} & \\frac{38}{5} & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{44 x^2}{5}-\\frac{281 x}{25}-\\frac{19666}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/5), (22/5), (33/5)],\n [-(47/5), 6, (44/5)],\n [-(18/5), (38/5), -1]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{25}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 6 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{27}{25} \\\\\n \\frac{18}{25} \\\\\n -\\frac{6}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [6],\n [-2]])\nprint(a * (3/25))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & 3 \\\\\n \\frac{3}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{27}{4} & 3 \\\\\n \\frac{3}{2} & \\frac{43}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), 3],\n [(3/2), (5/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -7 & 2 & 10 & -6 & 4 \\\\\n 3 & 3 & -8 & 7 & 10 \\\\\n 2 & 6 & 1 & 4 & -5 \\\\\n -6 & 7 & 1 & -9 & -2 \\\\\n -6 & 4 & 0 & 4 & 4 \\\\\n -2 & 0 & -7 & -9 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, 2, 10, -6, 4],\n [3, 3, -8, 7, 10],\n [2, 6, 1, 4, -5],\n [-6, 7, 1, -9, -2],\n [-6, 4, 0, 4, 4],\n [-2, 0, -7, -9, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -2 & -5 & -10 & 0 & -8 \\\\\n 9 & -1 & 10 & -10 & 8 \\\\\n -1 & -4 & -6 & 1 & 6 \\\\\n -10 & 4 & 2 & -5 & 2 \\\\\n 7 & -8 & 10 & -5 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, -5, -10, 0, -8],\n [9, -1, 10, -10, 8],\n [-1, -4, -6, 1, 6],\n [-10, 4, 2, -5, 2],\n [7, -8, 10, -5, -1]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{44}{7} & 2 & -\\frac{24}{7} & \\frac{68}{7} \\\\\n -\\frac{3}{7} & -\\frac{61}{7} & -\\frac{9}{7} & \\frac{29}{7} \\\\\n -\\frac{55}{7} & \\frac{23}{7} & \\frac{12}{7} & \\frac{19}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n \\frac{6}{7} & \\frac{33}{7} & \\frac{34}{7} & -\\frac{50}{7} \\\\\n -\\frac{22}{7} & -\\frac{54}{7} & -\\frac{23}{7} & \\frac{38}{7} \\\\\n \\frac{23}{7} & -\\frac{24}{7} & -\\frac{34}{7} & -\\frac{34}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{50}{7} & -\\frac{19}{7} & -\\frac{58}{7} & \\frac{118}{7} \\\\\n \\frac{19}{7} & -1 & 2 & -\\frac{9}{7} \\\\\n -\\frac{78}{7} & \\frac{47}{7} & \\frac{46}{7} & \\frac{53}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(44/7), 2, -(24/7), (68/7)],\n [-(3/7), -(61/7), -(9/7), (29/7)],\n [-(55/7), (23/7), (12/7), (19/7)]])\nb = np.array([\n [(6/7), (33/7), (34/7), -(50/7)],\n [-(22/7), -(54/7), -(23/7), (38/7)],\n [(23/7), -(24/7), -(34/7), -(34/7)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 0 & 2 & 6 \\\\\n 2 & 9 & 5 \\\\\n 7 & 9 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.978,-0.207,1.\\}, \\{0.518,0.961,1.\\}, \\{1.474,-1.21,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, 6],\n [2, 9, 5],\n [7, 9, 3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,1,-4\\}, \\{-2,-2,-3\\}, \\{-4,3,-2\\}}$.", - "Output Answer": [ - "$8 x-3 y+31 z+103=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, 1, -4],\n [-2, -2, -3],\n [-4, 3, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{19}{2} & 8 \\\\\n -\\frac{3}{2} & -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-17-2 i \\sqrt{11}\\right),\\frac{1}{2} \\left(-17+2 i \\sqrt{11}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/2), 8],\n [-(3/2), -(15/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -3 & -\\frac{9}{2} & \\frac{11}{2} & -5 \\\\\n \\frac{5}{4} & -\\frac{9}{2} & -\\frac{31}{4} & -\\frac{9}{4} \\\\\n -\\frac{17}{2} & -\\frac{11}{4} & -4 & -\\frac{1}{4} \\\\\n -4 & \\frac{23}{4} & -\\frac{11}{2} & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{13}{2} & \\frac{9}{2} & \\frac{31}{4} & 8 \\\\\n \\frac{1}{2} & -\\frac{35}{4} & 8 & -\\frac{11}{2} \\\\\n -6 & -\\frac{1}{2} & -\\frac{7}{2} & \\frac{7}{4} \\\\\n -\\frac{1}{4} & 10 & \\frac{29}{4} & -\\frac{39}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{7}{2} & -9 & -\\frac{9}{4} & -13 \\\\\n \\frac{3}{4} & \\frac{17}{4} & -\\frac{63}{4} & \\frac{13}{4} \\\\\n -\\frac{5}{2} & -\\frac{9}{4} & -\\frac{1}{2} & -2 \\\\\n -\\frac{15}{4} & -\\frac{17}{4} & -\\frac{51}{4} & \\frac{21}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -(9/2), (11/2), -5],\n [(5/4), -(9/2), -(31/4), -(9/4)],\n [-(17/2), -(11/4), -4, -(1/4)],\n [-4, (23/4), -(11/2), -(9/2)]])\nb = np.array([\n [-(13/2), (9/2), (31/4), 8],\n [(1/2), -(35/4), 8, -(11/2)],\n [-6, -(1/2), -(7/2), (7/4)],\n [-(1/4), 10, (29/4), -(39/4)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{4}{3}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & -7 & 5 \\\\\n -1 & 0 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & -\\frac{28}{3} & \\frac{20}{3} \\\\\n -\\frac{4}{3} & 0 & \\frac{28}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -7, 5],\n [-1, 0, 7]])\nprint(a * (4/3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -8 & 3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -4 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -4 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 3]])\nb = np.array([\n [-4, 6]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{13}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [0]])\nb = np.array([\n [1],\n [-6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & 8 \\\\\n 4 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-8 x-25$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 8],\n [4, 1]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -3 & 8 \\\\\n 8 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} \\left(1-\\sqrt{17}\\right),1\\right\\}, \\left\\{\\frac{1}{4} \\left(1+\\sqrt{17}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 8],\n [8, -7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\log (2) \\\\\n 13 \\log (2) \\\\\n -8 \\log (2) \\\\\n -14 \\log (2) \\\\\n 13 \\log (2) \\\\\n 10 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\log (2) \\\\\n 4 \\log (2) \\\\\n 13 \\log (2) \\\\\n 6 \\log (2) \\\\\n 10 \\log (2) \\\\\n -10 \\log (2) \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-104 \\log ^2(2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.log(2)],\n [13*math.log(2)],\n [-8*math.log(2)],\n [-14*math.log(2)],\n [13*math.log(2)],\n [10*math.log(2)]])\nb = np.array([\n [2*math.log(2)],\n [4*math.log(2)],\n [13*math.log(2)],\n [6*math.log(2)],\n [10*math.log(2)],\n [-10*math.log(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & -\\frac{3}{4} \\\\\n \\frac{29}{4} & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-3 x-\\frac{777}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -(3/4)],\n [(29/4), 9]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -3 & -3 & -10 \\\\\n -3 & -6 & -3 \\\\\n -8 & 5 & 7 \\\\\n 6 & -4 & -10 \\\\\n 10 & -10 & 9 \\\\\n -7 & 8 & 5 \\\\\n -5 & -5 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, -3, -10],\n [-3, -6, -3],\n [-8, 5, 7],\n [6, -4, -10],\n [10, -10, 9],\n [-7, 8, 5],\n [-5, -5, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 9 & 5 & -7 \\\\\n -4 & 2 & -1 \\\\\n -7 & -1 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+10 x^2+23 x-138$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 5, -7],\n [-4, 2, -1],\n [-7, -1, -1]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & -3 & 1 & 0 \\\\\n -3 & 2 & 3 & 2 \\\\\n -3 & -1 & -3 & 1 \\\\\n -2 & 3 & 1 & 3 \\\\\n 1 & 0 & -1 & -1 \\\\\n 1 & -3 & 0 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.99 \\\\\n -0.15 \\\\\n -2.06 \\\\\n 0.2 \\\\\n -2.26 \\\\\n 2.53 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.785 \\\\\n 0.448 \\\\\n -0.116 \\\\\n 0.74 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3, 1, 0],\n [-3, 2, 3, 2],\n [-3, -1, -3, 1],\n [-2, 3, 1, 3],\n [1, 0, -1, -1],\n [1, -3, 0, 3]])\nb = np.array([\n [-2.99],\n [-0.15],\n [-2.06],\n [0.2],\n [-2.26],\n [2.53]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -6 \\\\\n -8 \\\\\n 2 \\\\\n -8 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 6 \\\\\n -9 \\\\\n 4 \\\\\n -4 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{202}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-6],\n [-8],\n [2],\n [-8],\n [1]])\nb = np.array([\n [-2],\n [6],\n [-9],\n [4],\n [-4],\n [-5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 \\\\\n 6 \\\\\n 3 \\\\\n 3 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 9 \\\\\n -2 \\\\\n -1 \\\\\n -6 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-34$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [3],\n [6],\n [3],\n [3],\n [4]])\nb = np.array([\n [7],\n [9],\n [-2],\n [-1],\n [-6],\n [-7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{2}{3} & -4 & -8 \\\\\n -\\frac{1}{3} & -\\frac{25}{3} & \\frac{11}{3} \\\\\n -\\frac{11}{3} & -\\frac{13}{3} & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6.996-3.165 i,-6.996+3.165 i,4.659\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3), -4, -8],\n [-(1/3), -(25/3), (11/3)],\n [-(11/3), -(13/3), -(1/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\sqrt{2} \\\\\n 7 \\sqrt{2} \\\\\n \\sqrt{2} \\\\\n 5 \\sqrt{2} \\\\\n -6 \\sqrt{2} \\\\\n -5 \\sqrt{2} \\\\\n 0 \\\\\n 2 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\sqrt{2} \\\\\n 6 \\sqrt{2} \\\\\n -4 \\sqrt{2} \\\\\n 0 \\\\\n 3 \\sqrt{2} \\\\\n 3 \\sqrt{2} \\\\\n -\\sqrt{2} \\\\\n 4 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{410}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.sqrt(2)],\n [7*math.sqrt(2)],\n [math.sqrt(2)],\n [5*math.sqrt(2)],\n [-6*math.sqrt(2)],\n [-5*math.sqrt(2)],\n [0],\n [2*math.sqrt(2)]])\nb = np.array([\n [3*math.sqrt(2)],\n [6*math.sqrt(2)],\n [-4*math.sqrt(2)],\n [0],\n [3*math.sqrt(2)],\n [3*math.sqrt(2)],\n [-math.sqrt(2)],\n [4*math.sqrt(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{15}{2} & \\frac{7}{4} & \\frac{1}{2} \\\\\n -\\frac{5}{2} & \\frac{15}{4} & -\\frac{37}{4} \\\\\n -\\frac{5}{4} & -8 & -\\frac{5}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-5 x^2+\\frac{1479 x}{16}+\\frac{39505}{64}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/2), (7/4), (1/2)],\n [-(5/2), (15/4), -(37/4)],\n [-(5/4), -8, -(5/4)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & -1 & -1 & -1 \\\\\n -3 & -1 & -1 & -2 \\\\\n 2 & -3 & 2 & -2 \\\\\n -3 & 3 & -1 & -3 \\\\\n 2 & 2 & 3 & 0 \\\\\n 1 & 2 & 0 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.46 \\\\\n -0.92 \\\\\n -1.08 \\\\\n 0.06 \\\\\n -1.6 \\\\\n -0.15 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.331 \\\\\n -0.1 \\\\\n -0.193 \\\\\n 0.354 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1, -1, -1],\n [-3, -1, -1, -2],\n [2, -3, 2, -2],\n [-3, 3, -1, -3],\n [2, 2, 3, 0],\n [1, 2, 0, 0]])\nb = np.array([\n [2.46],\n [-0.92],\n [-1.08],\n [0.06],\n [-1.6],\n [-0.15]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{8}{3} & 7 & \\frac{85}{9} \\\\\n \\frac{79}{9} & -1 & -3 \\\\\n 7 & \\frac{16}{9} & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{5 x^2}{3}+\\frac{1142 x}{9}-\\frac{47594}{729}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/3), 7, (85/9)],\n [(79/9), -1, -3],\n [7, (16/9), 2]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{8}{3} & \\frac{8}{3} & \\frac{7}{3} \\\\\n -\\frac{5}{3} & -\\frac{8}{3} & -\\frac{1}{3} \\\\\n -\\frac{14}{3} & -\\frac{5}{3} & -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{1289}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/3), (8/3), (7/3)],\n [-(5/3), -(8/3), -(1/3)],\n [-(14/3), -(5/3), -(8/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -7 & -7 & -3 & -5 \\\\\n -3 & -4 & 2 & -6 \\\\\n -8 & -6 & 9 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -7, -3, -5],\n [-3, -4, 2, -6],\n [-8, -6, 9, -3]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, \\frac{11}{3}, -3}$ to the plane $-2 x+\\frac{10 y}{3}-3 z+\\frac{4}{3}=0$.", - "Output Answer": [ - "$\\frac{257}{3 \\sqrt{217}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, (11/3), -3\nplane = Poly(-2*x+((10*y)/3)-3*z+(4/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n 10 & -9 & 4 & 8 & 6 \\\\\n -5 & -4 & 6 & -6 & 5 \\\\\n 7 & 9 & -3 & -6 & -7 \\\\\n -9 & 5 & 1 & -2 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -9, 4, 8, 6],\n [-5, -4, 6, -6, 5],\n [7, 9, -3, -6, -7],\n [-9, 5, 1, -2, -7]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{6} \\\\\n \\frac{5}{6} \\\\\n -\\frac{1}{6} \\\\\n -\\frac{13}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{11}{2 \\sqrt{79}} \\\\\n \\frac{5}{2 \\sqrt{79}} \\\\\n -\\frac{1}{2 \\sqrt{79}} \\\\\n -\\frac{13}{2 \\sqrt{79}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/6)],\n [(5/6)],\n [-(1/6)],\n [-(13/6)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{45}{7} \\\\\n \\frac{44}{7} \\\\\n \\frac{62}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{46}{7} \\\\\n \\frac{2}{7} \\\\\n \\frac{48}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{284}{7} \\\\\n -\\frac{716}{7} \\\\\n \\frac{302}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(45/7)],\n [(44/7)],\n [(62/7)]])\nb = np.array([\n [-(46/7)],\n [(2/7)],\n [(48/7)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & -6 & 3 \\\\\n 1 & 9 & 7 \\\\\n -3 & -3 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-5.448-3.369 i,-5.448+3.369 i,7.896\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -6, 3],\n [1, 9, 7],\n [-3, -3, -9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n \\frac{5}{2} \\\\\n -3 \\\\\n -2 \\\\\n -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{4} \\\\\n -\\frac{5}{4} \\\\\n \\frac{9}{4} \\\\\n -\\frac{3}{4} \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{31}{28},\\frac{31}{28},-\\frac{279}{140},\\frac{93}{140},0\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2)],\n [(5/2)],\n [-3],\n [-2],\n [-(3/4)]]).squeeze()\nb = np.array([\n [-(5/4)],\n [-(5/4)],\n [(9/4)],\n [-(3/4)],\n [0]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{14}{5}, \\frac{2}{5}, -\\frac{17}{5}}$ to the plane $-\\frac{x}{5}-\\frac{24 y}{5}+z+1=0$.", - "Output Answer": [ - "$\\frac{61 \\sqrt{\\frac{2}{301}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (14/5), (2/5), -(17/5)\nplane = Poly(-(x/5)-((24*y)/5)+z+1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & -3 & -2 \\\\\n 3 & 2 & 0 \\\\\n -3 & -1 & -3 \\\\\n -3 & 3 & 1 \\\\\n -2 & 3 & 3 \\\\\n 3 & -1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.3 \\\\\n 2.81 \\\\\n 0.18 \\\\\n -2.24 \\\\\n 0.58 \\\\\n 2.91 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.547 \\\\\n 0.057 \\\\\n 0.067 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, -2],\n [3, 2, 0],\n [-3, -1, -3],\n [-3, 3, 1],\n [-2, 3, 3],\n [3, -1, 3]])\nb = np.array([\n [-1.3],\n [2.81],\n [0.18],\n [-2.24],\n [0.58],\n [2.91]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{2} & \\frac{1}{6} \\\\\n \\frac{11}{3} & \\frac{17}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{379}{36}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), (1/6)],\n [(11/3), (17/6)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{8} \\\\\n \\frac{3}{4} \\\\\n -\\frac{19}{8} \\\\\n \\frac{11}{8} \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{9}{\\sqrt{743}} \\\\\n \\frac{6}{\\sqrt{743}} \\\\\n -\\frac{19}{\\sqrt{743}} \\\\\n \\frac{11}{\\sqrt{743}} \\\\\n \\frac{12}{\\sqrt{743}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/8)],\n [(3/4)],\n [-(19/8)],\n [(11/8)],\n [(3/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{119}{16} \\\\\n \\frac{55}{16} \\\\\n \\frac{19}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{43}{16} \\\\\n -6 \\\\\n \\frac{45}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{4299}{128} \\\\\n -\\frac{1543}{32} \\\\\n -\\frac{9059}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(119/16)],\n [(55/16)],\n [(19/8)]])\nb = np.array([\n [-(43/16)],\n [-6],\n [(45/8)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,1,2\\}, \\{-1,3,-2\\}, \\{-1,-4,-1\\}}$.", - "Output Answer": [ - "$x+1=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, 1, 2],\n [-1, 3, -2],\n [-1, -4, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 5 & -10 & -2 & 2 & 2 & 7 & -2 \\\\\n -4 & -10 & -2 & -7 & 10 & -4 & 10 \\\\\n -4 & -8 & -2 & 8 & 2 & 9 & -8 \\\\\n -6 & 7 & -3 & 4 & -4 & -4 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & -\\frac{1166}{2709} & \\frac{773}{2709} & -\\frac{52}{903} \\\\\n 0 & 1 & 0 & 0 & -\\frac{169}{301} & -\\frac{317}{602} & \\frac{171}{301} \\\\\n 0 & 0 & 1 & 0 & \\frac{739}{2709} & \\frac{4243}{5418} & -\\frac{2944}{903} \\\\\n 0 & 0 & 0 & 1 & -\\frac{138}{301} & \\frac{282}{301} & -\\frac{384}{301} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, -10, -2, 2, 2, 7, -2],\n [-4, -10, -2, -7, 10, -4, 10],\n [-4, -8, -2, 8, 2, 9, -8],\n [-6, 7, -3, 4, -4, -4, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,-1,-4\\}, \\{0,2,-1\\}, \\{3,-1,1\\}}$.", - "Output Answer": [ - "$15 x+y-21 z-23=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, -1, -4],\n [0, 2, -1],\n [3, -1, 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & -\\frac{9}{2} \\\\\n \\frac{17}{2} & \\frac{19}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{4} \\left(5-3 \\sqrt{53}\\right),\\frac{1}{4} \\left(5+3 \\sqrt{53}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -(9/2)],\n [(17/2), (19/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7.503 \\\\\n 8.135 \\\\\n -3.701 \\\\\n 2.258 \\\\\n -9.16 \\\\\n 0.856 \\\\\n -1.588 \\\\\n -5.324 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9.319 \\\\\n -7.076 \\\\\n 9.642 \\\\\n 9.138 \\\\\n -0.285 \\\\\n -9.552 \\\\\n -0.86 \\\\\n 3.108 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-23.4415$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7.503],\n [8.135],\n [-3.701],\n [2.258],\n [-9.16],\n [0.856],\n [-1.588],\n [-5.324]])\nb = np.array([\n [9.319],\n [-7.076],\n [9.642],\n [9.138],\n [-0.285],\n [-9.552],\n [-0.86],\n [3.108]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 4 & -1 & \\frac{43}{9} \\\\\n 2 & -\\frac{16}{9} & \\frac{13}{9} \\\\\n \\frac{38}{9} & \\frac{19}{9} & -\\frac{37}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{621}{8566} & \\frac{2178}{21415} & \\frac{5139}{42830} \\\\\n \\frac{1044}{4283} & -\\frac{13347}{21415} & \\frac{1377}{21415} \\\\\n \\frac{855}{4283} & -\\frac{4617}{21415} & -\\frac{1863}{21415} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -1, (43/9)],\n [2, -(16/9), (13/9)],\n [(38/9), (19/9), -(37/9)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 3 & -1 & 3 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -2 & 1 & -2 & -1 \\\\\n 0 & 3 & -2 & 2 \\\\\n 1 & 0 & 0 & -3 \\\\\n 2 & -3 & -2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -3 & 0 & -4 & -14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, 3, 0]])\nb = np.array([\n [-2, 1, -2, -1],\n [0, 3, -2, 2],\n [1, 0, 0, -3],\n [2, -3, -2, 0]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{133}{16} & -\\frac{21}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{16} & -\\frac{59}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{17}{2} & \\frac{17}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(133/16), -(21/8)]])\nb = np.array([\n [-(3/16), -(59/16)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8.1 \\\\\n 6.1 \\\\\n 7.3 \\\\\n 3.6 \\\\\n 9.6 \\\\\n -5.3 \\\\\n 6.6 \\\\\n 5.3 \\\\\n 2. \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0.7 \\\\\n 9.5 \\\\\n -7.4 \\\\\n -3.6 \\\\\n -7.4 \\\\\n -0.9 \\\\\n -7.5 \\\\\n 1.5 \\\\\n -2.7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$30.0105$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8.1],\n [6.1],\n [7.3],\n [3.6],\n [9.6],\n [-5.3],\n [6.6],\n [5.3],\n [2.]])\nb = np.array([\n [0.7],\n [9.5],\n [-7.4],\n [-3.6],\n [-7.4],\n [-0.9],\n [-7.5],\n [1.5],\n [-2.7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\sqrt{3} \\\\\n -3 \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n -4 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{210}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-math.sqrt(3)],\n [-3*math.sqrt(3)],\n [math.sqrt(3)],\n [3*math.sqrt(3)]])\nb = np.array([\n [2*math.sqrt(3)],\n [3*math.sqrt(3)],\n [-4*math.sqrt(3)],\n [3*math.sqrt(3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{13}{8} & \\frac{57}{8} \\\\\n -\\frac{25}{8} & -\\frac{71}{8} \\\\\n \\frac{35}{8} & \\frac{1}{4} \\\\\n -\\frac{35}{4} & \\frac{31}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{33}{8} & -8 \\\\\n -5 & -\\frac{21}{4} \\\\\n -\\frac{31}{4} & \\frac{1}{2} \\\\\n \\frac{27}{8} & -\\frac{43}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{23}{4} & \\frac{121}{8} \\\\\n \\frac{15}{8} & -\\frac{29}{8} \\\\\n \\frac{97}{8} & -\\frac{1}{4} \\\\\n -\\frac{97}{8} & \\frac{105}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/8), (57/8)],\n [-(25/8), -(71/8)],\n [(35/8), (1/4)],\n [-(35/4), (31/4)]])\nb = np.array([\n [-(33/8), -8],\n [-5, -(21/4)],\n [-(31/4), (1/2)],\n [(27/8), -(43/8)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 7 \\\\\n -4 \\\\\n 1 \\\\\n 6 \\\\\n -7 \\\\\n 4 \\\\\n 5 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 0 \\\\\n -2 \\\\\n 3 \\\\\n 6 \\\\\n -1 \\\\\n 10 \\\\\n -3 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{330}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [7],\n [-4],\n [1],\n [6],\n [-7],\n [4],\n [5],\n [1]])\nb = np.array([\n [8],\n [0],\n [-2],\n [3],\n [6],\n [-1],\n [10],\n [-3],\n [5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -2 & -8 & -4 \\\\\n -5 & 4 & 4 \\\\\n 5 & -9 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-4 x-236$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -8, -4],\n [-5, 4, 4],\n [5, -9, -2]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{9}{2}, -\\frac{5}{2}, -\\frac{3}{2}}$ to the plane $4 x+\\frac{y}{2}-3=0$.", - "Output Answer": [ - "$\\frac{89}{2 \\sqrt{65}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(9/2), -(5/2), -(3/2)\nplane = Poly(4*x+(y/2)-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -3 & 9 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -10 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 7 & 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 9]])\nb = np.array([\n [-10, -3]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,1,1\\}, \\{-2,-3,0\\}, \\{-2,-3,2\\}}$", - "Output Answer": [ - "${\\left\\{\\sqrt{\\frac{2}{3}},\\frac{1}{\\sqrt{6}},\\frac{1}{\\sqrt{6}}\\right\\}, \\left\\{\\sqrt{\\frac{2}{87}},-\\frac{11}{\\sqrt{174}},\\frac{7}{\\sqrt{174}}\\right\\}, \\left\\{-\\frac{3}{\\sqrt{29}},\\frac{2}{\\sqrt{29}},\\frac{4}{\\sqrt{29}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, 1, 1), (-2, -3, 0), (-2, -3, 2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 5 & -8 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-3.,0.,5.\\}, \\{8.,5.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, -8, 3]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{2}{3}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -4 \\\\\n -\\frac{4}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [2]])\nprint(a * -(2/3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{9}{2} & -\\frac{49}{8} & -\\frac{5}{4} \\\\\n \\frac{55}{8} & -6 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{15}{2} & -\\frac{1}{4} & -\\frac{15}{4} \\\\\n \\frac{69}{8} & -2 & \\frac{53}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 3 & -\\frac{47}{8} & \\frac{5}{2} \\\\\n -\\frac{7}{4} & -4 & -\\frac{65}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2), -(49/8), -(5/4)],\n [(55/8), -6, -(3/2)]])\nb = np.array([\n [-(15/2), -(1/4), -(15/4)],\n [(69/8), -2, (53/8)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -8 \\\\\n -10 \\\\\n -5 \\\\\n 5 \\\\\n 7 \\\\\n -6 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 6 \\\\\n -3 \\\\\n 2 \\\\\n -1 \\\\\n 7 \\\\\n -4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{419}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-8],\n [-10],\n [-5],\n [5],\n [7],\n [-6],\n [0]])\nb = np.array([\n [4],\n [6],\n [-3],\n [2],\n [-1],\n [7],\n [-4],\n [-2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-5, 3, -2}$ to the plane $-5 x-4 y+3 z+1=0$.", - "Output Answer": [ - "$\\frac{4 \\sqrt{2}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -5, 3, -2\nplane = Poly(-5*x-4*y+3*z+1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 6 & 6 & 6 \\\\\n -1 & -8 & -5 \\\\\n 0 & -6 & 6 \\\\\n -5 & 6 & 0 \\\\\n 10 & -5 & 2 \\\\\n 0 & -4 & -3 \\\\\n 8 & 9 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, 6, 6],\n [-1, -8, -5],\n [0, -6, 6],\n [-5, 6, 0],\n [10, -5, 2],\n [0, -4, -3],\n [8, 9, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{14}{5} & -\\frac{5}{2} \\\\\n \\frac{24}{5} & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{11}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/5), -(5/2)],\n [(24/5), -(7/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 0 \\\\\n 9 \\\\\n 4 \\\\\n 5 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{187}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [0],\n [9],\n [4],\n [5],\n [4]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n \\frac{1}{2} & 5 & -\\frac{5}{2} & \\frac{29}{4} \\\\\n \\frac{15}{4} & -\\frac{13}{2} & -9 & \\frac{15}{2} \\\\\n \\frac{39}{4} & \\frac{13}{2} & -\\frac{27}{4} & \\frac{31}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), 5, -(5/2), (29/4)],\n [(15/4), -(13/2), -9, (15/2)],\n [(39/4), (13/2), -(27/4), (31/4)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{2} \\\\\n 9 \\\\\n -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -\\frac{13}{2} \\\\\n -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{\\frac{663}{2}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/2)],\n [9],\n [-(17/2)]])\nb = np.array([\n [2],\n [-(13/2)],\n [-(15/2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(2 \\sqrt{2}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [-1],\n [0],\n [0]]).squeeze()\nb = np.array([\n [-1],\n [-1],\n [0],\n [-1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{25}{16} & \\frac{41}{8} \\\\\n -\\frac{25}{16} & -\\frac{59}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{143 x}{16}+\\frac{625}{32}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/16), (41/8)],\n [-(25/16), -(59/8)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -2 \\\\\n -8 \\\\\n 9 \\\\\n -9 \\\\\n 3 \\\\\n 6 \\\\\n 2 \\\\\n 0 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -2 \\\\\n 4 \\\\\n 1 \\\\\n -4 \\\\\n -2 \\\\\n -10 \\\\\n 8 \\\\\n -5 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$11 \\sqrt{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-2],\n [-8],\n [9],\n [-9],\n [3],\n [6],\n [2],\n [0],\n [9]])\nb = np.array([\n [-9],\n [-2],\n [4],\n [1],\n [-4],\n [-2],\n [-10],\n [8],\n [-5],\n [-7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,3,1\\}, \\{0,0,-4\\}, \\{2,0,-5\\}}$.", - "Output Answer": [ - "$3 (x+2 z+8)-10 y=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, 3, 1],\n [0, 0, -4],\n [2, 0, -5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, -\\frac{11}{3}}$ to the line $\\frac{7 x}{3}-\\frac{y}{3}-\\frac{4}{3}=0$.", - "Output Answer": [ - "$\\frac{43}{15 \\sqrt{2}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, -(11/3)\nline = Poly(((7*x)/3)-(y/3)-(4/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -6 & -6 & 10 & 5 \\\\\n 9 & 10 & 7 & 7 \\\\\n -5 & -9 & 8 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{137.,-257.,-335.,526.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-6, -6, 10, 5],\n [9, 10, 7, 7],\n [-5, -9, 8, 2]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & \\frac{1}{2} \\\\\n 0 & 2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{27}{8} & \\frac{37}{8} \\\\\n 0 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), (1/2)],\n [0, 2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{16}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 8 & -6 & 6 \\\\\n -2 & 6 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{3}{2} & -\\frac{9}{8} & \\frac{9}{8} \\\\\n -\\frac{3}{8} & \\frac{9}{8} & \\frac{15}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -6, 6],\n [-2, 6, 10]])\nprint(a * (3/16))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -2 & -2 \\\\\n 0 & \\frac{8}{3} \\\\\n -\\frac{8}{3} & \\frac{7}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -2 & 0 & \\frac{7}{3} \\\\\n -\\frac{7}{3} & \\frac{1}{3} & \\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{26}{3} & -\\frac{2}{3} & -10 \\\\\n -\\frac{56}{9} & \\frac{8}{9} & \\frac{64}{9} \\\\\n -\\frac{1}{9} & \\frac{7}{9} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2],\n [0, (8/3)],\n [-(8/3), (7/3)]])\nb = np.array([\n [-2, 0, (7/3)],\n [-(7/3), (1/3), (8/3)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -1 & -1 \\\\\n -1 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & -1 & -1 & -2 \\\\\n -3 & 0 & -2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 1 & 3 & 5 \\\\\n -2 & 1 & 1 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1],\n [-1, 0]])\nb = np.array([\n [2, -1, -1, -2],\n [-3, 0, -2, -3]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{7}{2},-3,1\\right\\}, \\left\\{4,\\frac{7}{2},-\\frac{3}{2}\\right\\}, \\{0,1,4\\}}$.", - "Output Answer": [ - "$118 x-125 y+29 z+9=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(7/2), -3, 1],\n [4, (7/2), -(3/2)],\n [0, 1, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 5 & -10 \\\\\n -9 & -10 \\\\\n 9 & 2 \\\\\n -10 & -8 \\\\\n 4 & 10 \\\\\n 6 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, -10],\n [-9, -10],\n [9, 2],\n [-10, -8],\n [4, 10],\n [6, 5]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, \\frac{7}{2}, -5}$ to the plane $-\\frac{7 x}{2}+5 z-4=0$.", - "Output Answer": [ - "$\\frac{79}{\\sqrt{149}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, (7/2), -5\nplane = Poly(-((7*x)/2)+5*z-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & -1 & 3 & -2 \\\\\n -3 & 0 & 0 & 1 \\\\\n -1 & -2 & 3 & 1 \\\\\n 1 & 1 & 1 & 3 \\\\\n -3 & 2 & -2 & -2 \\\\\n -2 & -1 & -1 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.32 \\\\\n 1.86 \\\\\n -2.58 \\\\\n 2.73 \\\\\n 0.22 \\\\\n 0.64 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.177 \\\\\n 0.839 \\\\\n 0.149 \\\\\n 0.396 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -1, 3, -2],\n [-3, 0, 0, 1],\n [-1, -2, 3, 1],\n [1, 1, 1, 3],\n [-3, 2, -2, -2],\n [-2, -1, -1, 0]])\nb = np.array([\n [0.32],\n [1.86],\n [-2.58],\n [2.73],\n [0.22],\n [0.64]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 3 & 0 & 1 \\\\\n 0 & -3 & 1 \\\\\n -4 & -2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{3} & \\frac{1}{3} & -\\frac{1}{2} \\\\\n \\frac{2}{3} & -\\frac{2}{3} & \\frac{1}{2} \\\\\n 2 & -1 & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 0, 1],\n [0, -3, 1],\n [-4, -2, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{1}{5}, -\\frac{14}{5}, -\\frac{1}{5}}$ to the plane $-\\frac{17 x}{5}-\\frac{16 y}{5}-\\frac{21 z}{5}-\\frac{6}{5}=0$.", - "Output Answer": [ - "$\\frac{99 \\sqrt{\\frac{2}{493}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (1/5), -(14/5), -(1/5)\nplane = Poly(-((17*x)/5)-((16*y)/5)-((21*z)/5)-(6/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n 10 & -9 & -5 \\\\\n 2 & -10 & 1 \\\\\n -8 & 8 & -8 \\\\\n -1 & 0 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -9, -5],\n [2, -10, 1],\n [-8, 8, -8],\n [-1, 0, 5]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 3 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -3 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 15 \\\\\n 30 \\\\\n 30 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [3],\n [0]])\nb = np.array([\n [-4],\n [-3],\n [5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -\\frac{5}{4} & -\\frac{7}{4} & -\\frac{1}{2} & -\\frac{21}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/4), -(7/4), -(1/2), -(21/4)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -3 \\\\\n 2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 2 \\\\\n 0 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{2}{3},-\\frac{2}{3},0,-\\frac{2}{3}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-3],\n [2],\n [0]]).squeeze()\nb = np.array([\n [-2],\n [2],\n [0],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 4 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [4],\n [8]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n 9 & 8 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 8, 0]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{57}{10} & -\\frac{4}{5} & -4 \\\\\n -\\frac{61}{10} & \\frac{17}{10} & \\frac{7}{5} \\\\\n -\\frac{87}{10} & -\\frac{71}{10} & \\frac{3}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{17 x^2}{5}+\\frac{4183 x}{100}-\\frac{36007}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(57/10), -(4/5), -4],\n [-(61/10), (17/10), (7/5)],\n [-(87/10), -(71/10), (3/5)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{16}{3} & -\\frac{25}{3} \\\\\n -9 & \\frac{29}{3} \\\\\n \\frac{11}{3} & \\frac{26}{3} \\\\\n 3 & -1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{29}{3} & -\\frac{25}{3} \\\\\n -\\frac{26}{3} & 1 \\\\\n \\frac{26}{3} & -1 \\\\\n -\\frac{29}{3} & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{13}{3} & 0 \\\\\n -\\frac{1}{3} & \\frac{26}{3} \\\\\n -5 & \\frac{29}{3} \\\\\n \\frac{38}{3} & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(16/3), -(25/3)],\n [-9, (29/3)],\n [(11/3), (26/3)],\n [3, -1]])\nb = np.array([\n [-(29/3), -(25/3)],\n [-(26/3), 1],\n [(26/3), -1],\n [-(29/3), 6]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 0 & 6 & -9 & 7 \\\\\n -2 & -3 & 10 & 9 \\\\\n -5 & -4 & -3 & -9 \\\\\n 1 & 10 & 7 & -7 \\\\\n 7 & 4 & -10 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, 6, -9, 7],\n [-2, -3, 10, 9],\n [-5, -4, -3, -9],\n [1, 10, 7, -7],\n [7, 4, -10, 5]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{2}{\\sqrt{5}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [1],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [1],\n [-1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & 0 & 1 \\\\\n 2 & -2 & 1 \\\\\n 2 & 3 & 0 \\\\\n 2 & 3 & -2 \\\\\n 1 & 0 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.59 \\\\\n 0.82 \\\\\n 2.86 \\\\\n 0.04 \\\\\n 1.47 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.429 \\\\\n 0.138 \\\\\n -0.075 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 0, 1],\n [2, -2, 1],\n [2, 3, 0],\n [2, 3, -2],\n [1, 0, -3]])\nb = np.array([\n [0.59],\n [0.82],\n [2.86],\n [0.04],\n [1.47]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{2} \\\\\n 2 \\\\\n -10 \\\\\n -6 \\\\\n -7 \\\\\n -4 \\\\\n -3 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{91}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/2)],\n [2],\n [-10],\n [-6],\n [-7],\n [-4],\n [-3],\n [-5]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & 0 & -3 & 1 \\\\\n 2 & 3 & 1 & 3 \\\\\n -1 & 3 & 2 & -2 \\\\\n 2 & -1 & -1 & -2 \\\\\n -1 & 2 & 3 & 1 \\\\\n 0 & -1 & 3 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.82 \\\\\n 0.22 \\\\\n 0.62 \\\\\n -2.61 \\\\\n -0.36 \\\\\n 0.08 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.398 \\\\\n 0.075 \\\\\n 0.035 \\\\\n 0.239 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, -3, 1],\n [2, 3, 1, 3],\n [-1, 3, 2, -2],\n [2, -1, -1, -2],\n [-1, 2, 3, 1],\n [0, -1, 3, 0]])\nb = np.array([\n [0.82],\n [0.22],\n [0.62],\n [-2.61],\n [-0.36],\n [0.08]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{122}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [4]])\nb = np.array([\n [7],\n [5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $1$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & 0 \\\\\n 9 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -1 & 0 \\\\\n 9 & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0],\n [9, -9]])\nprint(a * 1)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-4,-\\frac{2}{3},\\frac{1}{3}\\right\\}, \\left\\{-\\frac{1}{3},-5,1\\right\\}, \\left\\{-\\frac{2}{3},-\\frac{7}{3},-\\frac{5}{3}\\right\\}}$.", - "Output Answer": [ - "$264 x+258 y+225 z+1153=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, -(2/3), (1/3)],\n [-(1/3), -5, 1],\n [-(2/3), -(7/3), -(5/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 7 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 2 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 45 \\\\\n 40 \\\\\n 38 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [7],\n [-5]])\nb = np.array([\n [-6],\n [2],\n [5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & -4 \\\\\n -\\frac{3}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{27}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), -4],\n [-(3/2), -(1/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & -1 \\\\\n -3 & 0 \\\\\n 0 & 3 \\\\\n 0 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.43 \\\\\n 0.81 \\\\\n 1.1 \\\\\n 0.45 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.442 \\\\\n 0.44 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1],\n [-3, 0],\n [0, 3],\n [0, -1]])\nb = np.array([\n [-2.43],\n [0.81],\n [1.1],\n [0.45]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -8 & 5 & 4 & \\frac{3}{2} & -9 \\\\\n -\\frac{7}{2} & \\frac{1}{2} & -\\frac{5}{2} & 1 & 0 \\\\\n -2 & -\\frac{3}{2} & 9 & -5 & 0 \\\\\n 3 & 5 & -6 & -\\frac{17}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 5, 4, (3/2), -9],\n [-(7/2), (1/2), -(5/2), 1, 0],\n [-2, -(3/2), 9, -5, 0],\n [3, 5, -6, -(17/2), (1/2)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & 0 & -1 \\\\\n 3 & -5 & -3 \\\\\n 4 & 0 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-20$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, -1],\n [3, -5, -3],\n [4, 0, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{2} \\\\\n \\frac{19}{4} \\\\\n 0 \\\\\n -\\frac{7}{4} \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -\\frac{33}{4} \\\\\n -7 \\\\\n \\frac{19}{2} \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1421}{3 \\sqrt{670294}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/2)],\n [(19/4)],\n [0],\n [-(7/4)],\n [-3]]).squeeze()\nb = np.array([\n [6],\n [-(33/4)],\n [-7],\n [(19/2)],\n [-4]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{9}{2},\\frac{5}{2},\\frac{5}{2}\\right\\}, \\left\\{-3,\\frac{5}{2},2\\right\\}, \\{1,-3,3\\}}$.", - "Output Answer": [ - "$x-2 y-15 z+38=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(9/2), (5/2), (5/2)],\n [-3, (5/2), 2],\n [1, -3, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n 7 & -2 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -2, -5]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{44}{5} & \\frac{23}{5} & -\\frac{41}{5} \\\\\n -\\frac{11}{5} & -\\frac{12}{5} & -\\frac{46}{5} \\\\\n -\\frac{16}{5} & \\frac{39}{5} & \\frac{47}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6.297,-0.045,4.542\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(44/5), (23/5), -(41/5)],\n [-(11/5), -(12/5), -(46/5)],\n [-(16/5), (39/5), (47/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -9 \\\\\n -7 \\\\\n 5 \\\\\n -3 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -10 \\\\\n 5 \\\\\n 10 \\\\\n 4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$84$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-9],\n [-7],\n [5],\n [-3],\n [-9]])\nb = np.array([\n [9],\n [-10],\n [5],\n [10],\n [4],\n [-2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{11}{9}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 4 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{44}{9} \\\\\n \\frac{77}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [4],\n [7]])\nprint(a * (11/9))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -3 \\\\\n -3 \\\\\n -5 \\\\\n -9 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 5 \\\\\n -7 \\\\\n 5 \\\\\n 2 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{519}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-3],\n [-3],\n [-5],\n [-9],\n [6]])\nb = np.array([\n [1],\n [5],\n [-7],\n [5],\n [2],\n [-7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & -2 & -5 \\\\\n 3 & 5 & -8 \\\\\n 8 & -6 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{2.616\\, -2.461 i,2.616\\, +2.461 i,9.769\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -2, -5],\n [3, 5, -8],\n [8, -6, 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & 7 & -1 \\\\\n 7 & 9 & -2 \\\\\n 5 & -10 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.76,-3.05,1.\\}, \\{0.03,0.1,1.\\}, \\{0.627,-0.202,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 7, -1],\n [7, 9, -2],\n [5, -10, -8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{11}{9}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 10 & 3 & 8 & -2 \\\\\n -10 & 2 & 7 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{110}{9} & -\\frac{11}{3} & -\\frac{88}{9} & \\frac{22}{9} \\\\\n \\frac{110}{9} & -\\frac{22}{9} & -\\frac{77}{9} & \\frac{110}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 3, 8, -2],\n [-10, 2, 7, -10]])\nprint(a * -(11/9))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${2, -\\frac{10}{3}, \\frac{11}{3}}$ to the plane $x-\\frac{4 y}{3}-\\frac{2 z}{3}+\\frac{7}{3}=0$.", - "Output Answer": [ - "$\\frac{19}{\\sqrt{29}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 2, -(10/3), (11/3)\nplane = Poly(x-((4*y)/3)-((2*z)/3)+(7/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{7} \\\\\n -\\frac{11}{7} \\\\\n -\\frac{55}{7} \\\\\n \\frac{9}{7} \\\\\n -\\frac{39}{7} \\\\\n \\frac{2}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{39}{7} \\\\\n -\\frac{30}{7} \\\\\n \\frac{57}{7} \\\\\n \\frac{23}{7} \\\\\n -\\frac{2}{7} \\\\\n \\frac{29}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{2501}{49}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/7)],\n [-(11/7)],\n [-(55/7)],\n [(9/7)],\n [-(39/7)],\n [(2/7)]])\nb = np.array([\n [-(39/7)],\n [-(30/7)],\n [(57/7)],\n [(23/7)],\n [-(2/7)],\n [(29/7)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2 & 2 & 1 \\\\\n 1 & -1 & 0 \\\\\n -1 & 1 & 1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -14 & 14 & 4 \\\\\n 8 & -8 & -2 \\\\\n -6 & 6 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2, 1],\n [1, -1, 0],\n [-1, 1, 1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n \\frac{19}{3} \\\\\n -9 \\\\\n -\\frac{13}{3} \\\\\n 10 \\\\\n \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{\\frac{737}{3}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [(19/3)],\n [-9],\n [-(13/3)],\n [10],\n [(4/3)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -7 \\\\\n -8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -10 \\\\\n -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 8 \\\\\n 3 \\\\\n -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-7],\n [-8]])\nb = np.array([\n [2],\n [-10],\n [-1]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{4}{3}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & 9 & -1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{8}{3} & -12 & \\frac{4}{3} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 9, -1, 0]])\nprint(a * -(4/3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 2 & 8 & 2 & 7 & 10 & 1 & 0 \\\\\n 5 & -4 & -7 & 10 & -4 & -4 & -1 \\\\\n -10 & 2 & -8 & 6 & 3 & 9 & 10 \\\\\n -9 & -9 & 0 & 7 & -9 & 2 & -1 \\\\\n -10 & -4 & -6 & -2 & -3 & -7 & -5 \\\\\n 6 & -8 & 4 & -2 & 1 & -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & \\frac{162081}{821989} \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & -\\frac{312842}{821989} \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & -\\frac{406081}{821989} \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & -\\frac{265669}{1643978} \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & \\frac{626907}{1643978} \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & \\frac{1572085}{1643978} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, 8, 2, 7, 10, 1, 0],\n [5, -4, -7, 10, -4, -4, -1],\n [-10, 2, -8, 6, 3, 9, 10],\n [-9, -9, 0, 7, -9, 2, -1],\n [-10, -4, -6, -2, -3, -7, -5],\n [6, -8, 4, -2, 1, -1, 2]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{16}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1]])\nprint(a * -(1/16))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{4} & -\\frac{23}{16} \\\\\n -\\frac{1}{16} & \\frac{1}{4} \\\\\n \\frac{29}{16} & -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{25}{16} & -\\frac{5}{4} & \\frac{7}{8} \\\\\n -\\frac{47}{16} & \\frac{17}{8} & -\\frac{11}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{181}{256} & -\\frac{31}{128} & \\frac{127}{64} \\\\\n -\\frac{213}{256} & \\frac{39}{64} & -\\frac{95}{128} \\\\\n \\frac{913}{256} & -\\frac{179}{64} & \\frac{291}{128} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/4), -(23/16)],\n [-(1/16), (1/4)],\n [(29/16), -(1/4)]])\nb = np.array([\n [(25/16), -(5/4), (7/8)],\n [-(47/16), (17/8), -(11/4)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{4,-2,0\\}, \\{-4,2,-4\\}, \\{-3,4,2\\}}$.", - "Output Answer": [ - "$8 x+11 y-5 (z+2)=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, -2, 0],\n [-4, 2, -4],\n [-3, 4, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 1 & -1 & 1 & 0 & 2 \\\\\n -1 & -1 & -2 & 1 & -2 \\\\\n 2 & -1 & -2 & 0 & 2 \\\\\n 2 & -3 & -3 & -3 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 3 & -1 & -1 & -1 \\\\\n -3 & -1 & 2 & -1 \\\\\n 3 & -3 & -2 & -1 \\\\\n 0 & -3 & -1 & 3 \\\\\n 3 & -2 & -2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 15 & -7 & -9 & 1 \\\\\n -12 & 9 & 6 & 5 \\\\\n 9 & 1 & -4 & 3 \\\\\n 3 & 21 & 3 & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, 1, 0, 2],\n [-1, -1, -2, 1, -2],\n [2, -1, -2, 0, 2],\n [2, -3, -3, -3, -1]])\nb = np.array([\n [3, -1, -1, -1],\n [-3, -1, 2, -1],\n [3, -3, -2, -1],\n [0, -3, -1, 3],\n [3, -2, -2, 1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 5 \\\\\n -3 \\\\\n -1 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -4 \\\\\n -7 \\\\\n 6 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$58$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [5],\n [-3],\n [-1],\n [-8]])\nb = np.array([\n [-7],\n [-4],\n [-7],\n [6],\n [-7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{2}{3} & -\\frac{10}{3} & -3 \\\\\n -4 & -\\frac{1}{3} & -3 \\\\\n -\\frac{14}{3} & -5 & -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{2048}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/3), -(10/3), -3],\n [-4, -(1/3), -3],\n [-(14/3), -5, -(8/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{2} & 0 \\\\\n 0 & \\frac{3}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{125}{8} & 0 \\\\\n 0 & \\frac{27}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), 0],\n [0, (3/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -2 & \\frac{2}{3} & -\\frac{5}{3} & \\frac{7}{3} \\\\\n \\frac{4}{3} & \\frac{4}{3} & -3 & -2 \\\\\n \\frac{8}{3} & -\\frac{5}{3} & -\\frac{2}{3} & 0 \\\\\n -\\frac{8}{3} & -\\frac{7}{3} & \\frac{2}{3} & 0 \\\\\n 2 & \\frac{7}{3} & \\frac{4}{3} & -\\frac{4}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 2 & -\\frac{8}{3} & 0 & 3 & -\\frac{7}{3} \\\\\n -\\frac{5}{3} & \\frac{5}{3} & -\\frac{5}{3} & -3 & 1 \\\\\n -2 & -\\frac{4}{3} & 1 & -1 & -\\frac{2}{3} \\\\\n \\frac{4}{3} & \\frac{8}{3} & -\\frac{7}{3} & \\frac{5}{3} & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n \\frac{4}{3} & \\frac{134}{9} & -\\frac{74}{9} & -\\frac{22}{9} & \\frac{58}{9} \\\\\n \\frac{34}{9} & -\\frac{8}{3} & -\\frac{5}{9} & -\\frac{1}{3} & \\frac{2}{9} \\\\\n \\frac{85}{9} & -9 & \\frac{19}{9} & \\frac{41}{3} & -\\frac{67}{9} \\\\\n -\\frac{25}{9} & \\frac{7}{3} & \\frac{41}{9} & -\\frac{5}{3} & \\frac{31}{9} \\\\\n -\\frac{13}{3} & -\\frac{61}{9} & \\frac{5}{9} & -\\frac{41}{9} & -\\frac{29}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, (2/3), -(5/3), (7/3)],\n [(4/3), (4/3), -3, -2],\n [(8/3), -(5/3), -(2/3), 0],\n [-(8/3), -(7/3), (2/3), 0],\n [2, (7/3), (4/3), -(4/3)]])\nb = np.array([\n [2, -(8/3), 0, 3, -(7/3)],\n [-(5/3), (5/3), -(5/3), -3, 1],\n [-2, -(4/3), 1, -1, -(2/3)],\n [(4/3), (8/3), -(7/3), (5/3), 0]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, 0}$ to the line $-5 x-3 y-1=0$.", - "Output Answer": [ - "$8 \\sqrt{\\frac{2}{17}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, 0\nline = Poly(-5*x-3*y-1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 2 & 1 & -3 & -9 \\\\\n -3 & -8 & -8 & 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -1 & 2 & 5 & 2 \\\\\n 2 & -8 & -1 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 3 & 2 & -7 \\\\\n -1 & -16 & -9 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, -3, -9],\n [-3, -8, -8, 7]])\nb = np.array([\n [-1, 2, 5, 2],\n [2, -8, -1, -8]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{8}{5} & \\frac{14}{5} & -\\frac{24}{5} \\\\\n -\\frac{7}{5} & \\frac{9}{5} & -\\frac{42}{5} \\\\\n -\\frac{8}{5} & -\\frac{42}{5} & \\frac{42}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.259,1.605,1.\\}, \\{-0.412,-0.625,1.\\}, \\{0.276,1.453,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/5), (14/5), -(24/5)],\n [-(7/5), (9/5), -(42/5)],\n [-(8/5), -(42/5), (42/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & 1 & -1 & 1 \\\\\n 0 & 1 & 3 & -3 \\\\\n -3 & 2 & -1 & 0 \\\\\n -1 & 3 & -2 & -3 \\\\\n 0 & -1 & -1 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.03 \\\\\n 1.66 \\\\\n 2.65 \\\\\n 2.05 \\\\\n 0.69 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.062 \\\\\n 0.829 \\\\\n -0.044 \\\\\n -0.175 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, -1, 1],\n [0, 1, 3, -3],\n [-3, 2, -1, 0],\n [-1, 3, -2, -3],\n [0, -1, -1, -3]])\nb = np.array([\n [2.03],\n [1.66],\n [2.65],\n [2.05],\n [0.69]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{4} & \\frac{7}{4} & \\frac{3}{2} \\\\\n \\frac{1}{4} & \\frac{7}{4} & \\frac{9}{4} \\\\\n \\frac{9}{4} & 4 & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{520}{1961} & \\frac{328}{1961} & \\frac{84}{1961} \\\\\n \\frac{316}{1961} & -\\frac{320}{1961} & \\frac{492}{1961} \\\\\n -\\frac{188}{1961} & \\frac{1084}{1961} & -\\frac{392}{1961} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/4), (7/4), (3/2)],\n [(1/4), (7/4), (9/4)],\n [(9/4), 4, (1/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -8 & 1 & -1 & -3 & 1 \\\\\n -3 & 3 & -6 & -5 & 10 \\\\\n 7 & 6 & -1 & 8 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & \\frac{49}{135} & \\frac{13}{135} \\\\\n 0 & 1 & 0 & \\frac{10}{9} & \\frac{1}{9} \\\\\n 0 & 0 & 1 & \\frac{163}{135} & -\\frac{224}{135} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-8, 1, -1, -3, 1],\n [-3, 3, -6, -5, 10],\n [7, 6, -1, 8, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & 7 & 0 \\\\\n 5 & 7 & 0 \\\\\n 5 & -7 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{1.563,7.,13.437\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 7, 0],\n [5, 7, 0],\n [5, -7, 7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 5 & 5 \\\\\n 3 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{4}{5} & -1 \\\\\n -\\frac{3}{5} & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 5],\n [3, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 2 & 4 \\\\\n 7 & -3 \\\\\n -8 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, 4],\n [7, -3],\n [-8, 3]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{9}{2} \\\\\n -9 \\\\\n -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -\\frac{15}{2} \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{189}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/2)],\n [-9],\n [-(9/2)]])\nb = np.array([\n [6],\n [-(15/2)],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{84}{25} & \\frac{453}{50} & \\frac{111}{20} \\\\\n \\frac{77}{50} & \\frac{769}{100} & \\frac{547}{100} \\\\\n \\frac{184}{25} & -\\frac{471}{50} & \\frac{9}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{1141 x^2}{100}-\\frac{132717 x}{5000}+\\frac{36881379}{250000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(84/25), (453/50), (111/20)],\n [(77/50), (769/100), (547/100)],\n [(184/25), -(471/50), (9/25)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{9}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), -3]])\nb = np.array([\n [(1/2)],\n [1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{8}{7} \\\\\n -\\frac{12}{7} \\\\\n -\\frac{17}{7} \\\\\n \\frac{13}{7} \\\\\n -\\frac{8}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 4 \\sqrt{\\frac{2}{365}} \\\\\n -6 \\sqrt{\\frac{2}{365}} \\\\\n -\\frac{17}{\\sqrt{730}} \\\\\n \\frac{13}{\\sqrt{730}} \\\\\n -4 \\sqrt{\\frac{2}{365}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(8/7)],\n [-(12/7)],\n [-(17/7)],\n [(13/7)],\n [-(8/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{22}{3} & \\frac{17}{3} \\\\\n \\frac{26}{3} & -\\frac{19}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{52} \\left(41-\\sqrt{3449}\\right),1\\right\\}, \\left\\{\\frac{1}{52} \\left(41+\\sqrt{3449}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(22/3), (17/3)],\n [(26/3), -(19/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -1+\\frac{3 i}{2} & \\frac{3}{2}+2 i \\\\\n -\\frac{5}{2}+\\frac{3 i}{2} & -\\frac{1}{2}+3 i \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{313}{8}-\\frac{65 i}{2} & -\\frac{49}{8}-\\frac{241 i}{4} \\\\\n \\frac{565}{8}+\\frac{i}{8} & \\frac{95}{2}-\\frac{559 i}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1+((3j)/2), (3/2)+2j],\n [-(5/2)+((3j)/2), -(1/2)+3j]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{2}{5} & \\frac{6}{5} & \\frac{18}{5} \\\\\n -\\frac{21}{5} & \\frac{13}{5} & -\\frac{21}{5} \\\\\n -\\frac{24}{5} & -\\frac{12}{5} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{80}{301} & -\\frac{15}{301} & -\\frac{225}{1204} \\\\\n \\frac{15}{344} & \\frac{35}{172} & -\\frac{15}{86} \\\\\n \\frac{705}{2408} & -\\frac{75}{1204} & \\frac{95}{1204} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/5), (6/5), (18/5)],\n [-(21/5), (13/5), -(21/5)],\n [-(24/5), -(12/5), -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n 2 \\\\\n -1 \\\\\n -9 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -9 \\\\\n 3 \\\\\n 9 \\\\\n -8 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(16 \\sqrt{\\frac{7}{4573}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-2],\n [2],\n [-1],\n [-9],\n [-5]]).squeeze()\nb = np.array([\n [5],\n [-9],\n [3],\n [9],\n [-8],\n [-3]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-4,\\frac{4}{3},-\\frac{4}{3}\\right\\}, \\left\\{\\frac{10}{3},-4,\\frac{1}{3}\\right\\}, \\left\\{-2,-\\frac{11}{3},-4\\right\\}}$.", - "Output Answer": [ - "$609 x+618 y-702 z+676=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, (4/3), -(4/3)],\n [(10/3), -4, (1/3)],\n [-2, -(11/3), -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{17}{6} & -\\frac{25}{6} \\\\\n -5 & -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{247}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/6), -(25/6)],\n [-5, -(7/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -1 & 2 \\\\\n 1 & 2 \\\\\n -1 & -2 \\\\\n 2 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 2 & 1 & 2 & -2 & -1 \\\\\n -2 & -2 & -2 & -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -6 & -5 & -6 & 0 & 7 \\\\\n -2 & -3 & -2 & -4 & 5 \\\\\n 2 & 3 & 2 & 4 & -5 \\\\\n 6 & 4 & 6 & -3 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2],\n [1, 2],\n [-1, -2],\n [2, -1]])\nb = np.array([\n [2, 1, 2, -2, -1],\n [-2, -2, -2, -1, 3]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & 1 & -1 & -1 & 1 \\\\\n 2 & 1 & 3 & -1 & 2 \\\\\n 3 & 2 & 3 & 0 & 0 \\\\\n 1 & 2 & -3 & 3 & 0 \\\\\n -3 & 1 & 0 & 1 & 2 \\\\\n -3 & -2 & 0 & -3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.11 \\\\\n 2.87 \\\\\n -1.61 \\\\\n 2.07 \\\\\n -0.9 \\\\\n 0.04 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.949 \\\\\n -0.344 \\\\\n -0.732 \\\\\n 0.026 \\\\\n 1.118 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, -1, -1, 1],\n [2, 1, 3, -1, 2],\n [3, 2, 3, 0, 0],\n [1, 2, -3, 3, 0],\n [-3, 1, 0, 1, 2],\n [-3, -2, 0, -3, 3]])\nb = np.array([\n [1.11],\n [2.87],\n [-1.61],\n [2.07],\n [-0.9],\n [0.04]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -4 & -\\frac{14}{3} \\\\\n -2 & -\\frac{13}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -(14/3)],\n [-2, -(13/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-2,\\frac{4}{3},-\\frac{5}{3}\\right\\}, \\left\\{\\frac{10}{3},-\\frac{1}{3},3\\right\\}, \\left\\{3,-\\frac{4}{3},\\frac{10}{3}\\right\\}}$.", - "Output Answer": [ - "$111 x-90 y-159 z+77=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, (4/3), -(5/3)],\n [(10/3), -(1/3), 3],\n [3, -(4/3), (10/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,1,0\\}, \\{-2,1,-2\\}, \\{5,0,3\\}}$.", - "Output Answer": [ - "$2 x-11 y-5 z+5=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, 1, 0],\n [-2, 1, -2],\n [5, 0, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n \\frac{47}{5} & \\frac{47}{5} \\\\\n -8 & -10 \\\\\n -\\frac{22}{5} & \\frac{46}{5} \\\\\n -\\frac{14}{5} & 0 \\\\\n \\frac{33}{5} & -\\frac{2}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(47/5), (47/5)],\n [-8, -10],\n [-(22/5), (46/5)],\n [-(14/5), 0],\n [(33/5), -(2/5)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{46}{5} \\\\\n -\\frac{91}{25} \\\\\n -\\frac{97}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{212}{25} \\\\\n -\\frac{421}{50} \\\\\n -\\frac{133}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{96041}{1250} \\\\\n \\frac{23623}{250} \\\\\n -\\frac{67707}{625} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(46/5)],\n [-(91/25)],\n [-(97/10)]])\nb = np.array([\n [-(212/25)],\n [-(421/50)],\n [-(133/100)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -3 & \\frac{37}{8} & 2 \\\\\n \\frac{63}{8} & -\\frac{63}{8} & -\\frac{15}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{27}{8} & -\\frac{55}{8} & -\\frac{41}{8} \\\\\n 9 & -\\frac{21}{4} & -\\frac{41}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{51}{8} & \\frac{23}{2} & \\frac{57}{8} \\\\\n -\\frac{9}{8} & -\\frac{21}{8} & \\frac{11}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, (37/8), 2],\n [(63/8), -(63/8), -(15/4)]])\nb = np.array([\n [(27/8), -(55/8), -(41/8)],\n [9, -(21/4), -(41/8)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n -\\frac{11}{4} \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n -\\frac{3}{2} \\\\\n 2 \\\\\n -\\frac{9}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{5}{37},-\\frac{15}{37},\\frac{20}{37},-\\frac{45}{74}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2)],\n [-(11/4)],\n [0],\n [1]]).squeeze()\nb = np.array([\n [(1/2)],\n [-(3/2)],\n [2],\n [-(9/4)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -8 & 4 \\\\\n -3 & -4 \\\\\n -7 & 5 \\\\\n 8 & 8 \\\\\n 3 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-8, 4],\n [-3, -4],\n [-7, 5],\n [8, 8],\n [3, 9]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & -8 & -3 \\\\\n 2 & 8 & 4 \\\\\n 2 & 6 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-11.125,5.562\\, -2.611 i,5.562\\, +2.611 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -8, -3],\n [2, 8, 4],\n [2, 6, -10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{5}{4},-\\frac{1}{4},2\\right\\}, \\left\\{\\frac{3}{2},-\\frac{9}{4},\\frac{5}{4}\\right\\}, \\left\\{\\frac{3}{4},\\frac{1}{4},1\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{\\sqrt{\\frac{5}{2}}}{3},-\\frac{1}{3 \\sqrt{10}},\\frac{4 \\sqrt{\\frac{2}{5}}}{3}\\right\\}, \\left\\{\\frac{29 \\sqrt{\\frac{5}{13078}}}{3},-\\frac{731}{3 \\sqrt{65390}},-\\frac{7 \\sqrt{\\frac{26}{2515}}}{3}\\right\\}, \\left\\{\\frac{67}{\\sqrt{6539}},\\frac{23}{\\sqrt{6539}},-3 \\sqrt{\\frac{13}{503}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack((((5/4), -(1/4), 2), ((3/2), -(9/4), (5/4)), ((3/4), (1/4), 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & 4 \\\\\n -3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$12$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 4],\n [-3, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{8}{5},-\\frac{4}{5}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-2]]).squeeze()\nb = np.array([\n [2],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{5}{\\pi },\\frac{1}{\\pi },\\frac{7}{\\pi }\\right\\}, \\left\\{\\frac{2}{\\pi },\\frac{4}{\\pi },\\frac{4}{\\pi }\\right\\}, \\left\\{\\frac{9}{\\pi },-\\frac{3}{\\pi },-\\frac{6}{\\pi }\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{3}},\\frac{1}{5 \\sqrt{3}},\\frac{7}{5 \\sqrt{3}}\\right\\}, \\left\\{13 \\sqrt{\\frac{2}{831}},\\frac{139}{5 \\sqrt{1662}},\\frac{73}{5 \\sqrt{1662}}\\right\\}, \\left\\{6 \\sqrt{\\frac{2}{277}},-\\frac{17}{\\sqrt{554}},\\frac{11}{\\sqrt{554}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-(5/math.pi), (1/math.pi), (7/math.pi)), ((2/math.pi), (4/math.pi), (4/math.pi)), ((9/math.pi), -(3/math.pi), -(6/math.pi))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & -1 & 2 & 2 \\\\\n 0 & 1 & -2 & 3 \\\\\n 1 & -1 & -3 & -1 \\\\\n -2 & 1 & -2 & -3 \\\\\n 3 & -2 & 2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.99 \\\\\n 2.31 \\\\\n 2.17 \\\\\n -2.94 \\\\\n 2.73 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.916 \\\\\n 1.395 \\\\\n -0.585 \\\\\n -0.149 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1, 2, 2],\n [0, 1, -2, 3],\n [1, -1, -3, -1],\n [-2, 1, -2, -3],\n [3, -2, 2, -2]])\nb = np.array([\n [-1.99],\n [2.31],\n [2.17],\n [-2.94],\n [2.73]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 7 & -1 & -4 & -9 \\\\\n -2 & -10 & -6 & -2 \\\\\n -10 & 0 & -2 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{207.,23.,-188.,242.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, -1, -4, -9],\n [-2, -10, -6, -2],\n [-10, 0, -2, 7]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-4, -\\frac{1}{7}}$ to the line $\\frac{4 x}{7}-\\frac{27 y}{7}+\\frac{26}{7}=0$.", - "Output Answer": [ - "$\\frac{97}{7 \\sqrt{745}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -4, -(1/7)\nline = Poly(((4*x)/7)-((27*y)/7)+(26/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 1 \\\\\n -3 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(13-i \\sqrt{3}\\right),\\frac{1}{2} \\left(13+i \\sqrt{3}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 1],\n [-3, 5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 8 & -7 & 3 \\\\\n -8 & -10 & -6 \\\\\n 0 & 0 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-11 x^2+118 x+1224$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -7, 3],\n [-8, -10, -6],\n [0, 0, -9]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 1 & 5 & 5 & 2 \\\\\n 7 & -9 & -9 & -8 \\\\\n -4 & -6 & 3 & -2 \\\\\n 8 & 1 & -9 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, 5, 5, 2],\n [7, -9, -9, -8],\n [-4, -6, 3, -2],\n [8, 1, -9, -3]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{13}{3},\\frac{14}{3},-\\frac{8}{3}\\right\\}, \\left\\{5,5,\\frac{1}{3}\\right\\}, \\left\\{1,0,-\\frac{10}{3}\\right\\}}$.", - "Output Answer": [ - "$62 x-43 y-9 z-92=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(13/3), (14/3), -(8/3)],\n [5, 5, (1/3)],\n [1, 0, -(10/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n \\frac{62}{7} \\\\\n \\frac{19}{7} \\\\\n -\\frac{60}{7} \\\\\n -\\frac{33}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{8}{7} \\\\\n \\frac{44}{7} \\\\\n \\frac{55}{7} \\\\\n \\frac{58}{7} \\\\\n \\frac{22}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{19298}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [(62/7)],\n [(19/7)],\n [-(60/7)],\n [-(33/7)]])\nb = np.array([\n [-(8/7)],\n [(44/7)],\n [(55/7)],\n [(58/7)],\n [(22/7)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n -1 \\\\\n 3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -2 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{15}{14},\\frac{5}{7},0,0,\\frac{5}{14}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [2],\n [-1],\n [3],\n [-2]]).squeeze()\nb = np.array([\n [-3],\n [-2],\n [0],\n [0],\n [-1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{17}{\\sqrt{\\pi }} \\\\\n -\\frac{17}{\\sqrt{\\pi }} \\\\\n -\\frac{13}{\\sqrt{\\pi }} \\\\\n \\frac{10}{\\sqrt{\\pi }} \\\\\n -\\frac{7}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{\\sqrt{\\pi }} \\\\\n \\frac{12}{\\sqrt{\\pi }} \\\\\n -\\frac{4}{\\sqrt{\\pi }} \\\\\n \\frac{16}{\\sqrt{\\pi }} \\\\\n -\\frac{16}{\\sqrt{\\pi }} \\\\\n -\\frac{17}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{23}{\\pi }$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [(17/(math.sqrt(math.pi)))],\n [-(17/(math.sqrt(math.pi)))],\n [-(13/(math.sqrt(math.pi)))],\n [(10/(math.sqrt(math.pi)))],\n [-(7/(math.sqrt(math.pi)))]])\nb = np.array([\n [-(4/(math.sqrt(math.pi)))],\n [(12/(math.sqrt(math.pi)))],\n [-(4/(math.sqrt(math.pi)))],\n [(16/(math.sqrt(math.pi)))],\n [-(16/(math.sqrt(math.pi)))],\n [-(17/(math.sqrt(math.pi)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,-3,2\\}, \\{-4,1,-4\\}, \\{-3,1,3\\}}$.", - "Output Answer": [ - "$28 x+29 y-4 z+67=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -3, 2],\n [-4, 1, -4],\n [-3, 1, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{16}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -8 \\\\\n -8 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{15}{16} \\\\\n -\\frac{5}{2} \\\\\n -\\frac{5}{2} \\\\\n \\frac{15}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-8],\n [-8],\n [6]])\nprint(a * (5/16))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{3} & -\\frac{10}{3} & 0 \\\\\n 8 & 9 & -\\frac{26}{3} \\\\\n \\frac{1}{3} & -\\frac{14}{3} & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.454,-1.681,1.\\}, \\{0.433\\, -0.966 i,0.816\\, +0.599 i,1.\\}, \\{0.433\\, +0.966 i,0.816\\, -0.599 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/3), -(10/3), 0],\n [8, 9, -(26/3)],\n [(1/3), -(14/3), 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -\\frac{39}{5} & -\\frac{51}{10} & -\\frac{38}{5} & -\\frac{24}{5} \\\\\n -\\frac{19}{2} & \\frac{3}{5} & \\frac{1}{10} & \\frac{27}{10} \\\\\n \\frac{27}{5} & -\\frac{61}{10} & -\\frac{37}{5} & -\\frac{79}{10} \\\\\n -\\frac{41}{5} & \\frac{39}{5} & -6 & -\\frac{1}{2} \\\\\n \\frac{16}{5} & -\\frac{21}{10} & \\frac{63}{10} & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(39/5), -(51/10), -(38/5), -(24/5)],\n [-(19/2), (3/5), (1/10), (27/10)],\n [(27/5), -(61/10), -(37/5), -(79/10)],\n [-(41/5), (39/5), -6, -(1/2)],\n [(16/5), -(21/10), (63/10), -8]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -7 \\\\\n -2 \\\\\n -5 \\\\\n 8 \\\\\n -3 \\\\\n -10 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{277}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-7],\n [-2],\n [-5],\n [8],\n [-3],\n [-10],\n [-1]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 2 & 5 \\\\\n -3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{2}{11} & -\\frac{5}{11} \\\\\n \\frac{3}{11} & \\frac{2}{11} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 5],\n [-3, -2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n 2 & 3 & 2 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 3, 2, -(3/2)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,2,-4\\}, \\{5,-4,-5\\}, \\{-5,-3,-3\\}}$.", - "Output Answer": [ - "$11 x+4 y+53 z+226=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, 2, -4],\n [5, -4, -5],\n [-5, -3, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -6 & -8 & 4 \\\\\n -5 & 6 & 0 \\\\\n -5 & -7 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+5 x^2+56 x-120$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -8, 4],\n [-5, 6, 0],\n [-5, -7, 5]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n \\frac{21}{8} & -\\frac{31}{16} & -\\frac{39}{16} \\\\\n -\\frac{21}{16} & -\\frac{3}{4} & \\frac{5}{4} \\\\\n \\frac{1}{2} & \\frac{25}{16} & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{2} & \\frac{9}{16} & -2 \\\\\n -\\frac{9}{4} & \\frac{11}{4} & \\frac{27}{16} \\\\\n \\frac{5}{16} & -\\frac{3}{16} & \\frac{11}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{585}{256} & -\\frac{869}{256} & -\\frac{3897}{256} \\\\\n \\frac{175}{64} & -\\frac{777}{256} & \\frac{307}{64} \\\\\n -\\frac{201}{64} & \\frac{269}{64} & \\frac{1827}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(21/8), -(31/16), -(39/16)],\n [-(21/16), -(3/4), (5/4)],\n [(1/2), (25/16), 2]])\nb = np.array([\n [-(1/2), (9/16), -2],\n [-(9/4), (11/4), (27/16)],\n [(5/16), -(3/16), (11/4)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & -6 & -5 \\\\\n -10 & -6 & 2 \\\\\n 4 & -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-10.857,-30.845,1.\\}, \\{0.811\\, -0.58 i,-0.548+0.339 i,1.\\}, \\{0.811\\, +0.58 i,-0.548-0.339 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -6, -5],\n [-10, -6, 2],\n [4, -1, 3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 0 & -9 \\\\\n -8 & 0 \\\\\n 8 & 9 \\\\\n -10 & 4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 8 & -8 \\\\\n -4 & 4 \\\\\n 5 & -9 \\\\\n 9 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -8 & -1 \\\\\n -4 & -4 \\\\\n 3 & 18 \\\\\n -19 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -9],\n [-8, 0],\n [8, 9],\n [-10, 4]])\nb = np.array([\n [8, -8],\n [-4, 4],\n [5, -9],\n [9, -2]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -2 & 7 & 9 \\\\\n 3 & -2 & 9 \\\\\n -2 & 8 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8.312,-1.283,10.595\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 7, 9],\n [3, -2, 9],\n [-2, 8, 5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -5 & 8 & 5 & 1 \\\\\n -1 & 6 & -9 & -1 \\\\\n -6 & 6 & -2 & 7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 5 & -1 & -5 & -4 \\\\\n -9 & -9 & -9 & -5 \\\\\n 3 & -7 & -7 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -10 & 9 & 10 & 5 \\\\\n 8 & 15 & 0 & 4 \\\\\n -9 & 13 & 5 & 16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 8, 5, 1],\n [-1, 6, -9, -1],\n [-6, 6, -2, 7]])\nb = np.array([\n [5, -1, -5, -4],\n [-9, -9, -9, -5],\n [3, -7, -7, -9]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{15}{7} & -\\frac{57}{7} & -1 \\\\\n -\\frac{15}{7} & -\\frac{31}{7} & \\frac{8}{7} \\\\\n -\\frac{4}{7} & \\frac{15}{7} & \\frac{57}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{11 x^2}{7}+\\frac{3160 x}{49}-\\frac{2309}{49}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/7), -(57/7), -1],\n [-(15/7), -(31/7), (8/7)],\n [-(4/7), (15/7), (57/7)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{27}{10}, -\\frac{2}{5}}$ to the line $-\\frac{29 x}{10}+\\frac{3 y}{10}+1=0$.", - "Output Answer": [ - "$\\frac{871}{50 \\sqrt{34}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(27/10), -(2/5)\nline = Poly(-((29*x)/10)+((3*y)/10)+1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -6 & 6 & 6 \\\\\n 9 & -8 & 0 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 5 & 7 & -4 \\\\\n -8 & 10 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -11 & -1 & 10 \\\\\n 17 & -18 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 6, 6],\n [9, -8, 0]])\nb = np.array([\n [5, 7, -4],\n [-8, 10, 2]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 2 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{2}} \\\\\n \\frac{1}{\\sqrt{2}} \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [2],\n [0],\n [0]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -\\frac{67}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(67/9)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{1}{2},2,-\\frac{1}{2}\\right\\}, \\left\\{3,-\\frac{9}{2},\\frac{7}{2}\\right\\}, \\left\\{-\\frac{7}{2},-\\frac{5}{2},-\\frac{9}{2}\\right\\}}$.", - "Output Answer": [ - "$352 x+16 y-282 z+3=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(1/2), 2, -(1/2)],\n [3, -(9/2), (7/2)],\n [-(7/2), -(5/2), -(9/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & 8 \\\\\n -6 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+10 x+72$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 8],\n [-6, -6]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & 1 \\\\\n 0 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-5,-2\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 1],\n [0, -5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{8}{3}, 4, -2}$ to the plane $-\\frac{13 x}{3}+\\frac{5 y}{3}+z+\\frac{14}{3}=0$.", - "Output Answer": [ - "$\\frac{188}{3 \\sqrt{203}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(8/3), 4, -2\nplane = Poly(-((13*x)/3)+((5*y)/3)+z+(14/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 2 \\\\\n -3 \\\\\n 2 \\\\\n 1 \\\\\n 5 \\\\\n 8 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 8 \\\\\n 5 \\\\\n -8 \\\\\n 9 \\\\\n -1 \\\\\n 9 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{446}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [2],\n [-3],\n [2],\n [1],\n [5],\n [8],\n [8]])\nb = np.array([\n [-2],\n [8],\n [5],\n [-8],\n [9],\n [-1],\n [9],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -3 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -6 \\\\\n -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -9 \\\\\n -36 \\\\\n 48 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-3],\n [-3]])\nb = np.array([\n [8],\n [-6],\n [-3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 4 \\\\\n 1 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 4 \\\\\n -7 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 7 \\\\\n 8 \\\\\n -6 \\\\\n 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [4],\n [1],\n [9]])\nb = np.array([\n [-1],\n [4],\n [-7],\n [-2]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 3 & 2 & -2 & -2 & -2 \\\\\n 1 & -1 & -1 & -3 & 3 \\\\\n -2 & -3 & 0 & -1 & -3 \\\\\n 3 & 1 & -3 & -3 & -1 \\\\\n 2 & 1 & 2 & 1 & 0 \\\\\n 2 & 3 & 2 & 3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.13 \\\\\n 1.39 \\\\\n -0.58 \\\\\n 1.18 \\\\\n -0.68 \\\\\n -1.08 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.548 \\\\\n 0.78 \\\\\n 0.252 \\\\\n -0.945 \\\\\n 0.061 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2, -2, -2, -2],\n [1, -1, -1, -3, 3],\n [-2, -3, 0, -1, -3],\n [3, 1, -3, -3, -1],\n [2, 1, 2, 1, 0],\n [2, 3, 2, 3, 2]])\nb = np.array([\n [1.13],\n [1.39],\n [-0.58],\n [1.18],\n [-0.68],\n [-1.08]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{2}-\\frac{5 i}{2} & \\frac{7}{2}-2 i & \\frac{7}{2}+\\frac{7 i}{2} \\\\\n -2-\\frac{i}{2} & -3-4 i & 3+4 i \\\\\n -1-2 i & -\\frac{9}{2}-\\frac{3 i}{2} & \\frac{7}{2}+3 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{17}{2}-\\frac{3 i}{4} & -\\frac{157}{4}-\\frac{139 i}{4} & \\frac{95}{4}+\\frac{67 i}{4} \\\\\n \\frac{43}{4}+\\frac{21 i}{4} & -\\frac{45}{2}+\\frac{15 i}{4} & \\frac{1}{4}-\\frac{39 i}{4} \\\\\n \\frac{29}{4}+\\frac{3 i}{4} & -\\frac{45}{4}-\\frac{5 i}{4} & -\\frac{3}{4}-12 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2)-((5j)/2), (7/2)-2j, (7/2)+((7j)/2)],\n [-2-(1j/2), -3-4j, 3+4j],\n [-1-2j, -(9/2)-((3j)/2), (7/2)+3j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{10}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -10 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -7 & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 5]])\nprint(a * (7/10))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -3 \\\\\n 2 \\\\\n 0 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{3}{\\sqrt{22}} \\\\\n \\sqrt{\\frac{2}{11}} \\\\\n 0 \\\\\n -\\frac{3}{\\sqrt{22}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-3],\n [2],\n [0],\n [-3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -5 \\\\\n 8 \\\\\n 2 \\\\\n -8 \\\\\n 2 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$36$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-5],\n [8],\n [2],\n [-8],\n [2],\n [-2],\n [1]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 7 & 0 & -9 & -9 \\\\\n 0 & -7 & 1 & 3 \\\\\n 0 & 5 & -9 & -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & -4 & -9 & 10 \\\\\n 2 & 3 & -4 & 1 \\\\\n 0 & 5 & -7 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 9 & -4 & -18 & 1 \\\\\n 2 & -4 & -3 & 4 \\\\\n 0 & 10 & -16 & -10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 0, -9, -9],\n [0, -7, 1, 3],\n [0, 5, -9, -5]])\nb = np.array([\n [2, -4, -9, 10],\n [2, 3, -4, 1],\n [0, 5, -7, -5]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{48}{5} & -\\frac{7}{5} \\\\\n \\frac{18}{5} & -7 \\\\\n -\\frac{48}{5} & -\\frac{17}{5} \\\\\n -6 & 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{29}{5} & -\\frac{43}{5} \\\\\n -\\frac{22}{5} & \\frac{32}{5} \\\\\n \\frac{48}{5} & 1 \\\\\n \\frac{1}{5} & -\\frac{12}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{77}{5} & -10 \\\\\n -\\frac{4}{5} & -\\frac{3}{5} \\\\\n 0 & -\\frac{12}{5} \\\\\n -\\frac{29}{5} & \\frac{18}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(48/5), -(7/5)],\n [(18/5), -7],\n [-(48/5), -(17/5)],\n [-6, 6]])\nb = np.array([\n [(29/5), -(43/5)],\n [-(22/5), (32/5)],\n [(48/5), 1],\n [(1/5), -(12/5)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,-1,0\\}, \\{2,4,-2\\}, \\{4,-3,4\\}}$.", - "Output Answer": [ - "$8 x-14 y-19 z+2=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, -1, 0],\n [2, 4, -2],\n [4, -3, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -1 & -6 & 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 0 & -3 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & -9 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -6, 4]])\nb = np.array([\n [0, -3, 3]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{93}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{93}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(93/16)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & \\frac{7}{5} & \\frac{44}{5} \\\\\n 0 & \\frac{49}{5} & \\frac{13}{5} \\\\\n \\frac{34}{5} & -2 & -\\frac{13}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6.578,9.405,11.374\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, (7/5), (44/5)],\n [0, (49/5), (13/5)],\n [(34/5), -2, -(13/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{8}{9} \\\\\n \\frac{25}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{10}{9} \\\\\n \\frac{25}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/9)],\n [(25/3)]])\nb = np.array([\n [-2],\n [0]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{53}{16} & \\frac{91}{16} \\\\\n \\frac{103}{16} & -\\frac{31}{16} \\\\\n \\frac{129}{16} & \\frac{65}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -3 & \\frac{41}{8} \\\\\n -\\frac{31}{8} & \\frac{49}{8} \\\\\n \\frac{35}{4} & \\frac{13}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{101}{16} & \\frac{9}{16} \\\\\n \\frac{165}{16} & -\\frac{129}{16} \\\\\n -\\frac{11}{16} & \\frac{13}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(53/16), (91/16)],\n [(103/16), -(31/16)],\n [(129/16), (65/8)]])\nb = np.array([\n [-3, (41/8)],\n [-(31/8), (49/8)],\n [(35/4), (13/2)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{5} \\\\\n -\\frac{8}{5} \\\\\n -\\frac{8}{5} \\\\\n -\\frac{9}{5} \\\\\n -\\frac{2}{5} \\\\\n -\\frac{11}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{5} \\\\\n \\frac{3}{5} \\\\\n \\frac{4}{5} \\\\\n \\frac{8}{5} \\\\\n -\\frac{3}{5} \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{217}{247},-\\frac{93}{247},-\\frac{124}{247},-\\frac{248}{247},\\frac{93}{247},-\\frac{310}{247}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/5)],\n [-(8/5)],\n [-(8/5)],\n [-(9/5)],\n [-(2/5)],\n [-(11/5)]]).squeeze()\nb = np.array([\n [-(7/5)],\n [(3/5)],\n [(4/5)],\n [(8/5)],\n [-(3/5)],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & 5 \\\\\n 2 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+2 x-10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 5],\n [2, -2]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 3 & -2 & 1 & -2 \\\\\n 9 & -8 & -2 & -8 \\\\\n 5 & -9 & -8 & 2 \\\\\n -7 & -1 & 2 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, -2, 1, -2],\n [9, -8, -2, -8],\n [5, -9, -8, 2],\n [-7, -1, 2, -10]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -7 & -6 & -2 & -7 & 5 \\\\\n 10 & 0 & -3 & -10 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & -\\frac{3}{10} & -1 & -\\frac{1}{10} \\\\\n 0 & 1 & \\frac{41}{60} & \\frac{7}{3} & -\\frac{43}{60} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, -6, -2, -7, 5],\n [10, 0, -3, -10, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{4}{3} & -\\frac{8}{3} \\\\\n \\frac{14}{3} & -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{33}{68} & \\frac{6}{17} \\\\\n -\\frac{21}{34} & \\frac{3}{17} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3), -(8/3)],\n [(14/3), -(11/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{2}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 6 & -9 & 0 & 2 \\\\\n 5 & 3 & 8 & -4 \\\\\n 0 & 0 & -8 & -8 \\\\\n -10 & 7 & -7 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -9 & \\frac{27}{2} & 0 & -3 \\\\\n -\\frac{15}{2} & -\\frac{9}{2} & -12 & 6 \\\\\n 0 & 0 & 12 & 12 \\\\\n 15 & -\\frac{21}{2} & \\frac{21}{2} & 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -9, 0, 2],\n [5, 3, 8, -4],\n [0, 0, -8, -8],\n [-10, 7, -7, -6]])\nprint(a * -(3/2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{2} & 4-i \\\\\n 4-2 i & -\\frac{3}{2}+i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{81}{4}-12 i & 5+3 i \\\\\n 6+2 i & \\frac{61}{4}-15 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), 4- 1j],\n [4-2j, -(3/2)+ 1j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & 7 \\\\\n 2 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-7 x-8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 7],\n [2, 1]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{9}{5}, \\frac{6}{5}, \\frac{11}{5}}$ to the plane $-\\frac{16 x}{5}+\\frac{18 y}{5}-\\frac{22 z}{5}-\\frac{21}{5}=0$.", - "Output Answer": [ - "$\\frac{383}{10 \\sqrt{266}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (9/5), (6/5), (11/5)\nplane = Poly(-((16*x)/5)+((18*y)/5)-((22*z)/5)-(21/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 3 \\\\\n 0 & -2 \\\\\n 3 & 1 \\\\\n 2 & -1 \\\\\n -3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.57 \\\\\n 2.53 \\\\\n 0.68 \\\\\n -2.75 \\\\\n -1.4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.011 \\\\\n -0.325 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3],\n [0, -2],\n [3, 1],\n [2, -1],\n [-3, 2]])\nb = np.array([\n [-0.57],\n [2.53],\n [0.68],\n [-2.75],\n [-1.4]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & 5 & -8 \\\\\n 1 & 1 & 5 \\\\\n -7 & 6 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.37,0.344,1.\\}, \\{-0.399,1.795,1.\\}, \\{0.456,-0.337,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 5, -8],\n [1, 1, 5],\n [-7, 6, -10]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [2]])\nb = np.array([\n [3],\n [9]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -2 & 2 & -5 \\\\\n -5 & 2 & -3 \\\\\n 3 & -9 & 2 \\\\\n 2 & -2 & -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -5 & 6 & 8 \\\\\n -9 & 6 & -5 \\\\\n -7 & -1 & -9 \\\\\n -3 & 1 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -7 & 8 & 3 \\\\\n -14 & 8 & -8 \\\\\n -4 & -10 & -7 \\\\\n -1 & -1 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2, -5],\n [-5, 2, -3],\n [3, -9, 2],\n [2, -2, -5]])\nb = np.array([\n [-5, 6, 8],\n [-9, 6, -5],\n [-7, -1, -9],\n [-3, 1, 6]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{39}{5} \\\\\n \\frac{36}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{3 \\sqrt{313}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(39/5)],\n [(36/5)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 5 & 10 & 9 & 0 & 9 \\\\\n 4 & -2 & 3 & -1 & 6 \\\\\n -2 & -3 & -8 & -1 & -10 \\\\\n 7 & 5 & -1 & -10 & -10 \\\\\n 10 & -1 & -2 & 4 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, 10, 9, 0, 9],\n [4, -2, 3, -1, 6],\n [-2, -3, -8, -1, -10],\n [7, 5, -1, -10, -10],\n [10, -1, -2, 4, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -2 & -3 & -3 & 3 & 3 \\\\\n -1 & 3 & 2 & 3 & 0 \\\\\n 1 & -3 & -2 & -3 & 2 \\\\\n -2 & -1 & 3 & -2 & 3 \\\\\n -2 & -1 & 3 & 2 & 0 \\\\\n 1 & 1 & 3 & -2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.7 \\\\\n -0.58 \\\\\n -0.16 \\\\\n 0.76 \\\\\n 0.22 \\\\\n 1.43 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.768 \\\\\n 0.015 \\\\\n -0.1 \\\\\n -0.438 \\\\\n -0.454 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, -3, 3, 3],\n [-1, 3, 2, 3, 0],\n [1, -3, -2, -3, 2],\n [-2, -1, 3, -2, 3],\n [-2, -1, 3, 2, 0],\n [1, 1, 3, -2, -3]])\nb = np.array([\n [-0.7],\n [-0.58],\n [-0.16],\n [0.76],\n [0.22],\n [1.43]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -3 \\\\\n -3 & 0 \\\\\n 1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.3 \\\\\n 2.02 \\\\\n 0.11 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.628 \\\\\n 0.382 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3],\n [-3, 0],\n [1, 3]])\nb = np.array([\n [-0.3],\n [2.02],\n [0.11]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 1 & 2 \\\\\n 0 & 0 \\\\\n 1 & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -2 & 2 & 1 & -2 & -1 \\\\\n 0 & -1 & 3 & 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -2 & 0 & 7 & 0 & -3 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n -2 & -1 & 10 & 1 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2],\n [0, 0],\n [1, 3]])\nb = np.array([\n [-2, 2, 1, -2, -1],\n [0, -1, 3, 1, -1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -5 & 9 & 8 & 3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.,0.,0.,0.,5.\\}, \\{3.,0.,0.,5.,0.\\}, \\{8.,0.,5.,0.,0.\\}, \\{9.,5.,0.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, 9, 8, 3, -2]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 8 \\\\\n -9 \\\\\n -2 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [8],\n [-9],\n [-2],\n [4]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n -3 & -3 \\\\\n 0 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.54 \\\\\n -2.77 \\\\\n 0.01 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.825 \\\\\n 0.066 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 0],\n [-3, -3],\n [0, -2]])\nb = np.array([\n [0.54],\n [-2.77],\n [0.01]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 2 \\\\\n -3 \\\\\n -2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 2 \\\\\n 2 \\\\\n 3 \\\\\n -1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{6}{23},-\\frac{12}{23},-\\frac{12}{23},-\\frac{18}{23},\\frac{6}{23},\\frac{12}{23}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [2],\n [-3],\n [-2],\n [0]]).squeeze()\nb = np.array([\n [-1],\n [2],\n [2],\n [3],\n [-1],\n [-2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 4 & -3 & -8 & 10 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -10 & 1 & 3 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 14 & -4 & -11 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -3, -8, 10]])\nb = np.array([\n [-10, 1, 3, 4]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{2,3,1\\}, \\{-1,5,2\\}, \\{-5,2,0\\}}$.", - "Output Answer": [ - "$x+10 y-17 z-15=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, 3, 1],\n [-1, 5, 2],\n [-5, 2, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, -3, 1}$ to the plane $-x+5 y+2 z+1=0$.", - "Output Answer": [ - "$\\sqrt{\\frac{15}{2}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, -3, 1\nplane = Poly(-x+5*y+2*z+1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -3 & -2 & 0 & 0 & 1 \\\\\n 0 & 3 & 1 & 2 & -3 \\\\\n 3 & 2 & -2 & 2 & 0 \\\\\n -2 & 3 & 3 & -2 & 1 \\\\\n 3 & -1 & -2 & 0 & -3 \\\\\n 0 & -3 & 2 & 1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.03 \\\\\n 1.01 \\\\\n -1.94 \\\\\n 0.06 \\\\\n -2.74 \\\\\n -1.41 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.206 \\\\\n 0.276 \\\\\n 0.134 \\\\\n -0.087 \\\\\n -0.055 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2, 0, 0, 1],\n [0, 3, 1, 2, -3],\n [3, 2, -2, 2, 0],\n [-2, 3, 3, -2, 1],\n [3, -1, -2, 0, -3],\n [0, -3, 2, 1, 2]])\nb = np.array([\n [-2.03],\n [1.01],\n [-1.94],\n [0.06],\n [-2.74],\n [-1.41]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 3 \\\\\n 2 & -2 \\\\\n -2 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.91 \\\\\n -1.57 \\\\\n -2.5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.652 \\\\\n 0.419 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3],\n [2, -2],\n [-2, 2]])\nb = np.array([\n [1.91],\n [-1.57],\n [-2.5]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -4 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-4],\n [5]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -2 & -2 & -3 \\\\\n 1 & -1 & 2 \\\\\n 1 & 2 & 2 \\\\\n -1 & 0 & 2 \\\\\n 3 & 3 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 2 & -3 & 0 & -2 & 3 \\\\\n 1 & 2 & -2 & -1 & -1 \\\\\n -3 & 2 & 2 & 2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 3 & -4 & -2 & 0 & -1 \\\\\n -5 & -1 & 6 & 3 & 2 \\\\\n -2 & 5 & 0 & 0 & -1 \\\\\n -8 & 7 & 4 & 6 & -5 \\\\\n 12 & -5 & -8 & -11 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2, -3],\n [1, -1, 2],\n [1, 2, 2],\n [-1, 0, 2],\n [3, 3, -1]])\nb = np.array([\n [2, -3, 0, -2, 3],\n [1, 2, -2, -1, -1],\n [-3, 2, 2, 2, -1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{23}{9} \\\\\n -\\frac{22}{9} \\\\\n \\frac{25}{9} \\\\\n -\\frac{20}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -2 & -\\frac{25}{9} & \\frac{16}{9} & -\\frac{7}{9} & \\frac{4}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n \\frac{46}{9} & \\frac{575}{81} & -\\frac{368}{81} & \\frac{161}{81} & -\\frac{92}{81} \\\\\n \\frac{44}{9} & \\frac{550}{81} & -\\frac{352}{81} & \\frac{154}{81} & -\\frac{88}{81} \\\\\n -\\frac{50}{9} & -\\frac{625}{81} & \\frac{400}{81} & -\\frac{175}{81} & \\frac{100}{81} \\\\\n \\frac{40}{9} & \\frac{500}{81} & -\\frac{320}{81} & \\frac{140}{81} & -\\frac{80}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/9)],\n [-(22/9)],\n [(25/9)],\n [-(20/9)]])\nb = np.array([\n [-2, -(25/9), (16/9), -(7/9), (4/9)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 2 & 4 & 0 & -9 \\\\\n 5 & -9 & 1 & -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 3 & -1 & 3 & 1 \\\\\n -6 & -1 & 2 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 5 & 3 & 3 & -8 \\\\\n -1 & -10 & 3 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 4, 0, -9],\n [5, -9, 1, -4]])\nb = np.array([\n [3, -1, 3, 1],\n [-6, -1, 2, 6]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -5 & 9 \\\\\n -3 & 0 \\\\\n 7 & -5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 7 & 4 \\\\\n -7 & 3 \\\\\n -7 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -12 & 5 \\\\\n 4 & -3 \\\\\n 14 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 9],\n [-3, 0],\n [7, -5]])\nb = np.array([\n [7, 4],\n [-7, 3],\n [-7, -7]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{5} \\\\\n -\\frac{5}{2} \\\\\n \\frac{2}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{26}{\\sqrt{1317}} \\\\\n -\\frac{25}{\\sqrt{1317}} \\\\\n \\frac{4}{\\sqrt{1317}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/5)],\n [-(5/2)],\n [(2/5)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -3 & 1 & -1 \\\\\n -2 & 2 & -1 \\\\\n 2 & -2 & 2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 5 & 1 & 0 \\\\\n 0 & 4 & -2 \\\\\n 2 & -6 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1, -1],\n [-2, 2, -1],\n [2, -2, 2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 6 \\\\\n 7 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 2 \\\\\n 4 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -10 \\\\\n 8 \\\\\n 11 \\\\\n 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [6],\n [7],\n [-2]])\nb = np.array([\n [-4],\n [2],\n [4],\n [4]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -1 & -8 \\\\\n -6 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(5-\\sqrt{241}\\right),\\frac{1}{2} \\left(5+\\sqrt{241}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -8],\n [-6, 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 0 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 0 & 0 \\\\\n 1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0]])\nb = np.array([\n [0, 0],\n [1, 1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{29}{10} & \\frac{19}{2} & \\frac{37}{10} \\\\\n \\frac{43}{10} & -\\frac{29}{5} & \\frac{17}{2} \\\\\n -\\frac{53}{10} & -\\frac{13}{10} & -\\frac{87}{10} \\\\\n \\frac{3}{5} & 1 & \\frac{73}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{81}{10} & \\frac{83}{10} & -\\frac{26}{5} \\\\\n -\\frac{11}{10} & -\\frac{51}{10} & -\\frac{3}{10} \\\\\n \\frac{13}{2} & \\frac{11}{2} & -\\frac{7}{5} \\\\\n \\frac{83}{10} & -\\frac{37}{5} & \\frac{11}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{26}{5} & \\frac{89}{5} & -\\frac{3}{2} \\\\\n \\frac{16}{5} & -\\frac{109}{10} & \\frac{41}{5} \\\\\n \\frac{6}{5} & \\frac{21}{5} & -\\frac{101}{10} \\\\\n \\frac{89}{10} & -\\frac{32}{5} & \\frac{42}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/10), (19/2), (37/10)],\n [(43/10), -(29/5), (17/2)],\n [-(53/10), -(13/10), -(87/10)],\n [(3/5), 1, (73/10)]])\nb = np.array([\n [(81/10), (83/10), -(26/5)],\n [-(11/10), -(51/10), -(3/10)],\n [(13/2), (11/2), -(7/5)],\n [(83/10), -(37/5), (11/10)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{1}{2}, -3, \\frac{3}{2}}$ to the plane $-2 x+4 y-\\frac{9 z}{2}-\\frac{7}{2}=0$.", - "Output Answer": [ - "$\\frac{85}{2 \\sqrt{161}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(1/2), -3, (3/2)\nplane = Poly(-2*x+4*y-((9*z)/2)-(7/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -4 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 6 \\\\\n 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3 \\\\\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-4],\n [2]])\nb = np.array([\n [-2],\n [6],\n [0]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -4 & \\frac{7}{2} & -\\frac{15}{2} \\\\\n 9 & -\\frac{5}{2} & \\frac{7}{2} \\\\\n \\frac{1}{2} & -2 & \\frac{15}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 6 & -1 & 4 \\\\\n -\\frac{19}{2} & 0 & \\frac{3}{2} \\\\\n -\\frac{1}{2} & -6 & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -10 & \\frac{9}{2} & -\\frac{23}{2} \\\\\n \\frac{37}{2} & -\\frac{5}{2} & 2 \\\\\n 1 & 4 & 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, (7/2), -(15/2)],\n [9, -(5/2), (7/2)],\n [(1/2), -2, (15/2)]])\nb = np.array([\n [6, -1, 4],\n [-(19/2), 0, (3/2)],\n [-(1/2), -6, -(7/2)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{33}{5} \\\\\n -\\frac{8}{5} \\\\\n \\frac{21}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{44}{5} \\\\\n -\\frac{6}{5} \\\\\n -\\frac{46}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{494}{25} \\\\\n \\frac{2442}{25} \\\\\n \\frac{154}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(33/5)],\n [-(8/5)],\n [(21/5)]])\nb = np.array([\n [(44/5)],\n [-(6/5)],\n [-(46/5)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{23}{9} & -\\frac{7}{9} & \\frac{5}{3} & -1 & \\frac{22}{9} \\\\\n -\\frac{5}{9} & -\\frac{19}{9} & \\frac{14}{9} & -\\frac{22}{9} & -\\frac{25}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{9} \\\\\n -\\frac{7}{9} \\\\\n -\\frac{10}{9} \\\\\n \\frac{7}{3} \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{589}{81} \\\\\n -\\frac{404}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/9), -(7/9), (5/3), -1, (22/9)],\n [-(5/9), -(19/9), (14/9), -(22/9), -(25/9)]])\nb = np.array([\n [-(13/9)],\n [-(7/9)],\n [-(10/9)],\n [(7/3)],\n [0]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -5 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -1 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$124$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-5],\n [9]])\nb = np.array([\n [-7],\n [-1],\n [7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -4 \\\\\n -1 \\\\\n 3 \\\\\n 7 \\\\\n 2 \\\\\n 0 \\\\\n -10 \\\\\n -1 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 1 \\\\\n -2 \\\\\n 0 \\\\\n 9 \\\\\n -4 \\\\\n -5 \\\\\n -3 \\\\\n 4 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4 \\sqrt{22}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-4],\n [-1],\n [3],\n [7],\n [2],\n [0],\n [-10],\n [-1],\n [4]])\nb = np.array([\n [8],\n [1],\n [-2],\n [0],\n [9],\n [-4],\n [-5],\n [-3],\n [4],\n [-9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9.79 \\\\\n -9.389 \\\\\n 8.331 \\\\\n -7.247 \\\\\n 2.659 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6.656 \\\\\n -5.375 \\\\\n 4.794 \\\\\n 4.776 \\\\\n -2.395 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$14.4409$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9.79],\n [-9.389],\n [8.331],\n [-7.247],\n [2.659]])\nb = np.array([\n [6.656],\n [-5.375],\n [4.794],\n [4.776],\n [-2.395]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{69}{10} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{69}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(69/10)]])\nb = np.array([\n [(69/10)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & -2 \\\\\n -3 & 1 \\\\\n -3 & -1 \\\\\n 2 & 1 \\\\\n -3 & 1 \\\\\n 1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.1 \\\\\n 0.24 \\\\\n -0.86 \\\\\n 1.32 \\\\\n 1.79 \\\\\n -1.44 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.007 \\\\\n 0.609 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2],\n [-3, 1],\n [-3, -1],\n [2, 1],\n [-3, 1],\n [1, -1]])\nb = np.array([\n [0.1],\n [0.24],\n [-0.86],\n [1.32],\n [1.79],\n [-1.44]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -3 & 0 & 1 & -1 & 0 \\\\\n -1 & 0 & -2 & 1 & -3 \\\\\n -1 & 3 & -2 & 3 & -2 \\\\\n -3 & 2 & 2 & -3 & -1 \\\\\n 0 & 0 & 0 & -1 & 0 \\\\\n 1 & -1 & -3 & 1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.89 \\\\\n 2.72 \\\\\n -1.82 \\\\\n -2.33 \\\\\n -2.36 \\\\\n -2.77 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.063 \\\\\n -1.196 \\\\\n 1.381 \\\\\n 0.673 \\\\\n -1.922 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, 1, -1, 0],\n [-1, 0, -2, 1, -3],\n [-1, 3, -2, 3, -2],\n [-3, 2, 2, -3, -1],\n [0, 0, 0, -1, 0],\n [1, -1, -3, 1, 1]])\nb = np.array([\n [-2.89],\n [2.72],\n [-1.82],\n [-2.33],\n [-2.36],\n [-2.77]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 0 & 2 \\\\\n \\frac{3}{2} & 1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 3 & 2 \\\\\n \\frac{3}{2} & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2],\n [(3/2), 1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{8}{3}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -2 \\\\\n -10 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{56}{3} \\\\\n \\frac{16}{3} \\\\\n \\frac{80}{3} \\\\\n -\\frac{40}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-2],\n [-10],\n [5]])\nprint(a * -(8/3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 0 & 6 & -6 \\\\\n -1 & -9 & -4 \\\\\n 9 & -10 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-13.,0.5\\, -7.73 i,0.5\\, +7.73 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 6, -6],\n [-1, -9, -4],\n [9, -10, -3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 3 & 3 \\\\\n 2 & 0 & -3 \\\\\n 0 & -3 & -1 \\\\\n 3 & -1 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.02 \\\\\n 2.81 \\\\\n -0.71 \\\\\n 1.91 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.033 \\\\\n 0.451 \\\\\n -1.023 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 3, 3],\n [2, 0, -3],\n [0, -3, -1],\n [3, -1, -2]])\nb = np.array([\n [-2.02],\n [2.81],\n [-0.71],\n [1.91]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 5 & -9 & 8 & 7 & -5 \\\\\n 4 & 5 & 0 & 6 & 0 \\\\\n 7 & 2 & 9 & -8 & -2 \\\\\n 4 & 9 & -6 & -10 & 10 \\\\\n -6 & 8 & 9 & 1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, -9, 8, 7, -5],\n [4, 5, 0, 6, 0],\n [7, 2, 9, -8, -2],\n [4, 9, -6, -10, 10],\n [-6, 8, 9, 1, -4]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -2 & 5 & -4 \\\\\n -9 & 4 & 8 \\\\\n -10 & -7 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-4 x^2-41 x-1146$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 5, -4],\n [-9, 4, 8],\n [-10, -7, -6]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 3 & 7 & 3 & -5 & 5 & 10 & 4 \\\\\n 2 & -6 & 7 & -6 & 1 & -3 & 10 \\\\\n 8 & -3 & -2 & -8 & 6 & -2 & 7 \\\\\n 8 & -10 & 8 & 7 & 8 & 8 & -8 \\\\\n 3 & -8 & -4 & 10 & 6 & 10 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & -\\frac{53881}{30225} & -\\frac{40681}{10075} \\\\\n 0 & 1 & 0 & 0 & 0 & \\frac{3626}{10075} & -\\frac{12347}{10075} \\\\\n 0 & 0 & 1 & 0 & 0 & \\frac{15683}{60450} & -\\frac{4546}{10075} \\\\\n 0 & 0 & 0 & 1 & 0 & \\frac{9076}{30225} & -\\frac{17474}{10075} \\\\\n 0 & 0 & 0 & 0 & 1 & \\frac{163841}{60450} & \\frac{35008}{10075} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, 7, 3, -5, 5, 10, 4],\n [2, -6, 7, -6, 1, -3, 10],\n [8, -3, -2, -8, 6, -2, 7],\n [8, -10, 8, 7, 8, 8, -8],\n [3, -8, -4, 10, 6, 10, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 4 \\\\\n -1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 4],\n [-1, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -3 \\\\\n \\frac{7}{2} \\\\\n 8 \\\\\n -7 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-3],\n [(7/2)],\n [8],\n [-7],\n [-1]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{10}{3} & -\\frac{1}{3} & -\\frac{8}{3} \\\\\n \\frac{11}{3} & \\frac{10}{3} & \\frac{1}{3} \\\\\n \\frac{13}{3} & -4 & \\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{2758}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(10/3), -(1/3), -(8/3)],\n [(11/3), (10/3), (1/3)],\n [(13/3), -4, (5/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{13}{4} & \\frac{1}{4} \\\\\n 8 & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{64} \\left(-5-3 \\sqrt{17}\\right),1\\right\\}, \\left\\{\\frac{1}{64} \\left(3 \\sqrt{17}-5\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/4), (1/4)],\n [8, (9/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & -10 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-3.,0.,4.\\}, \\{5.,4.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [8, -10, 6]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 0 \\\\\n -1 & 3 \\\\\n 1 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.5 \\\\\n 0.06 \\\\\n -0.46 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.837 \\\\\n -0.237 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 0],\n [-1, 3],\n [1, -2]])\nb = np.array([\n [-2.5],\n [0.06],\n [-0.46]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{2} & -\\frac{47}{10} \\\\\n -\\frac{27}{10} & -\\frac{33}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{55}{36} & \\frac{235}{108} \\\\\n \\frac{5}{4} & -\\frac{25}{12} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2), -(47/10)],\n [-(27/10), -(33/10)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -10 & 9 & 4 \\\\\n 0 & 3 & -4 \\\\\n 8 & 3 & -7 \\\\\n -6 & 7 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, 9, 4],\n [0, 3, -4],\n [8, 3, -7],\n [-6, 7, -1]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,5,-4\\}, \\{1,5,-3\\}, \\{2,-3,-3\\}}$.", - "Output Answer": [ - "$8 x+y-32 z-109=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, 5, -4],\n [1, 5, -3],\n [2, -3, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n \\frac{17}{3} \\\\\n -\\frac{16}{3} \\\\\n -\\frac{37}{6} \\\\\n -3 \\\\\n -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/3)],\n [-(16/3)],\n [-(37/6)],\n [-3],\n [-(1/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 0 & 0 & 5 \\\\\n -9 & 8 & 1 \\\\\n -7 & -7 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, 0, 5],\n [-9, 8, 1],\n [-7, -7, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 3 & 1 & 8 \\\\\n -4 & -6 & 6 \\\\\n 1 & -2 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 6 & 3 & 0 \\\\\n 3 & 3 & 3 \\\\\n 2 & -10 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 9 & 4 & 8 \\\\\n -1 & -3 & 9 \\\\\n 3 & -12 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1, 8],\n [-4, -6, 6],\n [1, -2, 2]])\nb = np.array([\n [6, 3, 0],\n [3, 3, 3],\n [2, -10, -5]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -1 & -2 & 1 & -3 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 2 & 2 \\\\\n 0 & -2 \\\\\n 1 & 2 \\\\\n -2 & 2 \\\\\n -2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, 1, -3, 2]])\nb = np.array([\n [2, 2],\n [0, -2],\n [1, 2],\n [-2, 2],\n [-2, -1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n 2 \\\\\n \\frac{3}{2} \\\\\n \\frac{1}{2} \\\\\n -\\frac{3}{2} \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\sqrt{\\frac{5}{17}} \\\\\n \\frac{4}{\\sqrt{85}} \\\\\n \\frac{3}{\\sqrt{85}} \\\\\n \\frac{1}{\\sqrt{85}} \\\\\n -\\frac{3}{\\sqrt{85}} \\\\\n -\\sqrt{\\frac{5}{17}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2)],\n [2],\n [(3/2)],\n [(1/2)],\n [-(3/2)],\n [-(5/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -5 & 1 & -1 \\\\\n 4 & 4 & 5 \\\\\n 2 & 3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$57$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 1, -1],\n [4, 4, 5],\n [2, 3, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 0 & -6 & -5 \\\\\n -2 & -5 & -8 \\\\\n 4 & -8 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, -6, -5],\n [-2, -5, -8],\n [4, -8, -5]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{5} \\\\\n \\frac{24}{5} \\\\\n -\\frac{39}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n \\frac{7}{5} \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{753}{25} \\\\\n 68 \\\\\n \\frac{911}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/5)],\n [(24/5)],\n [-(39/5)]])\nb = np.array([\n [-8],\n [(7/5)],\n [4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,2,-1\\}, \\{-2,-2,-3\\}, \\{-1,0,1\\}}$", - "Output Answer": [ - "${\\left\\{0,\\frac{2}{\\sqrt{5}},-\\frac{1}{\\sqrt{5}}\\right\\}, \\left\\{-\\sqrt{\\frac{5}{21}},-\\frac{4}{\\sqrt{105}},-\\frac{8}{\\sqrt{105}}\\right\\}, \\left\\{-\\frac{4}{\\sqrt{21}},\\frac{1}{\\sqrt{21}},\\frac{2}{\\sqrt{21}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, 2, -1), (-2, -2, -3), (-1, 0, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 2 & \\frac{3}{2} \\\\\n -2 & -1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -1 & 0 \\\\\n 0 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, (3/2)],\n [-2, -1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 0 \\\\\n 0 \\\\\n 9 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -1 \\\\\n 8 \\\\\n -6 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{59}{\\sqrt{9646}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [0],\n [0],\n [9],\n [1]]).squeeze()\nb = np.array([\n [-2],\n [-1],\n [8],\n [-6],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{3 \\pi }{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [1],\n [0],\n [0]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [0],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{10}{7}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & 3 \\\\\n -2 & -4 \\\\\n 2 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{20}{7} & -\\frac{30}{7} \\\\\n \\frac{20}{7} & \\frac{40}{7} \\\\\n -\\frac{20}{7} & -\\frac{30}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 3],\n [-2, -4],\n [2, 3]])\nprint(a * -(10/7))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -6 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -7 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{161}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-6],\n [-6]])\nb = np.array([\n [3],\n [-7],\n [-2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n 8 & 6 & -8 & 2 \\\\\n -6 & -6 & -3 & 4 \\\\\n -3 & -4 & 2 & -6 \\\\\n 0 & -5 & -4 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 6, -8, 2],\n [-6, -6, -3, 4],\n [-3, -4, 2, -6],\n [0, -5, -4, -9]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{4,-3,0\\}, \\{1,4,5\\}, \\{2,2,0\\}}$.", - "Output Answer": [ - "$25 x+10 y+z-70=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, -3, 0],\n [1, 4, 5],\n [2, 2, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & 2 & 1 \\\\\n 2 & 1 & -2 \\\\\n 3 & 2 & 1 \\\\\n 1 & -1 & -2 \\\\\n 0 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.55 \\\\\n -0.89 \\\\\n 2.13 \\\\\n -0.08 \\\\\n -2.15 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.056 \\\\\n 0.592 \\\\\n -0.046 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2, 1],\n [2, 1, -2],\n [3, 2, 1],\n [1, -1, -2],\n [0, -1, 2]])\nb = np.array([\n [0.55],\n [-0.89],\n [2.13],\n [-0.08],\n [-2.15]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{6} \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{7}{\\sqrt{85}} \\\\\n -\\frac{6}{\\sqrt{85}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/6)],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 5 \\\\\n -9 \\\\\n -8 \\\\\n 10 \\\\\n -2 \\\\\n -7 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 10 \\\\\n 6 \\\\\n -2 \\\\\n -4 \\\\\n -3 \\\\\n 6 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{179}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [5],\n [-9],\n [-8],\n [10],\n [-2],\n [-7],\n [8]])\nb = np.array([\n [10],\n [10],\n [6],\n [-2],\n [-4],\n [-3],\n [6],\n [0]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{10}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & -8 & -7 \\\\\n -4 & 1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{14}{5} & -\\frac{28}{5} & -\\frac{49}{10} \\\\\n -\\frac{14}{5} & \\frac{7}{10} & \\frac{21}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -8, -7],\n [-4, 1, 3]])\nprint(a * (7/10))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & -5 \\\\\n -5 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{10} \\left(3-\\sqrt{109}\\right),1\\right\\}, \\left\\{\\frac{1}{10} \\left(3+\\sqrt{109}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -5],\n [-5, -5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 0 & -2 & 10 & -6 \\\\\n 5 & 6 & -4 & -4 \\\\\n -8 & -6 & -8 & 9 \\\\\n -3 & 10 & -5 & 10 \\\\\n -10 & -7 & -10 & 8 \\\\\n 4 & -2 & -2 & -3 \\\\\n -4 & 6 & 0 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, -2, 10, -6],\n [5, 6, -4, -4],\n [-8, -6, -8, 9],\n [-3, 10, -5, 10],\n [-10, -7, -10, 8],\n [4, -2, -2, -3],\n [-4, 6, 0, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{15}{7}, -\\frac{2}{7}}$ to the line $\\frac{25 x}{7}-\\frac{13 y}{7}+\\frac{4}{7}=0$.", - "Output Answer": [ - "$\\frac{321}{7 \\sqrt{794}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(15/7), -(2/7)\nline = Poly(((25*x)/7)-((13*y)/7)+(4/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{16} \\\\\n \\frac{35}{16} \\\\\n -\\frac{23}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{5 \\sqrt{134}} \\\\\n \\frac{7}{\\sqrt{134}} \\\\\n -\\frac{23 \\sqrt{\\frac{2}{67}}}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/16)],\n [(35/16)],\n [-(23/8)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -8 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [-6]])\nb = np.array([\n [0],\n [0],\n [8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{28}{5} & -1 & \\frac{27}{5} \\\\\n \\frac{8}{5} & -\\frac{14}{5} & \\frac{21}{5} \\\\\n -\\frac{22}{5} & -\\frac{16}{5} & -\\frac{29}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-3.062-4.078 i,-3.062+4.078 i,3.123\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(28/5), -1, (27/5)],\n [(8/5), -(14/5), (21/5)],\n [-(22/5), -(16/5), -(29/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{16}{5} & \\frac{39}{10} \\\\\n \\frac{7}{10} & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{687}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(16/5), (39/10)],\n [(7/10), 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 2 & 2 \\\\\n 2 & 2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 32 & 32 \\\\\n 32 & 32 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2],\n [2, 2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -9 & 7 & -4 & -1 \\\\\n 7 & 1 & 1 & 1 \\\\\n -10 & -5 & -6 & 4 \\\\\n -7 & -6 & -1 & 10 \\\\\n 3 & 3 & -10 & -5 \\\\\n 10 & -10 & 10 & 5 \\\\\n 6 & 4 & 4 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-9, 7, -4, -1],\n [7, 1, 1, 1],\n [-10, -5, -6, 4],\n [-7, -6, -1, 10],\n [3, 3, -10, -5],\n [10, -10, 10, 5],\n [6, 4, 4, 7]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 8 & -8 & -1 & -2 & 8 & -10 & 1 \\\\\n 8 & -2 & -6 & 6 & 9 & 5 & 7 \\\\\n 3 & 9 & 8 & -5 & -4 & -1 & 5 \\\\\n 2 & -2 & -9 & 2 & -4 & 2 & -1 \\\\\n 2 & -10 & 3 & -7 & 9 & -8 & -10 \\\\\n -10 & -7 & -4 & -7 & 2 & 6 & -5 \\\\\n -10 & 6 & 6 & 4 & -10 & 1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, -8, -1, -2, 8, -10, 1],\n [8, -2, -6, 6, 9, 5, 7],\n [3, 9, 8, -5, -4, -1, 5],\n [2, -2, -9, 2, -4, 2, -1],\n [2, -10, 3, -7, 9, -8, -10],\n [-10, -7, -4, -7, 2, 6, -5],\n [-10, 6, 6, 4, -10, 1, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 1 & 2 \\\\\n -1 & 3 \\\\\n 3 & -2 \\\\\n 0 & -1 \\\\\n 2 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.76 \\\\\n -1.74 \\\\\n 2.07 \\\\\n 2.45 \\\\\n -1.48 \\\\\n -1.39 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.171 \\\\\n -0.105 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 0],\n [1, 2],\n [-1, 3],\n [3, -2],\n [0, -1],\n [2, 0]])\nb = np.array([\n [-2.76],\n [-1.74],\n [2.07],\n [2.45],\n [-1.48],\n [-1.39]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-5,-2,-2\\}, \\{-2,1,3\\}, \\{-1,-3,0\\}}$.", - "Output Answer": [ - "$11 x+14 y-15 z+53=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-5, -2, -2],\n [-2, 1, 3],\n [-1, -3, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -4 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 4 \\\\\n 0 \\\\\n 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-4],\n [6]])\nb = np.array([\n [-5],\n [4],\n [-2]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{19}{10} & \\frac{23}{5} \\\\\n -\\frac{1}{5} & -\\frac{3}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{7}{20}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/10), (23/5)],\n [-(1/5), -(3/10)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{3} \\\\\n 6 \\\\\n -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{3} \\\\\n -\\frac{8}{3} \\\\\n 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{88}{9} \\\\\n \\frac{22}{9} \\\\\n \\frac{172}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/3)],\n [6],\n [-(11/3)]])\nb = np.array([\n [-(2/3)],\n [-(8/3)],\n [0]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -2 \\\\\n -5 \\\\\n -2 \\\\\n -9 \\\\\n 9 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n -8 \\\\\n -5 \\\\\n 4 \\\\\n 7 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{110}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-2],\n [-5],\n [-2],\n [-9],\n [9],\n [-6]])\nb = np.array([\n [1],\n [0],\n [-8],\n [-5],\n [4],\n [7],\n [8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{21}{10} & -\\frac{7}{2} & \\frac{17}{5} \\\\\n -\\frac{9}{5} & -\\frac{17}{10} & \\frac{47}{10} \\\\\n -\\frac{7}{5} & \\frac{24}{5} & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{28510}{23383} & \\frac{28570}{23383} & -\\frac{10670}{23383} \\\\\n -\\frac{280}{23383} & -\\frac{2590}{23383} & \\frac{3750}{23383} \\\\\n -\\frac{11020}{23383} & \\frac{14980}{23383} & -\\frac{2730}{23383} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(21/10), -(7/2), (17/5)],\n [-(9/5), -(17/10), (47/10)],\n [-(7/5), (24/5), (7/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 4 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{155}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-3],\n [1]])\nb = np.array([\n [-8],\n [4],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{4}{3} & \\frac{23}{6} \\\\\n \\frac{23}{6} & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{433}{36}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/3), (23/6)],\n [(23/6), -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{16}{9} \\\\\n -\\frac{2}{3} \\\\\n -\\frac{20}{3} \\\\\n \\frac{2}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{2 \\sqrt{974}}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(16/9)],\n [-(2/3)],\n [-(20/3)],\n [(2/9)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & 3 & 2 & 3 \\\\\n 1 & 0 & -2 & 3 \\\\\n -2 & 0 & 1 & 3 \\\\\n 1 & 2 & 0 & 0 \\\\\n -1 & -1 & 1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.37 \\\\\n 2.23 \\\\\n 1.44 \\\\\n 0.55 \\\\\n 1.41 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.783 \\\\\n 0.134 \\\\\n -0.783 \\\\\n 0.232 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3, 2, 3],\n [1, 0, -2, 3],\n [-2, 0, 1, 3],\n [1, 2, 0, 0],\n [-1, -1, 1, -1]])\nb = np.array([\n [-1.37],\n [2.23],\n [1.44],\n [0.55],\n [1.41]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & 3 \\\\\n \\frac{1}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{15}{4} & 6 \\\\\n 1 & \\frac{7}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), 3],\n [(1/2), (1/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{4}{3} & \\frac{1}{3} & -\\frac{23}{3} \\\\\n \\frac{11}{3} & 3 & \\frac{16}{3} \\\\\n \\frac{13}{3} & \\frac{1}{3} & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.738,19.005,1.\\}, \\{0.109\\, -1.359 i,0.379\\, +1.21 i,1.\\}, \\{0.109\\, +1.359 i,0.379\\, -1.21 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3), (1/3), -(23/3)],\n [(11/3), 3, (16/3)],\n [(13/3), (1/3), 0]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{41}{7} \\\\\n 9 \\\\\n \\frac{22}{7} \\\\\n \\frac{19}{7} \\\\\n -\\frac{6}{7} \\\\\n \\frac{6}{7} \\\\\n -\\frac{5}{7} \\\\\n \\frac{8}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{26}{7} \\\\\n -9 \\\\\n -\\frac{60}{7} \\\\\n \\frac{43}{7} \\\\\n -3 \\\\\n \\frac{61}{7} \\\\\n -\\frac{33}{7} \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{2749}{49}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(41/7)],\n [9],\n [(22/7)],\n [(19/7)],\n [-(6/7)],\n [(6/7)],\n [-(5/7)],\n [(8/7)]])\nb = np.array([\n [-(26/7)],\n [-9],\n [-(60/7)],\n [(43/7)],\n [-3],\n [(61/7)],\n [-(33/7)],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, -1, -4}$ to the plane $2 x+y+z=0$.", - "Output Answer": [ - "$\\frac{1}{\\sqrt{6}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, -1, -4\nplane = Poly(2*x+y+z, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,3,0\\}, \\{-1,2,3\\}, \\{2,1,-3\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{2}{\\sqrt{13}},\\frac{3}{\\sqrt{13}},0\\right\\}, \\left\\{\\frac{3}{\\sqrt{1534}},\\sqrt{\\frac{2}{767}},3 \\sqrt{\\frac{13}{118}}\\right\\}, \\left\\{\\frac{9}{\\sqrt{118}},3 \\sqrt{\\frac{2}{59}},-\\frac{1}{\\sqrt{118}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, 3, 0), (-1, 2, 3), (2, 1, -3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -2 & -\\frac{7}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{21}{8} & -\\frac{3}{2} \\\\\n -\\frac{7}{4} & \\frac{15}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{35}{16} & -\\frac{9}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -(7/4)]])\nb = np.array([\n [(21/8), -(3/2)],\n [-(7/4), (15/8)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{2}{3} & \\frac{7}{3} \\\\\n \\frac{4}{3} & -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3), (7/3)],\n [(4/3), -(5/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -1 & 3 & 0 \\\\\n -2 & 2 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 2 & 1 & 0 & 0 & -1 \\\\\n -3 & -3 & 3 & 2 & -1 \\\\\n 1 & 0 & 0 & -2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -11 & -10 & 9 & 6 & -2 \\\\\n -10 & -8 & 6 & 4 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, 0],\n [-2, 2, 0]])\nb = np.array([\n [2, 1, 0, 0, -1],\n [-3, -3, 3, 2, -1],\n [1, 0, 0, -2, 1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & 3 & -5 \\\\\n 5 & 1 & 9 \\\\\n 5 & -2 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-3.26-6.585 i,-3.26+6.585 i,5.52\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 3, -5],\n [5, 1, 9],\n [5, -2, -4]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,3,-3\\}, \\{5,-1,5\\}, \\{2,0,4\\}}$.", - "Output Answer": [ - "$x+5 y+2 z-10=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, 3, -3],\n [5, -1, 5],\n [2, 0, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{4}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 1 & -6 \\\\\n -1 & 7 & 3 \\\\\n -6 & 9 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{2} & -\\frac{5}{4} & \\frac{15}{2} \\\\\n \\frac{5}{4} & -\\frac{35}{4} & -\\frac{15}{4} \\\\\n \\frac{15}{2} & -\\frac{45}{4} & -\\frac{35}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, -6],\n [-1, 7, 3],\n [-6, 9, 7]])\nprint(a * -(5/4))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & -6 \\\\\n 3 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{3} \\left(5-\\sqrt{7}\\right),1\\right\\}, \\left\\{\\frac{1}{3} \\left(5+\\sqrt{7}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -6],\n [3, -9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 8 & 7 & -8 \\\\\n 9 & -10 & 9 \\\\\n 5 & -5 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+2 x^2+66 x+63$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 7, -8],\n [9, -10, 9],\n [5, -5, 4]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 7 \\\\\n 3 \\\\\n 6 \\\\\n -8 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -4 \\\\\n -9 \\\\\n 3 \\\\\n 5 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-19$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [7],\n [3],\n [6],\n [-8],\n [9]])\nb = np.array([\n [-2],\n [-4],\n [-9],\n [3],\n [5],\n [6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 9 & -9 \\\\\n 4 & 9 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -7 & -4 \\\\\n 2 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 16 & -5 \\\\\n 2 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -9],\n [4, 9]])\nb = np.array([\n [-7, -4],\n [2, 2]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [1],\n [-1]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [0],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 2 \\\\\n -4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2],\n [-4, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n 6 & 7 \\\\\n -9 & -5 \\\\\n -9 & -4 \\\\\n 3 & 7 \\\\\n 9 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 7],\n [-9, -5],\n [-9, -4],\n [3, 7],\n [9, 7]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -9 & 5 & 3 & -2 & 9 \\\\\n -9 & 7 & 5 & -5 & -2 \\\\\n -5 & -4 & -4 & -6 & -6 \\\\\n 6 & -3 & -2 & 1 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 5, 3, -2, 9],\n [-9, 7, 5, -5, -2],\n [-5, -4, -4, -6, -6],\n [6, -3, -2, 1, -8]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -1 & -3 & 0 \\\\\n 1 & -5 & 3 \\\\\n -1 & -3 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{2}{5} & \\frac{3}{8} & -\\frac{9}{40} \\\\\n -\\frac{1}{5} & -\\frac{1}{8} & \\frac{3}{40} \\\\\n -\\frac{1}{5} & 0 & \\frac{1}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -3, 0],\n [1, -5, 3],\n [-1, -3, 5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n 2 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{14}} \\\\\n -\\sqrt{\\frac{2}{7}} \\\\\n \\sqrt{\\frac{2}{7}} \\\\\n \\sqrt{\\frac{2}{7}} \\\\\n \\frac{1}{\\sqrt{14}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-2],\n [2],\n [2],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{39}{10} & -\\frac{16}{5} & -\\frac{31}{10} \\\\\n -5 & -\\frac{12}{5} & 4 \\\\\n \\frac{16}{5} & \\frac{3}{5} & \\frac{43}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{101 x^2}{10}+\\frac{247 x}{50}-\\frac{70731}{250}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(39/10), -(16/5), -(31/10)],\n [-5, -(12/5), 4],\n [(16/5), (3/5), (43/5)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n \\frac{11}{2} & -\\frac{17}{2} & \\frac{7}{2} \\\\\n -1 & 3 & -\\frac{3}{2} \\\\\n 1 & -8 & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{9}{2} & 1 & -9 \\\\\n \\frac{15}{2} & -\\frac{11}{2} & \\frac{9}{2} \\\\\n -9 & 10 & -\\frac{19}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 10 & -\\frac{15}{2} & -\\frac{11}{2} \\\\\n \\frac{13}{2} & -\\frac{5}{2} & 3 \\\\\n -8 & 2 & -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/2), -(17/2), (7/2)],\n [-1, 3, -(3/2)],\n [1, -8, -(5/2)]])\nb = np.array([\n [(9/2), 1, -9],\n [(15/2), -(11/2), (9/2)],\n [-9, 10, -(19/2)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & 0 \\\\\n -3 & -3 \\\\\n -2 & 0 \\\\\n -3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.48 \\\\\n -1.27 \\\\\n -1.55 \\\\\n -2.74 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.008 \\\\\n -0.339 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0],\n [-3, -3],\n [-2, 0],\n [-3, -3]])\nb = np.array([\n [2.48],\n [-1.27],\n [-1.55],\n [-2.74]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n -5 & -3 \\\\\n -10 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [1, 0],\n [-5, -3],\n [-10, 4]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 5 & 4 & 6 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-6.,0.,5.,0.\\}, \\{-4.,5.,0.,0.\\}, \\{-2.,0.,0.,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, 4, 6, 10]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{32}{5} \\\\\n \\frac{2}{5} \\\\\n \\frac{49}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{3 \\sqrt{381}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(32/5)],\n [(2/5)],\n [(49/5)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -7 & 0 \\\\\n -7 & -2 \\\\\n -9 & 1 \\\\\n 2 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 6 & 8 \\\\\n 2 & -6 \\\\\n -1 & 7 \\\\\n 10 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -1 & 8 \\\\\n -5 & -8 \\\\\n -10 & 8 \\\\\n 12 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 0],\n [-7, -2],\n [-9, 1],\n [2, -1]])\nb = np.array([\n [6, 8],\n [2, -6],\n [-1, 7],\n [10, 9]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -6 & -5 & 8 \\\\\n 2 & 0 & 1 \\\\\n 5 & 0 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-7 x^2+24 x-35$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -5, 8],\n [2, 0, 1],\n [5, 0, -1]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{7}{2},-5,\\frac{9}{2}\\right\\}, \\left\\{\\frac{9}{2},\\frac{9}{2},-\\frac{1}{2}\\right\\}, \\left\\{-\\frac{5}{2},\\frac{7}{2},2\\right\\}}$.", - "Output Answer": [ - "$50 x+40 y+156 z-327=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(7/2), -5, (9/2)],\n [(9/2), (9/2), -(1/2)],\n [-(5/2), (7/2), 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{2} \\\\\n \\frac{17}{2} \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{17}{2} \\\\\n -\\frac{19}{2} \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{649}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/2)],\n [(17/2)],\n [-6]])\nb = np.array([\n [(17/2)],\n [-(19/2)],\n [-5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{17}{4} & -\\frac{15}{8} \\\\\n \\frac{75}{8} & -\\frac{59}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{93 x}{8}+\\frac{3131}{64}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/4), -(15/8)],\n [(75/8), -(59/8)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 5 \\\\\n 2 \\\\\n -1 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 8 \\\\\n -1 \\\\\n 5 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{67}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [5],\n [2],\n [-1],\n [-8]])\nb = np.array([\n [-9],\n [8],\n [-1],\n [5],\n [-5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{4}{9}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -7 & -3 & 9 & 8 \\\\\n -9 & 3 & -10 & -10 \\\\\n -7 & -6 & 7 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{28}{9} & -\\frac{4}{3} & 4 & \\frac{32}{9} \\\\\n -4 & \\frac{4}{3} & -\\frac{40}{9} & -\\frac{40}{9} \\\\\n -\\frac{28}{9} & -\\frac{8}{3} & \\frac{28}{9} & \\frac{8}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -3, 9, 8],\n [-9, 3, -10, -10],\n [-7, -6, 7, 2]])\nprint(a * (4/9))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 6 \\\\\n -7 \\\\\n -4 \\\\\n 1 \\\\\n 4 \\\\\n -3 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 3 \\\\\n -5 \\\\\n 10 \\\\\n -4 \\\\\n 8 \\\\\n -10 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{511}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [6],\n [-7],\n [-4],\n [1],\n [4],\n [-3],\n [-1]])\nb = np.array([\n [-7],\n [3],\n [-5],\n [10],\n [-4],\n [8],\n [-10],\n [3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 2 \\\\\n -7 \\\\\n 4 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$27$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [2],\n [-7],\n [4],\n [10]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 3 & 5 \\\\\n -6 & -10 \\\\\n -3 & -5 \\\\\n 0 & 8 \\\\\n 6 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, 5],\n [-6, -10],\n [-3, -5],\n [0, 8],\n [6, 7]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\sqrt{2} \\\\\n -5 \\sqrt{2} \\\\\n -7 \\sqrt{2} \\\\\n \\sqrt{2} \\\\\n -5 \\sqrt{2} \\\\\n -5 \\sqrt{2} \\\\\n 3 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\sqrt{2} \\\\\n -2 \\sqrt{2} \\\\\n \\sqrt{2} \\\\\n 3 \\sqrt{2} \\\\\n -7 \\sqrt{2} \\\\\n 0 \\\\\n -\\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$68$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-math.sqrt(2)],\n [-5*math.sqrt(2)],\n [-7*math.sqrt(2)],\n [math.sqrt(2)],\n [-5*math.sqrt(2)],\n [-5*math.sqrt(2)],\n [3*math.sqrt(2)]])\nb = np.array([\n [4*math.sqrt(2)],\n [-2*math.sqrt(2)],\n [math.sqrt(2)],\n [3*math.sqrt(2)],\n [-7*math.sqrt(2)],\n [0],\n [-math.sqrt(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & 2 \\\\\n -3 & -2 \\\\\n 0 & -2 \\\\\n 3 & 0 \\\\\n 2 & -2 \\\\\n 1 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.19 \\\\\n -2.39 \\\\\n -0.05 \\\\\n 0.08 \\\\\n 1.65 \\\\\n -0.5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.357 \\\\\n 0.065 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2],\n [-3, -2],\n [0, -2],\n [3, 0],\n [2, -2],\n [1, -3]])\nb = np.array([\n [-0.19],\n [-2.39],\n [-0.05],\n [0.08],\n [1.65],\n [-0.5]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 3 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -4 \\\\\n 8 \\\\\n -16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [3],\n [4]])\nb = np.array([\n [2],\n [1],\n [0]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 2 & 2 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -3 & -2 \\\\\n 0 & 3 \\\\\n 1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -9 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, -3]])\nb = np.array([\n [-3, -2],\n [0, 3],\n [1, 1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [1],\n [0],\n [-1],\n [-1],\n [-1],\n [1],\n [1],\n [-1]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [0],\n [0],\n [0],\n [-1],\n [1],\n [-1],\n [-1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -7 & 8 & 1 & 10 & -3 & -6 \\\\\n 4 & -1 & 5 & -5 & -5 & -6 \\\\\n -6 & -2 & 10 & 7 & 1 & -3 \\\\\n 9 & -1 & -5 & 9 & -2 & -10 \\\\\n 7 & -8 & 9 & -9 & 3 & -7 \\\\\n -1 & -8 & 5 & -2 & 7 & -1 \\\\\n -4 & -2 & 4 & 9 & -6 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, 8, 1, 10, -3, -6],\n [4, -1, 5, -5, -5, -6],\n [-6, -2, 10, 7, 1, -3],\n [9, -1, -5, 9, -2, -10],\n [7, -8, 9, -9, 3, -7],\n [-1, -8, 5, -2, 7, -1],\n [-4, -2, 4, 9, -6, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & \\frac{7}{4} & \\frac{5}{2} \\\\\n \\frac{27}{4} & \\frac{1}{2} & 6 \\\\\n 5 & -9 & -\\frac{31}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{21}{4} & \\frac{27}{4} & \\frac{23}{4} \\\\\n -2 & -\\frac{33}{4} & -\\frac{39}{4} \\\\\n 10 & -\\frac{11}{4} & -\\frac{9}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{31}{4} & -5 & -\\frac{13}{4} \\\\\n \\frac{35}{4} & \\frac{35}{4} & \\frac{63}{4} \\\\\n -5 & -\\frac{25}{4} & -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), (7/4), (5/2)],\n [(27/4), (1/2), 6],\n [5, -9, -(31/4)]])\nb = np.array([\n [-(21/4), (27/4), (23/4)],\n [-2, -(33/4), -(39/4)],\n [10, -(11/4), -(9/4)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 6 \\\\\n 2 \\\\\n -6 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{94}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [6],\n [2],\n [-6],\n [3]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{4}{3}, \\frac{5}{3}}$ to the line $\\frac{x}{3}+\\frac{5 y}{3}+\\frac{10}{3}=0$.", - "Output Answer": [ - "$\\frac{17}{\\sqrt{26}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(4/3), (5/3)\nline = Poly((x/3)+((5*y)/3)+(10/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & 10 \\\\\n 7 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-10,7\\}, \\{1,1\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 10],\n [7, 7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n 4 & -9 \\\\\n -9 & -9 \\\\\n 6 & 0 \\\\\n -1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -9],\n [-9, -9],\n [6, 0],\n [-1, -1]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{7} \\\\\n -\\frac{8}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{17}} \\\\\n -\\frac{4}{\\sqrt{17}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/7)],\n [-(8/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{403}{50} & \\frac{649}{100} & -\\frac{49}{25} \\\\\n \\frac{393}{50} & \\frac{117}{50} & -\\frac{167}{20} \\\\\n -\\frac{99}{50} & \\frac{383}{100} & -\\frac{184}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{76 x^2}{25}+\\frac{805953 x}{10000}+\\frac{13340221}{25000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(403/50), (649/100), -(49/25)],\n [(393/50), (117/50), -(167/20)],\n [-(99/50), (383/100), -(184/25)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{41}{8} \\\\\n \\frac{1}{4} \\\\\n \\frac{31}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{8} \\\\\n \\frac{11}{2} \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{173}{4} \\\\\n -\\frac{503}{32} \\\\\n -\\frac{899}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(41/8)],\n [(1/4)],\n [(31/4)]])\nb = np.array([\n [-(3/8)],\n [(11/2)],\n [-(5/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & 3 \\\\\n 7 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-11-\\sqrt{109}\\right),\\frac{1}{2} \\left(\\sqrt{109}-11\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 3],\n [7, -3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 0 & -3 & 3 \\\\\n -4 & -5 & 2 \\\\\n 4 & -5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{5}{24} & -\\frac{3}{16} & \\frac{1}{16} \\\\\n -\\frac{1}{18} & -\\frac{1}{12} & -\\frac{1}{12} \\\\\n \\frac{5}{18} & -\\frac{1}{12} & -\\frac{1}{12} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3, 3],\n [-4, -5, 2],\n [4, -5, -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 6 & 4 \\\\\n 1 & -4 \\\\\n 3 & -4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 5 & 4 \\\\\n -8 & 2 \\\\\n -8 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 9 & -6 \\\\\n 11 & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 4],\n [1, -4],\n [3, -4]])\nb = np.array([\n [5, 4],\n [-8, 2],\n [-8, 5]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 5 & 3 & -2 & 4 \\\\\n 6 & 2 & 7 & -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 8 & -8 & -10 & -6 \\\\\n -2 & 4 & 3 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 13 & -5 & -12 & -2 \\\\\n 4 & 6 & 10 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 3, -2, 4],\n [6, 2, 7, -6]])\nb = np.array([\n [8, -8, -10, -6],\n [-2, 4, 3, 3]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & 0 & -2 & 2 \\\\\n 1 & 3 & 1 & 1 \\\\\n 0 & 2 & 3 & 3 \\\\\n 3 & 0 & 0 & -3 \\\\\n -2 & -1 & -1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.8 \\\\\n -2.83 \\\\\n 2.49 \\\\\n 2.26 \\\\\n -1.75 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.463 \\\\\n -2.08 \\\\\n 1.128 \\\\\n 0.877 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, -2, 2],\n [1, 3, 1, 1],\n [0, 2, 3, 3],\n [3, 0, 0, -3],\n [-2, -1, -1, -1]])\nb = np.array([\n [2.8],\n [-2.83],\n [2.49],\n [2.26],\n [-1.75]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 0 & 5 & -4 & 1 & 5 & 2 & -7 \\\\\n -6 & 8 & -8 & 3 & 1 & -9 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & \\frac{4}{15} & -\\frac{7}{30} & \\frac{7}{6} & \\frac{61}{30} & -\\frac{27}{10} \\\\\n 0 & 1 & -\\frac{4}{5} & \\frac{1}{5} & 1 & \\frac{2}{5} & -\\frac{7}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, 5, -4, 1, 5, 2, -7],\n [-6, 8, -8, 3, 1, -9, 5]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & \\frac{13}{3} & \\frac{2}{3} \\\\\n 0 & \\frac{25}{3} & 2 \\\\\n 6 & \\frac{4}{3} & \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-0.338-0.99 i,-0.338+0.99 i,9.343\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, (13/3), (2/3)],\n [0, (25/3), 2],\n [6, (4/3), (4/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -7 & -4 \\\\\n -1 & -10 \\\\\n 2 & 7 \\\\\n -1 & 3 \\\\\n -10 & -8 \\\\\n 2 & -9 \\\\\n -9 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, -4],\n [-1, -10],\n [2, 7],\n [-1, 3],\n [-10, -8],\n [2, -9],\n [-9, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -3 & 2 & 5 \\\\\n 2 & 8 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & -\\frac{25}{14} \\\\\n 0 & 1 & -\\frac{5}{28} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 2, 5],\n [2, 8, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -3 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1]])\nb = np.array([\n [-1],\n [-1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$12$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6]])\nb = np.array([\n [-2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{17}{4} & \\frac{79}{16} \\\\\n -\\frac{77}{16} & \\frac{19}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{608}{8667} & -\\frac{1264}{8667} \\\\\n \\frac{1232}{8667} & \\frac{1088}{8667} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/4), (79/16)],\n [-(77/16), (19/8)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\sqrt{\\frac{2}{21}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [-1],\n [0],\n [-1],\n [-1],\n [-1],\n [1],\n [1]]).squeeze()\nb = np.array([\n [1],\n [1],\n [1],\n [-1],\n [0],\n [0],\n [-1],\n [-1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,3,5\\}, \\{-4,-2,1\\}, \\{-3,-3,2\\}}$.", - "Output Answer": [ - "$9 x+y-8 z+46=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, 3, 5],\n [-4, -2, 1],\n [-3, -3, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{11}{9}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & -9 & -10 & 0 \\\\\n 1 & 8 & -2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{11}{3} & 11 & \\frac{110}{9} & 0 \\\\\n -\\frac{11}{9} & -\\frac{88}{9} & \\frac{22}{9} & \\frac{11}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -9, -10, 0],\n [1, 8, -2, -1]])\nprint(a * -(11/9))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 5 & 3 & -6 \\\\\n 3 & -3 & 6 \\\\\n 1 & -7 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-4.646-7.133 i,-4.646+7.133 i,6.292\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 3, -6],\n [3, -3, 6],\n [1, -7, -5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{63}{8} \\\\\n -\\frac{11}{8} \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -\\frac{77}{8} \\\\\n -\\frac{39}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{341}{32} \\\\\n \\frac{3097}{32} \\\\\n -\\frac{5555}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(63/8)],\n [-(11/8)],\n [-(5/2)]])\nb = np.array([\n [-8],\n [-(77/8)],\n [-(39/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{33}{4} \\\\\n -\\frac{29}{4} \\\\\n -\\frac{27}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{2} \\\\\n \\frac{13}{4} \\\\\n -\\frac{21}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{11}{4} \\\\\n -4 \\\\\n -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(33/4)],\n [-(29/4)],\n [-(27/4)]])\nb = np.array([\n [-(11/2)],\n [(13/4)],\n [-(21/4)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $3$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 5 & 5 & -6 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 15 & 15 & -18 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 5, -6, 1]])\nprint(a * 3)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{23}{3} & \\frac{25}{3} \\\\\n \\frac{7}{3} & \\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{6} \\left(-15-\\sqrt{1661}\\right),\\frac{1}{6} \\left(\\sqrt{1661}-15\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/3), (25/3)],\n [(7/3), (8/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & -\\frac{23}{3} & -10 \\\\\n 2 & \\frac{14}{3} & \\frac{20}{3} \\\\\n -\\frac{1}{3} & -1 & -\\frac{17}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.621,-0.813,1.\\}, \\{2.246\\, -17.075 i,-8.946+2.462 i,1.\\}, \\{2.246\\, +17.075 i,-8.946-2.462 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(23/3), -10],\n [2, (14/3), (20/3)],\n [-(1/3), -1, -(17/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 3 & 1 & -1 & -3 \\\\\n 2 & 2 & 2 & -1 \\\\\n 3 & 2 & -3 & 3 \\\\\n -3 & 2 & 3 & 0 \\\\\n -1 & 0 & 3 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.67 \\\\\n 0.84 \\\\\n -1.3 \\\\\n 1.67 \\\\\n -0.27 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.248 \\\\\n 0.501 \\\\\n -0.038 \\\\\n -0.573 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1, -1, -3],\n [2, 2, 2, -1],\n [3, 2, -3, 3],\n [-3, 2, 3, 0],\n [-1, 0, 3, 1]])\nb = np.array([\n [1.67],\n [0.84],\n [-1.3],\n [1.67],\n [-0.27]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{71}{8} \\\\\n \\frac{31}{8} \\\\\n \\frac{15}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n \\frac{73}{8} \\\\\n -\\frac{21}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{873}{32} \\\\\n -\\frac{1311}{64} \\\\\n -\\frac{5555}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(71/8)],\n [(31/8)],\n [(15/8)]])\nb = np.array([\n [(3/2)],\n [(73/8)],\n [-(21/8)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 8 & -3 & -7 & 8 \\\\\n -5 & -2 & 10 & -8 \\\\\n -10 & 8 & 1 & 2 \\\\\n 6 & -8 & 9 & 1 \\\\\n 5 & -4 & -2 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, -3, -7, 8],\n [-5, -2, 10, -8],\n [-10, 8, 1, 2],\n [6, -8, 9, 1],\n [5, -4, -2, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & 3 & -1 & 1 \\\\\n 0 & 1 & 2 & 1 \\\\\n -3 & -3 & 1 & 1 \\\\\n 1 & 3 & 3 & 3 \\\\\n 0 & 2 & 0 & 3 \\\\\n 1 & 2 & 2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.56 \\\\\n -1.24 \\\\\n 0.77 \\\\\n 1.2 \\\\\n -1.61 \\\\\n -2.1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.025 \\\\\n -0.189 \\\\\n -0.124 \\\\\n 0.252 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, -1, 1],\n [0, 1, 2, 1],\n [-3, -3, 1, 1],\n [1, 3, 3, 3],\n [0, 2, 0, 3],\n [1, 2, 2, -3]])\nb = np.array([\n [0.56],\n [-1.24],\n [0.77],\n [1.2],\n [-1.61],\n [-2.1]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, -3, 4}$ to the plane $x-\\frac{8 y}{3}+\\frac{7 z}{3}-2=0$.", - "Output Answer": [ - "$\\frac{37}{\\sqrt{122}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, -3, 4\nplane = Poly(x-((8*y)/3)+((7*z)/3)-2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -2 & -2 \\\\\n -2 & 0 \\\\\n 1 & 2 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 2 & -2 & 1 \\\\\n 2 & 2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -8 & 0 & -6 \\\\\n -4 & 4 & -2 \\\\\n 6 & 2 & 5 \\\\\n 2 & 2 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2],\n [-2, 0],\n [1, 2],\n [0, 1]])\nb = np.array([\n [2, -2, 1],\n [2, 2, 2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{2}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -5 \\\\\n -15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [6]])\nprint(a * -(5/2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{4,0,-2\\}, \\{1,-2,-1\\}, \\{2,-2,4\\}}$.", - "Output Answer": [ - "$5 x-8 y-z-22=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, 0, -2],\n [1, -2, -1],\n [2, -2, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{14}{5}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{14}{5} & -\\frac{56}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -4]])\nprint(a * (14/5))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 0 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{3,0\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [0]]).squeeze()\nb = np.array([\n [1],\n [0]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{32}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & -8 \\\\\n 7 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{32} & \\frac{1}{4} \\\\\n -\\frac{7}{32} & -\\frac{1}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -8],\n [7, 4]])\nprint(a * -(1/32))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{14}{\\pi } \\\\\n \\frac{24}{\\pi } \\\\\n -\\frac{6}{\\pi } \\\\\n \\frac{16}{\\pi } \\\\\n \\frac{7}{\\pi } \\\\\n -\\frac{9}{\\pi } \\\\\n \\frac{1}{\\pi } \\\\\n \\frac{8}{\\pi } \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{8}{\\pi } \\\\\n \\frac{2}{\\pi } \\\\\n \\frac{6}{\\pi } \\\\\n \\frac{22}{\\pi } \\\\\n -\\frac{24}{\\pi } \\\\\n \\frac{11}{\\pi } \\\\\n \\frac{25}{\\pi } \\\\\n -\\frac{16}{\\pi } \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{106}{\\pi ^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(14/math.pi)],\n [(24/math.pi)],\n [-(6/math.pi)],\n [(16/math.pi)],\n [(7/math.pi)],\n [-(9/math.pi)],\n [(1/math.pi)],\n [(8/math.pi)]])\nb = np.array([\n [(8/math.pi)],\n [(2/math.pi)],\n [(6/math.pi)],\n [(22/math.pi)],\n [-(24/math.pi)],\n [(11/math.pi)],\n [(25/math.pi)],\n [-(16/math.pi)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{32}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 7 & -6 & -3 & 10 \\\\\n 4 & -9 & 6 & 2 \\\\\n -4 & -7 & -3 & -2 \\\\\n -8 & 5 & -7 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{35}{32} & \\frac{15}{16} & \\frac{15}{32} & -\\frac{25}{16} \\\\\n -\\frac{5}{8} & \\frac{45}{32} & -\\frac{15}{16} & -\\frac{5}{16} \\\\\n \\frac{5}{8} & \\frac{35}{32} & \\frac{15}{32} & \\frac{5}{16} \\\\\n \\frac{5}{4} & -\\frac{25}{32} & \\frac{35}{32} & -\\frac{5}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -6, -3, 10],\n [4, -9, 6, 2],\n [-4, -7, -3, -2],\n [-8, 5, -7, 1]])\nprint(a * -(5/32))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & \\frac{3}{2} & 1 \\\\\n -2 & -\\frac{5}{2} & 0 \\\\\n 2 & \\frac{1}{2} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & -\\frac{19}{4} & -\\frac{5}{2} \\\\\n 7 & \\frac{13}{4} & -2 \\\\\n -6 & 1 & \\frac{17}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, (3/2), 1],\n [-2, -(5/2), 0],\n [2, (1/2), -(3/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & 7 \\\\\n -9 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{6} i \\left(3 \\sqrt{3}-i\\right),1\\right\\}, \\left\\{-\\frac{1}{6} i \\left(3 \\sqrt{3}+i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 7],\n [-9, -3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{9}{5} & -\\frac{11}{5} & -\\frac{9}{5} \\\\\n -\\frac{14}{5} & \\frac{11}{5} & -\\frac{9}{5} \\\\\n \\frac{13}{5} & -\\frac{7}{5} & \\frac{6}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{159}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/5), -(11/5), -(9/5)],\n [-(14/5), (11/5), -(9/5)],\n [(13/5), -(7/5), (6/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -1 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 2 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$76$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-1],\n [10]])\nb = np.array([\n [-3],\n [2],\n [6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -6 & 6 & -4 & -3 \\\\\n 10 & 10 & 0 & 9 \\\\\n -3 & 3 & 8 & 4 \\\\\n -2 & 9 & 6 & -10 \\\\\n -1 & -8 & 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-6, 6, -4, -3],\n [10, 10, 0, 9],\n [-3, 3, 8, 4],\n [-2, 9, 6, -10],\n [-1, -8, 0, 2]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -3 & -2 & 3 & -8 & -8 \\\\\n 6 & 5 & -8 & 6 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2, 3, -8, -8],\n [6, 5, -8, 6, 0]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{2} \\\\\n 4 \\\\\n -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{2} \\\\\n 5 \\\\\n -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n \\frac{333}{4} \\\\\n \\frac{103}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2)],\n [4],\n [-(13/2)]])\nb = np.array([\n [-(17/2)],\n [5],\n [-8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 7 \\\\\n -4 \\\\\n -3 \\\\\n 7 \\\\\n 6 \\\\\n -5 \\\\\n -8 \\\\\n 5 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 5 \\\\\n -5 \\\\\n -3 \\\\\n 8 \\\\\n 8 \\\\\n 4 \\\\\n 10 \\\\\n -9 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{241}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [7],\n [-4],\n [-3],\n [7],\n [6],\n [-5],\n [-8],\n [5],\n [-5]])\nb = np.array([\n [9],\n [5],\n [-5],\n [-3],\n [8],\n [8],\n [4],\n [10],\n [-9],\n [3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 0 \\\\\n -3 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 1 \\\\\n -1 \\\\\n 3 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{3}{4},\\frac{3}{8},-\\frac{3}{8},\\frac{9}{8},\\frac{9}{8}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [0],\n [-3],\n [-2],\n [2]]).squeeze()\nb = np.array([\n [-2],\n [1],\n [-1],\n [3],\n [3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -7 & 3 & -5 \\\\\n -5 & 6 & 3 \\\\\n -5 & 7 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.868,-1.587,1.\\}, \\{-0.088,1.203,1.\\}, \\{2.622,0.718,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 3, -5],\n [-5, 6, 3],\n [-5, 7, 0]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,0,-1\\}, \\{-2,-2,-1\\}, \\{0,0,-3\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{2}{\\sqrt{5}},0,-\\frac{1}{\\sqrt{5}}\\right\\}, \\left\\{-\\frac{2}{3 \\sqrt{5}},-\\frac{\\sqrt{5}}{3},-\\frac{4}{3 \\sqrt{5}}\\right\\}, \\left\\{-\\frac{1}{3},\\frac{2}{3},-\\frac{2}{3}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, 0, -1), (-2, -2, -1), (0, 0, -3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{1}{3},1,-4\\right\\}, \\left\\{\\frac{11}{3},-\\frac{7}{3},-\\frac{2}{3}\\right\\}, \\left\\{1,\\frac{10}{3},\\frac{13}{3}\\right\\}}$.", - "Output Answer": [ - "$96 x+69 y-27 z-209=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(1/3), 1, -4],\n [(11/3), -(7/3), -(2/3)],\n [1, (10/3), (13/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,0,-2\\}, \\{0,-4,0\\}, \\{-3,-2,3\\}}$.", - "Output Answer": [ - "$8 x+3 y+6 z+12=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, 0, -2],\n [0, -4, 0],\n [-3, -2, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & -1 & -1 & 3 \\\\\n -1 & 3 & 1 & -1 \\\\\n 1 & -1 & -3 & 0 \\\\\n -2 & 3 & 3 & -3 \\\\\n -1 & -2 & -2 & -2 \\\\\n -1 & -3 & -2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.89 \\\\\n 1.62 \\\\\n -1.27 \\\\\n 1.45 \\\\\n 0.92 \\\\\n -2.08 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.739 \\\\\n 0.435 \\\\\n -0.108 \\\\\n 0.259 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, -1, 3],\n [-1, 3, 1, -1],\n [1, -1, -3, 0],\n [-2, 3, 3, -3],\n [-1, -2, -2, -2],\n [-1, -3, -2, -3]])\nb = np.array([\n [0.89],\n [1.62],\n [-1.27],\n [1.45],\n [0.92],\n [-2.08]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 5 & 1 & -2 \\\\\n -6 & 4 & 3 \\\\\n -9 & 4 & -10 \\\\\n 8 & 10 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, 1, -2],\n [-6, 4, 3],\n [-9, 4, -10],\n [8, 10, 2]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\pi \\\\\n -3 \\pi \\\\\n 0 \\\\\n 2 \\pi \\\\\n 2 \\pi \\\\\n 0 \\\\\n -\\pi \\\\\n -\\pi \\\\\n 3 \\pi \\\\\n -2 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\pi \\\\\n \\pi \\\\\n -2 \\pi \\\\\n -2 \\pi \\\\\n 2 \\pi \\\\\n 3 \\pi \\\\\n \\pi \\\\\n 3 \\pi \\\\\n 0 \\\\\n -\\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{19} \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.pi],\n [-3*math.pi],\n [0],\n [2*math.pi],\n [2*math.pi],\n [0],\n [-math.pi],\n [-math.pi],\n [3*math.pi],\n [-2*math.pi]])\nb = np.array([\n [2*math.pi],\n [math.pi],\n [-2*math.pi],\n [-2*math.pi],\n [2*math.pi],\n [3*math.pi],\n [math.pi],\n [3*math.pi],\n [0],\n [-math.pi]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{87}{16} & -\\frac{7}{2} & -\\frac{65}{8} & \\frac{63}{16} & -\\frac{111}{16} \\\\\n -\\frac{157}{16} & -\\frac{77}{8} & -\\frac{39}{8} & \\frac{71}{8} & -\\frac{79}{8} \\\\\n \\frac{9}{16} & \\frac{39}{8} & \\frac{83}{16} & \\frac{91}{16} & -\\frac{53}{8} \\\\\n \\frac{69}{16} & -\\frac{1}{4} & \\frac{93}{16} & \\frac{13}{8} & \\frac{81}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(87/16), -(7/2), -(65/8), (63/16), -(111/16)],\n [-(157/16), -(77/8), -(39/8), (71/8), -(79/8)],\n [(9/16), (39/8), (83/16), (91/16), -(53/8)],\n [(69/16), -(1/4), (93/16), (13/8), (81/16)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 1 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 3 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 16 \\\\\n 52 \\\\\n -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [1],\n [-4]])\nb = np.array([\n [-9],\n [3],\n [4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{9} \\\\\n \\frac{59}{9} \\\\\n \\frac{46}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{3} \\\\\n \\frac{25}{3} \\\\\n \\frac{13}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{383}{27} \\\\\n -\\frac{167}{3} \\\\\n \\frac{2036}{27} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/9)],\n [(59/9)],\n [(46/9)]])\nb = np.array([\n [-(29/3)],\n [(25/3)],\n [(13/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{11}{5} & \\frac{7}{5} & 0 & \\frac{11}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{5} \\\\\n -\\frac{2}{5} \\\\\n \\frac{4}{5} \\\\\n -\\frac{12}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{113}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/5), (7/5), 0, (11/5)]])\nb = np.array([\n [-(3/5)],\n [-(2/5)],\n [(4/5)],\n [-(12/5)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{8}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -8 & 2 \\\\\n 4 & 9 \\\\\n -5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 7 & -\\frac{7}{4} \\\\\n -\\frac{7}{2} & -\\frac{63}{8} \\\\\n \\frac{35}{8} & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 2],\n [4, 9],\n [-5, -4]])\nprint(a * -(7/8))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{16}{5} & \\frac{7}{2} & \\frac{23}{10} \\\\\n \\frac{2}{5} & \\frac{41}{10} & \\frac{23}{10} \\\\\n -1 & \\frac{14}{5} & \\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{10}{111} & \\frac{70}{111} & -\\frac{115}{111} \\\\\n -\\frac{245}{111} & -\\frac{235}{111} & \\frac{230}{37} \\\\\n \\frac{145}{37} & \\frac{455}{111} & -\\frac{1210}{111} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(16/5), (7/2), (23/10)],\n [(2/5), (41/10), (23/10)],\n [-1, (14/5), (8/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [-1],\n [0]]).squeeze()\nb = np.array([\n [1],\n [0],\n [0],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & 1 & 0 & -1 \\\\\n 2 & 2 & 1 & -2 \\\\\n 3 & 0 & 1 & 2 \\\\\n 0 & -3 & 2 & -2 \\\\\n 0 & 1 & -3 & -1 \\\\\n 3 & 1 & 0 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.82 \\\\\n 2.48 \\\\\n -2.97 \\\\\n -0.38 \\\\\n 2.17 \\\\\n 2.1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.417 \\\\\n 0.078 \\\\\n -0.645 \\\\\n -0.376 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 0, -1],\n [2, 2, 1, -2],\n [3, 0, 1, 2],\n [0, -3, 2, -2],\n [0, 1, -3, -1],\n [3, 1, 0, 3]])\nb = np.array([\n [-2.82],\n [2.48],\n [-2.97],\n [-0.38],\n [2.17],\n [2.1]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,1,0\\}, \\{-1,-3,2\\}, \\{-3,3,1\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{2}{\\sqrt{5}},\\frac{1}{\\sqrt{5}},0\\right\\}, \\left\\{-\\frac{7}{\\sqrt{345}},-\\frac{14}{\\sqrt{345}},2 \\sqrt{\\frac{5}{69}}\\right\\}, \\left\\{\\frac{2}{\\sqrt{69}},\\frac{4}{\\sqrt{69}},\\frac{7}{\\sqrt{69}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, 1, 0), (-1, -3, 2), (-3, 3, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -4 & 8 & 2 & -1 \\\\\n -6 & 2 & 1 & -5 \\\\\n 1 & -9 & -2 & -1 \\\\\n 4 & 7 & -7 & 3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -6 & 9 & -3 & 2 \\\\\n -8 & 5 & 4 & 6 \\\\\n 4 & -6 & 7 & -5 \\\\\n -4 & 8 & 1 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 2 & -1 & 5 & -3 \\\\\n 2 & -3 & -3 & -11 \\\\\n -3 & -3 & -9 & 4 \\\\\n 8 & -1 & -8 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 8, 2, -1],\n [-6, 2, 1, -5],\n [1, -9, -2, -1],\n [4, 7, -7, 3]])\nb = np.array([\n [-6, 9, -3, 2],\n [-8, 5, 4, 6],\n [4, -6, 7, -5],\n [-4, 8, 1, 1]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -6 \\\\\n -7 \\\\\n 4 \\\\\n -9 \\\\\n 7 \\\\\n 1 \\\\\n -9 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 0 \\\\\n -10 \\\\\n 3 \\\\\n -8 \\\\\n 2 \\\\\n -5 \\\\\n 4 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{309}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-6],\n [-7],\n [4],\n [-9],\n [7],\n [1],\n [-9],\n [3]])\nb = np.array([\n [-7],\n [0],\n [-10],\n [3],\n [-8],\n [2],\n [-5],\n [4],\n [-1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 1 & -9 & -5 \\\\\n 5 & -2 & 6 \\\\\n -5 & -9 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-7 x^2-78 x+341$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -9, -5],\n [5, -2, 6],\n [-5, -9, -6]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -5 & -3 \\\\\n -2 & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{33}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -3],\n [-2, -(9/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -4 & 5 \\\\\n 9 & 2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -7 & 9 \\\\\n -8 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 3 & -4 \\\\\n 17 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 5],\n [9, 2]])\nb = np.array([\n [-7, 9],\n [-8, 7]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,0,-1\\}, \\{2,4,-1\\}, \\{-3,-3,3\\}}$.", - "Output Answer": [ - "$16 x-20 y-15 z+33=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, 0, -1],\n [2, 4, -1],\n [-3, -3, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{9} & -\\frac{7}{9} \\\\\n -\\frac{20}{9} & \\frac{2}{9} \\\\\n \\frac{22}{9} & -2 \\\\\n -\\frac{8}{9} & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{16}{9} & \\frac{23}{9} & \\frac{7}{9} \\\\\n -3 & \\frac{8}{3} & -\\frac{25}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{269}{81} & -\\frac{283}{81} & \\frac{140}{81} \\\\\n \\frac{266}{81} & -\\frac{412}{81} & -\\frac{190}{81} \\\\\n \\frac{134}{81} & \\frac{74}{81} & \\frac{604}{81} \\\\\n -\\frac{358}{81} & \\frac{248}{81} & -\\frac{506}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/9), -(7/9)],\n [-(20/9), (2/9)],\n [(22/9), -2],\n [-(8/9), 2]])\nb = np.array([\n [-(16/9), (23/9), (7/9)],\n [-3, (8/3), -(25/9)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 0 & -9 & -4 \\\\\n -1 & 2 & -10 \\\\\n -5 & -1 & 5 \\\\\n -7 & -3 & -1 \\\\\n -10 & -8 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, -9, -4],\n [-1, 2, -10],\n [-5, -1, 5],\n [-7, -3, -1],\n [-10, -8, 4]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 7 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -7 \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 70 \\\\\n 28 \\\\\n 21 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [7],\n [4]])\nb = np.array([\n [1],\n [-7],\n [6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 1 & 1 & 2 \\\\\n -3 & 2 & 3 \\\\\n 1 & 0 & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -3 & 0 & 3 & 1 & -1 \\\\\n 0 & 1 & 3 & 2 & 1 \\\\\n 3 & 2 & -1 & 3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 3 & 5 & 4 & 9 & -4 \\\\\n 18 & 8 & -6 & 10 & -1 \\\\\n 6 & 6 & 0 & 10 & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1, 2],\n [-3, 2, 3],\n [1, 0, 3]])\nb = np.array([\n [-3, 0, 3, 1, -1],\n [0, 1, 3, 2, 1],\n [3, 2, -1, 3, -2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & -5 & 5 \\\\\n -2 & 2 & 4 \\\\\n -3 & 2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{12} & \\frac{5}{24} & -\\frac{5}{12} \\\\\n -\\frac{5}{36} & \\frac{13}{72} & -\\frac{1}{36} \\\\\n \\frac{1}{36} & \\frac{19}{72} & -\\frac{7}{36} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -5, 5],\n [-2, 2, 4],\n [-3, 2, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{3} \\\\\n \\frac{10}{9} \\\\\n 0 \\\\\n -\\frac{1}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{19}{27} \\\\\n -\\frac{190}{81} \\\\\n 0 \\\\\n \\frac{19}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/3)],\n [(10/9)],\n [0],\n [-(1/9)]])\nb = np.array([\n [-(19/9)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 1 & 2 \\\\\n 2 & -1 & -2 \\\\\n 1 & 1 & -1 \\\\\n -3 & -2 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.12 \\\\\n 2.09 \\\\\n -0.24 \\\\\n 0.54 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.016 \\\\\n -0.708 \\\\\n -0.687 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, 2],\n [2, -1, -2],\n [1, 1, -1],\n [-3, -2, 1]])\nb = np.array([\n [-2.12],\n [2.09],\n [-0.24],\n [0.54]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -3 & 1 \\\\\n -1 & -2 & -3 \\\\\n -3 & 3 & -1 \\\\\n -3 & -1 & 1 \\\\\n 0 & 0 & 2 \\\\\n 0 & -3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.31 \\\\\n -0.34 \\\\\n 0.87 \\\\\n 1.83 \\\\\n 1.95 \\\\\n 1.97 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.554 \\\\\n -0.443 \\\\\n 0.384 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3, 1],\n [-1, -2, -3],\n [-3, 3, -1],\n [-3, -1, 1],\n [0, 0, 2],\n [0, -3, -2]])\nb = np.array([\n [1.31],\n [-0.34],\n [0.87],\n [1.83],\n [1.95],\n [1.97]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -1 & -4 \\\\\n -1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2} & -\\frac{1}{2} \\\\\n -\\frac{1}{8} & \\frac{1}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -4],\n [-1, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{6}{7}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & 9 \\\\\n 0 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{24}{7} & \\frac{54}{7} \\\\\n 0 & -\\frac{6}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 9],\n [0, -1]])\nprint(a * (6/7))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -6 \\\\\n 9 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-6],\n [9],\n [0]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,-3,5\\}, \\{-1,1,3\\}, \\{3,0,0\\}}$.", - "Output Answer": [ - "$14 x+11 y+15 z-42=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, -3, 5],\n [-1, 1, 3],\n [3, 0, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & -2 \\\\\n 2 & -3 & -2 \\\\\n 2 & 0 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, -2],\n [2, -3, -2],\n [2, 0, -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{2 \\sqrt{5}} \\\\\n \\frac{1}{2 \\sqrt{5}} \\\\\n \\frac{1}{2 \\sqrt{5}} \\\\\n 0 \\\\\n \\frac{3}{2 \\sqrt{5}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [1],\n [1],\n [0],\n [3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 1 & 3 & -10 & -4 \\\\\n -3 & 1 & -3 & -5 \\\\\n -4 & 6 & -2 & 7 \\\\\n -3 & 9 & -6 & -9 \\\\\n 0 & -6 & -10 & 6 \\\\\n 4 & -3 & -1 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, 3, -10, -4],\n [-3, 1, -3, -5],\n [-4, 6, -2, 7],\n [-3, 9, -6, -9],\n [0, -6, -10, 6],\n [4, -3, -1, -10]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{1}{2},0,\\frac{7}{2}\\right\\}, \\left\\{\\frac{5}{2},\\frac{9}{2},-1\\right\\}, \\left\\{-\\frac{7}{2},-4,5\\right\\}}$.", - "Output Answer": [ - "$30 x-4 (6 y+z)+29=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(1/2), 0, (7/2)],\n [(5/2), (9/2), -1],\n [-(7/2), -4, 5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{2} \\\\\n \\frac{17}{2} \\\\\n -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 0 \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 51 \\\\\n 14 \\\\\n 85 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/2)],\n [(17/2)],\n [-(13/2)]])\nb = np.array([\n [-10],\n [0],\n [6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & -1 \\\\\n 5 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-5-\\sqrt{29}\\right),\\frac{1}{2} \\left(\\sqrt{29}-5\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -1],\n [5, 1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{7}{5}, -\\frac{17}{5}}$ to the line $-x+\\frac{5 y}{2}+\\frac{13}{10}=0$.", - "Output Answer": [ - "$\\frac{2 \\sqrt{29}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(7/5), -(17/5)\nline = Poly(-x+((5*y)/2)+(13/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & 0 & -3 \\\\\n 2 & 3 & -4 \\\\\n -4 & 3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{4} & \\frac{1}{4} & -\\frac{1}{4} \\\\\n -\\frac{1}{2} & \\frac{7}{18} & -\\frac{1}{18} \\\\\n -\\frac{1}{2} & \\frac{1}{6} & -\\frac{1}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, -3],\n [2, 3, -4],\n [-4, 3, -1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,1,-3\\}, \\{5,4,3\\}, \\{3,5,-3\\}}$.", - "Output Answer": [ - "$24 x-18 y-11 z-15=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, 1, -3],\n [5, 4, 3],\n [3, 5, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 8 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{226}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [8],\n [9]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 3 \\\\\n 4 \\\\\n -9 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -9 \\\\\n -10 \\\\\n 1 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8 \\sqrt{10}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [3],\n [4],\n [-9],\n [9]])\nb = np.array([\n [8],\n [-9],\n [-10],\n [1],\n [-5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{10}{3},0,-2\\right\\}, \\left\\{\\frac{8}{3},-3,3\\right\\}, \\left\\{2,-1,-\\frac{8}{3}\\right\\}}$.", - "Output Answer": [ - "$21 x+92 y+30 z+130=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(10/3), 0, -2],\n [(8/3), -3, 3],\n [2, -1, -(8/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -7 & -10 & 8 & -3 & -7 \\\\\n 4 & 6 & 0 & -2 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -10, 8, -3, -7],\n [4, 6, 0, -2, 3]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{4}{3} & \\frac{25}{3} \\\\\n 9 & \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{27} \\left(-4-\\sqrt{691}\\right),1\\right\\}, \\left\\{\\frac{1}{27} \\left(\\sqrt{691}-4\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/3), (25/3)],\n [9, (4/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 2 & 8 & -9 & -1 & -9 \\\\\n 6 & 5 & 6 & -9 & -2 \\\\\n 1 & 9 & 8 & 10 & -3 \\\\\n -7 & 10 & 6 & -1 & 5 \\\\\n -10 & 3 & 5 & -5 & 0 \\\\\n 0 & 0 & 7 & 4 & -7 \\\\\n 1 & -8 & -6 & 2 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, 8, -9, -1, -9],\n [6, 5, 6, -9, -2],\n [1, 9, 8, 10, -3],\n [-7, 10, 6, -1, 5],\n [-10, 3, 5, -5, 0],\n [0, 0, 7, 4, -7],\n [1, -8, -6, 2, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n 3 \\\\\n -2 \\\\\n 3 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{2 \\sqrt{7}} \\\\\n \\frac{1}{\\sqrt{7}} \\\\\n \\frac{3}{2 \\sqrt{7}} \\\\\n -\\frac{1}{\\sqrt{7}} \\\\\n \\frac{3}{2 \\sqrt{7}} \\\\\n -\\frac{1}{2 \\sqrt{7}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [2],\n [3],\n [-2],\n [3],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n 2 & -1 & 7 & -9 & 9 \\\\\n 6 & -9 & 1 & 9 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1, 7, -9, 9],\n [6, -9, 1, 9, 6]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & -1 \\\\\n -\\frac{8}{3} & \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1],\n [-(8/3), (4/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{2}{5},-\\frac{4}{5},\\frac{12}{5}\\right\\}, \\left\\{1,-\\frac{13}{5},\\frac{11}{5}\\right\\}, \\left\\{\\frac{13}{5},-\\frac{3}{5},\\frac{7}{5}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{41}},-\\frac{2}{\\sqrt{41}},\\frac{6}{\\sqrt{41}}\\right\\}, \\left\\{\\frac{146 \\sqrt{\\frac{2}{1353}}}{9},-\\frac{359}{9 \\sqrt{2706}},-\\frac{71}{9 \\sqrt{2706}}\\right\\}, \\left\\{\\frac{28 \\sqrt{\\frac{2}{33}}}{9},\\frac{41}{9 \\sqrt{66}},\\frac{23}{9 \\sqrt{66}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-(2/5), -(4/5), (12/5)), (1, -(13/5), (11/5)), ((13/5), -(3/5), (7/5))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{6}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -9 & 4 \\\\\n -9 & 6 \\\\\n -4 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{21}{2} & \\frac{14}{3} \\\\\n -\\frac{21}{2} & 7 \\\\\n -\\frac{14}{3} & -\\frac{7}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 4],\n [-9, 6],\n [-4, -1]])\nprint(a * (7/6))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{34}{7} & -\\frac{68}{7} \\\\\n \\frac{50}{7} & -2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 6 & -\\frac{66}{7} \\\\\n -\\frac{1}{7} & -\\frac{23}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{76}{7} & -\\frac{2}{7} \\\\\n \\frac{51}{7} & \\frac{9}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(34/7), -(68/7)],\n [(50/7), -2]])\nb = np.array([\n [6, -(66/7)],\n [-(1/7), -(23/7)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\sqrt{2} \\\\\n -6 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\sqrt{2} \\\\\n -5 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{5}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [4*math.sqrt(2)],\n [-6*math.sqrt(2)]])\nb = np.array([\n [math.sqrt(2)],\n [-5*math.sqrt(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{21}{5} & -\\frac{16}{5} & \\frac{4}{5} \\\\\n \\frac{11}{5} & \\frac{44}{5} & \\frac{13}{5} \\\\\n -5 & \\frac{19}{5} & -\\frac{16}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.55,2.576,1.\\}, \\{-0.007-0.528 i,-0.212+0.044 i,1.\\}, \\{-0.007+0.528 i,-0.212-0.044 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(21/5), -(16/5), (4/5)],\n [(11/5), (44/5), (13/5)],\n [-5, (19/5), -(16/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 8 & -\\frac{11}{2} & -\\frac{5}{2} \\\\\n 5 & \\frac{7}{2} & -2 \\\\\n -\\frac{17}{2} & 9 & -\\frac{19}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+2 x^2+57 x-\\frac{5309}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -(11/2), -(5/2)],\n [5, (7/2), -2],\n [-(17/2), 9, -(19/2)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 1 & -3 & 0 \\\\\n 5 & 4 & -2 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{4}{19} & \\frac{3}{19} & \\frac{6}{19} \\\\\n -\\frac{5}{19} & \\frac{1}{19} & \\frac{2}{19} \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3, 0],\n [5, 4, -2],\n [0, 0, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2} & -\\frac{35}{4} \\\\\n \\frac{67}{8} & \\frac{19}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -2 & -\\frac{15}{2} \\\\\n -\\frac{27}{4} & -\\frac{21}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & -\\frac{5}{4} \\\\\n \\frac{121}{8} & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), -(35/4)],\n [(67/8), (19/8)]])\nb = np.array([\n [-2, -(15/2)],\n [-(27/4), -(21/8)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -5 & -1 \\\\\n -4 & -4 & -1 \\\\\n 4 & -3 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-107$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -5, -1],\n [-4, -4, -1],\n [4, -3, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n \\frac{7}{3} & \\frac{17}{3} & \\frac{5}{3} & -\\frac{10}{3} & -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/3), (17/3), (5/3), -(10/3), -(11/3)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -9 \\\\\n -2 \\\\\n -6 \\\\\n -8 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 0 \\\\\n -7 \\\\\n 4 \\\\\n 10 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-9],\n [-2],\n [-6],\n [-8],\n [6]])\nb = np.array([\n [-9],\n [0],\n [-7],\n [4],\n [10],\n [7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{22}{5} & \\frac{3}{5} & \\frac{19}{5} \\\\\n -\\frac{16}{5} & -\\frac{22}{5} & \\frac{9}{5} \\\\\n \\frac{7}{5} & \\frac{14}{5} & -\\frac{12}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1319}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(22/5), (3/5), (19/5)],\n [-(16/5), -(22/5), (9/5)],\n [(7/5), (14/5), -(12/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -7 \\\\\n -3 \\\\\n 1 \\\\\n -7 \\\\\n 8 \\\\\n -6 \\\\\n 8 \\\\\n 5 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -3 \\\\\n -2 \\\\\n 1 \\\\\n -7 \\\\\n -5 \\\\\n 2 \\\\\n 6 \\\\\n 4 \\\\\n -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{17}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-7],\n [-3],\n [1],\n [-7],\n [8],\n [-6],\n [8],\n [5],\n [1]])\nb = np.array([\n [6],\n [-3],\n [-2],\n [1],\n [-7],\n [-5],\n [2],\n [6],\n [4],\n [-10]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & -3 \\\\\n 7 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{7} \\left(-2-i \\sqrt{17}\\right),1\\right\\}, \\left\\{\\frac{1}{7} \\left(-2+i \\sqrt{17}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3],\n [7, 5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{17}{4} & -\\frac{7}{2} \\\\\n \\frac{9}{4} & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{8}{29} & \\frac{28}{29} \\\\\n -\\frac{18}{29} & \\frac{34}{29} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/4), -(7/2)],\n [(9/4), -1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 4 & 0 \\\\\n 0 & 6 \\\\\n -3 & -5 \\\\\n -3 & 7 \\\\\n -9 & -4 \\\\\n -3 & -1 \\\\\n -7 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, 0],\n [0, 6],\n [-3, -5],\n [-3, 7],\n [-9, -4],\n [-3, -1],\n [-7, -10]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -9 & -2 & -7 & -7 \\\\\n 5 & -6 & -6 & -3 \\\\\n -6 & 1 & -1 & 7 \\\\\n -2 & -3 & -6 & -3 \\\\\n -7 & 9 & 3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -2, -7, -7],\n [5, -6, -6, -3],\n [-6, 1, -1, 7],\n [-2, -3, -6, -3],\n [-7, 9, 3, 2]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{23}{8} & -\\frac{41}{8} & \\frac{49}{8} \\\\\n -\\frac{9}{2} & -\\frac{17}{4} & -\\frac{59}{8} \\\\\n \\frac{43}{8} & 9 & \\frac{5}{2} \\\\\n -\\frac{25}{8} & \\frac{1}{2} & \\frac{13}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{35}{4} & -\\frac{15}{4} & 2 \\\\\n \\frac{9}{2} & 10 & 2 \\\\\n \\frac{35}{8} & -\\frac{55}{8} & -\\frac{11}{8} \\\\\n -\\frac{47}{8} & \\frac{79}{8} & -\\frac{23}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{93}{8} & -\\frac{11}{8} & \\frac{33}{8} \\\\\n -9 & -\\frac{57}{4} & -\\frac{75}{8} \\\\\n 1 & \\frac{127}{8} & \\frac{31}{8} \\\\\n \\frac{11}{4} & -\\frac{75}{8} & \\frac{75}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/8), -(41/8), (49/8)],\n [-(9/2), -(17/4), -(59/8)],\n [(43/8), 9, (5/2)],\n [-(25/8), (1/2), (13/2)]])\nb = np.array([\n [(35/4), -(15/4), 2],\n [(9/2), 10, 2],\n [(35/8), -(55/8), -(11/8)],\n [-(47/8), (79/8), -(23/8)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{15}{2} & \\frac{11}{2} & -\\frac{17}{4} \\\\\n -5 & \\frac{1}{2} & -\\frac{27}{4} \\\\\n -2 & \\frac{19}{2} & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{2.355\\, -9.427 i,2.355\\, +9.427 i,10.291\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/2), (11/2), -(17/4)],\n [-5, (1/2), -(27/4)],\n [-2, (19/2), 7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -4 & -\\frac{5}{2} \\\\\n \\frac{5}{2} & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{39}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -(5/2)],\n [(5/2), 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{47}{5} \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{33}{10} \\\\\n \\frac{17}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{127}{10} \\\\\n -\\frac{73}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(47/5)],\n [-9]])\nb = np.array([\n [(33/10)],\n [(17/10)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -1 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -22 \\\\\n -44 \\\\\n -11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-3],\n [2]])\nb = np.array([\n [-2],\n [-1],\n [8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{11}{16}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 9 & 5 & 4 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{99}{16} & -\\frac{55}{16} & -\\frac{11}{4} & -\\frac{55}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 5, 4, 5]])\nprint(a * -(11/16))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -7 & 3 & -10 & 3 \\\\\n -5 & -3 & 2 & -10 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 8 & -3 & -7 & -8 \\\\\n 5 & 6 & -10 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -15 & 6 & -3 & 11 \\\\\n -10 & -9 & 12 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 3, -10, 3],\n [-5, -3, 2, -10]])\nb = np.array([\n [8, -3, -7, -8],\n [5, 6, -10, -9]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [0],\n [1],\n [1],\n [0],\n [-1]]).squeeze()\nb = np.array([\n [0],\n [1],\n [1],\n [-1],\n [1],\n [0],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & 1 \\\\\n 3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1],\n [3, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{4}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -6 & -6 & 0 & 5 \\\\\n -3 & 1 & -3 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{3}{2} & \\frac{3}{2} & 0 & -\\frac{5}{4} \\\\\n \\frac{3}{4} & -\\frac{1}{4} & \\frac{3}{4} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -6, 0, 5],\n [-3, 1, -3, -10]])\nprint(a * -(1/4))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{53}{25} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{53}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(53/25)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${0, 4}$ to the line $2 x-2 y+2=0$.", - "Output Answer": [ - "$\\frac{3}{\\sqrt{2}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 0, 4\nline = Poly(2*x-2*y+2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 2 & 5 & 3 & 10 & 2 \\\\\n -9 & -8 & 0 & 6 & 9 \\\\\n -1 & -6 & 3 & -5 & 1 \\\\\n 4 & 6 & 8 & 5 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-3881.,4755.,2697.,-2861.,2253.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, 5, 3, 10, 2],\n [-9, -8, 0, 6, 9],\n [-1, -6, 3, -5, 1],\n [4, 6, 8, 5, -9]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -10 & -6 & 7 \\\\\n 9 & 4 & -2 \\\\\n 2 & 5 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-11 x^2-40 x+113$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -6, 7],\n [9, 4, -2],\n [2, 5, -5]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 0 & 3 \\\\\n 0 & 0 & 2 \\\\\n -2 & -2 & -1 \\\\\n -3 & -1 & -3 \\\\\n -1 & -1 & 2 \\\\\n -1 & -1 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.16 \\\\\n -2.62 \\\\\n 2.3 \\\\\n -1.57 \\\\\n 1.92 \\\\\n 0.97 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.678 \\\\\n -2.926 \\\\\n -0.179 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0, 3],\n [0, 0, 2],\n [-2, -2, -1],\n [-3, -1, -3],\n [-1, -1, 2],\n [-1, -1, 0]])\nb = np.array([\n [0.16],\n [-2.62],\n [2.3],\n [-1.57],\n [1.92],\n [0.97]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & 2 & -2 \\\\\n -2 & 2 & -1 \\\\\n -2 & -1 & 3 \\\\\n 0 & -3 & -3 \\\\\n 3 & 3 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.97 \\\\\n -1.78 \\\\\n 0.59 \\\\\n -1.58 \\\\\n -2.88 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.575 \\\\\n -0.036 \\\\\n 0.189 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2, -2],\n [-2, 2, -1],\n [-2, -1, 3],\n [0, -3, -3],\n [3, 3, -1]])\nb = np.array([\n [2.97],\n [-1.78],\n [0.59],\n [-1.58],\n [-2.88]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(\\sqrt{6}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [1],\n [0],\n [1],\n [0]]).squeeze()\nb = np.array([\n [0],\n [0],\n [0],\n [-1],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{49}{5} \\\\\n \\frac{31}{10} \\\\\n -\\frac{29}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -\\frac{17}{5} \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1113}{50} \\\\\n \\frac{421}{10} \\\\\n -\\frac{1511}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(49/5)],\n [(31/10)],\n [-(29/10)]])\nb = np.array([\n [-1],\n [-(17/5)],\n [-4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 10 \\\\\n 4 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(7-\\sqrt{241}\\right),\\frac{1}{2} \\left(7+\\sqrt{241}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 10],\n [4, -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & -9 & -2 \\\\\n 0 & 0 & -5 \\\\\n 5 & -4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1.027,-0.647,1.\\}, \\{0.024\\, -1.616 i,0.496\\, -1.042 i,1.\\}, \\{0.024\\, +1.616 i,0.496\\, +1.042 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -9, -2],\n [0, 0, -5],\n [5, -4, 0]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n \\frac{19}{4} & \\frac{19}{2} & -\\frac{3}{2} & -\\frac{29}{4} & -\\frac{29}{4} \\\\\n -\\frac{7}{2} & -\\frac{3}{2} & \\frac{11}{2} & -\\frac{29}{4} & -\\frac{9}{2} \\\\\n \\frac{19}{2} & \\frac{1}{2} & \\frac{3}{2} & \\frac{19}{4} & -\\frac{11}{2} \\\\\n 7 & \\frac{21}{4} & -\\frac{13}{2} & -\\frac{15}{4} & -\\frac{33}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/4), (19/2), -(3/2), -(29/4), -(29/4)],\n [-(7/2), -(3/2), (11/2), -(29/4), -(9/2)],\n [(19/2), (1/2), (3/2), (19/4), -(11/2)],\n [7, (21/4), -(13/2), -(15/4), -(33/4)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n 0 & -1 & 10 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -1, 10, 0]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,1,1\\}, \\{3,1,3\\}, \\{2,2,1\\}}$", - "Output Answer": [ - "${\\left\\{\\sqrt{\\frac{2}{3}},\\frac{1}{\\sqrt{6}},\\frac{1}{\\sqrt{6}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{21}},-\\frac{2}{\\sqrt{21}},\\frac{4}{\\sqrt{21}}\\right\\}, \\left\\{-\\sqrt{\\frac{2}{7}},\\frac{3}{\\sqrt{14}},\\frac{1}{\\sqrt{14}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, 1, 1), (3, 1, 3), (2, 2, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2 & -2 & -3 \\\\\n -3 & -2 & -2 \\\\\n -2 & -3 & 3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -85 & -69 & -79 \\\\\n -94 & -85 & -59 \\\\\n -59 & -79 & 40 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2, -3],\n [-3, -2, -2],\n [-2, -3, 3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,1,-2\\}, \\{1,2,0\\}, \\{-1,0,-2\\}}$", - "Output Answer": [ - "${\\left\\{0,\\frac{1}{\\sqrt{5}},-\\frac{2}{\\sqrt{5}}\\right\\}, \\left\\{\\sqrt{\\frac{5}{21}},\\frac{8}{\\sqrt{105}},\\frac{4}{\\sqrt{105}}\\right\\}, \\left\\{-\\frac{4}{\\sqrt{21}},\\frac{2}{\\sqrt{21}},\\frac{1}{\\sqrt{21}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, 1, -2), (1, 2, 0), (-1, 0, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{31}{8} & 5 \\\\\n -\\frac{17}{8} & -\\frac{33}{8} \\\\\n -\\frac{57}{8} & -\\frac{51}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{31}{8} & -\\frac{11}{2} \\\\\n -7 & -\\frac{45}{8} \\\\\n -\\frac{7}{4} & -\\frac{21}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{31}{4} & \\frac{21}{2} \\\\\n \\frac{39}{8} & \\frac{3}{2} \\\\\n -\\frac{43}{8} & -\\frac{15}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(31/8), 5],\n [-(17/8), -(33/8)],\n [-(57/8), -(51/8)]])\nb = np.array([\n [-(31/8), -(11/2)],\n [-7, -(45/8)],\n [-(7/4), -(21/8)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 0 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -4 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{89}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [0],\n [6]])\nb = np.array([\n [-5],\n [-4],\n [-8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -7 & 1 & -2 \\\\\n -3 & -8 & -8 \\\\\n -2 & 7 & 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & 8 \\\\\n -2 & 4 & -4 \\\\\n -5 & -6 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -6 & 0 & 6 \\\\\n -5 & -4 & -12 \\\\\n -7 & 1 & 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 1, -2],\n [-3, -8, -8],\n [-2, 7, 7]])\nb = np.array([\n [1, -1, 8],\n [-2, 4, -4],\n [-5, -6, 4]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{4} & \\frac{21}{8} \\\\\n -3 & \\frac{1}{4} \\\\\n \\frac{3}{2} & -\\frac{31}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n \\frac{5}{16} & -\\frac{25}{16} & \\frac{25}{16} & -\\frac{19}{8} & \\frac{31}{16} \\\\\n 0 & -\\frac{43}{16} & -\\frac{11}{8} & \\frac{33}{16} & \\frac{43}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n \\frac{15}{64} & -\\frac{1053}{128} & -\\frac{39}{16} & \\frac{465}{128} & \\frac{1089}{128} \\\\\n -\\frac{15}{16} & \\frac{257}{64} & -\\frac{161}{32} & \\frac{489}{64} & -\\frac{329}{64} \\\\\n \\frac{15}{32} & \\frac{733}{256} & \\frac{641}{128} & -\\frac{1935}{256} & -\\frac{589}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/4), (21/8)],\n [-3, (1/4)],\n [(3/2), -(31/16)]])\nb = np.array([\n [(5/16), -(25/16), (25/16), -(19/8), (31/16)],\n [0, -(43/16), -(11/8), (33/16), (43/16)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{ccc}\n 1 & -1 & 1 \\\\\n -2 & -4 & 2 \\\\\n -3 & -6 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 2 & -\\frac{5}{2} & 2 \\\\\n -2 & 0 & 0 \\\\\n -3 & -\\frac{3}{2} & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [1, -1, 1],\n [-2, -4, 2],\n [-3, -6, 3]])\nprint(expm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{25}{3} & -7 & -\\frac{20}{3} \\\\\n 3 & \\frac{25}{3} & \\frac{17}{3} \\\\\n -8 & -\\frac{8}{3} & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.858,5.641,1.\\}, \\{0.015,-0.976,1.\\}, \\{1.467,-0.54,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/3), -7, -(20/3)],\n [3, (25/3), (17/3)],\n [-8, -(8/3), 0]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{26}{3} \\\\\n -\\frac{4}{3} \\\\\n \\frac{26}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{14}{3} \\\\\n 6 \\\\\n \\frac{10}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{508}{9} \\\\\n \\frac{104}{9} \\\\\n \\frac{524}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/3)],\n [-(4/3)],\n [(26/3)]])\nb = np.array([\n [(14/3)],\n [6],\n [(10/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -7 & 1 \\\\\n -10 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, 1],\n [-10, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & 0 & 0 \\\\\n 1 & 1 & 1 \\\\\n -2 & -2 & 1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 8 & 0 & 0 \\\\\n -3 & -5 & 1 \\\\\n -18 & -2 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, 0],\n [1, 1, 1],\n [-2, -2, 1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{2} & -2 & -1 \\\\\n -1 & -2 & -\\frac{3}{2} \\\\\n 1 & 0 & -2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{13}{4} & 1 & \\frac{7}{2} \\\\\n -1 & 6 & 7 \\\\\n -\\frac{1}{2} & -2 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), -2, -1],\n [-1, -2, -(3/2)],\n [1, 0, -2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -9 & -9 & -9 & 2 & 5 \\\\\n -5 & 10 & 9 & 9 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.,-14.,15.,0.,0.\\}, \\{23.,52.,0.,0.,135.\\}, \\{101.,-71.,0.,135.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, -9, -9, 2, 5],\n [-5, 10, 9, 9, -3]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{9} \\\\\n -\\frac{2}{3} \\\\\n -\\frac{1}{9} \\\\\n -\\frac{4}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{17}{3 \\sqrt{38}} \\\\\n -\\sqrt{\\frac{2}{19}} \\\\\n -\\frac{1}{3 \\sqrt{38}} \\\\\n -\\frac{2 \\sqrt{\\frac{2}{19}}}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/9)],\n [-(2/3)],\n [-(1/9)],\n [-(4/9)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 4 & -3 & -5 \\\\\n 5 & 1 & -2 \\\\\n 1 & 5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{25} & \\frac{37}{150} & -\\frac{11}{150} \\\\\n -\\frac{3}{25} & \\frac{11}{150} & \\frac{17}{150} \\\\\n -\\frac{4}{25} & \\frac{23}{150} & -\\frac{19}{150} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -3, -5],\n [5, 1, -2],\n [1, 5, -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [1],\n [-1],\n [-1],\n [-1],\n [-1]]).squeeze()\nb = np.array([\n [0],\n [-1],\n [0],\n [0],\n [1],\n [0],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{49}{10} & \\frac{37}{10} & -\\frac{14}{5} \\\\\n \\frac{7}{10} & -\\frac{19}{10} & -2 \\\\\n \\frac{7}{10} & -\\frac{33}{10} & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{25}{98} & -\\frac{520}{343} & \\frac{795}{686} \\\\\n 0 & \\frac{5}{7} & -\\frac{5}{7} \\\\\n \\frac{5}{56} & -\\frac{335}{196} & \\frac{425}{392} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(49/10), (37/10), -(14/5)],\n [(7/10), -(19/10), -2],\n [(7/10), -(33/10), -2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{4}{3} \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{8}{17} \\\\\n -\\frac{15}{17} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [(4/3)],\n [-(5/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 3 & 0 \\\\\n 2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2]])\nb = np.array([\n [3, 0],\n [2, -2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, -3}$ to the line $-2 x-4 y+2=0$.", - "Output Answer": [ - "$\\frac{4}{\\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, -3\nline = Poly(-2*x-4*y+2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-1,2,-2\\}, \\{0,3,-2\\}, \\{2,1,-1\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{3},\\frac{2}{3},-\\frac{2}{3}\\right\\}, \\left\\{\\frac{10}{3 \\sqrt{17}},\\frac{7}{3 \\sqrt{17}},\\frac{2}{3 \\sqrt{17}}\\right\\}, \\left\\{\\frac{2}{\\sqrt{17}},-\\frac{2}{\\sqrt{17}},-\\frac{3}{\\sqrt{17}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, 2, -2), (0, 3, -2), (2, 1, -1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{4} & -\\frac{35}{4} \\\\\n -\\frac{31}{4} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{62} \\left(3-\\sqrt{4349}\\right),1\\right\\}, \\left\\{\\frac{1}{62} \\left(3+\\sqrt{4349}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/4), -(35/4)],\n [-(31/4), -(1/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{2}{3} & \\frac{5}{3} \\\\\n \\frac{7}{3} & -\\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{7} \\left(3-2 \\sqrt{11}\\right),1\\right\\}, \\left\\{\\frac{1}{7} \\left(3+2 \\sqrt{11}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/3), (5/3)],\n [(7/3), -(4/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{3,0,-1\\}, \\{1,0,-2\\}, \\{1,-3,-2\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{3}{\\sqrt{10}},0,-\\frac{1}{\\sqrt{10}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{10}},0,-\\frac{3}{\\sqrt{10}}\\right\\}, \\{0,-1,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((3, 0, -1), (1, 0, -2), (1, -3, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & -\\frac{5}{2} \\\\\n -3 & -3 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{31}{4} & \\frac{25}{4} \\\\\n \\frac{15}{2} & \\frac{33}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), -(5/2)],\n [-3, -3]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 0 & 9 \\\\\n -1 & -3 \\\\\n 10 & -6 \\\\\n 10 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, 9],\n [-1, -3],\n [10, -6],\n [10, 2]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -1 \\\\\n -8 \\\\\n 7 \\\\\n 1 \\\\\n -1 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -9 \\\\\n 4 \\\\\n 0 \\\\\n 2 \\\\\n -7 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{538}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-1],\n [-8],\n [7],\n [1],\n [-1],\n [-8]])\nb = np.array([\n [8],\n [-9],\n [4],\n [0],\n [2],\n [-7],\n [4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1}{\\sqrt{5}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [1],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [1],\n [1],\n [-1],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, -\\frac{9}{2}}$ to the line $5 x-5 y-3=0$.", - "Output Answer": [ - "$\\frac{9}{10 \\sqrt{2}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, -(9/2)\nline = Poly(5*x-5*y-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -2 & -1 \\\\\n 0 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2} & -\\frac{1}{8} \\\\\n 0 & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1],\n [0, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{2}{3} & 3 \\\\\n -1 & \\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{15}{17} & -\\frac{27}{17} \\\\\n \\frac{9}{17} & -\\frac{6}{17} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3), 3],\n [-1, (5/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -4 \\\\\n -1 \\\\\n -5 \\\\\n 0 \\\\\n 4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 4 \\\\\n 2 \\\\\n 7 \\\\\n -4 \\\\\n 10 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-11$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-4],\n [-1],\n [-5],\n [0],\n [4],\n [-2]])\nb = np.array([\n [4],\n [4],\n [2],\n [7],\n [-4],\n [10],\n [5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 0 & 3 & 3 & -2 & -3 \\\\\n -1 & -3 & 3 & 1 & 3 \\\\\n 0 & 1 & 0 & 2 & 0 \\\\\n 0 & -1 & 0 & 3 & -1 \\\\\n 3 & 0 & -2 & -2 & 3 \\\\\n 3 & 1 & 1 & -1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.86 \\\\\n 2.96 \\\\\n -1.04 \\\\\n 1.15 \\\\\n -1.86 \\\\\n 0.18 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.008 \\\\\n -0.644 \\\\\n 0.723 \\\\\n -0.109 \\\\\n -0.347 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 3, 3, -2, -3],\n [-1, -3, 3, 1, 3],\n [0, 1, 0, 2, 0],\n [0, -1, 0, 3, -1],\n [3, 0, -2, -2, 3],\n [3, 1, 1, -1, -1]])\nb = np.array([\n [1.86],\n [2.96],\n [-1.04],\n [1.15],\n [-1.86],\n [0.18]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{205}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [8]])\nb = np.array([\n [-1],\n [-6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 2 & 0 & 2 & 2 \\\\\n -1 & -1 & -1 & 0 \\\\\n 3 & 1 & 0 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 0 & -2 & -3 & 3 & 1 \\\\\n 2 & -2 & -2 & -2 & -2 \\\\\n 2 & 3 & 1 & 2 & 3 \\\\\n 2 & 1 & -3 & -2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 8 & 4 & -10 & 6 & 8 \\\\\n -4 & 1 & 4 & -3 & -2 \\\\\n 4 & -7 & -14 & 5 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, 2, 2],\n [-1, -1, -1, 0],\n [3, 1, 0, 1]])\nb = np.array([\n [0, -2, -3, 3, 1],\n [2, -2, -2, -2, -2],\n [2, 3, 1, 2, 3],\n [2, 1, -3, -2, 0]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{22}{3} \\\\\n -5 \\\\\n -\\frac{23}{3} \\\\\n \\frac{4}{3} \\\\\n \\frac{2}{3} \\\\\n -\\frac{17}{3} \\\\\n 1 \\\\\n -\\frac{26}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{62}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(22/3)],\n [-5],\n [-(23/3)],\n [(4/3)],\n [(2/3)],\n [-(17/3)],\n [1],\n [-(26/3)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{8}{3}, -\\frac{14}{3}}$ to the line $4 x+y-\\frac{11}{3}=0$.", - "Output Answer": [ - "$\\frac{19}{\\sqrt{17}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(8/3), -(14/3)\nline = Poly(4*x+y-(11/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{10} & -\\frac{9}{10} & \\frac{9}{10} \\\\\n -\\frac{17}{10} & \\frac{18}{5} & \\frac{3}{10} \\\\\n \\frac{23}{10} & \\frac{2}{5} & \\frac{43}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{160}{207} & -\\frac{235}{1104} & \\frac{65}{368} \\\\\n -\\frac{250}{621} & \\frac{35}{207} & \\frac{5}{69} \\\\\n \\frac{280}{621} & \\frac{325}{3312} & \\frac{145}{1104} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/10), -(9/10), (9/10)],\n [-(17/10), (18/5), (3/10)],\n [(23/10), (2/5), (43/10)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{17}{2} \\\\\n \\frac{5}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{41}{6} \\\\\n \\frac{7}{6} \\\\\n -\\frac{10}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1055}{36} \\\\\n \\frac{445}{36} \\\\\n -\\frac{223}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [(17/2)],\n [(5/6)]])\nb = np.array([\n [(41/6)],\n [(7/6)],\n [-(10/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -3 & 0 & 0 \\\\\n 4 & -3 & 3 \\\\\n 4 & -3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{3} & 0 & 0 \\\\\n -\\frac{4}{9} & 0 & -\\frac{1}{3} \\\\\n 0 & \\frac{1}{3} & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, 0],\n [4, -3, 3],\n [4, -3, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{29}{3} & -\\frac{29}{3} & \\frac{11}{3} \\\\\n \\frac{23}{6} & \\frac{49}{6} & 4 \\\\\n -\\frac{35}{6} & -3 & -\\frac{13}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{8}{3} & -\\frac{17}{3} & -\\frac{11}{6} \\\\\n -\\frac{35}{6} & \\frac{41}{6} & \\frac{11}{3} \\\\\n \\frac{13}{6} & -\\frac{53}{6} & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -7 & -\\frac{46}{3} & \\frac{11}{6} \\\\\n -2 & 15 & \\frac{23}{3} \\\\\n -\\frac{11}{3} & -\\frac{71}{6} & -\\frac{37}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/3), -(29/3), (11/3)],\n [(23/6), (49/6), 4],\n [-(35/6), -3, -(13/6)]])\nb = np.array([\n [(8/3), -(17/3), -(11/6)],\n [-(35/6), (41/6), (11/3)],\n [(13/6), -(53/6), -4]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{12}{7} \\\\\n -\\frac{3}{7} \\\\\n \\frac{18}{7} \\\\\n -\\frac{6}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{4}{\\sqrt{57}} \\\\\n -\\frac{1}{\\sqrt{57}} \\\\\n 2 \\sqrt{\\frac{3}{19}} \\\\\n -\\frac{2}{\\sqrt{57}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(12/7)],\n [-(3/7)],\n [(18/7)],\n [-(6/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -6 & 7 \\\\\n 2 & 7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 0 & 1 \\\\\n -1 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -6 & 6 \\\\\n 3 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 7],\n [2, 7]])\nb = np.array([\n [0, 1],\n [-1, -1]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -1 \\\\\n -1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1],\n [-1, -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -7 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 8 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{23 \\sqrt{\\frac{2}{15}}}{15}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-7],\n [5]]).squeeze()\nb = np.array([\n [5],\n [8],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -9 \\\\\n -8 \\\\\n -8 \\\\\n -4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{310}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-9],\n [-8],\n [-8],\n [-4],\n [-2]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n \\frac{9}{10} & -\\frac{17}{10} & 6 \\\\\n \\frac{97}{10} & \\frac{17}{10} & -\\frac{89}{10} \\\\\n -6 & \\frac{14}{5} & -\\frac{18}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{47}{5} & \\frac{37}{10} & 5 \\\\\n \\frac{19}{2} & \\frac{14}{5} & \\frac{23}{10} \\\\\n \\frac{69}{10} & \\frac{26}{5} & \\frac{41}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{17}{2} & 2 & 11 \\\\\n \\frac{96}{5} & \\frac{9}{2} & -\\frac{33}{5} \\\\\n \\frac{9}{10} & 8 & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/10), -(17/10), 6],\n [(97/10), (17/10), -(89/10)],\n [-6, (14/5), -(18/5)]])\nb = np.array([\n [-(47/5), (37/10), 5],\n [(19/2), (14/5), (23/10)],\n [(69/10), (26/5), (41/10)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -4 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -3 \\\\\n -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 12 \\\\\n -26 \\\\\n 23 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-4],\n [-4]])\nb = np.array([\n [5],\n [-3],\n [-6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{17}{2} & -\\frac{1}{2} & -\\frac{7}{2} \\\\\n -\\frac{1}{2} & -\\frac{15}{2} & 7 \\\\\n \\frac{3}{2} & -3 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+2 x^2+\\frac{147 x}{4}+\\frac{517}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/2), -(1/2), -(7/2)],\n [-(1/2), -(15/2), 7],\n [(3/2), -3, 1]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & 1 & -3 & 3 & 2 \\\\\n -1 & 3 & 2 & -1 & 0 \\\\\n 2 & 1 & 0 & -3 & 0 \\\\\n 1 & -2 & 0 & 1 & 2 \\\\\n 2 & 3 & -3 & 0 & 2 \\\\\n 2 & -1 & 2 & 3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.56 \\\\\n -2.62 \\\\\n 2.78 \\\\\n 0.35 \\\\\n -1.59 \\\\\n -2.81 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.454 \\\\\n -0.789 \\\\\n -0.712 \\\\\n -0.876 \\\\\n 0.425 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, -3, 3, 2],\n [-1, 3, 2, -1, 0],\n [2, 1, 0, -3, 0],\n [1, -2, 0, 1, 2],\n [2, 3, -3, 0, 2],\n [2, -1, 2, 3, 2]])\nb = np.array([\n [1.56],\n [-2.62],\n [2.78],\n [0.35],\n [-1.59],\n [-2.81]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{2} \\\\\n 5 \\\\\n -7 \\\\\n \\frac{17}{2} \\\\\n \\frac{1}{2} \\\\\n -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 8 \\\\\n \\frac{1}{2} \\\\\n -2 \\\\\n 9 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{37}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/2)],\n [5],\n [-7],\n [(17/2)],\n [(1/2)],\n [-(13/2)]])\nb = np.array([\n [4],\n [8],\n [(1/2)],\n [-2],\n [9],\n [-5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & -\\frac{1}{2} \\\\\n 0 & \\frac{5}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{27}{8} & -\\frac{49}{8} \\\\\n 0 & \\frac{125}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), -(1/2)],\n [0, (5/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{2}-5 i & -\\frac{1}{2}+\\frac{3 i}{2} \\\\\n -4 & \\frac{5}{2}+\\frac{5 i}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{11}{4}+39 i & \\frac{19}{4}-\\frac{7 i}{4} \\\\\n 8+10 i & 2+\\frac{13 i}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2)-5j, -(1/2)+((3j)/2)],\n [-4, (5/2)+((5j)/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -\\frac{23}{9} & -3 & \\frac{2}{3} \\\\\n \\frac{26}{9} & \\frac{25}{9} & -\\frac{8}{3} \\\\\n \\frac{16}{9} & \\frac{7}{3} & \\frac{1}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & -\\frac{5}{3} & \\frac{23}{9} & \\frac{22}{9} \\\\\n \\frac{8}{3} & -\\frac{19}{9} & \\frac{7}{9} & \\frac{22}{9} \\\\\n -\\frac{7}{9} & \\frac{2}{3} & -\\frac{5}{9} & -\\frac{22}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{368}{27} & \\frac{298}{27} & -\\frac{748}{81} & -\\frac{1232}{81} \\\\\n \\frac{412}{27} & -\\frac{1009}{81} & \\frac{893}{81} & \\frac{550}{27} \\\\\n \\frac{785}{81} & -\\frac{211}{27} & \\frac{170}{27} & \\frac{88}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/9), -3, (2/3)],\n [(26/9), (25/9), -(8/3)],\n [(16/9), (7/3), (1/9)]])\nb = np.array([\n [2, -(5/3), (23/9), (22/9)],\n [(8/3), -(19/9), (7/9), (22/9)],\n [-(7/9), (2/3), -(5/9), -(22/9)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -2 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{2} & -3 \\\\\n 0 & -\\frac{5}{2} \\\\\n -2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1, 2]])\nb = np.array([\n [-(5/2), -3],\n [0, -(5/2)],\n [-2, -2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{4}{3} \\\\\n -\\frac{5}{3} \\\\\n \\frac{8}{3} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n \\frac{7}{3} \\\\\n \\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{41}{122},\\frac{287}{366},\\frac{164}{183}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3)],\n [-(5/3)],\n [(8/3)]]).squeeze()\nb = np.array([\n [1],\n [(7/3)],\n [(8/3)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & -6 & 1 \\\\\n 10 & -3 & -8 \\\\\n 9 & -9 & 8 \\\\\n -6 & 6 & 4 \\\\\n -8 & -5 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, -6, 1],\n [10, -3, -8],\n [9, -9, 8],\n [-6, 6, 4],\n [-8, -5, 1]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & -1 \\\\\n \\frac{5}{2} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{13}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1],\n [(5/2), -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, 3, 1}$ to the plane $\\frac{10 x}{3}-\\frac{y}{3}+2 z-\\frac{14}{3}=0$.", - "Output Answer": [ - "$\\frac{19}{\\sqrt{137}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, 3, 1\nplane = Poly(((10*x)/3)-(y/3)+2*z-(14/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{8}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -7 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{35}{8} & -\\frac{15}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -6]])\nprint(a * (5/8))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & 6 \\\\\n 7 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-5-\\sqrt{193}\\right),\\frac{1}{2} \\left(\\sqrt{193}-5\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 6],\n [7, -5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{17}{3} & -\\frac{5}{2} & \\frac{3}{2} \\\\\n -\\frac{4}{3} & \\frac{1}{6} & -\\frac{26}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{15}{2} & -\\frac{31}{6} & -\\frac{23}{3} \\\\\n -\\frac{17}{3} & \\frac{49}{6} & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{79}{6} & \\frac{8}{3} & \\frac{55}{6} \\\\\n \\frac{13}{3} & -8 & -\\frac{17}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/3), -(5/2), (3/2)],\n [-(4/3), (1/6), -(26/3)]])\nb = np.array([\n [-(15/2), -(31/6), -(23/3)],\n [-(17/3), (49/6), -3]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 4 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 8 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{194}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [4],\n [7]])\nb = np.array([\n [6],\n [8],\n [4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 3 & 8 \\\\\n 5 & -4 \\\\\n -1 & -7 \\\\\n 7 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -2 & -10 \\\\\n 7 & 6 \\\\\n 10 & -8 \\\\\n 6 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & -2 \\\\\n 12 & 2 \\\\\n 9 & -15 \\\\\n 13 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 8],\n [5, -4],\n [-1, -7],\n [7, 1]])\nb = np.array([\n [-2, -10],\n [7, 6],\n [10, -8],\n [6, -4]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 1 \\\\\n 2 & -1 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.49 \\\\\n 1.55 \\\\\n -0.57 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.608 \\\\\n -0.334 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1],\n [2, -1],\n [0, 0]])\nb = np.array([\n [1.49],\n [1.55],\n [-0.57]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{16} \\\\\n -\\frac{9}{16} \\\\\n -\\frac{15}{8} \\\\\n -\\frac{31}{16} \\\\\n -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{\\sqrt{1967}} \\\\\n -\\frac{9}{\\sqrt{1967}} \\\\\n -\\frac{30}{\\sqrt{1967}} \\\\\n -\\frac{31}{\\sqrt{1967}} \\\\\n -\\frac{4}{\\sqrt{1967}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/16)],\n [-(9/16)],\n [-(15/8)],\n [-(31/16)],\n [-(1/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [1],\n [1],\n [0],\n [1],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [0],\n [1],\n [0],\n [0],\n [0],\n [1],\n [0],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{3} \\\\\n \\frac{4}{3} \\\\\n \\frac{19}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{74}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/3)],\n [(4/3)],\n [(19/3)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -3-4 i & 3 & 3-2 i \\\\\n -i & 5-3 i & 4+3 i \\\\\n 1+5 i & -3-4 i & -3-i \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 45-189 i & -46+46 i & 177-53 i \\\\\n 163+70 i & -254-308 i & 159-64 i \\\\\n -103+154 i & -80-10 i & -221-110 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3-4j, 3, 3-2j],\n [- 1j, 5-3j, 4+3j],\n [1+5j, -3-4j, -3- 1j]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -5 & -4 & -5 & 0 \\\\\n -7 & -1 & -3 & -9 \\\\\n -9 & -8 & 9 & 2 \\\\\n 5 & 1 & -4 & -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -9 & 5 & -9 & -2 \\\\\n 3 & 1 & 0 & -7 \\\\\n 2 & 0 & -8 & -9 \\\\\n -8 & -10 & 10 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -14 & 1 & -14 & -2 \\\\\n -4 & 0 & -3 & -16 \\\\\n -7 & -8 & 1 & -7 \\\\\n -3 & -9 & 6 & -14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -4, -5, 0],\n [-7, -1, -3, -9],\n [-9, -8, 9, 2],\n [5, 1, -4, -6]])\nb = np.array([\n [-9, 5, -9, -2],\n [3, 1, 0, -7],\n [2, 0, -8, -9],\n [-8, -10, 10, -8]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -4 & -10 & 7 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-5.,0.,0.,4.\\}, \\{-5.,2.,0.,0.\\}, \\{7.,0.,4.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, -10, 7, -5]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{55}{8} \\\\\n -\\frac{41}{8} \\\\\n \\frac{79}{8} \\\\\n \\frac{75}{8} \\\\\n \\frac{5}{8} \\\\\n \\frac{21}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{\\frac{8519}{2}}}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(55/8)],\n [-(41/8)],\n [(79/8)],\n [(75/8)],\n [(5/8)],\n [(21/8)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{2}{3}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & 1 & 6 & 5 \\\\\n 1 & 9 & 6 & -9 \\\\\n 3 & 10 & -2 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{2}{3} & \\frac{2}{3} & 4 & \\frac{10}{3} \\\\\n \\frac{2}{3} & 6 & 4 & -6 \\\\\n 2 & \\frac{20}{3} & -\\frac{4}{3} & -\\frac{20}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, 6, 5],\n [1, 9, 6, -9],\n [3, 10, -2, -10]])\nprint(a * (2/3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 6 \\\\\n -9 \\\\\n -8 \\\\\n 9 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{347}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [6],\n [-9],\n [-8],\n [9],\n [-9]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 2 \\\\\n -8 \\\\\n -4 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [2],\n [-8],\n [-4],\n [-1]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 3 & 0 \\\\\n -2 & -1 \\\\\n -3 & 8 \\\\\n -9 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, 0],\n [-2, -1],\n [-3, 8],\n [-9, 10]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, 3]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -\\frac{5}{3} \\\\\n -\\frac{28}{3} \\\\\n -6 \\\\\n \\frac{19}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{28}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-(5/3)],\n [-(28/3)],\n [-6],\n [(19/3)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 3 & 4 & 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -8 & 5 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -5 & 9 & 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 4, 9]])\nb = np.array([\n [-8, 5, 2]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{16} & -\\frac{3}{2} & 0 \\\\\n -\\frac{11}{8} & -\\frac{25}{16} & \\frac{17}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{39}{16} & \\frac{7}{16} & -\\frac{35}{16} & \\frac{17}{8} \\\\\n -\\frac{1}{2} & -\\frac{39}{16} & \\frac{3}{4} & -\\frac{9}{16} \\\\\n \\frac{13}{8} & \\frac{15}{8} & 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{231}{256} & \\frac{943}{256} & -\\frac{323}{256} & \\frac{125}{128} \\\\\n \\frac{113}{128} & \\frac{1841}{256} & \\frac{235}{128} & \\frac{565}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/16), -(3/2), 0],\n [-(11/8), -(25/16), (17/8)]])\nb = np.array([\n [(39/16), (7/16), -(35/16), (17/8)],\n [-(1/2), -(39/16), (3/4), -(9/16)],\n [(13/8), (15/8), 0, 2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -6 & -9 & -9 & -4 \\\\\n 2 & -2 & 6 & 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -7 & -7 & -9 & -4 \\\\\n -9 & 1 & -2 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -13 & -16 & -18 & -8 \\\\\n -7 & -1 & 4 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -9, -9, -4],\n [2, -2, 6, 7]])\nb = np.array([\n [-7, -7, -9, -4],\n [-9, 1, -2, -3]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{113}{25} \\\\\n -\\frac{19}{25} \\\\\n -\\frac{61}{25} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{49}{50} \\\\\n \\frac{33}{4} \\\\\n -\\frac{377}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{14372}{625} \\\\\n -\\frac{48579}{2500} \\\\\n -\\frac{91363}{2500} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(113/25)],\n [-(19/25)],\n [-(61/25)]])\nb = np.array([\n [(49/50)],\n [(33/4)],\n [-(377/100)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & -7 \\\\\n 5 & -5 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & -1 & 0 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, -1, -7],\n [5, -5, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & -2 & 0 \\\\\n -1 & 3 & 3 \\\\\n 0 & -5 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-38$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2, 0],\n [-1, 3, 3],\n [0, -5, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -2 \\\\\n -1 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{4}{9},-\\frac{4}{9},-\\frac{2}{9},\\frac{2}{3}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [-2],\n [-2],\n [-1],\n [3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{10}{7}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & 9 & -10 \\\\\n -8 & 9 & 7 \\\\\n -2 & -7 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{40}{7} & \\frac{90}{7} & -\\frac{100}{7} \\\\\n -\\frac{80}{7} & \\frac{90}{7} & 10 \\\\\n -\\frac{20}{7} & -10 & \\frac{40}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 9, -10],\n [-8, 9, 7],\n [-2, -7, 4]])\nprint(a * (10/7))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,0,1\\}, \\{0,2,2\\}, \\{1,-3,-1\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{2}{\\sqrt{5}},0,\\frac{1}{\\sqrt{5}}\\right\\}, \\left\\{\\frac{2}{3 \\sqrt{5}},\\frac{\\sqrt{5}}{3},\\frac{4}{3 \\sqrt{5}}\\right\\}, \\left\\{\\frac{1}{3},-\\frac{2}{3},\\frac{2}{3}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, 0, 1), (0, 2, 2), (1, -3, -1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,-5,-1\\}, \\{3,1,-4\\}, \\{-3,3,-5\\}}$.", - "Output Answer": [ - "$y+2 z+7=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, -5, -1],\n [3, 1, -4],\n [-3, 3, -5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, 3}$ to the line $-3 x-y+2=0$.", - "Output Answer": [ - "$4 \\sqrt{\\frac{2}{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, 3\nline = Poly(-3*x-y+2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -4 & 2 & -1 & -3 & 8 \\\\\n -3 & -7 & 9 & 0 & 9 \\\\\n -5 & -1 & 10 & -3 & 9 \\\\\n -4 & 5 & -1 & -9 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{675.,54.,57.,-323.,210.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, 2, -1, -3, 8],\n [-3, -7, 9, 0, 9],\n [-5, -1, 10, -3, 9],\n [-4, 5, -1, -9, -2]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{2} & -\\frac{7}{2} \\\\\n 2 & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{10}{73} & \\frac{14}{73} \\\\\n -\\frac{8}{73} & -\\frac{18}{73} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2), -(7/2)],\n [2, -(5/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & 4 & -2 \\\\\n 4 & 5 & 1 \\\\\n -3 & 6 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-2.891,7.445\\, -0.781 i,7.445\\, +0.781 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 4, -2],\n [4, 5, 1],\n [-3, 6, 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 5 & 7 & 4 & 4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 9 & 7 & -6 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -4 & 0 & 10 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 7, 4, 4]])\nb = np.array([\n [9, 7, -6, 3]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{2} & \\frac{19}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -4 & -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{17}{2} & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2), (19/2)]])\nb = np.array([\n [-4, -(15/2)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 4 \\\\\n -1 \\\\\n 4 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 10 \\\\\n -1 \\\\\n -3 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$57$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [4],\n [-1],\n [4],\n [8]])\nb = np.array([\n [-2],\n [10],\n [-1],\n [-3],\n [4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{2} \\\\\n -\\frac{3}{4} \\\\\n \\frac{17}{2} \\\\\n -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{2} \\\\\n -\\frac{9}{2} \\\\\n -4 \\\\\n -\\frac{7}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{91 \\sqrt{\\frac{3}{15070}}}{5}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2)],\n [-(3/4)],\n [(17/2)],\n [-(3/4)]]).squeeze()\nb = np.array([\n [-(7/2)],\n [-(9/2)],\n [-4],\n [-(7/4)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{28}{3} & -\\frac{67}{9} \\\\\n \\frac{4}{3} & \\frac{29}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-19 x+\\frac{2704}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(28/3), -(67/9)],\n [(4/3), (29/3)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -5 & -6 & -2 & -5 & 9 & 3 \\\\\n 0 & 3 & 10 & -10 & 1 & 6 \\\\\n -9 & 7 & 10 & 8 & -7 & -7 \\\\\n 9 & -2 & 8 & -4 & 9 & 5 \\\\\n -10 & -10 & -3 & -6 & -1 & -7 \\\\\n 0 & 8 & -7 & 7 & -4 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, -6, -2, -5, 9, 3],\n [0, 3, 10, -10, 1, 6],\n [-9, 7, 10, 8, -7, -7],\n [9, -2, 8, -4, 9, 5],\n [-10, -10, -3, -6, -1, -7],\n [0, 8, -7, 7, -4, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & -\\frac{20}{3} & \\frac{1}{3} \\\\\n \\frac{20}{3} & -7 & \\frac{25}{3} \\\\\n 5 & -\\frac{28}{3} & \\frac{10}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-0.916,-0.875-9.549 i,-0.875+9.549 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(20/3), (1/3)],\n [(20/3), -7, (25/3)],\n [5, -(28/3), (10/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{3} & \\frac{2}{3} & -9 \\\\\n \\frac{11}{3} & -\\frac{10}{3} & -\\frac{29}{3} \\\\\n -\\frac{14}{3} & \\frac{29}{3} & -\\frac{10}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{2.104,0.272,1.\\}, \\{-0.381-0.814 i,0.033\\, -1.287 i,1.\\}, \\{-0.381+0.814 i,0.033\\, +1.287 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/3), (2/3), -9],\n [(11/3), -(10/3), -(29/3)],\n [-(14/3), (29/3), -(10/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & 1 & 1 & 2 \\\\\n 1 & 3 & 3 & -1 \\\\\n -2 & 3 & -3 & -2 \\\\\n 0 & 3 & -3 & 1 \\\\\n 3 & 1 & 0 & 3 \\\\\n 1 & 0 & -1 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.78 \\\\\n -2.64 \\\\\n -0.5 \\\\\n 1.08 \\\\\n -0.97 \\\\\n 1.28 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.122 \\\\\n -0.425 \\\\\n -0.54 \\\\\n -0.086 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 1, 2],\n [1, 3, 3, -1],\n [-2, 3, -3, -2],\n [0, 3, -3, 1],\n [3, 1, 0, 3],\n [1, 0, -1, -3]])\nb = np.array([\n [-0.78],\n [-2.64],\n [-0.5],\n [1.08],\n [-0.97],\n [1.28]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n 7 & 3 & 3 & -8 & 3 \\\\\n -8 & 1 & 4 & 9 & -4 \\\\\n -6 & 3 & 7 & -1 & -1 \\\\\n -1 & 1 & -1 & 5 & -6 \\\\\n -7 & 5 & -2 & 5 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 3, 3, -8, 3],\n [-8, 1, 4, 9, -4],\n [-6, 3, 7, -1, -1],\n [-1, 1, -1, 5, -6],\n [-7, 5, -2, 5, -2]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 3 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -8 \\\\\n 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -48 \\\\\n 54 \\\\\n 107 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [3],\n [-6]])\nb = np.array([\n [-9],\n [-8],\n [0]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{5} & -\\frac{38}{5} & \\frac{24}{5} \\\\\n \\frac{37}{5} & \\frac{48}{5} & -\\frac{11}{5} \\\\\n -\\frac{4}{5} & 8 & \\frac{47}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{4.444\\, -8.023 i,4.444\\, +8.023 i,10.712\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/5), -(38/5), (24/5)],\n [(37/5), (48/5), -(11/5)],\n [-(4/5), 8, (47/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n \\frac{41}{8} & -\\frac{27}{8} & -\\frac{39}{8} & -7 \\\\\n -\\frac{21}{4} & 2 & -\\frac{21}{4} & -1 \\\\\n -\\frac{59}{8} & -\\frac{35}{8} & -\\frac{57}{8} & \\frac{13}{8} \\\\\n 0 & -3 & -\\frac{55}{8} & -\\frac{7}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(41/8), -(27/8), -(39/8), -7],\n [-(21/4), 2, -(21/4), -1],\n [-(59/8), -(35/8), -(57/8), (13/8)],\n [0, -3, -(55/8), -(7/8)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{5} \\\\\n -\\frac{11}{5} \\\\\n -\\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{13}{\\sqrt{354}} \\\\\n -\\frac{11}{\\sqrt{354}} \\\\\n -4 \\sqrt{\\frac{2}{177}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/5)],\n [-(11/5)],\n [-(8/5)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{2}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 8 & 8 \\\\\n 3 & 6 \\\\\n 2 & 5 \\\\\n -10 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -12 & -12 \\\\\n -\\frac{9}{2} & -9 \\\\\n -3 & -\\frac{15}{2} \\\\\n 15 & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 8],\n [3, 6],\n [2, 5],\n [-10, 4]])\nprint(a * -(3/2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{987}{100} & \\frac{417}{100} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{661}{100} & \\frac{297}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{163}{50} & \\frac{6}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(987/100), (417/100)]])\nb = np.array([\n [-(661/100), (297/100)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{7} \\\\\n 10 \\\\\n \\frac{29}{7} \\\\\n -\\frac{46}{7} \\\\\n \\frac{59}{7} \\\\\n \\frac{4}{7} \\\\\n -\\frac{24}{7} \\\\\n -\\frac{24}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/7)],\n [10],\n [(29/7)],\n [-(46/7)],\n [(59/7)],\n [(4/7)],\n [-(24/7)],\n [-(24/7)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{13}{3} & -\\frac{2}{3} \\\\\n -\\frac{7}{3} & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{4}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/3), -(2/3)],\n [-(7/3), (2/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -5 & 8 & -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 4 & 8 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & 16 & -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 8, -5]])\nb = np.array([\n [4, 8, -7]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{2}{9}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & 5 & -9 & 5 \\\\\n -10 & -7 & 2 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{2}{9} & \\frac{10}{9} & -2 & \\frac{10}{9} \\\\\n -\\frac{20}{9} & -\\frac{14}{9} & \\frac{4}{9} & -\\frac{8}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 5, -9, 5],\n [-10, -7, 2, -4]])\nprint(a * (2/9))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 4 & -1 & 9 & 8 \\\\\n -5 & -5 & -9 & 3 \\\\\n 1 & 4 & -10 & 0 \\\\\n 1 & -7 & -7 & -3 \\\\\n 1 & -1 & -9 & -1 \\\\\n -10 & 0 & 10 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, -1, 9, 8],\n [-5, -5, -9, 3],\n [1, 4, -10, 0],\n [1, -7, -7, -3],\n [1, -1, -9, -1],\n [-10, 0, 10, 1]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -9 & -2 & 4 \\\\\n -9 & 1 & 1 \\\\\n 3 & -10 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-9 x^2+21 x+279$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -2, 4],\n [-9, 1, 1],\n [3, -10, -1]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 4 & -3 & -8 \\\\\n -10 & 10 & -1 \\\\\n -4 & 9 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+18 x^2-43 x+464$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -3, -8],\n [-10, 10, -1],\n [-4, 9, 4]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -3 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -9 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -93 \\\\\n -109 \\\\\n -36 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-3],\n [-9]])\nb = np.array([\n [9],\n [-9],\n [4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n \\frac{2}{5} & -\\frac{14}{5} & -\\frac{2}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{7}{5} & 1 & -\\frac{7}{5} & \\frac{3}{5} \\\\\n \\frac{2}{5} & -\\frac{12}{5} & \\frac{6}{5} & \\frac{13}{5} \\\\\n -\\frac{1}{5} & \\frac{3}{5} & \\frac{9}{5} & \\frac{12}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{12}{25} & \\frac{172}{25} & -\\frac{116}{25} & -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/5), -(14/5), -(2/5)]])\nb = np.array([\n [(7/5), 1, -(7/5), (3/5)],\n [(2/5), -(12/5), (6/5), (13/5)],\n [-(1/5), (3/5), (9/5), (12/5)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 0 & 2 & -2 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -2 & 0 & -2 \\\\\n 0 & 1 & 2 \\\\\n -2 & -3 & 1 \\\\\n 0 & 3 & 2 \\\\\n 0 & 2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 4 & 9 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, -2, -1, 2]])\nb = np.array([\n [-2, 0, -2],\n [0, 1, 2],\n [-2, -3, 1],\n [0, 3, 2],\n [0, 2, 1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n \\frac{33}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{3}{7} \\\\\n -\\frac{2}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{87}{49}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [(33/7)]])\nb = np.array([\n [(3/7)],\n [-(2/7)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1}{\\sqrt{6}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [1],\n [1],\n [0]]).squeeze()\nb = np.array([\n [0],\n [-1],\n [0],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{77}{9} & -\\frac{61}{9} \\\\\n \\frac{19}{3} & \\frac{23}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{22}{3} & -\\frac{28}{9} \\\\\n \\frac{34}{9} & -\\frac{32}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{143}{9} & -\\frac{89}{9} \\\\\n \\frac{91}{9} & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(77/9), -(61/9)],\n [(19/3), (23/9)]])\nb = np.array([\n [-(22/3), -(28/9)],\n [(34/9), -(32/9)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{9}{8}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -5 & 8 & -5 \\\\\n 9 & -3 & 10 \\\\\n -2 & -6 & -3 \\\\\n 10 & 9 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{45}{8} & -9 & \\frac{45}{8} \\\\\n -\\frac{81}{8} & \\frac{27}{8} & -\\frac{45}{4} \\\\\n \\frac{9}{4} & \\frac{27}{4} & \\frac{27}{8} \\\\\n -\\frac{45}{4} & -\\frac{81}{8} & \\frac{63}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 8, -5],\n [9, -3, 10],\n [-2, -6, -3],\n [10, 9, -7]])\nprint(a * -(9/8))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 1 & -3 & -1 & -2 & 2 \\\\\n 3 & 2 & 0 & 0 & -1 \\\\\n 1 & 3 & 0 & -1 & 1 \\\\\n -3 & 1 & -2 & -2 & 0 \\\\\n 2 & 0 & 0 & 3 & 1 \\\\\n -3 & 1 & -2 & -2 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.11 \\\\\n -2.96 \\\\\n -2.03 \\\\\n -1. \\\\\n 1.47 \\\\\n 0.19 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.331 \\\\\n -0.638 \\\\\n -0.1 \\\\\n 0.479 \\\\\n 0.693 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3, -1, -2, 2],\n [3, 2, 0, 0, -1],\n [1, 3, 0, -1, 1],\n [-3, 1, -2, -2, 0],\n [2, 0, 0, 3, 1],\n [-3, 1, -2, -2, 0]])\nb = np.array([\n [2.11],\n [-2.96],\n [-2.03],\n [-1.],\n [1.47],\n [0.19]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{18}{5} & \\frac{81}{10} \\\\\n -\\frac{41}{10} & \\frac{57}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{93 x}{10}+\\frac{5373}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(18/5), (81/10)],\n [-(41/10), (57/10)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9.7 \\\\\n 4.8 \\\\\n 6.4 \\\\\n -4.7 \\\\\n -8.4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0.6 \\\\\n -10. \\\\\n 4.9 \\\\\n -7.9 \\\\\n -4.8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$66.63$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9.7],\n [4.8],\n [6.4],\n [-4.7],\n [-8.4]])\nb = np.array([\n [0.6],\n [-10.],\n [4.9],\n [-7.9],\n [-4.8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -3 \\pi \\\\\n -2 \\pi \\\\\n -\\pi \\\\\n 2 \\pi \\\\\n -3 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\pi \\\\\n -\\pi \\\\\n \\pi \\\\\n 2 \\pi \\\\\n \\pi \\\\\n -2 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7 \\pi ^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [-3*math.pi],\n [-2*math.pi],\n [-math.pi],\n [2*math.pi],\n [-3*math.pi]])\nb = np.array([\n [-2*math.pi],\n [-math.pi],\n [math.pi],\n [2*math.pi],\n [math.pi],\n [-2*math.pi]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -7 \\\\\n 8 \\\\\n -6 \\\\\n 1 \\\\\n -3 \\\\\n -10 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 7 \\\\\n 2 \\\\\n -3 \\\\\n 8 \\\\\n -6 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$38$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-7],\n [8],\n [-6],\n [1],\n [-3],\n [-10],\n [-6]])\nb = np.array([\n [-1],\n [-1],\n [7],\n [2],\n [-3],\n [8],\n [-6],\n [7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{2} & \\frac{11}{2} & -\\frac{11}{4} \\\\\n 6 & -\\frac{17}{2} & 3 \\\\\n 2 & -\\frac{21}{4} & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-10.819-2.281 i,-10.819+2.281 i,-3.362\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/2), (11/2), -(11/4)],\n [6, -(17/2), 3],\n [2, -(21/4), -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-2$ and the matrix\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -10 \\\\\n 2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-1],\n [0]])\nprint(a * -2)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n 8 & -\\frac{21}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -(21/4)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 1 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -9 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -41 \\\\\n 43 \\\\\n -20 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [1],\n [-4]])\nb = np.array([\n [-7],\n [-9],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{27}{5} & 1 \\\\\n \\frac{34}{5} & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(-17-\\sqrt{2049}\\right),\\frac{1}{10} \\left(\\sqrt{2049}-17\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(27/5), 1],\n [(34/5), 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -2 & -3 \\\\\n -2 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{5}{4} & \\frac{3}{4} \\\\\n \\frac{1}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3],\n [-2, -5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n \\frac{68}{7} \\\\\n \\frac{34}{7} \\\\\n -\\frac{18}{7} \\\\\n \\frac{15}{7} \\\\\n \\frac{47}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(68/7)],\n [(34/7)],\n [-(18/7)],\n [(15/7)],\n [(47/7)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 5 & \\frac{1}{3} \\\\\n \\frac{7}{3} & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{14}{3},\\frac{22}{3}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, (1/3)],\n [(7/3), 7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & 4 \\\\\n 10 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-1-\\sqrt{385}\\right),\\frac{1}{2} \\left(\\sqrt{385}-1\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 4],\n [10, -8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & 5 \\\\\n -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 5],\n [-1, 2]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 9 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -48 \\\\\n -40 \\\\\n 57 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [9],\n [8]])\nb = np.array([\n [-7],\n [-3],\n [-8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{16}{9} & \\frac{35}{9} \\\\\n -\\frac{31}{9} & -\\frac{32}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{288}{1597} & -\\frac{315}{1597} \\\\\n \\frac{279}{1597} & -\\frac{144}{1597} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(16/9), (35/9)],\n [-(31/9), -(32/9)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & 1 & 0 & 1 \\\\\n 0 & 0 & -3 & 3 \\\\\n -3 & 1 & 3 & -2 \\\\\n -2 & 0 & -1 & 2 \\\\\n 2 & -3 & 3 & 2 \\\\\n 3 & -1 & 2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.41 \\\\\n 1.23 \\\\\n 1.5 \\\\\n -2.21 \\\\\n -1.14 \\\\\n -1.36 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.12 \\\\\n 0.289 \\\\\n -0.062 \\\\\n -0.118 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1, 0, 1],\n [0, 0, -3, 3],\n [-3, 1, 3, -2],\n [-2, 0, -1, 2],\n [2, -3, 3, 2],\n [3, -1, 2, -2]])\nb = np.array([\n [-0.41],\n [1.23],\n [1.5],\n [-2.21],\n [-1.14],\n [-1.36]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${5, 5}$ to the line $-2 x-2 y+4=0$.", - "Output Answer": [ - "$4 \\sqrt{2}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 5, 5\nline = Poly(-2*x-2*y+4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{13}{5}, \\frac{7}{5}, -\\frac{12}{5}}$ to the plane $-\\frac{8 x}{5}+2 y+\\frac{9 z}{5}+\\frac{6}{5}=0$.", - "Output Answer": [ - "$\\frac{16}{5 \\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (13/5), (7/5), -(12/5)\nplane = Poly(-((8*x)/5)+2*y+((9*z)/5)+(6/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n \\frac{9}{2} \\\\\n \\frac{5}{2} \\\\\n \\frac{17}{2} \\\\\n -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{17}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [(9/2)],\n [(5/2)],\n [(17/2)],\n [-(9/2)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -2 & -5 & 10 & 1 & 0 \\\\\n 6 & 7 & -4 & -4 & 4 \\\\\n -3 & 0 & 3 & 2 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -5, 10, 1, 0],\n [6, 7, -4, -4, 4],\n [-3, 0, 3, 2, 9]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n \\frac{76}{9} & -\\frac{44}{9} & \\frac{10}{9} & -\\frac{46}{9} & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(76/9), -(44/9), (10/9), -(46/9), -2]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{8}{5}, \\frac{29}{10}}$ to the line $\\frac{22 x}{5}+\\frac{23 y}{5}+\\frac{9}{10}=0$.", - "Output Answer": [ - "$\\frac{532}{5 \\sqrt{1013}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (8/5), (29/10)\nline = Poly(((22*x)/5)+((23*y)/5)+(9/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{13}{2} & -\\frac{5}{2} \\\\\n -\\frac{35}{4} & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{11 x}{2}-\\frac{227}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2), -(5/2)],\n [-(35/4), -1]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{68}{9} & \\frac{64}{9} & -\\frac{80}{9} \\\\\n \\frac{77}{9} & \\frac{14}{3} & \\frac{5}{9} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{9} & -\\frac{71}{9} & 9 \\\\\n \\frac{32}{9} & -3 & -\\frac{62}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{49}{9} & 15 & -\\frac{161}{9} \\\\\n 5 & \\frac{23}{3} & \\frac{67}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(68/9), (64/9), -(80/9)],\n [(77/9), (14/3), (5/9)]])\nb = np.array([\n [-(19/9), -(71/9), 9],\n [(32/9), -3, -(62/9)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & -4 & 4 \\\\\n \\frac{1}{2} & -2 & -\\frac{7}{2} \\\\\n 3 & \\frac{1}{2} & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{451}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), -4, 4],\n [(1/2), -2, -(7/2)],\n [3, (1/2), 5]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 5 \\\\\n -1 \\\\\n -4 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 0 \\\\\n -4 \\\\\n 10 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8 \\sqrt{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [5],\n [-1],\n [-4],\n [-6]])\nb = np.array([\n [2],\n [0],\n [-4],\n [10],\n [-3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{2,\\frac{8}{3},\\frac{8}{3}\\right\\}, \\left\\{\\frac{8}{3},\\frac{7}{3},-2\\right\\}, \\left\\{-\\frac{8}{3},-\\frac{1}{3},-\\frac{7}{3}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{3}{\\sqrt{41}},\\frac{4}{\\sqrt{41}},\\frac{4}{\\sqrt{41}}\\right\\}, \\left\\{\\frac{244}{5 \\sqrt{8733}},\\frac{35}{\\sqrt{8733}},-\\frac{358}{5 \\sqrt{8733}}\\right\\}, \\left\\{-\\frac{52}{5 \\sqrt{213}},\\frac{10}{\\sqrt{213}},-\\frac{11}{5 \\sqrt{213}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, (8/3), (8/3)), ((8/3), (7/3), -2), (-(8/3), -(1/3), -(7/3))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & 3 & 0 & 0 \\\\\n 2 & 3 & -2 & -2 \\\\\n 0 & 2 & -2 & -1 \\\\\n 2 & 2 & 3 & 2 \\\\\n -1 & -2 & 2 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.66 \\\\\n 1.56 \\\\\n 2.57 \\\\\n 1.03 \\\\\n -1.25 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.308 \\\\\n 0.842 \\\\\n -0.531 \\\\\n 0.73 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, 0, 0],\n [2, 3, -2, -2],\n [0, 2, -2, -1],\n [2, 2, 3, 2],\n [-1, -2, 2, 1]])\nb = np.array([\n [2.66],\n [1.56],\n [2.57],\n [1.03],\n [-1.25]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -4 & 0 \\\\\n 4 & -4 & 2 \\\\\n -3 & 3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$90$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -4, 0],\n [4, -4, 2],\n [-3, 3, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 4 \\\\\n -10 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2,5\\}, \\{-1,1\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 4],\n [-10, -6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 7 \\\\\n 3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -4 \\\\\n 7 \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -12 \\\\\n 3 \\\\\n 10 \\\\\n 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [7],\n [3],\n [2]])\nb = np.array([\n [-2],\n [-4],\n [7],\n [2]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & -3 & 3 & -1 \\\\\n 1 & -1 & 0 & 2 \\\\\n -1 & -3 & -3 & -1 \\\\\n 0 & -2 & 2 & -2 \\\\\n 3 & 2 & -1 & -2 \\\\\n 3 & 3 & 3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.71 \\\\\n 0.71 \\\\\n -0.77 \\\\\n -1.49 \\\\\n 0.51 \\\\\n 1.25 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.136 \\\\\n 0.061 \\\\\n 0.308 \\\\\n 0.162 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3, 3, -1],\n [1, -1, 0, 2],\n [-1, -3, -3, -1],\n [0, -2, 2, -2],\n [3, 2, -1, -2],\n [3, 3, 3, 2]])\nb = np.array([\n [2.71],\n [0.71],\n [-0.77],\n [-1.49],\n [0.51],\n [1.25]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & -7 \\\\\n 0 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-3,2\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -7],\n [0, -3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{25}{9} \\\\\n -\\frac{4}{3} \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{59}{9} \\\\\n \\frac{56}{9} \\\\\n -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{64}{9} \\\\\n \\frac{227}{27} \\\\\n \\frac{692}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(25/9)],\n [-(4/3)],\n [-1]])\nb = np.array([\n [-(59/9)],\n [(56/9)],\n [-(2/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{4}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 10 \\\\\n 7 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{3}{4} & \\frac{5}{2} \\\\\n \\frac{7}{4} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 10],\n [7, -2]])\nprint(a * (1/4))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [1],\n [0],\n [0],\n [-1],\n [-1],\n [-1],\n [0]]).squeeze()\nb = np.array([\n [1],\n [1],\n [1],\n [1],\n [1],\n [0],\n [1],\n [0],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 2 \\\\\n 3 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{1}{2 \\sqrt{6}} \\\\\n \\frac{1}{2 \\sqrt{6}} \\\\\n \\frac{1}{\\sqrt{6}} \\\\\n \\frac{\\sqrt{\\frac{3}{2}}}{2} \\\\\n -\\frac{\\sqrt{\\frac{3}{2}}}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [1],\n [2],\n [3],\n [-3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 0 & 5 & -2 & -1 \\\\\n -4 & -4 & -6 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & \\frac{19}{10} & -\\frac{3}{10} \\\\\n 0 & 1 & -\\frac{2}{5} & -\\frac{1}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, 5, -2, -1],\n [-4, -4, -6, 2]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{12}{5} \\\\\n -\\frac{11}{5} \\\\\n \\frac{46}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{69}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(12/5)],\n [-(11/5)],\n [(46/5)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\sqrt{\\frac{3}{5}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [1],\n [-1],\n [-1]]).squeeze()\nb = np.array([\n [0],\n [1],\n [0],\n [-1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n 1 & -\\frac{1}{2} & -9 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(1/2), -9, 4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{31}{5} & 9 \\\\\n \\frac{17}{5} & -\\frac{38}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{34} \\left(7-\\sqrt{3109}\\right),1\\right\\}, \\left\\{\\frac{1}{34} \\left(7+\\sqrt{3109}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(31/5), 9],\n [(17/5), -(38/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -9 & \\frac{2}{3} & -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -3 & -\\frac{10}{3} & -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -12 & -\\frac{8}{3} & -\\frac{22}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, (2/3), -(14/3)]])\nb = np.array([\n [-3, -(10/3), -(8/3)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2.7 \\\\\n 2.2 \\\\\n -2.9 \\\\\n 8.8 \\\\\n -2. \\\\\n -0.1 \\\\\n -9.9 \\\\\n 7.6 \\\\\n -2.6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6.6 \\\\\n -6.2 \\\\\n 4.9 \\\\\n -8.1 \\\\\n -2.7 \\\\\n -4.5 \\\\\n 8.8 \\\\\n -8.9 \\\\\n -3.6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$32.7873$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2.7],\n [2.2],\n [-2.9],\n [8.8],\n [-2.],\n [-0.1],\n [-9.9],\n [7.6],\n [-2.6]])\nb = np.array([\n [6.6],\n [-6.2],\n [4.9],\n [-8.1],\n [-2.7],\n [-4.5],\n [8.8],\n [-8.9],\n [-3.6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -9 & -6 \\\\\n 3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-9, -6],\n [3, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 0 \\\\\n -3 \\\\\n 3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2}{\\sqrt{23}} \\\\\n 0 \\\\\n -\\frac{3}{\\sqrt{23}} \\\\\n \\frac{3}{\\sqrt{23}} \\\\\n \\frac{1}{\\sqrt{23}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [0],\n [-3],\n [3],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,1,-2\\}, \\{3,0,-1\\}, \\{-3,5,-4\\}}$.", - "Output Answer": [ - "$x-6 y-12 z-15=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, 1, -2],\n [3, 0, -1],\n [-3, 5, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-2$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -7 & 5 \\\\\n -7 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 14 & -10 \\\\\n 14 & -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 5],\n [-7, 4]])\nprint(a * -2)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -\\frac{11}{10} & -\\frac{91}{10} & \\frac{11}{10} & -\\frac{13}{10} \\\\\n \\frac{46}{5} & \\frac{12}{5} & -\\frac{32}{5} & -\\frac{3}{10} \\\\\n \\frac{9}{5} & \\frac{13}{2} & \\frac{7}{2} & \\frac{67}{10} \\\\\n -\\frac{17}{2} & \\frac{4}{5} & -\\frac{11}{5} & \\frac{23}{10} \\\\\n -7 & \\frac{22}{5} & -\\frac{42}{5} & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/10), -(91/10), (11/10), -(13/10)],\n [(46/5), (12/5), -(32/5), -(3/10)],\n [(9/5), (13/2), (7/2), (67/10)],\n [-(17/2), (4/5), -(11/5), (23/10)],\n [-7, (22/5), -(42/5), -10]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{6} \\\\\n -\\frac{11}{6} \\\\\n -\\frac{1}{6} \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{\\sqrt{7}}{6} \\\\\n -\\frac{11}{6 \\sqrt{7}} \\\\\n -\\frac{1}{6 \\sqrt{7}} \\\\\n -\\frac{3}{2 \\sqrt{7}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/6)],\n [-(11/6)],\n [-(1/6)],\n [-(3/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & -6 & 8 \\\\\n -3 & -3 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{10.,11.,7.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [1, -6, 8],\n [-3, -3, 9]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 0 & -1 & -1 & -2 & 2 \\\\\n 0 & -3 & 0 & -2 & 3 \\\\\n 2 & -1 & 2 & 1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 0 & 2 & -1 & 0 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, 0]])\nb = np.array([\n [0, -1, -1, -2, 2],\n [0, -3, 0, -2, 3],\n [2, -1, 2, 1, 1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -4 & 6 & 2 & 2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -8 & -8 & -4 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 4 & 14 & 6 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 6, 2, 2]])\nb = np.array([\n [-8, -8, -4, -1]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n 0 \\\\\n -\\frac{1}{2} \\\\\n \\frac{1}{2} \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [-1],\n [1],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & 0 \\\\\n 3 & 3 \\\\\n 0 & -2 \\\\\n -3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.25 \\\\\n -0.87 \\\\\n 2.78 \\\\\n -2.95 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.499 \\\\\n -0.916 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0],\n [3, 3],\n [0, -2],\n [-3, 2]])\nb = np.array([\n [-0.25],\n [-0.87],\n [2.78],\n [-2.95]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -6 \\\\\n -6 \\\\\n 8 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -9 \\\\\n 6 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$27$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-6],\n [-6],\n [8],\n [3]])\nb = np.array([\n [1],\n [-9],\n [6],\n [1],\n [1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{21}{5} \\\\\n -\\frac{16}{5} \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{48}{5} \\\\\n -9 \\\\\n -\\frac{47}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{77}{25} \\\\\n -\\frac{1707}{25} \\\\\n \\frac{1713}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(21/5)],\n [-(16/5)],\n [-3]])\nb = np.array([\n [(48/5)],\n [-9],\n [-(47/5)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-2,-\\frac{13}{3},-\\frac{11}{3}\\right\\}, \\left\\{-\\frac{8}{3},-\\frac{13}{3},3\\right\\}, \\left\\{-\\frac{14}{3},-\\frac{7}{3},-1\\right\\}}$.", - "Output Answer": [ - "$30 x+36 y+3 z+227=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, -(13/3), -(11/3)],\n [-(8/3), -(13/3), 3],\n [-(14/3), -(7/3), -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -\\frac{1}{6} \\\\\n \\frac{1}{3} \\\\\n \\frac{5}{3} \\\\\n \\frac{7}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -6 \\sqrt{\\frac{2}{149}} \\\\\n -\\frac{1}{\\sqrt{298}} \\\\\n \\sqrt{\\frac{2}{149}} \\\\\n 5 \\sqrt{\\frac{2}{149}} \\\\\n \\frac{7}{\\sqrt{298}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-(1/6)],\n [(1/3)],\n [(5/3)],\n [(7/6)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & 0 & -1 \\\\\n 2 & -1 & -2 \\\\\n -1 & 1 & -1 \\\\\n 1 & 3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.74 \\\\\n -2.46 \\\\\n 2.82 \\\\\n -1.93 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.102 \\\\\n 0.663 \\\\\n 0.975 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, -1],\n [2, -1, -2],\n [-1, 1, -1],\n [1, 3, -3]])\nb = np.array([\n [-1.74],\n [-2.46],\n [2.82],\n [-1.93]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 3 & 7 \\\\\n -2 & -7 \\\\\n 10 & -3 \\\\\n 10 & -5 \\\\\n -4 & 10 \\\\\n -5 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, 7],\n [-2, -7],\n [10, -3],\n [10, -5],\n [-4, 10],\n [-5, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{7}{5},-\\frac{14}{5}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-2]]).squeeze()\nb = np.array([\n [-1],\n [-2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 8 & \\frac{41}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 7 & -\\frac{4}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 15 & \\frac{37}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, (41/5)]])\nb = np.array([\n [7, -(4/5)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n -2 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 \\\\\n -6 \\\\\n -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [-2],\n [-3]])\nb = np.array([\n [3]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 9 & -9 & 9 \\\\\n -4 & -9 & -4 \\\\\n -5 & 5 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.353,0.349,1.\\}, \\{-1.435,-2.008,1.\\}, \\{-0.812,-0.14,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -9, 9],\n [-4, -9, -4],\n [-5, 5, -7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 1 \\\\\n -8 \\\\\n 5 \\\\\n 10 \\\\\n -1 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -5 \\\\\n -7 \\\\\n 5 \\\\\n -3 \\\\\n -4 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$18$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [1],\n [-8],\n [5],\n [10],\n [-1],\n [-4]])\nb = np.array([\n [-1],\n [-5],\n [-7],\n [5],\n [-3],\n [-4],\n [-7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{2}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & -3 & 1 \\\\\n -2 & -2 & 3 \\\\\n 7 & 2 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & \\frac{3}{2} & -\\frac{1}{2} \\\\\n 1 & 1 & -\\frac{3}{2} \\\\\n -\\frac{7}{2} & -1 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3, 1],\n [-2, -2, 3],\n [7, 2, 10]])\nprint(a * -(1/2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 3 & 1 \\\\\n -2 & 2 \\\\\n 2 & -2 \\\\\n 2 & 0 \\\\\n -2 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 3 & 2 & 0 & -1 \\\\\n -3 & 0 & 3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 6 & 6 & 3 & -5 \\\\\n -12 & -4 & 6 & -2 \\\\\n 12 & 4 & -6 & 2 \\\\\n 6 & 4 & 0 & -2 \\\\\n 0 & -4 & -6 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1],\n [-2, 2],\n [2, -2],\n [2, 0],\n [-2, -2]])\nb = np.array([\n [3, 2, 0, -1],\n [-3, 0, 3, -2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{4} & -\\frac{3}{2} \\\\\n -\\frac{17}{4} & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{34} \\left(37-\\sqrt{1777}\\right),1\\right\\}, \\left\\{\\frac{1}{34} \\left(37+\\sqrt{1777}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/4), -(3/2)],\n [-(17/4), 8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 0 & -1 & -3 & -2 & 1 \\\\\n 0 & 3 & 3 & -1 & -1 \\\\\n -2 & 3 & 2 & -2 & 2 \\\\\n -2 & -2 & 2 & 2 & 2 \\\\\n -2 & -1 & 1 & -1 & -3 \\\\\n 0 & 1 & 2 & -2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.02 \\\\\n 0.9 \\\\\n -1.41 \\\\\n -0.25 \\\\\n -2.36 \\\\\n 2.97 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2.348 \\\\\n -1.632 \\\\\n 1.472 \\\\\n -1.824 \\\\\n 0.883 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -1, -3, -2, 1],\n [0, 3, 3, -1, -1],\n [-2, 3, 2, -2, 2],\n [-2, -2, 2, 2, 2],\n [-2, -1, 1, -1, -3],\n [0, 1, 2, -2, -2]])\nb = np.array([\n [2.02],\n [0.9],\n [-1.41],\n [-0.25],\n [-2.36],\n [2.97]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 5 & \\frac{3}{5} \\\\\n \\frac{11}{5} & \\frac{21}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{492}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, (3/5)],\n [(11/5), (21/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{1}{2},-\\frac{9}{2},0\\right\\}, \\left\\{-\\frac{9}{2},1,\\frac{5}{2}\\right\\}, \\{4,3,3\\}}$.", - "Output Answer": [ - "$9 x-95 y+227 z-432=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(1/2), -(9/2), 0],\n [-(9/2), 1, (5/2)],\n [4, 3, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6.3 \\\\\n 0.2 \\\\\n -3.2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4.7 \\\\\n -4.4 \\\\\n 0.7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$12.5447$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6.3],\n [0.2],\n [-3.2]])\nb = np.array([\n [-4.7],\n [-4.4],\n [0.7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 6 \\\\\n 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-3]])\nb = np.array([\n [-2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -3 & -4 \\\\\n -7 & -4 \\\\\n -5 & 4 \\\\\n 6 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -4],\n [-7, -4],\n [-5, 4],\n [6, 3]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & 5 & -6 \\\\\n -2 & -3 & 9 \\\\\n -4 & 3 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.191,0.639,1.\\}, \\{3.177,-0.829,1.\\}, \\{4.086,1.618,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 5, -6],\n [-2, -3, 9],\n [-4, 3, 9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -10 & 3 & 0 \\\\\n 5 & 4 & 8 \\\\\n -2 & -1 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{11.773,-4.421,1.\\}, \\{0.142\\, -0.393 i,1.153\\, -2.037 i,1.\\}, \\{0.142\\, +0.393 i,1.153\\, +2.037 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 3, 0],\n [5, 4, 8],\n [-2, -1, 8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{3} \\\\\n 3 \\\\\n -\\frac{11}{3} \\\\\n \\frac{1}{3} \\\\\n \\frac{26}{3} \\\\\n \\frac{29}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{83}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/3)],\n [3],\n [-(11/3)],\n [(1/3)],\n [(26/3)],\n [(29/3)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -10 & 7 \\\\\n 2 & 4 \\\\\n 3 & -2 \\\\\n -3 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, 7],\n [2, 4],\n [3, -2],\n [-3, 7]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -1 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{2} \\\\\n \\frac{9}{2} \\\\\n \\frac{7}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 28 \\\\\n \\frac{105}{2} \\\\\n -\\frac{31}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-1],\n [-7]])\nb = np.array([\n [-(13/2)],\n [(9/2)],\n [(7/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n -42 & -35 & -31 & 55 \\\\\n -47 & -40 & -38 & 61 \\\\\n -28 & -23 & -22 & 36 \\\\\n -80 & -67 & -62 & 104 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{229}{2} & -96 & -\\frac{177}{2} & 150 \\\\\n -36 & -\\frac{89}{3} & -\\frac{173}{6} & \\frac{281}{6} \\\\\n -\\frac{55}{2} & -\\frac{68}{3} & -\\frac{125}{6} & \\frac{106}{3} \\\\\n -\\frac{259}{2} & -108 & -\\frac{201}{2} & 169 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [-42, -35, -31, 55],\n [-47, -40, -38, 61],\n [-28, -23, -22, 36],\n [-80, -67, -62, 104]])\nprint(expm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{7}{3}, -4, -5}$ to the plane $-\\frac{10 x}{3}-3 y-z+\\frac{14}{3}=0$.", - "Output Answer": [ - "$\\frac{53 \\sqrt{\\frac{5}{38}}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(7/3), -4, -5\nplane = Poly(-((10*x)/3)-3*y-z+(14/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 3 \\\\\n -4 \\\\\n 5 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$14$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [3],\n [-4],\n [5],\n [1]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{16}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 0 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{45}{16} \\\\\n 0 \\\\\n \\frac{45}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [0],\n [-9]])\nprint(a * -(5/16))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 2 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -17 \\\\\n 29 \\\\\n 18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [3],\n [-2]])\nb = np.array([\n [-4],\n [2],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & -\\frac{5}{2} & -2 \\\\\n \\frac{5}{2} & 1 & -\\frac{1}{2} \\\\\n \\frac{5}{2} & -\\frac{5}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{41}{4} & 5 & -\\frac{7}{4} \\\\\n -\\frac{5}{4} & -4 & -\\frac{27}{4} \\\\\n -\\frac{5}{2} & -15 & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -(5/2), -2],\n [(5/2), 1, -(1/2)],\n [(5/2), -(5/2), (5/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n \\frac{2}{5} \\\\\n -\\frac{2}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{4}{5} & \\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{8}{25} & \\frac{16}{25} \\\\\n -\\frac{8}{25} & -\\frac{16}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/5)],\n [-(2/5)]])\nb = np.array([\n [(4/5), (8/5)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -7 & -2 \\\\\n 2 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -2],\n [2, 3]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 10 & 1 & 3 \\\\\n -1 & 2 & 8 \\\\\n -4 & 10 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [10, 1, 3],\n [-1, 2, 8],\n [-4, 10, 10]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & 2 & 3 \\\\\n 3 & 4 & 0 \\\\\n -3 & -3 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2, 3],\n [3, 4, 0],\n [-3, -3, -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{20}{3} \\\\\n \\frac{22}{3} \\\\\n \\frac{11}{3} \\\\\n \\frac{25}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{14}{3} \\\\\n -\\frac{74}{9} \\\\\n -\\frac{13}{3} \\\\\n -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{34}{3} \\\\\n \\frac{140}{9} \\\\\n 8 \\\\\n 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/3)],\n [(22/3)],\n [(11/3)],\n [(25/3)]])\nb = np.array([\n [(14/3)],\n [-(74/9)],\n [-(13/3)],\n [-(8/3)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 0 & -10 & 0 \\\\\n -2 & -9 & 2 \\\\\n -4 & -5 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-9.813,0.375,5.438\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -10, 0],\n [-2, -9, 2],\n [-4, -5, 5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{4}{3} & \\frac{11}{3} & 1 \\\\\n \\frac{10}{3} & -\\frac{4}{3} & -\\frac{5}{3} \\\\\n \\frac{1}{3} & -\\frac{2}{3} & -\\frac{13}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1495}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3), (11/3), 1],\n [(10/3), -(4/3), -(5/3)],\n [(1/3), -(2/3), -(13/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & -2 \\\\\n -\\frac{5}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{2}{3} & -\\frac{8}{15} \\\\\n -\\frac{2}{3} & -\\frac{2}{15} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), -2],\n [-(5/2), (5/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 1 \\\\\n 0 \\\\\n -5 \\\\\n -10 \\\\\n -4 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 0 \\\\\n 4 \\\\\n -7 \\\\\n -1 \\\\\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$103$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [1],\n [0],\n [-5],\n [-10],\n [-4],\n [6]])\nb = np.array([\n [6],\n [0],\n [4],\n [-7],\n [-1],\n [2],\n [2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 3 & 2 & -3 \\\\\n 1 & -4 & -3 \\\\\n -2 & -4 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{4}{13} & \\frac{7}{13} & -\\frac{9}{13} \\\\\n \\frac{7}{26} & -\\frac{9}{26} & \\frac{3}{13} \\\\\n -\\frac{6}{13} & \\frac{4}{13} & -\\frac{7}{13} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2, -3],\n [1, -4, -3],\n [-2, -4, -1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{2} \\\\\n \\frac{1}{2} \\\\\n -\\frac{3}{2} \\\\\n -1 \\\\\n -4 \\\\\n \\frac{17}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{17}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2)],\n [(1/2)],\n [-(3/2)],\n [-1],\n [-4],\n [(17/2)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & -5 & 0 \\\\\n -9 & 1 & 9 \\\\\n -2 & -3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-3.243,-1.,5.243\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -5, 0],\n [-9, 1, 9],\n [-2, -3, 1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & -3 & -2 \\\\\n 0 & 0 & 0 \\\\\n -3 & -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3, -2],\n [0, 0, 0],\n [-3, -1, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 1 & -1 & 2 & 3 & 2 \\\\\n 1 & 1 & -3 & 0 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 1 & -2 & -3 & 2 & 1 \\\\\n 2 & -1 & -1 & 0 & 1 \\\\\n 0 & -2 & -2 & 3 & 1 \\\\\n 0 & -2 & 3 & 0 & -3 \\\\\n -2 & -3 & -1 & 0 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -5 & -17 & 1 & 8 & -9 \\\\\n 1 & 0 & 1 & -7 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, 2, 3, 2],\n [1, 1, -3, 0, 1]])\nb = np.array([\n [1, -2, -3, 2, 1],\n [2, -1, -1, 0, 1],\n [0, -2, -2, 3, 1],\n [0, -2, 3, 0, -3],\n [-2, -3, -1, 0, -1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -1 & 3 & -3 \\\\\n -2 & -1 & -4 \\\\\n 1 & 3 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{8}{19} & -\\frac{21}{19} & -\\frac{15}{19} \\\\\n \\frac{4}{19} & -\\frac{1}{19} & \\frac{2}{19} \\\\\n -\\frac{5}{19} & \\frac{6}{19} & \\frac{7}{19} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, -3],\n [-2, -1, -4],\n [1, 3, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 2 & -1 & 3 & 3 & 1 \\\\\n -2 & -1 & 1 & 1 & 1 \\\\\n 0 & -1 & 1 & 1 & 0 \\\\\n -3 & -3 & 0 & -2 & 2 \\\\\n 0 & 0 & -2 & 0 & 3 \\\\\n 3 & 0 & -2 & 0 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.55 \\\\\n -1.81 \\\\\n 1.53 \\\\\n -1.67 \\\\\n -0.22 \\\\\n 1. \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.448 \\\\\n -2.827 \\\\\n -3.377 \\\\\n 2.06 \\\\\n -2.347 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1, 3, 3, 1],\n [-2, -1, 1, 1, 1],\n [0, -1, 1, 1, 0],\n [-3, -3, 0, -2, 2],\n [0, 0, -2, 0, 3],\n [3, 0, -2, 0, 3]])\nb = np.array([\n [-2.55],\n [-1.81],\n [1.53],\n [-1.67],\n [-0.22],\n [1.]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -11 \\log (2) \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$66 \\log ^2(2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-6*math.log(2)]])\nb = np.array([\n [-11*math.log(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{4}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 9 & 6 & 7 \\\\\n 5 & 9 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{9}{4} & \\frac{3}{2} & \\frac{7}{4} \\\\\n \\frac{5}{4} & \\frac{9}{4} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 6, 7],\n [5, 9, -6]])\nprint(a * (1/4))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{23}{3} & 5 & -\\frac{2}{3} \\\\\n \\frac{19}{3} & -\\frac{16}{3} & -\\frac{8}{3} \\\\\n \\frac{13}{3} & 0 & -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-12.634,-2.516-1.694 i,-2.516+1.694 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/3), 5, -(2/3)],\n [(19/3), -(16/3), -(8/3)],\n [(13/3), 0, -(14/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{9}{2}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -4 & -6 & 0 & 8 \\\\\n 8 & 9 & -6 & -10 \\\\\n -2 & 3 & 6 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 18 & 27 & 0 & -36 \\\\\n -36 & -\\frac{81}{2} & 27 & 45 \\\\\n 9 & -\\frac{27}{2} & -27 & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -6, 0, 8],\n [8, 9, -6, -10],\n [-2, 3, 6, -1]])\nprint(a * -(9/2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 7 & 1 & 1 & -1 & 1 \\\\\n -3 & -1 & -10 & -9 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & -\\frac{9}{4} & -\\frac{5}{2} & \\frac{1}{4} \\\\\n 0 & 1 & \\frac{67}{4} & \\frac{33}{2} & -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, 1, 1, -1, 1],\n [-3, -1, -10, -9, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{6}{5} \\\\\n \\frac{87}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{41}{10} \\\\\n \\frac{37}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{53}{10} \\\\\n \\frac{62}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(6/5)],\n [(87/10)]])\nb = np.array([\n [-(41/10)],\n [(37/10)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{3}{4} & -\\frac{3}{2} & -\\frac{1}{4} & -2 & \\frac{3}{2} \\\\\n \\frac{5}{4} & \\frac{3}{2} & \\frac{7}{4} & 1 & \\frac{3}{4} \\\\\n \\frac{7}{4} & -3 & -\\frac{9}{4} & \\frac{11}{4} & \\frac{3}{4} \\\\\n -\\frac{3}{4} & -\\frac{1}{2} & 2 & -\\frac{7}{4} & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 3 & -1 \\\\\n -2 & -\\frac{5}{2} \\\\\n 0 & -\\frac{1}{4} \\\\\n -2 & \\frac{7}{4} \\\\\n \\frac{9}{4} & -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{65}{8} & -\\frac{1}{16} \\\\\n \\frac{7}{16} & -\\frac{17}{4} \\\\\n \\frac{119}{16} & \\frac{169}{16} \\\\\n \\frac{45}{16} & -\\frac{7}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/4), -(3/2), -(1/4), -2, (3/2)],\n [(5/4), (3/2), (7/4), 1, (3/4)],\n [(7/4), -3, -(9/4), (11/4), (3/4)],\n [-(3/4), -(1/2), 2, -(7/4), (1/4)]])\nb = np.array([\n [3, -1],\n [-2, -(5/2)],\n [0, -(1/4)],\n [-2, (7/4)],\n [(9/4), -(3/4)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -1 & \\frac{14}{9} & \\frac{13}{9} \\\\\n \\frac{14}{3} & -\\frac{10}{3} & 4 \\\\\n -\\frac{8}{3} & \\frac{11}{9} & \\frac{35}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{2169}{3836} & \\frac{1041}{7672} & -\\frac{1341}{3836} \\\\\n \\frac{3501}{3836} & \\frac{9}{7672} & -\\frac{1305}{3836} \\\\\n \\frac{387}{3836} & \\frac{711}{7672} & \\frac{477}{3836} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, (14/9), (13/9)],\n [(14/3), -(10/3), 4],\n [-(8/3), (11/9), (35/9)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{2}{3},-\\frac{13}{3},-5\\right\\}, \\left\\{1,-4,\\frac{2}{3}\\right\\}, \\left\\{\\frac{14}{3},\\frac{13}{3},-4\\right\\}}$.", - "Output Answer": [ - "$439 x-257 y-114 z-1391=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(2/3), -(13/3), -5],\n [1, -4, (2/3)],\n [(14/3), (13/3), -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{22}{9} & \\frac{49}{9} & \\frac{52}{9} \\\\\n -\\frac{1}{9} & -\\frac{80}{9} & -\\frac{32}{9} \\\\\n -\\frac{89}{9} & -\\frac{23}{3} & \\frac{17}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{41 x^2}{9}+\\frac{277 x}{81}-\\frac{304763}{729}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(22/9), (49/9), (52/9)],\n [-(1/9), -(80/9), -(32/9)],\n [-(89/9), -(23/3), (17/9)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & -8 & 0 \\\\\n -5 & 8 & 7 \\\\\n 8 & -7 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-4.407,-3.999,1.\\}, \\{0.512\\, -0.344 i,0.067\\, +0.602 i,1.\\}, \\{0.512\\, +0.344 i,0.067\\, -0.602 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -8, 0],\n [-5, 8, 7],\n [8, -7, 8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 e \\\\\n 2 e \\\\\n 3 e \\\\\n 2 e \\\\\n -e \\\\\n 0 \\\\\n 2 e \\\\\n -2 e \\\\\n -e \\\\\n 2 e \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -e \\\\\n 2 e \\\\\n 3 e \\\\\n 2 e \\\\\n e \\\\\n 2 e \\\\\n 2 e \\\\\n 3 e \\\\\n 2 e \\\\\n e \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{11} e$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-2*math.e],\n [2*math.e],\n [3*math.e],\n [2*math.e],\n [-math.e],\n [0],\n [2*math.e],\n [-2*math.e],\n [-math.e],\n [2*math.e]])\nb = np.array([\n [-math.e],\n [2*math.e],\n [3*math.e],\n [2*math.e],\n [math.e],\n [2*math.e],\n [2*math.e],\n [3*math.e],\n [2*math.e],\n [math.e]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n \\frac{11}{2} & -\\frac{7}{2} & \\frac{17}{2} \\\\\n 4 & 8 & 6 \\\\\n \\frac{9}{2} & -\\frac{17}{2} & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/2), -(7/2), (17/2)],\n [4, 8, 6],\n [(9/2), -(17/2), 2]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{4}{3}, -1}$ to the line $-5 x-\\frac{13 y}{3}-3=0$.", - "Output Answer": [ - "$12 \\sqrt{\\frac{2}{197}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(4/3), -1\nline = Poly(-5*x-((13*y)/3)-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n -3 & -8 \\\\\n -1 & 7 \\\\\n -7 & 9 \\\\\n -5 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [1, 0],\n [-3, -8],\n [-1, 7],\n [-7, 9],\n [-5, -9]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{2} & -\\frac{5}{2} & \\frac{5}{2} \\\\\n -\\frac{3}{2} & 0 & -3 \\\\\n -\\frac{3}{2} & -2 & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{4} & -\\frac{15}{4} & 0 \\\\\n \\frac{21}{4} & \\frac{39}{4} & \\frac{15}{4} \\\\\n \\frac{15}{2} & \\frac{35}{4} & \\frac{17}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), -(5/2), (5/2)],\n [-(3/2), 0, -3],\n [-(3/2), -2, -(5/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 0 & 2 \\\\\n 3 & 3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 18 & 30 \\\\\n 45 & 63 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2],\n [3, 3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{33}{4} \\\\\n \\frac{25}{4} \\\\\n -8 \\\\\n -\\frac{19}{4} \\\\\n \\frac{31}{4} \\\\\n -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{2} \\\\\n -\\frac{5}{2} \\\\\n \\frac{27}{4} \\\\\n -\\frac{11}{4} \\\\\n \\frac{37}{4} \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{5515}}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(33/4)],\n [(25/4)],\n [-8],\n [-(19/4)],\n [(31/4)],\n [-(7/2)]])\nb = np.array([\n [-(9/2)],\n [-(5/2)],\n [(27/4)],\n [-(11/4)],\n [(37/4)],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & 4 \\\\\n 6 & -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{19}{2},\\frac{3}{2}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), 4],\n [6, -(13/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & -1 \\\\\n 3 & 3 \\\\\n 3 & -1 \\\\\n -3 & -2 \\\\\n 3 & -2 \\\\\n 3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.39 \\\\\n 0.97 \\\\\n 2.17 \\\\\n 2.98 \\\\\n 0.94 \\\\\n 2.04 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.034 \\\\\n 0.036 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1],\n [3, 3],\n [3, -1],\n [-3, -2],\n [3, -2],\n [3, 3]])\nb = np.array([\n [-2.39],\n [0.97],\n [2.17],\n [2.98],\n [0.94],\n [2.04]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & 2 \\\\\n 1 & -2 \\\\\n 1 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.62 \\\\\n 2.61 \\\\\n 1.51 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.677 \\\\\n -0.55 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2],\n [1, -2],\n [1, 0]])\nb = np.array([\n [-1.62],\n [2.61],\n [1.51]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 6 & -8 \\\\\n -9 & 6 \\\\\n -5 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, -8],\n [-9, 6],\n [-5, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{0,\\frac{9}{2},-\\frac{3}{2}\\right\\}, \\left\\{-\\frac{7}{2},0,\\frac{5}{2}\\right\\}, \\{2,3,3\\}}$.", - "Output Answer": [ - "$3 (x+6)-5 y-3 z=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, (9/2), -(3/2)],\n [-(7/2), 0, (5/2)],\n [2, 3, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 7 & -5 & 6 & 7 & 8 \\\\\n 8 & 3 & -1 & -10 & 9 \\\\\n 1 & -9 & -9 & -1 & 3 \\\\\n -1 & -3 & 1 & -5 & -4 \\\\\n -4 & 3 & -1 & -6 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, -5, 6, 7, 8],\n [8, 3, -1, -10, 9],\n [1, -9, -9, -1, 3],\n [-1, -3, 1, -5, -4],\n [-4, 3, -1, -6, 5]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0.151 \\\\\n 8.249 \\\\\n -0.104 \\\\\n 8.424 \\\\\n 8.161 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9.25 \\\\\n -8.921 \\\\\n -4.903 \\\\\n 5.818 \\\\\n -0.686 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$22.1648$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0.151],\n [8.249],\n [-0.104],\n [8.424],\n [8.161]])\nb = np.array([\n [-9.25],\n [-8.921],\n [-4.903],\n [5.818],\n [-0.686]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-1,-\\frac{1}{2},\\frac{1}{2}\\right\\}, \\left\\{4,5,\\frac{5}{2}\\right\\}, \\{-1,0,4\\}}$.", - "Output Answer": [ - "$73 x-70 y+10 z+33=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, -(1/2), (1/2)],\n [4, 5, (5/2)],\n [-1, 0, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -\\frac{159}{16} \\\\\n -\\frac{23}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{139}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-(159/16)],\n [-(23/16)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8. \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2.5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-20.$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8.]])\nb = np.array([\n [-2.5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 3 \\\\\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 2 \\\\\n 0 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{1}{9},\\frac{2}{9},0,-\\frac{2}{9}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [3],\n [2],\n [2]]).squeeze()\nb = np.array([\n [-1],\n [2],\n [0],\n [-2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{35}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{27}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{31}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(35/4)]])\nb = np.array([\n [(27/4)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{2}{5}, -\\frac{23}{5}}$ to the line $-\\frac{12 x}{5}-\\frac{13 y}{5}-\\frac{4}{5}=0$.", - "Output Answer": [ - "$\\frac{303}{5 \\sqrt{313}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(2/5), -(23/5)\nline = Poly(-((12*x)/5)-((13*y)/5)-(4/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -2 & 0 & -1 \\\\\n 0 & 3 & -1 \\\\\n 2 & -2 & -2 \\\\\n -3 & 2 & 1 \\\\\n -2 & -1 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 0 & 1 & -1 & -1 & -3 \\\\\n -3 & 1 & -2 & -1 & 3 \\\\\n 2 & 3 & 0 & 0 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -2 & -5 & 2 & 2 & 7 \\\\\n -11 & 0 & -6 & -3 & 10 \\\\\n 2 & -6 & 2 & 0 & -10 \\\\\n -4 & 2 & -1 & 1 & 14 \\\\\n -1 & -9 & 4 & 3 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, -1],\n [0, 3, -1],\n [2, -2, -2],\n [-3, 2, 1],\n [-2, -1, -2]])\nb = np.array([\n [0, 1, -1, -1, -3],\n [-3, 1, -2, -1, 3],\n [2, 3, 0, 0, -1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{2}{e},\\frac{2}{e},\\frac{7}{e}\\right\\}, \\left\\{\\frac{4}{e},\\frac{6}{e},0\\right\\}, \\left\\{-\\frac{1}{e},-\\frac{2}{e},-\\frac{2}{e}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{2}{\\sqrt{57}},\\frac{2}{\\sqrt{57}},\\frac{7}{\\sqrt{57}}\\right\\}, \\left\\{\\frac{94}{\\sqrt{36537}},\\frac{151}{\\sqrt{36537}},-\\frac{70}{\\sqrt{36537}}\\right\\}, \\left\\{\\frac{21}{\\sqrt{641}},-\\frac{14}{\\sqrt{641}},-\\frac{2}{\\sqrt{641}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((2/math.e), (2/math.e), (7/math.e)), ((4/math.e), (6/math.e), 0), (-(1/math.e), -(2/math.e), -(2/math.e))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -7 & -3 & -\\frac{19}{2} & -10 \\\\\n -\\frac{17}{2} & \\frac{15}{2} & -\\frac{1}{2} & -9 \\\\\n -\\frac{1}{2} & 1 & -6 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{7}{2} & -4 & \\frac{15}{2} & -\\frac{15}{2} \\\\\n -\\frac{7}{2} & -\\frac{19}{2} & -\\frac{1}{2} & -\\frac{5}{2} \\\\\n \\frac{7}{2} & \\frac{3}{2} & -\\frac{7}{2} & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{21}{2} & -7 & -2 & -\\frac{35}{2} \\\\\n -12 & -2 & -1 & -\\frac{23}{2} \\\\\n 3 & \\frac{5}{2} & -\\frac{19}{2} & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -3, -(19/2), -10],\n [-(17/2), (15/2), -(1/2), -9],\n [-(1/2), 1, -6, -2]])\nb = np.array([\n [-(7/2), -4, (15/2), -(15/2)],\n [-(7/2), -(19/2), -(1/2), -(5/2)],\n [(7/2), (3/2), -(7/2), -5]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -5 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-5],\n [-7]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -2 & 0 & -3 & 3 & 2 \\\\\n -2 & 0 & 1 & -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -2 & 0 & 5 & -5 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2]])\nb = np.array([\n [-2, 0, -3, 3, 2],\n [-2, 0, 1, -1, 3]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & 9 \\\\\n 7 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-9 x-63$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 9],\n [7, 0]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [1],\n [0],\n [1],\n [0],\n [0],\n [1],\n [1],\n [0]]).squeeze()\nb = np.array([\n [1],\n [0],\n [1],\n [-1],\n [-1],\n [1],\n [0],\n [0],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 5 & 4 & -1 \\\\\n -4 & 0 & -4 \\\\\n -5 & -2 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$96$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 4, -1],\n [-4, 0, -4],\n [-5, -2, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -10 & 3 & 4 \\\\\n -7 & -6 & -3 \\\\\n 5 & 9 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-19 x^2-136 x-690$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 3, 4],\n [-7, -6, -3],\n [5, 9, -3]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -6 & -5 & -5 & 10 & 0 \\\\\n 2 & 4 & 2 & 4 & -8 \\\\\n 3 & -9 & -7 & 0 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-5.,219.,-213.,0.,55.\\}, \\{30.,-214.,288.,55.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-6, -5, -5, 10, 0],\n [2, 4, 2, 4, -8],\n [3, -9, -7, 0, 9]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{4} \\\\\n \\frac{5}{2} \\\\\n \\frac{9}{4} \\\\\n -\\frac{5}{4} \\\\\n \\frac{3}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{4 \\sqrt{14}} \\\\\n \\frac{5}{2 \\sqrt{14}} \\\\\n \\frac{9}{4 \\sqrt{14}} \\\\\n -\\frac{5}{4 \\sqrt{14}} \\\\\n \\frac{3}{4 \\sqrt{14}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/4)],\n [(5/2)],\n [(9/4)],\n [-(5/4)],\n [(3/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -10 \\\\\n -2 \\\\\n -7 \\\\\n 7 \\\\\n -7 \\\\\n 7 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 3 \\\\\n -4 \\\\\n 0 \\\\\n -8 \\\\\n 7 \\\\\n -2 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-161$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-10],\n [-2],\n [-7],\n [7],\n [-7],\n [7],\n [8]])\nb = np.array([\n [4],\n [3],\n [-4],\n [0],\n [-8],\n [7],\n [-2],\n [-7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{4,-1,-4\\}, \\{-2,-1,-4\\}, \\{4,-1,-5\\}}$.", - "Output Answer": [ - "$y+1=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, -1, -4],\n [-2, -1, -4],\n [4, -1, -5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 0 & 2 & -3 & -1 & -1 \\\\\n -3 & 2 & 1 & -1 & 3 \\\\\n 2 & 2 & 3 & 1 & -1 \\\\\n -1 & -1 & 1 & -3 & 3 \\\\\n 1 & 3 & 1 & 2 & 2 \\\\\n 1 & 0 & -3 & 0 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.77 \\\\\n -2.52 \\\\\n -1.82 \\\\\n -1.27 \\\\\n -0.87 \\\\\n 1.76 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.205 \\\\\n -0.649 \\\\\n -0.469 \\\\\n 0.536 \\\\\n 0.084 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, -3, -1, -1],\n [-3, 2, 1, -1, 3],\n [2, 2, 3, 1, -1],\n [-1, -1, 1, -3, 3],\n [1, 3, 1, 2, 2],\n [1, 0, -3, 0, -3]])\nb = np.array([\n [-0.77],\n [-2.52],\n [-1.82],\n [-1.27],\n [-0.87],\n [1.76]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 5 & -2 \\\\\n 0 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1,0\\}, \\{1,1\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -2],\n [0, 3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{64}{7} & \\frac{4}{7} \\\\\n -\\frac{39}{7} & \\frac{1}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+9 x+\\frac{92}{49}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(64/7), (4/7)],\n [-(39/7), (1/7)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & -7 & 2 \\\\\n -2 & 6 & 7 \\\\\n 6 & 3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-7.,7.\\, -2.828 i,7.\\, +2.828 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -7, 2],\n [-2, 6, 7],\n [6, 3, 0]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & 1 & -3 \\\\\n -4 & 0 & 4 \\\\\n -5 & -1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1, -3],\n [-4, 0, 4],\n [-5, -1, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,3,3\\}, \\left\\{-2,\\frac{3}{2},-\\frac{3}{2}\\right\\}, \\left\\{-\\frac{7}{2},-3,2\\right\\}}$.", - "Output Answer": [ - "$34 x-23 y-15 z+80=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, 3, 3],\n [-2, (3/2), -(3/2)],\n [-(7/2), -3, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{32}{5} \\\\\n -\\frac{44}{5} \\\\\n 0 \\\\\n -\\frac{46}{5} \\\\\n \\frac{44}{5} \\\\\n -\\frac{37}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{26}{5} \\\\\n \\frac{38}{5} \\\\\n \\frac{8}{5} \\\\\n -\\frac{2}{5} \\\\\n -\\frac{6}{5} \\\\\n -\\frac{29}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{61}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(32/5)],\n [-(44/5)],\n [0],\n [-(46/5)],\n [(44/5)],\n [-(37/5)]])\nb = np.array([\n [-(26/5)],\n [(38/5)],\n [(8/5)],\n [-(2/5)],\n [-(6/5)],\n [-(29/5)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 1 \\\\\n -5 \\\\\n -8 \\\\\n 2 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$28$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [1],\n [-5],\n [-8],\n [2],\n [-6]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{31}{4} & -\\frac{7}{4} & -\\frac{19}{2} & 4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{23}{4} & -\\frac{13}{4} & -\\frac{35}{4} & \\frac{37}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -2 & \\frac{3}{2} & -\\frac{3}{4} & -\\frac{21}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(31/4), -(7/4), -(19/2), 4]])\nb = np.array([\n [-(23/4), -(13/4), -(35/4), (37/4)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -9 & \\frac{5}{3} \\\\\n -3 & -\\frac{26}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{6} \\left(-53-i \\sqrt{179}\\right),\\frac{1}{6} \\left(-53+i \\sqrt{179}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, (5/3)],\n [-3, -(26/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & 0 \\\\\n 2 & 0 \\\\\n -2 & -1 \\\\\n -1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.78 \\\\\n 0.95 \\\\\n -0.45 \\\\\n 2.64 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.236 \\\\\n 1.663 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0],\n [2, 0],\n [-2, -1],\n [-1, 1]])\nb = np.array([\n [-0.78],\n [0.95],\n [-0.45],\n [2.64]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 0 \\\\\n -2 \\\\\n 1 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{\\sqrt{2}}{3} \\\\\n 0 \\\\\n -\\frac{\\sqrt{2}}{3} \\\\\n \\frac{1}{3 \\sqrt{2}} \\\\\n -\\frac{1}{\\sqrt{2}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [0],\n [-2],\n [1],\n [-3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 9 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 1 \\\\\n -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -72 \\\\\n -24 \\\\\n -57 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [9],\n [0]])\nb = np.array([\n [6],\n [1],\n [-8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(-2 \\sqrt{6}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [0],\n [1],\n [0],\n [-1],\n [-1],\n [-1],\n [0]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [0],\n [1],\n [-1],\n [0],\n [1],\n [0],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 1 \\\\\n -1 & 0 & 0 \\\\\n -3 & 3 & 0 \\\\\n 1 & -3 & 0 \\\\\n -1 & 3 & 2 \\\\\n 2 & 1 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.42 \\\\\n -0.71 \\\\\n 1.4 \\\\\n -1.27 \\\\\n 2.37 \\\\\n -1.1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.289 \\\\\n 0.155 \\\\\n 0.988 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 0, 1],\n [-1, 0, 0],\n [-3, 3, 0],\n [1, -3, 0],\n [-1, 3, 2],\n [2, 1, 0]])\nb = np.array([\n [1.42],\n [-0.71],\n [1.4],\n [-1.27],\n [2.37],\n [-1.1]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n \\frac{4}{3} & -2 & -\\frac{17}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{2}{3} & \\frac{13}{6} \\\\\n -\\frac{1}{3} & \\frac{11}{6} \\\\\n -\\frac{1}{2} & \\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{107}{36} & -\\frac{25}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3), -2, -(17/6)]])\nb = np.array([\n [(2/3), (13/6)],\n [-(1/3), (11/6)],\n [-(1/2), (8/3)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{14}{3}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{28}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2]])\nprint(a * (14/3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n \\frac{7}{4} \\\\\n -\\frac{3}{2} \\\\\n -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3 \\sqrt{\\frac{2}{65}} \\\\\n \\frac{7}{\\sqrt{130}} \\\\\n -3 \\sqrt{\\frac{2}{65}} \\\\\n -\\frac{3}{\\sqrt{130}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2)],\n [(7/4)],\n [-(3/2)],\n [-(3/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n 1 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{\\sqrt{2}}{3} \\\\\n -\\frac{\\sqrt{2}}{3} \\\\\n \\frac{1}{3 \\sqrt{2}} \\\\\n \\frac{1}{\\sqrt{2}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-2],\n [1],\n [3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{6}{5}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -7 & 0 & -4 \\\\\n -8 & -5 & 10 \\\\\n -9 & -4 & 3 \\\\\n -8 & 2 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{42}{5} & 0 & \\frac{24}{5} \\\\\n \\frac{48}{5} & 6 & -12 \\\\\n \\frac{54}{5} & \\frac{24}{5} & -\\frac{18}{5} \\\\\n \\frac{48}{5} & -\\frac{12}{5} & \\frac{42}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 0, -4],\n [-8, -5, 10],\n [-9, -4, 3],\n [-8, 2, -7]])\nprint(a * -(6/5))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -7 & 9 \\\\\n -7 & 0 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 4 & -8 \\\\\n 0 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -11 & 17 \\\\\n -7 & 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 9],\n [-7, 0]])\nb = np.array([\n [4, -8],\n [0, -9]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 5 & -5 & 6 \\\\\n 5 & 10 & 1 \\\\\n 8 & 1 & -4 \\\\\n 4 & 1 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 9 & 4 & 8 \\\\\n 10 & 10 & -8 \\\\\n -8 & 5 & 0 \\\\\n 9 & 5 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 14 & -1 & 14 \\\\\n 15 & 20 & -7 \\\\\n 0 & 6 & -4 \\\\\n 13 & 6 & 16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -5, 6],\n [5, 10, 1],\n [8, 1, -4],\n [4, 1, 8]])\nb = np.array([\n [9, 4, 8],\n [10, 10, -8],\n [-8, 5, 0],\n [9, 5, 8]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{47}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{47}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(47/5)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -6 & 1 & 9 \\\\\n 1 & 6 & 0 \\\\\n 9 & -3 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-10.522,6.281,12.241\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 1, 9],\n [1, 6, 0],\n [9, -3, 8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{587}{100} \\\\\n -\\frac{587}{100} \\\\\n -\\frac{403}{100} \\\\\n -\\frac{219}{25} \\\\\n \\frac{161}{25} \\\\\n -\\frac{81}{10} \\\\\n \\frac{151}{25} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{122183}}{20}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(587/100)],\n [-(587/100)],\n [-(403/100)],\n [-(219/25)],\n [(161/25)],\n [-(81/10)],\n [(151/25)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -5 & -1 & -2 \\\\\n 3 & 5 & -1 \\\\\n 4 & -4 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{29}{198} & \\frac{1}{66} & \\frac{1}{18} \\\\\n \\frac{1}{18} & \\frac{1}{6} & -\\frac{1}{18} \\\\\n -\\frac{16}{99} & -\\frac{4}{33} & -\\frac{1}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -1, -2],\n [3, 5, -1],\n [4, -4, -5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n 1 \\\\\n -\\frac{3}{2} \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{\\sqrt{47}} \\\\\n \\frac{2}{\\sqrt{47}} \\\\\n -\\frac{3}{\\sqrt{47}} \\\\\n -\\frac{5}{\\sqrt{47}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2)],\n [1],\n [-(3/2)],\n [-(5/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{50}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{9}{50} & -\\frac{3}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2]])\nprint(a * -(3/50))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{2}{5}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -10 & -2 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -4 & -\\frac{4}{5} & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -2, -5]])\nprint(a * (2/5))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{9}{2},-4,-\\frac{1}{2}\\right\\}, \\left\\{-\\frac{5}{2},2,\\frac{3}{2}\\right\\}, \\left\\{\\frac{7}{2},0,-\\frac{1}{2}\\right\\}}$.", - "Output Answer": [ - "$8 x+2 y+22 z-17=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(9/2), -4, -(1/2)],\n [-(5/2), 2, (3/2)],\n [(7/2), 0, -(1/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & -1 & 4 \\\\\n 4 & -5 & 1 \\\\\n 7 & -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.561,-0.285,1.\\}, \\{0.787,13.192,1.\\}, \\{1.097,0.352,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -1, 4],\n [4, -5, 1],\n [7, -1, 3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{59}{10} \\\\\n \\frac{691}{100} \\\\\n -\\frac{991}{100} \\\\\n \\frac{251}{100} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{127}{50} \\\\\n -\\frac{273}{50} \\\\\n -\\frac{197}{100} \\\\\n \\frac{333}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{84}{25} \\\\\n \\frac{1237}{100} \\\\\n -\\frac{397}{50} \\\\\n -\\frac{83}{20} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(59/10)],\n [(691/100)],\n [-(991/100)],\n [(251/100)]])\nb = np.array([\n [(127/50)],\n [-(273/50)],\n [-(197/100)],\n [(333/50)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{2} & \\frac{3}{2} & 1 \\\\\n \\frac{5}{2} & \\frac{3}{2} & \\frac{1}{2} \\\\\n \\frac{1}{2} & \\frac{3}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{215}{8} & \\frac{111}{8} & \\frac{79}{8} \\\\\n \\frac{97}{4} & 12 & \\frac{23}{8} \\\\\n \\frac{13}{4} & 12 & \\frac{43}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), (3/2), 1],\n [(5/2), (3/2), (1/2)],\n [(1/2), (3/2), (1/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & 3 \\\\\n 2 & -2 \\\\\n 2 & 2 \\\\\n -2 & -1 \\\\\n 2 & -3 \\\\\n 3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.9 \\\\\n 2.95 \\\\\n -0.1 \\\\\n -1.35 \\\\\n 2.35 \\\\\n -2.03 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.301 \\\\\n -0.622 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 3],\n [2, -2],\n [2, 2],\n [-2, -1],\n [2, -3],\n [3, 3]])\nb = np.array([\n [-1.9],\n [2.95],\n [-0.1],\n [-1.35],\n [2.35],\n [-2.03]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7]])\nb = np.array([\n [-2]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 3 & 5 & 5 \\\\\n 4 & -3 & 3 \\\\\n 5 & -7 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+33 x+73$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 5, 5],\n [4, -3, 3],\n [5, -7, 0]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{9}{4}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 10 & -3 & 2 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{45}{2} & \\frac{27}{4} & -\\frac{9}{2} & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -3, 2, 4]])\nprint(a * -(9/4))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -1 & -2 & -1 & -1 & -1 \\\\\n -1 & 2 & -3 & 2 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 0 & -3 & -2 & -2 & 0 \\\\\n 1 & 0 & -3 & 1 & -2 \\\\\n -2 & 3 & -2 & 3 & 0 \\\\\n -1 & 0 & -1 & 3 & 3 \\\\\n 2 & 2 & 0 & 0 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -1 & -2 & 11 & -6 & 3 \\\\\n 4 & -8 & 0 & 1 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, -1, -1, -1],\n [-1, 2, -3, 2, -1]])\nb = np.array([\n [0, -3, -2, -2, 0],\n [1, 0, -3, 1, -2],\n [-2, 3, -2, 3, 0],\n [-1, 0, -1, 3, 3],\n [2, 2, 0, 0, -2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n \\frac{59}{6} \\\\\n -\\frac{17}{3} \\\\\n \\frac{41}{6} \\\\\n \\frac{17}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$34$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [(59/6)],\n [-(17/3)],\n [(41/6)],\n [(17/3)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 0 & 1 & 0 & 1 & 2 \\\\\n -3 & -1 & 0 & -3 & -1 \\\\\n 1 & -2 & 2 & -3 & 0 \\\\\n 1 & 1 & -1 & -3 & 3 \\\\\n 2 & -1 & -1 & 1 & -2 \\\\\n -2 & 2 & 3 & 1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.27 \\\\\n 1.41 \\\\\n -0.25 \\\\\n 0.04 \\\\\n 1.94 \\\\\n -1.12 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.192 \\\\\n -0.412 \\\\\n -0.369 \\\\\n 0.14 \\\\\n 0.17 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 0, 1, 2],\n [-3, -1, 0, -3, -1],\n [1, -2, 2, -3, 0],\n [1, 1, -1, -3, 3],\n [2, -1, -1, 1, -2],\n [-2, 2, 3, 1, -1]])\nb = np.array([\n [2.27],\n [1.41],\n [-0.25],\n [0.04],\n [1.94],\n [-1.12]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 0 & -6 & 1 \\\\\n 5 & -8 & -5 \\\\\n -4 & 1 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-12 x^2-71 x-267$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -6, 1],\n [5, -8, -5],\n [-4, 1, -4]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & 4 \\\\\n 9 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+6 x-52$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 4],\n [9, 2]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 1 & 1 & 6 & 7 & -1 \\\\\n -4 & -10 & 8 & -1 & 1 \\\\\n 1 & 10 & -8 & 4 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{68.,-94.,-75.,68.,0.\\}, \\{476.,-182.,-15.,0.,204.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [1, 1, 6, 7, -1],\n [-4, -10, 8, -1, 1],\n [1, 10, -8, 4, 6]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & -8 \\\\\n 4 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(1-\\sqrt{161}\\right),\\frac{1}{2} \\left(1+\\sqrt{161}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -8],\n [4, -8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -6 & 2 & 10 \\\\\n 3 & -9 & -6 \\\\\n 1 & 8 & -5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -6 & 0 & -9 \\\\\n 9 & 7 & 5 \\\\\n 6 & -9 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 2 & 19 \\\\\n -6 & -16 & -11 \\\\\n -5 & 17 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 2, 10],\n [3, -9, -6],\n [1, 8, -5]])\nb = np.array([\n [-6, 0, -9],\n [9, 7, 5],\n [6, -9, -6]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 3 \\\\\n 1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3],\n [1, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & -7 \\\\\n -\\frac{3}{2} & -\\frac{19}{2} \\\\\n -5 & 6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -9 & -\\frac{13}{2} \\\\\n \\frac{13}{2} & -8 \\\\\n 10 & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{19}{2} & -\\frac{1}{2} \\\\\n -8 & -\\frac{3}{2} \\\\\n -15 & \\frac{17}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), -7],\n [-(3/2), -(19/2)],\n [-5, 6]])\nb = np.array([\n [-9, -(13/2)],\n [(13/2), -8],\n [10, -(5/2)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{2}{5}, -\\frac{19}{5}, -2}$ to the plane $\\frac{12 x}{5}-\\frac{14 y}{5}+\\frac{21 z}{5}-\\frac{22}{5}=0$.", - "Output Answer": [ - "$\\frac{78}{5 \\sqrt{781}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(2/5), -(19/5), -2\nplane = Poly(((12*x)/5)-((14*y)/5)+((21*z)/5)-(22/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & -7 \\\\\n -3 & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{12} \\left(7-\\sqrt{385}\\right),1\\right\\}, \\left\\{\\frac{1}{12} \\left(7+\\sqrt{385}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -7],\n [-3, -(7/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n 1 & \\frac{17}{4} & 9 & 8 & 4 \\\\\n \\frac{5}{2} & \\frac{21}{4} & -\\frac{7}{4} & \\frac{11}{4} & \\frac{1}{2} \\\\\n -8 & -4 & \\frac{7}{2} & -\\frac{15}{2} & -\\frac{29}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, (17/4), 9, 8, 4],\n [(5/2), (21/4), -(7/4), (11/4), (1/2)],\n [-8, -4, (7/2), -(15/2), -(29/4)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, 4, 4}$ to the plane $5 x-y-2 z-1=0$.", - "Output Answer": [ - "$\\sqrt{\\frac{2}{15}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, 4, 4\nplane = Poly(5*x-y-2*z-1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{42}{5} & 6 & \\frac{17}{5} \\\\\n \\frac{42}{5} & \\frac{4}{5} & -1 \\\\\n \\frac{49}{5} & \\frac{29}{5} & -\\frac{1}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.155,1.321,1.\\}, \\{0.172,-0.341,1.\\}, \\{0.409,0.439,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(42/5), 6, (17/5)],\n [(42/5), (4/5), -1],\n [(49/5), (29/5), -(1/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, 3}$ to the line $-\\frac{8 x}{3}-\\frac{10 y}{3}+\\frac{7}{3}=0$.", - "Output Answer": [ - "$\\frac{7}{2 \\sqrt{41}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, 3\nline = Poly(-((8*x)/3)-((10*y)/3)+(7/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,-1,-4\\}, \\{5,5,-1\\}, \\{3,-3,3\\}}$.", - "Output Answer": [ - "$24 x-17 y-22 z-57=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, -1, -4],\n [5, 5, -1],\n [3, -3, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{15}{4} & \\frac{13}{2} & -\\frac{5}{2} \\\\\n \\frac{17}{4} & \\frac{15}{2} & 7 \\\\\n -\\frac{15}{2} & -\\frac{17}{2} & \\frac{39}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-7.008,10.254\\, -7.755 i,10.254\\, +7.755 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/4), (13/2), -(5/2)],\n [(17/4), (15/2), 7],\n [-(15/2), -(17/2), (39/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\sqrt{\\frac{3}{10}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [1],\n [1],\n [0],\n [-1],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [0],\n [0],\n [-1],\n [-1],\n [-1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{7}{3},3,-\\frac{2}{3}\\right\\}, \\left\\{3,\\frac{13}{3},5\\right\\}, \\left\\{-\\frac{13}{3},\\frac{2}{3},\\frac{5}{3}\\right\\}}$.", - "Output Answer": [ - "$147 x-354 y+66 z+763=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(7/3), 3, -(2/3)],\n [3, (13/3), 5],\n [-(13/3), (2/3), (5/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{791}{100} & -\\frac{363}{50} \\\\\n -\\frac{3}{4} & -\\frac{357}{50} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{143}{50} & \\frac{523}{100} \\\\\n -\\frac{377}{100} & \\frac{239}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{101}{20} & -\\frac{1249}{100} \\\\\n \\frac{151}{50} & -\\frac{167}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(791/100), -(363/50)],\n [-(3/4), -(357/50)]])\nb = np.array([\n [-(143/50), (523/100)],\n [-(377/100), (239/25)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\sqrt{2} \\\\\n 5 \\sqrt{2} \\\\\n \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 2 \\sqrt{2} \\\\\n 7 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$34$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.sqrt(2)],\n [5*math.sqrt(2)],\n [math.sqrt(2)]])\nb = np.array([\n [0],\n [2*math.sqrt(2)],\n [7*math.sqrt(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -6 & -1 & 7 & -3 & -1 \\\\\n 10 & 1 & 0 & 7 & 8 \\\\\n 4 & -6 & -9 & 6 & 8 \\\\\n 10 & 5 & 8 & 9 & -3 \\\\\n 9 & -2 & 6 & -1 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-6, -1, 7, -3, -1],\n [10, 1, 0, 7, 8],\n [4, -6, -9, 6, 8],\n [10, 5, 8, 9, -3],\n [9, -2, 6, -1, -6]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 9 & 9 & -2 & -5 \\\\\n 4 & 1 & -10 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & -\\frac{88}{27} & \\frac{95}{27} \\\\\n 0 & 1 & \\frac{82}{27} & -\\frac{110}{27} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, 9, -2, -5],\n [4, 1, -10, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -5 & -4 & 3 & 5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 6 & -3 & -6 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -11 & -1 & 9 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -4, 3, 5]])\nb = np.array([\n [6, -3, -6, 8]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & 5 & 4 \\\\\n 4 & 3 & -3 \\\\\n 4 & 3 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{48}{1505} & \\frac{17}{301} & \\frac{17}{301} \\\\\n \\frac{37}{301} & \\frac{16}{301} & \\frac{16}{301} \\\\\n \\frac{121}{1505} & -\\frac{23}{602} & -\\frac{23}{602} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 5, 4],\n [4, 3, -3],\n [4, 3, -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 5 & -7 \\\\\n -5 & 10 \\\\\n 10 & -2 \\\\\n -10 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, -7],\n [-5, 10],\n [10, -2],\n [-10, 6]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1]])\nb = np.array([\n [9]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 3 \\\\\n -2 \\\\\n -3 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{23}} \\\\\n 0 \\\\\n \\frac{3}{\\sqrt{23}} \\\\\n -\\frac{2}{\\sqrt{23}} \\\\\n -\\frac{3}{\\sqrt{23}} \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [3],\n [-2],\n [-3],\n [0]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & 4 \\\\\n -2 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 4],\n [-2, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2} & -2 \\\\\n -\\frac{7}{2} & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{14} \\left(1-\\sqrt{113}\\right),1\\right\\}, \\left\\{\\frac{1}{14} \\left(1+\\sqrt{113}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), -2],\n [-(7/2), 0]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -9 & -10 & -4 & -1 \\\\\n 2 & 8 & -6 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-46.,31.,26.,0.\\}, \\{22.,-25.,0.,52.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, -10, -4, -1],\n [2, 8, -6, 3]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 2 \\\\\n 5 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -5 \\\\\n 4 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$61$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [2],\n [5],\n [-2]])\nb = np.array([\n [7],\n [-5],\n [4],\n [-1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & 0 \\\\\n 3 & -3 & 3 \\\\\n 0 & -1 & -3 \\\\\n -3 & 3 & 3 \\\\\n 2 & -2 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.55 \\\\\n 0.78 \\\\\n 2.25 \\\\\n 0.87 \\\\\n -0.02 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2.987 \\\\\n -3.018 \\\\\n 0.256 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, 0],\n [3, -3, 3],\n [0, -1, -3],\n [-3, 3, 3],\n [2, -2, 1]])\nb = np.array([\n [1.55],\n [0.78],\n [2.25],\n [0.87],\n [-0.02]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [-1],\n [0],\n [1],\n [0]]).squeeze()\nb = np.array([\n [0],\n [0],\n [0],\n [1],\n [0],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 0 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 2 \\\\\n 1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{11},-\\frac{1}{11},-\\frac{2}{11},-\\frac{1}{11},-\\frac{2}{11}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [0],\n [-2],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [2],\n [1],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -7 & 0 & -7 & 6 \\\\\n 2 & 2 & -6 & 9 \\\\\n -10 & 8 & 7 & -3 \\\\\n -4 & -10 & -5 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, 0, -7, 6],\n [2, 2, -6, 9],\n [-10, 8, 7, -3],\n [-4, -10, -5, 0]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & -2 & 1 \\\\\n 3 & -3 & 1 \\\\\n 2 & 1 & 1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 11 & -8 & 4 \\\\\n 12 & -9 & 4 \\\\\n 8 & 4 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2, 1],\n [3, -3, 1],\n [2, 1, 1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,1,0\\}, \\{1,-1,3\\}, \\{0,2,-2\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{2}{\\sqrt{5}},\\frac{1}{\\sqrt{5}},0\\right\\}, \\left\\{\\frac{1}{\\sqrt{30}},-\\sqrt{\\frac{2}{15}},\\sqrt{\\frac{5}{6}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{6}},\\sqrt{\\frac{2}{3}},\\frac{1}{\\sqrt{6}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, 1, 0), (1, -1, 3), (0, 2, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{2} & -\\frac{7}{2}-\\frac{7 i}{2} & -\\frac{3}{2}-5 i \\\\\n \\frac{1}{2}-4 i & -1+\\frac{5 i}{2} & \\frac{1}{2}-\\frac{5 i}{2} \\\\\n 4+2 i & 3 i & -5+5 i \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 53+\\frac{827 i}{8} & -\\frac{1689}{8}+\\frac{1711 i}{8} & -\\frac{1499}{4}-\\frac{1261 i}{8} \\\\\n -\\frac{703}{8}+\\frac{203 i}{2} & -\\frac{727}{8}-145 i & -42-\\frac{749 i}{4} \\\\\n \\frac{521}{4}-\\frac{721 i}{4} & \\frac{1877}{4}+96 i & \\frac{1033}{4}+\\frac{1245 i}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), -(7/2)-((7j)/2), -(3/2)-5j],\n [(1/2)-4j, -1+((5j)/2), (1/2)-((5j)/2)],\n [4+2j, 3j, -5+5j]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & \\frac{2}{3} \\\\\n -\\frac{11}{3} & -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{104}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, (2/3)],\n [-(11/3), -(14/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -10 & 4 \\\\\n -5 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -10 & 2 \\\\\n -3 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -20 & 6 \\\\\n -8 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 4],\n [-5, 2]])\nb = np.array([\n [-10, 2],\n [-3, -2]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & 2 & 3 \\\\\n -1 & -1 & 1 \\\\\n -3 & -2 & -2 \\\\\n -1 & 1 & -2 \\\\\n 3 & -3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.08 \\\\\n 1.84 \\\\\n -1.19 \\\\\n 1.75 \\\\\n 2.49 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.313 \\\\\n -0.128 \\\\\n -0.079 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2, 3],\n [-1, -1, 1],\n [-3, -2, -2],\n [-1, 1, -2],\n [3, -3, -2]])\nb = np.array([\n [0.08],\n [1.84],\n [-1.19],\n [1.75],\n [2.49]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -3 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -10 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{27}{\\sqrt{16166}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-3],\n [10]]).squeeze()\nb = np.array([\n [1],\n [-10],\n [-6]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{15}{2}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{15}{2} & \\frac{15}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1]])\nprint(a * (15/2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -2 & 10 \\\\\n 1 & 8 \\\\\n -3 & -1 \\\\\n 7 & -3 \\\\\n -1 & 8 \\\\\n -5 & 9 \\\\\n -8 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, 10],\n [1, 8],\n [-3, -1],\n [7, -3],\n [-1, 8],\n [-5, 9],\n [-8, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{37}{16} & -\\frac{61}{8} & 1 \\\\\n -\\frac{99}{16} & \\frac{17}{8} & -5 \\\\\n -\\frac{141}{16} & -\\frac{119}{16} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{95 x^2}{16}+\\frac{4095 x}{64}-\\frac{3365}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/16), -(61/8), 1],\n [-(99/16), (17/8), -5],\n [-(141/16), -(119/16), (3/2)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{25}{16}, -\\frac{15}{32}}$ to the line $-\\frac{97 x}{32}+\\frac{17 y}{16}+\\frac{1}{2}=0$.", - "Output Answer": [ - "$\\frac{303}{2 \\sqrt{10565}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (25/16), -(15/32)\nline = Poly(-((97*x)/32)+((17*y)/16)+(1/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & -1 \\\\\n 6 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1],\n [6, -2]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -1 & -2 \\\\\n 2 & 0 \\\\\n -2 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & -2 & 1 & 1 \\\\\n 2 & 3 & 2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -6 & -4 & -5 & 3 \\\\\n 4 & -4 & 2 & 2 \\\\\n -8 & -2 & -6 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2],\n [2, 0],\n [-2, -2]])\nb = np.array([\n [2, -2, 1, 1],\n [2, 3, 2, -2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{26}{25} \\\\\n -\\frac{493}{100} \\\\\n -\\frac{753}{100} \\\\\n -\\frac{13}{25} \\\\\n -\\frac{25}{4} \\\\\n \\frac{257}{50} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{753}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/25)],\n [-(493/100)],\n [-(753/100)],\n [-(13/25)],\n [-(25/4)],\n [(257/50)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 3 & -9 & 2 & 5 \\\\\n 9 & 2 & 7 & -5 \\\\\n -9 & -8 & 8 & 7 \\\\\n 8 & -3 & 7 & 2 \\\\\n -4 & 4 & 8 & 4 \\\\\n -2 & 3 & -1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, -9, 2, 5],\n [9, 2, 7, -5],\n [-9, -8, 8, 7],\n [8, -3, 7, 2],\n [-4, 4, 8, 4],\n [-2, 3, -1, -3]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & 5 & -3 \\\\\n -5 & 4 & 3 \\\\\n 2 & -3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$45$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 5, -3],\n [-5, 4, 3],\n [2, -3, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${5, \\frac{14}{3}}$ to the line $\\frac{10 x}{3}-\\frac{14 y}{3}+\\frac{2}{3}=0$.", - "Output Answer": [ - "$\\frac{10 \\sqrt{\\frac{2}{37}}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 5, (14/3)\nline = Poly(((10*x)/3)-((14*y)/3)+(2/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -9 & 3 & 0 & 8 \\\\\n -3 & 0 & -7 & 5 \\\\\n -3 & 8 & -2 & -5 \\\\\n 5 & -1 & 1 & 4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 1 & -7 & -2 & 7 \\\\\n -5 & 6 & -2 & -3 \\\\\n 4 & -5 & -8 & 6 \\\\\n 3 & -7 & 6 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -10 & 10 & 2 & 1 \\\\\n 2 & -6 & -5 & 8 \\\\\n -7 & 13 & 6 & -11 \\\\\n 2 & 6 & -5 & 13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 3, 0, 8],\n [-3, 0, -7, 5],\n [-3, 8, -2, -5],\n [5, -1, 1, 4]])\nb = np.array([\n [1, -7, -2, 7],\n [-5, 6, -2, -3],\n [4, -5, -8, 6],\n [3, -7, 6, -9]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{17}{2} & -2 & 0 \\\\\n \\frac{22}{3} & 9 & -\\frac{28}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/2), -2, 0],\n [(22/3), 9, -(28/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n \\frac{4}{3} \\\\\n 2 \\\\\n -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{6}{\\sqrt{113}} \\\\\n \\frac{4}{\\sqrt{113}} \\\\\n \\frac{6}{\\sqrt{113}} \\\\\n -\\frac{5}{\\sqrt{113}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [(4/3)],\n [2],\n [-(5/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & -3 & -3 \\\\\n -3 & 3 & 0 \\\\\n 3 & 0 & 1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 17 & -21 & -3 \\\\\n -21 & 72 & 27 \\\\\n 3 & -27 & -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -3, -3],\n [-3, 3, 0],\n [3, 0, 1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n \\sqrt{5} \\\\\n \\sqrt{5} \\\\\n -2 \\sqrt{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\sqrt{5} \\\\\n \\sqrt{5} \\\\\n \\sqrt{5} \\\\\n -2 \\sqrt{5} \\\\\n -\\sqrt{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-2*math.sqrt(5)],\n [4*math.sqrt(5)],\n [math.sqrt(5)],\n [math.sqrt(5)],\n [-2*math.sqrt(5)]])\nb = np.array([\n [-3*math.sqrt(5)],\n [math.sqrt(5)],\n [math.sqrt(5)],\n [-2*math.sqrt(5)],\n [-math.sqrt(5)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{3 \\pi }{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [-1],\n [-1],\n [0],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [1],\n [1],\n [-1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & -2 \\\\\n -1 & 1 \\\\\n -1 & 2 \\\\\n 1 & 2 \\\\\n -1 & -1 \\\\\n -2 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.61 \\\\\n 1.02 \\\\\n 2.18 \\\\\n -1.46 \\\\\n -0.28 \\\\\n 2.7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.374 \\\\\n 0.005 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2],\n [-1, 1],\n [-1, 2],\n [1, 2],\n [-1, -1],\n [-2, 3]])\nb = np.array([\n [2.61],\n [1.02],\n [2.18],\n [-1.46],\n [-0.28],\n [2.7]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{13}{6} & -\\frac{8}{3} & -\\frac{20}{3} & 5 \\\\\n \\frac{25}{6} & -4 & \\frac{29}{6} & -\\frac{7}{3} \\\\\n -\\frac{5}{3} & \\frac{14}{3} & -3 & -\\frac{8}{3} \\\\\n \\frac{1}{3} & \\frac{22}{3} & \\frac{19}{2} & -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{13}{2} & -\\frac{14}{3} & -\\frac{17}{3} & -\\frac{19}{6} \\\\\n -\\frac{19}{6} & \\frac{43}{6} & 0 & 2 \\\\\n -\\frac{17}{2} & \\frac{19}{3} & -\\frac{29}{3} & -\\frac{7}{3} \\\\\n -\\frac{19}{6} & 7 & \\frac{7}{3} & \\frac{7}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{26}{3} & -\\frac{22}{3} & -\\frac{37}{3} & \\frac{11}{6} \\\\\n 1 & \\frac{19}{6} & \\frac{29}{6} & -\\frac{1}{3} \\\\\n -\\frac{61}{6} & 11 & -\\frac{38}{3} & -5 \\\\\n -\\frac{17}{6} & \\frac{43}{3} & \\frac{71}{6} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/6), -(8/3), -(20/3), 5],\n [(25/6), -4, (29/6), -(7/3)],\n [-(5/3), (14/3), -3, -(8/3)],\n [(1/3), (22/3), (19/2), -(5/3)]])\nb = np.array([\n [-(13/2), -(14/3), -(17/3), -(19/6)],\n [-(19/6), (43/6), 0, 2],\n [-(17/2), (19/3), -(29/3), -(7/3)],\n [-(19/6), 7, (7/3), (7/6)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{55}{9} & -4 \\\\\n 8 & \\frac{5}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{40 x}{9}+\\frac{589}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(55/9), -4],\n [8, (5/3)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 8 & 4 & 6 & -1 \\\\\n -3 & 0 & 8 & 8 \\\\\n -2 & 8 & 5 & -7 \\\\\n 10 & 9 & -1 & 2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -5 & -1 & 7 & 2 \\\\\n -7 & 8 & -9 & 3 \\\\\n 3 & -9 & 5 & 3 \\\\\n -9 & 5 & 9 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 13 & 5 & -1 & -3 \\\\\n 4 & -8 & 17 & 5 \\\\\n -5 & 17 & 0 & -10 \\\\\n 19 & 4 & -10 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 4, 6, -1],\n [-3, 0, 8, 8],\n [-2, 8, 5, -7],\n [10, 9, -1, 2]])\nb = np.array([\n [-5, -1, 7, 2],\n [-7, 8, -9, 3],\n [3, -9, 5, 3],\n [-9, 5, 9, 3]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -5 & -2 & 8 & 9 \\\\\n -5 & 5 & 4 & -8 \\\\\n 10 & 1 & -7 & 10 \\\\\n 7 & -5 & 3 & 7 \\\\\n 3 & 8 & -6 & -1 \\\\\n -6 & -5 & 7 & -9 \\\\\n -10 & 7 & -7 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, -2, 8, 9],\n [-5, 5, 4, -8],\n [10, 1, -7, 10],\n [7, -5, 3, 7],\n [3, 8, -6, -1],\n [-6, -5, 7, -9],\n [-10, 7, -7, 1]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -8 & -\\frac{25}{6} & -\\frac{1}{2} & -\\frac{29}{3} \\\\\n -\\frac{47}{6} & 9 & \\frac{35}{6} & \\frac{37}{6} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n \\frac{25}{3} & \\frac{47}{6} & \\frac{11}{3} & \\frac{11}{2} \\\\\n -\\frac{17}{6} & \\frac{17}{2} & -\\frac{8}{3} & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{49}{3} & -12 & -\\frac{25}{6} & -\\frac{91}{6} \\\\\n -5 & \\frac{1}{2} & \\frac{17}{2} & \\frac{79}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -(25/6), -(1/2), -(29/3)],\n [-(47/6), 9, (35/6), (37/6)]])\nb = np.array([\n [(25/3), (47/6), (11/3), (11/2)],\n [-(17/6), (17/2), -(8/3), -7]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 5 & -10 \\\\\n 3 & 10 \\\\\n 2 & -6 \\\\\n -5 & -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -9 & 7 \\\\\n -4 & -1 \\\\\n -6 & 9 \\\\\n -2 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -4 & -3 \\\\\n -1 & 9 \\\\\n -4 & 3 \\\\\n -7 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -10],\n [3, 10],\n [2, -6],\n [-5, -8]])\nb = np.array([\n [-9, 7],\n [-4, -1],\n [-6, 9],\n [-2, 9]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n \\frac{11}{5} & \\frac{1}{5} & -\\frac{3}{5} & \\frac{2}{5} \\\\\n \\frac{12}{5} & 1 & -1 & \\frac{11}{5} \\\\\n -\\frac{3}{5} & \\frac{11}{5} & -\\frac{7}{5} & \\frac{4}{5} \\\\\n \\frac{11}{5} & -\\frac{7}{5} & -\\frac{14}{5} & \\frac{12}{5} \\\\\n \\frac{2}{5} & -\\frac{3}{5} & \\frac{14}{5} & \\frac{2}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{12}{5} & 0 & \\frac{7}{5} & -\\frac{6}{5} \\\\\n \\frac{8}{5} & -\\frac{13}{5} & \\frac{14}{5} & -3 \\\\\n -\\frac{2}{5} & -\\frac{12}{5} & \\frac{2}{5} & -\\frac{3}{5} \\\\\n \\frac{13}{5} & \\frac{11}{5} & \\frac{7}{5} & \\frac{11}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{92}{25} & \\frac{9}{5} & \\frac{99}{25} & -2 \\\\\n \\frac{49}{25} & \\frac{116}{25} & \\frac{221}{25} & -\\frac{11}{25} \\\\\n \\frac{38}{5} & -\\frac{3}{5} & \\frac{147}{25} & -\\frac{82}{25} \\\\\n -\\frac{4}{25} & \\frac{391}{25} & \\frac{7}{5} & \\frac{213}{25} \\\\\n -2 & -\\frac{107}{25} & \\frac{14}{25} & \\frac{13}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/5), (1/5), -(3/5), (2/5)],\n [(12/5), 1, -1, (11/5)],\n [-(3/5), (11/5), -(7/5), (4/5)],\n [(11/5), -(7/5), -(14/5), (12/5)],\n [(2/5), -(3/5), (14/5), (2/5)]])\nb = np.array([\n [-(12/5), 0, (7/5), -(6/5)],\n [(8/5), -(13/5), (14/5), -3],\n [-(2/5), -(12/5), (2/5), -(3/5)],\n [(13/5), (11/5), (7/5), (11/5)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & -2 \\\\\n -3 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{-\\sqrt{\\frac{2}{3}},1\\right\\}, \\left\\{\\sqrt{\\frac{2}{3}},1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -2],\n [-3, -8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & -8 \\\\\n 1 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+x-4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -8],\n [1, 3]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{10}{7}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 10 & 8 \\\\\n -2 & 5 \\\\\n 2 & 5 \\\\\n 2 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{100}{7} & -\\frac{80}{7} \\\\\n \\frac{20}{7} & -\\frac{50}{7} \\\\\n -\\frac{20}{7} & -\\frac{50}{7} \\\\\n -\\frac{20}{7} & \\frac{60}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 8],\n [-2, 5],\n [2, 5],\n [2, -6]])\nprint(a * -(10/7))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-4, -3, 0}$ to the plane $-3 x-4 y-4 z-4=0$.", - "Output Answer": [ - "$\\frac{20}{\\sqrt{41}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -4, -3, 0\nplane = Poly(-3*x-4*y-4*z-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{14}{5}, -\\frac{2}{5}, -\\frac{17}{5}}$ to the plane $-\\frac{7 x}{5}-3 y+\\frac{17 z}{5}+\\frac{16}{5}=0$.", - "Output Answer": [ - "$\\frac{277}{5 \\sqrt{563}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (14/5), -(2/5), -(17/5)\nplane = Poly(-((7*x)/5)-3*y+((17*z)/5)+(16/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -7 & -9 & 3 \\\\\n 9 & 9 & 4 \\\\\n -4 & 9 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.183,0.724,1.\\}, \\{0.209\\, -1.132 i,-0.754+0.368 i,1.\\}, \\{0.209\\, +1.132 i,-0.754-0.368 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -9, 3],\n [9, 9, 4],\n [-4, 9, 5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n \\frac{17}{3} \\\\\n -1 \\\\\n \\frac{16}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$17$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [(17/3)],\n [-1],\n [(16/3)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{43}{10} & -\\frac{91}{10} & \\frac{13}{2} \\\\\n -\\frac{8}{5} & \\frac{14}{5} & -\\frac{39}{5} \\\\\n -\\frac{81}{10} & \\frac{9}{5} & -\\frac{44}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{17 x^2}{10}-\\frac{169 x}{100}-\\frac{36369}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(43/10), -(91/10), (13/2)],\n [-(8/5), (14/5), -(39/5)],\n [-(81/10), (9/5), -(44/5)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{1,2,3\\}, \\{-2,-1,3\\}, \\{2,0,2\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{14}},\\sqrt{\\frac{2}{7}},\\frac{3}{\\sqrt{14}}\\right\\}, \\left\\{-\\frac{11}{\\sqrt{266}},-4 \\sqrt{\\frac{2}{133}},\\frac{9}{\\sqrt{266}}\\right\\}, \\left\\{\\frac{3}{\\sqrt{19}},-\\frac{3}{\\sqrt{19}},\\frac{1}{\\sqrt{19}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((1, 2, 3), (-2, -1, 3), (2, 0, 2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & 1 & -2 \\\\\n 2 & -3 & -1 \\\\\n 2 & 3 & -3 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & -10 & 7 \\\\\n -10 & 8 & 2 \\\\\n -2 & -16 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, -2],\n [2, -3, -1],\n [2, 3, -3]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -9 \\\\\n 5 \\\\\n 8 \\\\\n 7 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$40$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-9],\n [5],\n [8],\n [7],\n [-6]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{39}{10} & \\frac{13}{5} & -\\frac{18}{5} \\\\\n \\frac{1}{2} & \\frac{29}{10} & \\frac{22}{5} \\\\\n -\\frac{7}{10} & \\frac{3}{5} & -\\frac{7}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{3350}{5777} & \\frac{740}{5777} & \\frac{10940}{5777} \\\\\n -\\frac{1190}{5777} & \\frac{1470}{5777} & \\frac{7680}{5777} \\\\\n \\frac{1165}{5777} & \\frac{260}{5777} & -\\frac{6305}{5777} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(39/10), (13/5), -(18/5)],\n [(1/2), (29/10), (22/5)],\n [-(7/10), (3/5), -(7/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2 & 0 & 0 \\\\\n 1 & -1 & -1 \\\\\n 0 & -2 & 1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 4 & 0 & 0 \\\\\n -3 & 3 & 0 \\\\\n -2 & 0 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, 0],\n [1, -1, -1],\n [0, -2, 1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{14}{3} & -9 & \\frac{79}{9} \\\\\n -\\frac{46}{9} & \\frac{28}{9} & -\\frac{8}{3} \\\\\n -\\frac{53}{9} & \\frac{62}{9} & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{43 x^2}{9}-\\frac{1235 x}{81}-\\frac{2954}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/3), -9, (79/9)],\n [-(46/9), (28/9), -(8/3)],\n [-(53/9), (62/9), -3]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & -5 \\\\\n 9 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{9} i \\left(2 \\sqrt{5}-5 i\\right),1\\right\\}, \\left\\{-\\frac{1}{9} i \\left(2 \\sqrt{5}+5 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -5],\n [9, -1]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & -7 \\\\\n -6 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+5 x-66$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -7],\n [-6, -8]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 0 & \\frac{6}{7} & \\frac{16}{7} \\\\\n \\frac{25}{7} & \\frac{19}{7} & -\\frac{29}{7} \\\\\n -\\frac{27}{7} & \\frac{5}{7} & \\frac{17}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{819}{3089} & -\\frac{77}{6178} & -\\frac{1673}{6178} \\\\\n \\frac{1253}{6178} & \\frac{756}{3089} & \\frac{700}{3089} \\\\\n \\frac{2233}{6178} & -\\frac{567}{6178} & -\\frac{525}{6178} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, (6/7), (16/7)],\n [(25/7), (19/7), -(29/7)],\n [-(27/7), (5/7), (17/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{26}{3} \\\\\n -\\frac{7}{3} \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{8}{3} \\\\\n -\\frac{1}{3} \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{43}{3} \\\\\n \\frac{148}{3} \\\\\n \\frac{82}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(26/3)],\n [-(7/3)],\n [-1]])\nb = np.array([\n [(8/3)],\n [-(1/3)],\n [6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{15}{2} & -\\frac{13}{2} \\\\\n -\\frac{5}{2} & \\frac{15}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(15-\\sqrt{65}\\right),\\frac{1}{2} \\left(15+\\sqrt{65}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/2), -(13/2)],\n [-(5/2), (15/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -8 & -8 & -3 \\\\\n 10 & -8 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{16.,-43.,72.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-8, -8, -3],\n [10, -8, -7]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{6} & \\frac{19}{2} & -\\frac{11}{6} \\\\\n -9 & \\frac{25}{6} & \\frac{22}{3} \\\\\n -\\frac{59}{6} & -1 & \\frac{1}{3} \\\\\n 0 & \\frac{19}{2} & -\\frac{43}{6} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{43}{6} & -3 & \\frac{1}{6} \\\\\n -\\frac{7}{6} & \\frac{5}{6} & -\\frac{8}{3} \\\\\n \\frac{1}{3} & -2 & 9 \\\\\n -9 & -\\frac{31}{6} & -\\frac{19}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{22}{3} & \\frac{25}{2} & -2 \\\\\n -\\frac{47}{6} & \\frac{10}{3} & 10 \\\\\n -\\frac{61}{6} & 1 & -\\frac{26}{3} \\\\\n 9 & \\frac{44}{3} & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/6), (19/2), -(11/6)],\n [-9, (25/6), (22/3)],\n [-(59/6), -1, (1/3)],\n [0, (19/2), -(43/6)]])\nb = np.array([\n [-(43/6), -3, (1/6)],\n [-(7/6), (5/6), -(8/3)],\n [(1/3), -2, 9],\n [-9, -(31/6), -(19/6)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 8 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -4 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -44 \\\\\n -9 \\\\\n 60 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [8],\n [-1]])\nb = np.array([\n [-6],\n [-4],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & 2 & 8 \\\\\n -6 & 7 & -7 \\\\\n 0 & 6 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{1.119,7.44\\, -7.68 i,7.44\\, +7.68 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 2, 8],\n [-6, 7, -7],\n [0, 6, 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & 0 \\\\\n 2 & -2 \\\\\n -3 & -2 \\\\\n 1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.84 \\\\\n 2.99 \\\\\n 0.48 \\\\\n -0.42 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.624 \\\\\n -0.856 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0],\n [2, -2],\n [-3, -2],\n [1, 2]])\nb = np.array([\n [1.84],\n [2.99],\n [0.48],\n [-0.42]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{9}{5}, \\frac{11}{5}, -\\frac{16}{5}}$ to the plane $3 x-\\frac{16 y}{5}-z+\\frac{1}{5}=0$.", - "Output Answer": [ - "$\\frac{113 \\sqrt{\\frac{2}{253}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(9/5), (11/5), -(16/5)\nplane = Poly(3*x-((16*y)/5)-z+(1/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 2 \\\\\n 3 \\\\\n -2 \\\\\n -4 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 3 \\\\\n -8 \\\\\n -9 \\\\\n -4 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$71$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [2],\n [3],\n [-2],\n [-4],\n [5]])\nb = np.array([\n [8],\n [3],\n [-8],\n [-9],\n [-4],\n [3]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{7}{5}, -\\frac{23}{5}}$ to the line $\\frac{12 x}{5}-\\frac{6 y}{5}+\\frac{11}{5}=0$.", - "Output Answer": [ - "$\\frac{277}{30 \\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (7/5), -(23/5)\nline = Poly(((12*x)/5)-((6*y)/5)+(11/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{4} & \\frac{5}{4} & 5 \\\\\n \\frac{1}{2} & 5 & \\frac{3}{4} \\\\\n 7 & \\frac{11}{2} & -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.719,-0.023,1.\\}, \\{0.643,1.41,1.\\}, \\{1.068,-0.24,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/4), (5/4), 5],\n [(1/2), 5, (3/4)],\n [7, (11/2), -(13/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{20}{3} \\\\\n -\\frac{7}{3} \\\\\n \\frac{40}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{14}{9} \\\\\n -\\frac{76}{9} \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{2662}{81} \\\\\n \\frac{520}{81} \\\\\n \\frac{158}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/3)],\n [-(7/3)],\n [(40/9)]])\nb = np.array([\n [-(14/9)],\n [-(76/9)],\n [2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & \\frac{9}{2} \\\\\n -4 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-17 x+90$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, (9/2)],\n [-4, 8]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4 \\sqrt{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [2]])\nb = np.array([\n [7],\n [6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -4 & 4 & -3 \\\\\n 1 & -3 & 5 \\\\\n -2 & 1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & \\frac{3}{5} & -\\frac{11}{5} \\\\\n 2 & \\frac{6}{5} & -\\frac{17}{5} \\\\\n 1 & \\frac{4}{5} & -\\frac{8}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 4, -3],\n [1, -3, 5],\n [-2, 1, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{79}{16} & -\\frac{47}{16} & -\\frac{19}{2} \\\\\n -\\frac{147}{16} & \\frac{25}{16} & \\frac{53}{16} \\\\\n -\\frac{137}{16} & -10 & -2 \\\\\n \\frac{83}{16} & -\\frac{43}{8} & -\\frac{83}{16} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{85}{16} & -\\frac{41}{16} & -\\frac{87}{16} \\\\\n -\\frac{53}{16} & -8 & -\\frac{59}{8} \\\\\n -\\frac{63}{16} & \\frac{59}{16} & -\\frac{59}{8} \\\\\n -1 & -\\frac{5}{2} & -\\frac{17}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{41}{4} & -\\frac{3}{8} & -\\frac{65}{16} \\\\\n -\\frac{47}{8} & \\frac{153}{16} & \\frac{171}{16} \\\\\n -\\frac{37}{8} & -\\frac{219}{16} & \\frac{43}{8} \\\\\n \\frac{99}{16} & -\\frac{23}{8} & -\\frac{15}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(79/16), -(47/16), -(19/2)],\n [-(147/16), (25/16), (53/16)],\n [-(137/16), -10, -2],\n [(83/16), -(43/8), -(83/16)]])\nb = np.array([\n [(85/16), -(41/16), -(87/16)],\n [-(53/16), -8, -(59/8)],\n [-(63/16), (59/16), -(59/8)],\n [-1, -(5/2), -(17/4)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{3} & -\\frac{1}{3} \\\\\n \\frac{2}{3} & \\frac{14}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{68}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/3), -(1/3)],\n [(2/3), (14/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{59}{20} \\\\\n \\frac{633}{100} \\\\\n -\\frac{161}{100} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{91}{50} \\\\\n \\frac{89}{10} \\\\\n -\\frac{351}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{78893}{10000} \\\\\n -\\frac{132847}{10000} \\\\\n -\\frac{94439}{2500} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(59/20)],\n [(633/100)],\n [-(161/100)]])\nb = np.array([\n [(91/50)],\n [(89/10)],\n [-(351/100)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{1}{2},\\frac{11}{4},-\\frac{7}{4}\\right\\}, \\left\\{\\frac{5}{4},\\frac{3}{2},1\\right\\}, \\left\\{\\frac{7}{4},-\\frac{5}{4},\\frac{1}{2}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\sqrt{\\frac{2}{87}},\\frac{11}{\\sqrt{174}},-\\frac{7}{\\sqrt{174}}\\right\\}, \\left\\{\\frac{3}{\\sqrt{29}},\\frac{2}{\\sqrt{29}},\\frac{4}{\\sqrt{29}}\\right\\}, \\left\\{\\sqrt{\\frac{2}{3}},-\\frac{1}{\\sqrt{6}},-\\frac{1}{\\sqrt{6}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack((((1/2), (11/4), -(7/4)), ((5/4), (3/2), 1), ((7/4), -(5/4), (1/2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -3 \\\\\n 3 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -8 \\\\\n 3 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{203}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-3],\n [3],\n [-5]])\nb = np.array([\n [3],\n [-8],\n [3],\n [8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -3 & 6 \\\\\n -3 & 4 \\\\\n 6 & 9 \\\\\n 8 & -1 \\\\\n -4 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 6],\n [-3, 4],\n [6, 9],\n [8, -1],\n [-4, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-48$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [6*math.sqrt(2)]])\nb = np.array([\n [-4*math.sqrt(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,0,4\\}, \\{4,3,0\\}, \\{-1,4,1\\}}$.", - "Output Answer": [ - "$7 x+17 y+18 z-79=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, 0, 4],\n [4, 3, 0],\n [-1, 4, 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{19}{2} & 5 \\\\\n \\frac{13}{2} & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{3,\\frac{29}{2}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/2), 5],\n [(13/2), 8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{6} \\\\\n -1 \\\\\n \\frac{1}{2} \\\\\n \\frac{3}{2} \\\\\n \\frac{5}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n \\frac{2}{3} & \\frac{1}{2} & \\frac{1}{3} & -\\frac{4}{3} & -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -\\frac{11}{9} & -\\frac{11}{12} & -\\frac{11}{18} & \\frac{22}{9} & \\frac{55}{18} \\\\\n -\\frac{2}{3} & -\\frac{1}{2} & -\\frac{1}{3} & \\frac{4}{3} & \\frac{5}{3} \\\\\n \\frac{1}{3} & \\frac{1}{4} & \\frac{1}{6} & -\\frac{2}{3} & -\\frac{5}{6} \\\\\n 1 & \\frac{3}{4} & \\frac{1}{2} & -2 & -\\frac{5}{2} \\\\\n \\frac{5}{3} & \\frac{5}{4} & \\frac{5}{6} & -\\frac{10}{3} & -\\frac{25}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/6)],\n [-1],\n [(1/2)],\n [(3/2)],\n [(5/2)]])\nb = np.array([\n [(2/3), (1/2), (1/3), -(4/3), -(5/3)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{37}{7} \\\\\n \\frac{11}{7} \\\\\n -\\frac{29}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{10}{7} \\\\\n \\frac{51}{7} \\\\\n -\\frac{41}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{2473}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(37/7)],\n [(11/7)],\n [-(29/7)]])\nb = np.array([\n [-(10/7)],\n [(51/7)],\n [-(41/7)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -4 & -4 \\\\\n 5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$36$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -4],\n [5, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -3 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -3 \\\\\n 16 \\\\\n 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-3],\n [3]])\nb = np.array([\n [2],\n [-1],\n [2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3.215 \\\\\n 0.024 \\\\\n -5.7 \\\\\n 5.593 \\\\\n -8.494 \\\\\n -0.804 \\\\\n -7.848 \\\\\n 9.162 \\\\\n -3.198 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8.251 \\\\\n 4.949 \\\\\n 9.044 \\\\\n 2.874 \\\\\n -3.475 \\\\\n -7.334 \\\\\n 8.626 \\\\\n -4.051 \\\\\n 4.122 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$29.0135$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3.215],\n [0.024],\n [-5.7],\n [5.593],\n [-8.494],\n [-0.804],\n [-7.848],\n [9.162],\n [-3.198]])\nb = np.array([\n [-8.251],\n [4.949],\n [9.044],\n [2.874],\n [-3.475],\n [-7.334],\n [8.626],\n [-4.051],\n [4.122]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{7} \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/7)],\n [0]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -1 & 3 \\\\\n 3 & 6 \\\\\n -7 & -8 \\\\\n 10 & -5 \\\\\n 4 & 4 \\\\\n 4 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-1, 3],\n [3, 6],\n [-7, -8],\n [10, -5],\n [4, 4],\n [4, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & 1 & 2 \\\\\n -1 & -2 & -2 \\\\\n -3 & -3 & 3 \\\\\n 1 & 1 & 3 \\\\\n 2 & 1 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.01 \\\\\n 1.54 \\\\\n 2.92 \\\\\n -1.34 \\\\\n -0.17 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.711 \\\\\n -1.513 \\\\\n 0.071 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1, 2],\n [-1, -2, -2],\n [-3, -3, 3],\n [1, 1, 3],\n [2, 1, -3]])\nb = np.array([\n [1.01],\n [1.54],\n [2.92],\n [-1.34],\n [-0.17]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{67}{7} & -\\frac{43}{7} & \\frac{40}{7} \\\\\n -\\frac{3}{7} & \\frac{46}{7} & \\frac{45}{7} \\\\\n \\frac{67}{7} & -\\frac{43}{7} & \\frac{22}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{x^2}{7}+\\frac{4418 x}{49}-\\frac{448052}{343}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(67/7), -(43/7), (40/7)],\n [-(3/7), (46/7), (45/7)],\n [(67/7), -(43/7), (22/7)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n \\frac{17}{7} & \\frac{13}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{16}{7} \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{454}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/7), (13/7)]])\nb = np.array([\n [-(16/7)],\n [-2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 5 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -1 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -17 \\\\\n 26 \\\\\n -15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [5],\n [3]])\nb = np.array([\n [2],\n [-1],\n [-4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -8 \\\\\n -2 \\\\\n -3 \\\\\n 0 \\\\\n -7 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 6 \\\\\n 1 \\\\\n 5 \\\\\n -6 \\\\\n 9 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-144$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-8],\n [-2],\n [-3],\n [0],\n [-7],\n [2]])\nb = np.array([\n [-4],\n [6],\n [1],\n [5],\n [-6],\n [9],\n [-4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & 1 \\\\\n -8 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+15 x+62$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 1],\n [-8, -9]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-3,\\frac{7}{3},-3\\right\\}, \\left\\{\\frac{11}{3},3,\\frac{10}{3}\\right\\}, \\{1,4,-4\\}}$.", - "Output Answer": [ - "$101 x-288 y-76 z+747=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, (7/3), -3],\n [(11/3), 3, (10/3)],\n [1, 4, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\pi \\\\\n -3 \\pi \\\\\n -\\pi \\\\\n 3 \\pi \\\\\n 0 \\\\\n \\pi \\\\\n \\pi \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\pi \\\\\n \\pi \\\\\n 3 \\pi \\\\\n -2 \\pi \\\\\n 0 \\\\\n 0 \\\\\n -3 \\pi \\\\\n 3 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{119} \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-3*math.pi],\n [-3*math.pi],\n [-math.pi],\n [3*math.pi],\n [0],\n [math.pi],\n [math.pi],\n [0]])\nb = np.array([\n [3*math.pi],\n [math.pi],\n [3*math.pi],\n [-2*math.pi],\n [0],\n [0],\n [-3*math.pi],\n [3*math.pi]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{28}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{31}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1]])\nb = np.array([\n [-(28/3)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 7 & 6 & -7 \\\\\n -2 & -5 & -8 \\\\\n -3 & 4 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-3 x^2+22 x+644$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 6, -7],\n [-2, -5, -8],\n [-3, 4, -5]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{34}{7} \\\\\n -\\frac{36}{7} \\\\\n \\frac{40}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{68}{7} \\\\\n -\\frac{41}{7} \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{2648}{49} \\\\\n \\frac{3672}{49} \\\\\n \\frac{1054}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(34/7)],\n [-(36/7)],\n [(40/7)]])\nb = np.array([\n [(68/7)],\n [-(41/7)],\n [-4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{8}{7} \\\\\n \\frac{66}{7} \\\\\n \\frac{17}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -7 \\\\\n -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{541}{7} \\\\\n -\\frac{39}{7} \\\\\n 58 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(8/7)],\n [(66/7)],\n [(17/7)]])\nb = np.array([\n [-7],\n [-7],\n [-10]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -2 \\\\\n 0 \\\\\n -2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 1 \\\\\n -2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{3}{23},\\frac{1}{23},-\\frac{2}{23},\\frac{3}{23}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-2],\n [0],\n [-2]]).squeeze()\nb = np.array([\n [3],\n [1],\n [-2],\n [3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 0 & -5 & 0 \\\\\n -4 & -5 & 6 \\\\\n -4 & 1 & 0 \\\\\n -10 & -1 & 8 \\\\\n -2 & -6 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, -5, 0],\n [-4, -5, 6],\n [-4, 1, 0],\n [-10, -1, 8],\n [-2, -6, -10]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{43}{8} & -\\frac{1}{8} \\\\\n \\frac{21}{8} & \\frac{1}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{11 x}{2}+1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(43/8), -(1/8)],\n [(21/8), (1/8)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -\\frac{59}{6} \\\\\n -\\frac{16}{3} \\\\\n \\frac{20}{3} \\\\\n \\frac{25}{6} \\\\\n \\frac{3}{2} \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$35$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-(59/6)],\n [-(16/3)],\n [(20/3)],\n [(25/6)],\n [(3/2)],\n [(1/2)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{49}{9} & \\frac{23}{3} & -\\frac{20}{9} \\\\\n -\\frac{1}{3} & \\frac{29}{9} & -\\frac{23}{3} \\\\\n -\\frac{17}{9} & -\\frac{50}{9} & -\\frac{5}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{25 x^2}{9}+\\frac{4904 x}{81}+\\frac{243197}{729}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(49/9), (23/3), -(20/9)],\n [-(1/3), (29/9), -(23/3)],\n [-(17/9), -(50/9), -(5/9)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 4 \\\\\n 0 \\\\\n 7 \\\\\n -4 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{106}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [4],\n [0],\n [7],\n [-4],\n [3]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{19}{5}, \\frac{43}{10}}$ to the line $\\frac{47 x}{10}+\\frac{13 y}{10}-\\frac{12}{5}=0$.", - "Output Answer": [ - "$\\frac{421}{2 \\sqrt{2378}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (19/5), (43/10)\nline = Poly(((47*x)/10)+((13*y)/10)-(12/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -6 \\\\\n -3 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$16$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-6],\n [-3],\n [6]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 1 & -2 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & 2 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1]])\nb = np.array([\n [1, -2, 3]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -7 & -4 & -1 & 1 & -7 & -5 \\\\\n -4 & -7 & 10 & -2 & 5 & 3 \\\\\n -2 & 7 & 2 & 9 & -3 & 9 \\\\\n -3 & 6 & 7 & 1 & 6 & 2 \\\\\n -6 & 6 & 5 & 7 & 1 & 8 \\\\\n -10 & -5 & 6 & 0 & 10 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, -4, -1, 1, -7, -5],\n [-4, -7, 10, -2, 5, 3],\n [-2, 7, 2, 9, -3, 9],\n [-3, 6, 7, 1, 6, 2],\n [-6, 6, 5, 7, 1, 8],\n [-10, -5, 6, 0, 10, 2]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{64}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 2 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{5}{32} \\\\\n \\frac{5}{32} \\\\\n \\frac{5}{64} \\\\\n \\frac{5}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [2],\n [1],\n [1]])\nprint(a * (5/64))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{3} & -1 \\\\\n \\frac{10}{3} & -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{37}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/3), -1],\n [(10/3), -(7/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 8 & -2 & -3 \\\\\n 7 & 3 & -2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -1 & -1 & 7 \\\\\n 7 & 5 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 9 & -1 & -10 \\\\\n 0 & -2 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -2, -3],\n [7, 3, -2]])\nb = np.array([\n [-1, -1, 7],\n [7, 5, -4]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{4} \\\\\n \\frac{9}{4} \\\\\n \\frac{3}{4} \\\\\n -\\frac{1}{4} \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{2 \\sqrt{5}} \\\\\n \\frac{3}{2 \\sqrt{5}} \\\\\n \\frac{1}{2 \\sqrt{5}} \\\\\n -\\frac{1}{6 \\sqrt{5}} \\\\\n -\\frac{4}{3 \\sqrt{5}} \\\\\n \\frac{2}{3 \\sqrt{5}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/4)],\n [(9/4)],\n [(3/4)],\n [-(1/4)],\n [-2],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{14}{5} & -\\frac{11}{5} & \\frac{36}{5} \\\\\n -\\frac{39}{10} & -\\frac{3}{5} & \\frac{46}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{71}{10} & -\\frac{8}{5} & \\frac{81}{10} \\\\\n \\frac{23}{10} & -\\frac{44}{5} & \\frac{9}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{99}{10} & -\\frac{19}{5} & \\frac{153}{10} \\\\\n -\\frac{8}{5} & -\\frac{47}{5} & \\frac{101}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(14/5), -(11/5), (36/5)],\n [-(39/10), -(3/5), (46/5)]])\nb = np.array([\n [-(71/10), -(8/5), (81/10)],\n [(23/10), -(44/5), (9/10)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-2$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & 1 & -5 & -2 \\\\\n 8 & 2 & -4 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 2 & -2 & 10 & 4 \\\\\n -16 & -4 & 8 & 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, -5, -2],\n [8, 2, -4, -6]])\nprint(a * -2)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -7 & -\\frac{35}{6} & \\frac{8}{3} & 5 \\\\\n \\frac{23}{3} & \\frac{17}{6} & \\frac{11}{2} & \\frac{15}{2} \\\\\n -\\frac{43}{6} & 9 & -\\frac{19}{2} & \\frac{19}{6} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{14}{3} & \\frac{19}{2} & -\\frac{11}{2} & \\frac{47}{6} \\\\\n -\\frac{13}{6} & -\\frac{29}{3} & -\\frac{19}{3} & -\\frac{22}{3} \\\\\n -\\frac{22}{3} & \\frac{28}{3} & -5 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{7}{3} & -\\frac{46}{3} & \\frac{49}{6} & -\\frac{17}{6} \\\\\n \\frac{59}{6} & \\frac{25}{2} & \\frac{71}{6} & \\frac{89}{6} \\\\\n \\frac{1}{6} & -\\frac{1}{3} & -\\frac{9}{2} & \\frac{13}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -(35/6), (8/3), 5],\n [(23/3), (17/6), (11/2), (15/2)],\n [-(43/6), 9, -(19/2), (19/6)]])\nb = np.array([\n [-(14/3), (19/2), -(11/2), (47/6)],\n [-(13/6), -(29/3), -(19/3), -(22/3)],\n [-(22/3), (28/3), -5, 1]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{22}{3} & -\\frac{17}{3} \\\\\n 0 & \\frac{19}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{19}{3},\\frac{22}{3}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(22/3), -(17/3)],\n [0, (19/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 5 & 1 & 2 \\\\\n 5 & 2 & 3 \\\\\n 2 & -4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 1, 2],\n [5, 2, 3],\n [2, -4, -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -1 & -2 & 0 & -1 & -3 \\\\\n -1 & -2 & -1 & 3 & 0 \\\\\n -1 & 3 & 0 & 1 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 2 & -1 \\\\\n 2 & -1 \\\\\n -3 & 3 \\\\\n -2 & 1 \\\\\n -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -1 & -7 \\\\\n -9 & 3 \\\\\n 2 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, 0, -1, -3],\n [-1, -2, -1, 3, 0],\n [-1, 3, 0, 1, 0]])\nb = np.array([\n [2, -1],\n [2, -1],\n [-3, 3],\n [-2, 1],\n [-1, 3]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -6 & -9 & 9 \\\\\n 7 & -7 & 10 \\\\\n 8 & -1 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6.91-3.737 i,-6.91+3.737 i,9.82\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -9, 9],\n [7, -7, 10],\n [8, -1, 9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 10 & -3 & -6 \\\\\n -6 & 6 & 10 \\\\\n 4 & -1 & -4 \\\\\n 4 & -8 & 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 6 & 3 & 0 \\\\\n -4 & 10 & -6 \\\\\n 8 & -5 & 3 \\\\\n -3 & -4 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 16 & 0 & -6 \\\\\n -10 & 16 & 4 \\\\\n 12 & -6 & -1 \\\\\n 1 & -12 & 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -3, -6],\n [-6, 6, 10],\n [4, -1, -4],\n [4, -8, 7]])\nb = np.array([\n [6, 3, 0],\n [-4, 10, -6],\n [8, -5, 3],\n [-3, -4, 4]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & -1 \\\\\n -3 & 3 \\\\\n 2 & -2 \\\\\n 2 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.13 \\\\\n 2.75 \\\\\n 2.7 \\\\\n -1.5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.75 \\\\\n -0.699 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1],\n [-3, 3],\n [2, -2],\n [2, 0]])\nb = np.array([\n [2.13],\n [2.75],\n [2.7],\n [-1.5]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -\\frac{29}{9} & -\\frac{44}{9} & \\frac{53}{9} & \\frac{2}{3} \\\\\n \\frac{11}{9} & -9 & \\frac{20}{9} & \\frac{71}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/9), -(44/9), (53/9), (2/3)],\n [(11/9), -9, (20/9), (71/9)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{13}{5}, 2}$ to the line $-2 x+\\frac{9 y}{5}-\\frac{4}{5}=0$.", - "Output Answer": [ - "$\\frac{12}{\\sqrt{181}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (13/5), 2\nline = Poly(-2*x+((9*y)/5)-(4/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n -3 & 8 & -6 \\\\\n \\frac{37}{5} & -\\frac{41}{5} & -6 \\\\\n \\frac{23}{5} & \\frac{87}{10} & -\\frac{23}{5} \\\\\n -\\frac{51}{10} & -\\frac{89}{10} & -\\frac{69}{10} \\\\\n -\\frac{46}{5} & \\frac{31}{10} & \\frac{93}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 8, -6],\n [(37/5), -(41/5), -6],\n [(23/5), (87/10), -(23/5)],\n [-(51/10), -(89/10), -(69/10)],\n [-(46/5), (31/10), (93/10)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{2} \\\\\n -4 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{5}{4} \\\\\n -7 \\\\\n -\\frac{33}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{133}{\\sqrt{176514}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2)],\n [-4],\n [1]]).squeeze()\nb = np.array([\n [(5/4)],\n [-7],\n [-(33/4)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(-2 \\sqrt{5}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [1],\n [1],\n [0],\n [0],\n [1],\n [-1]]).squeeze()\nb = np.array([\n [1],\n [0],\n [0],\n [0],\n [-1],\n [-1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -\\frac{11}{8} & -\\frac{3}{2} \\\\\n -\\frac{1}{8} & -\\frac{11}{4} \\\\\n 1 & -\\frac{11}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{11}{4} & \\frac{15}{8} \\\\\n \\frac{5}{2} & \\frac{3}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{32} & -\\frac{237}{64} \\\\\n -\\frac{209}{32} & -\\frac{147}{64} \\\\\n -\\frac{77}{8} & -\\frac{3}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/8), -(3/2)],\n [-(1/8), -(11/4)],\n [1, -(11/4)]])\nb = np.array([\n [-(11/4), (15/8)],\n [(5/2), (3/4)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -10 \\\\\n -8 \\\\\n -4 \\\\\n 1 \\\\\n 1 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 2 \\\\\n 7 \\\\\n 0 \\\\\n -5 \\\\\n -8 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-103$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-10],\n [-8],\n [-4],\n [1],\n [1],\n [-5]])\nb = np.array([\n [2],\n [2],\n [7],\n [0],\n [-5],\n [-8],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -3 & -6 \\\\\n -5 & 5 \\\\\n 3 & 9 \\\\\n 6 & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 7 & -7 \\\\\n 8 & 1 \\\\\n 9 & 8 \\\\\n -9 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 4 & -13 \\\\\n 3 & 6 \\\\\n 12 & 17 \\\\\n -3 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -6],\n [-5, 5],\n [3, 9],\n [6, 3]])\nb = np.array([\n [7, -7],\n [8, 1],\n [9, 8],\n [-9, 0]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{28}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{20}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{560}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(28/3)]])\nb = np.array([\n [-(20/3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 4 & -2 \\\\\n 3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{6} & \\frac{1}{9} \\\\\n -\\frac{1}{6} & \\frac{2}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -2],\n [3, 3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{77}{16} \\\\\n \\frac{121}{16} \\\\\n -\\frac{15}{8} \\\\\n \\frac{5}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{\\frac{10785}{2}}}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(77/16)],\n [(121/16)],\n [-(15/8)],\n [(5/8)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 4 \\\\\n -7 \\\\\n -6 \\\\\n -1 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 7 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-105$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [4],\n [-7],\n [-6],\n [-1],\n [-8]])\nb = np.array([\n [-5],\n [-1],\n [1],\n [1],\n [7],\n [7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{73}{20} & \\frac{38}{5} & \\frac{473}{50} \\\\\n \\frac{891}{100} & \\frac{33}{5} & -\\frac{101}{50} \\\\\n \\frac{819}{100} & -\\frac{353}{50} & -\\frac{92}{25} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{747}{100} & \\frac{449}{100} & \\frac{413}{100} \\\\\n \\frac{377}{100} & -\\frac{127}{25} & \\frac{76}{25} \\\\\n \\frac{287}{50} & -\\frac{217}{100} & \\frac{281}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{278}{25} & \\frac{311}{100} & \\frac{533}{100} \\\\\n \\frac{257}{50} & \\frac{292}{25} & -\\frac{253}{50} \\\\\n \\frac{49}{20} & -\\frac{489}{100} & -\\frac{93}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(73/20), (38/5), (473/50)],\n [(891/100), (33/5), -(101/50)],\n [(819/100), -(353/50), -(92/25)]])\nb = np.array([\n [-(747/100), (449/100), (413/100)],\n [(377/100), -(127/25), (76/25)],\n [(287/50), -(217/100), (281/50)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{8}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -5 \\\\\n -2 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{8} \\\\\n -\\frac{15}{8} \\\\\n -\\frac{3}{4} \\\\\n -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-5],\n [-2],\n [-8]])\nprint(a * (3/8))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -5 & -6 & 9 & 7 & -5 & 8 \\\\\n -4 & -3 & 9 & -6 & 7 & 3 \\\\\n -6 & 8 & -2 & -6 & -10 & 7 \\\\\n 2 & 6 & -8 & 5 & -3 & -1 \\\\\n -5 & 7 & 1 & 4 & -3 & 0 \\\\\n 3 & -9 & 2 & -4 & -5 & -1 \\\\\n -4 & 7 & 4 & -8 & 6 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, -6, 9, 7, -5, 8],\n [-4, -3, 9, -6, 7, 3],\n [-6, 8, -2, -6, -10, 7],\n [2, 6, -8, 5, -3, -1],\n [-5, 7, 1, 4, -3, 0],\n [3, -9, 2, -4, -5, -1],\n [-4, 7, 4, -8, 6, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 7 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -9 \\\\\n -8 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-75$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [7],\n [1],\n [-1]])\nb = np.array([\n [-6],\n [-9],\n [-8],\n [-2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{5} & \\frac{23}{5} & \\frac{4}{5} \\\\\n \\frac{8}{5} & -6 & \\frac{33}{5} \\\\\n \\frac{33}{5} & -\\frac{36}{5} & \\frac{1}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-4.52-6.669 i,-4.52+6.669 i,3.839\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/5), (23/5), (4/5)],\n [(8/5), -6, (33/5)],\n [(33/5), -(36/5), (1/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -2 & -5 & -8 \\\\\n -6 & -7 & 3 \\\\\n 1 & 0 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, -5, -8],\n [-6, -7, 3],\n [1, 0, 3]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n \\frac{11}{7} & \\frac{24}{7} \\\\\n \\frac{68}{7} & -8 \\\\\n \\frac{15}{7} & -\\frac{58}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/7), (24/7)],\n [(68/7), -8],\n [(15/7), -(58/7)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $1$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 6 & -1 \\\\\n 10 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 6 & -1 \\\\\n 10 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -1],\n [10, -4]])\nprint(a * 1)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 0 & 2 & 1 & -1 & 2 \\\\\n -1 & -2 & 3 & -1 & -3 \\\\\n -1 & 2 & -2 & -3 & -1 \\\\\n 1 & 2 & -1 & -3 & 1 \\\\\n 0 & -3 & 2 & 3 & 2 \\\\\n 0 & -3 & 2 & 0 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.94 \\\\\n 2.89 \\\\\n -1.64 \\\\\n 1.91 \\\\\n 2.56 \\\\\n -1.12 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.355 \\\\\n 0.861 \\\\\n 1.556 \\\\\n 0.01 \\\\\n 0.195 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, 1, -1, 2],\n [-1, -2, 3, -1, -3],\n [-1, 2, -2, -3, -1],\n [1, 2, -1, -3, 1],\n [0, -3, 2, 3, 2],\n [0, -3, 2, 0, 0]])\nb = np.array([\n [2.94],\n [2.89],\n [-1.64],\n [1.91],\n [2.56],\n [-1.12]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 1 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{35}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-2],\n [6]])\nb = np.array([\n [10],\n [1],\n [-9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{5}{3},1,-1\\right\\}, \\left\\{\\frac{14}{3},-\\frac{13}{3},\\frac{11}{3}\\right\\}, \\left\\{\\frac{10}{3},-3,-\\frac{11}{3}\\right\\}}$.", - "Output Answer": [ - "$444 x+543 y+18 z+215=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(5/3), 1, -1],\n [(14/3), -(13/3), (11/3)],\n [(10/3), -3, -(11/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -5 & -9 & -2 & -6 \\\\\n -8 & 2 & 1 & -3 \\\\\n 7 & 2 & 6 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-185.,-387.,749.,485.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, -9, -2, -6],\n [-8, 2, 1, -3],\n [7, 2, 6, -5]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -3 & 2 & 4 \\\\\n -3 & 4 & -2 \\\\\n -3 & 4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{2}{3} & -\\frac{4}{3} & \\frac{5}{3} \\\\\n -\\frac{1}{2} & -1 & \\frac{3}{2} \\\\\n 0 & -\\frac{1}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2, 4],\n [-3, 4, -2],\n [-3, 4, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & -1 & -3 & 3 \\\\\n 3 & 2 & -1 & 2 \\\\\n 2 & 0 & -1 & -3 \\\\\n -2 & -2 & -3 & -2 \\\\\n -1 & 3 & -1 & 1 \\\\\n 3 & 1 & 2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.63 \\\\\n -2. \\\\\n 0.36 \\\\\n -0.45 \\\\\n -1.93 \\\\\n -0.77 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.184 \\\\\n -0.845 \\\\\n 0.065 \\\\\n 0.285 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, -3, 3],\n [3, 2, -1, 2],\n [2, 0, -1, -3],\n [-2, -2, -3, -2],\n [-1, 3, -1, 1],\n [3, 1, 2, -2]])\nb = np.array([\n [2.63],\n [-2.],\n [0.36],\n [-0.45],\n [-1.93],\n [-0.77]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -7 \\\\\n -3 \\\\\n -8 \\\\\n -9 \\\\\n 1 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-7],\n [-3],\n [-8],\n [-9],\n [1],\n [-5]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{32}{5} & \\frac{42}{5} \\\\\n \\frac{21}{5} & -\\frac{12}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{5} \\left(-22-\\sqrt{982}\\right),\\frac{1}{5} \\left(\\sqrt{982}-22\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(32/5), (42/5)],\n [(21/5), -(12/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -3 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -\\frac{1}{\\sqrt{2}} \\\\\n -\\frac{1}{\\sqrt{2}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [-3],\n [-3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 10 & -6 & 0 \\\\\n -8 & 9 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-9.,-15.,7.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [10, -6, 0],\n [-8, 9, 9]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,-3,3\\}, \\{5,3,-1\\}, \\{3,0,-1\\}}$.", - "Output Answer": [ - "$-12 x+8 y-15 z+21=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, -3, 3],\n [5, 3, -1],\n [3, 0, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{1}{e},\\frac{2}{e},-\\frac{2}{e}\\right\\}, \\left\\{-\\frac{8}{e},\\frac{2}{e},\\frac{1}{e}\\right\\}, \\left\\{-\\frac{5}{e},\\frac{1}{e},-\\frac{7}{e}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{3},\\frac{2}{3},-\\frac{2}{3}\\right\\}, \\left\\{-\\frac{62}{3 \\sqrt{521}},-\\frac{2}{3 \\sqrt{521}},\\frac{29}{3 \\sqrt{521}}\\right\\}, \\left\\{-\\frac{6}{\\sqrt{521}},-\\frac{17}{\\sqrt{521}},-\\frac{14}{\\sqrt{521}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-(1/math.e), (2/math.e), -(2/math.e)), (-(8/math.e), (2/math.e), (1/math.e)), (-(5/math.e), (1/math.e), -(7/math.e))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{28}{9} & -5 & \\frac{25}{9} \\\\\n \\frac{32}{9} & \\frac{14}{9} & \\frac{1}{9} \\\\\n -\\frac{10}{3} & \\frac{16}{9} & -\\frac{40}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{2592}{8411} & \\frac{6300}{8411} & \\frac{3555}{16822} \\\\\n -\\frac{5625}{8411} & -\\frac{8415}{8411} & -\\frac{3726}{8411} \\\\\n -\\frac{4194}{8411} & -\\frac{8091}{8411} & -\\frac{4716}{8411} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(28/9), -5, (25/9)],\n [(32/9), (14/9), (1/9)],\n [-(10/3), (16/9), -(40/9)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 5 & 4 & \\frac{21}{8} \\\\\n -\\frac{13}{8} & -\\frac{37}{8} & \\frac{19}{8} \\\\\n -3 & -\\frac{21}{8} & -\\frac{23}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{400}{517} & \\frac{472}{2585} & \\frac{2216}{2585} \\\\\n -\\frac{1208}{2585} & -\\frac{3328}{12925} & -\\frac{8264}{12925} \\\\\n -\\frac{984}{2585} & \\frac{576}{12925} & -\\frac{8512}{12925} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 4, (21/8)],\n [-(13/8), -(37/8), (19/8)],\n [-3, -(21/8), -(23/8)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{20}{3} & 4 & 6 \\\\\n -\\frac{17}{3} & -5 & -\\frac{17}{3} \\\\\n -\\frac{5}{3} & \\frac{7}{3} & -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6.239,-5.047-6.724 i,-5.047+6.724 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/3), 4, 6],\n [-(17/3), -5, -(17/3)],\n [-(5/3), (7/3), -(14/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n 11 & 9 & 26 & -15 \\\\\n -16 & -11 & -35 & 19 \\\\\n -9 & -7 & -21 & 12 \\\\\n -17 & -12 & -38 & 21 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{35}{3} & \\frac{17}{2} & 25 & -\\frac{43}{3} \\\\\n -20 & -13 & -44 & 24 \\\\\n -\\frac{32}{3} & -8 & -\\frac{47}{2} & \\frac{83}{6} \\\\\n -\\frac{68}{3} & -16 & -\\frac{101}{2} & \\frac{173}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [11, 9, 26, -15],\n [-16, -11, -35, 19],\n [-9, -7, -21, 12],\n [-17, -12, -38, 21]])\nprint(expm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 3 & 3 & 3 & 3 & 0 \\\\\n -2 & -3 & 2 & -1 & 2 \\\\\n -2 & 0 & -1 & -2 & -3 \\\\\n -1 & 0 & 0 & -1 & -2 \\\\\n -2 & 1 & 2 & 1 & 0 \\\\\n 1 & -2 & -2 & 3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.56 \\\\\n 0.29 \\\\\n 0.88 \\\\\n 1.41 \\\\\n 2.2 \\\\\n 0.04 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.068 \\\\\n 0.314 \\\\\n -0.317 \\\\\n 0.293 \\\\\n 0.093 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3, 3, 3, 0],\n [-2, -3, 2, -1, 2],\n [-2, 0, -1, -2, -3],\n [-1, 0, 0, -1, -2],\n [-2, 1, 2, 1, 0],\n [1, -2, -2, 3, 3]])\nb = np.array([\n [-2.56],\n [0.29],\n [0.88],\n [1.41],\n [2.2],\n [0.04]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-1,-\\frac{5}{2},0\\right\\}, \\{-3,3,5\\}, \\left\\{\\frac{5}{2},5,5\\right\\}}$.", - "Output Answer": [ - "$40 x-110 y+137 z-235=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, -(5/2), 0],\n [-3, 3, 5],\n [(5/2), 5, 5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & 0 & -1 \\\\\n -7 & 4 & -2 \\\\\n 3 & -9 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-5.331,5.166\\, -2.322 i,5.166\\, +2.322 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 0, -1],\n [-7, 4, -2],\n [3, -9, -3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 3 & -7 & -10 \\\\\n -6 & 1 & -1 \\\\\n -9 & 7 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-11.716,-3.82,12.536\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -7, -10],\n [-6, 1, -1],\n [-9, 7, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-3,-1,2\\}, \\{-3,1,0\\}, \\{2,-3,-2\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{3}{\\sqrt{14}},-\\frac{1}{\\sqrt{14}},\\sqrt{\\frac{2}{7}}\\right\\}, \\left\\{-\\frac{9}{\\sqrt{266}},\\frac{11}{\\sqrt{266}},-4 \\sqrt{\\frac{2}{133}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{19}},-\\frac{3}{\\sqrt{19}},-\\frac{3}{\\sqrt{19}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-3, -1, 2), (-3, 1, 0), (2, -3, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 6 \\\\\n -7 \\\\\n 6 \\\\\n -3 \\\\\n -2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -7 \\\\\n 2 \\\\\n 1 \\\\\n 8 \\\\\n -5 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{590}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [6],\n [-7],\n [6],\n [-3],\n [-2],\n [-1]])\nb = np.array([\n [8],\n [-7],\n [2],\n [1],\n [8],\n [-5],\n [-5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & -3 & 2 \\\\\n -3 & 0 & 0 \\\\\n 4 & 1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, 2],\n [-3, 0, 0],\n [4, 1, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{35}{16} & -\\frac{5}{4} & -\\frac{41}{16} \\\\\n \\frac{17}{4} & -\\frac{11}{4} & -\\frac{45}{16} \\\\\n \\frac{11}{4} & \\frac{7}{8} & -\\frac{11}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{20528}{114229} & \\frac{11632}{114229} & \\frac{7232}{114229} \\\\\n -\\frac{8096}{114229} & -\\frac{26752}{114229} & \\frac{34904}{114229} \\\\\n -\\frac{23104}{114229} & \\frac{3120}{114229} & -\\frac{23200}{114229} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(35/16), -(5/4), -(41/16)],\n [(17/4), -(11/4), -(45/16)],\n [(11/4), (7/8), -(11/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -5 \\\\\n 6 \\\\\n -8 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$34$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-5],\n [6],\n [-8],\n [-6]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $5$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -4 & 9 & 3 \\\\\n -3 & 9 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -20 & 45 & 15 \\\\\n -15 & 45 & 35 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 9, 3],\n [-3, 9, 7]])\nprint(a * 5)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n 9 & 10 & 2 \\\\\n 6 & 8 & -5 \\\\\n -9 & 3 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 10, 2],\n [6, 8, -5],\n [-9, 3, -4]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 7 \\\\\n -5 \\\\\n 5 \\\\\n 7 \\\\\n 7 \\\\\n 4 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [7],\n [-5],\n [5],\n [7],\n [7],\n [4],\n [3]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -3 & 3 \\\\\n -1 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{5}{18} & -\\frac{1}{6} \\\\\n \\frac{1}{18} & -\\frac{1}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 3],\n [-1, -5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & 4 & -8 \\\\\n -3 & -1 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{4.,-4.,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [6, 4, -8],\n [-3, -1, 8]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{11}{7} & -\\frac{24}{7} \\\\\n -5 & \\frac{29}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{203}{521} & -\\frac{168}{521} \\\\\n -\\frac{245}{521} & -\\frac{77}{521} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/7), -(24/7)],\n [-5, (29/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{9}{5}, \\frac{13}{5}}$ to the line $-\\frac{11 x}{10}-\\frac{11 y}{5}-\\frac{18}{5}=0$.", - "Output Answer": [ - "$\\frac{367}{55 \\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(9/5), (13/5)\nline = Poly(-((11*x)/10)-((11*y)/5)-(18/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 8 & 0 & -7 & -1 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-5.,0.,0.,0.,4.\\}, \\{0.,1.,0.,0.,0.\\}, \\{1.,0.,0.,8.,0.\\}, \\{7.,0.,8.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [8, 0, -7, -1, 10]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-5, 4}$ to the line $3 x+3 y+2=0$.", - "Output Answer": [ - "$\\frac{1}{3 \\sqrt{2}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -5, 4\nline = Poly(3*x+3*y+2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{2,1,-1\\}, \\{-2,3,-5\\}, \\{-2,5,-5\\}}$.", - "Output Answer": [ - "$x-z-3=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, 1, -1],\n [-2, 3, -5],\n [-2, 5, -5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 e \\\\\n 0 \\\\\n -e \\\\\n e \\\\\n e \\\\\n 2 e \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 e \\\\\n -e \\\\\n 3 e \\\\\n 2 e \\\\\n e \\\\\n -3 e \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{11} e$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [3*math.e],\n [0],\n [-math.e],\n [math.e],\n [math.e],\n [2*math.e]])\nb = np.array([\n [2*math.e],\n [-math.e],\n [3*math.e],\n [2*math.e],\n [math.e],\n [-3*math.e]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -7 & 9 & 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 5 & 7 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -2 & 16 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 9, 9]])\nb = np.array([\n [5, 7, -1]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 2 & -10 & 2 \\\\\n 4 & -1 & 0 \\\\\n -4 & -9 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-7 x^2-38 x-384$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -10, 2],\n [4, -1, 0],\n [-4, -9, -8]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -3 & 4 \\\\\n -6 & 7 \\\\\n 0 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -4 & 7 \\\\\n 7 & -7 \\\\\n -7 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -7 & 11 \\\\\n 1 & 0 \\\\\n -7 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 4],\n [-6, 7],\n [0, 8]])\nb = np.array([\n [-4, 7],\n [7, -7],\n [-7, -5]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 3 & -3 & -8 & -6 & -5 \\\\\n 6 & -2 & -1 & -3 & 6 \\\\\n 5 & -5 & -9 & -7 & 4 \\\\\n -1 & 0 & 1 & 10 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{671.,3283.,-1757.,655.,458.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, -3, -8, -6, -5],\n [6, -2, -1, -3, 6],\n [5, -5, -9, -7, 4],\n [-1, 0, 1, 10, -9]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{5} \\\\\n \\frac{9}{5} \\\\\n -\\frac{9}{5} \\\\\n \\frac{13}{5} \\\\\n \\frac{7}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -\\frac{11}{5} \\\\\n -\\frac{2}{5} \\\\\n \\frac{2}{5} \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{175}{379},\\frac{385}{379},\\frac{70}{379},-\\frac{70}{379},\\frac{525}{379}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/5)],\n [(9/5)],\n [-(9/5)],\n [(13/5)],\n [(7/5)]]).squeeze()\nb = np.array([\n [1],\n [-(11/5)],\n [-(2/5)],\n [(2/5)],\n [-3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -2 & \\frac{19}{8} & \\frac{3}{4} & \\frac{27}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{17}{16} & -\\frac{3}{2} & -\\frac{13}{16} & -\\frac{23}{16} \\\\\n -\\frac{47}{16} & \\frac{37}{16} & -\\frac{3}{2} & -2 \\\\\n -\\frac{43}{16} & \\frac{45}{16} & \\frac{21}{8} & \\frac{25}{16} \\\\\n -\\frac{5}{16} & \\frac{21}{16} & -\\frac{21}{16} & -\\frac{13}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{1893}{256} & \\frac{3281}{256} & -\\frac{559}{256} & -\\frac{531}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, (19/8), (3/4), (27/16)]])\nb = np.array([\n [-(17/16), -(3/2), -(13/16), -(23/16)],\n [-(47/16), (37/16), -(3/2), -2],\n [-(43/16), (45/16), (21/8), (25/16)],\n [-(5/16), (21/16), -(21/16), -(13/16)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -3 & 1 & 1 & 0 & -1 \\\\\n -2 & 3 & 2 & 3 & -3 \\\\\n 1 & 0 & 3 & -3 & -3 \\\\\n 1 & -2 & -1 & 1 & 3 \\\\\n 1 & -1 & 0 & 0 & -2 \\\\\n 0 & 3 & -3 & -3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.83 \\\\\n 1.25 \\\\\n 1.4 \\\\\n -0.64 \\\\\n 1.36 \\\\\n -1.02 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.994 \\\\\n -1.003 \\\\\n 0.063 \\\\\n -0.006 \\\\\n -0.677 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1, 1, 0, -1],\n [-2, 3, 2, 3, -3],\n [1, 0, 3, -3, -3],\n [1, -2, -1, 1, 3],\n [1, -1, 0, 0, -2],\n [0, 3, -3, -3, -3]])\nb = np.array([\n [2.83],\n [1.25],\n [1.4],\n [-0.64],\n [1.36],\n [-1.02]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -7 & 2 & -1 & 4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 2, -1, 4, 0]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${4, -1}$ to the line $3 x+y-1=0$.", - "Output Answer": [ - "$\\sqrt{10}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 4, -1\nline = Poly(3*x+y-1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{41}{9} \\\\\n \\frac{14}{9} \\\\\n \\frac{8}{3} \\\\\n -\\frac{70}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n \\frac{40}{9} \\\\\n \\frac{1}{3} \\\\\n \\frac{82}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{95}{9} \\\\\n 6 \\\\\n 3 \\\\\n \\frac{4}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(41/9)],\n [(14/9)],\n [(8/3)],\n [-(70/9)]])\nb = np.array([\n [6],\n [(40/9)],\n [(1/3)],\n [(82/9)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 6 \\\\\n -1 \\\\\n 6 \\\\\n 10 \\\\\n -7 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -1 \\\\\n -2 \\\\\n 1 \\\\\n -5 \\\\\n 2 \\\\\n -2 \\\\\n 1 \\\\\n -4 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{309}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [1],\n [0],\n [-1],\n [6],\n [-1],\n [6],\n [10],\n [-7],\n [5]])\nb = np.array([\n [8],\n [-1],\n [-2],\n [1],\n [-5],\n [2],\n [-2],\n [1],\n [-4],\n [3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{14}{5}, \\frac{18}{5}}$ to the line $\\frac{11 x}{5}+\\frac{19 y}{5}-\\frac{18}{5}=0$.", - "Output Answer": [ - "$\\frac{49 \\sqrt{\\frac{2}{241}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(14/5), (18/5)\nline = Poly(((11*x)/5)+((19*y)/5)-(18/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{23}{3} \\\\\n \\frac{43}{6} \\\\\n \\frac{13}{3} \\\\\n \\frac{4}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{19}{2} \\\\\n \\frac{22}{3} \\\\\n \\frac{19}{2} \\\\\n -\\frac{53}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{103}{6} \\\\\n -\\frac{1}{6} \\\\\n -\\frac{31}{6} \\\\\n \\frac{61}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/3)],\n [(43/6)],\n [(13/3)],\n [(4/3)]])\nb = np.array([\n [(19/2)],\n [(22/3)],\n [(19/2)],\n [-(53/6)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{1}{e},\\frac{5}{e},-\\frac{5}{e}\\right\\}, \\left\\{-\\frac{7}{e},\\frac{8}{e},0\\right\\}, \\left\\{\\frac{7}{e},\\frac{3}{e},\\frac{3}{e}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{51}},\\frac{5}{\\sqrt{51}},-\\frac{5}{\\sqrt{51}}\\right\\}, \\left\\{-65 \\sqrt{\\frac{2}{13243}},\\frac{81}{\\sqrt{26486}},\\frac{55}{\\sqrt{26486}}\\right\\}, \\left\\{20 \\sqrt{\\frac{2}{2337}},\\frac{35}{\\sqrt{4674}},\\frac{43}{\\sqrt{4674}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((1/math.e), (5/math.e), -(5/math.e)), (-(7/math.e), (8/math.e), 0), ((7/math.e), (3/math.e), (3/math.e))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 1 & 2 & 1 & 2 \\\\\n -2 & -2 & -3 & 2 \\\\\n -3 & -1 & 2 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -1 & -1 & 3 & 1 & -2 \\\\\n -2 & -2 & -3 & 0 & -1 \\\\\n -3 & -3 & -2 & 2 & -2 \\\\\n -2 & -1 & -2 & -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -12 & -10 & -9 & 1 & -4 \\\\\n 11 & 13 & 2 & -10 & 14 \\\\\n 5 & 2 & -4 & 4 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, 1, 2],\n [-2, -2, -3, 2],\n [-3, -1, 2, -3]])\nb = np.array([\n [-1, -1, 3, 1, -2],\n [-2, -2, -3, 0, -1],\n [-3, -3, -2, 2, -2],\n [-2, -1, -2, -1, 1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -2 & -2 \\\\\n -\\frac{5}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{61}{2} & -\\frac{41}{2} \\\\\n -\\frac{205}{8} & -\\frac{121}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2],\n [-(5/2), -(1/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0],\n [0, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & -2 & 5 \\\\\n -7 & 7 & 6 \\\\\n 0 & -4 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1.528,-1.216,1.\\}, \\{0.165\\, -0.869 i,0.483\\, -1.251 i,1.\\}, \\{0.165\\, +0.869 i,0.483\\, +1.251 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -2, 5],\n [-7, 7, 6],\n [0, -4, 6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{17}{2} & \\frac{15}{4} & \\frac{1}{4} \\\\\n -7 & \\frac{15}{4} & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{4} & 8 & \\frac{15}{4} \\\\\n \\frac{11}{2} & \\frac{1}{2} & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{37}{4} & -\\frac{17}{4} & -\\frac{7}{2} \\\\\n -\\frac{25}{2} & \\frac{13}{4} & \\frac{5}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/2), (15/4), (1/4)],\n [-7, (15/4), (1/4)]])\nb = np.array([\n [-(3/4), 8, (15/4)],\n [(11/2), (1/2), -1]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{3} \\\\\n 3 \\\\\n -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -\\frac{1}{3} \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{21}{23},\\frac{7}{23},-\\frac{42}{23}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/3)],\n [3],\n [-(2/3)]]).squeeze()\nb = np.array([\n [-1],\n [-(1/3)],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{2 \\sqrt{2}} \\\\\n 0 \\\\\n \\frac{1}{2 \\sqrt{2}} \\\\\n -\\frac{1}{2 \\sqrt{2}} \\\\\n -\\frac{1}{\\sqrt{2}} \\\\\n \\frac{1}{2 \\sqrt{2}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [1],\n [-1],\n [-2],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & -4 & 1 \\\\\n 6 & 9 & 5 \\\\\n 2 & 0 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.705,-0.175,1.\\}, \\{1.352\\, -2.515 i,2.837\\, +2.773 i,1.\\}, \\{1.352\\, +2.515 i,2.837\\, -2.773 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -4, 1],\n [6, 9, 5],\n [2, 0, 6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{0,-\\frac{4}{3},\\frac{4}{3}\\right\\}, \\left\\{\\frac{4}{3},-\\frac{13}{3},0\\right\\}, \\left\\{-\\frac{2}{3},\\frac{1}{3},-\\frac{11}{3}\\right\\}}$.", - "Output Answer": [ - "$155 x+68 y+2 z+88=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, -(4/3), (4/3)],\n [(4/3), -(13/3), 0],\n [-(2/3), (1/3), -(11/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 3 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{2}{3},\\frac{4}{3},\\frac{2}{3}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [1],\n [3]]).squeeze()\nb = np.array([\n [1],\n [-2],\n [-1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{20}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & 10 & -2 & -10 \\\\\n 2 & 3 & -3 & 0 \\\\\n 3 & 2 & 9 & 2 \\\\\n 1 & 2 & 4 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{9}{20} & -\\frac{3}{2} & \\frac{3}{10} & \\frac{3}{2} \\\\\n -\\frac{3}{10} & -\\frac{9}{20} & \\frac{9}{20} & 0 \\\\\n -\\frac{9}{20} & -\\frac{3}{10} & -\\frac{27}{20} & -\\frac{3}{10} \\\\\n -\\frac{3}{20} & -\\frac{3}{10} & -\\frac{3}{5} & \\frac{6}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 10, -2, -10],\n [2, 3, -3, 0],\n [3, 2, 9, 2],\n [1, 2, 4, -8]])\nprint(a * -(3/20))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{2} & -6 & -2 \\\\\n \\frac{7}{2} & -\\frac{7}{2} & -\\frac{17}{2} \\\\\n \\frac{15}{2} & -8 & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.097,-0.602,1.\\}, \\{-0.291-1.542 i,1.262\\, -0.64 i,1.\\}, \\{-0.291+1.542 i,1.262\\, +0.64 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/2), -6, -2],\n [(7/2), -(7/2), -(17/2)],\n [(15/2), -8, (9/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -4 & -3 & 4 \\\\\n -3 & 4 & -1 \\\\\n -2 & 5 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-104$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -3, 4],\n [-3, 4, -1],\n [-2, 5, 2]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4.42 \\\\\n 2. \\\\\n -7.38 \\\\\n -2.33 \\\\\n 1.4 \\\\\n 1.94 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6.32 \\\\\n 4.38 \\\\\n -6.72 \\\\\n 3.52 \\\\\n 7.41 \\\\\n 2.35 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8.9566$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4.42],\n [2.],\n [-7.38],\n [-2.33],\n [1.4],\n [1.94]])\nb = np.array([\n [6.32],\n [4.38],\n [-6.72],\n [3.52],\n [7.41],\n [2.35]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 3 \\\\\n -2 & 3 \\\\\n 0 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.49 \\\\\n 3. \\\\\n -0.38 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.053 \\\\\n 0.721 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3],\n [-2, 3],\n [0, 2]])\nb = np.array([\n [2.49],\n [3.],\n [-0.38]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 3 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 8 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 11 \\\\\n 88 \\\\\n 88 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [3],\n [-4]])\nb = np.array([\n [-8],\n [8],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{\\sqrt{\\pi }} \\\\\n \\frac{14}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{\\sqrt{\\pi }} \\\\\n \\frac{6}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{112}{\\pi }$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(4/(math.sqrt(math.pi)))],\n [(14/(math.sqrt(math.pi)))]])\nb = np.array([\n [-(7/(math.sqrt(math.pi)))],\n [(6/(math.sqrt(math.pi)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -9 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, 0]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 7 \\\\\n 0 \\\\\n 3 \\\\\n 6 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 8 \\\\\n 1 \\\\\n -8 \\\\\n 2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{41}{\\sqrt{10573}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [7],\n [0],\n [3],\n [6],\n [8]]).squeeze()\nb = np.array([\n [9],\n [8],\n [1],\n [-8],\n [2],\n [-2]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -2 & -3 \\\\\n 3 & 3 & 0 \\\\\n 2 & 3 & -2 \\\\\n -1 & 3 & 1 \\\\\n -2 & 3 & -1 \\\\\n 3 & 2 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.41 \\\\\n -2.15 \\\\\n 0.45 \\\\\n 2.14 \\\\\n -1.25 \\\\\n 2.27 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.093 \\\\\n 0.096 \\\\\n 0.308 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, -3],\n [3, 3, 0],\n [2, 3, -2],\n [-1, 3, 1],\n [-2, 3, -1],\n [3, 2, -1]])\nb = np.array([\n [-1.41],\n [-2.15],\n [0.45],\n [2.14],\n [-1.25],\n [2.27]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{10}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 5 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & -\\frac{4}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -8]])\nprint(a * (1/10))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -7 & -3 & -2 & 5 & 8 \\\\\n 8 & -1 & 6 & -5 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -3, -2, 5, 8],\n [8, -1, 6, -5, 8]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{2} & -\\frac{3}{2} \\\\\n -2 & -\\frac{5}{2} \\\\\n 2 & \\frac{5}{2} \\\\\n 2 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 3 & 0 & -\\frac{1}{2} & 0 & \\frac{1}{2} \\\\\n -\\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} & 1 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -\\frac{27}{4} & \\frac{3}{4} & \\frac{1}{2} & -\\frac{3}{2} & 1 \\\\\n -\\frac{19}{4} & \\frac{5}{4} & -\\frac{1}{4} & -\\frac{5}{2} & \\frac{11}{4} \\\\\n \\frac{19}{4} & -\\frac{5}{4} & \\frac{1}{4} & \\frac{5}{2} & -\\frac{11}{4} \\\\\n \\frac{15}{2} & \\frac{3}{2} & -\\frac{5}{2} & -3 & \\frac{11}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), -(3/2)],\n [-2, -(5/2)],\n [2, (5/2)],\n [2, -3]])\nb = np.array([\n [3, 0, -(1/2), 0, (1/2)],\n [-(1/2), -(1/2), (1/2), 1, -(3/2)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 5 & -\\frac{1}{2} \\\\\n -2 & 0 & 2 \\\\\n -\\frac{9}{2} & 4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-87$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 5, -(1/2)],\n [-2, 0, 2],\n [-(9/2), 4, -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -1 & 0 \\\\\n -2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -1 & 0 \\\\\n -1 & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0],\n [-2, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{2}{5}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [1],\n [0],\n [-1],\n [0],\n [1],\n [-1]]).squeeze()\nb = np.array([\n [0],\n [-1],\n [-1],\n [1],\n [0],\n [-1],\n [0],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{21}{5} \\\\\n -\\frac{1}{5} \\\\\n 0 \\\\\n -\\frac{47}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{47}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(21/5)],\n [-(1/5)],\n [0],\n [-(47/5)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n 5 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n -\\sqrt{3} \\\\\n 5 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\sqrt{3} \\\\\n 2 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n -\\sqrt{3} \\\\\n -3 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-234$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-math.sqrt(3)],\n [-5*math.sqrt(3)],\n [math.sqrt(3)],\n [5*math.sqrt(3)],\n [4*math.sqrt(3)],\n [-math.sqrt(3)],\n [5*math.sqrt(3)]])\nb = np.array([\n [4*math.sqrt(3)],\n [2*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [-math.sqrt(3)],\n [-3*math.sqrt(3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -2 & -1 & -5 \\\\\n 0 & 5 & 4 \\\\\n 7 & -9 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -6 & 8 & -1 \\\\\n 3 & 4 & 8 \\\\\n 0 & -9 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -8 & 7 & -6 \\\\\n 3 & 9 & 12 \\\\\n 7 & -18 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1, -5],\n [0, 5, 4],\n [7, -9, -1]])\nb = np.array([\n [-6, 8, -1],\n [3, 4, 8],\n [0, -9, 3]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{97}{10} & \\frac{41}{10} & \\frac{47}{10} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{33}{5} & -9 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{163}{10} & \\frac{131}{10} & \\frac{97}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(97/10), (41/10), (47/10)]])\nb = np.array([\n [(33/5), -9, -5]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{2} & -\\frac{3}{2} & \\frac{3}{2} \\\\\n -2 & \\frac{3}{2} & -\\frac{1}{2} \\\\\n 3 & -\\frac{1}{2} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{327}{8} & -\\frac{201}{8} & \\frac{201}{8} \\\\\n -\\frac{143}{4} & \\frac{87}{4} & -\\frac{83}{4} \\\\\n 48 & -\\frac{55}{2} & \\frac{57}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), -(3/2), (3/2)],\n [-2, (3/2), -(1/2)],\n [3, -(1/2), (3/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 5 & 10 & 7 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-7.,0.,5.,0.\\}, \\{-2.,1.,0.,0.\\}, \\{-1.,0.,0.,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, 10, 7, 5]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -4 & -4 & 0 & 5 & -10 \\\\\n 3 & 0 & -1 & -4 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.,-3.,0.,0.,2.\\}, \\{1.,-1.,3.,0.,0.\\}, \\{16.,-1.,0.,12.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, -4, 0, 5, -10],\n [3, 0, -1, -4, 3]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -7 & -10 & 5 \\\\\n -2 & -6 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-20.,25.,22.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, -10, 5],\n [-2, -6, 5]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 3 & 5 & 5 \\\\\n 2 & 2 & -2 \\\\\n 2 & -2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{3}{34} & \\frac{5}{68} & \\frac{5}{17} \\\\\n \\frac{1}{34} & \\frac{13}{68} & -\\frac{4}{17} \\\\\n \\frac{2}{17} & -\\frac{4}{17} & \\frac{1}{17} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 5, 5],\n [2, 2, -2],\n [2, -2, -1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -8 & -\\frac{3}{2} & \\frac{11}{2} \\\\\n \\frac{5}{2} & -\\frac{9}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -9 & -7 & \\frac{9}{2} \\\\\n -1 & \\frac{15}{2} & \\frac{15}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -17 & -\\frac{17}{2} & 10 \\\\\n \\frac{3}{2} & 3 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -(3/2), (11/2)],\n [(5/2), -(9/2), -(1/2)]])\nb = np.array([\n [-9, -7, (9/2)],\n [-1, (15/2), (15/2)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-2,-\\frac{1}{2},\\frac{3}{2}\\right\\}, \\left\\{-\\frac{7}{2},-\\frac{9}{2},2\\right\\}, \\left\\{4,-5,\\frac{7}{2}\\right\\}}$.", - "Output Answer": [ - "$46 x-48 y-246 z+437=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, -(1/2), (3/2)],\n [-(7/2), -(9/2), 2],\n [4, -5, (7/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 8 \\\\\n -4 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 1 \\\\\n 6 \\\\\n -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -7 \\\\\n 9 \\\\\n 2 \\\\\n -13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [8],\n [-4],\n [-5]])\nb = np.array([\n [3],\n [1],\n [6],\n [-8]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -10 & 6 \\\\\n -2 & 5 \\\\\n 7 & -2 \\\\\n -3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, 6],\n [-2, 5],\n [7, -2],\n [-3, 1]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 9 & 1 & 1 \\\\\n -8 & 9 & -4 \\\\\n 9 & 6 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.463,0.123,1.\\}, \\{0.215\\, -0.08 i,-0.204+1.008 i,1.\\}, \\{0.215\\, +0.08 i,-0.204-1.008 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 1, 1],\n [-8, 9, -4],\n [9, 6, 10]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,1,-2\\}, \\{4,-3,4\\}, \\{0,-3,-4\\}}$.", - "Output Answer": [ - "$4 x+3 y-2 z+1=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, 1, -2],\n [4, -3, 4],\n [0, -3, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 2 & -3 \\\\\n 2 & 0 \\\\\n -2 & -2 \\\\\n 1 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -15 \\\\\n -6 \\\\\n 0 \\\\\n -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3],\n [2, 0],\n [-2, -2],\n [1, 0]])\nb = np.array([\n [-3],\n [3]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n \\frac{1}{4} \\\\\n 3 \\\\\n -\\frac{3}{2} \\\\\n \\frac{15}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{4}{\\sqrt{965}} \\\\\n \\frac{2}{\\sqrt{965}} \\\\\n \\frac{24}{\\sqrt{965}} \\\\\n -\\frac{12}{\\sqrt{965}} \\\\\n 3 \\sqrt{\\frac{5}{193}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2)],\n [(1/4)],\n [3],\n [-(3/2)],\n [(15/8)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & -7 \\\\\n -6 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{12} \\left(-15-\\sqrt{393}\\right),1\\right\\}, \\left\\{\\frac{1}{12} \\left(\\sqrt{393}-15\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -7],\n [-6, -9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{3}{2}, 4}$ to the line $3 x-4 y+\\frac{5}{2}=0$.", - "Output Answer": [ - "$\\frac{18}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(3/2), 4\nline = Poly(3*x-4*y+(5/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{36}{5} & -\\frac{37}{5} \\\\\n -2 & -\\frac{89}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{17 x}{10}-\\frac{1972}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(36/5), -(37/5)],\n [-2, -(89/10)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{489}{50} \\\\\n \\frac{789}{100} \\\\\n \\frac{151}{50} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{759}{100} \\\\\n \\frac{47}{20} \\\\\n \\frac{341}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{198079}{10000} \\\\\n \\frac{140679}{2500} \\\\\n -\\frac{828681}{10000} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(489/50)],\n [(789/100)],\n [(151/50)]])\nb = np.array([\n [(759/100)],\n [(47/20)],\n [(341/100)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -3 \\\\\n -7 \\\\\n -7 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$22$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-3],\n [-7],\n [-7],\n [1]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [-1],\n [0],\n [0],\n [0],\n [-1],\n [-1]]).squeeze()\nb = np.array([\n [-1],\n [-1],\n [0],\n [0],\n [1],\n [0],\n [1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 5 & 9 \\\\\n -9 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{9} i \\left(4 \\sqrt{5}-i\\right),1\\right\\}, \\left\\{-\\frac{1}{9} i \\left(4 \\sqrt{5}+i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 9],\n [-9, 7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -2 & 9 & 7 \\\\\n 3 & 6 & 8 \\\\\n -5 & 9 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.6,-0.299,1.\\}, \\{-0.358,-0.391,1.\\}, \\{3.697,4.322,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 9, 7],\n [3, 6, 8],\n [-5, 9, -10]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 1 & 2 \\\\\n -3 & -3 \\\\\n 0 & -3 \\\\\n 2 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 1 & 3 & 3 & -1 \\\\\n 0 & -2 & -2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & -1 & -1 & 1 \\\\\n -3 & -3 & -3 & 0 \\\\\n 0 & 6 & 6 & -3 \\\\\n 2 & 10 & 10 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2],\n [-3, -3],\n [0, -3],\n [2, -2]])\nb = np.array([\n [1, 3, 3, -1],\n [0, -2, -2, 1]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 0 & -4 \\\\\n 4 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{16} & \\frac{1}{4} \\\\\n -\\frac{1}{4} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -4],\n [4, -1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{15}{8} & -1 \\\\\n -\\frac{13}{16} & -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{8}{41} & -\\frac{32}{41} \\\\\n -\\frac{26}{41} & -\\frac{60}{41} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/8), -1],\n [-(13/16), -(1/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 3 & -3 & 2 & 1 \\\\\n 1 & -3 & 2 & 0 \\\\\n 1 & -3 & 1 & -2 \\\\\n -2 & -2 & -1 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -1 & -1 & 2 \\\\\n -3 & -2 & 0 \\\\\n 1 & -2 & 1 \\\\\n -3 & -2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 5 & -3 & 6 \\\\\n 10 & 1 & 4 \\\\\n 15 & 7 & 7 \\\\\n 7 & 8 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -3, 2, 1],\n [1, -3, 2, 0],\n [1, -3, 1, -2],\n [-2, -2, -1, 0]])\nb = np.array([\n [-1, -1, 2],\n [-3, -2, 0],\n [1, -2, 1],\n [-3, -2, -2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{9}{2} \\\\\n -1 \\\\\n -\\frac{13}{2} \\\\\n -\\frac{19}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 3 \\\\\n -9 \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{29}{2} \\\\\n 2 \\\\\n -\\frac{31}{2} \\\\\n -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/2)],\n [-1],\n [-(13/2)],\n [-(19/2)]])\nb = np.array([\n [10],\n [3],\n [-9],\n [6]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{12}{5} & \\frac{12}{5} \\\\\n 1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{5}{8} & -\\frac{1}{2} \\\\\n -\\frac{5}{24} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(12/5), (12/5)],\n [1, -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{18}{7} \\\\\n \\frac{20}{7} \\\\\n \\frac{17}{7} \\\\\n \\frac{12}{7} \\\\\n \\frac{17}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3 \\sqrt{\\frac{6}{241}} \\\\\n 10 \\sqrt{\\frac{2}{723}} \\\\\n \\frac{17}{\\sqrt{1446}} \\\\\n 2 \\sqrt{\\frac{6}{241}} \\\\\n \\frac{17}{\\sqrt{1446}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(18/7)],\n [(20/7)],\n [(17/7)],\n [(12/7)],\n [(17/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 1 & -8 & -2 & 1 \\\\\n 0 & -1 & -2 & -8 \\\\\n 9 & 3 & -4 & -4 \\\\\n -1 & 1 & -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [1, -8, -2, 1],\n [0, -1, -2, -8],\n [9, 3, -4, -4],\n [-1, 1, -1, 2]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{26}{e} \\\\\n -\\frac{25}{e} \\\\\n -\\frac{2}{e} \\\\\n \\frac{7}{e} \\\\\n -\\frac{24}{e} \\\\\n -\\frac{8}{e} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{22}{e} \\\\\n -\\frac{18}{e} \\\\\n -\\frac{5}{e} \\\\\n \\frac{6}{e} \\\\\n \\frac{6}{e} \\\\\n \\frac{17}{e} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{350}{e^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(26/math.e)],\n [-(25/math.e)],\n [-(2/math.e)],\n [(7/math.e)],\n [-(24/math.e)],\n [-(8/math.e)]])\nb = np.array([\n [(22/math.e)],\n [-(18/math.e)],\n [-(5/math.e)],\n [(6/math.e)],\n [(6/math.e)],\n [(17/math.e)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{3} & \\frac{11}{3} \\\\\n -2 & -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{80}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/3), (11/3)],\n [-2, -(2/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{11}} \\\\\n -\\frac{1}{\\sqrt{11}} \\\\\n -\\frac{1}{\\sqrt{11}} \\\\\n 0 \\\\\n \\frac{2}{\\sqrt{11}} \\\\\n \\frac{2}{\\sqrt{11}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [-1],\n [0],\n [2],\n [2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,1,-1\\}, \\{-2,0,-4\\}, \\{-4,-3,2\\}}$.", - "Output Answer": [ - "$15 x-36 y-13 z-22=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, 1, -1],\n [-2, 0, -4],\n [-4, -3, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2-4 i & -2 & -5-4 i \\\\\n 3+3 i & 2-i & 1+i \\\\\n 1-4 i & -1-4 i & 2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 101+263 i & 180+81 i & 218+85 i \\\\\n -161-121 i & -153+22 i & -153-53 i \\\\\n -41+82 i & 45+79 i & -72+128 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2-4j, -2, -5-4j],\n [3+3j, 2- 1j, 1+ 1j],\n [1-4j, -1-4j, 2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 8 & 6 & -8 & 1 \\\\\n 10 & -9 & -1 & 9 \\\\\n -9 & 0 & -7 & 6 \\\\\n -5 & -1 & 0 & 9 \\\\\n 2 & -6 & 8 & -6 \\\\\n -3 & -7 & 9 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, 6, -8, 1],\n [10, -9, -1, 9],\n [-9, 0, -7, 6],\n [-5, -1, 0, 9],\n [2, -6, 8, -6],\n [-3, -7, 9, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{1,\\frac{9}{2},-\\frac{1}{2}\\right\\}, \\left\\{-1,4,-\\frac{9}{2}\\right\\}, \\left\\{-\\frac{1}{2},\\frac{7}{2},-4\\right\\}}$.", - "Output Answer": [ - "$18 x+8 y-10 z-59=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, (9/2), -(1/2)],\n [-1, 4, -(9/2)],\n [-(1/2), (7/2), -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 1 \\\\\n -2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{2} \\left(-5-\\sqrt{23}\\right),1\\right\\}, \\left\\{\\frac{1}{2} \\left(\\sqrt{23}-5\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 1],\n [-2, -2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{5}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & -8 & 2 \\\\\n -6 & 10 & -10 \\\\\n 3 & -3 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{5} & \\frac{8}{5} & -\\frac{2}{5} \\\\\n \\frac{6}{5} & -2 & 2 \\\\\n -\\frac{3}{5} & \\frac{3}{5} & -\\frac{4}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -8, 2],\n [-6, 10, -10],\n [3, -3, 4]])\nprint(a * -(1/5))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & -9 \\\\\n -9 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{18} \\left(11-\\sqrt{445}\\right),1\\right\\}, \\left\\{\\frac{1}{18} \\left(11+\\sqrt{445}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -9],\n [-9, 9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & \\frac{5}{2} & \\frac{5}{2} \\\\\n -\\frac{1}{2} & 1 & -\\frac{3}{2} \\\\\n 3 & -1 & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{45}{4} & \\frac{155}{8} & \\frac{125}{8} \\\\\n -\\frac{71}{8} & -\\frac{17}{2} & -\\frac{115}{8} \\\\\n \\frac{95}{4} & -\\frac{5}{4} & -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, (5/2), (5/2)],\n [-(1/2), 1, -(3/2)],\n [3, -1, 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{5} \\\\\n -\\frac{18}{5} \\\\\n \\frac{22}{5} \\\\\n -\\frac{48}{5} \\\\\n -4 \\\\\n -1 \\\\\n \\frac{4}{5} \\\\\n -\\frac{43}{5} \\\\\n -\\frac{23}{5} \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -\\frac{33}{5} \\\\\n 3 \\\\\n \\frac{7}{5} \\\\\n \\frac{49}{5} \\\\\n \\frac{24}{5} \\\\\n -\\frac{17}{5} \\\\\n -\\frac{13}{5} \\\\\n \\frac{38}{5} \\\\\n -\\frac{24}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{17453}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/5)],\n [-(18/5)],\n [(22/5)],\n [-(48/5)],\n [-4],\n [-1],\n [(4/5)],\n [-(43/5)],\n [-(23/5)],\n [7]])\nb = np.array([\n [2],\n [-(33/5)],\n [3],\n [(7/5)],\n [(49/5)],\n [(24/5)],\n [-(17/5)],\n [-(13/5)],\n [(38/5)],\n [-(24/5)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{37}{8} \\\\\n \\frac{7}{4} \\\\\n -\\frac{5}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n \\frac{67}{8} \\\\\n -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{505}{64} \\\\\n \\frac{455}{16} \\\\\n \\frac{1359}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/8)],\n [(7/4)],\n [-(5/8)]])\nb = np.array([\n [10],\n [(67/8)],\n [-(15/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{5} & \\frac{24}{5} & -\\frac{6}{5} \\\\\n \\frac{13}{5} & \\frac{1}{5} & \\frac{3}{10} \\\\\n -\\frac{17}{10} & -\\frac{9}{10} & \\frac{9}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{15}{557} & \\frac{180}{557} & -\\frac{40}{557} \\\\\n \\frac{865}{3899} & \\frac{760}{3899} & \\frac{450}{3899} \\\\\n \\frac{1000}{11697} & \\frac{1570}{3899} & \\frac{6380}{11697} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/5), (24/5), -(6/5)],\n [(13/5), (1/5), (3/10)],\n [-(17/10), -(9/10), (9/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{39}{4} & \\frac{35}{4} \\\\\n 8 & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{64} \\left(49-\\sqrt{6881}\\right),1\\right\\}, \\left\\{\\frac{1}{64} \\left(49+\\sqrt{6881}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(39/4), (35/4)],\n [8, -(5/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -2 & 3 & -8 & 5 & -1 \\\\\n 4 & 9 & 1 & -7 & 9 \\\\\n -9 & 10 & 8 & -9 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-323.,-1021.,-454.,0.,1215.\\}, \\{121.,227.,308.,405.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, 3, -8, 5, -1],\n [4, 9, 1, -7, 9],\n [-9, 10, 8, -9, 9]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 0 & \\frac{20}{3} & \\frac{10}{3} \\\\\n 4 & -\\frac{20}{3} & \\frac{22}{3} \\\\\n -\\frac{28}{3} & -4 & -\\frac{23}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-10.863,-1.735-6.647 i,-1.735+6.647 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, (20/3), (10/3)],\n [4, -(20/3), (22/3)],\n [-(28/3), -4, -(23/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{8}{9}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -8 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{64}{9} & -\\frac{40}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 5]])\nprint(a * -(8/9))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 2 \\\\\n -2 \\\\\n 4 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 1 \\\\\n 2 \\\\\n 4 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{9}{2 \\sqrt{55}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [2],\n [-2],\n [4],\n [-9]]).squeeze()\nb = np.array([\n [7],\n [1],\n [2],\n [4],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & 1 & 3 & -2 \\\\\n 0 & -2 & -3 & 0 \\\\\n 2 & -1 & 1 & 3 \\\\\n 1 & 0 & -2 & -3 \\\\\n -3 & 0 & -1 & -3 \\\\\n 3 & -2 & 2 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.57 \\\\\n 2.89 \\\\\n -1.3 \\\\\n 0.2 \\\\\n -2.01 \\\\\n 0.73 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.275 \\\\\n -0.312 \\\\\n -0.437 \\\\\n 0.054 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, 3, -2],\n [0, -2, -3, 0],\n [2, -1, 1, 3],\n [1, 0, -2, -3],\n [-3, 0, -1, -3],\n [3, -2, 2, -1]])\nb = np.array([\n [-1.57],\n [2.89],\n [-1.3],\n [0.2],\n [-2.01],\n [0.73]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -3 & -3 \\\\\n 1 & 1 \\\\\n -1 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 1 & 2 & 0 & 1 \\\\\n 2 & 0 & -1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -9 & -6 & 3 & 6 \\\\\n 3 & 2 & -1 & -2 \\\\\n -1 & -2 & 0 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3],\n [1, 1],\n [-1, 0]])\nb = np.array([\n [1, 2, 0, 1],\n [2, 0, -1, -3]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n \\frac{19}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{52}{\\sqrt{19865}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [(19/2)]]).squeeze()\nb = np.array([\n [5],\n [-2]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{16}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 9 & 7 & 4 \\\\\n -8 & -9 & -8 \\\\\n -8 & 10 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{45}{16} & -\\frac{35}{16} & -\\frac{5}{4} \\\\\n \\frac{5}{2} & \\frac{45}{16} & \\frac{5}{2} \\\\\n \\frac{5}{2} & -\\frac{25}{8} & \\frac{15}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 7, 4],\n [-8, -9, -8],\n [-8, 10, -3]])\nprint(a * -(5/16))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 3 & -1 & -3 & 9 & -9 \\\\\n 6 & -7 & -1 & -4 & 9 \\\\\n 8 & 4 & 0 & -10 & 9 \\\\\n -7 & -6 & -9 & 4 & -5 \\\\\n 3 & 2 & -2 & 10 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, -1, -3, 9, -9],\n [6, -7, -1, -4, 9],\n [8, 4, 0, -10, 9],\n [-7, -6, -9, 4, -5],\n [3, 2, -2, 10, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 0 & 2 \\\\\n -2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{3}{4} & -\\frac{1}{2} \\\\\n \\frac{1}{2} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2],\n [-2, -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, -1, -4}$ to the plane $5 x+3 y-3=0$.", - "Output Answer": [ - "$\\frac{21}{\\sqrt{34}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, -1, -4\nplane = Poly(5*x+3*y-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\sqrt{\\frac{2}{3}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [1],\n [-1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 10 \\\\\n -2 \\\\\n 0 \\\\\n 9 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -1 \\\\\n -6 \\\\\n 6 \\\\\n 4 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{7}{\\sqrt{31886}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [10],\n [-2],\n [0],\n [9],\n [-7]]).squeeze()\nb = np.array([\n [-3],\n [-1],\n [-6],\n [6],\n [4],\n [3]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1}{\\sqrt{14}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [1],\n [-1],\n [0],\n [-1],\n [1],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [0],\n [-1],\n [-1],\n [-1],\n [-1],\n [1],\n [0],\n [1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{21}{4} \\\\\n \\frac{11}{4} \\\\\n \\frac{13}{2} \\\\\n -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{13}{2} \\\\\n -6 \\\\\n -\\frac{29}{4} \\\\\n \\frac{23}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{1173}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(21/4)],\n [(11/4)],\n [(13/2)],\n [-(17/2)]])\nb = np.array([\n [(13/2)],\n [-6],\n [-(29/4)],\n [(23/4)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & -6 & 5 \\\\\n 2 & 3 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{45.,-20.,3.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, -6, 5],\n [2, 3, -10]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -4 & 1 \\\\\n -6 & -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 0 & 0 \\\\\n -1 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -4 & 1 \\\\\n -7 & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 1],\n [-6, -5]])\nb = np.array([\n [0, 0],\n [-1, -4]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -5 & 5 \\\\\n -3 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{8} & -\\frac{1}{8} \\\\\n \\frac{3}{40} & -\\frac{1}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 5],\n [-3, -5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{27}{5} & -7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -2 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{37}{5} & -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(27/5), -7]])\nb = np.array([\n [-2, 5]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -\\frac{19}{9} \\\\\n -\\frac{37}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{61}{9} \\\\\n -\\frac{35}{9} \\\\\n -\\frac{17}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{326}{81} \\\\\n -\\frac{5011}{81} \\\\\n \\frac{3049}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-(19/9)],\n [-(37/9)]])\nb = np.array([\n [(61/9)],\n [-(35/9)],\n [-(17/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -7 & 7 & 6 & -5 & 7 \\\\\n -6 & -9 & 1 & 1 & -5 \\\\\n 10 & -4 & 2 & -6 & -10 \\\\\n -9 & -9 & -10 & 9 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1715.,-2719.,1491.,-42.,3126.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, 7, 6, -5, 7],\n [-6, -9, 1, 1, -5],\n [10, -4, 2, -6, -10],\n [-9, -9, -10, 9, 2]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\sqrt{5} \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\sqrt{5} \\\\\n -3 \\sqrt{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{65}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [2*math.sqrt(5)],\n [0]])\nb = np.array([\n [4*math.sqrt(5)],\n [-3*math.sqrt(5)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & -3 \\\\\n 1 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{2} \\left(-13-\\sqrt{157}\\right),1\\right\\}, \\left\\{\\frac{1}{2} \\left(\\sqrt{157}-13\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -3],\n [1, 9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & -1 & 3 & 2 \\\\\n -2 & -3 & 0 & -2 \\\\\n -3 & 1 & 3 & -3 \\\\\n -1 & 1 & -2 & -1 \\\\\n -2 & 1 & -3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.85 \\\\\n 1.7 \\\\\n 0.22 \\\\\n -1.47 \\\\\n 2.48 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.277 \\\\\n -0.415 \\\\\n -0.108 \\\\\n -0.666 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1, 3, 2],\n [-2, -3, 0, -2],\n [-3, 1, 3, -3],\n [-1, 1, -2, -1],\n [-2, 1, -3, -3]])\nb = np.array([\n [-1.85],\n [1.7],\n [0.22],\n [-1.47],\n [2.48]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{135}{16} & -\\frac{123}{16} \\\\\n \\frac{17}{16} & \\frac{69}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{33 x}{8}-\\frac{903}{32}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(135/16), -(123/16)],\n [(17/16), (69/16)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{2}{3},-\\frac{7}{3},-\\frac{10}{3}\\right\\}, \\left\\{\\frac{1}{3},-\\frac{5}{3},2\\right\\}, \\left\\{\\frac{14}{3},\\frac{5}{3},\\frac{8}{3}\\right\\}}$.", - "Output Answer": [ - "$26 x-35 y+6 z-79=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(2/3), -(7/3), -(10/3)],\n [(1/3), -(5/3), 2],\n [(14/3), (5/3), (8/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & -7 & 4 \\\\\n -1 & 2 & 6 \\\\\n 2 & 9 & -7 \\\\\n 10 & -8 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, -7, 4],\n [-1, 2, 6],\n [2, 9, -7],\n [10, -8, 3]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{4,-2,\\frac{5}{3}\\right\\}, \\left\\{\\frac{1}{3},\\frac{14}{3},-\\frac{14}{3}\\right\\}, \\left\\{\\frac{10}{3},0,-\\frac{5}{3}\\right\\}}$.", - "Output Answer": [ - "$129 x+108 y+39 z-365=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, -2, (5/3)],\n [(1/3), (14/3), -(14/3)],\n [(10/3), 0, -(5/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{39}{8} & -\\frac{101}{16} & \\frac{147}{16} \\\\\n -\\frac{37}{4} & -\\frac{43}{8} & \\frac{53}{8} \\\\\n -\\frac{15}{8} & -\\frac{127}{16} & \\frac{89}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{81 x^2}{16}+\\frac{281 x}{16}+\\frac{7139}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(39/8), -(101/16), (147/16)],\n [-(37/4), -(43/8), (53/8)],\n [-(15/8), -(127/16), (89/16)]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{68}{9} & -3 \\\\\n \\frac{59}{9} & -\\frac{8}{3} \\\\\n \\frac{52}{9} & 4 \\\\\n -1 & \\frac{58}{9} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{56}{9} & -\\frac{25}{3} \\\\\n \\frac{74}{9} & -\\frac{79}{9} \\\\\n -5 & -9 \\\\\n \\frac{73}{9} & -\\frac{19}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{124}{9} & \\frac{16}{3} \\\\\n -\\frac{5}{3} & \\frac{55}{9} \\\\\n \\frac{97}{9} & 13 \\\\\n -\\frac{82}{9} & \\frac{115}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(68/9), -3],\n [(59/9), -(8/3)],\n [(52/9), 4],\n [-1, (58/9)]])\nb = np.array([\n [-(56/9), -(25/3)],\n [(74/9), -(79/9)],\n [-5, -9],\n [(73/9), -(19/3)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{16}{5} & -\\frac{18}{5} \\\\\n -\\frac{13}{5} & \\frac{16}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{22}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(16/5), -(18/5)],\n [-(13/5), (16/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 7 & 10 \\\\\n -5 & -3 \\\\\n 1 & -10 \\\\\n 3 & -7 \\\\\n -9 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, 10],\n [-5, -3],\n [1, -10],\n [3, -7],\n [-9, 2]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{35}{4} & -\\frac{7}{2} & \\frac{5}{4} \\\\\n -\\frac{3}{2} & -\\frac{39}{4} & \\frac{13}{2} \\\\\n \\frac{39}{4} & -\\frac{9}{2} & -\\frac{11}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1.322,0.24,1.\\}, \\{0.25\\, -0.144 i,1.353\\, -0.772 i,1.\\}, \\{0.25\\, +0.144 i,1.353\\, +0.772 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(35/4), -(7/2), (5/4)],\n [-(3/2), -(39/4), (13/2)],\n [(39/4), -(9/2), -(11/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -6 & 6 & 0 & -10 & 10 \\\\\n 6 & 3 & -1 & 0 & 1 \\\\\n -8 & -9 & 2 & 5 & -6 \\\\\n 4 & 9 & 6 & -2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 1 \\\\\n 0 & 1 & 0 & 0 & -\\frac{62}{43} \\\\\n 0 & 0 & 1 & 0 & \\frac{29}{43} \\\\\n 0 & 0 & 0 & 1 & -\\frac{106}{43} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-6, 6, 0, -10, 10],\n [6, 3, -1, 0, 1],\n [-8, -9, 2, 5, -6],\n [4, 9, 6, -2, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{3,2,1\\}, \\{1,-2,-1\\}, \\{-3,-2,-1\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{3}{\\sqrt{14}},\\sqrt{\\frac{2}{7}},\\frac{1}{\\sqrt{14}}\\right\\}, \\left\\{\\sqrt{\\frac{5}{14}},-3 \\sqrt{\\frac{2}{35}},-\\frac{3}{\\sqrt{70}}\\right\\}, \\{0,0,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((3, 2, 1), (1, -2, -1), (-3, -2, -1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{21}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{133}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7]])\nb = np.array([\n [-(21/16)]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $1$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & 10 & 8 \\\\\n 1 & 8 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & 10 & 8 \\\\\n 1 & 8 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 10, 8],\n [1, 8, -4]])\nprint(a * 1)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -10 \\\\\n 8 \\\\\n -4 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 0 \\\\\n 6 \\\\\n -7 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(76 \\sqrt{\\frac{2}{20955}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-10],\n [8],\n [-4],\n [-7]]).squeeze()\nb = np.array([\n [4],\n [0],\n [6],\n [-7],\n [-8]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{8}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & -5 & -4 \\\\\n 8 & -6 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & -\\frac{5}{8} & -\\frac{1}{2} \\\\\n 1 & -\\frac{3}{4} & -\\frac{5}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -5, -4],\n [8, -6, -10]])\nprint(a * (1/8))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{15}{8}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & -9 & 9 \\\\\n -10 & -8 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{45}{8} & \\frac{135}{8} & -\\frac{135}{8} \\\\\n \\frac{75}{4} & 15 & \\frac{15}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -9, 9],\n [-10, -8, -1]])\nprint(a * -(15/8))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{26}{5} & \\frac{8}{5} & 1 \\\\\n -3 & -\\frac{7}{5} & -\\frac{37}{5} \\\\\n 4 & -\\frac{29}{5} & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.261,1.29,1.\\}, \\{-0.239-0.22 i,-0.883-0.009 i,1.\\}, \\{-0.239+0.22 i,-0.883+0.009 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/5), (8/5), 1],\n [-3, -(7/5), -(37/5)],\n [4, -(29/5), 2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{e} \\\\\n -\\frac{22}{e} \\\\\n \\frac{22}{e} \\\\\n \\frac{17}{e} \\\\\n \\frac{16}{e} \\\\\n -\\frac{8}{e} \\\\\n \\frac{17}{e} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{11}{e} \\\\\n \\frac{3}{e} \\\\\n -\\frac{18}{e} \\\\\n \\frac{1}{e} \\\\\n \\frac{24}{e} \\\\\n -\\frac{26}{e} \\\\\n -\\frac{25}{e} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{5309}}{e}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(15/math.e)],\n [-(22/math.e)],\n [(22/math.e)],\n [(17/math.e)],\n [(16/math.e)],\n [-(8/math.e)],\n [(17/math.e)]])\nb = np.array([\n [(11/math.e)],\n [(3/math.e)],\n [-(18/math.e)],\n [(1/math.e)],\n [(24/math.e)],\n [-(26/math.e)],\n [-(25/math.e)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & -4 & -5 \\\\\n -4 & -3 & 2 \\\\\n 0 & 3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$62$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -4, -5],\n [-4, -3, 2],\n [0, 3, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{18}{5}, -\\frac{14}{5}, -\\frac{21}{5}}$ to the plane $-\\frac{6 x}{5}+3 y+2 z-4=0$.", - "Output Answer": [ - "$\\frac{412}{95}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(18/5), -(14/5), -(21/5)\nplane = Poly(-((6*x)/5)+3*y+2*z-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & 0 & 4 \\\\\n 4 & 1 & -7 \\\\\n 4 & 6 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-2.01-5.93 i,-2.01+5.93 i,6.02\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 0, 4],\n [4, 1, -7],\n [4, 6, -3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{5} \\\\\n \\frac{13}{5} \\\\\n \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{14}{\\sqrt{1497}} \\\\\n \\frac{26}{\\sqrt{1497}} \\\\\n \\frac{25}{\\sqrt{1497}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/5)],\n [(13/5)],\n [(5/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{16}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{5}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2]])\nprint(a * (5/16))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{4} \\\\\n -\\frac{15}{2} \\\\\n \\frac{11}{2} \\\\\n -\\frac{61}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{21}{4} \\\\\n \\frac{69}{8} \\\\\n -2 \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{11}{2} \\\\\n -\\frac{129}{8} \\\\\n \\frac{15}{2} \\\\\n -\\frac{109}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/4)],\n [-(15/2)],\n [(11/2)],\n [-(61/8)]])\nb = np.array([\n [-(21/4)],\n [(69/8)],\n [-2],\n [6]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{3}{16} & -1 & -\\frac{9}{16} & \\frac{47}{16} & \\frac{23}{16} \\\\\n -\\frac{5}{8} & -\\frac{11}{8} & \\frac{47}{16} & -1 & -\\frac{15}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{16} & \\frac{1}{2} \\\\\n \\frac{21}{8} & -\\frac{9}{8} \\\\\n \\frac{17}{16} & -\\frac{11}{4} \\\\\n -\\frac{43}{16} & -\\frac{15}{8} \\\\\n \\frac{41}{16} & \\frac{11}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{475}{64} & -\\frac{449}{256} \\\\\n -\\frac{31}{128} & -\\frac{1437}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/16), -1, -(9/16), (47/16), (23/16)],\n [-(5/8), -(11/8), (47/16), -1, -(15/16)]])\nb = np.array([\n [(1/16), (1/2)],\n [(21/8), -(9/8)],\n [(17/16), -(11/4)],\n [-(43/16), -(15/8)],\n [(41/16), (11/16)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{23}{3} & -4 \\\\\n -9 & -\\frac{22}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{6} \\left(-45-\\sqrt{1297}\\right),\\frac{1}{6} \\left(\\sqrt{1297}-45\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/3), -4],\n [-9, -(22/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{26}{3} & \\frac{17}{3} \\\\\n -8 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{48} \\left(-29-i \\sqrt{791}\\right),1\\right\\}, \\left\\{\\frac{1}{48} \\left(-29+i \\sqrt{791}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/3), (17/3)],\n [-8, -1]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7 \\sqrt{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [3]])\nb = np.array([\n [-3],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & -9 & 1 \\\\\n -8 & 7 & 2 \\\\\n -7 & 9 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [6, -9, 1],\n [-8, 7, 2],\n [-7, 9, 5]]))\nprint(a.nullspace())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\sqrt{3} \\\\\n 5 \\sqrt{3} \\\\\n 0 \\\\\n -3 \\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n 2 \\sqrt{3} \\\\\n -\\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n -4 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -4 \\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{591}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [2*math.sqrt(3)],\n [5*math.sqrt(3)],\n [0],\n [-3*math.sqrt(3)],\n [4*math.sqrt(3)],\n [3*math.sqrt(3)],\n [2*math.sqrt(3)],\n [-math.sqrt(3)],\n [3*math.sqrt(3)],\n [-4*math.sqrt(3)]])\nb = np.array([\n [0],\n [0],\n [-4*math.sqrt(3)],\n [-2*math.sqrt(3)],\n [-5*math.sqrt(3)],\n [3*math.sqrt(3)],\n [math.sqrt(3)],\n [math.sqrt(3)],\n [-5*math.sqrt(3)],\n [-5*math.sqrt(3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{881}{100} \\\\\n -\\frac{991}{100} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{50} \\\\\n \\frac{91}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{883}{100} \\\\\n -\\frac{271}{20} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(881/100)],\n [-(991/100)]])\nb = np.array([\n [-(1/50)],\n [(91/25)]])\nprint(a - b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -4 & 6 & 9 \\\\\n -3 & 6 & 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 1 & -3 & 5 \\\\\n -3 & 2 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -3 & 3 & 14 \\\\\n -6 & 8 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 6, 9],\n [-3, 6, 9]])\nb = np.array([\n [1, -3, 5],\n [-3, 2, -4]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 10 & -1 & 0 \\\\\n -8 & 10 & 0 \\\\\n -9 & -4 & 10 \\\\\n -1 & 1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, -1, 0],\n [-8, 10, 0],\n [-9, -4, 10],\n [-1, 1, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & 2 & 0 \\\\\n 0 & -1 & 2 \\\\\n -3 & 3 & 0 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & -4 & 4 \\\\\n -6 & 7 & -2 \\\\\n 3 & -9 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2, 0],\n [0, -1, 2],\n [-3, 3, 0]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{3} & -\\frac{25}{3} & \\frac{8}{3} \\\\\n -\\frac{11}{3} & \\frac{2}{3} & -8 \\\\\n -\\frac{22}{3} & -\\frac{4}{3} & -\\frac{10}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.733,0.998,1.\\}, \\{-0.846-0.893 i,0.26\\, +1.043 i,1.\\}, \\{-0.846+0.893 i,0.26\\, -1.043 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/3), -(25/3), (8/3)],\n [-(11/3), (2/3), -8],\n [-(22/3), -(4/3), -(10/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{2} & -2 & 2 \\\\\n -\\frac{5}{2} & \\frac{3}{2} & \\frac{5}{2} \\\\\n -\\frac{1}{2} & \\frac{3}{2} & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{17}{4} & 1 & -8 \\\\\n -\\frac{15}{4} & 11 & -\\frac{15}{4} \\\\\n -3 & \\frac{7}{4} & \\frac{15}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), -2, 2],\n [-(5/2), (3/2), (5/2)],\n [-(1/2), (3/2), -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 0 & -7 & 0 & -8 \\\\\n -6 & 0 & -10 & 5 \\\\\n 4 & -3 & 2 & 0 \\\\\n 8 & -1 & 3 & 4 \\\\\n -10 & 0 & -9 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, -7, 0, -8],\n [-6, 0, -10, 5],\n [4, -3, 2, 0],\n [8, -1, 3, 4],\n [-10, 0, -9, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -1 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 10 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 82 \\\\\n 73 \\\\\n -81 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-1],\n [-9]])\nb = np.array([\n [-1],\n [10],\n [8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -3 & 7 & -8 \\\\\n 1 & -4 & -8 \\\\\n -4 & 3 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-7 x^2+3 x+256$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 7, -8],\n [1, -4, -8],\n [-4, 3, 0]])\nprint(np.poly(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & 2 \\\\\n -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2],\n [-1, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & -3 & -1 & 0 \\\\\n -1 & 3 & 2 & 3 \\\\\n 1 & 2 & -1 & -1 \\\\\n 3 & 3 & 2 & 2 \\\\\n -3 & 0 & 2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.9 \\\\\n 1.24 \\\\\n 0.09 \\\\\n 1.86 \\\\\n 2.79 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.115 \\\\\n 0.142 \\\\\n 0.937 \\\\\n -0.383 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3, -1, 0],\n [-1, 3, 2, 3],\n [1, 2, -1, -1],\n [3, 3, 2, 2],\n [-3, 0, 2, -3]])\nb = np.array([\n [-0.9],\n [1.24],\n [0.09],\n [1.86],\n [2.79]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n 2 \\\\\n -1 \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{13}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{39}{16} \\\\\n \\frac{13}{4} \\\\\n -\\frac{13}{8} \\\\\n -\\frac{39}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2)],\n [2],\n [-1],\n [-(3/2)]])\nb = np.array([\n [(13/8)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -\\frac{21}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{16}{\\sqrt{305}} \\\\\n -\\frac{7}{\\sqrt{305}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-(21/16)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{11}{\\sqrt{3}} \\\\\n 3 \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n -\\frac{16}{\\sqrt{3}} \\\\\n -\\frac{16}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{\\sqrt{3}} \\\\\n \\frac{4}{\\sqrt{3}} \\\\\n 4 \\sqrt{3} \\\\\n \\frac{14}{\\sqrt{3}} \\\\\n \\frac{16}{\\sqrt{3}} \\\\\n -\\frac{13}{\\sqrt{3}} \\\\\n -\\frac{4}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{91}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(11/(math.sqrt(3)))],\n [3*math.sqrt(3)],\n [math.sqrt(3)],\n [-5*math.sqrt(3)],\n [3*math.sqrt(3)],\n [-(16/(math.sqrt(3)))],\n [-(16/(math.sqrt(3)))]])\nb = np.array([\n [-(17/(math.sqrt(3)))],\n [(4/(math.sqrt(3)))],\n [4*math.sqrt(3)],\n [(14/(math.sqrt(3)))],\n [(16/(math.sqrt(3)))],\n [-(13/(math.sqrt(3)))],\n [-(4/(math.sqrt(3)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -3 & -\\frac{3}{2} & -\\frac{11}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -1 & \\frac{11}{4} & -1 & \\frac{3}{2} \\\\\n -\\frac{5}{4} & \\frac{5}{4} & -1 & 3 \\\\\n \\frac{3}{4} & -\\frac{5}{2} & -\\frac{9}{4} & \\frac{7}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{45}{16} & -\\frac{13}{4} & \\frac{171}{16} & -\\frac{221}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -(3/2), -(11/4)]])\nb = np.array([\n [-1, (11/4), -1, (3/2)],\n [-(5/4), (5/4), -1, 3],\n [(3/4), -(5/2), -(9/4), (7/4)]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -2 & -2 & 0 & -3 & 1 \\\\\n -3 & 0 & 1 & -1 & -2 \\\\\n 1 & 0 & 2 & 0 & 1 \\\\\n -3 & 3 & -3 & -1 & 0 \\\\\n -1 & 3 & -3 & -2 & 0 \\\\\n 1 & -3 & 0 & -3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.18 \\\\\n -2.85 \\\\\n 1.48 \\\\\n 0.87 \\\\\n -0.3 \\\\\n -1.83 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.331 \\\\\n 0.584 \\\\\n 0.217 \\\\\n 0.946 \\\\\n 1.27 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2, 0, -3, 1],\n [-3, 0, 1, -1, -2],\n [1, 0, 2, 0, 1],\n [-3, 3, -3, -1, 0],\n [-1, 3, -3, -2, 0],\n [1, -3, 0, -3, 3]])\nb = np.array([\n [-1.18],\n [-2.85],\n [1.48],\n [0.87],\n [-0.3],\n [-1.83]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{64}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 3 \\\\\n 4 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{35}{64} \\\\\n -\\frac{21}{64} \\\\\n -\\frac{7}{16} \\\\\n -\\frac{21}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [3],\n [4],\n [6]])\nprint(a * -(7/64))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -7 \\\\\n -2 \\\\\n 6 \\\\\n 8 \\\\\n 0 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 6 \\\\\n -9 \\\\\n -5 \\\\\n 8 \\\\\n -8 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$22$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-7],\n [-2],\n [6],\n [8],\n [0],\n [-3]])\nb = np.array([\n [-4],\n [6],\n [-9],\n [-5],\n [8],\n [-8],\n [8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{1}{3},-\\frac{13}{3},-\\frac{1}{3}\\right\\}, \\left\\{\\frac{7}{3},3,-\\frac{1}{3}\\right\\}, \\left\\{-\\frac{13}{3},-3,-\\frac{1}{3}\\right\\}}$.", - "Output Answer": [ - "$3 z+1=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(1/3), -(13/3), -(1/3)],\n [(7/3), 3, -(1/3)],\n [-(13/3), -3, -(1/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & 1 \\\\\n -1 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{2 \\left(3-\\sqrt{2}\\right),2 \\left(3+\\sqrt{2}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1],\n [-1, 9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -3 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1]])\nb = np.array([\n [1],\n [-2]])\nprint(a @ b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 6 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [6],\n [-9]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{1,-2,1\\}, \\{0,2,-1\\}, \\{1,0,0\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{6}},-\\sqrt{\\frac{2}{3}},\\frac{1}{\\sqrt{6}}\\right\\}, \\left\\{\\sqrt{\\frac{5}{6}},\\sqrt{\\frac{2}{15}},-\\frac{1}{\\sqrt{30}}\\right\\}, \\{0,0,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((1, -2, 1), (0, 2, -1), (1, 0, 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 8 & -2 & -6 & 0 \\\\\n -1 & 0 & -7 & -3 \\\\\n -6 & 3 & -7 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & 3 & -6 & 3 \\\\\n -7 & -10 & -6 & 9 \\\\\n 1 & 6 & 4 & 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 10 & 1 & -12 & 3 \\\\\n -8 & -10 & -13 & 6 \\\\\n -5 & 9 & -3 & 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -2, -6, 0],\n [-1, 0, -7, -3],\n [-6, 3, -7, 1]])\nb = np.array([\n [2, 3, -6, 3],\n [-7, -10, -6, 9],\n [1, 6, 4, 10]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -8 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 6 \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 20 \\\\\n -30 \\\\\n 20 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-8],\n [-6]])\nb = np.array([\n [7],\n [6],\n [2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 2 \\\\\n 3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{9},-\\frac{1}{9},-\\frac{1}{6},-\\frac{1}{18}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [0],\n [-1]]).squeeze()\nb = np.array([\n [-2],\n [2],\n [3],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -7 & -1 \\\\\n -5 & -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 0 & -3 \\\\\n -4 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -7 & -4 \\\\\n -9 & -14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -1],\n [-5, -9]])\nb = np.array([\n [0, -3],\n [-4, -5]])\nprint(a + b)\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, 3, 4}$ to the plane $-5 x-4 y+3 z-1=0$.", - "Output Answer": [ - "$\\frac{7 \\sqrt{2}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, 3, 4\nplane = Poly(-5*x-4*y+3*z-1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, -4, \\frac{2}{3}}$ to the plane $\\frac{10 x}{3}+3 y+2 z-\\frac{8}{3}=0$.", - "Output Answer": [ - "$10 \\sqrt{\\frac{7}{31}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, -4, (2/3)\nplane = Poly(((10*x)/3)+3*y+2*z-(8/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{3} \\\\\n 3 \\\\\n -1 \\\\\n \\frac{20}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n \\frac{7}{3} \\\\\n -10 \\\\\n -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(76 \\sqrt{\\frac{2}{316979}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/3)],\n [3],\n [-1],\n [(20/3)]]).squeeze()\nb = np.array([\n [1],\n [(7/3)],\n [-10],\n [-(2/3)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{16}{7} \\\\\n -\\frac{60}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{4 \\sqrt{241}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(16/7)],\n [-(60/7)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "dev" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -\\frac{77}{16} & -\\frac{113}{16} \\\\\n \\frac{59}{8} & -\\frac{3}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(77/16), -(113/16)],\n [(59/8), -(3/8)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -1 & -1 \\\\\n -2 & 2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -1 & 9 \\\\\n 3 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & -10 \\\\\n -5 & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1],\n [-2, 2]])\nb = np.array([\n [-1, 9],\n [3, 9]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -5 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-5],\n [10]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & -7 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.,0.,6.\\}, \\{7.,6.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [6, -7, 1]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 8 & 8 & -5 \\\\\n -4 & -4 & -3 \\\\\n 3 & 0 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-x^2+5 x-132$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 8, -5],\n [-4, -4, -3],\n [3, 0, -5]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{2} & \\frac{1}{2} & -1 \\\\\n -\\frac{5}{2} & -\\frac{1}{2} & -2 \\\\\n 0 & \\frac{3}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n 2 \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{17}{4} \\\\\n \\frac{7}{4} \\\\\n \\frac{11}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), (1/2), -1],\n [-(5/2), -(1/2), -2],\n [0, (3/2), -(1/2)]])\nb = np.array([\n [-(3/2)],\n [2],\n [(1/2)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{26}{3} \\\\\n \\frac{23}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{26}{3} \\\\\n -\\frac{29}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}+\\tan ^{-1}\\left(\\frac{1343}{156}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/3)],\n [(23/3)]]).squeeze()\nb = np.array([\n [-(26/3)],\n [-(29/3)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 8 & 9 & -1 & 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -3 & 0 & -5 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 5 & 9 & -6 & 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 9, -1, 4]])\nb = np.array([\n [-3, 0, -5, 7]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{3} \\\\\n 1 \\\\\n -1 \\\\\n -\\frac{7}{3} \\\\\n \\frac{7}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{4}{3} & -\\frac{2}{3} & -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{16}{9} & \\frac{8}{9} & \\frac{8}{9} \\\\\n \\frac{4}{3} & -\\frac{2}{3} & -\\frac{2}{3} \\\\\n -\\frac{4}{3} & \\frac{2}{3} & \\frac{2}{3} \\\\\n -\\frac{28}{9} & \\frac{14}{9} & \\frac{14}{9} \\\\\n \\frac{28}{9} & -\\frac{14}{9} & -\\frac{14}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/3)],\n [1],\n [-1],\n [-(7/3)],\n [(7/3)]])\nb = np.array([\n [(4/3), -(2/3), -(2/3)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 5 & -\\frac{11}{3} & 8 \\\\\n \\frac{2}{3} & -\\frac{28}{3} & \\frac{14}{3} \\\\\n -\\frac{2}{3} & -\\frac{25}{3} & \\frac{11}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{2 x^2}{3}+\\frac{143 x}{9}-\\frac{1364}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -(11/3), 8],\n [(2/3), -(28/3), (14/3)],\n [-(2/3), -(25/3), (11/3)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{147}{16} & \\frac{19}{2} & \\frac{3}{2} & -\\frac{107}{16} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{43}{16} & -\\frac{117}{16} & -2 & -\\frac{65}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{13}{2} & \\frac{269}{16} & \\frac{7}{2} & -\\frac{21}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(147/16), (19/2), (3/2), -(107/16)]])\nb = np.array([\n [-(43/16), -(117/16), -2, -(65/16)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -5 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 26 \\\\\n -6 \\\\\n -14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-5],\n [4]])\nb = np.array([\n [-2],\n [-4],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -5 \\sqrt{2} \\\\\n 4 \\sqrt{2} \\\\\n -4 \\sqrt{2} \\\\\n 5 \\sqrt{2} \\\\\n 6 \\sqrt{2} \\\\\n 3 \\sqrt{2} \\\\\n -\\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\sqrt{2} \\\\\n -7 \\sqrt{2} \\\\\n \\sqrt{2} \\\\\n -5 \\sqrt{2} \\\\\n 4 \\sqrt{2} \\\\\n -5 \\sqrt{2} \\\\\n -2 \\sqrt{2} \\\\\n 4 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{422}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [-5*math.sqrt(2)],\n [4*math.sqrt(2)],\n [-4*math.sqrt(2)],\n [5*math.sqrt(2)],\n [6*math.sqrt(2)],\n [3*math.sqrt(2)],\n [-math.sqrt(2)]])\nb = np.array([\n [5*math.sqrt(2)],\n [-7*math.sqrt(2)],\n [math.sqrt(2)],\n [-5*math.sqrt(2)],\n [4*math.sqrt(2)],\n [-5*math.sqrt(2)],\n [-2*math.sqrt(2)],\n [4*math.sqrt(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{8} & \\frac{23}{8} \\\\\n \\frac{77}{8} & -\\frac{7}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{5 x}{8}-\\frac{1897}{64}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/8), (23/8)],\n [(77/8), -(7/4)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & 3 \\\\\n 10 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{2-\\sqrt{34},2+\\sqrt{34}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 3],\n [10, 4]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 2 & -\\frac{3}{2} \\\\\n -2 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{31}{2} & -\\frac{75}{8} \\\\\n -\\frac{25}{2} & -\\frac{51}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(3/2)],\n [-2, -(3/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 3 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{11}} \\\\\n \\frac{3}{\\sqrt{11}} \\\\\n -\\frac{1}{\\sqrt{11}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [3],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{11}{3},-\\frac{2}{3},1\\right\\}, \\left\\{-3,-\\frac{1}{3},\\frac{11}{3}\\right\\}, \\left\\{-\\frac{10}{3},0,\\frac{8}{3}\\right\\}}$.", - "Output Answer": [ - "$11 x+68 y+19 z-14=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(11/3), -(2/3), 1],\n [-3, -(1/3), (11/3)],\n [-(10/3), 0, (8/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & -1 \\\\\n -3 & -2 \\\\\n -2 & 3 \\\\\n 2 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.57 \\\\\n -0.05 \\\\\n -2.67 \\\\\n -0.8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.155 \\\\\n -0.625 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -1],\n [-3, -2],\n [-2, 3],\n [2, -1]])\nb = np.array([\n [2.57],\n [-0.05],\n [-2.67],\n [-0.8]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -7 & 1 & -1 & -9 \\\\\n -3 & -9 & 6 & -8 \\\\\n -5 & 6 & -2 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 1, -1, -9],\n [-3, -9, 6, -8],\n [-5, 6, -2, -5]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & -3 & -1 \\\\\n -2 & 1 & 1 \\\\\n -2 & -2 & -1 \\\\\n 2 & 1 & 2 \\\\\n 2 & 3 & 0 \\\\\n -1 & 3 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.67 \\\\\n -1.73 \\\\\n 2.41 \\\\\n 0.43 \\\\\n -1.5 \\\\\n -2.95 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.119 \\\\\n -0.386 \\\\\n 0.042 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3, -1],\n [-2, 1, 1],\n [-2, -2, -1],\n [2, 1, 2],\n [2, 3, 0],\n [-1, 3, 1]])\nb = np.array([\n [-2.67],\n [-1.73],\n [2.41],\n [0.43],\n [-1.5],\n [-2.95]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & -3 \\\\\n 2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3],\n [2, -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -5 & -6 & 1 & -2 & -1 & 2 & 1 \\\\\n -5 & -3 & -6 & -9 & -1 & 4 & -9 \\\\\n 5 & -5 & -1 & -6 & -4 & 7 & 0 \\\\\n 0 & -8 & 9 & -10 & 7 & -7 & 4 \\\\\n 9 & -2 & 0 & -4 & 9 & 0 & -5 \\\\\n -7 & 7 & 9 & 4 & -9 & 1 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & \\frac{50112}{61027} \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & -\\frac{299609}{183081} \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & -\\frac{111440}{183081} \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & \\frac{140923}{183081} \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & -\\frac{255995}{183081} \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & -\\frac{362801}{183081} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, -6, 1, -2, -1, 2, 1],\n [-5, -3, -6, -9, -1, 4, -9],\n [5, -5, -1, -6, -4, 7, 0],\n [0, -8, 9, -10, 7, -7, 4],\n [9, -2, 0, -4, 9, 0, -5],\n [-7, 7, 9, 4, -9, 1, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 0 & -1 & 2 & -2 & -1 \\\\\n -2 & 0 & 1 & -1 & -1 \\\\\n 1 & 3 & 1 & -1 & 2 \\\\\n 2 & 2 & 3 & 2 & 2 \\\\\n 1 & 0 & -3 & -2 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -3 \\\\\n -3 \\\\\n 3 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -8 \\\\\n -5 \\\\\n -17 \\\\\n -11 \\\\\n 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -1, 2, -2, -1],\n [-2, 0, 1, -1, -1],\n [1, 3, 1, -1, 2],\n [2, 2, 3, 2, 2],\n [1, 0, -3, -2, 1]])\nb = np.array([\n [0],\n [-3],\n [-3],\n [3],\n [-1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{781}{100} \\\\\n -\\frac{59}{10} \\\\\n \\frac{993}{100} \\\\\n -\\frac{221}{50} \\\\\n -\\frac{34}{25} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{\\frac{215797}{10}}}{10}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(781/100)],\n [-(59/10)],\n [(993/100)],\n [-(221/50)],\n [-(34/25)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & -2 & 1 & -2 \\\\\n -1 & 2 & -1 & 1 \\\\\n 0 & 1 & -2 & 3 \\\\\n -1 & 0 & 0 & -1 \\\\\n 0 & -3 & -2 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.95 \\\\\n -1.55 \\\\\n 0.84 \\\\\n 1.62 \\\\\n -0.47 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -5.12 \\\\\n -3.435 \\\\\n 3.5 \\\\\n 3.7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2, 1, -2],\n [-1, 2, -1, 1],\n [0, 1, -2, 3],\n [-1, 0, 0, -1],\n [0, -3, -2, -1]])\nb = np.array([\n [-1.95],\n [-1.55],\n [0.84],\n [1.62],\n [-0.47]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n -5 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2)],\n [-5],\n [-6]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 3 & -5 & -10 \\\\\n 3 & -1 & -7 \\\\\n 6 & 1 & -6 \\\\\n 7 & -6 & 3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -5 & 2 & -5 \\\\\n 7 & 1 & 4 \\\\\n 7 & -3 & 4 \\\\\n 5 & -9 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 8 & -7 & -5 \\\\\n -4 & -2 & -11 \\\\\n -1 & 4 & -10 \\\\\n 2 & 3 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -5, -10],\n [3, -1, -7],\n [6, 1, -6],\n [7, -6, 3]])\nb = np.array([\n [-5, 2, -5],\n [7, 1, 4],\n [7, -3, 4],\n [5, -9, 8]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 8 \\\\\n 9 \\\\\n -9 \\\\\n 7 \\\\\n -5 \\\\\n 4 \\\\\n -3 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -9 \\\\\n -2 \\\\\n 8 \\\\\n 9 \\\\\n 6 \\\\\n 7 \\\\\n -6 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{1023}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [8],\n [9],\n [-9],\n [7],\n [-5],\n [4],\n [-3],\n [4]])\nb = np.array([\n [6],\n [-9],\n [-2],\n [8],\n [9],\n [6],\n [7],\n [-6],\n [-5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & -2 & 3 \\\\\n 1 & -2 & -4 \\\\\n -2 & 2 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{10} & -\\frac{3}{5} & -\\frac{7}{10} \\\\\n -\\frac{1}{4} & 0 & \\frac{1}{4} \\\\\n \\frac{1}{10} & -\\frac{2}{5} & -\\frac{3}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2, 3],\n [1, -2, -4],\n [-2, 2, 3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-5,1,1\\}, \\{4,4,-2\\}, \\{-1,-1,-2\\}}$.", - "Output Answer": [ - "$x-y+2 z+4=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-5, 1, 1],\n [4, 4, -2],\n [-1, -1, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{27}{5} & -\\frac{39}{5} \\\\\n \\frac{13}{5} & \\frac{16}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{26} i \\left(\\sqrt{1907}-11 i\\right),1\\right\\}, \\left\\{-\\frac{1}{26} i \\left(\\sqrt{1907}+11 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(27/5), -(39/5)],\n [(13/5), (16/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 4 & \\frac{3}{2} & -\\frac{5}{2} \\\\\n -\\frac{1}{2} & \\frac{9}{2} & 1 \\\\\n -2 & 2 & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{110}{277} & -\\frac{82}{277} & \\frac{102}{277} \\\\\n -\\frac{2}{277} & \\frac{72}{277} & -\\frac{22}{277} \\\\\n \\frac{64}{277} & -\\frac{88}{277} & \\frac{150}{277} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, (3/2), -(5/2)],\n [-(1/2), (9/2), 1],\n [-2, 2, (7/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & -\\frac{1}{2} & -2 \\\\\n \\frac{5}{2} & 2 & \\frac{1}{2} \\\\\n \\frac{5}{2} & 2 & 3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{317}{8} & -\\frac{199}{8} & -17 \\\\\n \\frac{95}{8} & -\\frac{15}{8} & -\\frac{185}{8} \\\\\n \\frac{395}{8} & 20 & -\\frac{85}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(1/2), -2],\n [(5/2), 2, (1/2)],\n [(5/2), 2, 3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -2 & -5 & 5 & -2 & 7 \\\\\n 3 & 8 & 7 & 8 & -5 \\\\\n 7 & 1 & -9 & 6 & -5 \\\\\n 8 & 3 & -1 & 9 & -6 \\\\\n 3 & -8 & 1 & 8 & 3 \\\\\n -3 & -4 & -5 & -8 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, -5, 5, -2, 7],\n [3, 8, 7, 8, -5],\n [7, 1, -9, 6, -5],\n [8, 3, -1, 9, -6],\n [3, -8, 1, 8, 3],\n [-3, -4, -5, -8, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 7 & -10 & 10 \\\\\n 8 & -9 & -3 \\\\\n -3 & -3 & 1 \\\\\n 2 & 7 & 6 \\\\\n -5 & 9 & -2 \\\\\n 4 & 9 & -6 \\\\\n 1 & -7 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, -10, 10],\n [8, -9, -3],\n [-3, -3, 1],\n [2, 7, 6],\n [-5, 9, -2],\n [4, 9, -6],\n [1, -7, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{31}{4} \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{64}{5 \\sqrt{193}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(31/4)],\n [-(1/2)]]).squeeze()\nb = np.array([\n [7],\n [-(7/2)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\log (2) \\\\\n -5 \\log (2) \\\\\n -\\log (2) \\\\\n \\log (2) \\\\\n 7 \\log (2) \\\\\n 4 \\log (2) \\\\\n -2 \\log (2) \\\\\n -8 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 11 \\log (2) \\\\\n -4 \\log (2) \\\\\n 9 \\log (2) \\\\\n -14 \\log (2) \\\\\n -4 \\log (2) \\\\\n 7 \\log (2) \\\\\n -14 \\log (2) \\\\\n -4 \\log (2) \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\log ^2(2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-5*math.log(2)],\n [-5*math.log(2)],\n [-math.log(2)],\n [math.log(2)],\n [7*math.log(2)],\n [4*math.log(2)],\n [-2*math.log(2)],\n [-8*math.log(2)]])\nb = np.array([\n [11*math.log(2)],\n [-4*math.log(2)],\n [9*math.log(2)],\n [-14*math.log(2)],\n [-4*math.log(2)],\n [7*math.log(2)],\n [-14*math.log(2)],\n [-4*math.log(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{4}{7}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & 2 & 5 & -4 \\\\\n 6 & 8 & 1 & -9 \\\\\n 9 & -7 & 8 & 6 \\\\\n 3 & -1 & -9 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{8}{7} & -\\frac{8}{7} & -\\frac{20}{7} & \\frac{16}{7} \\\\\n -\\frac{24}{7} & -\\frac{32}{7} & -\\frac{4}{7} & \\frac{36}{7} \\\\\n -\\frac{36}{7} & 4 & -\\frac{32}{7} & -\\frac{24}{7} \\\\\n -\\frac{12}{7} & \\frac{4}{7} & \\frac{36}{7} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, 5, -4],\n [6, 8, 1, -9],\n [9, -7, 8, 6],\n [3, -1, -9, 0]])\nprint(a * -(4/7))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 1 & \\frac{17}{8} \\\\\n \\frac{39}{8} & \\frac{13}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{8}{43} & \\frac{136}{559} \\\\\n \\frac{24}{43} & -\\frac{64}{559} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, (17/8)],\n [(39/8), (13/8)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & -\\frac{29}{4} & \\frac{23}{4} \\\\\n 0 & -\\frac{5}{4} & \\frac{7}{2} \\\\\n \\frac{1}{2} & \\frac{3}{4} & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{9 x^2}{4}+\\frac{67 x}{8}-\\frac{393}{32}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), -(29/4), (23/4)],\n [0, -(5/4), (7/2)],\n [(1/2), (3/4), 3]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{15}{32}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 8 & -5 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{15}{4} & \\frac{75}{32} & -\\frac{75}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -5, 5]])\nprint(a * -(15/32))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -2 & -6 & 9 & 5 \\\\\n -1 & -1 & 7 & -7 \\\\\n 6 & 3 & 6 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & \\frac{53}{23} \\\\\n 0 & 1 & 0 & -\\frac{229}{69} \\\\\n 0 & 0 & 1 & -\\frac{79}{69} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, -6, 9, 5],\n [-1, -1, 7, -7],\n [6, 3, 6, -3]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -1 & -7 & 6 \\\\\n 1 & 1 & 9 \\\\\n 1 & 7 & -2 \\\\\n 9 & -9 & 3 \\\\\n 8 & 5 & 9 \\\\\n -5 & 9 & -10 \\\\\n 6 & -3 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-1, -7, 6],\n [1, 1, 9],\n [1, 7, -2],\n [9, -9, 3],\n [8, 5, 9],\n [-5, 9, -10],\n [6, -3, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\sqrt{3} \\\\\n -\\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\sqrt{3} \\\\\n -3 \\sqrt{3} \\\\\n -\\sqrt{3} \\\\\n -5 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-18$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-3*math.sqrt(3)],\n [-math.sqrt(3)],\n [3*math.sqrt(3)],\n [3*math.sqrt(3)]])\nb = np.array([\n [-3*math.sqrt(3)],\n [-3*math.sqrt(3)],\n [-math.sqrt(3)],\n [-5*math.sqrt(3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & -1 & 6 \\\\\n 1 & 6 & 7 \\\\\n 5 & 8 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-4.058,2.555,1.\\}, \\{-0.653,-0.76,1.\\}, \\{0.641,0.749,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -1, 6],\n [1, 6, 7],\n [5, 8, 7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -3 & 8 & 7 & 8 & 8 \\\\\n 2 & -9 & 5 & 2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 8, 7, 8, 8],\n [2, -9, 5, 2, 0]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -1 \\\\\n 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -28 \\\\\n -20 \\\\\n 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-3],\n [2]])\nb = np.array([\n [5],\n [-1],\n [10]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -9 & 10 & -2 \\\\\n 1 & -6 & 2 \\\\\n 3 & 7 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-7.934,1.338,1.\\}, \\{-2.118,-0.486,1.\\}, \\{-0.016,0.177,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 10, -2],\n [1, -6, 2],\n [3, 7, 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 1 & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{5}{2} & \\frac{17}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), 9]])\nb = np.array([\n [1, -(1/2)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{9}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & -6 \\\\\n 0 & -9 \\\\\n -3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & -\\frac{14}{3} \\\\\n 0 & -7 \\\\\n -\\frac{7}{3} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -6],\n [0, -9],\n [-3, 0]])\nprint(a * (7/9))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -9 & 9 & 3 & 5 \\\\\n 0 & 8 & 10 & -6 \\\\\n 7 & 6 & -6 & 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 6 & 10 & -8 & 4 \\\\\n 3 & 7 & -5 & -4 \\\\\n 6 & 1 & 8 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -3 & 19 & -5 & 9 \\\\\n 3 & 15 & 5 & -10 \\\\\n 13 & 7 & 2 & 15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 9, 3, 5],\n [0, 8, 10, -6],\n [7, 6, -6, 6]])\nb = np.array([\n [6, 10, -8, 4],\n [3, 7, -5, -4],\n [6, 1, 8, 9]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{3,-1,-1\\}, \\{3,-3,1\\}, \\{0,-2,3\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{3}{\\sqrt{11}},-\\frac{1}{\\sqrt{11}},-\\frac{1}{\\sqrt{11}}\\right\\}, \\left\\{0,-\\frac{1}{\\sqrt{2}},\\frac{1}{\\sqrt{2}}\\right\\}, \\left\\{\\sqrt{\\frac{2}{11}},\\frac{3}{\\sqrt{22}},\\frac{3}{\\sqrt{22}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((3, -1, -1), (3, -3, 1), (0, -2, 3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{4}{3} & -3 \\\\\n \\frac{23}{9} & \\frac{28}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{84}{319} & \\frac{81}{319} \\\\\n -\\frac{69}{319} & \\frac{36}{319} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3), -3],\n [(23/9), (28/9)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{47}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{6}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{282}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(47/5)]])\nb = np.array([\n [(6/5)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{4}{3} \\\\\n \\frac{11}{3} \\\\\n -\\frac{17}{3} \\\\\n \\frac{17}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{20}{3} \\\\\n -\\frac{16}{3} \\\\\n -\\frac{19}{3} \\\\\n -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{6}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3)],\n [(11/3)],\n [-(17/3)],\n [(17/3)]])\nb = np.array([\n [(20/3)],\n [-(16/3)],\n [-(19/3)],\n [-(2/3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{371}{50} \\\\\n -\\frac{39}{5} \\\\\n -\\frac{363}{100} \\\\\n \\frac{571}{100} \\\\\n -\\frac{53}{20} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{2721}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(371/50)],\n [-(39/5)],\n [-(363/100)],\n [(571/100)],\n [-(53/20)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{149}{20} & \\frac{123}{100} & -\\frac{417}{100} \\\\\n -\\frac{663}{100} & -\\frac{319}{50} & \\frac{244}{25} \\\\\n -\\frac{271}{50} & -\\frac{68}{25} & -\\frac{489}{50} \\\\\n -\\frac{179}{100} & -\\frac{91}{10} & -\\frac{35}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{93}{20} & -\\frac{27}{50} & \\frac{799}{100} \\\\\n \\frac{227}{50} & -\\frac{203}{100} & -\\frac{61}{25} \\\\\n -\\frac{611}{100} & \\frac{483}{50} & -\\frac{7}{20} \\\\\n -\\frac{48}{5} & -\\frac{999}{100} & \\frac{17}{20} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{14}{5} & \\frac{177}{100} & -\\frac{304}{25} \\\\\n -\\frac{1117}{100} & -\\frac{87}{20} & \\frac{61}{5} \\\\\n \\frac{69}{100} & -\\frac{619}{50} & -\\frac{943}{100} \\\\\n \\frac{781}{100} & \\frac{89}{100} & -\\frac{48}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(149/20), (123/100), -(417/100)],\n [-(663/100), -(319/50), (244/25)],\n [-(271/50), -(68/25), -(489/50)],\n [-(179/100), -(91/10), -(35/4)]])\nb = np.array([\n [(93/20), -(27/50), (799/100)],\n [(227/50), -(203/100), -(61/25)],\n [-(611/100), (483/50), -(7/20)],\n [-(48/5), -(999/100), (17/20)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{37}{5} & \\frac{8}{5} & \\frac{22}{5} \\\\\n \\frac{43}{5} & \\frac{24}{5} & \\frac{41}{5} \\\\\n -\\frac{14}{5} & \\frac{21}{5} & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-9.262,2.421,11.041\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/5), (8/5), (22/5)],\n [(43/5), (24/5), (41/5)],\n [-(14/5), (21/5), -8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n -2 \\\\\n -\\frac{3}{2} \\\\\n 2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n -\\frac{1}{2} \\\\\n \\frac{1}{2} \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{3}{10},-\\frac{1}{10},\\frac{1}{10},\\frac{3}{10}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2)],\n [-2],\n [-(3/2)],\n [2]]).squeeze()\nb = np.array([\n [(3/2)],\n [-(1/2)],\n [(1/2)],\n [(3/2)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 0 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{85}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [0],\n [-9]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{36}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{62}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{2232}{49}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(36/7)]])\nb = np.array([\n [-(62/7)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -3 \\\\\n 2 \\\\\n 1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{19}} \\\\\n -\\frac{3}{\\sqrt{19}} \\\\\n \\frac{2}{\\sqrt{19}} \\\\\n \\frac{1}{\\sqrt{19}} \\\\\n -\\frac{2}{\\sqrt{19}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-3],\n [2],\n [1],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{4}{5} \\\\\n \\frac{36}{5} \\\\\n \\frac{44}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{63}{10} \\\\\n -\\frac{13}{5} \\\\\n \\frac{57}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1598}{25} \\\\\n -60 \\\\\n \\frac{1082}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/5)],\n [(36/5)],\n [(44/5)]])\nb = np.array([\n [-(63/10)],\n [-(13/5)],\n [(57/10)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{153}{32}, -\\frac{75}{16}}$ to the line $\\frac{145 x}{32}+\\frac{65 y}{16}-\\frac{17}{8}=0$.", - "Output Answer": [ - "$\\frac{509}{160 \\sqrt{1517}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (153/32), -(75/16)\nline = Poly(((145*x)/32)+((65*y)/16)-(17/8), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & -1 & -\\frac{1}{2} \\\\\n 2 & 2 & -\\frac{1}{2} \\\\\n \\frac{1}{2} & 2 & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{4} & -2 & \\frac{3}{2} \\\\\n \\frac{7}{4} & 1 & -\\frac{3}{2} \\\\\n 3 & \\frac{3}{2} & -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, -(1/2)],\n [2, 2, -(1/2)],\n [(1/2), 2, -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-1,\\frac{2}{3},-\\frac{10}{3}\\right\\}, \\left\\{-2,4,-\\frac{5}{3}\\right\\}, \\left\\{-2,\\frac{14}{3},-\\frac{8}{3}\\right\\}}$.", - "Output Answer": [ - "$40 x+9 y+6 z+54=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, (2/3), -(10/3)],\n [-2, 4, -(5/3)],\n [-2, (14/3), -(8/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{127}{16} & -\\frac{51}{16} \\\\\n \\frac{69}{8} & -\\frac{67}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{115}{16} & -\\frac{37}{8} \\\\\n -\\frac{49}{8} & -\\frac{19}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{121}{8} & -\\frac{125}{16} \\\\\n \\frac{5}{2} & -\\frac{105}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(127/16), -(51/16)],\n [(69/8), -(67/16)]])\nb = np.array([\n [-(115/16), -(37/8)],\n [-(49/8), -(19/8)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{29}{5} & \\frac{18}{5} \\\\\n \\frac{42}{5} & \\frac{28}{5} \\\\\n \\frac{49}{5} & -\\frac{33}{5} \\\\\n -\\frac{37}{5} & \\frac{21}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{41}{5} & 6 \\\\\n 4 & -\\frac{24}{5} \\\\\n \\frac{43}{5} & \\frac{7}{5} \\\\\n -2 & \\frac{42}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 14 & \\frac{48}{5} \\\\\n \\frac{62}{5} & \\frac{4}{5} \\\\\n \\frac{92}{5} & -\\frac{26}{5} \\\\\n -\\frac{47}{5} & \\frac{63}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/5), (18/5)],\n [(42/5), (28/5)],\n [(49/5), -(33/5)],\n [-(37/5), (21/5)]])\nb = np.array([\n [(41/5), 6],\n [4, -(24/5)],\n [(43/5), (7/5)],\n [-2, (42/5)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{19}{5}, \\frac{1}{5}, 5}$ to the plane $\\frac{21 x}{5}-\\frac{y}{5}+\\frac{12 z}{5}+\\frac{3}{5}=0$.", - "Output Answer": [ - "$\\frac{17}{\\sqrt{586}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(19/5), (1/5), 5\nplane = Poly(((21*x)/5)-(y/5)+((12*z)/5)+(3/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{8}{3} & -\\frac{7}{3} & -4 \\\\\n 4 & -\\frac{8}{3} & -\\frac{10}{3} \\\\\n \\frac{5}{3} & 1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{142}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(8/3), -(7/3), -4],\n [4, -(8/3), -(10/3)],\n [(5/3), 1, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -5 & -2 & 9 \\\\\n 0 & -10 & -6 \\\\\n 3 & 1 & 6 \\\\\n -8 & 3 & -8 \\\\\n -9 & 5 & 7 \\\\\n -3 & 6 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, -2, 9],\n [0, -10, -6],\n [3, 1, 6],\n [-8, 3, -8],\n [-9, 5, 7],\n [-3, 6, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{3} \\\\\n \\frac{7}{3} \\\\\n -\\frac{4}{3} \\\\\n \\frac{7}{3} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{7}{3} \\\\\n 2 \\\\\n \\frac{2}{3} \\\\\n -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{91}{279},\\frac{26}{93},\\frac{26}{279},-\\frac{26}{279}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/3)],\n [(7/3)],\n [-(4/3)],\n [(7/3)]]).squeeze()\nb = np.array([\n [(7/3)],\n [2],\n [(2/3)],\n [-(2/3)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{ccc}\n -2 & 1 & 1 \\\\\n -4 & -1 & -3 \\\\\n 4 & -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{e^2} & \\frac{1}{e^2} & \\frac{1}{e^2} \\\\\n \\frac{1-e^4}{e^2} & \\frac{2}{e^2} & \\frac{2-e^4}{e^2} \\\\\n \\frac{e^4-1}{e^2} & -\\frac{1}{e^2} & \\frac{e^4-1}{e^2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [-2, 1, 1],\n [-4, -1, -3],\n [4, -1, 1]])\nprint(expm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 1 & -6 & 5 & -1 \\\\\n -1 & -2 & 1 & 5 \\\\\n 3 & 3 & 8 & -8 \\\\\n 8 & -8 & -3 & 6 \\\\\n 5 & -7 & -3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [1, -6, 5, -1],\n [-1, -2, 1, 5],\n [3, 3, 8, -8],\n [8, -8, -3, 6],\n [5, -7, -3, 0]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 1-i & -1+5 i \\\\\n 3-5 i & 1-3 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 22+18 i & 18+14 i \\\\\n -14-22 i & 14+14 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1- 1j, -1+5j],\n [3-5j, 1-3j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -\\frac{28}{3} \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(28/3)],\n [5]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [0],\n [1]]).squeeze()\nb = np.array([\n [1],\n [-1],\n [-1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -1 \\\\\n -10 \\\\\n -9 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -2 \\\\\n -7 \\\\\n 4 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$26$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-1],\n [-10],\n [-9],\n [-7]])\nb = np.array([\n [-5],\n [-2],\n [-7],\n [4],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -8 \\\\\n -2 \\\\\n -3 \\\\\n 9 \\\\\n 4 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-8],\n [-2],\n [-3],\n [9],\n [4],\n [-5]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -9 & 6 & 3 & 6 \\\\\n -4 & 6 & -6 & 3 \\\\\n 1 & 10 & -2 & -10 \\\\\n 9 & 8 & -9 & 0 \\\\\n -10 & -3 & 1 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 6, 3, 6],\n [-4, 6, -6, 3],\n [1, 10, -2, -10],\n [9, 8, -9, 0],\n [-10, -3, 1, 10]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 4 \\\\\n -4 \\\\\n 7 \\\\\n 5 \\\\\n 8 \\\\\n -6 \\\\\n 6 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -4 \\\\\n 2 \\\\\n 3 \\\\\n -3 \\\\\n -10 \\\\\n 7 \\\\\n -3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{870}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [4],\n [-4],\n [7],\n [5],\n [8],\n [-6],\n [6],\n [5]])\nb = np.array([\n [-3],\n [-4],\n [2],\n [3],\n [-3],\n [-10],\n [7],\n [-3],\n [1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -4 \\\\\n 6 \\\\\n 6 \\\\\n 9 \\\\\n -8 \\\\\n 3 \\\\\n 2 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 7 \\\\\n -6 \\\\\n -6 \\\\\n -7 \\\\\n 3 \\\\\n 8 \\\\\n 7 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{885}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-4],\n [6],\n [6],\n [9],\n [-8],\n [3],\n [2],\n [-9]])\nb = np.array([\n [4],\n [7],\n [-6],\n [-6],\n [-7],\n [3],\n [8],\n [7],\n [-9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 0 & 0 & 8 \\\\\n -2 & -7 & -4 \\\\\n -8 & 7 & 0 \\\\\n -10 & 6 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, 0, 8],\n [-2, -7, -4],\n [-8, 7, 0],\n [-10, 6, 8]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{11}{2} & \\frac{77}{8} \\\\\n -\\frac{5}{8} & -\\frac{123}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{35 x}{16}-\\frac{2321}{64}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/2), (77/8)],\n [-(5/8), -(123/16)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & -1 \\\\\n -2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1],\n [-2, -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{16}{3} & -3 & \\frac{2}{3} \\\\\n -1 & -4 & 6 \\\\\n \\frac{23}{3} & -\\frac{25}{3} & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-1.336,5.835\\, -3.755 i,5.835\\, +3.755 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(16/3), -3, (2/3)],\n [-1, -4, 6],\n [(23/3), -(25/3), 9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -\\frac{13}{4} & \\frac{35}{4} \\\\\n \\frac{17}{4} & -\\frac{35}{4} \\\\\n -\\frac{7}{2} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/4), (35/4)],\n [(17/4), -(35/4)],\n [-(7/2), -4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{317}{100} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{317}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(317/100)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & -\\frac{3}{2} & -\\frac{3}{2} \\\\\n 1 & -\\frac{1}{2} & 0 \\\\\n \\frac{3}{2} & 2 & \\frac{1}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{4} & -\\frac{21}{4} & -\\frac{15}{4} \\\\\n \\frac{3}{2} & -\\frac{5}{4} & -\\frac{3}{2} \\\\\n \\frac{23}{4} & -\\frac{9}{4} & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(3/2), -(3/2)],\n [1, -(1/2), 0],\n [(3/2), 2, (1/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2} & \\frac{27}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -4 & -\\frac{79}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{7}{2} & \\frac{53}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), (27/8)]])\nb = np.array([\n [-4, -(79/8)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 2 & -4 & -7 \\\\\n -7 & -3 & -1 \\\\\n -5 & -2 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, -4, -7],\n [-7, -3, -1],\n [-5, -2, 7]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-4, \\frac{23}{5}}$ to the line $3 x-\\frac{6 y}{5}-\\frac{22}{5}=0$.", - "Output Answer": [ - "$\\frac{548}{15 \\sqrt{29}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -4, (23/5)\nline = Poly(3*x-((6*y)/5)-(22/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1}{\\sqrt{3}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [0],\n [1],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [-1],\n [-1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{41}{10} \\\\\n -\\frac{19}{2} \\\\\n -\\frac{71}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n \\frac{77}{10} \\\\\n \\frac{11}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{9}{10} \\\\\n -\\frac{9}{5} \\\\\n -\\frac{49}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(41/10)],\n [-(19/2)],\n [-(71/10)]])\nb = np.array([\n [5],\n [(77/10)],\n [(11/5)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -2 & 5 & 8 & -7 & -10 \\\\\n 8 & 3 & 9 & 10 & -2 \\\\\n -4 & 9 & 0 & -6 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 5, 8, -7, -10],\n [8, 3, 9, 10, -2],\n [-4, 9, 0, -6, 2]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{16} \\\\\n -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{11}{\\sqrt{265}} \\\\\n -\\frac{12}{\\sqrt{265}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/16)],\n [-(3/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n \\frac{11}{4} & -\\frac{5}{2} & 5 \\\\\n \\frac{11}{2} & -\\frac{13}{2} & -\\frac{1}{2} \\\\\n -9 & -\\frac{15}{2} & 7 \\\\\n -\\frac{11}{2} & -\\frac{21}{4} & -\\frac{7}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{37}{4} & \\frac{21}{4} & \\frac{1}{2} \\\\\n \\frac{29}{4} & \\frac{1}{4} & 2 \\\\\n -7 & -\\frac{31}{4} & -7 \\\\\n -\\frac{31}{4} & -\\frac{37}{4} & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{2} & \\frac{11}{4} & \\frac{11}{2} \\\\\n \\frac{51}{4} & -\\frac{25}{4} & \\frac{3}{2} \\\\\n -16 & -\\frac{61}{4} & 0 \\\\\n -\\frac{53}{4} & -\\frac{29}{2} & -\\frac{35}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/4), -(5/2), 5],\n [(11/2), -(13/2), -(1/2)],\n [-9, -(15/2), 7],\n [-(11/2), -(21/4), -(7/4)]])\nb = np.array([\n [-(37/4), (21/4), (1/2)],\n [(29/4), (1/4), 2],\n [-7, -(31/4), -7],\n [-(31/4), -(37/4), -7]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,-2,-2\\}, \\{-3,0,3\\}, \\{5,3,-2\\}}$.", - "Output Answer": [ - "$25 x-45 y+13 z+36=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, -2, -2],\n [-3, 0, 3],\n [5, 3, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{13}{5}, 2, \\frac{17}{5}}$ to the plane $\\frac{8 x}{5}+\\frac{8 y}{5}+\\frac{23}{5}=0$.", - "Output Answer": [ - "$\\frac{299}{40 \\sqrt{2}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (13/5), 2, (17/5)\nplane = Poly(((8*x)/5)+((8*y)/5)+(23/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -4 \\\\\n -5 \\\\\n 5 \\\\\n -8 \\\\\n -3 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -7 \\\\\n 8 \\\\\n -5 \\\\\n -8 \\\\\n -6 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$29$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-4],\n [-5],\n [5],\n [-8],\n [-3],\n [9]])\nb = np.array([\n [-2],\n [-7],\n [8],\n [-5],\n [-8],\n [-6],\n [-2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{3,-\\frac{1}{2},3\\right\\}, \\{4,3,5\\}, \\left\\{5,-\\frac{5}{2},-\\frac{3}{2}\\right\\}}$.", - "Output Answer": [ - "$47 x-34 y+36 z-266=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, -(1/2), 3],\n [4, 3, 5],\n [5, -(5/2), -(3/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n \\frac{17}{2} \\\\\n -\\frac{7}{2} \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{7}{2} \\\\\n 7 \\\\\n -\\frac{3}{2} \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{23}{2} \\\\\n \\frac{31}{2} \\\\\n -5 \\\\\n 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [(17/2)],\n [-(7/2)],\n [4]])\nb = np.array([\n [(7/2)],\n [7],\n [-(3/2)],\n [5]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 3 & -1 & 6 & -4 & 5 \\\\\n -9 & -5 & 6 & 2 & -8 \\\\\n 7 & -7 & -9 & -1 & -3 \\\\\n 5 & -2 & -8 & 6 & 3 \\\\\n -8 & 3 & 3 & 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, -1, 6, -4, 5],\n [-9, -5, 6, 2, -8],\n [7, -7, -9, -1, -3],\n [5, -2, -8, 6, 3],\n [-8, 3, 3, 1, -1]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -8 & 1 & 9 & 3 & 0 \\\\\n -3 & 3 & 3 & 1 & -3 \\\\\n 3 & -5 & -3 & 2 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-41.,-4.,-36.,0.,1.\\}, \\{72.,9.,61.,6.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-8, 1, 9, 3, 0],\n [-3, 3, 3, 1, -3],\n [3, -5, -3, 2, -5]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -\\frac{11}{2} \\\\\n \\frac{17}{2} \\\\\n 0 \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{19}{2} \\\\\n -\\frac{19}{2} \\\\\n -7 \\\\\n \\frac{15}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{625}{\\sqrt{652517}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-(11/2)],\n [(17/2)],\n [0],\n [-(3/2)]]).squeeze()\nb = np.array([\n [2],\n [(19/2)],\n [-(19/2)],\n [-7],\n [(15/2)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 0 & -10 & -8 & -3 \\\\\n 1 & -10 & 4 & 4 \\\\\n -5 & 0 & 2 & -1 \\\\\n -1 & -1 & 0 & 6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 9 & -7 & 1 & 0 \\\\\n 7 & 0 & 0 & 10 \\\\\n 8 & -9 & -8 & 1 \\\\\n 7 & -7 & -6 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -9 & -3 & -9 & -3 \\\\\n -6 & -10 & 4 & -6 \\\\\n -13 & 9 & 10 & -2 \\\\\n -8 & 6 & 6 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -10, -8, -3],\n [1, -10, 4, 4],\n [-5, 0, 2, -1],\n [-1, -1, 0, 6]])\nb = np.array([\n [9, -7, 1, 0],\n [7, 0, 0, 10],\n [8, -9, -8, 1],\n [7, -7, -6, 7]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & -\\frac{25}{3} \\\\\n -\\frac{14}{3} & \\frac{16}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{6} \\left(-5-\\sqrt{2769}\\right),\\frac{1}{6} \\left(\\sqrt{2769}-5\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -(25/3)],\n [-(14/3), (16/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 7 & -4 \\\\\n 0 & -10 \\\\\n 3 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, -4],\n [0, -10],\n [3, 4]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{2}{3}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [0],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [-1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 7 & 6 & 7 & -6 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-6.,7.,0.,0.,0.\\}, \\{-3.,0.,0.,0.,7.\\}, \\{-1.,0.,1.,0.,0.\\}, \\{6.,0.,0.,7.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, 6, 7, -6, 3]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{37}{16}, \\frac{1}{8}}$ to the line $-\\frac{29 x}{8}-\\frac{27 y}{16}-\\frac{41}{32}=0$.", - "Output Answer": [ - "$\\frac{441}{4 \\sqrt{4093}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(37/16), (1/8)\nline = Poly(-((29*x)/8)-((27*y)/16)-(41/32), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 1 & 3 & -3 & 2 \\\\\n 1 & 2 & -2 & 1 \\\\\n -2 & 2 & 3 & 3 \\\\\n 0 & -1 & -3 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -2 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -3 \\\\\n -3 \\\\\n 0 \\\\\n 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3, -3, 2],\n [1, 2, -2, 1],\n [-2, 2, 3, 3],\n [0, -1, -3, -2]])\nb = np.array([\n [-2],\n [-2],\n [-1],\n [1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{9}{2},-2,-\\frac{3}{2}\\right\\}, \\left\\{-\\frac{1}{2},-\\frac{7}{2},-4\\right\\}, \\left\\{-\\frac{1}{2},-3,-4\\right\\}}$.", - "Output Answer": [ - "$2 x-4 z-15=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(9/2), -2, -(3/2)],\n [-(1/2), -(7/2), -4],\n [-(1/2), -3, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -4 & 1 \\\\\n -3 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{4}{19} & -\\frac{1}{19} \\\\\n \\frac{3}{19} & -\\frac{4}{19} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 1],\n [-3, -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & -\\frac{5}{3} \\\\\n -\\frac{5}{2} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{49}{6}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(5/3)],\n [-(5/2), -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{7}{2}, -1}$ to the line $-3 x-\\frac{5 y}{2}+\\frac{9}{2}=0$.", - "Output Answer": [ - "$\\frac{35}{\\sqrt{61}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(7/2), -1\nline = Poly(-3*x-((5*y)/2)+(9/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -6 & 7 \\\\\n -10 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-6, 7],\n [-10, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & 5 & 7 \\\\\n 9 & 6 & 2 \\\\\n 7 & 2 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-11.256,-0.353,13.608\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 5, 7],\n [9, 6, 2],\n [7, 2, -8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{7}{3}, -3, -\\frac{2}{3}}$ to the plane $x-\\frac{5 y}{3}-\\frac{10 z}{3}-\\frac{14}{3}=0$.", - "Output Answer": [ - "$\\frac{22 \\sqrt{\\frac{2}{67}}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (7/3), -3, -(2/3)\nplane = Poly(x-((5*y)/3)-((10*z)/3)-(14/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 10 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{7}{2} \\\\\n \\frac{15}{2} \\\\\n \\frac{11}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 40 \\\\\n \\frac{3}{2} \\\\\n -\\frac{55}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [10],\n [2]])\nb = np.array([\n [(7/2)],\n [(15/2)],\n [(11/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7.7 \\\\\n -7.6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7.1 \\\\\n 0.7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8.32166$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7.7],\n [-7.6]])\nb = np.array([\n [7.1],\n [0.7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & -\\frac{1}{2} & \\frac{1}{2} \\\\\n \\frac{5}{2} & \\frac{1}{2} & \\frac{3}{2} \\\\\n -\\frac{3}{2} & 0 & \\frac{5}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{13}{8} & \\frac{5}{8} & -\\frac{1}{8} \\\\\n -\\frac{61}{8} & \\frac{5}{4} & \\frac{89}{8} \\\\\n -\\frac{33}{8} & \\frac{3}{2} & \\frac{55}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -(1/2), (1/2)],\n [(5/2), (1/2), (3/2)],\n [-(3/2), 0, (5/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 6 & -3 & 1 \\\\\n 8 & 1 & 9 \\\\\n -6 & -4 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, -3, 1],\n [8, 1, 9],\n [-6, -4, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & -\\frac{22}{3} \\\\\n \\frac{13}{3} & -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{13} \\left(-8-i \\sqrt{222}\\right),1\\right\\}, \\left\\{\\frac{1}{13} \\left(-8+i \\sqrt{222}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -(22/3)],\n [(13/3), -(2/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{32}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -9 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{63}{32} & \\frac{21}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 6]])\nprint(a * (7/32))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & 7 \\\\\n -\\frac{8}{3} & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{2}{3} \\left(-3-\\sqrt{102}\\right),\\frac{2}{3} \\left(\\sqrt{102}-3\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 7],\n [-(8/3), -10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{13}{3} & -\\frac{1}{9} \\\\\n \\frac{43}{9} & -\\frac{2}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{18}{35} & -\\frac{9}{35} \\\\\n \\frac{387}{35} & -\\frac{351}{35} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/3), -(1/9)],\n [(43/9), -(2/9)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & -2 \\\\\n 0 & 2 \\\\\n -2 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.08 \\\\\n 2.43 \\\\\n 1.25 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.144 \\\\\n 0.936 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2],\n [0, 2],\n [-2, 2]])\nb = np.array([\n [-2.08],\n [2.43],\n [1.25]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & -8 \\\\\n -4 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-10,8\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -8],\n [-4, 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & -4 & \\frac{7}{3} \\\\\n \\frac{4}{3} & -1 & -1 \\\\\n -\\frac{4}{3} & 3 & \\frac{13}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{56}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -4, (7/3)],\n [(4/3), -1, -1],\n [-(4/3), 3, (13/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 6 & -4 & -6 & 4 \\\\\n 9 & -8 & -1 & 5 \\\\\n -1 & -6 & 2 & -6 \\\\\n -9 & 9 & 3 & 7 \\\\\n 0 & 0 & -2 & -7 \\\\\n 1 & -5 & -6 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, -4, -6, 4],\n [9, -8, -1, 5],\n [-1, -6, 2, -6],\n [-9, 9, 3, 7],\n [0, 0, -2, -7],\n [1, -5, -6, 2]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & -\\frac{11}{3} & -3 \\\\\n -\\frac{7}{3} & 2 & \\frac{5}{3} \\\\\n 3 & -\\frac{11}{3} & -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{167}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(11/3), -3],\n [-(7/3), 2, (5/3)],\n [3, -(11/3), -(5/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -4 \\\\\n -9 \\\\\n -3 \\\\\n -2 \\\\\n 4 \\\\\n 5 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -4 \\\\\n 3 \\\\\n 7 \\\\\n 2 \\\\\n 5 \\\\\n -9 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{509}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-4],\n [-9],\n [-3],\n [-2],\n [4],\n [5],\n [-5]])\nb = np.array([\n [-2],\n [-4],\n [3],\n [7],\n [2],\n [5],\n [-9],\n [-1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{9}{4}, \\frac{9}{8}}$ to the line $-\\frac{143 x}{32}-\\frac{17 y}{16}+\\frac{31}{8}=0$.", - "Output Answer": [ - "$\\frac{236}{\\sqrt{21605}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (9/4), (9/8)\nline = Poly(-((143*x)/32)-((17*y)/16)+(31/8), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -7 \\\\\n 4 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 6 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-7],\n [4],\n [-1]])\nb = np.array([\n [0],\n [0],\n [6],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & -4 \\\\\n 1 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-5-\\sqrt{105}\\right),\\frac{1}{2} \\left(\\sqrt{105}-5\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -4],\n [1, -8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{7}{3} & -\\frac{11}{3} & -2 \\\\\n 1 & -\\frac{14}{3} & 4 \\\\\n -\\frac{4}{3} & \\frac{13}{3} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{106}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/3), -(11/3), -2],\n [1, -(14/3), 4],\n [-(4/3), (13/3), -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2.6 \\\\\n 4. \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2.3 \\\\\n -1.5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-0.02$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2.6],\n [4.]])\nb = np.array([\n [2.3],\n [-1.5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{6} & -\\frac{14}{3} & -\\frac{11}{3} \\\\\n -\\frac{13}{2} & 3 & -\\frac{19}{6} \\\\\n \\frac{29}{3} & \\frac{8}{3} & -\\frac{13}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{3 x^2}{2}-\\frac{7 x}{9}+\\frac{8009}{18}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/6), -(14/3), -(11/3)],\n [-(13/2), 3, -(19/6)],\n [(29/3), (8/3), -(13/3)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -5 & 10 \\\\\n 7 & 2 \\\\\n 0 & 8 \\\\\n 0 & -5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 6 & 4 \\\\\n 7 & 1 \\\\\n -8 & -4 \\\\\n 2 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -11 & 6 \\\\\n 0 & 1 \\\\\n 8 & 12 \\\\\n -2 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 10],\n [7, 2],\n [0, 8],\n [0, -5]])\nb = np.array([\n [6, 4],\n [7, 1],\n [-8, -4],\n [2, -1]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & -2 & -2 & 1 & -3 \\\\\n -1 & 1 & 1 & 2 & 0 \\\\\n 3 & 1 & -1 & 1 & 3 \\\\\n -1 & 0 & 1 & 2 & -2 \\\\\n -3 & -3 & 2 & 1 & -3 \\\\\n 0 & 0 & 0 & 1 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.15 \\\\\n -2.61 \\\\\n -1.1 \\\\\n 1.69 \\\\\n -0.36 \\\\\n -1.8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.278 \\\\\n -0.085 \\\\\n 0.144 \\\\\n -0.605 \\\\\n -0.344 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, -2, 1, -3],\n [-1, 1, 1, 2, 0],\n [3, 1, -1, 1, 3],\n [-1, 0, 1, 2, -2],\n [-3, -3, 2, 1, -3],\n [0, 0, 0, 1, -2]])\nb = np.array([\n [0.15],\n [-2.61],\n [-1.1],\n [1.69],\n [-0.36],\n [-1.8]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & 1 & -2 \\\\\n 3 & 0 & 3 \\\\\n 1 & -3 & -3 \\\\\n 0 & 0 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.08 \\\\\n 2.8 \\\\\n -2.22 \\\\\n 1.59 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.004 \\\\\n 0.441 \\\\\n 0.472 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1, -2],\n [3, 0, 3],\n [1, -3, -3],\n [0, 0, 3]])\nb = np.array([\n [1.08],\n [2.8],\n [-2.22],\n [1.59]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -3 & 6 & 10 \\\\\n -4 & -10 & 6 \\\\\n -8 & 1 & -6 \\\\\n 2 & -7 & 2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 2 & -5 & -2 \\\\\n -7 & -6 & -2 \\\\\n 3 & 4 & 0 \\\\\n -10 & 5 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -5 & 11 & 12 \\\\\n 3 & -4 & 8 \\\\\n -11 & -3 & -6 \\\\\n 12 & -12 & 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 6, 10],\n [-4, -10, 6],\n [-8, 1, -6],\n [2, -7, 2]])\nb = np.array([\n [2, -5, -2],\n [-7, -6, -2],\n [3, 4, 0],\n [-10, 5, -7]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{\\sqrt{34}} \\\\\n \\frac{5}{\\sqrt{34}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2)],\n [(5/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n -18 & 14 & -2 & -17 \\\\\n -21 & 18 & -4 & -22 \\\\\n -12 & 9 & -1 & -10 \\\\\n 3 & -1 & -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{37}{2} & \\frac{95}{6} & -\\frac{17}{6} & -\\frac{39}{2} \\\\\n -\\frac{69}{2} & \\frac{61}{2} & -\\frac{13}{2} & -37 \\\\\n -12 & 10 & -1 & -\\frac{23}{2} \\\\\n -6 & 6 & -2 & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [-18, 14, -2, -17],\n [-21, 18, -4, -22],\n [-12, 9, -1, -10],\n [3, -1, -1, 1]])\nprint(expm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{9}{5} & -\\frac{34}{5} & -9 \\\\\n -\\frac{42}{5} & \\frac{12}{5} & -8 \\\\\n -\\frac{44}{5} & \\frac{42}{5} & -\\frac{37}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.204,-1.827,1.\\}, \\{-1.271,0.488,1.\\}, \\{2.41,2.056,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/5), -(34/5), -9],\n [-(42/5), (12/5), -8],\n [-(44/5), (42/5), -(37/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -\\frac{15}{2} \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -6 \\\\\n -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 9 \\\\\n 30 \\\\\n -24 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-(15/2)],\n [-6]])\nb = np.array([\n [4],\n [-6],\n [-6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 9 \\\\\n -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{20}{3} \\\\\n \\frac{7}{3} \\\\\n -\\frac{28}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{881}{15 \\sqrt{6302}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [9],\n [-(14/3)]]).squeeze()\nb = np.array([\n [-(20/3)],\n [(7/3)],\n [-(28/3)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,4,-3\\}, \\{-4,0,1\\}, \\{1,3,-2\\}}$.", - "Output Answer": [ - "$y+z-1=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, 4, -3],\n [-4, 0, 1],\n [1, 3, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,-2,0\\}, \\{-2,2,-2\\}, \\{2,1,1\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{2}},-\\frac{1}{\\sqrt{2}},0\\right\\}, \\left\\{-\\frac{1}{\\sqrt{3}},\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{6}},\\frac{1}{\\sqrt{6}},\\sqrt{\\frac{2}{3}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, -2, 0), (-2, 2, -2), (2, 1, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{13}{3} & -\\frac{26}{3} \\\\\n -\\frac{5}{3} & -\\frac{20}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 5 & 2 \\\\\n \\frac{10}{3} & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{28}{3} & -\\frac{20}{3} \\\\\n \\frac{5}{3} & -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/3), -(26/3)],\n [-(5/3), -(20/3)]])\nb = np.array([\n [5, 2],\n [(10/3), 5]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & -3 & -5 \\\\\n 3 & 0 & 0 \\\\\n -5 & -2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$21$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3, -5],\n [3, 0, 0],\n [-5, -2, -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{28}{5} \\\\\n \\frac{23}{5} \\\\\n -\\frac{12}{5} \\\\\n -\\frac{22}{5} \\\\\n \\frac{32}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{32}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(28/5)],\n [(23/5)],\n [-(12/5)],\n [-(22/5)],\n [(32/5)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 6 & -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -3 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 3 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -5]])\nb = np.array([\n [-3, 6]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,0,2\\}, \\{1,-2,1\\}, \\{0,-1,0\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{2}},0,\\frac{1}{\\sqrt{2}}\\right\\}, \\{0,-1,0\\}, \\{0,0,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, 0, 2), (1, -2, 1), (0, -1, 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{2}{\\sqrt{3}} \\\\\n -\\frac{11}{\\sqrt{3}} \\\\\n 5 \\sqrt{3} \\\\\n -\\frac{13}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{\\sqrt{3}} \\\\\n -\\frac{17}{\\sqrt{3}} \\\\\n -\\frac{10}{\\sqrt{3}} \\\\\n \\frac{7}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{80}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(2/(math.sqrt(3)))],\n [-(11/(math.sqrt(3)))],\n [5*math.sqrt(3)],\n [-(13/(math.sqrt(3)))]])\nb = np.array([\n [-(13/(math.sqrt(3)))],\n [-(17/(math.sqrt(3)))],\n [-(10/(math.sqrt(3)))],\n [(7/(math.sqrt(3)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0.59 \\\\\n 3.74 \\\\\n 0.55 \\\\\n -5.26 \\\\\n -2.9 \\\\\n 6.66 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5.43 \\\\\n -2.62 \\\\\n 6.77 \\\\\n 3.14 \\\\\n -6.47 \\\\\n -0.3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$15.7202$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0.59],\n [3.74],\n [0.55],\n [-5.26],\n [-2.9],\n [6.66]])\nb = np.array([\n [-5.43],\n [-2.62],\n [6.77],\n [3.14],\n [-6.47],\n [-0.3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{13}{3}, \\frac{1}{3}, \\frac{14}{3}}$ to the plane $\\frac{x}{3}+\\frac{5 y}{3}-\\frac{14 z}{3}-\\frac{5}{3}=0$.", - "Output Answer": [ - "$\\frac{73}{\\sqrt{222}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(13/3), (1/3), (14/3)\nplane = Poly((x/3)+((5*y)/3)-((14*z)/3)-(5/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2}{\\sqrt{5}} \\\\\n 0 \\\\\n -\\frac{1}{\\sqrt{5}} \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [0],\n [-1],\n [0],\n [0]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & -10 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-5.,0.,6.\\}, \\{5.,3.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [6, -10, 5]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -10 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 3 \\\\\n -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 78 \\\\\n -49 \\\\\n 53 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-10],\n [4]])\nb = np.array([\n [8],\n [3],\n [-9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & 2 & -1 \\\\\n 2 & -2 & 1 \\\\\n 1 & 2 & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 10 & 18 & -9 \\\\\n 18 & -26 & 9 \\\\\n 9 & 18 & -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, -1],\n [2, -2, 1],\n [1, 2, 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{46}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{46}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(46/9)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -5 & 2 & 1 & 0 & 7 & 6 \\\\\n -3 & 10 & 10 & -1 & 1 & -1 \\\\\n 0 & 4 & -1 & -5 & 5 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & -\\frac{7}{29} & -\\frac{147}{116} & -\\frac{133}{116} \\\\\n 0 & 1 & 0 & -\\frac{30}{29} & \\frac{219}{232} & \\frac{165}{232} \\\\\n 0 & 0 & 1 & \\frac{25}{29} & -\\frac{71}{58} & -\\frac{67}{58} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, 2, 1, 0, 7, 6],\n [-3, 10, 10, -1, 1, -1],\n [0, 4, -1, -5, 5, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{123}{20} & -\\frac{188}{25} & -\\frac{84}{25} & \\frac{248}{25} \\\\\n -\\frac{107}{50} & \\frac{142}{25} & -\\frac{233}{25} & -\\frac{137}{20} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{289}{100} & \\frac{1}{5} & -\\frac{209}{25} & -\\frac{253}{50} \\\\\n -\\frac{469}{100} & -\\frac{196}{25} & -\\frac{833}{100} & -\\frac{269}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{163}{50} & -\\frac{193}{25} & 5 & \\frac{749}{50} \\\\\n \\frac{51}{20} & \\frac{338}{25} & -\\frac{99}{100} & -\\frac{147}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(123/20), -(188/25), -(84/25), (248/25)],\n [-(107/50), (142/25), -(233/25), -(137/20)]])\nb = np.array([\n [-(289/100), (1/5), -(209/25), -(253/50)],\n [-(469/100), -(196/25), -(833/100), -(269/50)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 0 & \\frac{7}{5} \\\\\n \\frac{3}{5} & -\\frac{13}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{65}{21} & \\frac{5}{3} \\\\\n \\frac{5}{7} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, (7/5)],\n [(3/5), -(13/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{2,4,-2\\}, \\{5,3,4\\}, \\{0,4,3\\}}$.", - "Output Answer": [ - "$5 x+27 y+2 z-114=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, 4, -2],\n [5, 3, 4],\n [0, 4, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{4}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 9 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{27}{4} & \\frac{15}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 5]])\nprint(a * (3/4))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n \\frac{14}{5} \\\\\n -\\frac{2}{5} \\\\\n 8 \\\\\n \\frac{43}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n \\frac{29}{5} \\\\\n 6 \\\\\n \\frac{22}{5} \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{3901}{10 \\sqrt{230503}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [(14/5)],\n [-(2/5)],\n [8],\n [(43/5)]]).squeeze()\nb = np.array([\n [7],\n [(29/5)],\n [6],\n [(22/5)],\n [10]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{32}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & 3 & -7 \\\\\n 6 & -3 & 8 \\\\\n -3 & 2 & 3 \\\\\n -8 & 7 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{15}{32} & -\\frac{15}{32} & \\frac{35}{32} \\\\\n -\\frac{15}{16} & \\frac{15}{32} & -\\frac{5}{4} \\\\\n \\frac{15}{32} & -\\frac{5}{16} & -\\frac{15}{32} \\\\\n \\frac{5}{4} & -\\frac{35}{32} & \\frac{25}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 3, -7],\n [6, -3, 8],\n [-3, 2, 3],\n [-8, 7, -10]])\nprint(a * -(5/32))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{10}{7} \\\\\n 5 \\\\\n \\frac{4}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{55}{7} \\\\\n \\frac{25}{7} \\\\\n \\frac{64}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{2140}{49} \\\\\n -\\frac{60}{7} \\\\\n -\\frac{1675}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(10/7)],\n [5],\n [(4/7)]])\nb = np.array([\n [(55/7)],\n [(25/7)],\n [(64/7)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 3 \\\\\n -9 \\\\\n 4 \\\\\n 4 \\\\\n -3 \\\\\n 6 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 10 \\\\\n 6 \\\\\n -6 \\\\\n -3 \\\\\n 8 \\\\\n 5 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-48$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [3],\n [-9],\n [4],\n [4],\n [-3],\n [6],\n [4]])\nb = np.array([\n [6],\n [10],\n [6],\n [-6],\n [-3],\n [8],\n [5],\n [-6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -10 & -7 & -7 & 7 \\\\\n -2 & 4 & -8 & -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 3 & -1 & -9 & -6 \\\\\n 6 & -7 & 8 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -7 & -8 & -16 & 1 \\\\\n 4 & -3 & 0 & -11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -7, -7, 7],\n [-2, 4, -8, -5]])\nb = np.array([\n [3, -1, -9, -6],\n [6, -7, 8, -6]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -9 & 3 & 6 & -5 \\\\\n 9 & 6 & -2 & 8 \\\\\n 1 & 4 & 9 & 10 \\\\\n -1 & 5 & 1 & 4 \\\\\n 7 & -8 & -9 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, 3, 6, -5],\n [9, 6, -2, 8],\n [1, 4, 9, 10],\n [-1, 5, 1, 4],\n [7, -8, -9, -10]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & 10 \\\\\n 1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{2-\\sqrt{14},1\\right\\}, \\left\\{2+\\sqrt{14},1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 10],\n [1, 0]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 1 & -3 & 7 & -4 & -3 \\\\\n 5 & 4 & 4 & 10 & 4 \\\\\n -8 & 1 & -2 & 10 & -9 \\\\\n -6 & -1 & -10 & -8 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-128.,-1227.,-82.,408.,449.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [1, -3, 7, -4, -3],\n [5, 4, 4, 10, 4],\n [-8, 1, -2, 10, -9],\n [-6, -1, -10, -8, 1]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 0 & -2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & -2 & -1 \\\\\n 0 & 2 & 1 \\\\\n 0 & -4 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [1],\n [-1],\n [2]])\nb = np.array([\n [0, -2, -1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -10 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -37 \\\\\n 15 \\\\\n -13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-10],\n [-3]])\nb = np.array([\n [-1],\n [1],\n [4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{5}{2},-5,\\frac{3}{2}\\right\\}, \\{-3,1,5\\}, \\left\\{-\\frac{9}{2},-2,0\\right\\}}$.", - "Output Answer": [ - "$78 x+31 y-42 z+413=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(5/2), -5, (3/2)],\n [-3, 1, 5],\n [-(9/2), -2, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 3 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 8 \\\\\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 5 \\\\\n 11 \\\\\n 17 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [3],\n [8]])\nb = np.array([\n [1],\n [8],\n [9]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{1}{5}, -\\frac{23}{5}, -\\frac{1}{5}}$ to the plane $\\frac{14 x}{5}-2 y-2 z-\\frac{9}{5}=0$.", - "Output Answer": [ - "$\\frac{19 \\sqrt{11}}{30}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (1/5), -(23/5), -(1/5)\nplane = Poly(((14*x)/5)-2*y-2*z-(9/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 9 & 2 & 7 \\\\\n -3 & -4 & -2 \\\\\n 5 & -10 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+10 x^2+60 x$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 2, 7],\n [-3, -4, -2],\n [5, -10, 5]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 5 & -8 & 7 & -2 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-7.,0.,5.,0.,0.\\}, \\{2.,0.,0.,5.,0.\\}, \\{7.,0.,0.,0.,5.\\}, \\{8.,5.,0.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, -8, 7, -2, -7]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -2 & -6 & 3 \\\\\n 8 & 2 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-30.,21.,22.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, -6, 3],\n [8, 2, 9]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{9}{4} & \\frac{7}{2} & -\\frac{33}{4} \\\\\n \\frac{7}{4} & -8 & \\frac{13}{4} \\\\\n \\frac{9}{4} & -5 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{5.074,2.16,1.\\}, \\{0.353\\, -1.038 i,0.645\\, +0.471 i,1.\\}, \\{0.353\\, +1.038 i,0.645\\, -0.471 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/4), (7/2), -(33/4)],\n [(7/4), -8, (13/4)],\n [(9/4), -5, -3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -\\frac{9}{5} & \\frac{41}{5} & -\\frac{14}{5} & \\frac{7}{5} \\\\\n -\\frac{36}{5} & -\\frac{29}{5} & \\frac{47}{5} & -\\frac{3}{5} \\\\\n 8 & -7 & -\\frac{2}{5} & \\frac{38}{5} \\\\\n \\frac{31}{5} & \\frac{7}{5} & -\\frac{46}{5} & -\\frac{39}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/5), (41/5), -(14/5), (7/5)],\n [-(36/5), -(29/5), (47/5), -(3/5)],\n [8, -7, -(2/5), (38/5)],\n [(31/5), (7/5), -(46/5), -(39/5)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{5} & 4 & \\frac{24}{5} \\\\\n -5 & -\\frac{11}{5} & \\frac{3}{5} \\\\\n -\\frac{8}{5} & -2 & -\\frac{11}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{4961}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/5), 4, (24/5)],\n [-5, -(11/5), (3/5)],\n [-(8/5), -2, -(11/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & 3 & -1 \\\\\n -3 & 2 & -1 \\\\\n 2 & 1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-0.099-2.243 i,-0.099+2.243 i,0.198\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 3, -1],\n [-3, 2, -1],\n [2, 1, 1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 2 & 4 \\\\\n -3 & -3 & 0 \\\\\n -5 & -5 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, 4],\n [-3, -3, 0],\n [-5, -5, -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -6 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 10]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{2} & \\frac{37}{10} & \\frac{1}{10} \\\\\n -\\frac{49}{10} & -\\frac{22}{5} & -\\frac{29}{10} \\\\\n \\frac{19}{10} & -\\frac{12}{5} & -\\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{47663}{1000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), (37/10), (1/10)],\n [-(49/10), -(22/5), -(29/10)],\n [(19/10), -(12/5), -(8/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, \\frac{13}{3}}$ to the line $\\frac{5 x}{3}+\\frac{5 y}{3}+\\frac{7}{3}=0$.", - "Output Answer": [ - "$\\frac{28 \\sqrt{2}}{15}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, (13/3)\nline = Poly(((5*x)/3)+((5*y)/3)+(7/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n \\frac{17}{6} & \\frac{41}{6} & \\frac{11}{6} & -\\frac{1}{2} \\\\\n -\\frac{3}{2} & -\\frac{20}{3} & \\frac{25}{3} & \\frac{19}{2} \\\\\n -\\frac{1}{6} & -\\frac{15}{2} & -\\frac{26}{3} & -\\frac{49}{6} \\\\\n \\frac{13}{3} & -\\frac{29}{3} & \\frac{7}{2} & 10 \\\\\n \\frac{15}{2} & -1 & \\frac{17}{6} & -\\frac{23}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/6), (41/6), (11/6), -(1/2)],\n [-(3/2), -(20/3), (25/3), (19/2)],\n [-(1/6), -(15/2), -(26/3), -(49/6)],\n [(13/3), -(29/3), (7/2), 10],\n [(15/2), -1, (17/6), -(23/6)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{10} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{24}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{9}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/10)]])\nb = np.array([\n [-(24/5)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n \\frac{23}{10} & \\frac{11}{5} \\\\\n -\\frac{1}{2} & \\frac{1}{5} \\\\\n \\frac{21}{10} & -2 \\\\\n \\frac{9}{5} & -\\frac{13}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{23}{10} & -\\frac{1}{10} & -\\frac{11}{10} & \\frac{23}{10} \\\\\n \\frac{8}{5} & 1 & -\\frac{19}{10} & -\\frac{27}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{177}{100} & \\frac{197}{100} & -\\frac{671}{100} & -\\frac{13}{20} \\\\\n \\frac{147}{100} & \\frac{1}{4} & \\frac{17}{100} & -\\frac{169}{100} \\\\\n -\\frac{803}{100} & -\\frac{221}{100} & \\frac{149}{100} & \\frac{1023}{100} \\\\\n -\\frac{311}{50} & -\\frac{37}{25} & \\frac{49}{100} & \\frac{153}{20} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/10), (11/5)],\n [-(1/2), (1/5)],\n [(21/10), -2],\n [(9/5), -(13/10)]])\nb = np.array([\n [-(23/10), -(1/10), -(11/10), (23/10)],\n [(8/5), 1, -(19/10), -(27/10)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -\\frac{31}{9} \\\\\n \\frac{67}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{56}{9} \\\\\n -\\frac{55}{9} \\\\\n -\\frac{25}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{4460}{81} \\\\\n -\\frac{2402}{81} \\\\\n -\\frac{4706}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-(31/9)],\n [(67/9)]])\nb = np.array([\n [-(56/9)],\n [-(55/9)],\n [-(25/9)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 10 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 65 \\\\\n 39 \\\\\n 39 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [3],\n [-8]])\nb = np.array([\n [-3],\n [10],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & -2 \\\\\n -8 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+7 x-24$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2],\n [-8, -8]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{2} & -\\frac{1}{2} \\\\\n -\\frac{5}{2} & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{7}{27} & -\\frac{1}{27} \\\\\n -\\frac{5}{27} & -\\frac{7}{27} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2), -(1/2)],\n [-(5/2), -(7/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\pi \\\\\n -\\pi \\\\\n -3 \\pi \\\\\n 0 \\\\\n -3 \\pi \\\\\n -\\pi \\\\\n 2 \\pi \\\\\n \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\pi \\\\\n 2 \\pi \\\\\n -2 \\pi \\\\\n 2 \\pi \\\\\n -2 \\pi \\\\\n -\\pi \\\\\n -\\pi \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\pi ^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [3*math.pi],\n [-math.pi],\n [-3*math.pi],\n [0],\n [-3*math.pi],\n [-math.pi],\n [2*math.pi],\n [math.pi]])\nb = np.array([\n [-2*math.pi],\n [2*math.pi],\n [-2*math.pi],\n [2*math.pi],\n [-2*math.pi],\n [-math.pi],\n [-math.pi],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 3 \\\\\n 2 \\\\\n 1 \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{5}{2} \\\\\n -2 \\\\\n -\\frac{3}{2} \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{0,\\frac{5}{6},-\\frac{2}{3},-\\frac{1}{2},-\\frac{1}{3}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [3],\n [2],\n [1],\n [-(5/2)]]).squeeze()\nb = np.array([\n [0],\n [(5/2)],\n [-2],\n [-(3/2)],\n [-1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2 & -3 & 2 \\\\\n 2 & -1 & 0 \\\\\n 0 & -1 & 2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -2 & 7 & 0 \\\\\n -6 & -5 & 4 \\\\\n -2 & -1 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, 2],\n [2, -1, 0],\n [0, -1, 2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${4, 3, -4}$ to the plane $5 x-3 y+2 z+3=0$.", - "Output Answer": [ - "$3 \\sqrt{\\frac{2}{19}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 4, 3, -4\nplane = Poly(5*x-3*y+2*z+3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{3} \\\\\n \\frac{10}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{194}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [5]])\nb = np.array([\n [-(19/3)],\n [(10/3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{2}{3} & -\\frac{10}{3} & \\frac{1}{3} \\\\\n 4 & -\\frac{8}{3} & 3 \\\\\n 7 & -\\frac{19}{3} & 1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{20}{3} & \\frac{19}{3} & \\frac{7}{3} \\\\\n -7 & -\\frac{5}{3} & -\\frac{17}{3} \\\\\n \\frac{26}{3} & -\\frac{4}{3} & \\frac{17}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 6 & -\\frac{29}{3} & -2 \\\\\n 11 & -1 & \\frac{26}{3} \\\\\n -\\frac{5}{3} & -5 & -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3), -(10/3), (1/3)],\n [4, -(8/3), 3],\n [7, -(19/3), 1]])\nb = np.array([\n [-(20/3), (19/3), (7/3)],\n [-7, -(5/3), -(17/3)],\n [(26/3), -(4/3), (17/3)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -4 & -8 & -1 \\\\\n 0 & 6 & -6 \\\\\n -1 & -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.136,1.405,1.\\}, \\{5.441,0.546,1.\\}, \\{18.196,-23.452,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -8, -1],\n [0, 6, -6],\n [-1, -1, 1]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 7 & -5 & 4 & 2 & 0 & -1 & -4 \\\\\n 4 & 8 & 3 & 10 & -3 & -3 & -5 \\\\\n 4 & -6 & 0 & 7 & -8 & -10 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & \\frac{533}{158} & -\\frac{224}{79} & -\\frac{262}{79} & -\\frac{212}{79} \\\\\n 0 & 1 & 0 & \\frac{171}{158} & -\\frac{44}{79} & -\\frac{43}{79} & -\\frac{36}{79} \\\\\n 0 & 0 & 1 & -\\frac{320}{79} & \\frac{337}{79} & \\frac{385}{79} & \\frac{247}{79} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, -5, 4, 2, 0, -1, -4],\n [4, 8, 3, 10, -3, -3, -5],\n [4, -6, 0, 7, -8, -10, -8]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,-3,0\\}, \\{2,-5,1\\}, \\{-1,3,-3\\}}$.", - "Output Answer": [ - "$y+2 z+3=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, -3, 0],\n [2, -5, 1],\n [-1, 3, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{34}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-2]])\nb = np.array([\n [9],\n [3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{31}{9} & -\\frac{13}{9} \\\\\n -\\frac{55}{9} & \\frac{55}{9} \\\\\n \\frac{35}{9} & -\\frac{29}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{9} & -\\frac{44}{9} \\\\\n -\\frac{4}{9} & \\frac{26}{3} \\\\\n \\frac{11}{3} & \\frac{58}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{26}{9} & \\frac{31}{9} \\\\\n -\\frac{17}{3} & -\\frac{23}{9} \\\\\n \\frac{2}{9} & -\\frac{145}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(31/9), -(13/9)],\n [-(55/9), (55/9)],\n [(35/9), -(29/3)]])\nb = np.array([\n [-(5/9), -(44/9)],\n [-(4/9), (26/3)],\n [(11/3), (58/9)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -9 & -\\frac{9}{2} & -10 \\\\\n 10 & -2 & \\frac{7}{2} \\\\\n -5 & -2 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8.005-3.329 i,-8.005+3.329 i,0.01\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -(9/2), -10],\n [10, -2, (7/2)],\n [-5, -2, -5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{81}{16} \\\\\n -3 \\\\\n -\\frac{77}{8} \\\\\n -\\frac{9}{8} \\\\\n -\\frac{81}{16} \\\\\n \\frac{25}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{40091}}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(81/16)],\n [-3],\n [-(77/8)],\n [-(9/8)],\n [-(81/16)],\n [(25/16)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7.23 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4.74 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$34.2702$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7.23]])\nb = np.array([\n [-4.74]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -6 & -6 \\\\\n -4 & -7 \\\\\n 4 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -6],\n [-4, -7],\n [4, -2]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & 7 \\\\\n \\frac{3}{2} & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-1-\\sqrt{43}\\right),\\frac{1}{2} \\left(\\sqrt{43}-1\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 7],\n [(3/2), -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-5,0,-1\\}, \\{0,-5,0\\}, \\{-5,-2,5\\}}$.", - "Output Answer": [ - "$14 x+15 y+5 z+75=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-5, 0, -1],\n [0, -5, 0],\n [-5, -2, 5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n \\frac{5}{2} \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{2} \\\\\n -1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{11}{6},\\frac{11}{15},\\frac{22}{15}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2)],\n [(5/2)],\n [1]]).squeeze()\nb = np.array([\n [-(5/2)],\n [-1],\n [-2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{19}{3} & \\frac{4}{3} \\\\\n 3 & \\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{3} \\left(-4-3 \\sqrt{29}\\right),\\frac{1}{3} \\left(3 \\sqrt{29}-4\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/3), (4/3)],\n [3, (11/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -1 & -\\frac{2}{7} & -\\frac{30}{7} \\\\\n \\frac{26}{7} & \\frac{33}{7} & -\\frac{12}{7} \\\\\n \\frac{10}{7} & -\\frac{10}{7} & \\frac{8}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{252}{4337} & \\frac{553}{4337} & \\frac{3549}{8674} \\\\\n -\\frac{574}{4337} & \\frac{427}{4337} & -\\frac{1512}{4337} \\\\\n -\\frac{2065}{8674} & -\\frac{315}{8674} & -\\frac{1253}{17348} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -(2/7), -(30/7)],\n [(26/7), (33/7), -(12/7)],\n [(10/7), -(10/7), (8/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{7} \\\\\n -\\frac{47}{7} \\\\\n -\\frac{26}{7} \\\\\n \\frac{10}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{47}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/7)],\n [-(47/7)],\n [-(26/7)],\n [(10/7)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & 3 & -1 \\\\\n -10 & -1 & 10 \\\\\n -9 & 3 & 3 \\\\\n 10 & 6 & -3 \\\\\n 3 & 3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, 3, -1],\n [-10, -1, 10],\n [-9, 3, 3],\n [10, 6, -3],\n [3, 3, 0]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -6 & 7 & 3 & 2 \\\\\n -1 & -5 & -7 & -1 \\\\\n 10 & 5 & -3 & -2 \\\\\n 0 & 5 & 3 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-6, 7, 3, 2],\n [-1, -5, -7, -1],\n [10, 5, -3, -2],\n [0, 5, 3, 6]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{4}{5}, -\\frac{5}{2}}$ to the line $\\frac{x}{10}-\\frac{11 y}{5}+\\frac{11}{5}=0$.", - "Output Answer": [ - "$\\frac{389}{5 \\sqrt{485}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (4/5), -(5/2)\nline = Poly((x/10)-((11*y)/5)+(11/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -4 \\\\\n -2 \\\\\n -3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-4],\n [-2],\n [-3],\n [-8]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 9 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -5 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -88 \\\\\n 12 \\\\\n 92 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [9],\n [-5]])\nb = np.array([\n [-8],\n [-5],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -10 & -1 & 1 & 9 \\\\\n 2 & -3 & 1 & -8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 1 & 4 & -6 & 6 \\\\\n -5 & 9 & -7 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -11 & -5 & 7 & 3 \\\\\n 7 & -12 & 8 & -11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -1, 1, 9],\n [2, -3, 1, -8]])\nb = np.array([\n [1, 4, -6, 6],\n [-5, 9, -7, 3]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n 0 \\\\\n 1 \\\\\n 3 \\\\\n -\\frac{5}{2} \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n \\frac{5}{2} \\\\\n -2 \\\\\n -\\frac{1}{2} \\\\\n -1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{1}{18},-\\frac{5}{18},\\frac{2}{9},\\frac{1}{18},\\frac{1}{9},-\\frac{2}{9}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2)],\n [0],\n [1],\n [3],\n [-(5/2)],\n [-(1/2)]]).squeeze()\nb = np.array([\n [(1/2)],\n [(5/2)],\n [-2],\n [-(1/2)],\n [-1],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & \\frac{1}{2} & -2 \\\\\n 1 & \\frac{5}{2} & \\frac{3}{2} \\\\\n -\\frac{5}{2} & 0 & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{47}{4} & \\frac{5}{2} & -\\frac{9}{4} \\\\\n \\frac{5}{4} & \\frac{27}{4} & \\frac{1}{4} \\\\\n -\\frac{15}{4} & -\\frac{5}{4} & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), (1/2), -2],\n [1, (5/2), (3/2)],\n [-(5/2), 0, -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -2 & -10 & -7 & 10 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-7.,0.,2.,0.,0.\\}, \\{-5.,1.,0.,0.,0.\\}, \\{5.,0.,0.,1.,0.\\}, \\{7.,0.,0.,0.,2.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, -10, -7, 10, 7]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{43}{10} \\\\\n -\\frac{3}{5} \\\\\n \\frac{39}{5} \\\\\n \\frac{41}{10} \\\\\n \\frac{91}{10} \\\\\n \\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{18187}}{10}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(43/10)],\n [-(3/5)],\n [(39/5)],\n [(41/10)],\n [(91/10)],\n [(8/5)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{2}{5}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & -4 & -4 \\\\\n -7 & -3 & -4 \\\\\n -6 & -6 & -6 \\\\\n -10 & -1 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{4}{5} & -\\frac{8}{5} & -\\frac{8}{5} \\\\\n -\\frac{14}{5} & -\\frac{6}{5} & -\\frac{8}{5} \\\\\n -\\frac{12}{5} & -\\frac{12}{5} & -\\frac{12}{5} \\\\\n -4 & -\\frac{2}{5} & -\\frac{12}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -4, -4],\n [-7, -3, -4],\n [-6, -6, -6],\n [-10, -1, -6]])\nprint(a * (2/5))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,-2,3\\}, \\{-2,5,-1\\}, \\{-3,-2,-3\\}}$.", - "Output Answer": [ - "$7 x+y-7 z+2=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, -2, 3],\n [-2, 5, -1],\n [-3, -2, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & 1 \\\\\n -3 & 2 & 2 \\\\\n -1 & 0 & 1 \\\\\n 2 & 3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.05 \\\\\n -2.81 \\\\\n -2.29 \\\\\n 1.66 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.898 \\\\\n -0.843 \\\\\n -2.051 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, 1],\n [-3, 2, 2],\n [-1, 0, 1],\n [2, 3, -3]])\nb = np.array([\n [-2.05],\n [-2.81],\n [-2.29],\n [1.66]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{34}{7} & \\frac{31}{7} \\\\\n 4 & -\\frac{19}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{133}{222} & \\frac{217}{222} \\\\\n \\frac{98}{111} & \\frac{119}{111} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(34/7), (31/7)],\n [4, -(19/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $3$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -9 & -6 & -5 & 6 \\\\\n -9 & 9 & -3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -27 & -18 & -15 & 18 \\\\\n -27 & 27 & -9 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -6, -5, 6],\n [-9, 9, -3, 1]])\nprint(a * 3)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -5 & 7 & 8 & -7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -4 & -4 & -1 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -1 & 11 & 9 & -16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 7, 8, -7]])\nb = np.array([\n [-4, -4, -1, 9]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{15}{2} & -\\frac{33}{4} & -\\frac{9}{2} \\\\\n -\\frac{17}{4} & -\\frac{19}{2} & \\frac{3}{4} \\\\\n \\frac{11}{4} & -1 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-14.378,-0.519,2.897\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/2), -(33/4), -(9/2)],\n [-(17/4), -(19/2), (3/4)],\n [(11/4), -1, 5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{21}{16} & \\frac{1}{8} \\\\\n \\frac{21}{16} & -\\frac{25}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{50}{63} & -\\frac{2}{63} \\\\\n -\\frac{1}{3} & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(21/16), (1/8)],\n [(21/16), -(25/8)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -10 & -4 \\\\\n -6 & -7 \\\\\n -8 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, -4],\n [-6, -7],\n [-8, 2]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & 5 & -4 \\\\\n 3 & 2 & -6 \\\\\n -2 & -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-0.116-1.164 i,-0.116+1.164 i,10.231\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 5, -4],\n [3, 2, -6],\n [-2, -1, 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{5} & \\frac{49}{10} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{69}{10} & \\frac{29}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{63}{10} & -\\frac{9}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/5), (49/10)]])\nb = np.array([\n [-(69/10), (29/5)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 8 & 0 & -\\frac{13}{3} \\\\\n \\frac{16}{3} & 0 & 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{14}{3} & \\frac{13}{3} & 8 \\\\\n -\\frac{23}{3} & \\frac{8}{3} & \\frac{29}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{10}{3} & \\frac{13}{3} & \\frac{11}{3} \\\\\n -\\frac{7}{3} & \\frac{8}{3} & \\frac{50}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 0, -(13/3)],\n [(16/3), 0, 7]])\nb = np.array([\n [-(14/3), (13/3), 8],\n [-(23/3), (8/3), (29/3)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 6 \\\\\n -5 \\\\\n -7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 3 \\\\\n 7 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 10 \\\\\n 3 \\\\\n -12 \\\\\n -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [6],\n [-5],\n [-7]])\nb = np.array([\n [-10],\n [3],\n [7],\n [-4]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{3,-\\frac{1}{2},0\\right\\}, \\left\\{0,3,\\frac{3}{2}\\right\\}, \\{0,2,-2\\}}$.", - "Output Answer": [ - "$43 x+42 y-12 (z+9)=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, -(1/2), 0],\n [0, 3, (3/2)],\n [0, 2, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -5 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 4 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{178}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-5],\n [-4]])\nb = np.array([\n [1],\n [4],\n [0]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -6 \\\\\n 1 \\\\\n 7 \\\\\n -8 \\\\\n -9 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 0 \\\\\n -7 \\\\\n -4 \\\\\n 6 \\\\\n 4 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{714}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-6],\n [1],\n [7],\n [-8],\n [-9],\n [1]])\nb = np.array([\n [-3],\n [0],\n [-7],\n [-4],\n [6],\n [4],\n [-7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,-2,-2\\}, \\{1,-1,-1\\}, \\{-5,0,-1\\}}$.", - "Output Answer": [ - "$x+6 y-11 z-6=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, -2, -2],\n [1, -1, -1],\n [-5, 0, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 4 & -8 & 10 \\\\\n -9 & 5 & 2 \\\\\n -8 & -4 & -3 \\\\\n 8 & 8 & -10 \\\\\n 4 & -4 & -8 \\\\\n -7 & -8 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, -8, 10],\n [-9, 5, 2],\n [-8, -4, -3],\n [8, 8, -10],\n [4, -4, -8],\n [-7, -8, -10]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & 2 & -2 \\\\\n 0 & 3 & 1 \\\\\n 4 & -4 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$18$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2, -2],\n [0, 3, 1],\n [4, -4, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{35}{16} \\\\\n -\\frac{13}{16} \\\\\n -\\frac{5}{2} \\\\\n -\\frac{33}{16} \\\\\n -\\frac{35}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{35}{2 \\sqrt{1327}} \\\\\n -\\frac{13}{2 \\sqrt{1327}} \\\\\n -\\frac{20}{\\sqrt{1327}} \\\\\n -\\frac{33}{2 \\sqrt{1327}} \\\\\n -\\frac{35}{2 \\sqrt{1327}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(35/16)],\n [-(13/16)],\n [-(5/2)],\n [-(33/16)],\n [-(35/16)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n \\frac{23}{10} & \\frac{3}{5} & -\\frac{13}{5} \\\\\n \\frac{12}{5} & -\\frac{11}{10} & \\frac{1}{2} \\\\\n -\\frac{6}{5} & \\frac{9}{10} & -1 \\\\\n -\\frac{19}{10} & -\\frac{3}{2} & \\frac{17}{10} \\\\\n \\frac{13}{5} & \\frac{11}{5} & -\\frac{11}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{10} & -\\frac{13}{10} & \\frac{27}{10} \\\\\n -2 & \\frac{12}{5} & \\frac{1}{2} \\\\\n \\frac{3}{10} & -\\frac{8}{5} & \\frac{1}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{497}{100} & \\frac{261}{100} & \\frac{599}{100} \\\\\n -\\frac{77}{100} & -\\frac{164}{25} & \\frac{603}{100} \\\\\n -\\frac{27}{50} & \\frac{133}{25} & -\\frac{299}{100} \\\\\n \\frac{299}{50} & -\\frac{77}{20} & -\\frac{277}{50} \\\\\n -\\frac{811}{100} & \\frac{183}{50} & \\frac{79}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/10), (3/5), -(13/5)],\n [(12/5), -(11/10), (1/2)],\n [-(6/5), (9/10), -1],\n [-(19/10), -(3/2), (17/10)],\n [(13/5), (11/5), -(11/10)]])\nb = np.array([\n [-(13/10), -(13/10), (27/10)],\n [-2, (12/5), (1/2)],\n [(3/10), -(8/5), (1/5)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -5 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$12$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-5],\n [-6]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [1],\n [1],\n [0],\n [0]]).squeeze()\nb = np.array([\n [1],\n [0],\n [1],\n [0],\n [1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{4}{e} \\\\\n \\frac{6}{e} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{2}{e} \\\\\n \\frac{20}{e} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{10 \\sqrt{2}}{e}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(4/math.e)],\n [(6/math.e)]])\nb = np.array([\n [(2/math.e)],\n [(20/math.e)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 0 & -6 & 1 & -6 & -7 \\\\\n -5 & -5 & -9 & 9 & -7 \\\\\n 5 & 4 & 0 & -7 & -7 \\\\\n 3 & -5 & -1 & 3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1039.,-670.,-6956.,-4939.,3814.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, -6, 1, -6, -7],\n [-5, -5, -9, 9, -7],\n [5, 4, 0, -7, -7],\n [3, -5, -1, 3, 2]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 7 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 8 \\\\\n -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -42 \\\\\n -54 \\\\\n -93 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [7],\n [0]])\nb = np.array([\n [3],\n [8],\n [-6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & 5 \\\\\n 5 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(13-\\sqrt{101}\\right),\\frac{1}{2} \\left(13+\\sqrt{101}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 5],\n [5, 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -9 & 7 & 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 3 & 7 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -6 & 14 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 7, 6]])\nb = np.array([\n [3, 7, -5]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 6 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -4 \\\\\n 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -6 \\\\\n 15 \\\\\n 36 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [6],\n [-3]])\nb = np.array([\n [-4],\n [-4],\n [1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 3 \\\\\n 8 \\\\\n -1 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 4 \\\\\n 10 \\\\\n 4 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [3],\n [8],\n [-1],\n [-4]])\nb = np.array([\n [6],\n [4],\n [10],\n [4],\n [-8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{57}{7} \\\\\n \\frac{19}{7} \\\\\n 7 \\\\\n -\\frac{40}{7} \\\\\n -6 \\\\\n -\\frac{57}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{264}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(57/7)],\n [(19/7)],\n [7],\n [-(40/7)],\n [-6],\n [-(57/7)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{2} & -\\frac{7}{2} \\\\\n -\\frac{7}{2} & -\\frac{11}{2} \\\\\n -\\frac{11}{2} & -6 \\\\\n -3 & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{2} & -\\frac{3}{2} \\\\\n -\\frac{1}{2} & -\\frac{5}{2} \\\\\n -\\frac{7}{2} & 5 \\\\\n -9 & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & -2 \\\\\n -3 & -3 \\\\\n -2 & -11 \\\\\n 6 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/2), -(7/2)],\n [-(7/2), -(11/2)],\n [-(11/2), -6],\n [-3, (7/2)]])\nb = np.array([\n [(7/2), -(3/2)],\n [-(1/2), -(5/2)],\n [-(7/2), 5],\n [-9, -(7/2)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -\\frac{21}{5} \\\\\n 6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -\\frac{7}{5} \\\\\n -\\frac{21}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -6 \\\\\n -\\frac{14}{5} \\\\\n \\frac{51}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-(21/5)],\n [6]])\nb = np.array([\n [3],\n [-(7/5)],\n [-(21/5)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n -5 & 2 & 4 \\\\\n -4 & 9 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 2, 4],\n [-4, 9, 5]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{39}{5} \\\\\n \\frac{36}{5} \\\\\n \\frac{39}{5} \\\\\n -8 \\\\\n 6 \\\\\n -\\frac{43}{5} \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{43}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(39/5)],\n [(36/5)],\n [(39/5)],\n [-8],\n [6],\n [-(43/5)],\n [-3]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{2,-\\frac{3}{2},-3\\right\\}, \\left\\{-\\frac{9}{2},\\frac{1}{2},\\frac{9}{2}\\right\\}, \\{-2,1,-1\\}}$.", - "Output Answer": [ - "$59 x+68 y+33 z+83=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, -(3/2), -3],\n [-(9/2), (1/2), (9/2)],\n [-2, 1, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 0 & 1 & 6 & -1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.,-6.,1.,0.,0.\\}, \\{0.,1.,0.,1.,0.\\}, \\{0.,4.,0.,0.,1.\\}, \\{1.,0.,0.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, 1, 6, -1, -4]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{4}{e} \\\\\n \\frac{11}{e} \\\\\n -\\frac{6}{e} \\\\\n \\frac{1}{e} \\\\\n \\frac{10}{e} \\\\\n -\\frac{1}{e} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{17}{e} \\\\\n -\\frac{17}{e} \\\\\n -\\frac{4}{e} \\\\\n \\frac{10}{e} \\\\\n \\frac{8}{e} \\\\\n -\\frac{11}{e} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{1142}}{e}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(4/math.e)],\n [(11/math.e)],\n [-(6/math.e)],\n [(1/math.e)],\n [(10/math.e)],\n [-(1/math.e)]])\nb = np.array([\n [(17/math.e)],\n [-(17/math.e)],\n [-(4/math.e)],\n [(10/math.e)],\n [(8/math.e)],\n [-(11/math.e)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -5 \\\\\n -2 \\\\\n 7 \\\\\n -8 \\\\\n 9 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 1 \\\\\n -10 \\\\\n -2 \\\\\n -1 \\\\\n -6 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-51$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-5],\n [-2],\n [7],\n [-8],\n [9],\n [2]])\nb = np.array([\n [4],\n [1],\n [-10],\n [-2],\n [-1],\n [-6],\n [-9]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{4}{7},\\frac{16}{7},\\frac{18}{7}\\right\\}, \\left\\{2,-\\frac{4}{7},\\frac{15}{7}\\right\\}, \\left\\{2,\\frac{12}{7},\\frac{9}{7}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{2}{\\sqrt{149}},\\frac{8}{\\sqrt{149}},\\frac{9}{\\sqrt{149}}\\right\\}, \\left\\{\\frac{43}{\\sqrt{3278}},-\\frac{23}{\\sqrt{3278}},15 \\sqrt{\\frac{2}{1639}}\\right\\}, \\left\\{\\frac{3}{\\sqrt{22}},\\frac{3}{\\sqrt{22}},-\\sqrt{\\frac{2}{11}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-(4/7), (16/7), (18/7)), (2, -(4/7), (15/7)), (2, (12/7), (9/7))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & -9 & 5 \\\\\n 0 & -7 & 7 \\\\\n 3 & 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.812,-2.943,1.\\}, \\{0.404,0.866,1.\\}, \\{2.947,0.458,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -9, 5],\n [0, -7, 7],\n [3, 1, -1]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{6}{5} \\\\\n -4 \\\\\n -\\frac{38}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{4}{5} \\\\\n 6 \\\\\n \\frac{17}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 32 \\\\\n -2 \\\\\n -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(6/5)],\n [-4],\n [-(38/5)]])\nb = np.array([\n [(4/5)],\n [6],\n [(17/5)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3 \\\\\n -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [2]])\nb = np.array([\n [-3]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 5 \\\\\n 2 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} \\left(13-\\sqrt{209}\\right),1\\right\\}, \\left\\{\\frac{1}{4} \\left(13+\\sqrt{209}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 5],\n [2, -5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -9 & -5 & 10 \\\\\n 3 & -2 & 10 \\\\\n -1 & -2 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-12 x^2-74 x-243$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -5, 10],\n [3, -2, 10],\n [-1, -2, -1]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & -1 \\\\\n 8 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-3 x+10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1],\n [8, 1]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{23}{5} \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{10} \\\\\n \\frac{49}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{33}{10} \\\\\n \\frac{54}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/5)],\n [1]])\nb = np.array([\n [-(13/10)],\n [(49/5)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, -3}$ to the line $x=0$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, -3\nline = Poly(x, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & -3 \\\\\n 1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{2} \\left(-5-\\sqrt{13}\\right),1\\right\\}, \\left\\{\\frac{1}{2} \\left(\\sqrt{13}-5\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -3],\n [1, -3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 4 & -5 & -4 & 6 & 3 & -10 & 4 \\\\\n 10 & 5 & 5 & -6 & -4 & -10 & -10 \\\\\n 8 & -3 & 2 & 2 & -3 & -2 & 4 \\\\\n 0 & -8 & 0 & -7 & -3 & 6 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & \\frac{11}{1940} & -\\frac{1609}{970} & -\\frac{497}{970} \\\\\n 0 & 1 & 0 & 0 & \\frac{32}{97} & -\\frac{120}{97} & -\\frac{158}{97} \\\\\n 0 & 0 & 1 & 0 & -\\frac{1047}{970} & \\frac{1563}{485} & \\frac{569}{485} \\\\\n 0 & 0 & 0 & 1 & \\frac{5}{97} & \\frac{54}{97} & \\frac{42}{97} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, -5, -4, 6, 3, -10, 4],\n [10, 5, 5, -6, -4, -10, -10],\n [8, -3, 2, 2, -3, -2, 4],\n [0, -8, 0, -7, -3, 6, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & -1 & -2 \\\\\n -2 & -2 & -3 \\\\\n -1 & 1 & -1 \\\\\n 1 & -2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.44 \\\\\n -2.11 \\\\\n 2.63 \\\\\n -1.97 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.351 \\\\\n 1.529 \\\\\n -0.22 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1, -2],\n [-2, -2, -3],\n [-1, 1, -1],\n [1, -2, -2]])\nb = np.array([\n [-2.44],\n [-2.11],\n [2.63],\n [-1.97]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,3,0\\}, \\{0,2,3\\}, \\{-4,4,-3\\}}$.", - "Output Answer": [ - "$\\text{Symbol}[\\text{True},0]$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, 3, 0],\n [0, 2, 3],\n [-4, 4, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & -8 \\\\\n -10 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(3-\\sqrt{329}\\right),\\frac{1}{2} \\left(3+\\sqrt{329}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -8],\n [-10, 0]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 3 & -7 \\\\\n -8 & 0 \\\\\n -7 & -8 \\\\\n 1 & 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 8 & 8 \\\\\n -1 & -8 \\\\\n 2 & 5 \\\\\n 5 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 11 & 1 \\\\\n -9 & -8 \\\\\n -5 & -3 \\\\\n 6 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -7],\n [-8, 0],\n [-7, -8],\n [1, 7]])\nb = np.array([\n [8, 8],\n [-1, -8],\n [2, 5],\n [5, -7]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-1,-2,0\\}, \\{2,-3,3\\}, \\{3,3,-1\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{5}},-\\frac{2}{\\sqrt{5}},0\\right\\}, \\left\\{7 \\sqrt{\\frac{2}{235}},-\\frac{7}{\\sqrt{470}},3 \\sqrt{\\frac{5}{94}}\\right\\}, \\left\\{3 \\sqrt{\\frac{2}{47}},-\\frac{3}{\\sqrt{94}},-\\frac{7}{\\sqrt{94}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, -2, 0), (2, -3, 3), (3, 3, -1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -2 \\\\\n -5 \\\\\n 7 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 7 \\\\\n -3 \\\\\n -9 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-71$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-2],\n [-5],\n [7],\n [-7]])\nb = np.array([\n [-3],\n [7],\n [-3],\n [-9],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & -2 & 0 \\\\\n 3 & -1 & 2 \\\\\n -1 & 0 & 1 \\\\\n 2 & -3 & 2 \\\\\n -2 & 3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.79 \\\\\n 0.5 \\\\\n -0.79 \\\\\n 1.5 \\\\\n 2.03 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.136 \\\\\n -0.017 \\\\\n 0.495 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2, 0],\n [3, -1, 2],\n [-1, 0, 1],\n [2, -3, 2],\n [-2, 3, 3]])\nb = np.array([\n [1.79],\n [0.5],\n [-0.79],\n [1.5],\n [2.03]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{8}{3} \\\\\n \\frac{2}{3} \\\\\n -\\frac{1}{9} \\\\\n \\frac{4}{3} \\\\\n \\frac{8}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{24}{\\sqrt{821}} \\\\\n \\frac{6}{\\sqrt{821}} \\\\\n -\\frac{1}{\\sqrt{821}} \\\\\n \\frac{12}{\\sqrt{821}} \\\\\n \\frac{8}{\\sqrt{821}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(8/3)],\n [(2/3)],\n [-(1/9)],\n [(4/3)],\n [(8/9)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{13}{7}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & -2 & 2 \\\\\n -7 & 5 & 7 \\\\\n -5 & 4 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{39}{7} & -\\frac{26}{7} & \\frac{26}{7} \\\\\n -13 & \\frac{65}{7} & 13 \\\\\n -\\frac{65}{7} & \\frac{52}{7} & -\\frac{117}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2, 2],\n [-7, 5, 7],\n [-5, 4, -9]])\nprint(a * (13/7))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -6 & 1 & -9 & -9 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 1, -9, -9, -6]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-2,4,\\frac{7}{2}\\right\\}, \\left\\{1,3,-\\frac{1}{2}\\right\\}, \\left\\{1,-\\frac{1}{2},2\\right\\}}$.", - "Output Answer": [ - "$22 x+10 y+14 z-45=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, 4, (7/2)],\n [1, 3, -(1/2)],\n [1, -(1/2), 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{21}{10}, \\frac{17}{5}}$ to the line $-\\frac{13 x}{5}-\\frac{49 y}{10}+\\frac{9}{10}=0$.", - "Output Answer": [ - "$\\frac{1061}{5 \\sqrt{3077}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (21/10), (17/5)\nline = Poly(-((13*x)/5)-((49*y)/10)+(9/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n \\frac{33}{4} \\\\\n -\\frac{33}{4} \\\\\n -\\frac{29}{4} \\\\\n -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$25$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [(33/4)],\n [-(33/4)],\n [-(29/4)],\n [-(1/4)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,3,2\\}, \\{1,-1,-1\\}, \\{-2,-3,0\\}}$", - "Output Answer": [ - "${\\left\\{0,\\frac{3}{\\sqrt{13}},\\frac{2}{\\sqrt{13}}\\right\\}, \\left\\{\\sqrt{\\frac{13}{14}},\\sqrt{\\frac{2}{91}},-\\frac{3}{\\sqrt{182}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{14}},-\\sqrt{\\frac{2}{7}},\\frac{3}{\\sqrt{14}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, 3, 2), (1, -1, -1), (-2, -3, 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -4 & -5 & -3 & -4 & -3 & -10 & -10 \\\\\n 1 & 4 & -9 & -1 & -2 & 2 & 5 \\\\\n 5 & -3 & 8 & -3 & -10 & 4 & 0 \\\\\n -5 & 2 & 0 & 6 & -9 & 4 & 5 \\\\\n -1 & -9 & 1 & 1 & -2 & -5 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & \\frac{68924}{71287} & \\frac{110388}{71287} \\\\\n 0 & 1 & 0 & 0 & 0 & \\frac{43993}{71287} & -\\frac{14849}{71287} \\\\\n 0 & 0 & 1 & 0 & 0 & \\frac{8683}{71287} & -\\frac{45060}{71287} \\\\\n 0 & 0 & 0 & 1 & 0 & \\frac{61959}{71287} & \\frac{132239}{71287} \\\\\n 0 & 0 & 0 & 0 & 1 & -\\frac{18892}{71287} & -\\frac{16071}{71287} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-4, -5, -3, -4, -3, -10, -10],\n [1, 4, -9, -1, -2, 2, 5],\n [5, -3, 8, -3, -10, 4, 0],\n [-5, 2, 0, 6, -9, 4, 5],\n [-1, -9, 1, 1, -2, -5, 2]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{35}{4} \\\\\n -\\frac{35}{4} \\\\\n -\\frac{5}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -\\frac{11}{2} \\\\\n \\frac{33}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1265}{16} \\\\\n \\frac{1255}{16} \\\\\n \\frac{35}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(35/4)],\n [-(35/4)],\n [-(5/4)]])\nb = np.array([\n [-5],\n [-(11/2)],\n [(33/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{2}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 15 \\\\\n 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [-8]])\nprint(a * -(3/2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{15}{13},-\\frac{10}{13}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1]]).squeeze()\nb = np.array([\n [-3],\n [-2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{22}{3} & -\\frac{2}{3} \\\\\n -9 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{27} \\left(2-\\sqrt{58}\\right),1\\right\\}, \\left\\{\\frac{1}{27} \\left(2+\\sqrt{58}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(22/3), -(2/3)],\n [-9, -6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 1 & 2 & 4 & -5 & -9 & 4 & -8 \\\\\n 10 & 10 & -10 & -4 & 0 & -6 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & -6 & \\frac{21}{5} & 9 & -\\frac{26}{5} & \\frac{31}{5} \\\\\n 0 & 1 & 5 & -\\frac{23}{5} & -9 & \\frac{23}{5} & -\\frac{71}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, 2, 4, -5, -9, 4, -8],\n [10, 10, -10, -4, 0, -6, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{1,2,2\\}, \\{-2,0,-1\\}, \\{2,1,3\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{3},\\frac{2}{3},\\frac{2}{3}\\right\\}, \\left\\{-\\frac{14}{3 \\sqrt{29}},\\frac{8}{3 \\sqrt{29}},-\\frac{1}{3 \\sqrt{29}}\\right\\}, \\left\\{-\\frac{2}{\\sqrt{29}},-\\frac{3}{\\sqrt{29}},\\frac{4}{\\sqrt{29}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((1, 2, 2), (-2, 0, -1), (2, 1, 3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{4}{3}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -7 & 9 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{28}{3} & -12 & 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 9, -9]])\nprint(a * -(4/3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -6 \\\\\n -3 \\\\\n 1 \\\\\n -8 \\\\\n 9 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -10 \\\\\n -6 \\\\\n -7 \\\\\n -10 \\\\\n 9 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$223$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-6],\n [-3],\n [1],\n [-8],\n [9],\n [0]])\nb = np.array([\n [-9],\n [-10],\n [-6],\n [-7],\n [-10],\n [9],\n [1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, 0, -\\frac{7}{3}}$ to the plane $\\frac{2 x}{3}-\\frac{5 y}{3}+2 z+\\frac{13}{3}=0$.", - "Output Answer": [ - "$\\sqrt{\\frac{5}{13}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, 0, -(7/3)\nplane = Poly(((2*x)/3)-((5*y)/3)+2*z+(13/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -3 & -2 & 0 & -2 & -2 \\\\\n 2 & -2 & 2 & -1 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -3 & 2 & -2 \\\\\n 0 & -2 & 1 \\\\\n -3 & 3 & -1 \\\\\n 1 & 2 & 0 \\\\\n 1 & -1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 5 & -4 & 6 \\\\\n -13 & 12 & -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2, 0, -2, -2],\n [2, -2, 2, -1, 0]])\nb = np.array([\n [-3, 2, -2],\n [0, -2, 1],\n [-3, 3, -1],\n [1, 2, 0],\n [1, -1, -1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -9 & 0 \\\\\n -9 & 10 \\\\\n -10 & 1 \\\\\n -1 & -3 \\\\\n 3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, 0],\n [-9, 10],\n [-10, 1],\n [-1, -3],\n [3, 3]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -5 & 7 & -10 & 9 \\\\\n 1 & 6 & 6 & 5 \\\\\n 7 & -2 & 5 & 4 \\\\\n -10 & -6 & 0 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, 7, -10, 9],\n [1, 6, 6, 5],\n [7, -2, 5, 4],\n [-10, -6, 0, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & 0 \\\\\n -1 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6,-6\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 0],\n [-1, -6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{16}{5} & \\frac{41}{5} & -\\frac{12}{5} \\\\\n \\frac{34}{5} & -3 & \\frac{33}{5} \\\\\n -\\frac{37}{5} & -\\frac{29}{5} & \\frac{48}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-11.035,7.218\\, -4.695 i,7.218\\, +4.695 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(16/5), (41/5), -(12/5)],\n [(34/5), -3, (33/5)],\n [-(37/5), -(29/5), (48/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -4 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -7 \\\\\n 7 \\\\\n -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1 \\\\\n 3 \\\\\n -8 \\\\\n 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-4],\n [-1],\n [0]])\nb = np.array([\n [4],\n [-7],\n [7],\n [-8]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & -2 \\\\\n -7 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{0,9\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2],\n [-7, 7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -9 & -5 & 0 \\\\\n 2 & 1 & -9 \\\\\n 4 & -8 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-8 x^2+71 x+828$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -5, 0],\n [2, 1, -9],\n [4, -8, 0]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{11}{4} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{1}{4} \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{7}{10},\\frac{7}{5}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [(11/4)]]).squeeze()\nb = np.array([\n [(1/4)],\n [-(1/2)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,-4,-3\\}, \\{2,1,5\\}, \\{-1,2,-2\\}}$.", - "Output Answer": [ - "$43 x-18 y-21 z+37=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, -4, -3],\n [2, 1, 5],\n [-1, 2, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{59}{7} \\\\\n \\frac{54}{7} \\\\\n -\\frac{19}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{44}{7} \\\\\n -\\frac{27}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{622}{49} \\\\\n \\frac{1327}{49} \\\\\n \\frac{1840}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(59/7)],\n [(54/7)],\n [-(19/7)]])\nb = np.array([\n [2],\n [(44/7)],\n [-(27/7)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & 2 & -3 \\\\\n 0 & 0 & -3 \\\\\n 0 & 3 & -2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 4 & -5 & -6 \\\\\n 0 & -9 & 6 \\\\\n 0 & -6 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, -3],\n [0, 0, -3],\n [0, 3, -2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 3 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$84$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-3],\n [2]])\nb = np.array([\n [-9],\n [3],\n [6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -2 \\\\\n -4 \\\\\n 10 \\\\\n -9 \\\\\n 2 \\\\\n 10 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -6 \\\\\n 8 \\\\\n 2 \\\\\n 0 \\\\\n -3 \\\\\n -2 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$90$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-2],\n [-4],\n [10],\n [-9],\n [2],\n [10],\n [6]])\nb = np.array([\n [-8],\n [-6],\n [8],\n [2],\n [0],\n [-3],\n [-2],\n [10]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{3} \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{29}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$58$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/3)],\n [-6]])\nb = np.array([\n [0],\n [-(29/3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{26}{3} & \\frac{13}{3} \\\\\n -\\frac{4}{3} & \\frac{16}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} \\left(-5-3 i \\sqrt{3}\\right),1\\right\\}, \\left\\{\\frac{1}{4} \\left(-5+3 i \\sqrt{3}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/3), (13/3)],\n [-(4/3), (16/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{7}{5} & \\frac{14}{5} & -3 & -\\frac{9}{5} & \\frac{2}{5} \\\\\n -3 & -\\frac{4}{5} & 1 & \\frac{8}{5} & \\frac{1}{5} \\\\\n \\frac{11}{5} & -1 & \\frac{8}{5} & \\frac{1}{5} & 0 \\\\\n \\frac{9}{5} & -\\frac{12}{5} & -1 & \\frac{11}{5} & -\\frac{13}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{7}{5} & -\\frac{2}{5} & -\\frac{13}{5} & -2 \\\\\n \\frac{3}{5} & -\\frac{2}{5} & -\\frac{11}{5} & \\frac{13}{5} \\\\\n -\\frac{9}{5} & 1 & \\frac{7}{5} & \\frac{13}{5} \\\\\n -\\frac{14}{5} & \\frac{12}{5} & \\frac{12}{5} & \\frac{4}{5} \\\\\n \\frac{14}{5} & 2 & \\frac{13}{5} & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{282}{25} & -\\frac{177}{25} & -10 & \\frac{51}{25} \\\\\n -\\frac{52}{5} & \\frac{169}{25} & \\frac{383}{25} & \\frac{42}{5} \\\\\n -\\frac{24}{25} & \\frac{8}{5} & -\\frac{4}{5} & -\\frac{67}{25} \\\\\n -\\frac{264}{25} & -\\frac{17}{25} & -\\frac{57}{25} & -\\frac{462}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/5), (14/5), -3, -(9/5), (2/5)],\n [-3, -(4/5), 1, (8/5), (1/5)],\n [(11/5), -1, (8/5), (1/5), 0],\n [(9/5), -(12/5), -1, (11/5), -(13/5)]])\nb = np.array([\n [(7/5), -(2/5), -(13/5), -2],\n [(3/5), -(2/5), -(11/5), (13/5)],\n [-(9/5), 1, (7/5), (13/5)],\n [-(14/5), (12/5), (12/5), (4/5)],\n [(14/5), 2, (13/5), 3]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & 0 \\\\\n 6 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+9 x+14$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 0],\n [6, -2]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{29}{10} & -\\frac{23}{10} & \\frac{23}{10} \\\\\n -\\frac{1}{5} & \\frac{37}{10} & -4 \\\\\n \\frac{23}{5} & \\frac{9}{2} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{34311}{1000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/10), -(23/10), (23/10)],\n [-(1/5), (37/10), -4],\n [(23/5), (9/2), -(3/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{57}{8} & -\\frac{35}{16} & \\frac{103}{16} & -\\frac{19}{16} \\\\\n -\\frac{51}{16} & -\\frac{9}{2} & -\\frac{75}{16} & -\\frac{33}{8} \\\\\n \\frac{63}{8} & -\\frac{39}{16} & -\\frac{19}{4} & \\frac{9}{16} \\\\\n \\frac{137}{16} & \\frac{75}{8} & -\\frac{117}{16} & \\frac{21}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{1}{4} & \\frac{83}{16} & \\frac{129}{16} & \\frac{103}{16} \\\\\n \\frac{1}{16} & \\frac{93}{16} & \\frac{159}{16} & -\\frac{125}{16} \\\\\n \\frac{35}{16} & -\\frac{1}{2} & -\\frac{97}{16} & -\\frac{31}{16} \\\\\n -\\frac{9}{8} & -\\frac{1}{16} & -\\frac{25}{16} & -\\frac{61}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{55}{8} & 3 & \\frac{29}{2} & \\frac{21}{4} \\\\\n -\\frac{25}{8} & \\frac{21}{16} & \\frac{21}{4} & -\\frac{191}{16} \\\\\n \\frac{161}{16} & -\\frac{47}{16} & -\\frac{173}{16} & -\\frac{11}{8} \\\\\n \\frac{119}{16} & \\frac{149}{16} & -\\frac{71}{8} & \\frac{23}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(57/8), -(35/16), (103/16), -(19/16)],\n [-(51/16), -(9/2), -(75/16), -(33/8)],\n [(63/8), -(39/16), -(19/4), (9/16)],\n [(137/16), (75/8), -(117/16), (21/4)]])\nb = np.array([\n [-(1/4), (83/16), (129/16), (103/16)],\n [(1/16), (93/16), (159/16), -(125/16)],\n [(35/16), -(1/2), -(97/16), -(31/16)],\n [-(9/8), -(1/16), -(25/16), -(61/16)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -5 & -4 \\\\\n 8 & -8 \\\\\n -5 & -9 \\\\\n 3 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 8 & 6 \\\\\n -7 & -3 \\\\\n -3 & 2 \\\\\n 5 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 3 & 2 \\\\\n 1 & -11 \\\\\n -8 & -7 \\\\\n 8 & 14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -4],\n [8, -8],\n [-5, -9],\n [3, 8]])\nb = np.array([\n [8, 6],\n [-7, -3],\n [-3, 2],\n [5, 6]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{2} & -\\frac{1}{2} \\\\\n \\frac{2}{3} & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{193}{12}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2), -(1/2)],\n [(2/3), (9/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 0 & -1 & -3 & -3 & 0 \\\\\n -1 & 0 & -2 & -3 & -3 \\\\\n 2 & 3 & -2 & 3 & 2 \\\\\n 3 & 2 & 3 & -3 & 1 \\\\\n 0 & 0 & 3 & 0 & -2 \\\\\n 0 & 0 & -1 & -3 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.03 \\\\\n 1.16 \\\\\n 0.99 \\\\\n -0.42 \\\\\n 2.9 \\\\\n -2.69 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.794 \\\\\n -0.682 \\\\\n -0.044 \\\\\n 0.994 \\\\\n -1.707 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -1, -3, -3, 0],\n [-1, 0, -2, -3, -3],\n [2, 3, -2, 3, 2],\n [3, 2, 3, -3, 1],\n [0, 0, 3, 0, -2],\n [0, 0, -1, -3, -1]])\nb = np.array([\n [-2.03],\n [1.16],\n [0.99],\n [-0.42],\n [2.9],\n [-2.69]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{19}{4} & -\\frac{15}{4} \\\\\n 6 & -\\frac{29}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} \\left(4-\\sqrt{6}\\right),1\\right\\}, \\left\\{\\frac{1}{4} \\left(4+\\sqrt{6}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/4), -(15/4)],\n [6, -(29/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{2}{9}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -4 & -1 & -3 & 9 \\\\\n 9 & 10 & -6 & 7 \\\\\n 8 & 6 & -8 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{8}{9} & -\\frac{2}{9} & -\\frac{2}{3} & 2 \\\\\n 2 & \\frac{20}{9} & -\\frac{4}{3} & \\frac{14}{9} \\\\\n \\frac{16}{9} & \\frac{4}{3} & -\\frac{16}{9} & \\frac{4}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -1, -3, 9],\n [9, 10, -6, 7],\n [8, 6, -8, 6]])\nprint(a * (2/9))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & \\frac{1}{4} \\\\\n -\\frac{33}{4} & -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{33} \\left(-31-4 \\sqrt{58}\\right),1\\right\\}, \\left\\{\\frac{1}{33} \\left(4 \\sqrt{58}-31\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, (1/4)],\n [-(33/4), -(13/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & 8 & -9 \\\\\n 6 & -7 & -8 \\\\\n 9 & 0 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-10.739,8.869\\, -9.738 i,8.869\\, +9.738 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 8, -9],\n [6, -7, -8],\n [9, 0, 8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{19}{5} & -\\frac{22}{5} \\\\\n \\frac{8}{5} & \\frac{6}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{15}{31} & \\frac{55}{31} \\\\\n -\\frac{20}{31} & -\\frac{95}{62} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/5), -(22/5)],\n [(8/5), (6/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -7 & -10 & -8 & -3 & 1 \\\\\n -9 & 4 & -3 & -5 & 10 \\\\\n -3 & -8 & 2 & -7 & -7 \\\\\n -7 & -3 & -6 & 9 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & \\frac{325}{4816} \\\\\n 0 & 1 & 0 & 0 & \\frac{1229}{1204} \\\\\n 0 & 0 & 1 & 0 & -\\frac{377}{301} \\\\\n 0 & 0 & 0 & 1 & -\\frac{2665}{4816} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, -10, -8, -3, 1],\n [-9, 4, -3, -5, 10],\n [-3, -8, 2, -7, -7],\n [-7, -3, -6, 9, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -3 & 0 & 3 \\\\\n 1 & -1 & 2 \\\\\n 2 & 2 & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 15 & 6 & -12 \\\\\n 0 & 5 & -1 \\\\\n -6 & -4 & 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, 3],\n [1, -1, 2],\n [2, 2, -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 2 & -\\frac{13}{3} & -\\frac{17}{3} \\\\\n -\\frac{17}{3} & -\\frac{23}{3} & 3 \\\\\n 10 & \\frac{17}{3} & \\frac{10}{3} \\\\\n \\frac{16}{3} & -\\frac{7}{3} & -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{3} & -\\frac{25}{3} & -9 \\\\\n -4 & -\\frac{10}{3} & -6 \\\\\n -8 & 7 & -\\frac{4}{3} \\\\\n 8 & \\frac{17}{3} & -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{19}{3} & -\\frac{38}{3} & -\\frac{44}{3} \\\\\n -\\frac{29}{3} & -11 & -3 \\\\\n 2 & \\frac{38}{3} & 2 \\\\\n \\frac{40}{3} & \\frac{10}{3} & -\\frac{26}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(13/3), -(17/3)],\n [-(17/3), -(23/3), 3],\n [10, (17/3), (10/3)],\n [(16/3), -(7/3), -5]])\nb = np.array([\n [(13/3), -(25/3), -9],\n [-4, -(10/3), -6],\n [-8, 7, -(4/3)],\n [8, (17/3), -(11/3)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -9 & 7 \\\\\n -10 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, 7],\n [-10, 1]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -3 & -8 & 6 & -7 \\\\\n -4 & -7 & 10 & 10 \\\\\n 2 & -1 & -2 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-146.,-18.,-83.,12.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, -8, 6, -7],\n [-4, -7, 10, 10],\n [2, -1, -2, 9]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{5} \\\\\n \\frac{3}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{8}{5} \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{108}{205},\\frac{27}{41}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/5)],\n [(3/5)]]).squeeze()\nb = np.array([\n [-(8/5)],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -9 \\\\\n 8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -1 \\\\\n -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -13 \\\\\n -8 \\\\\n 16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-9],\n [8]])\nb = np.array([\n [4],\n [-1],\n [-8]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n \\frac{19}{2} \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2)],\n [(19/2)],\n [-3]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -\\frac{19}{6} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{25}{6} \\\\\n -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{49}{6} \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-(19/6)]])\nb = np.array([\n [(25/6)],\n [-(11/3)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{29}{5} & \\frac{9}{5} \\\\\n 5 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(-59-\\sqrt{901}\\right),\\frac{1}{10} \\left(\\sqrt{901}-59\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/5), (9/5)],\n [5, -6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -7 & -2 & 3 \\\\\n 9 & 5 & -6 \\\\\n 7 & -7 & 0 \\\\\n 10 & -1 & 5 \\\\\n -9 & 9 & 4 \\\\\n 4 & 0 & -9 \\\\\n -10 & 4 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, -2, 3],\n [9, 5, -6],\n [7, -7, 0],\n [10, -1, 5],\n [-9, 9, 4],\n [4, 0, -9],\n [-10, 4, 1]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n 4 & -6 & 3 & -7 \\\\\n 9 & -6 & -7 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -6, 3, -7],\n [9, -6, -7, -7]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{1}{2} & -\\frac{8}{3} & -\\frac{1}{2} & \\frac{1}{3} \\\\\n \\frac{4}{3} & \\frac{3}{2} & -\\frac{5}{6} & \\frac{5}{3} \\\\\n -\\frac{1}{3} & \\frac{5}{2} & -\\frac{5}{6} & \\frac{17}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 1 & -\\frac{1}{3} \\\\\n -\\frac{7}{6} & -\\frac{7}{3} \\\\\n 1 & -\\frac{11}{6} \\\\\n -\\frac{17}{6} & \\frac{1}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{7}{6} & \\frac{265}{36} \\\\\n -\\frac{215}{36} & -\\frac{77}{36} \\\\\n -\\frac{109}{9} & -\\frac{67}{18} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), -(8/3), -(1/2), (1/3)],\n [(4/3), (3/2), -(5/6), (5/3)],\n [-(1/3), (5/2), -(5/6), (17/6)]])\nb = np.array([\n [1, -(1/3)],\n [-(7/6), -(7/3)],\n [1, -(11/6)],\n [-(17/6), (1/6)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n 0 & 0 & 0 & 0 \\\\\n 35 & 14 & -8 & -12 \\\\\n -107 & -40 & 22 & 33 \\\\\n 112 & 43 & -24 & -36 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 36 & 15 & -8 & -12 \\\\\n -\\frac{273}{2} & -\\frac{101}{2} & 29 & 42 \\\\\n \\frac{797}{6} & 50 & -28 & -41 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [0, 0, 0, 0],\n [35, 14, -8, -12],\n [-107, -40, 22, 33],\n [112, 43, -24, -36]])\nprint(expm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 2 \\\\\n \\frac{8}{3} \\\\\n -7 \\\\\n -\\frac{19}{3} \\\\\n \\frac{26}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{98}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [2],\n [(8/3)],\n [-7],\n [-(19/3)],\n [(26/3)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{4}{5}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{16}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4]])\nprint(a * -(4/5))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{10} & -1 & -\\frac{27}{10} \\\\\n -\\frac{41}{10} & -\\frac{22}{5} & \\frac{11}{10} \\\\\n \\frac{1}{2} & \\frac{23}{5} & \\frac{19}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{3103}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/10), -1, -(27/10)],\n [-(41/10), -(22/5), (11/10)],\n [(1/2), (23/5), (19/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -4 & 1 & -3 \\\\\n 3 & 4 & -4 \\\\\n 4 & -1 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{8}{19} & \\frac{1}{19} & -\\frac{4}{19} \\\\\n \\frac{31}{38} & \\frac{4}{19} & \\frac{25}{38} \\\\\n \\frac{1}{2} & 0 & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 1, -3],\n [3, 4, -4],\n [4, -1, 5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{9} & -\\frac{19}{9} & \\frac{59}{9} \\\\\n \\frac{85}{9} & \\frac{25}{9} & -\\frac{79}{9} \\\\\n \\frac{40}{9} & \\frac{23}{3} & \\frac{49}{9} \\\\\n -\\frac{44}{9} & -\\frac{40}{9} & 8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{61}{9} & 1 & -\\frac{61}{9} \\\\\n -\\frac{62}{9} & -1 & -\\frac{49}{9} \\\\\n \\frac{29}{3} & \\frac{13}{3} & \\frac{23}{3} \\\\\n -\\frac{38}{9} & \\frac{1}{9} & -\\frac{11}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{62}{9} & -\\frac{28}{9} & \\frac{40}{3} \\\\\n \\frac{49}{3} & \\frac{34}{9} & -\\frac{10}{3} \\\\\n -\\frac{47}{9} & \\frac{10}{3} & -\\frac{20}{9} \\\\\n -\\frac{2}{3} & -\\frac{41}{9} & \\frac{83}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/9), -(19/9), (59/9)],\n [(85/9), (25/9), -(79/9)],\n [(40/9), (23/3), (49/9)],\n [-(44/9), -(40/9), 8]])\nb = np.array([\n [(61/9), 1, -(61/9)],\n [-(62/9), -1, -(49/9)],\n [(29/3), (13/3), (23/3)],\n [-(38/9), (1/9), -(11/9)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{16}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{7}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1]])\nprint(a * -(7/16))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{3} & -\\frac{2}{3} & -\\frac{13}{3} \\\\\n -\\frac{2}{3} & -\\frac{2}{3} & 3 \\\\\n \\frac{8}{3} & -1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{727}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/3), -(2/3), -(13/3)],\n [-(2/3), -(2/3), 3],\n [(8/3), -1, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 1 & 3 & -2 & -3 & 1 \\\\\n 3 & -3 & -3 & -3 & 0 \\\\\n 0 & 1 & 2 & -2 & 2 \\\\\n 1 & -2 & -1 & 0 & 3 \\\\\n -2 & 2 & 0 & 3 & 0 \\\\\n -3 & 3 & 3 & -2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.76 \\\\\n 1.26 \\\\\n 1.53 \\\\\n 2.02 \\\\\n -1.59 \\\\\n 2.21 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.832 \\\\\n -1.173 \\\\\n -0.101 \\\\\n -0.975 \\\\\n 0.471 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3, -2, -3, 1],\n [3, -3, -3, -3, 0],\n [0, 1, 2, -2, 2],\n [1, -2, -1, 0, 3],\n [-2, 2, 0, 3, 0],\n [-3, 3, 3, -2, -3]])\nb = np.array([\n [-1.76],\n [1.26],\n [1.53],\n [2.02],\n [-1.59],\n [2.21]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -1 & -5 \\\\\n 1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{3}{8} & \\frac{5}{8} \\\\\n -\\frac{1}{8} & -\\frac{1}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -5],\n [1, -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -3 & 1 & -3 & -1 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1, -3, -1, 1]])\nb = np.array([\n [-2],\n [-1],\n [0],\n [0],\n [-1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 4 & 8 & 5 \\\\\n 7 & 5 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -8 & 0 & 3 \\\\\n -10 & 0 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -4 & 8 & 8 \\\\\n -3 & 5 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 8, 5],\n [7, 5, 8]])\nb = np.array([\n [-8, 0, 3],\n [-10, 0, -4]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,-3,3\\}, \\{3,-3,2\\}, \\{-3,-4,1\\}}$.", - "Output Answer": [ - "$x-11 y+5 z-46=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, -3, 3],\n [3, -3, 2],\n [-3, -4, 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 8 & \\frac{28}{3} & -\\frac{10}{3} & 4 \\\\\n 9 & -\\frac{1}{3} & -\\frac{4}{3} & 4 \\\\\n \\frac{28}{3} & \\frac{17}{3} & \\frac{4}{3} & 2 \\\\\n 6 & -\\frac{26}{3} & \\frac{25}{3} & -\\frac{26}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{20}{3} & \\frac{28}{3} & -\\frac{17}{3} & -\\frac{1}{3} \\\\\n \\frac{1}{3} & -\\frac{2}{3} & \\frac{7}{3} & 6 \\\\\n \\frac{8}{3} & -\\frac{13}{3} & 2 & 7 \\\\\n -\\frac{13}{3} & -\\frac{1}{3} & 0 & -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{4}{3} & \\frac{56}{3} & -9 & \\frac{11}{3} \\\\\n \\frac{28}{3} & -1 & 1 & 10 \\\\\n 12 & \\frac{4}{3} & \\frac{10}{3} & 9 \\\\\n \\frac{5}{3} & -9 & \\frac{25}{3} & -11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, (28/3), -(10/3), 4],\n [9, -(1/3), -(4/3), 4],\n [(28/3), (17/3), (4/3), 2],\n [6, -(26/3), (25/3), -(26/3)]])\nb = np.array([\n [-(20/3), (28/3), -(17/3), -(1/3)],\n [(1/3), -(2/3), (7/3), 6],\n [(8/3), -(13/3), 2, 7],\n [-(13/3), -(1/3), 0, -(7/3)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n 10 & 0 & -4 & 7 \\\\\n 0 & -1 & 8 & 4 \\\\\n -5 & 9 & -8 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 0, -4, 7],\n [0, -1, 8, 4],\n [-5, 9, -8, 0]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{2} & \\frac{3}{2} \\\\\n -6 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{3}{4} \\left(7-i \\sqrt{15}\\right),\\frac{3}{4} \\left(7+i \\sqrt{15}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/2), (3/2)],\n [-6, 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{28}{5} & \\frac{29}{5} & -\\frac{6}{5} \\\\\n \\frac{17}{5} & -7 & \\frac{47}{5} \\\\\n \\frac{2}{5} & 10 & \\frac{26}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.22,0.145,1.\\}, \\{0.392,0.588,1.\\}, \\{0.639,-1.866,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(28/5), (29/5), -(6/5)],\n [(17/5), -7, (47/5)],\n [(2/5), 10, (26/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -2 \\\\\n -1 & 0 \\\\\n 0 & -1 \\\\\n -2 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.51 \\\\\n -2.43 \\\\\n 2.53 \\\\\n -0.84 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.933 \\\\\n -1.712 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2],\n [-1, 0],\n [0, -1],\n [-2, -1]])\nb = np.array([\n [-1.51],\n [-2.43],\n [2.53],\n [-0.84]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 2 \\\\\n -5 \\\\\n 7 \\\\\n 10 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{77}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [2],\n [-5],\n [7],\n [10],\n [-9]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -7 \\\\\n -6 \\\\\n 6 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{161}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-7],\n [-6],\n [6],\n [-6]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{67}{8} & \\frac{3}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{13}{16} & \\frac{69}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{147}{16} & 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(67/8), (3/8)]])\nb = np.array([\n [-(13/16), (69/8)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 3 \\\\\n \\frac{1}{2} & -1 & -3 \\\\\n -1 & 2 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -2 & 6 & -\\frac{3}{2} \\\\\n 3 & -5 & 9 \\\\\n \\frac{3}{2} & -5 & -\\frac{27}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 0, 3],\n [(1/2), -1, -3],\n [-1, 2, -(3/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -2 & 0 & -2 & -7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 4 & 5 & 1 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -6 & -5 & -3 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, -2, -7]])\nb = np.array([\n [4, 5, 1, -2]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{22}{3} \\\\\n \\frac{10}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{2 \\sqrt{146}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(22/3)],\n [(10/3)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & 1 \\\\\n -2 & 1 \\\\\n -3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.71 \\\\\n 1.29 \\\\\n -1.97 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.289 \\\\\n 0.368 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 1],\n [-2, 1],\n [-3, -3]])\nb = np.array([\n [-1.71],\n [1.29],\n [-1.97]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{2}{3} & -8 \\\\\n -\\frac{7}{6} & -\\frac{19}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{22}{3} & 9 \\\\\n \\frac{29}{3} & -\\frac{4}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{20}{3} & -17 \\\\\n -\\frac{65}{6} & -\\frac{49}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/3), -8],\n [-(7/6), -(19/2)]])\nb = np.array([\n [(22/3), 9],\n [(29/3), -(4/3)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 9 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2 \\\\\n 14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [9]])\nb = np.array([\n [-3],\n [-5]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{379}{50} \\\\\n -\\frac{102}{25} \\\\\n -\\frac{47}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{949}{100} \\\\\n -\\frac{487}{100} \\\\\n -\\frac{21}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{14321}{500} \\\\\n -\\frac{5737}{100} \\\\\n \\frac{9023}{5000} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(379/50)],\n [-(102/25)],\n [-(47/5)]])\nb = np.array([\n [(949/100)],\n [-(487/100)],\n [-(21/5)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-1,-3,0\\}, \\{0,-1,-1\\}, \\{-1,1,3\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{10}},-\\frac{3}{\\sqrt{10}},0\\right\\}, \\left\\{\\frac{3}{\\sqrt{110}},-\\frac{1}{\\sqrt{110}},-\\sqrt{\\frac{10}{11}}\\right\\}, \\left\\{-\\frac{3}{\\sqrt{11}},\\frac{1}{\\sqrt{11}},-\\frac{1}{\\sqrt{11}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, -3, 0), (0, -1, -1), (-1, 1, 3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n e \\\\\n 2 e \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 e \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{5} e$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.e],\n [2*math.e]])\nb = np.array([\n [-3*math.e],\n [0]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -2 & -3 & 3 & -3 \\\\\n 1 & -1 & 3 & 1 \\\\\n 1 & 1 & 2 & -2 \\\\\n -1 & 2 & 2 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 1 & 2 \\\\\n -2 & -2 \\\\\n 2 & 3 \\\\\n -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 13 & 5 \\\\\n 8 & 15 \\\\\n 5 & 2 \\\\\n -1 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, 3, -3],\n [1, -1, 3, 1],\n [1, 1, 2, -2],\n [-1, 2, 2, 0]])\nb = np.array([\n [1, 2],\n [-2, -2],\n [2, 3],\n [-1, 2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{2}{\\sqrt{29}} \\\\\n \\frac{4}{\\sqrt{29}} \\\\\n -\\frac{3}{\\sqrt{29}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [2],\n [-(3/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 1 & 9 & 9 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-9.,0.,1.,0.\\}, \\{-9.,1.,0.,0.\\}, \\{-4.,0.,0.,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [1, 9, 9, 4]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 1 & -1 \\\\\n 1 & -2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & 1 \\\\\n -1 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1],\n [1, -2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & 10 & 2 \\\\\n -\\frac{7}{3} & -1 & \\frac{4}{3} \\\\\n \\frac{22}{3} & -\\frac{4}{3} & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.355,0.067,1.\\}, \\{-0.928-0.616 i,-0.408+0.566 i,1.\\}, \\{-0.928+0.616 i,-0.408-0.566 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 10, 2],\n [-(7/3), -1, (4/3)],\n [(22/3), -(4/3), 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n -\\frac{17}{16} \\\\\n \\frac{55}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{61}{16} \\\\\n -\\frac{13}{8} \\\\\n \\frac{123}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{661}{256} \\\\\n -\\frac{6307}{256} \\\\\n -\\frac{1661}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2)],\n [-(17/16)],\n [(55/16)]])\nb = np.array([\n [-(61/16)],\n [-(13/8)],\n [(123/16)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -3 \\\\\n -14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-9]])\nb = np.array([\n [-7],\n [-5]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -5 & -5 \\\\\n -1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -5],\n [-1, -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -9 \\\\\n -7 \\\\\n 0 \\\\\n -2 \\\\\n -9 \\\\\n 7 \\\\\n 8 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 9 \\\\\n 4 \\\\\n 6 \\\\\n -10 \\\\\n -1 \\\\\n 2 \\\\\n 4 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{798}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-9],\n [-7],\n [0],\n [-2],\n [-9],\n [7],\n [8],\n [8]])\nb = np.array([\n [4],\n [9],\n [4],\n [6],\n [-10],\n [-1],\n [2],\n [4],\n [10]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & 4 & -4 \\\\\n -3 & 0 & 1 \\\\\n -3 & 3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$45$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 4, -4],\n [-3, 0, 1],\n [-3, 3, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & -2 & 1 & -1 \\\\\n 3 & 0 & -1 & 0 \\\\\n -2 & 2 & -3 & -1 \\\\\n -1 & -1 & -3 & 0 \\\\\n 3 & -1 & 3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.84 \\\\\n 1.89 \\\\\n -0.68 \\\\\n 2.01 \\\\\n 0.63 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.474 \\\\\n -0.942 \\\\\n -0.511 \\\\\n -0.249 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2, 1, -1],\n [3, 0, -1, 0],\n [-2, 2, -3, -1],\n [-1, -1, -3, 0],\n [3, -1, 3, 2]])\nb = np.array([\n [1.84],\n [1.89],\n [-0.68],\n [2.01],\n [0.63]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-4, 0}$ to the line $\\frac{5 x}{2}+y+1=0$.", - "Output Answer": [ - "$\\frac{18}{\\sqrt{29}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -4, 0\nline = Poly(((5*x)/2)+y+1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & -3 \\\\\n -5 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -3],\n [-5, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{66}{7} \\\\\n -\\frac{39}{7} \\\\\n \\frac{30}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{3}{7} \\\\\n \\frac{59}{7} \\\\\n -\\frac{11}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1341}{49} \\\\\n -\\frac{636}{49} \\\\\n -\\frac{3777}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(66/7)],\n [-(39/7)],\n [(30/7)]])\nb = np.array([\n [(3/7)],\n [(59/7)],\n [-(11/7)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{14}{3} \\\\\n -8 \\\\\n 7 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(14/3)],\n [-8],\n [7],\n [1]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & 1 & 0 & 0 \\\\\n 3 & 2 & -2 & 3 \\\\\n -3 & 3 & -3 & -1 \\\\\n -2 & -1 & -1 & -2 \\\\\n 3 & 3 & 0 & 0 \\\\\n 1 & 2 & 0 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.28 \\\\\n 0.36 \\\\\n -1.4 \\\\\n 2.95 \\\\\n 2.22 \\\\\n 2. \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.807 \\\\\n -0.26 \\\\\n -0.548 \\\\\n -1.056 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, 0, 0],\n [3, 2, -2, 3],\n [-3, 3, -3, -1],\n [-2, -1, -1, -2],\n [3, 3, 0, 0],\n [1, 2, 0, -2]])\nb = np.array([\n [1.28],\n [0.36],\n [-1.4],\n [2.95],\n [2.22],\n [2.]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 5 & 5 & 9 & -4 & -5 & -1 & -8 \\\\\n 1 & 10 & -7 & 7 & -5 & 10 & -10 \\\\\n 9 & 2 & 7 & -3 & 10 & -10 & -10 \\\\\n 2 & 9 & -2 & -5 & 6 & -8 & 9 \\\\\n 2 & -1 & 3 & 9 & 8 & -6 & 7 \\\\\n -1 & 7 & -5 & 10 & -3 & -2 & 8 \\\\\n 6 & -8 & -10 & 1 & -6 & -9 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, 5, 9, -4, -5, -1, -8],\n [1, 10, -7, 7, -5, 10, -10],\n [9, 2, 7, -3, 10, -10, -10],\n [2, 9, -2, -5, 6, -8, 9],\n [2, -1, 3, 9, 8, -6, 7],\n [-1, 7, -5, 10, -3, -2, 8],\n [6, -8, -10, 1, -6, -9, -3]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 6 & -2 & -6 & 9 & -5 \\\\\n -3 & -9 & -2 & -4 & 10 \\\\\n 7 & 4 & 6 & 6 & 4 \\\\\n 9 & 2 & -2 & 4 & -5 \\\\\n -1 & 4 & 3 & 1 & 8 \\\\\n 0 & -6 & 10 & -8 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, -2, -6, 9, -5],\n [-3, -9, -2, -4, 10],\n [7, 4, 6, 6, 4],\n [9, 2, -2, 4, -5],\n [-1, 4, 3, 1, 8],\n [0, -6, 10, -8, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -\\frac{3}{4} \\\\\n -\\frac{11}{2} \\\\\n -\\frac{17}{2} \\\\\n -\\frac{13}{4} \\\\\n \\frac{1}{4} \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{3 \\sqrt{231}}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-(3/4)],\n [-(11/2)],\n [-(17/2)],\n [-(13/4)],\n [(1/4)],\n [-(1/2)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{9}{4} & \\frac{25}{8} & -\\frac{37}{8} \\\\\n -\\frac{3}{16} & -\\frac{73}{16} & \\frac{31}{16} \\\\\n -\\frac{61}{16} & -\\frac{63}{16} & -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{184}{1305} & \\frac{14032}{53505} & -\\frac{3424}{17835} \\\\\n -\\frac{376}{3915} & -\\frac{39568}{160515} & -\\frac{2384}{53505} \\\\\n -\\frac{832}{3915} & -\\frac{6256}{160515} & -\\frac{6608}{53505} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/4), (25/8), -(37/8)],\n [-(3/16), -(73/16), (31/16)],\n [-(61/16), -(63/16), -(3/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 9 & -1 & 8 \\\\\n 3 & 10 & 8 \\\\\n 3 & 2 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+20 x^2-72 x-267$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -1, 8],\n [3, 10, 8],\n [3, 2, 1]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & -\\frac{7}{2} \\\\\n -\\frac{19}{2} & -3 \\\\\n 3 & 2 \\\\\n -8 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 4 & 2 \\\\\n \\frac{17}{2} & -\\frac{7}{2} \\\\\n -\\frac{9}{2} & \\frac{11}{2} \\\\\n \\frac{1}{2} & \\frac{17}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{7}{2} & -\\frac{11}{2} \\\\\n -18 & \\frac{1}{2} \\\\\n \\frac{15}{2} & -\\frac{7}{2} \\\\\n -\\frac{17}{2} & -10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), -(7/2)],\n [-(19/2), -3],\n [3, 2],\n [-8, -(3/2)]])\nb = np.array([\n [4, 2],\n [(17/2), -(7/2)],\n [-(9/2), (11/2)],\n [(1/2), (17/2)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{23}{3} & -4 & \\frac{20}{3} & -8 \\\\\n -\\frac{17}{6} & -\\frac{19}{6} & -\\frac{7}{2} & -\\frac{4}{3} \\\\\n -8 & 5 & -\\frac{43}{6} & \\frac{16}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{7}{3} & -4 & \\frac{5}{2} & \\frac{17}{2} \\\\\n \\frac{16}{3} & -\\frac{1}{2} & \\frac{11}{6} & -3 \\\\\n \\frac{7}{6} & -\\frac{5}{2} & \\frac{1}{6} & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{16}{3} & -8 & \\frac{55}{6} & \\frac{1}{2} \\\\\n \\frac{5}{2} & -\\frac{11}{3} & -\\frac{5}{3} & -\\frac{13}{3} \\\\\n -\\frac{41}{6} & \\frac{5}{2} & -7 & \\frac{22}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/3), -4, (20/3), -8],\n [-(17/6), -(19/6), -(7/2), -(4/3)],\n [-8, 5, -(43/6), (16/3)]])\nb = np.array([\n [-(7/3), -4, (5/2), (17/2)],\n [(16/3), -(1/2), (11/6), -3],\n [(7/6), -(5/2), (1/6), 2]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n 4 & -6 \\\\\n 1 & -10 \\\\\n -7 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -6],\n [1, -10],\n [-7, -4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -8 & 0 & 5 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 1 & 6 & -5 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -7 & 6 & 0 & 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 0, 5, 8]])\nb = np.array([\n [1, 6, -5, 2]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{2}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 8 & 5 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 4 & \\frac{5}{2} & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 5, -5]])\nprint(a * (1/2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & -5 & 3 \\\\\n -6 & 5 & 10 \\\\\n -1 & -4 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{4.796,-2.848,1.\\}, \\{0.532\\, -0.687 i,0.316\\, -1.275 i,1.\\}, \\{0.532\\, +0.687 i,0.316\\, +1.275 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -5, 3],\n [-6, 5, 10],\n [-1, -4, 5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & 0 \\\\\n -3 & 0 \\\\\n -3 & -1 \\\\\n -1 & -3 \\\\\n -3 & -3 \\\\\n -3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.26 \\\\\n -0.72 \\\\\n -1.17 \\\\\n -1.32 \\\\\n -1.05 \\\\\n 1.35 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.15 \\\\\n 0.022 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0],\n [-3, 0],\n [-3, -1],\n [-1, -3],\n [-3, -3],\n [-3, -3]])\nb = np.array([\n [-0.26],\n [-0.72],\n [-1.17],\n [-1.32],\n [-1.05],\n [1.35]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 10 & -6 & -\\frac{9}{2} \\\\\n -9 & -7 & -\\frac{17}{2} \\\\\n -1 & -\\frac{9}{2} & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{7.,-3.667,1.\\}, \\{0.075,-0.701,1.\\}, \\{1.057,3.228,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -6, -(9/2)],\n [-9, -7, -(17/2)],\n [-1, -(9/2), 3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 1 & -1 \\\\\n 3 & 3 \\\\\n 10 & -6 \\\\\n 8 & 1 \\\\\n 10 & 3 \\\\\n -10 & 5 \\\\\n 5 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, -1],\n [3, 3],\n [10, -6],\n [8, 1],\n [10, 3],\n [-10, 5],\n [5, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{1}{3}, -\\frac{1}{3}, -\\frac{11}{3}}$ to the plane $\\frac{14 x}{3}-2 y+\\frac{2 z}{3}-\\frac{7}{3}=0$.", - "Output Answer": [ - "$\\frac{17}{2 \\sqrt{59}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(1/3), -(1/3), -(11/3)\nplane = Poly(((14*x)/3)-2*y+((2*z)/3)-(7/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [1],\n [1],\n [1],\n [1],\n [0],\n [0],\n [0],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [-1],\n [0],\n [0],\n [0],\n [0],\n [0],\n [1],\n [0],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,1,1\\}, \\{-3,3,1\\}, \\{-1,2,3\\}}$", - "Output Answer": [ - "${\\left\\{0,\\frac{1}{\\sqrt{2}},\\frac{1}{\\sqrt{2}}\\right\\}, \\left\\{-\\frac{3}{\\sqrt{11}},\\frac{1}{\\sqrt{11}},-\\frac{1}{\\sqrt{11}}\\right\\}, \\left\\{-\\sqrt{\\frac{2}{11}},-\\frac{3}{\\sqrt{22}},\\frac{3}{\\sqrt{22}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, 1, 1), (-3, 3, 1), (-1, 2, 3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{7}{2} & -\\frac{9 i}{2} & -\\frac{7}{2}-4 i \\\\\n \\frac{7}{2}+\\frac{5 i}{2} & \\frac{3}{2}-\\frac{7 i}{2} & \\frac{3}{2}-5 i \\\\\n -\\frac{9}{2}-\\frac{7 i}{2} & -\\frac{5}{2}+\\frac{i}{2} & -5+\\frac{9 i}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{101}{4}+\\frac{29 i}{2} & -5-\\frac{57 i}{4} & \\frac{3}{4}-\\frac{33 i}{2} \\\\\n 2+\\frac{35 i}{2} & -13 i & -\\frac{5}{2}-\\frac{15 i}{4} \\\\\n \\frac{25}{2}-\\frac{39 i}{2} & -\\frac{15}{2}+16 i & \\frac{21}{4}-\\frac{3 i}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2), -((9j)/2), -(7/2)-4j],\n [(7/2)+((5j)/2), (3/2)-((7j)/2), (3/2)-5j],\n [-(9/2)-((7j)/2), -(5/2)+(1j/2), -5+((9j)/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{17}{7} & -\\frac{31}{7} & -2 & \\frac{29}{7} \\\\\n \\frac{48}{7} & \\frac{3}{7} & 9 & 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -1 & \\frac{16}{7} & \\frac{44}{7} & \\frac{26}{7} \\\\\n \\frac{6}{7} & \\frac{23}{7} & 0 & -\\frac{65}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{10}{7} & -\\frac{15}{7} & \\frac{30}{7} & \\frac{55}{7} \\\\\n \\frac{54}{7} & \\frac{26}{7} & 9 & \\frac{5}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/7), -(31/7), -2, (29/7)],\n [(48/7), (3/7), 9, 10]])\nb = np.array([\n [-1, (16/7), (44/7), (26/7)],\n [(6/7), (23/7), 0, -(65/7)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{51}{16} & -3 & -\\frac{83}{16} & \\frac{53}{16} \\\\\n -\\frac{79}{8} & \\frac{11}{4} & \\frac{7}{16} & \\frac{17}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{83}{16} & -9 & \\frac{135}{16} & \\frac{131}{16} \\\\\n -\\frac{81}{16} & \\frac{87}{16} & -\\frac{53}{16} & \\frac{57}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{67}{8} & -12 & \\frac{13}{4} & \\frac{23}{2} \\\\\n -\\frac{239}{16} & \\frac{131}{16} & -\\frac{23}{8} & \\frac{193}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(51/16), -3, -(83/16), (53/16)],\n [-(79/8), (11/4), (7/16), (17/2)]])\nb = np.array([\n [(83/16), -9, (135/16), (131/16)],\n [-(81/16), (87/16), -(53/16), (57/16)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & -3 & -1 \\\\\n 3 & 2 & 3 \\\\\n 3 & 1 & -1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -45 & 14 & -1 \\\\\n -6 & -49 & -21 \\\\\n -21 & -15 & -25 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3, -1],\n [3, 2, 3],\n [3, 1, -1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{15}{8}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 10 & -10 \\\\\n -2 & -8 \\\\\n 7 & 9 \\\\\n -5 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{75}{4} & \\frac{75}{4} \\\\\n \\frac{15}{4} & 15 \\\\\n -\\frac{105}{8} & -\\frac{135}{8} \\\\\n \\frac{75}{8} & -\\frac{75}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -10],\n [-2, -8],\n [7, 9],\n [-5, 10]])\nprint(a * -(15/8))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{2}{9}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 9 \\\\\n 7 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{2}{3} & 2 \\\\\n \\frac{14}{9} & -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 9],\n [7, -3]])\nprint(a * (2/9))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -2 & 3 & -7 \\\\\n 9 & -4 & -4 \\\\\n 1 & 9 & 3 \\\\\n -8 & 0 & -10 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -9 & -7 & 10 \\\\\n -3 & 4 & 8 \\\\\n 3 & -2 & 0 \\\\\n -8 & 6 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 7 & 10 & -17 \\\\\n 12 & -8 & -12 \\\\\n -2 & 11 & 3 \\\\\n 0 & -6 & -15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 3, -7],\n [9, -4, -4],\n [1, 9, 3],\n [-8, 0, -10]])\nb = np.array([\n [-9, -7, 10],\n [-3, 4, 8],\n [3, -2, 0],\n [-8, 6, 5]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & -3 & -2 \\\\\n 4 & 2 & 4 \\\\\n 5 & 1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{10} & \\frac{7}{60} & \\frac{1}{15} \\\\\n -\\frac{3}{10} & -\\frac{1}{60} & \\frac{2}{15} \\\\\n \\frac{1}{20} & \\frac{17}{120} & -\\frac{2}{15} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3, -2],\n [4, 2, 4],\n [5, 1, -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 2 & 6 & 2 & 9 & -8 \\\\\n 10 & 0 & 5 & -1 & -10 \\\\\n 4 & -9 & -9 & 4 & 5 \\\\\n -7 & -9 & 10 & 9 & 6 \\\\\n -2 & 1 & -10 & -4 & 4 \\\\\n 4 & -9 & -5 & -3 & -9 \\\\\n -10 & -5 & 10 & -5 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, 6, 2, 9, -8],\n [10, 0, 5, -1, -10],\n [4, -9, -9, 4, 5],\n [-7, -9, 10, 9, 6],\n [-2, 1, -10, -4, 4],\n [4, -9, -5, -3, -9],\n [-10, -5, 10, -5, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{3} \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{5}{3} & 0 & -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{35}{9} & 0 & \\frac{7}{3} & -\\frac{7}{3} \\\\\n \\frac{10}{3} & 0 & 2 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/3)],\n [-2]])\nb = np.array([\n [-(5/3), 0, -1, 1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{13}{2} & -8 \\\\\n \\frac{3}{2} & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{-\\frac{2}{3} \\left(1-i \\sqrt{11}\\right),1\\right\\}, \\left\\{-\\frac{2}{3} \\left(1+i \\sqrt{11}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/2), -8],\n [(3/2), -(9/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 2 & 1 \\\\\n -2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{4} & -\\frac{1}{4} \\\\\n \\frac{1}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1],\n [-2, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 10 \\\\\n 5 \\\\\n 4 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{178}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [10],\n [5],\n [4],\n [-1],\n [0]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 3 \\\\\n 2 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -3 \\\\\n 3 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{27}{29},\\frac{27}{29},-\\frac{27}{29},-\\frac{9}{29},-\\frac{9}{29}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [3],\n [2],\n [-2],\n [2]]).squeeze()\nb = np.array([\n [3],\n [-3],\n [3],\n [1],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{5} \\\\\n \\frac{7}{5} \\\\\n \\frac{6}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{7}{\\sqrt{134}} \\\\\n \\frac{7}{\\sqrt{134}} \\\\\n 3 \\sqrt{\\frac{2}{67}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/5)],\n [(7/5)],\n [(6/5)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{1,-4,\\frac{7}{2}\\right\\}, \\left\\{-\\frac{3}{2},-2,-\\frac{3}{2}\\right\\}, \\left\\{\\frac{3}{2},-5,-4\\right\\}}$.", - "Output Answer": [ - "$80 x+85 y-6 z+281=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -4, (7/2)],\n [-(3/2), -2, -(3/2)],\n [(3/2), -5, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n \\frac{2}{\\sqrt{5}} \\\\\n \\frac{1}{\\sqrt{5}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [2],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -9 & 7 & -4 & -7 & 0 \\\\\n 1 & -8 & 8 & 4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & -\\frac{24}{65} & \\frac{28}{65} & \\frac{21}{65} \\\\\n 0 & 1 & -\\frac{68}{65} & -\\frac{29}{65} & \\frac{27}{65} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-9, 7, -4, -7, 0],\n [1, -8, 8, 4, -3]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 e \\\\\n 2 e \\\\\n e \\\\\n 0 \\\\\n 3 e \\\\\n 2 e \\\\\n e \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n e \\\\\n e \\\\\n 3 e \\\\\n 3 e \\\\\n e \\\\\n e \\\\\n e \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9 e^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-2*math.e],\n [2*math.e],\n [math.e],\n [0],\n [3*math.e],\n [2*math.e],\n [math.e]])\nb = np.array([\n [math.e],\n [math.e],\n [3*math.e],\n [3*math.e],\n [math.e],\n [math.e],\n [math.e]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{7}{2},0,-3\\right\\}, \\{-5,4,4\\}, \\left\\{3,\\frac{1}{2},-\\frac{1}{2}\\right\\}}$.", - "Output Answer": [ - "$26 x+197 y-107 z-230=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(7/2), 0, -3],\n [-5, 4, 4],\n [3, (1/2), -(1/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${4, -3}$ to the line $5 x+4 y-1=0$.", - "Output Answer": [ - "$\\frac{7}{\\sqrt{41}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 4, -3\nline = Poly(5*x+4*y-1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 1 & -1 & -1 & -2 & 0 \\\\\n 0 & -2 & 2 & 0 & 2 \\\\\n -1 & -2 & -3 & -2 & -2 \\\\\n -1 & -2 & 2 & -2 & 2 \\\\\n -1 & -3 & 2 & 0 & -3 \\\\\n 0 & -1 & -2 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.86 \\\\\n 2.07 \\\\\n 1.51 \\\\\n 0.04 \\\\\n 0.87 \\\\\n -1.49 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.092 \\\\\n -0.518 \\\\\n 0.191 \\\\\n -0.274 \\\\\n -0.297 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, -1, -2, 0],\n [0, -2, 2, 0, 2],\n [-1, -2, -3, -2, -2],\n [-1, -2, 2, -2, 2],\n [-1, -3, 2, 0, -3],\n [0, -1, -2, -1, 2]])\nb = np.array([\n [1.86],\n [2.07],\n [1.51],\n [0.04],\n [0.87],\n [-1.49]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 2 \\\\\n \\frac{22}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -\\frac{5}{3} \\\\\n -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{295}{\\sqrt{733163}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [2],\n [(22/3)]]).squeeze()\nb = np.array([\n [7],\n [-(5/3)],\n [-(11/3)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 2 \\\\\n -8 \\\\\n 2 \\\\\n 1 \\\\\n -2 \\\\\n 5 \\\\\n -2 \\\\\n 2 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 2 \\\\\n 10 \\\\\n 0 \\\\\n 8 \\\\\n 9 \\\\\n 2 \\\\\n -4 \\\\\n 5 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{167}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [2],\n [-8],\n [2],\n [1],\n [-2],\n [5],\n [-2],\n [2],\n [8]])\nb = np.array([\n [-5],\n [2],\n [10],\n [0],\n [8],\n [9],\n [2],\n [-4],\n [5],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(\\sqrt{35}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [0],\n [0],\n [1],\n [0],\n [-1],\n [-1],\n [0],\n [1]]).squeeze()\nb = np.array([\n [1],\n [0],\n [0],\n [-1],\n [1],\n [0],\n [-1],\n [1],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{3,3,0\\}, \\{0,0,-2\\}, \\{0,1,-3\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{2}},\\frac{1}{\\sqrt{2}},0\\right\\}, \\{0,0,-1\\}, \\left\\{-\\frac{1}{\\sqrt{2}},\\frac{1}{\\sqrt{2}},0\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((3, 3, 0), (0, 0, -2), (0, 1, -3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 3 & -2 \\\\\n 0 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 3 & -2 & -3 & 1 \\\\\n -2 & -2 & -1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 13 & -2 & -7 & 5 \\\\\n 2 & 2 & 1 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2],\n [0, -1]])\nb = np.array([\n [3, -2, -3, 1],\n [-2, -2, -1, -1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 3 & 3 & 1 & -2 & 2 \\\\\n 0 & 0 & 2 & 0 & -3 \\\\\n -3 & 2 & 0 & -3 & 0 \\\\\n 1 & 0 & 2 & 1 & 1 \\\\\n 1 & 1 & 0 & 0 & 3 \\\\\n -1 & -3 & -3 & -3 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.66 \\\\\n -1.42 \\\\\n -2.45 \\\\\n -2.65 \\\\\n 0.55 \\\\\n 1.05 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.511 \\\\\n 0.525 \\\\\n -1.539 \\\\\n 0.64 \\\\\n -0.396 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3, 1, -2, 2],\n [0, 0, 2, 0, -3],\n [-3, 2, 0, -3, 0],\n [1, 0, 2, 1, 1],\n [1, 1, 0, 0, 3],\n [-1, -3, -3, -3, -1]])\nb = np.array([\n [-0.66],\n [-1.42],\n [-2.45],\n [-2.65],\n [0.55],\n [1.05]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 4 & 8 & 7 & 10 \\\\\n -2 & -1 & 10 & 5 \\\\\n 9 & 10 & 8 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{789.,-743.,-86.,339.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, 8, 7, 10],\n [-2, -1, 10, 5],\n [9, 10, 8, 3]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 5 & -2 \\\\\n 5 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+2 x-25$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -2],\n [5, -7]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{23}{5} & -\\frac{9}{5} & -2 \\\\\n \\frac{32}{5} & -\\frac{16}{5} & -\\frac{16}{5} \\\\\n \\frac{7}{5} & \\frac{27}{5} & \\frac{27}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.258,-1.463,1.\\}, \\{-0.093-0.114 i,-1.+0.382 i,1.\\}, \\{-0.093+0.114 i,-1.-0.382 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/5), -(9/5), -2],\n [(32/5), -(16/5), -(16/5)],\n [(7/5), (27/5), (27/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 3 & 0 & 0 \\\\\n 3 & 1 & -3 \\\\\n 0 & 2 & 2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 9 & 0 & 0 \\\\\n 12 & -5 & -9 \\\\\n 6 & 6 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 0, 0],\n [3, 1, -3],\n [0, 2, 2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n \\frac{26}{9} \\\\\n \\frac{11}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{9}{\\sqrt{878}} \\\\\n 13 \\sqrt{\\frac{2}{439}} \\\\\n \\frac{11}{\\sqrt{878}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [(26/9)],\n [(11/9)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,-3,0\\}, \\{-1,0,4\\}, \\{3,3,3\\}}$.", - "Output Answer": [ - "$5 x-4 y+8 z-27=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, -3, 0],\n [-1, 0, 4],\n [3, 3, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -7 \\\\\n -3 \\\\\n -9 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 1 \\\\\n -5 \\\\\n 6 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{37}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-7],\n [-3],\n [-9],\n [2]])\nb = np.array([\n [8],\n [1],\n [-5],\n [6],\n [4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{2} & -\\frac{11}{2} & \\frac{1}{2} \\\\\n -1 & 5 & -7 \\\\\n \\frac{11}{2} & 2 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{11 x^2}{2}+\\frac{23 x}{4}+56$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), -(11/2), (1/2)],\n [-1, 5, -7],\n [(11/2), 2, 4]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -3 & -5 \\\\\n -4 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1,2\\}, \\{5,2\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -5],\n [-4, 5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n 1 & 1 & -1 & 0 \\\\\n 13 & 9 & -7 & 4 \\\\\n 15 & 11 & -9 & 4 \\\\\n -5 & -3 & 3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 2-\\frac{1}{e} & 1-\\frac{1}{e} & \\frac{1}{e}-1 & 0 \\\\\n -2-\\frac{3}{e^2}+\\frac{1}{e}+4 e^2 & -1-\\frac{2}{e^2}+\\frac{1}{e}+3 e^2 & 1+\\frac{2}{e^2}-\\frac{1}{e}-2 e^2 & e^2-\\frac{1}{e^2} \\\\\n -\\frac{3}{e^2}-\\frac{1}{e}+4 e^2 & -\\frac{2}{e^2}-\\frac{1}{e}+3 e^2 & \\frac{2}{e^2}+\\frac{1}{e}-2 e^2 & e^2-\\frac{1}{e^2} \\\\\n -2+\\frac{3}{e^2}-\\frac{1}{e} & -1+\\frac{2}{e^2}-\\frac{1}{e} & 1-\\frac{2}{e^2}+\\frac{1}{e} & \\frac{1}{e^2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [1, 1, -1, 0],\n [13, 9, -7, 4],\n [15, 11, -9, 4],\n [-5, -3, 3, -2]])\nprint(expm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -3 & -9 & -1 & 9 \\\\\n 2 & -1 & 7 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -9, -1, 9],\n [2, -1, 7, -5]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & -3 & -6 \\\\\n 7 & -4 & -7 \\\\\n 5 & 10 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.682,-1.265,1.\\}, \\{-0.329-0.463 i,-0.224-0.77 i,1.\\}, \\{-0.329+0.463 i,-0.224+0.77 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3, -6],\n [7, -4, -7],\n [5, 10, 7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{14}{\\sqrt{\\pi }} \\\\\n -\\frac{3}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{15}{\\sqrt{\\pi }} \\\\\n -\\frac{16}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{162}{\\pi }$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(14/(math.sqrt(math.pi)))],\n [-(3/(math.sqrt(math.pi)))]])\nb = np.array([\n [(15/(math.sqrt(math.pi)))],\n [-(16/(math.sqrt(math.pi)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{2}+\\frac{5 i}{2} & 1+i & -3-i \\\\\n 1-\\frac{3 i}{2} & -1+\\frac{i}{2} & 3 i \\\\\n 1-\\frac{9 i}{2} & -3+\\frac{5 i}{2} & \\frac{7}{2}+\\frac{3 i}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{311}{4}-\\frac{87 i}{4} & 28+21 i & \\frac{83}{2}-\\frac{101 i}{2} \\\\\n -\\frac{79}{8}+\\frac{365 i}{4} & \\frac{87}{4}-\\frac{209 i}{8} & -63-\\frac{125 i}{4} \\\\\n \\frac{83}{2}+\\frac{795 i}{8} & \\frac{103}{8}-\\frac{71 i}{2} & -\\frac{193}{2}+\\frac{25 i}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2)+((5j)/2), 1+ 1j, -3- 1j],\n [1-((3j)/2), -1+(1j/2), 3j],\n [1-((9j)/2), -3+((5j)/2), (7/2)+((3j)/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -6 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$84$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [-3],\n [2]])\nb = np.array([\n [-8],\n [-6],\n [-7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{5} & -\\frac{12}{5} & \\frac{27}{5} \\\\\n \\frac{46}{5} & \\frac{18}{5} & -\\frac{17}{5} \\\\\n -\\frac{7}{5} & -\\frac{31}{5} & \\frac{22}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{39 x^2}{5}-\\frac{114 x}{5}-\\frac{24253}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/5), -(12/5), (27/5)],\n [(46/5), (18/5), -(17/5)],\n [-(7/5), -(31/5), (22/5)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{61}{10} \\\\\n \\frac{7}{10} \\\\\n -\\frac{23}{10} \\\\\n -\\frac{24}{5} \\\\\n \\frac{67}{10} \\\\\n -\\frac{34}{5} \\\\\n -\\frac{31}{10} \\\\\n \\frac{47}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{\\frac{9443}{2}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(61/10)],\n [(7/10)],\n [-(23/10)],\n [-(24/5)],\n [(67/10)],\n [-(34/5)],\n [-(31/10)],\n [(47/10)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{16} \\\\\n \\frac{65}{16} \\\\\n -\\frac{71}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{33}{8} \\\\\n -\\frac{149}{16} \\\\\n -\\frac{59}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{7207}{64} \\\\\n -\\frac{4509}{128} \\\\\n -\\frac{4737}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/16)],\n [(65/16)],\n [-(71/8)]])\nb = np.array([\n [(33/8)],\n [-(149/16)],\n [-(59/8)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -3 & -3 & 2 & 3 & 1 \\\\\n 2 & -2 & -3 & -3 & -2 \\\\\n 0 & 0 & 0 & -1 & 0 \\\\\n 0 & 1 & 2 & -3 & -2 \\\\\n 0 & 1 & 1 & -3 & 2 \\\\\n -3 & -2 & 3 & 3 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.08 \\\\\n -1.29 \\\\\n -2.76 \\\\\n -2.43 \\\\\n 0.41 \\\\\n 0.92 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 11.603 \\\\\n -4.274 \\\\\n 6.894 \\\\\n 2.387 \\\\\n 2.537 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3, 2, 3, 1],\n [2, -2, -3, -3, -2],\n [0, 0, 0, -1, 0],\n [0, 1, 2, -3, -2],\n [0, 1, 1, -3, 2],\n [-3, -2, 3, 3, 0]])\nb = np.array([\n [2.08],\n [-1.29],\n [-2.76],\n [-2.43],\n [0.41],\n [0.92]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -4 & 0 & -2 \\\\\n -2 & 4 & -4 \\\\\n -1 & 3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-60$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 0, -2],\n [-2, 4, -4],\n [-1, 3, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{11}{8} \\\\\n \\frac{7}{4} \\\\\n \\frac{3}{2} \\\\\n 2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{11}{\\sqrt{717}} \\\\\n \\frac{14}{\\sqrt{717}} \\\\\n 4 \\sqrt{\\frac{3}{239}} \\\\\n \\frac{16}{\\sqrt{717}} \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-(11/8)],\n [(7/4)],\n [(3/2)],\n [2],\n [0]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -5 & 2 & 1 \\\\\n 0 & 4 & -3 \\\\\n 2 & -2 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-50$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 2, 1],\n [0, 4, -3],\n [2, -2, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n \\frac{52}{9} & -\\frac{22}{3} & \\frac{79}{9} \\\\\n -\\frac{89}{9} & \\frac{4}{3} & \\frac{26}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(52/9), -(22/3), (79/9)],\n [-(89/9), (4/3), (26/9)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & -2 \\\\\n -5 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{10} \\left(1-\\sqrt{41}\\right),1\\right\\}, \\left\\{\\frac{1}{10} \\left(1+\\sqrt{41}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -2],\n [-5, -6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 7 & 6 & 4 & 7 \\\\\n -1 & 3 & 2 & 2 \\\\\n -2 & -7 & 9 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-41.,-59.,-55.,123.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, 6, 4, 7],\n [-1, 3, 2, 2],\n [-2, -7, 9, 0]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{23}{8} & -\\frac{17}{8} & -\\frac{11}{4} & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{115}{16} & -\\frac{85}{16} & -\\frac{55}{8} & \\frac{5}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2)]])\nb = np.array([\n [(23/8), -(17/8), -(11/4), (1/4)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n 1 & -\\frac{1}{8} & \\frac{31}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(1/8), (31/4)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{11}{2} \\\\\n 5 \\\\\n -\\frac{11}{2} \\\\\n -\\frac{3}{2} \\\\\n 4 \\\\\n -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 9 \\\\\n \\frac{15}{2} \\\\\n -7 \\\\\n -\\frac{7}{2} \\\\\n -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{101}{\\sqrt{137678}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/2)],\n [5],\n [-(11/2)],\n [-(3/2)],\n [4],\n [-(13/2)]]).squeeze()\nb = np.array([\n [5],\n [9],\n [(15/2)],\n [-7],\n [-(7/2)],\n [-(7/2)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & 1 & 1 \\\\\n 0 & -3 & -3 \\\\\n 2 & 2 & 0 \\\\\n 1 & 1 & -1 \\\\\n -1 & 0 & 0 \\\\\n 0 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.63 \\\\\n 1.01 \\\\\n 1.17 \\\\\n -2.14 \\\\\n 1.47 \\\\\n 0.84 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.156 \\\\\n -0.391 \\\\\n 0.235 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1, 1],\n [0, -3, -3],\n [2, 2, 0],\n [1, 1, -1],\n [-1, 0, 0],\n [0, -1, 2]])\nb = np.array([\n [-0.63],\n [1.01],\n [1.17],\n [-2.14],\n [1.47],\n [0.84]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{47}{5} \\\\\n -\\frac{49}{5} \\\\\n -\\frac{23}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{119}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(47/5)],\n [-(49/5)],\n [-(23/5)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{2} & \\frac{9}{2} \\\\\n 0 & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{35}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), (9/2)],\n [0, -(5/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 0 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -6 \\\\\n -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -30 \\\\\n 47 \\\\\n -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [0],\n [-5]])\nb = np.array([\n [-9],\n [-6],\n [-1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{2} & 8 & -2 \\\\\n \\frac{9}{2} & 9 & 6 \\\\\n \\frac{13}{2} & -\\frac{17}{2} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.969,-1.494,1.\\}, \\{-0.81-0.044 i,-0.214+0.028 i,1.\\}, \\{-0.81+0.044 i,-0.214-0.028 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/2), 8, -2],\n [(9/2), 9, 6],\n [(13/2), -(17/2), (3/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & 6 \\\\\n 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{3-\\sqrt{22},3+\\sqrt{22}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 6],\n [1, -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & -6 & -4 \\\\\n -8 & -2 & 2 \\\\\n -9 & 0 & 8 \\\\\n 9 & 3 & 1 \\\\\n 5 & 7 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, -6, -4],\n [-8, -2, 2],\n [-9, 0, 8],\n [9, 3, 1],\n [5, 7, -6]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$20$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(4/(math.sqrt(3)))]])\nb = np.array([\n [-5*math.sqrt(3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -2 & -1 & -7 \\\\\n -3 & 6 & -2 \\\\\n -9 & -6 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.615,0.195,1.\\}, \\{-0.843-0.033 i,-0.794+0.081 i,1.\\}, \\{-0.843+0.033 i,-0.794-0.081 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1, -7],\n [-3, 6, -2],\n [-9, -6, -7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -10 & -5 & 2 & 0 \\\\\n 2 & 2 & 7 & 10 \\\\\n -7 & 0 & 6 & 0 \\\\\n 0 & 10 & -2 & 4 \\\\\n 8 & 6 & -1 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, -5, 2, 0],\n [2, 2, 7, 10],\n [-7, 0, 6, 0],\n [0, 10, -2, 4],\n [8, 6, -1, -9]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -3 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 9 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -24 \\\\\n 7 \\\\\n -15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-3],\n [5]])\nb = np.array([\n [7],\n [9],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{26}{3} & -4 \\\\\n \\frac{4}{3} & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{44 x}{3}+\\frac{172}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/3), -4],\n [(4/3), 6]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{10}{\\sqrt{\\pi }} \\\\\n -\\frac{3}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{7}{\\sqrt{\\pi }} \\\\\n -\\frac{12}{\\sqrt{\\pi }} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{34}{\\pi }$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(10/(math.sqrt(math.pi)))],\n [-(3/(math.sqrt(math.pi)))]])\nb = np.array([\n [(7/(math.sqrt(math.pi)))],\n [-(12/(math.sqrt(math.pi)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & -\\frac{1}{10} & \\frac{8}{5} \\\\\n -\\frac{6}{5} & 0 & -\\frac{23}{10} \\\\\n -\\frac{9}{10} & \\frac{12}{5} & 0 \\\\\n \\frac{11}{5} & \\frac{9}{10} & \\frac{7}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{10} & \\frac{2}{5} & -\\frac{7}{10} \\\\\n \\frac{21}{10} & \\frac{19}{10} & -\\frac{7}{5} \\\\\n -\\frac{17}{10} & -\\frac{11}{10} & \\frac{11}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{57}{25} & -\\frac{7}{4} & \\frac{331}{100} \\\\\n \\frac{47}{20} & \\frac{41}{20} & -\\frac{211}{50} \\\\\n \\frac{387}{100} & \\frac{21}{5} & -\\frac{273}{100} \\\\\n \\frac{89}{25} & \\frac{91}{50} & -\\frac{63}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), -(1/10), (8/5)],\n [-(6/5), 0, -(23/10)],\n [-(9/10), (12/5), 0],\n [(11/5), (9/10), (7/10)]])\nb = np.array([\n [(13/10), (2/5), -(7/10)],\n [(21/10), (19/10), -(7/5)],\n [-(17/10), -(11/10), (11/5)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -9 \\\\\n -9 \\\\\n -4 \\\\\n 3 \\\\\n 6 \\\\\n 2 \\\\\n -6 \\\\\n -5 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -9 \\\\\n -5 \\\\\n -5 \\\\\n -9 \\\\\n 1 \\\\\n -2 \\\\\n -4 \\\\\n -7 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{11}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-9],\n [-9],\n [-4],\n [3],\n [6],\n [2],\n [-6],\n [-5],\n [6]])\nb = np.array([\n [-5],\n [-9],\n [-5],\n [-5],\n [-9],\n [1],\n [-2],\n [-4],\n [-7],\n [-1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{5} & -\\frac{16}{5} & -\\frac{42}{5} \\\\\n 9 & \\frac{44}{5} & -\\frac{63}{10} \\\\\n -\\frac{31}{5} & -\\frac{14}{5} & \\frac{21}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{27 x^2}{2}-\\frac{59 x}{10}-\\frac{38619}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/5), -(16/5), -(42/5)],\n [9, (44/5), -(63/10)],\n [-(31/5), -(14/5), (21/10)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{2}{3} & -\\frac{11}{6} & -\\frac{11}{6} \\\\\n -\\frac{2}{3} & \\frac{17}{6} & \\frac{1}{3} \\\\\n -\\frac{4}{3} & \\frac{1}{2} & \\frac{25}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{991}{54}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3), -(11/6), -(11/6)],\n [-(2/3), (17/6), (1/3)],\n [-(4/3), (1/2), (25/6)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{113}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [9]])\nb = np.array([\n [-8],\n [-5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -10 \\\\\n -10 \\\\\n -10 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -3 \\\\\n -8 \\\\\n -9 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(13 \\sqrt{\\frac{5}{1159}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-10],\n [-10],\n [-10],\n [4]]).squeeze()\nb = np.array([\n [-3],\n [-3],\n [-8],\n [-9],\n [9]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -5 & 2 \\\\\n 0 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-5,5\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 2],\n [0, 5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{4}{5}, \\frac{9}{5}}$ to the line $-\\frac{24 x}{5}-\\frac{37 y}{10}-1=0$.", - "Output Answer": [ - "$\\frac{115}{\\sqrt{3673}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (4/5), (9/5)\nline = Poly(-((24*x)/5)-((37*y)/10)-1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 8 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -9 \\\\\n -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-27$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [8],\n [-1]])\nb = np.array([\n [5],\n [-9],\n [-10]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1}{\\sqrt{3}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [-1],\n [1],\n [0],\n [0]]).squeeze()\nb = np.array([\n [0],\n [1],\n [0],\n [-1],\n [-1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{2 \\pi }{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [1]]).squeeze()\nb = np.array([\n [0],\n [-1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & \\frac{14}{3} \\\\\n \\frac{5}{3} & -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{166}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, (14/3)],\n [(5/3), -(8/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 8 \\\\\n -8 \\\\\n -9 \\\\\n 8 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 5 \\\\\n 8 \\\\\n -7 \\\\\n -3 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{118}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [8],\n [-8],\n [-9],\n [8],\n [3]])\nb = np.array([\n [-1],\n [5],\n [8],\n [-7],\n [-3],\n [-6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2}-\\frac{5 i}{2} & -\\frac{5}{2}-5 i & 3-\\frac{3 i}{2} \\\\\n -3-5 i & -3+\\frac{3 i}{2} & \\frac{3}{2}-2 i \\\\\n -2+i & \\frac{9}{2}-\\frac{5 i}{2} & -\\frac{3}{2}-\\frac{5 i}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{395}{4}+36 i & \\frac{167}{4}+\\frac{523 i}{8} & -\\frac{185}{8}+\\frac{795 i}{4} \\\\\n \\frac{325}{2}+\\frac{61 i}{4} & -\\frac{3}{2}-\\frac{329 i}{8} & \\frac{515}{8}+155 i \\\\\n \\frac{391}{4}+\\frac{229 i}{4} & \\frac{47}{8}+\\frac{547 i}{8} & -\\frac{357}{8}+\\frac{585 i}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2)-((5j)/2), -(5/2)-5j, 3-((3j)/2)],\n [-3-5j, -3+((3j)/2), (3/2)-2j],\n [-2+ 1j, (9/2)-((5j)/2), -(3/2)-((5j)/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\sqrt{5},\\frac{6}{\\sqrt{5}},\\sqrt{5}\\right\\}, \\left\\{0,\\frac{4}{\\sqrt{5}},\\frac{4}{\\sqrt{5}}\\right\\}, \\left\\{\\frac{6}{\\sqrt{5}},\\sqrt{5},-\\sqrt{5}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{5}{\\sqrt{86}},3 \\sqrt{\\frac{2}{43}},\\frac{5}{\\sqrt{86}}\\right\\}, \\left\\{\\frac{22}{43} \\sqrt{\\frac{5}{\\frac{2740}{1849}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)^2}},\\frac{8}{43} \\sqrt{\\frac{5}{\\frac{2740}{1849}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)^2}},\\frac{\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}}{\\sqrt{\\frac{2740}{1849}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)^2}}\\right\\}, \\left\\{\\frac{\\frac{6}{\\sqrt{5}}-\\frac{25 \\sqrt{5}}{86}-\\frac{22 \\sqrt{5} \\left(4-\\sqrt{5} \\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)\\right)}{43 \\left(\\frac{2740}{1849}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)^2\\right)}}{\\sqrt{\\left(\\frac{6}{\\sqrt{5}}-\\frac{25 \\sqrt{5}}{86}-\\frac{22 \\sqrt{5} \\left(4-\\sqrt{5} \\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)\\right)}{43 \\left(\\frac{2740}{1849}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)^2\\right)}\\right)^2+\\left(\\frac{58 \\sqrt{5}}{43}-\\frac{8 \\sqrt{5} \\left(4-\\sqrt{5} \\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)\\right)}{43 \\left(\\frac{2740}{1849}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)^2\\right)}\\right)^2+\\left(\\frac{61 \\sqrt{5}}{86}-\\frac{\\left(-\\frac{4}{\\sqrt{5}}+\\frac{22 \\sqrt{5}}{43}\\right) \\left(4-\\sqrt{5} \\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)\\right)}{\\frac{2740}{1849}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)^2}\\right)^2}},\\frac{\\frac{58 \\sqrt{5}}{43}-\\frac{8 \\sqrt{5} \\left(4-\\sqrt{5} \\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)\\right)}{43 \\left(\\frac{2740}{1849}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)^2\\right)}}{\\sqrt{\\left(\\frac{6}{\\sqrt{5}}-\\frac{25 \\sqrt{5}}{86}-\\frac{22 \\sqrt{5} \\left(4-\\sqrt{5} \\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)\\right)}{43 \\left(\\frac{2740}{1849}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)^2\\right)}\\right)^2+\\left(\\frac{58 \\sqrt{5}}{43}-\\frac{8 \\sqrt{5} \\left(4-\\sqrt{5} \\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)\\right)}{43 \\left(\\frac{2740}{1849}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)^2\\right)}\\right)^2+\\left(\\frac{61 \\sqrt{5}}{86}-\\frac{\\left(-\\frac{4}{\\sqrt{5}}+\\frac{22 \\sqrt{5}}{43}\\right) \\left(4-\\sqrt{5} \\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)\\right)}{\\frac{2740}{1849}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)^2}\\right)^2}},\\frac{-\\frac{61 \\sqrt{5}}{86}-\\frac{\\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right) \\left(4-\\sqrt{5} \\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)\\right)}{\\frac{2740}{1849}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)^2}}{\\sqrt{\\left(\\frac{6}{\\sqrt{5}}-\\frac{25 \\sqrt{5}}{86}-\\frac{22 \\sqrt{5} \\left(4-\\sqrt{5} \\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)\\right)}{43 \\left(\\frac{2740}{1849}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)^2\\right)}\\right)^2+\\left(\\frac{58 \\sqrt{5}}{43}-\\frac{8 \\sqrt{5} \\left(4-\\sqrt{5} \\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)\\right)}{43 \\left(\\frac{2740}{1849}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)^2\\right)}\\right)^2+\\left(\\frac{61 \\sqrt{5}}{86}-\\frac{\\left(-\\frac{4}{\\sqrt{5}}+\\frac{22 \\sqrt{5}}{43}\\right) \\left(4-\\sqrt{5} \\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)\\right)}{\\frac{2740}{1849}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{22 \\sqrt{5}}{43}\\right)^2}\\right)^2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-math.sqrt(5), (6/(math.sqrt(5))), math.sqrt(5)), (0, (4/(math.sqrt(5))), (4/(math.sqrt(5)))), ((6/(math.sqrt(5))), math.sqrt(5), -math.sqrt(5))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{43}{5} \\\\\n -\\frac{51}{10} \\\\\n \\frac{7}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{97}{10} \\\\\n -\\frac{2}{5} \\\\\n \\frac{37}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1859}{50} \\\\\n \\frac{2503}{50} \\\\\n -\\frac{4603}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(43/5)],\n [-(51/10)],\n [(7/5)]])\nb = np.array([\n [-(97/10)],\n [-(2/5)],\n [(37/5)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{2}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 5 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{9}{2} \\\\\n -\\frac{5}{2} \\\\\n 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [5],\n [-6]])\nprint(a * -(1/2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\sqrt{\\frac{2}{5}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [1],\n [0],\n [0],\n [0]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [-1],\n [-1],\n [1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & -1 \\\\\n 3 & -3 \\\\\n 2 & 3 \\\\\n -2 & 0 \\\\\n 1 & -3 \\\\\n 0 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.45 \\\\\n 1.82 \\\\\n 0.77 \\\\\n 1.15 \\\\\n -1.97 \\\\\n -2.24 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.18 \\\\\n -0.028 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1],\n [3, -3],\n [2, 3],\n [-2, 0],\n [1, -3],\n [0, 2]])\nb = np.array([\n [-2.45],\n [1.82],\n [0.77],\n [1.15],\n [-1.97],\n [-2.24]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{5} & -\\frac{2}{5} & \\frac{3}{5} \\\\\n \\frac{1}{5} & \\frac{4}{5} & \\frac{1}{5} \\\\\n -\\frac{21}{5} & -2 & -\\frac{19}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{424}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/5), -(2/5), (3/5)],\n [(1/5), (4/5), (1/5)],\n [-(21/5), -2, -(19/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{58}{9} \\\\\n \\frac{38}{9} \\\\\n -\\frac{10}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -\\frac{19}{3} \\\\\n -\\frac{1}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{608}{81} \\\\\n -\\frac{482}{81} \\\\\n -\\frac{1786}{27} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(58/9)],\n [(38/9)],\n [-(10/9)]])\nb = np.array([\n [6],\n [-(19/3)],\n [-(1/9)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{16}{3} & -2 \\\\\n \\frac{8}{3} & \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{2}{3} \\left(-3-\\sqrt{13}\\right),\\frac{2}{3} \\left(\\sqrt{13}-3\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(16/3), -2],\n [(8/3), (4/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & -1 \\\\\n -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1],\n [-1, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -9 & -5 & 2 \\\\\n -1 & 8 & -6 \\\\\n -4 & 4 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{3.88,0.574,1.\\}, \\{-0.106-0.292 i,0.422\\, +0.992 i,1.\\}, \\{-0.106+0.292 i,0.422\\, -0.992 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -5, 2],\n [-1, 8, -6],\n [-4, 4, 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -8 \\\\\n -\\frac{10}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{1117}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-8],\n [-(10/3)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 5 & 6 & 1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -5 & -4 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 10 & 10 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 6, 1]])\nb = np.array([\n [-5, -4, -2]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0.4 \\\\\n 3.1 \\\\\n 5.6 \\\\\n -9.2 \\\\\n 9.4 \\\\\n 9.1 \\\\\n -7.5 \\\\\n 5.9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3.2 \\\\\n -2.7 \\\\\n -1.4 \\\\\n 10. \\\\\n -8.2 \\\\\n 3.7 \\\\\n -9. \\\\\n -9.7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$32.3056$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0.4],\n [3.1],\n [5.6],\n [-9.2],\n [9.4],\n [9.1],\n [-7.5],\n [5.9]])\nb = np.array([\n [3.2],\n [-2.7],\n [-1.4],\n [10.],\n [-8.2],\n [3.7],\n [-9.],\n [-9.7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & 6 \\\\\n -6 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{3}{2} \\left(-3-i \\sqrt{7}\\right),\\frac{3}{2} \\left(-3+i \\sqrt{7}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 6],\n [-6, -9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{7}{4} \\\\\n -\\frac{11}{4} \\\\\n 1 \\\\\n -\\frac{9}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{7}{\\sqrt{267}} \\\\\n -\\frac{11}{\\sqrt{267}} \\\\\n \\frac{4}{\\sqrt{267}} \\\\\n -3 \\sqrt{\\frac{3}{89}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-(7/4)],\n [-(11/4)],\n [1],\n [-(9/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 6 & 3 & -4 & -9 & -2 \\\\\n -9 & 5 & -7 & 3 & -3 \\\\\n 9 & 4 & 5 & -6 & 10 \\\\\n 4 & -6 & -4 & 8 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-3055.,-4764.,-2601.,-3346.,3948.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [6, 3, -4, -9, -2],\n [-9, 5, -7, 3, -3],\n [9, 4, 5, -6, 10],\n [4, -6, -4, 8, 0]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 9 & -8 & 4 & -5 & -2 \\\\\n -6 & 4 & 8 & -9 & 10 \\\\\n 7 & 0 & 0 & 7 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 1 & 0 \\\\\n 0 & 1 & 0 & \\frac{5}{4} & \\frac{7}{10} \\\\\n 0 & 0 & 1 & -1 & \\frac{9}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, -8, 4, -5, -2],\n [-6, 4, 8, -9, 10],\n [7, 0, 0, 7, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$28$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-3]])\nb = np.array([\n [5],\n [-1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,-3,2\\}, \\{4,-3,-5\\}, \\{0,3,2\\}}$.", - "Output Answer": [ - "$14 x+7 y+2 z-25=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, -3, 2],\n [4, -3, -5],\n [0, 3, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{13}{3} & -\\frac{68}{9} & \\frac{25}{9} & -\\frac{43}{9} \\\\\n \\frac{19}{3} & -\\frac{68}{9} & \\frac{76}{9} & \\frac{25}{9} \\\\\n \\frac{20}{9} & -\\frac{7}{3} & \\frac{29}{3} & -\\frac{83}{9} \\\\\n \\frac{77}{9} & \\frac{55}{9} & -\\frac{10}{9} & \\frac{4}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{76}{9} & \\frac{56}{9} & \\frac{19}{3} & \\frac{82}{9} \\\\\n -\\frac{74}{9} & -\\frac{14}{9} & \\frac{19}{9} & \\frac{55}{9} \\\\\n \\frac{23}{9} & \\frac{82}{9} & \\frac{52}{9} & \\frac{7}{3} \\\\\n 3 & -\\frac{74}{9} & \\frac{16}{3} & \\frac{28}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{37}{9} & -\\frac{4}{3} & \\frac{82}{9} & \\frac{13}{3} \\\\\n -\\frac{17}{9} & -\\frac{82}{9} & \\frac{95}{9} & \\frac{80}{9} \\\\\n \\frac{43}{9} & \\frac{61}{9} & \\frac{139}{9} & -\\frac{62}{9} \\\\\n \\frac{104}{9} & -\\frac{19}{9} & \\frac{38}{9} & \\frac{32}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/3), -(68/9), (25/9), -(43/9)],\n [(19/3), -(68/9), (76/9), (25/9)],\n [(20/9), -(7/3), (29/3), -(83/9)],\n [(77/9), (55/9), -(10/9), (4/3)]])\nb = np.array([\n [(76/9), (56/9), (19/3), (82/9)],\n [-(74/9), -(14/9), (19/9), (55/9)],\n [(23/9), (82/9), (52/9), (7/3)],\n [3, -(74/9), (16/3), (28/3)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,-2,0\\}, \\{2,-2,1\\}, \\{0,-2,-2\\}}$", - "Output Answer": [ - "${\\{0,-1,0\\}, \\left\\{\\frac{2}{\\sqrt{5}},0,\\frac{1}{\\sqrt{5}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{5}},0,-\\frac{2}{\\sqrt{5}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, -2, 0), (2, -2, 1), (0, -2, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{5} & \\frac{3}{5} \\\\\n \\frac{13}{10} & -\\frac{4}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{63}{50}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/5), (3/5)],\n [(13/10), -(4/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{37}{6} & -\\frac{43}{6} & \\frac{16}{3} & \\frac{17}{6} \\\\\n -\\frac{53}{6} & -\\frac{53}{6} & \\frac{17}{6} & 4 \\\\\n -\\frac{59}{6} & \\frac{28}{3} & -\\frac{4}{3} & -\\frac{28}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{43}{6} & -6 & -\\frac{17}{6} & \\frac{11}{3} \\\\\n -\\frac{5}{6} & \\frac{3}{2} & \\frac{49}{6} & -\\frac{22}{3} \\\\\n -\\frac{29}{3} & -\\frac{5}{6} & \\frac{37}{6} & \\frac{7}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{40}{3} & -\\frac{79}{6} & \\frac{5}{2} & \\frac{13}{2} \\\\\n -\\frac{29}{3} & -\\frac{22}{3} & 11 & -\\frac{10}{3} \\\\\n -\\frac{39}{2} & \\frac{17}{2} & \\frac{29}{6} & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(37/6), -(43/6), (16/3), (17/6)],\n [-(53/6), -(53/6), (17/6), 4],\n [-(59/6), (28/3), -(4/3), -(28/3)]])\nb = np.array([\n [-(43/6), -6, -(17/6), (11/3)],\n [-(5/6), (3/2), (49/6), -(22/3)],\n [-(29/3), -(5/6), (37/6), (7/3)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 10 & 8 & 4 \\\\\n 3 & 8 & -6 \\\\\n -2 & 7 & 2 \\\\\n -6 & -10 & 7 \\\\\n 7 & -1 & -7 \\\\\n 0 & -9 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, 8, 4],\n [3, 8, -6],\n [-2, 7, 2],\n [-6, -10, 7],\n [7, -1, -7],\n [0, -9, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 8 \\\\\n -6 \\\\\n -9 \\\\\n 8 \\\\\n -6 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 9 \\\\\n 3 \\\\\n 7 \\\\\n -8 \\\\\n -2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-95$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [8],\n [-6],\n [-9],\n [8],\n [-6],\n [-1]])\nb = np.array([\n [-7],\n [9],\n [3],\n [7],\n [-8],\n [-2],\n [-1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -2 & -3 & 0 & 0 \\\\\n 1 & -1 & 1 & 3 \\\\\n 2 & -1 & -2 & 0 \\\\\n 0 & -3 & 0 & -2 \\\\\n -1 & 3 & -3 & -3 \\\\\n -1 & 3 & -2 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.48 \\\\\n 1.05 \\\\\n -0.31 \\\\\n -1.36 \\\\\n 2.23 \\\\\n -2.34 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.69 \\\\\n -0.244 \\\\\n -0.518 \\\\\n 0.495 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, 0, 0],\n [1, -1, 1, 3],\n [2, -1, -2, 0],\n [0, -3, 0, -2],\n [-1, 3, -3, -3],\n [-1, 3, -2, -1]])\nb = np.array([\n [2.48],\n [1.05],\n [-0.31],\n [-1.36],\n [2.23],\n [-2.34]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -4 & 4 \\\\\n 1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{3}{8} & -\\frac{1}{2} \\\\\n -\\frac{1}{8} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 4],\n [1, -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 5 & 2 & -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 2 & -10 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 7 & -8 & -10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 2, -9]])\nb = np.array([\n [2, -10, -1]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & 7 \\\\\n 6 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+13 x-6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 7],\n [6, -9]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-4, 4}$ to the line $2 x+5 y-3=0$.", - "Output Answer": [ - "$\\frac{9}{\\sqrt{29}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -4, 4\nline = Poly(2*x+5*y-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 9 \\\\\n -3 \\\\\n 6 \\\\\n -4 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$38$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [9],\n [-3],\n [6],\n [-4],\n [-9]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{41}{5} \\\\\n \\frac{19}{5} \\\\\n 0 \\\\\n \\frac{12}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{41}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(41/5)],\n [(19/5)],\n [0],\n [(12/5)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 8 & 2 & 8 & -9 \\\\\n 4 & 7 & 9 & 3 \\\\\n -4 & -7 & 2 & 2 \\\\\n 4 & 8 & 4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [8, 2, 8, -9],\n [4, 7, 9, 3],\n [-4, -7, 2, 2],\n [4, 8, 4, 0]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{3} & \\frac{5}{3} & -\\frac{7}{3} \\\\\n 0 & 4 & -3 \\\\\n -\\frac{8}{3} & \\frac{11}{3} & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{41}{103} & \\frac{29}{103} & -\\frac{13}{103} \\\\\n -\\frac{24}{103} & \\frac{22}{103} & \\frac{15}{103} \\\\\n -\\frac{32}{103} & -\\frac{5}{103} & \\frac{20}{103} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/3), (5/3), -(7/3)],\n [0, 4, -3],\n [-(8/3), (11/3), (2/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -5 & -1 & -8 & -4 & 2 \\\\\n -9 & 7 & 6 & -1 & -9 \\\\\n -8 & -2 & 1 & 3 & -8 \\\\\n -7 & 1 & 3 & 4 & -6 \\\\\n -3 & -1 & 0 & 1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -1, -8, -4, 2],\n [-9, 7, 6, -1, -9],\n [-8, -2, 1, 3, -8],\n [-7, 1, 3, 4, -6],\n [-3, -1, 0, 1, 4]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -5 & \\frac{7}{2} & -8 \\\\\n 8 & \\frac{15}{2} & -\\frac{15}{2} \\\\\n \\frac{11}{2} & -\\frac{19}{2} & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.832,-2.209,1.\\}, \\{0.135\\, -0.858 i,0.547\\, +0.218 i,1.\\}, \\{0.135\\, +0.858 i,0.547\\, -0.218 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, (7/2), -8],\n [8, (15/2), -(15/2)],\n [(11/2), -(19/2), -(5/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{13}{3}, \\frac{8}{3}, 4}$ to the plane $x+2 y+\\frac{4 z}{3}-\\frac{1}{3}=0$.", - "Output Answer": [ - "$\\frac{18}{\\sqrt{61}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(13/3), (8/3), 4\nplane = Poly(x+2*y+((4*z)/3)-(1/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{3} & \\frac{77}{9} \\\\\n -\\frac{26}{3} & \\frac{47}{9} \\\\\n \\frac{46}{9} & -\\frac{55}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3), (77/9)],\n [-(26/3), (47/9)],\n [(46/9), -(55/9)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -5 & 10 \\\\\n 4 & 0 \\\\\n -8 & -8 \\\\\n 2 & -2 \\\\\n 8 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, 10],\n [4, 0],\n [-8, -8],\n [2, -2],\n [8, 7]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,1,1\\}, \\{-1,2,-1\\}, \\{-2,1,-2\\}}$", - "Output Answer": [ - "${\\left\\{\\sqrt{\\frac{2}{3}},\\frac{1}{\\sqrt{6}},\\frac{1}{\\sqrt{6}}\\right\\}, \\left\\{-2 \\sqrt{\\frac{2}{105}},\\frac{13}{\\sqrt{210}},-\\sqrt{\\frac{5}{42}}\\right\\}, \\left\\{\\frac{3}{\\sqrt{35}},-\\frac{1}{\\sqrt{35}},-\\sqrt{\\frac{5}{7}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, 1, 1), (-1, 2, -1), (-2, 1, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -3 & 9 \\\\\n -10 & -6 \\\\\n -5 & -1 \\\\\n -10 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 9],\n [-10, -6],\n [-5, -1],\n [-10, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -2 & -2 \\\\\n -4 & -2 \\\\\n -5 & -9 \\\\\n 6 & -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 4 & -9 \\\\\n -6 & -5 \\\\\n -5 & -9 \\\\\n -4 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 2 & -11 \\\\\n -10 & -7 \\\\\n -10 & -18 \\\\\n 2 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2],\n [-4, -2],\n [-5, -9],\n [6, -10]])\nb = np.array([\n [4, -9],\n [-6, -5],\n [-5, -9],\n [-4, 6]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{683}{100} \\\\\n -\\frac{6}{25} \\\\\n -\\frac{133}{50} \\\\\n \\frac{49}{25} \\\\\n \\frac{177}{25} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1877}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(683/100)],\n [-(6/25)],\n [-(133/50)],\n [(49/25)],\n [(177/25)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & -9 \\\\\n -9 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(19-5 \\sqrt{13}\\right),\\frac{1}{2} \\left(19+5 \\sqrt{13}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -9],\n [-9, 10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{5}{3}, -4}$ to the line $-\\frac{5 x}{3}+y+\\frac{7}{3}=0$.", - "Output Answer": [ - "$\\frac{5 \\sqrt{\\frac{2}{17}}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(5/3), -4\nline = Poly(-((5*x)/3)+y+(7/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 1 & -3 & 10 & 0 & -9 & 7 & 6 \\\\\n -6 & 9 & -7 & -2 & -4 & 5 & -3 \\\\\n 8 & -3 & -1 & 5 & -7 & 1 & -8 \\\\\n -5 & -7 & -9 & -1 & -4 & 7 & 1 \\\\\n 3 & -8 & -10 & 9 & -6 & 0 & -8 \\\\\n 2 & -2 & -2 & 9 & 10 & 6 & -3 \\\\\n -5 & -9 & 1 & 3 & 6 & -6 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, -3, 10, 0, -9, 7, 6],\n [-6, 9, -7, -2, -4, 5, -3],\n [8, -3, -1, 5, -7, 1, -8],\n [-5, -7, -9, -1, -4, 7, 1],\n [3, -8, -10, 9, -6, 0, -8],\n [2, -2, -2, 9, 10, 6, -3],\n [-5, -9, 1, 3, 6, -6, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{9}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 3 & -3 & -7 & 1 \\\\\n -2 & -9 & -3 & -7 \\\\\n 3 & -1 & 9 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{5}{3} & \\frac{5}{3} & \\frac{35}{9} & -\\frac{5}{9} \\\\\n \\frac{10}{9} & 5 & \\frac{5}{3} & \\frac{35}{9} \\\\\n -\\frac{5}{3} & \\frac{5}{9} & -5 & -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -3, -7, 1],\n [-2, -9, -3, -7],\n [3, -1, 9, 3]])\nprint(a * -(5/9))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{4}{5}, \\frac{23}{5}, -2}$ to the plane $-\\frac{6 x}{5}-\\frac{y}{5}-\\frac{17 z}{5}=0$.", - "Output Answer": [ - "$\\frac{171}{5 \\sqrt{326}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(4/5), (23/5), -2\nplane = Poly(-((6*x)/5)-(y/5)-((17*z)/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -\\frac{397}{100} \\\\\n \\frac{83}{100} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{64}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-(397/100)],\n [(83/100)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 5 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 1 \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 36 \\\\\n -60 \\\\\n -44 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [5],\n [-6]])\nb = np.array([\n [9],\n [1],\n [6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{3}{5}, -\\frac{3}{5}}$ to the line $-\\frac{17 x}{5}+\\frac{24 y}{5}+\\frac{19}{5}=0$.", - "Output Answer": [ - "$\\frac{28}{5 \\sqrt{865}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (3/5), -(3/5)\nline = Poly(-((17*x)/5)+((24*y)/5)+(19/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & -\\frac{49}{5} \\\\\n -\\frac{2}{5} & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-11 x+\\frac{602}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -(49/5)],\n [-(2/5), 7]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 4 \\\\\n 8 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 9 \\\\\n 3 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{133}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [4],\n [8],\n [-10]])\nb = np.array([\n [-3],\n [9],\n [3],\n [9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & -3 \\\\\n \\frac{7}{2} & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{19}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3],\n [(7/2), -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{31}{7}, -\\frac{25}{7}}$ to the line $-\\frac{30 x}{7}-\\frac{2 y}{7}-\\frac{5}{7}=0$.", - "Output Answer": [ - "$\\frac{915}{14 \\sqrt{226}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (31/7), -(25/7)\nline = Poly(-((30*x)/7)-((2*y)/7)-(5/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, -1, -3}$ to the plane $-x-y-2 z-3=0$.", - "Output Answer": [ - "$\\frac{1}{\\sqrt{6}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, -1, -3\nplane = Poly(-x-y-2*z-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{13}{4}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -9 & -2 & -5 \\\\\n 5 & -1 & -2 \\\\\n 10 & 6 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{117}{4} & \\frac{13}{2} & \\frac{65}{4} \\\\\n -\\frac{65}{4} & \\frac{13}{4} & \\frac{13}{2} \\\\\n -\\frac{65}{2} & -\\frac{39}{2} & -\\frac{65}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -2, -5],\n [5, -1, -2],\n [10, 6, 5]])\nprint(a * -(13/4))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & -1 & 1 \\\\\n -2 & 3 & 2 \\\\\n -1 & 2 & 1 \\\\\n 1 & 3 & -1 \\\\\n -2 & -1 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.92 \\\\\n -2.93 \\\\\n 0.44 \\\\\n 2.78 \\\\\n -1.38 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.919 \\\\\n 0.492 \\\\\n -0.641 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1, 1],\n [-2, 3, 2],\n [-1, 2, 1],\n [1, 3, -1],\n [-2, -1, -3]])\nb = np.array([\n [-0.92],\n [-2.93],\n [0.44],\n [2.78],\n [-1.38]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -8 & -9 & 3 & 7 & -6 \\\\\n -3 & -3 & -1 & 4 & 6 \\\\\n 0 & -10 & -6 & 6 & 6 \\\\\n -2 & 9 & 3 & -6 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -9, 3, 7, -6],\n [-3, -3, -1, 4, 6],\n [0, -10, -6, 6, 6],\n [-2, 9, 3, -6, 9]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 3 \\\\\n 8 \\\\\n 7 \\\\\n 4 \\\\\n 3 \\\\\n 4 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{21}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [3],\n [8],\n [7],\n [4],\n [3],\n [4],\n [-1]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{2} & -2 \\\\\n -\\frac{1}{2} & -2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{29}{4} & -1 \\\\\n -\\frac{1}{4} & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), -2],\n [-(1/2), -2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 8 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -6 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -14 \\\\\n -21 \\\\\n 14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [8],\n [3]])\nb = np.array([\n [5],\n [-6],\n [-4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 5 & 9 & 6 \\\\\n -4 & -8 & 4 \\\\\n -6 & 2 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, 9, 6],\n [-4, -8, 4],\n [-6, 2, -8]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 9 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 0 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-57$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [9],\n [1]])\nb = np.array([\n [-7],\n [0],\n [-8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & -1 \\\\\n 0 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1,15\\}, \\{1,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -1],\n [0, 9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -4 & -6 & -4 \\\\\n 0 & -2 & -10 \\\\\n 2 & -10 & 5 \\\\\n 6 & -8 & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 9 & -2 & 8 \\\\\n 1 & -4 & 5 \\\\\n 5 & 6 & 1 \\\\\n -7 & -8 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 5 & -8 & 4 \\\\\n 1 & -6 & -5 \\\\\n 7 & -4 & 6 \\\\\n -1 & -16 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -6, -4],\n [0, -2, -10],\n [2, -10, 5],\n [6, -8, 3]])\nb = np.array([\n [9, -2, 8],\n [1, -4, 5],\n [5, 6, 1],\n [-7, -8, 3]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -3 & -3 \\\\\n -2 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-2 x-21$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3],\n [-2, 5]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 2 & -1 \\\\\n 3 & 1 & -1 \\\\\n -1 & -3 & -3 \\\\\n -1 & 1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.19 \\\\\n 2.73 \\\\\n 0.91 \\\\\n 1.18 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.717 \\\\\n -0.272 \\\\\n 0.143 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, -1],\n [3, 1, -1],\n [-1, -3, -3],\n [-1, 1, 3]])\nb = np.array([\n [-0.19],\n [2.73],\n [0.91],\n [1.18]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{2,-5,-2\\}, \\{-4,-5,-1\\}, \\{3,0,-3\\}}$.", - "Output Answer": [ - "$x+y+6 z+15=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, -5, -2],\n [-4, -5, -1],\n [3, 0, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{26}{9} & -\\frac{8}{9} \\\\\n -\\frac{5}{9} & -\\frac{4}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{4} & -\\frac{1}{2} \\\\\n -\\frac{5}{16} & -\\frac{13}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/9), -(8/9)],\n [-(5/9), -(4/9)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 5 & 1 & -10 \\\\\n 0 & -8 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{17.,-5.,8.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, 1, -10],\n [0, -8, -5]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n \\frac{47}{16} & \\frac{17}{16} & -1 \\\\\n \\frac{11}{4} & -\\frac{13}{8} & \\frac{3}{4} \\\\\n \\frac{41}{16} & -\\frac{13}{8} & -\\frac{3}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{35}{16} & -\\frac{23}{8} & \\frac{9}{16} & \\frac{19}{16} \\\\\n \\frac{9}{16} & \\frac{7}{4} & -\\frac{33}{16} & \\frac{7}{4} \\\\\n \\frac{15}{16} & -\\frac{17}{16} & \\frac{17}{16} & \\frac{1}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{779}{128} & -\\frac{707}{128} & -\\frac{205}{128} & \\frac{1337}{256} \\\\\n \\frac{743}{128} & -\\frac{739}{64} & \\frac{729}{128} & \\frac{33}{64} \\\\\n \\frac{289}{64} & -\\frac{2563}{256} & \\frac{147}{32} & \\frac{45}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(47/16), (17/16), -1],\n [(11/4), -(13/8), (3/4)],\n [(41/16), -(13/8), -(3/16)]])\nb = np.array([\n [(35/16), -(23/8), (9/16), (19/16)],\n [(9/16), (7/4), -(33/16), (7/4)],\n [(15/16), -(17/16), (17/16), (1/8)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{5} \\\\\n -\\frac{7}{5} \\\\\n \\frac{12}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{9}{5} \\\\\n -3 \\\\\n \\frac{1}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{486}{1535},-\\frac{162}{307},\\frac{54}{1535}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/5)],\n [-(7/5)],\n [(12/5)]]).squeeze()\nb = np.array([\n [(9/5)],\n [-3],\n [(1/5)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{113}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-1]])\nb = np.array([\n [-1],\n [7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & -\\frac{7}{2} & -\\frac{3}{2} \\\\\n -\\frac{3}{2} & \\frac{17}{2} & 0 \\\\\n -9 & \\frac{5}{2} & -\\frac{19}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.331,2.704,1.\\}, \\{-1.289,-0.273,1.\\}, \\{0.132,0.01,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(7/2), -(3/2)],\n [-(3/2), (17/2), 0],\n [-9, (5/2), -(19/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & 8 \\\\\n 3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-4,3\\}, \\{2,1\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 8],\n [3, -1]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{23}{16} \\\\\n -\\frac{1}{4} \\\\\n -\\frac{17}{8} \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{23}{3 \\sqrt{445}} \\\\\n -\\frac{4}{3 \\sqrt{445}} \\\\\n -\\frac{34}{3 \\sqrt{445}} \\\\\n \\frac{16}{\\sqrt{445}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/16)],\n [-(1/4)],\n [-(17/8)],\n [3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & 9 & 3 \\\\\n -7 & 7 & -10 \\\\\n -8 & -3 & -9 \\\\\n 1 & -10 & -10 \\\\\n 0 & -5 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, 9, 3],\n [-7, 7, -10],\n [-8, -3, -9],\n [1, -10, -10],\n [0, -5, 1]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7.582 \\\\\n -9.746 \\\\\n -4.446 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3.92 \\\\\n -0.272 \\\\\n -9.83 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$76.0765$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7.582],\n [-9.746],\n [-4.446]])\nb = np.array([\n [-3.92],\n [-0.272],\n [-9.83]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & -1 \\\\\n 2 & -1 \\\\\n 1 & 0 \\\\\n 2 & 0 \\\\\n -3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.19 \\\\\n 0.27 \\\\\n 2.26 \\\\\n 1.31 \\\\\n -1.85 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.612 \\\\\n 0.141 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1],\n [2, -1],\n [1, 0],\n [2, 0],\n [-3, 3]])\nb = np.array([\n [1.19],\n [0.27],\n [2.26],\n [1.31],\n [-1.85]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -4 \\\\\n 9 \\\\\n -8 \\\\\n -2 \\\\\n -9 \\\\\n 4 \\\\\n 8 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 8 \\\\\n -3 \\\\\n -10 \\\\\n 4 \\\\\n 9 \\\\\n -8 \\\\\n -6 \\\\\n -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{1217}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-4],\n [9],\n [-8],\n [-2],\n [-9],\n [4],\n [8],\n [5]])\nb = np.array([\n [2],\n [8],\n [-3],\n [-10],\n [4],\n [9],\n [-8],\n [-6],\n [-10]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n -2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{1}{\\sqrt{11}} \\\\\n \\frac{1}{\\sqrt{11}} \\\\\n \\frac{1}{\\sqrt{11}} \\\\\n -\\frac{2}{\\sqrt{11}} \\\\\n -\\frac{2}{\\sqrt{11}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [1],\n [1],\n [-2],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 9 & 5 & -9 \\\\\n -8 & 4 & -3 \\\\\n -5 & 8 & 8 \\\\\n -2 & 7 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, 5, -9],\n [-8, 4, -3],\n [-5, 8, 8],\n [-2, 7, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{13}{3}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -6 & 8 & 2 & -7 \\\\\n 3 & 9 & 7 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -26 & \\frac{104}{3} & \\frac{26}{3} & -\\frac{91}{3} \\\\\n 13 & 39 & \\frac{91}{3} & 13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 8, 2, -7],\n [3, 9, 7, 3]])\nprint(a * (13/3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -4 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$19$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-4],\n [8]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -2 & -1 & 0 & 0 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -1 & 3 & -3 & -1 & -2 \\\\\n -2 & -3 & 1 & 2 & -2 \\\\\n 2 & -1 & 0 & -2 & -1 \\\\\n 0 & -2 & -1 & 2 & 2 \\\\\n 1 & -3 & 2 & 2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 2 & 3 & 1 & -4 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1, 0, 0, -2]])\nb = np.array([\n [-1, 3, -3, -1, -2],\n [-2, -3, 1, 2, -2],\n [2, -1, 0, -2, -1],\n [0, -2, -1, 2, 2],\n [1, -3, 2, 2, 2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{9}{7} & -\\frac{34}{7} & \\frac{66}{7} \\\\\n \\frac{17}{7} & \\frac{45}{7} & \\frac{24}{7} \\\\\n -2 & -\\frac{69}{7} & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{9 x^2}{7}-\\frac{23 x}{7}-\\frac{71439}{343}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/7), -(34/7), (66/7)],\n [(17/7), (45/7), (24/7)],\n [-2, -(69/7), -9]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 4 & 1 \\\\\n 9 & -7 \\\\\n -3 & -9 \\\\\n 6 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, 1],\n [9, -7],\n [-3, -9],\n [6, 7]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 6 & 4 \\\\\n 3 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, 4],\n [3, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -8 & 2 & 4 \\\\\n 3 & -2 & 0 \\\\\n 1 & -2 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-x^2+84 x+74$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 2, 4],\n [3, -2, 0],\n [1, -2, 9]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 2 & 9 & 9 & 8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 1 & -8 & 6 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 17 & 3 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 9, 9, 8]])\nb = np.array([\n [1, -8, 6, 2]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{2} \\\\\n 10 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{7}{2} \\\\\n -\\frac{5}{2} \\\\\n -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{215}{2} \\\\\n 52 \\\\\n -\\frac{225}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/2)],\n [10],\n [-7]])\nb = np.array([\n [(7/2)],\n [-(5/2)],\n [-9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -6 & -9 & 8 \\\\\n 6 & 9 & 4 \\\\\n -8 & 7 & 1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 0 & 5 & -8 \\\\\n -5 & 1 & -3 \\\\\n 10 & 9 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -6 & -14 & 16 \\\\\n 11 & 8 & 7 \\\\\n -18 & -2 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -9, 8],\n [6, 9, 4],\n [-8, 7, 1]])\nb = np.array([\n [0, 5, -8],\n [-5, 1, -3],\n [10, 9, 2]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n 7 & -3 & -2 \\\\\n 5 & -7 & -6 \\\\\n 9 & -1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -3, -2],\n [5, -7, -6],\n [9, -1, 4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{70}{9} & -\\frac{40}{9} & -\\frac{8}{3} \\\\\n \\frac{25}{9} & -\\frac{23}{9} & -\\frac{23}{9} \\\\\n 0 & \\frac{56}{9} & \\frac{17}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{64 x^2}{9}-\\frac{1477 x}{81}+\\frac{46190}{729}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(70/9), -(40/9), -(8/3)],\n [(25/9), -(23/9), -(23/9)],\n [0, (56/9), (17/9)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,3,3\\}, \\{-1,0,-2\\}, \\{2,-3,-3\\}}$.", - "Output Answer": [ - "$12 x+13 y-3 z+6=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, 3, 3],\n [-1, 0, -2],\n [2, -3, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, -\\frac{2}{7}}$ to the line $-\\frac{20 x}{7}+\\frac{6 y}{7}+\\frac{30}{7}=0$.", - "Output Answer": [ - "$\\frac{239}{7 \\sqrt{109}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, -(2/7)\nline = Poly(-((20*x)/7)+((6*y)/7)+(30/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{4} \\\\\n -\\frac{137}{16} \\\\\n -\\frac{59}{16} \\\\\n -\\frac{49}{16} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{16} \\\\\n \\frac{97}{16} \\\\\n \\frac{95}{16} \\\\\n \\frac{13}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{23}{16} \\\\\n -\\frac{117}{8} \\\\\n -\\frac{77}{8} \\\\\n -\\frac{101}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/4)],\n [-(137/16)],\n [-(59/16)],\n [-(49/16)]])\nb = np.array([\n [-(29/16)],\n [(97/16)],\n [(95/16)],\n [(13/4)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -\\frac{26}{3} & \\frac{13}{6} \\\\\n -\\frac{19}{2} & -8 \\\\\n -\\frac{15}{2} & -\\frac{23}{6} \\\\\n -\\frac{11}{2} & \\frac{47}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(26/3), (13/6)],\n [-(19/2), -8],\n [-(15/2), -(23/6)],\n [-(11/2), (47/6)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{29}{6} & -\\frac{2}{3} \\\\\n \\frac{5}{6} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{54}{241} & -\\frac{24}{241} \\\\\n \\frac{30}{241} & \\frac{174}{241} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/6), -(2/3)],\n [(5/6), (3/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & -9 \\\\\n 7 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(1-i \\sqrt{227}\\right),\\frac{1}{2} \\left(1+i \\sqrt{227}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -9],\n [7, 3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{21}{4} & -4 & \\frac{11}{4} \\\\\n -\\frac{1}{2} & -4 & \\frac{5}{4} \\\\\n \\frac{25}{4} & -\\frac{11}{2} & \\frac{27}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-3.777,2.008,9.77\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(21/4), -4, (11/4)],\n [-(1/2), -4, (5/4)],\n [(25/4), -(11/2), (27/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 3 & 6 & -2 & 3 \\\\\n -7 & -2 & -9 & -10 \\\\\n 7 & 6 & 8 & -1 \\\\\n 6 & -10 & -5 & 7 \\\\\n -10 & -10 & -10 & 10 \\\\\n -8 & 0 & 10 & 7 \\\\\n -10 & 1 & 2 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, 6, -2, 3],\n [-7, -2, -9, -10],\n [7, 6, 8, -1],\n [6, -10, -5, 7],\n [-10, -10, -10, 10],\n [-8, 0, 10, 7],\n [-10, 1, 2, 7]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & 4 & -\\frac{5}{3} \\\\\n -4 & \\frac{7}{3} & \\frac{14}{3} \\\\\n -2 & -\\frac{5}{3} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{1040}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 4, -(5/3)],\n [-4, (7/3), (14/3)],\n [-2, -(5/3), -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{20}{7},1,-\\frac{2}{7}\\right\\}, \\left\\{\\frac{10}{7},-1,-\\frac{16}{7}\\right\\}, \\left\\{-\\frac{11}{7},\\frac{3}{7},-\\frac{12}{7}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{20}{\\sqrt{453}},\\frac{7}{\\sqrt{453}},-\\frac{2}{\\sqrt{453}}\\right\\}, \\left\\{\\frac{95}{\\sqrt{15444582}},-413 \\sqrt{\\frac{2}{7722291}},-\\frac{3841}{\\sqrt{15444582}}\\right\\}, \\left\\{\\frac{63}{\\sqrt{34094}},85 \\sqrt{\\frac{2}{17047}},-\\frac{35}{\\sqrt{34094}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-(20/7), 1, -(2/7)), ((10/7), -1, -(16/7)), (-(11/7), (3/7), -(12/7))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 6 \\\\\n 1 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [6],\n [1],\n [-8]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,-3,1\\}, \\{1,3,-2\\}, \\{0,1,-3\\}}$", - "Output Answer": [ - "${\\left\\{-\\sqrt{\\frac{2}{7}},-\\frac{3}{\\sqrt{14}},\\frac{1}{\\sqrt{14}}\\right\\}, \\left\\{-2 \\sqrt{\\frac{2}{21}},\\frac{1}{\\sqrt{42}},-\\frac{5}{\\sqrt{42}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, -3, 1), (1, 3, -2), (0, 1, -3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{29}{10} & \\frac{27}{10} \\\\\n 4 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{79}{10}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/10), (27/10)],\n [4, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 0 & 4 & -1 \\\\\n -3 & -5 & -3 \\\\\n 0 & -1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{23}{45} & -\\frac{1}{3} & -\\frac{17}{45} \\\\\n \\frac{4}{15} & 0 & \\frac{1}{15} \\\\\n \\frac{1}{15} & 0 & \\frac{4}{15} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 4, -1],\n [-3, -5, -3],\n [0, -1, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 0 & 3 & \\frac{16}{3} & \\frac{35}{6} \\\\\n \\frac{11}{2} & 9 & 6 & \\frac{29}{6} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{1}{3} & -8 & -\\frac{3}{2} & \\frac{23}{6} \\\\\n -\\frac{23}{3} & \\frac{17}{3} & -\\frac{5}{2} & -\\frac{59}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{1}{3} & 11 & \\frac{41}{6} & 2 \\\\\n \\frac{79}{6} & \\frac{10}{3} & \\frac{17}{2} & \\frac{44}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 3, (16/3), (35/6)],\n [(11/2), 9, 6, (29/6)]])\nb = np.array([\n [-(1/3), -8, -(3/2), (23/6)],\n [-(23/3), (17/3), -(5/2), -(59/6)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{28}{3} & -7 \\\\\n -4 & -\\frac{29}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+19 x+\\frac{560}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(28/3), -7],\n [-4, -(29/3)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n -\\frac{5}{4} \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{3}{4} \\\\\n \\frac{39}{4} \\\\\n \\frac{19}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{173}{8} \\\\\n -4 \\\\\n \\frac{93}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2)],\n [-(5/4)],\n [1]])\nb = np.array([\n [(3/4)],\n [(39/4)],\n [(19/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 3 & 4 & 4 & 9 \\\\\n 9 & 2 & 5 & -3 \\\\\n 0 & 7 & 1 & -9 \\\\\n 7 & -4 & 5 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, 4, 4, 9],\n [9, 2, 5, -3],\n [0, 7, 1, -9],\n [7, -4, 5, -9]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & -4 & 1 \\\\\n -1 & 1 & -1 \\\\\n 2 & -4 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$14$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -4, 1],\n [-1, 1, -1],\n [2, -4, -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -10 & -2 & -8 & 9 \\\\\n -7 & -6 & -10 & 1 \\\\\n 10 & -1 & -7 & -5 \\\\\n 8 & 6 & -5 & 10 \\\\\n 5 & -8 & -7 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, -2, -8, 9],\n [-7, -6, -10, 1],\n [10, -1, -7, -5],\n [8, 6, -5, 10],\n [5, -8, -7, 0]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & 0 \\\\\n 4 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 0],\n [4, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -2 & 7 & -7 \\\\\n -3 & -7 & -9 \\\\\n -5 & 7 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-13 x^2-99 x+441$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 7, -7],\n [-3, -7, -9],\n [-5, 7, -4]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{2} \\\\\n -\\frac{29}{6} \\\\\n \\frac{16}{3} \\\\\n \\frac{28}{3} \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{28}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2)],\n [-(29/6)],\n [(16/3)],\n [(28/3)],\n [-8]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 8 \\\\\n 4 \\\\\n 6 \\\\\n 6 \\\\\n -5 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 2 \\\\\n 7 \\\\\n 7 \\\\\n -9 \\\\\n -4 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$133$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [8],\n [4],\n [6],\n [6],\n [-5],\n [-7]])\nb = np.array([\n [-5],\n [2],\n [7],\n [7],\n [-9],\n [-4],\n [-8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{\\log (2),-4 \\log (2),\\log (2)\\}, \\{-3 \\log (2),2 \\log (2),3 \\log (2)\\}, \\{2 \\log (2),-3 \\log (2),2 \\log (2)\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{3 \\sqrt{2}},-\\frac{2 \\sqrt{2}}{3},\\frac{1}{3 \\sqrt{2}}\\right\\}, \\left\\{-\\frac{23}{3 \\sqrt{166}},\\frac{\\sqrt{\\frac{2}{83}}}{3},\\frac{31}{3 \\sqrt{166}}\\right\\}, \\left\\{\\frac{7}{\\sqrt{83}},\\frac{3}{\\sqrt{83}},\\frac{5}{\\sqrt{83}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((math.log(2), -4*math.log(2), math.log(2)), (-3*math.log(2), 2*math.log(2), 3*math.log(2)), (2*math.log(2), -3*math.log(2), 2*math.log(2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{41}{5} \\\\\n -\\frac{4}{5} \\\\\n -\\frac{38}{5} \\\\\n \\frac{18}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{5} \\\\\n 7 \\\\\n -\\frac{34}{5} \\\\\n -\\frac{31}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{239}{\\sqrt{1290135}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(41/5)],\n [-(4/5)],\n [-(38/5)],\n [(18/5)]]).squeeze()\nb = np.array([\n [-(3/5)],\n [7],\n [-(34/5)],\n [-(31/5)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n -2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2}{\\sqrt{13}} \\\\\n -\\frac{1}{\\sqrt{13}} \\\\\n 0 \\\\\n 0 \\\\\n -\\frac{2}{\\sqrt{13}} \\\\\n -\\frac{2}{\\sqrt{13}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-1],\n [0],\n [0],\n [-2],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -7 & -\\frac{13}{2} & \\frac{13}{2} \\\\\n -\\frac{13}{2} & -\\frac{5}{2} & 8 \\\\\n 0 & -4 & -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{2.694,-2.465,1.\\}, \\{0.763\\, -1.46 i,0.295\\, -1.135 i,1.\\}, \\{0.763\\, +1.46 i,0.295\\, +1.135 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -(13/2), (13/2)],\n [-(13/2), -(5/2), 8],\n [0, -4, -(17/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{22}{3} & -\\frac{8}{3} & \\frac{2}{3} \\\\\n -3 & \\frac{29}{3} & -\\frac{5}{3} \\\\\n \\frac{23}{3} & 1 & -\\frac{29}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-9.786,5.3,11.819\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(22/3), -(8/3), (2/3)],\n [-3, (29/3), -(5/3)],\n [(23/3), 1, -(29/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n \\frac{49}{9} & -\\frac{86}{9} & -\\frac{7}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(49/9), -(86/9), -(7/9)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{10} \\\\\n \\frac{5}{2} \\\\\n \\frac{14}{5} \\\\\n -\\frac{1}{2} \\\\\n \\frac{11}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{2 \\sqrt{389}} \\\\\n \\frac{25}{2 \\sqrt{389}} \\\\\n \\frac{14}{\\sqrt{389}} \\\\\n -\\frac{5}{2 \\sqrt{389}} \\\\\n \\frac{11}{2 \\sqrt{389}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/10)],\n [(5/2)],\n [(14/5)],\n [-(1/2)],\n [(11/10)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{11}{3} & -3 \\\\\n 6 & \\frac{19}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{6} \\left(-5-\\sqrt{7}\\right),1\\right\\}, \\left\\{\\frac{1}{6} \\left(\\sqrt{7}-5\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/3), -3],\n [6, (19/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -1 & \\frac{1}{2} & \\frac{4}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{2} & -\\frac{1}{6} & -1 \\\\\n \\frac{7}{6} & \\frac{5}{6} & \\frac{17}{6} \\\\\n -\\frac{11}{6} & -\\frac{7}{6} & -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{49}{36} & -\\frac{35}{36} & -\\frac{25}{36} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, (1/2), (4/3)]])\nb = np.array([\n [-(1/2), -(1/6), -1],\n [(7/6), (5/6), (17/6)],\n [-(11/6), -(7/6), -(7/3)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-2$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -10 & 3 \\\\\n 9 & -4 \\\\\n -6 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 20 & -6 \\\\\n -18 & 8 \\\\\n 12 & 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 3],\n [9, -4],\n [-6, -6]])\nprint(a * -2)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -3 & 10 & -9 & 3 \\\\\n -9 & -7 & 9 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -6 & -5 & -7 & -2 \\\\\n -9 & -1 & 6 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -9 & 5 & -16 & 1 \\\\\n -18 & -8 & 15 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 10, -9, 3],\n [-9, -7, 9, 0]])\nb = np.array([\n [-6, -5, -7, -2],\n [-9, -1, 6, 7]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n -\\frac{8}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{\\sqrt{3}} \\\\\n -\\frac{13}{\\sqrt{3}} \\\\\n -\\frac{11}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{205}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-4*math.sqrt(3)],\n [math.sqrt(3)],\n [-(8/(math.sqrt(3)))]])\nb = np.array([\n [-(13/(math.sqrt(3)))],\n [-(13/(math.sqrt(3)))],\n [-(11/(math.sqrt(3)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\sqrt{5} \\\\\n -4 \\sqrt{5} \\\\\n \\sqrt{5} \\\\\n 0 \\\\\n -\\sqrt{5} \\\\\n 2 \\sqrt{5} \\\\\n -4 \\sqrt{5} \\\\\n \\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n 2 \\sqrt{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\sqrt{5} \\\\\n \\sqrt{5} \\\\\n 2 \\sqrt{5} \\\\\n -4 \\sqrt{5} \\\\\n -2 \\sqrt{5} \\\\\n 0 \\\\\n \\sqrt{5} \\\\\n -2 \\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{445}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.sqrt(5)],\n [-4*math.sqrt(5)],\n [math.sqrt(5)],\n [0],\n [-math.sqrt(5)],\n [2*math.sqrt(5)],\n [-4*math.sqrt(5)],\n [math.sqrt(5)],\n [4*math.sqrt(5)],\n [2*math.sqrt(5)]])\nb = np.array([\n [-math.sqrt(5)],\n [math.sqrt(5)],\n [2*math.sqrt(5)],\n [-4*math.sqrt(5)],\n [-2*math.sqrt(5)],\n [0],\n [math.sqrt(5)],\n [-2*math.sqrt(5)],\n [4*math.sqrt(5)],\n [4*math.sqrt(5)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{2} \\\\\n -\\frac{1}{4} \\\\\n \\frac{27}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{29}{8} \\\\\n -\\frac{71}{8} \\\\\n -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{2005}{64} \\\\\n -\\frac{1857}{64} \\\\\n \\frac{2159}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/2)],\n [-(1/4)],\n [(27/8)]])\nb = np.array([\n [(29/8)],\n [-(71/8)],\n [-(11/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{31}{8} & -\\frac{5}{8} & \\frac{111}{16} \\\\\n -\\frac{143}{16} & -\\frac{129}{16} & -\\frac{27}{4} \\\\\n -7 & -\\frac{35}{16} & \\frac{145}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{8} & \\frac{117}{16} & -\\frac{93}{16} \\\\\n -\\frac{121}{16} & -\\frac{77}{16} & -\\frac{59}{16} \\\\\n -\\frac{5}{4} & -\\frac{19}{16} & -\\frac{113}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{21}{4} & \\frac{107}{16} & \\frac{9}{8} \\\\\n -\\frac{33}{2} & -\\frac{103}{8} & -\\frac{167}{16} \\\\\n -\\frac{33}{4} & -\\frac{27}{8} & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(31/8), -(5/8), (111/16)],\n [-(143/16), -(129/16), -(27/4)],\n [-7, -(35/16), (145/16)]])\nb = np.array([\n [-(11/8), (117/16), -(93/16)],\n [-(121/16), -(77/16), -(59/16)],\n [-(5/4), -(19/16), -(113/16)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{6} \\\\\n \\frac{23}{3} \\\\\n -\\frac{25}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/6)],\n [(23/3)],\n [-(25/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{63}{10} & \\frac{1}{10} \\\\\n \\frac{61}{10} & -\\frac{17}{10} \\\\\n \\frac{7}{2} & -\\frac{71}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{5} & \\frac{18}{5} \\\\\n \\frac{2}{5} & -\\frac{7}{2} \\\\\n \\frac{81}{10} & -\\frac{21}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{69}{10} & \\frac{37}{10} \\\\\n \\frac{13}{2} & -\\frac{26}{5} \\\\\n \\frac{58}{5} & -\\frac{46}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(63/10), (1/10)],\n [(61/10), -(17/10)],\n [(7/2), -(71/10)]])\nb = np.array([\n [(3/5), (18/5)],\n [(2/5), -(7/2)],\n [(81/10), -(21/10)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\text{Indeterminate}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [1],\n [0]]).squeeze()\nb = np.array([\n [0],\n [0],\n [0],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{18}{5}, \\frac{11}{5}, -\\frac{19}{5}}$ to the plane $-\\frac{24 x}{5}+4 y+\\frac{19 z}{5}-3=0$.", - "Output Answer": [ - "$\\frac{648}{5 \\sqrt{1337}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (18/5), (11/5), -(19/5)\nplane = Poly(-((24*x)/5)+4*y+((19*z)/5)-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 3 & 5 & -3 & -2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-5.,3.,0.,0.,0.\\}, \\{1.,0.,1.,0.,0.\\}, \\{2.,0.,0.,0.,3.\\}, \\{2.,0.,0.,3.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, 5, -3, -2, -2]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{8}{3} & \\frac{9}{2} & \\frac{5}{6} \\\\\n -\\frac{7}{6} & 4 & 1 \\\\\n \\frac{4}{3} & -\\frac{8}{3} & -\\frac{29}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{5015}{216}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/3), (9/2), (5/6)],\n [-(7/6), 4, 1],\n [(4/3), -(8/3), -(29/6)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & 2 & 3 \\\\\n -4 & 0 & 5 \\\\\n -1 & -3 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.637,-1.197,1.\\}, \\{-0.595-0.462 i,-0.476-1.335 i,1.\\}, \\{-0.595+0.462 i,-0.476+1.335 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2, 3],\n [-4, 0, 5],\n [-1, -3, -5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{16}{7}, \\frac{33}{7}}$ to the line $\\frac{18 x}{7}+\\frac{24 y}{7}+\\frac{23}{7}=0$.", - "Output Answer": [ - "$\\frac{19}{6}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(16/7), (33/7)\nline = Poly(((18*x)/7)+((24*y)/7)+(23/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -6 & 4 & 3 & 8 \\\\\n 5 & 2 & 7 & -8 \\\\\n -1 & 3 & 9 & -9 \\\\\n -9 & -2 & 0 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 4, 3, 8],\n [5, 2, 7, -8],\n [-1, 3, 9, -9],\n [-9, -2, 0, 4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$12$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [1],\n [10]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 9 & -4 & 4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-4.,0.,9.,0.\\}, \\{1.,0.,0.,3.\\}, \\{4.,9.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, -4, 4, -3]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -7 & -5 & \\frac{17}{2} \\\\\n 6 & \\frac{19}{2} & 9 \\\\\n 5 & \\frac{3}{2} & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.62,0.352,1.\\}, \\{0.835\\, -3.077 i,0.239\\, +9.208 i,1.\\}, \\{0.835\\, +3.077 i,0.239\\, -9.208 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -5, (17/2)],\n [6, (19/2), 9],\n [5, (3/2), 3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{3} & -10 & \\frac{23}{3} \\\\\n -\\frac{29}{3} & -\\frac{1}{3} & -\\frac{14}{3} \\\\\n \\frac{13}{3} & 6 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-13.385,4.693\\, -1.713 i,4.693\\, +1.713 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/3), -10, (23/3)],\n [-(29/3), -(1/3), -(14/3)],\n [(13/3), 6, 0]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{16}{3} & -4 & -8 \\\\\n -\\frac{2}{3} & -\\frac{7}{3} & \\frac{5}{3} \\\\\n -2 & -\\frac{29}{3} & -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{7 x^2}{3}+17 x+\\frac{856}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(16/3), -4, -8],\n [-(2/3), -(7/3), (5/3)],\n [-2, -(29/3), -(2/3)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -1 \\\\\n -1 \\\\\n -2 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -9 \\\\\n 9 \\\\\n 6 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{345}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-1],\n [-1],\n [-2],\n [4]])\nb = np.array([\n [9],\n [-9],\n [9],\n [6],\n [-5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 2 & 6 & 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-3.,1.,0.,0.\\}, \\{-1.,0.,2.,0.\\}, \\{1.,0.,0.,2.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, 6, 1, -1]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 9 & 6 & -1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -9 & -1 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 18 & 7 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 6, -1]])\nb = np.array([\n [-9, -1, 2]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 5 & -6 & 1 & 8 & 10 \\\\\n 6 & -8 & 10 & 1 & 2 \\\\\n -6 & 9 & 9 & 4 & -1 \\\\\n -9 & -9 & -6 & -1 & 5 \\\\\n -9 & 4 & -4 & -6 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, -6, 1, 8, 10],\n [6, -8, 10, 1, 2],\n [-6, 9, 9, 4, -1],\n [-9, -9, -6, -1, 5],\n [-9, 4, -4, -6, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & 4-\\frac{5 i}{2} & \\frac{5}{2}-2 i \\\\\n 1+\\frac{7 i}{2} & -\\frac{1}{2}-2 i & \\frac{1}{2}-\\frac{5 i}{2} \\\\\n -\\frac{5}{2}+3 i & -2+3 i & 2+4 i \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{129}{8}+\\frac{377 i}{8} & \\frac{475}{4}+\\frac{903 i}{8} & \\frac{1053}{8}+\\frac{295 i}{4} \\\\\n -98+\\frac{903 i}{8} & \\frac{457}{8}-\\frac{107 i}{8} & \\frac{935}{8}+\\frac{225 i}{8} \\\\\n -\\frac{1465}{8}-\\frac{259 i}{2} & -\\frac{379}{2}-\\frac{91 i}{4} & -\\frac{801}{4}+\\frac{1043 i}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), 4-((5j)/2), (5/2)-2j],\n [1+((7j)/2), -(1/2)-2j, (1/2)-((5j)/2)],\n [-(5/2)+3j, -2+3j, 2+4j]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, -1}$ to the line $5 x+y+1=0$.", - "Output Answer": [ - "$\\frac{15}{\\sqrt{26}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, -1\nline = Poly(5*x+y+1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{6}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 4 & -7 & 7 & 4 \\\\\n 6 & 5 & -10 & 9 \\\\\n -5 & 1 & -9 & 9 \\\\\n 8 & -5 & 10 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{2}{3} & -\\frac{7}{6} & \\frac{7}{6} & \\frac{2}{3} \\\\\n 1 & \\frac{5}{6} & -\\frac{5}{3} & \\frac{3}{2} \\\\\n -\\frac{5}{6} & \\frac{1}{6} & -\\frac{3}{2} & \\frac{3}{2} \\\\\n \\frac{4}{3} & -\\frac{5}{6} & \\frac{5}{3} & -\\frac{7}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -7, 7, 4],\n [6, 5, -10, 9],\n [-5, 1, -9, 9],\n [8, -5, 10, -7]])\nprint(a * (1/6))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & \\frac{28}{5} & -\\frac{34}{5} \\\\\n \\frac{13}{5} & -\\frac{31}{5} & -\\frac{8}{5} \\\\\n -\\frac{46}{5} & -\\frac{32}{5} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8.903,-6.998,11.701\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, (28/5), -(34/5)],\n [(13/5), -(31/5), -(8/5)],\n [-(46/5), -(32/5), -4]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{2} & -\\frac{27}{8} & \\frac{7}{4} \\\\\n -\\frac{9}{2} & \\frac{13}{4} & 4 \\\\\n \\frac{3}{4} & -\\frac{19}{8} & -\\frac{23}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{20}{6111} & -\\frac{1774}{6111} & -\\frac{2456}{6111} \\\\\n -\\frac{424}{2037} & \\frac{128}{2037} & -\\frac{80}{2037} \\\\\n \\frac{352}{2037} & -\\frac{260}{2037} & -\\frac{856}{2037} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), -(27/8), (7/4)],\n [-(9/2), (13/4), 4],\n [(3/4), -(19/8), -(23/8)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{3}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -4 & -9 \\\\\n -1 & -3 \\\\\n -2 & 0 \\\\\n 7 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{20}{3} & 15 \\\\\n \\frac{5}{3} & 5 \\\\\n \\frac{10}{3} & 0 \\\\\n -\\frac{35}{3} & -\\frac{50}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -9],\n [-1, -3],\n [-2, 0],\n [7, 10]])\nprint(a * -(5/3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{20}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 6 & 0 & -8 & -4 \\\\\n -9 & -6 & -6 & -9 \\\\\n -3 & 1 & -3 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{3}{10} & 0 & \\frac{2}{5} & \\frac{1}{5} \\\\\n \\frac{9}{20} & \\frac{3}{10} & \\frac{3}{10} & \\frac{9}{20} \\\\\n \\frac{3}{20} & -\\frac{1}{20} & \\frac{3}{20} & \\frac{3}{20} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 0, -8, -4],\n [-9, -6, -6, -9],\n [-3, 1, -3, -3]])\nprint(a * -(1/20))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{68}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-68$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7]])\nb = np.array([\n [-(68/7)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 8 & 6 & 6 & -9 & -6 & -4 & 0 \\\\\n -3 & 0 & -6 & -8 & -5 & -9 & -9 \\\\\n 4 & 9 & -10 & -6 & -5 & 1 & 3 \\\\\n 8 & 10 & -9 & 6 & 3 & 4 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & \\frac{999}{2423} & -\\frac{12919}{2423} & -\\frac{15309}{2423} \\\\\n 0 & 1 & 0 & 0 & -\\frac{1257}{2423} & \\frac{14611}{2423} & \\frac{17691}{2423} \\\\\n 0 & 0 & 1 & 0 & -\\frac{371}{2423} & \\frac{5814}{2423} & \\frac{7257}{2423} \\\\\n 0 & 0 & 0 & 1 & \\frac{1418}{2423} & \\frac{3210}{2423} & \\frac{3024}{2423} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, 6, 6, -9, -6, -4, 0],\n [-3, 0, -6, -8, -5, -9, -9],\n [4, 9, -10, -6, -5, 1, 3],\n [8, 10, -9, 6, 3, 4, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{0,-\\frac{1}{2},\\frac{7}{2}\\right\\}, \\left\\{-4,4,\\frac{5}{2}\\right\\}, \\left\\{3,-2,-\\frac{1}{2}\\right\\}}$.", - "Output Answer": [ - "$78 x+76 y+30 z-67=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, -(1/2), (7/2)],\n [-4, 4, (5/2)],\n [3, -2, -(1/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 6 & -\\frac{5}{2} & \\frac{11}{6} \\\\\n \\frac{11}{3} & \\frac{17}{2} & \\frac{11}{2} \\\\\n \\frac{59}{6} & 0 & -\\frac{25}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{31 x^2}{3}+\\frac{329 x}{18}-\\frac{19409}{36}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -(5/2), (11/6)],\n [(11/3), (17/2), (11/2)],\n [(59/6), 0, -(25/6)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n -\\frac{8}{3} \\\\\n \\frac{5}{3} \\\\\n 1 \\\\\n \\frac{4}{3} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{2}{3} \\\\\n 0 \\\\\n 3 \\\\\n \\frac{2}{3} \\\\\n \\frac{2}{3} \\\\\n \\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{36}{97},0,-\\frac{162}{97},-\\frac{36}{97},-\\frac{36}{97},-\\frac{36}{97}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [-(8/3)],\n [(5/3)],\n [1],\n [(4/3)]]).squeeze()\nb = np.array([\n [(2/3)],\n [0],\n [3],\n [(2/3)],\n [(2/3)],\n [(2/3)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -3 & -2 & 2 \\\\\n -5 & 2 & 0 \\\\\n 3 & 0 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{2} & -\\frac{1}{2} & -1 \\\\\n -\\frac{5}{4} & -\\frac{3}{4} & -\\frac{5}{2} \\\\\n -\\frac{3}{2} & -\\frac{3}{2} & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2, 2],\n [-5, 2, 0],\n [3, 0, -1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,-2,-3\\}, \\{-4,3,-4\\}, \\{2,-2,-1\\}}$.", - "Output Answer": [ - "$5 x+3 y-5 z-9=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, -2, -3],\n [-4, 3, -4],\n [2, -2, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{7}{3}, 3, -5}$ to the plane $4 x-\\frac{10 y}{3}-2 z+\\frac{13}{3}=0$.", - "Output Answer": [ - "$\\frac{3 \\sqrt{\\frac{5}{14}}}{2}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(7/3), 3, -5\nplane = Poly(4*x-((10*y)/3)-2*z+(13/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 2 & -1 \\\\\n -1 & 3 & -5 \\\\\n 0 & -3 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-65$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, -1],\n [-1, 3, -5],\n [0, -3, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{4}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 10 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{15}{2} \\\\\n 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [10],\n [8]])\nprint(a * (3/4))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & -2 \\\\\n 5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$22$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2],\n [5, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{93}{32}, \\frac{69}{32}}$ to the line $\\frac{147 x}{32}-\\frac{9 y}{8}-\\frac{1}{2}=0$.", - "Output Answer": [ - "$\\frac{2135 \\sqrt{\\frac{5}{509}}}{96}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (93/32), (69/32)\nline = Poly(((147*x)/32)-((9*y)/8)-(1/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{16} \\\\\n \\frac{35}{4} \\\\\n -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 2 \\\\\n \\frac{117}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{153}{16} \\\\\n \\frac{43}{4} \\\\\n \\frac{109}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/16)],\n [(35/4)],\n [-(1/2)]])\nb = np.array([\n [10],\n [2],\n [(117/16)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{3} & 1 & \\frac{16}{3} \\\\\n -6 & -9 & 7 \\\\\n -\\frac{28}{3} & 10 & \\frac{26}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-12.532,8.266\\, -6.722 i,8.266\\, +6.722 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/3), 1, (16/3)],\n [-6, -9, 7],\n [-(28/3), 10, (26/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -5 & 2 & -9 & 10 & -9 \\\\\n -10 & 2 & 3 & 1 & 4 \\\\\n 8 & 9 & -5 & -4 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-265.,-1567.,-1288.,0.,1087.\\}, \\{537.,583.,1039.,1087.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, 2, -9, 10, -9],\n [-10, 2, 3, 1, 4],\n [8, 9, -5, -4, 9]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4]])\nb = np.array([\n [-8]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{5} \\\\\n \\frac{12}{5} \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{26}{5} \\\\\n -\\frac{59}{10} \\\\\n \\frac{19}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{2293}{50} \\\\\n \\frac{2181}{50} \\\\\n \\frac{497}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/5)],\n [(12/5)],\n [7]])\nb = np.array([\n [(26/5)],\n [-(59/10)],\n [(19/10)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{65}{7} & -\\frac{12}{7} & -10 \\\\\n \\frac{12}{7} & -\\frac{13}{7} & -\\frac{61}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{7} & -7 & -1 \\\\\n \\frac{30}{7} & \\frac{17}{7} & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{46}{7} & \\frac{37}{7} & -9 \\\\\n -\\frac{18}{7} & -\\frac{30}{7} & -\\frac{117}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(65/7), -(12/7), -10],\n [(12/7), -(13/7), -(61/7)]])\nb = np.array([\n [-(19/7), -7, -1],\n [(30/7), (17/7), 8]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{2} & 0 \\\\\n -\\frac{3}{2} & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{25}{4} & 0 \\\\\n -\\frac{9}{4} & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), 0],\n [-(3/2), -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{9}{4} \\\\\n -1 \\\\\n -\\frac{3}{4} \\\\\n \\frac{5}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{9}{\\sqrt{131}} \\\\\n -\\frac{4}{\\sqrt{131}} \\\\\n -\\frac{3}{\\sqrt{131}} \\\\\n \\frac{5}{\\sqrt{131}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/4)],\n [-1],\n [-(3/4)],\n [(5/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -2 & -3 & 1 & 2 & -2 \\\\\n -1 & 2 & 2 & 3 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -2 & 2 & -1 & -1 & 1 \\\\\n -2 & -3 & 0 & 0 & 2 \\\\\n -2 & -1 & 2 & 1 & 1 \\\\\n 1 & -1 & 0 & 2 & -2 \\\\\n 1 & 0 & 1 & 2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 8 & 2 & 2 & 3 & -9 \\\\\n -2 & -13 & 6 & 11 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, 1, 2, -2],\n [-1, 2, 2, 3, 1]])\nb = np.array([\n [-2, 2, -1, -1, 1],\n [-2, -3, 0, 0, 2],\n [-2, -1, 2, 1, 1],\n [1, -1, 0, 2, -2],\n [1, 0, 1, 2, -1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{573}{100} \\\\\n -\\frac{103}{50} \\\\\n -\\frac{32}{25} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{37}{50} \\\\\n -\\frac{9}{5} \\\\\n \\frac{82}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{5663}{625} \\\\\n \\frac{22309}{1250} \\\\\n \\frac{7399}{625} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(573/100)],\n [-(103/50)],\n [-(32/25)]])\nb = np.array([\n [(37/50)],\n [-(9/5)],\n [(82/25)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{35}{4} \\\\\n 4 \\\\\n \\frac{35}{4} \\\\\n -\\frac{35}{4} \\\\\n -\\frac{5}{2} \\\\\n \\frac{19}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{169}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(35/4)],\n [4],\n [(35/4)],\n [-(35/4)],\n [-(5/2)],\n [(19/2)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n -10 \\\\\n -1 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -6 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$79$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [-10],\n [-1],\n [7]])\nb = np.array([\n [-1],\n [-6],\n [-2],\n [1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 2 & 3 \\\\\n -3 & 3 & 1 \\\\\n 3 & 0 & 3 \\\\\n 3 & -3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.16 \\\\\n 1.15 \\\\\n -1.57 \\\\\n -1.3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.469 \\\\\n 0.147 \\\\\n 0.216 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, 3],\n [-3, 3, 1],\n [3, 0, 3],\n [3, -3, 3]])\nb = np.array([\n [2.16],\n [1.15],\n [-1.57],\n [-1.3]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -4 & 8 & 1 \\\\\n -7 & 0 & -1 \\\\\n -5 & -4 & -4 \\\\\n -9 & 10 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-4, 8, 1],\n [-7, 0, -1],\n [-5, -4, -4],\n [-9, 10, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -7 & -4 & 4 & 0 & -10 & -2 \\\\\n -8 & -3 & 9 & 2 & 9 & -1 \\\\\n 4 & -1 & -3 & 5 & -1 & 8 \\\\\n 4 & -6 & 8 & 1 & 3 & 2 \\\\\n -7 & -3 & -5 & -2 & -4 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & \\frac{2416}{33203} \\\\\n 0 & 1 & 0 & 0 & 0 & -\\frac{81371}{66406} \\\\\n 0 & 0 & 1 & 0 & 0 & -\\frac{60393}{66406} \\\\\n 0 & 0 & 0 & 1 & 0 & \\frac{26766}{33203} \\\\\n 0 & 0 & 0 & 0 & 1 & \\frac{9145}{33203} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, -4, 4, 0, -10, -2],\n [-8, -3, 9, 2, 9, -1],\n [4, -1, -3, 5, -1, 8],\n [4, -6, 8, 1, 3, 2],\n [-7, -3, -5, -2, -4, 5]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\pi \\\\\n -2 \\pi \\\\\n \\pi \\\\\n \\pi \\\\\n -2 \\pi \\\\\n -\\pi \\\\\n 2 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\pi \\\\\n -3 \\pi \\\\\n -3 \\pi \\\\\n 2 \\pi \\\\\n 3 \\pi \\\\\n -3 \\pi \\\\\n 3 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$12 \\pi ^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [2*math.pi],\n [-2*math.pi],\n [math.pi],\n [math.pi],\n [-2*math.pi],\n [-math.pi],\n [2*math.pi]])\nb = np.array([\n [2*math.pi],\n [-3*math.pi],\n [-3*math.pi],\n [2*math.pi],\n [3*math.pi],\n [-3*math.pi],\n [3*math.pi]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{25}{3} & -\\frac{59}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{32}{9} & -\\frac{62}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{107}{9} & -\\frac{121}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(25/3), -(59/9)]])\nb = np.array([\n [(32/9), -(62/9)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 3 & 3 & 3 \\\\\n 4 & 5 & 0 \\\\\n 5 & -3 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{8} & 0 & \\frac{1}{8} \\\\\n -\\frac{1}{10} & \\frac{1}{5} & -\\frac{1}{10} \\\\\n \\frac{37}{120} & -\\frac{1}{5} & -\\frac{1}{40} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3, 3],\n [4, 5, 0],\n [5, -3, -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 10 & 1 \\\\\n -9 & -8 \\\\\n -7 & -3 \\\\\n 10 & 4 \\\\\n 4 & 4 \\\\\n 9 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, 1],\n [-9, -8],\n [-7, -3],\n [10, 4],\n [4, 4],\n [9, -3]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 9 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [9],\n [-8]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 7 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -8 \\\\\n 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n -136 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [7],\n [0]])\nb = np.array([\n [8],\n [-8],\n [0]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -1 & -\\frac{4}{3} \\\\\n -\\frac{11}{3} & -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 3 & -\\frac{12}{11} \\\\\n -3 & \\frac{9}{11} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -(4/3)],\n [-(11/3), -(11/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 3 & -4 & 9 & 4 \\\\\n 3 & -1 & 5 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & \\frac{11}{9} & -\\frac{32}{9} \\\\\n 0 & 1 & -\\frac{4}{3} & -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, -4, 9, 4],\n [3, -1, 5, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -2 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -5 \\\\\n 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 21 \\\\\n 14 \\\\\n 19 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-2],\n [7]])\nb = np.array([\n [-3],\n [-5],\n [7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{3}{2 \\sqrt{10}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [1],\n [1],\n [-1],\n [0],\n [0],\n [-1],\n [1],\n [-1]]).squeeze()\nb = np.array([\n [0],\n [1],\n [0],\n [0],\n [0],\n [1],\n [1],\n [0],\n [-1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{3} & -2 \\\\\n \\frac{13}{3} & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{85}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/3), -2],\n [(13/3), -(1/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{3}{2}, -\\frac{7}{2}}$ to the line $\\frac{3 x}{2}-2 y=0$.", - "Output Answer": [ - "$\\frac{19}{10}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(3/2), -(7/2)\nline = Poly(((3*x)/2)-2*y, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & -2 & 0 & -2 \\\\\n -2 & -3 & -3 & 3 \\\\\n -3 & 0 & -3 & 0 \\\\\n -2 & 3 & 2 & -1 \\\\\n 2 & 1 & 1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.08 \\\\\n 1.68 \\\\\n -2.37 \\\\\n -2.92 \\\\\n 1.72 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.685 \\\\\n -0.66 \\\\\n 0.105 \\\\\n 0.234 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2, 0, -2],\n [-2, -3, -3, 3],\n [-3, 0, -3, 0],\n [-2, 3, 2, -1],\n [2, 1, 1, -1]])\nb = np.array([\n [1.08],\n [1.68],\n [-2.37],\n [-2.92],\n [1.72]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-3 \\log (2),-\\log (2),-4 \\log (2)\\}, \\{\\log (2),-4 \\log (2),-2 \\log (2)\\}, \\{4 \\log (2),\\log (2),3 \\log (2)\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{3}{\\sqrt{26}},-\\frac{1}{\\sqrt{26}},-2 \\sqrt{\\frac{2}{13}}\\right\\}, \\left\\{\\frac{53}{\\sqrt{12090}},-19 \\sqrt{\\frac{5}{2418}},-8 \\sqrt{\\frac{2}{6045}}\\right\\}, \\left\\{\\frac{14}{\\sqrt{465}},2 \\sqrt{\\frac{5}{93}},-\\frac{13}{\\sqrt{465}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-3*math.log(2), -math.log(2), -4*math.log(2)), (math.log(2), -4*math.log(2), -2*math.log(2)), (4*math.log(2), math.log(2), 3*math.log(2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & -10 & -8 \\\\\n -\\frac{5}{2} & -\\frac{1}{2} & \\frac{11}{2} \\\\\n -\\frac{11}{2} & -9 & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-1.629-4.639 i,-1.629+4.639 i,10.258\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -10, -8],\n [-(5/2), -(1/2), (11/2)],\n [-(11/2), -9, (7/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -2 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -6 \\\\\n -6 \\\\\n 3 \\\\\n 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-2],\n [1],\n [1]])\nb = np.array([\n [3]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & -3 \\\\\n -2 & -1 \\\\\n 1 & 2 \\\\\n 1 & 1 \\\\\n -2 & -2 \\\\\n -3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.38 \\\\\n -1.06 \\\\\n -0.01 \\\\\n 2.51 \\\\\n -2.44 \\\\\n 2.76 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.071 \\\\\n 0.859 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3],\n [-2, -1],\n [1, 2],\n [1, 1],\n [-2, -2],\n [-3, 3]])\nb = np.array([\n [-2.38],\n [-1.06],\n [-0.01],\n [2.51],\n [-2.44],\n [2.76]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -3 \\\\\n 0 \\\\\n -10 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-3],\n [0],\n [-10],\n [-3]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{3} \\\\\n \\frac{26}{3} \\\\\n \\frac{2}{3} \\\\\n 6 \\\\\n -\\frac{20}{3} \\\\\n -\\frac{20}{3} \\\\\n \\frac{14}{3} \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{26}{3} \\\\\n -\\frac{20}{3} \\\\\n \\frac{20}{3} \\\\\n -\\frac{22}{3} \\\\\n \\frac{28}{3} \\\\\n -\\frac{14}{3} \\\\\n -\\frac{1}{3} \\\\\n -\\frac{20}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{7234}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/3)],\n [(26/3)],\n [(2/3)],\n [6],\n [-(20/3)],\n [-(20/3)],\n [(14/3)],\n [-6]])\nb = np.array([\n [-(26/3)],\n [-(20/3)],\n [(20/3)],\n [-(22/3)],\n [(28/3)],\n [-(14/3)],\n [-(1/3)],\n [-(20/3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{1}{3},-3,-\\frac{11}{3}\\right\\}, \\left\\{\\frac{1}{3},\\frac{10}{3},-3\\right\\}, \\left\\{-\\frac{11}{3},-\\frac{13}{3},-\\frac{10}{3}\\right\\}}$.", - "Output Answer": [ - "$81 x-66 y+546 z+1831=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(1/3), -3, -(11/3)],\n [(1/3), (10/3), -3],\n [-(11/3), -(13/3), -(10/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{4} & -\\frac{19}{2} & -\\frac{3}{2} \\\\\n 4 & \\frac{9}{4} & \\frac{11}{2} \\\\\n \\frac{13}{4} & \\frac{25}{4} & \\frac{17}{4} \\\\\n \\frac{27}{4} & -9 & -\\frac{37}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{2} & -3 & -2 \\\\\n \\frac{9}{2} & -\\frac{11}{2} & \\frac{5}{2} \\\\\n -1 & -\\frac{19}{2} & -\\frac{33}{4} \\\\\n \\frac{9}{2} & -\\frac{29}{4} & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{4} & -\\frac{13}{2} & \\frac{1}{2} \\\\\n -\\frac{1}{2} & \\frac{31}{4} & 3 \\\\\n \\frac{17}{4} & \\frac{63}{4} & \\frac{25}{2} \\\\\n \\frac{9}{4} & -\\frac{7}{4} & -\\frac{57}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/4), -(19/2), -(3/2)],\n [4, (9/4), (11/2)],\n [(13/4), (25/4), (17/4)],\n [(27/4), -9, -(37/4)]])\nb = np.array([\n [-(3/2), -3, -2],\n [(9/2), -(11/2), (5/2)],\n [-1, -(19/2), -(33/4)],\n [(9/2), -(29/4), 5]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & 2 \\\\\n -3 & 1 \\\\\n 1 & -2 \\\\\n -1 & -3 \\\\\n -2 & -1 \\\\\n -3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.87 \\\\\n -0.13 \\\\\n 2.17 \\\\\n -2.11 \\\\\n 0.79 \\\\\n -1.72 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.511 \\\\\n -0.053 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2],\n [-3, 1],\n [1, -2],\n [-1, -3],\n [-2, -1],\n [-3, -2]])\nb = np.array([\n [-2.87],\n [-0.13],\n [2.17],\n [-2.11],\n [0.79],\n [-1.72]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -7 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -6 \\\\\n 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -67 \\\\\n -42 \\\\\n 16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-7],\n [-10]])\nb = np.array([\n [4],\n [-6],\n [1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 4 & -6 \\\\\n -4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, -6],\n [-4, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{13}{3}, \\frac{7}{3}, -\\frac{8}{3}}$ to the plane $\\frac{x}{3}-\\frac{4 y}{3}-\\frac{14 z}{3}+\\frac{11}{3}=0$.", - "Output Answer": [ - "$\\frac{104}{3 \\sqrt{213}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(13/3), (7/3), -(8/3)\nplane = Poly((x/3)-((4*y)/3)-((14*z)/3)+(11/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{1}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{22}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/3)]])\nb = np.array([\n [7]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 2 & -3 & 10 & -9 & 10 \\\\\n 8 & 7 & 0 & 1 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-44.,34.,0.,0.,19.\\}, \\{-35.,40.,19.,0.,0.\\}, \\{30.,-37.,0.,19.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, -3, 10, -9, 10],\n [8, 7, 0, 1, 6]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{2} \\\\\n -\\frac{79}{8} \\\\\n -\\frac{51}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{8} \\\\\n \\frac{17}{4} \\\\\n -\\frac{19}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 74 \\\\\n -\\frac{1819}{64} \\\\\n -\\frac{3497}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/2)],\n [-(79/8)],\n [-(51/8)]])\nb = np.array([\n [-(15/8)],\n [(17/4)],\n [-(19/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -\\frac{19}{3} \\\\\n -\\frac{17}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{3} \\\\\n -\\frac{17}{3} \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{631}{9} \\\\\n \\frac{520}{9} \\\\\n \\frac{421}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-(19/3)],\n [-(17/3)]])\nb = np.array([\n [-(2/3)],\n [-(17/3)],\n [6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{10}{7},-\\frac{4}{7},-3\\right\\}, \\left\\{\\frac{1}{7},-\\frac{20}{7},\\frac{19}{7}\\right\\}, \\left\\{2,\\frac{8}{7},-\\frac{9}{7}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{10}{\\sqrt{557}},-\\frac{4}{\\sqrt{557}},-\\frac{21}{\\sqrt{557}}\\right\\}, \\left\\{\\frac{3647}{\\sqrt{183226821}},-\\frac{12376}{\\sqrt{183226821}},\\frac{4094}{\\sqrt{183226821}}\\right\\}, \\left\\{\\frac{496}{\\sqrt{328953}},\\frac{211}{\\sqrt{328953}},\\frac{196}{\\sqrt{328953}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack((((10/7), -(4/7), -3), ((1/7), -(20/7), (19/7)), (2, (8/7), -(9/7))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -8 & -6 & -6 \\\\\n 3 & 3 & -1 \\\\\n 3 & -6 & 0 \\\\\n -7 & 0 & -5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 0 & 8 & -6 \\\\\n 9 & -5 & -5 \\\\\n -7 & -4 & -8 \\\\\n 2 & 9 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -8 & -14 & 0 \\\\\n -6 & 8 & 4 \\\\\n 10 & -2 & 8 \\\\\n -9 & -9 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -6, -6],\n [3, 3, -1],\n [3, -6, 0],\n [-7, 0, -5]])\nb = np.array([\n [0, 8, -6],\n [9, -5, -5],\n [-7, -4, -8],\n [2, 9, -4]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 0 & 1 & 3 \\\\\n -4 & -5 & -2 \\\\\n 4 & 3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{11}{12} & \\frac{5}{6} & \\frac{13}{12} \\\\\n -1 & -1 & -1 \\\\\n \\frac{2}{3} & \\frac{1}{3} & \\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 3],\n [-4, -5, -2],\n [4, 3, -1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -\\frac{17}{2} \\\\\n -5 \\\\\n -\\frac{5}{2} \\\\\n 3 \\\\\n \\frac{11}{2} \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{17}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-(17/2)],\n [-5],\n [-(5/2)],\n [3],\n [(11/2)],\n [-7]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\pi \\\\\n 3 \\pi \\\\\n \\pi \\\\\n -2 \\pi \\\\\n -2 \\pi \\\\\n -\\pi \\\\\n -\\pi \\\\\n -3 \\pi \\\\\n -3 \\pi \\\\\n -3 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\pi \\\\\n -3 \\pi \\\\\n -3 \\pi \\\\\n \\pi \\\\\n 2 \\pi \\\\\n \\pi \\\\\n 2 \\pi \\\\\n -\\pi \\\\\n -3 \\pi \\\\\n \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{14} \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.pi],\n [3*math.pi],\n [math.pi],\n [-2*math.pi],\n [-2*math.pi],\n [-math.pi],\n [-math.pi],\n [-3*math.pi],\n [-3*math.pi],\n [-3*math.pi]])\nb = np.array([\n [-3*math.pi],\n [-3*math.pi],\n [-3*math.pi],\n [math.pi],\n [2*math.pi],\n [math.pi],\n [2*math.pi],\n [-math.pi],\n [-3*math.pi],\n [math.pi]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{12}{5},-\\frac{6}{5}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-2]]).squeeze()\nb = np.array([\n [-2],\n [-1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{3}{2} & 1 & -\\frac{11}{5} & \\frac{1}{2} & -\\frac{7}{10} \\\\\n -\\frac{13}{5} & \\frac{17}{10} & -2 & -\\frac{7}{10} & 2 \\\\\n -3 & -\\frac{29}{10} & -\\frac{13}{10} & -\\frac{29}{10} & -\\frac{9}{10} \\\\\n 0 & \\frac{2}{5} & -\\frac{23}{10} & \\frac{1}{5} & \\frac{3}{5} \\\\\n \\frac{6}{5} & \\frac{1}{5} & \\frac{29}{10} & \\frac{19}{10} & \\frac{27}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & -\\frac{21}{10} \\\\\n \\frac{23}{10} & \\frac{4}{5} \\\\\n \\frac{3}{5} & \\frac{7}{5} \\\\\n \\frac{4}{5} & -\\frac{2}{5} \\\\\n -3 & \\frac{29}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{573}{100} & -\\frac{383}{50} \\\\\n -\\frac{31}{4} & \\frac{101}{10} \\\\\n -\\frac{1157}{100} & \\frac{71}{100} \\\\\n -\\frac{21}{10} & -\\frac{31}{25} \\\\\n -\\frac{129}{50} & \\frac{877}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), 1, -(11/5), (1/2), -(7/10)],\n [-(13/5), (17/10), -2, -(7/10), 2],\n [-3, -(29/10), -(13/10), -(29/10), -(9/10)],\n [0, (2/5), -(23/10), (1/5), (3/5)],\n [(6/5), (1/5), (29/10), (19/10), (27/10)]])\nb = np.array([\n [(3/2), -(21/10)],\n [(23/10), (4/5)],\n [(3/5), (7/5)],\n [(4/5), -(2/5)],\n [-3, (29/10)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4.559 \\\\\n 6.366 \\\\\n -6.349 \\\\\n 4.42 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6.477 \\\\\n -2.537 \\\\\n 2.024 \\\\\n -4.777 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$18.8613$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4.559],\n [6.366],\n [-6.349],\n [4.42]])\nb = np.array([\n [-6.477],\n [-2.537],\n [2.024],\n [-4.777]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{59}{8} & -\\frac{13}{4} & \\frac{13}{2} & -\\frac{45}{8} \\\\\n -\\frac{11}{4} & \\frac{23}{8} & -\\frac{29}{4} & \\frac{23}{8} \\\\\n -\\frac{19}{8} & \\frac{5}{8} & 9 & \\frac{39}{8} \\\\\n \\frac{5}{8} & -\\frac{57}{8} & -\\frac{65}{8} & \\frac{61}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 7 & 4 & -\\frac{51}{8} & -\\frac{67}{8} \\\\\n -\\frac{35}{4} & -9 & -\\frac{15}{2} & \\frac{61}{8} \\\\\n \\frac{25}{4} & -\\frac{57}{8} & \\frac{67}{8} & -6 \\\\\n -\\frac{61}{8} & \\frac{17}{2} & -\\frac{5}{4} & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{3}{8} & -\\frac{29}{4} & \\frac{103}{8} & \\frac{11}{4} \\\\\n 6 & \\frac{95}{8} & \\frac{1}{4} & -\\frac{19}{4} \\\\\n -\\frac{69}{8} & \\frac{31}{4} & \\frac{5}{8} & \\frac{87}{8} \\\\\n \\frac{33}{4} & -\\frac{125}{8} & -\\frac{55}{8} & -\\frac{11}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(59/8), -(13/4), (13/2), -(45/8)],\n [-(11/4), (23/8), -(29/4), (23/8)],\n [-(19/8), (5/8), 9, (39/8)],\n [(5/8), -(57/8), -(65/8), (61/8)]])\nb = np.array([\n [7, 4, -(51/8), -(67/8)],\n [-(35/4), -9, -(15/2), (61/8)],\n [(25/4), -(57/8), (67/8), -6],\n [-(61/8), (17/2), -(5/4), 9]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{4}{5} \\\\\n \\frac{13}{5} \\\\\n -\\frac{1}{5} \\\\\n \\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{2 \\sqrt{\\frac{2}{5}}}{5} \\\\\n \\frac{13}{5 \\sqrt{10}} \\\\\n -\\frac{1}{5 \\sqrt{10}} \\\\\n \\frac{4 \\sqrt{\\frac{2}{5}}}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/5)],\n [(13/5)],\n [-(1/5)],\n [(8/5)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & 2 \\\\\n -2 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(5-3 \\sqrt{17}\\right),\\frac{1}{2} \\left(5+3 \\sqrt{17}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 2],\n [-2, 9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 5 & \\frac{29}{6} & \\frac{11}{6} \\\\\n \\frac{13}{6} & \\frac{2}{3} & \\frac{7}{3} \\\\\n -\\frac{4}{3} & -\\frac{25}{6} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{181}{12}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, (29/6), (11/6)],\n [(13/6), (2/3), (7/3)],\n [-(4/3), -(25/6), (1/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{13}{5}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & -7 & -6 & -6 \\\\\n -9 & 9 & 1 & 6 \\\\\n 0 & -9 & -7 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 0 & -\\frac{91}{5} & -\\frac{78}{5} & -\\frac{78}{5} \\\\\n -\\frac{117}{5} & \\frac{117}{5} & \\frac{13}{5} & \\frac{78}{5} \\\\\n 0 & -\\frac{117}{5} & -\\frac{91}{5} & 13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -7, -6, -6],\n [-9, 9, 1, 6],\n [0, -9, -7, 5]])\nprint(a * (13/5))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -9 & -\\frac{39}{4} \\\\\n -\\frac{27}{4} & \\frac{19}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{x}{2}-\\frac{2421}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -(39/4)],\n [-(27/4), (19/2)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -2 \\\\\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -7 \\\\\n 36 \\\\\n 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-1],\n [1]])\nb = np.array([\n [0],\n [-2],\n [9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{1}{2},-\\frac{5}{2},-\\frac{7}{2}\\right\\}, \\left\\{-\\frac{1}{2},\\frac{3}{2},1\\right\\}, \\left\\{\\frac{5}{2},-\\frac{7}{2},\\frac{9}{2}\\right\\}}$.", - "Output Answer": [ - "$146 x+68 y-28 z-1=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(1/2), -(5/2), -(7/2)],\n [-(1/2), (3/2), 1],\n [(5/2), -(7/2), (9/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 2 & 4 & 5 \\\\\n 7 & -4 & -8 \\\\\n -7 & -3 & 8 \\\\\n -7 & -3 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, 4, 5],\n [7, -4, -8],\n [-7, -3, 8],\n [-7, -3, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-4, \\frac{11}{5}}$ to the line $\\frac{4 x}{5}-\\frac{2 y}{5}-\\frac{14}{5}=0$.", - "Output Answer": [ - "$\\frac{86}{5 \\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -4, (11/5)\nline = Poly(((4*x)/5)-((2*y)/5)-(14/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 7 & -6 \\\\\n -8 & -8 \\\\\n -2 & 6 \\\\\n 0 & -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 5 & -3 \\\\\n -10 & 0 \\\\\n 4 & 6 \\\\\n -10 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 12 & -9 \\\\\n -18 & -8 \\\\\n 2 & 12 \\\\\n -10 & -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -6],\n [-8, -8],\n [-2, 6],\n [0, -4]])\nb = np.array([\n [5, -3],\n [-10, 0],\n [4, 6],\n [-10, -4]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{49}{8} & -\\frac{107}{16} & -\\frac{137}{16} \\\\\n -\\frac{13}{8} & -\\frac{121}{16} & \\frac{27}{16} \\\\\n -\\frac{15}{8} & \\frac{9}{8} & -\\frac{9}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{57 x^2}{4}-\\frac{6451 x}{256}+\\frac{76755}{512}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(49/8), -(107/16), -(137/16)],\n [-(13/8), -(121/16), (27/16)],\n [-(15/8), (9/8), -(9/16)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & -1 & 1 & 2 \\\\\n -2 & 1 & 0 & -2 \\\\\n -1 & 1 & 1 & 0 \\\\\n -1 & 2 & 2 & 3 \\\\\n 2 & 1 & 3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.17 \\\\\n -1.3 \\\\\n 2.12 \\\\\n -2.5 \\\\\n -0.95 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.183 \\\\\n 0.38 \\\\\n -0.726 \\\\\n -0.289 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1, 1, 2],\n [-2, 1, 0, -2],\n [-1, 1, 1, 0],\n [-1, 2, 2, 3],\n [2, 1, 3, -2]])\nb = np.array([\n [-2.17],\n [-1.3],\n [2.12],\n [-2.5],\n [-0.95]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & -2 & -2 & -2 \\\\\n 0 & -1 & 1 & -3 \\\\\n -1 & -2 & -2 & 3 \\\\\n 3 & -3 & 0 & -2 \\\\\n -2 & -1 & 0 & -1 \\\\\n -2 & -2 & -3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.1 \\\\\n -1.04 \\\\\n -2.3 \\\\\n 1.01 \\\\\n -0.85 \\\\\n -1.48 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.409 \\\\\n 0.415 \\\\\n -0.148 \\\\\n -0.253 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2, -2, -2],\n [0, -1, 1, -3],\n [-1, -2, -2, 3],\n [3, -3, 0, -2],\n [-2, -1, 0, -1],\n [-2, -2, -3, -2]])\nb = np.array([\n [-0.1],\n [-1.04],\n [-2.3],\n [1.01],\n [-0.85],\n [-1.48]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{4} & \\frac{13}{2} \\\\\n \\frac{35}{4} & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{70} \\left(-33-\\sqrt{4729}\\right),1\\right\\}, \\left\\{\\frac{1}{70} \\left(\\sqrt{4729}-33\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/4), (13/2)],\n [(35/4), 8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${1, -5, -4}$ to the plane $-x+y+2 z-2=0$.", - "Output Answer": [ - "$8 \\sqrt{\\frac{2}{3}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 1, -5, -4\nplane = Poly(-x+y+2*z-2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{2}{3},\\frac{14}{3},-\\frac{7}{3}\\right\\}, \\left\\{\\frac{8}{3},\\frac{4}{3},-\\frac{7}{3}\\right\\}, \\left\\{\\frac{2}{3},-2,3\\right\\}}$.", - "Output Answer": [ - "$3 (x+y+z)-5=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(2/3), (14/3), -(7/3)],\n [(8/3), (4/3), -(7/3)],\n [(2/3), -2, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{8}{3} & 2 & \\frac{8}{3} & -\\frac{5}{3} & -\\frac{4}{3} \\\\\n -\\frac{5}{3} & \\frac{7}{3} & -\\frac{4}{3} & 1 & \\frac{5}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n \\frac{2}{3} & -\\frac{7}{3} & -1 & \\frac{7}{3} & \\frac{5}{3} \\\\\n 1 & -\\frac{5}{3} & -3 & -2 & 0 \\\\\n -\\frac{4}{3} & -3 & \\frac{4}{3} & \\frac{7}{3} & -3 \\\\\n -\\frac{7}{3} & 0 & \\frac{1}{3} & 0 & \\frac{8}{3} \\\\\n 3 & -2 & \\frac{7}{3} & -\\frac{5}{3} & \\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n \\frac{1}{9} & -\\frac{134}{9} & -\\frac{79}{9} & \\frac{32}{3} & -\\frac{92}{9} \\\\\n \\frac{17}{3} & \\frac{2}{3} & -\\frac{26}{9} & -\\frac{130}{9} & \\frac{20}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(8/3), 2, (8/3), -(5/3), -(4/3)],\n [-(5/3), (7/3), -(4/3), 1, (5/3)]])\nb = np.array([\n [(2/3), -(7/3), -1, (7/3), (5/3)],\n [1, -(5/3), -3, -2, 0],\n [-(4/3), -3, (4/3), (7/3), -3],\n [-(7/3), 0, (1/3), 0, (8/3)],\n [3, -2, (7/3), -(5/3), (5/3)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -5 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 7 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1 \\\\\n 2 \\\\\n -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-5],\n [-6]])\nb = np.array([\n [3],\n [7],\n [-2]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{4,0,-4\\}, \\{-4,5,2\\}, \\{5,-1,0\\}}$.", - "Output Answer": [ - "$26 x+38 y+3 z-92=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, 0, -4],\n [-4, 5, 2],\n [5, -1, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -3 & 3 & -1 \\\\\n 2 & 0 & 2 \\\\\n 0 & 3 & -1 \\\\\n 1 & -1 & 3 \\\\\n 0 & -1 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -7 \\\\\n 2 \\\\\n -7 \\\\\n 5 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 3, -1],\n [2, 0, 2],\n [0, 3, -1],\n [1, -1, 3],\n [0, -1, -2]])\nb = np.array([\n [0],\n [-2],\n [1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -3 & 9 & 2 & -3 & 6 \\\\\n -1 & -5 & 4 & -10 & -6 \\\\\n 6 & 8 & -7 & -6 & -2 \\\\\n 10 & 0 & 1 & -10 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{2735.,-6331.,-3810.,-4548.,9860.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, 9, 2, -3, 6],\n [-1, -5, 4, -10, -6],\n [6, 8, -7, -6, -2],\n [10, 0, 1, -10, -7]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{ccc}\n 1 & -2 & 2 \\\\\n -2 & 1 & -2 \\\\\n -2 & 2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n e & \\frac{1-e^2}{e} & \\frac{e^2-1}{e} \\\\\n \\frac{1-e^2}{e} & e & \\frac{1-e^2}{e} \\\\\n \\frac{1-e^2}{e} & \\frac{e^2-1}{e} & \\frac{2-e^2}{e} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [1, -2, 2],\n [-2, 1, -2],\n [-2, 2, -3]])\nprint(expm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 0 & 10 & -9 & 1 \\\\\n 3 & -4 & 10 & -6 \\\\\n -2 & 1 & -1 & 10 \\\\\n 3 & -3 & -5 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, 10, -9, 1],\n [3, -4, 10, -6],\n [-2, 1, -1, 10],\n [3, -3, -5, -10]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & -2 & 3 & 1 \\\\\n 0 & -3 & -3 & -3 \\\\\n -2 & 0 & 1 & -1 \\\\\n 3 & 0 & -3 & 3 \\\\\n 3 & 2 & 3 & 2 \\\\\n 2 & 0 & 1 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.35 \\\\\n 1.24 \\\\\n 1.7 \\\\\n -1.09 \\\\\n 0.33 \\\\\n -1.49 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.337 \\\\\n -0.1 \\\\\n 0.038 \\\\\n 0.032 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2, 3, 1],\n [0, -3, -3, -3],\n [-2, 0, 1, -1],\n [3, 0, -3, 3],\n [3, 2, 3, 2],\n [2, 0, 1, -3]])\nb = np.array([\n [-0.35],\n [1.24],\n [1.7],\n [-1.09],\n [0.33],\n [-1.49]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -8 & 5 & 2 & -5 \\\\\n 10 & 5 & -8 & -7 \\\\\n 5 & 6 & 2 & 7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -1 & 5 & 5 & -1 \\\\\n -7 & 9 & -1 & -7 \\\\\n -3 & 4 & -7 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -7 & 0 & -3 & -4 \\\\\n 17 & -4 & -7 & 0 \\\\\n 8 & 2 & 9 & 15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 5, 2, -5],\n [10, 5, -8, -7],\n [5, 6, 2, 7]])\nb = np.array([\n [-1, 5, 5, -1],\n [-7, 9, -1, -7],\n [-3, 4, -7, -8]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{7} \\\\\n -\\frac{3}{7} \\\\\n -\\frac{11}{7} \\\\\n \\frac{3}{7} \\\\\n 0 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{4}{3 \\sqrt{39}} \\\\\n -\\frac{1}{\\sqrt{39}} \\\\\n -\\frac{11}{3 \\sqrt{39}} \\\\\n \\frac{1}{\\sqrt{39}} \\\\\n 0 \\\\\n -\\frac{14}{3 \\sqrt{39}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/7)],\n [-(3/7)],\n [-(11/7)],\n [(3/7)],\n [0],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{49}{9} \\\\\n \\frac{20}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{22}{3} \\\\\n \\frac{38}{9} \\\\\n -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{22}{3} \\\\\n \\frac{29}{3} \\\\\n \\frac{14}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [(49/9)],\n [(20/9)]])\nb = np.array([\n [(22/3)],\n [(38/9)],\n [-(2/3)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{13}{2} & -4 \\\\\n \\frac{27}{4} & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{9} \\left(-1-i \\sqrt{47}\\right),1\\right\\}, \\left\\{\\frac{1}{9} \\left(-1+i \\sqrt{47}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/2), -4],\n [(27/4), -5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{15}{4} & \\frac{7}{2} & -\\frac{1}{8} \\\\\n -\\frac{15}{4} & -\\frac{25}{8} & -\\frac{23}{8} \\\\\n \\frac{1}{8} & \\frac{9}{2} & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{192}{9497} & -\\frac{2784}{9497} & -\\frac{1784}{9497} \\\\\n \\frac{8456}{28491} & \\frac{8648}{28491} & \\frac{1920}{9497} \\\\\n -\\frac{8440}{28491} & -\\frac{8416}{28491} & \\frac{240}{9497} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/4), (7/2), -(1/8)],\n [-(15/4), -(25/8), -(23/8)],\n [(1/8), (9/2), (9/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,0,-2\\}, \\{-1,-2,0\\}, \\{2,1,1\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{2}},0,-\\frac{1}{\\sqrt{2}}\\right\\}, \\left\\{-\\frac{1}{3 \\sqrt{2}},-\\frac{2 \\sqrt{2}}{3},-\\frac{1}{3 \\sqrt{2}}\\right\\}, \\left\\{\\frac{2}{3},-\\frac{1}{3},\\frac{2}{3}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, 0, -2), (-1, -2, 0), (2, 1, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{64}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & 9 & -2 \\\\\n -4 & 7 & -1 \\\\\n 7 & -9 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{32} & \\frac{63}{64} & -\\frac{7}{32} \\\\\n -\\frac{7}{16} & \\frac{49}{64} & -\\frac{7}{64} \\\\\n \\frac{49}{64} & -\\frac{63}{64} & -\\frac{7}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 9, -2],\n [-4, 7, -1],\n [7, -9, -2]])\nprint(a * (7/64))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,2,-3\\}, \\{3,3,0\\}, \\{-3,-2,1\\}}$", - "Output Answer": [ - "${\\left\\{0,\\frac{2}{\\sqrt{13}},-\\frac{3}{\\sqrt{13}}\\right\\}, \\left\\{\\sqrt{\\frac{13}{22}},\\frac{9}{\\sqrt{286}},3 \\sqrt{\\frac{2}{143}}\\right\\}, \\left\\{-\\frac{3}{\\sqrt{22}},\\frac{3}{\\sqrt{22}},\\sqrt{\\frac{2}{11}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, 2, -3), (3, 3, 0), (-3, -2, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -7 \\\\\n 0 \\\\\n 1 \\\\\n 6 \\\\\n -1 \\\\\n 9 \\\\\n -3 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -8 \\\\\n 6 \\\\\n 5 \\\\\n -7 \\\\\n 4 \\\\\n 9 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{131}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-7],\n [0],\n [1],\n [6],\n [-1],\n [9],\n [-3],\n [-7]])\nb = np.array([\n [10],\n [-8],\n [6],\n [5],\n [-7],\n [4],\n [9],\n [-3],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{2} & \\frac{17}{10} \\\\\n \\frac{8}{5} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{647}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), (17/10)],\n [(8/5), (3/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{8}{3},-\\frac{1}{3},-\\frac{7}{3}\\right\\}, \\left\\{\\frac{1}{3},\\frac{4}{3},-\\frac{1}{3}\\right\\}, \\left\\{\\frac{2}{3},-\\frac{14}{3},-\\frac{8}{3}\\right\\}}$.", - "Output Answer": [ - "$73 x+69 y-167 z-172=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(8/3), -(1/3), -(7/3)],\n [(1/3), (4/3), -(1/3)],\n [(2/3), -(14/3), -(8/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & -6 \\\\\n -8 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-12 x-13$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -6],\n [-8, 5]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 0 & -2 & -3 \\\\\n 0 & 2 & 1 \\\\\n -2 & 1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -5 \\\\\n -1 \\\\\n 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2, -3],\n [0, 2, 1],\n [-2, 1, 2]])\nb = np.array([\n [0],\n [-2],\n [3]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 4 \\\\\n 5 \\\\\n 8 \\\\\n 9 \\\\\n -7 \\\\\n 10 \\\\\n -2 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n -9 \\\\\n -4 \\\\\n 5 \\\\\n -5 \\\\\n 6 \\\\\n -5 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{473}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [4],\n [5],\n [8],\n [9],\n [-7],\n [10],\n [-2],\n [-8]])\nb = np.array([\n [1],\n [-2],\n [-9],\n [-4],\n [5],\n [-5],\n [6],\n [-5],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{59}{7} \\\\\n \\frac{33}{7} \\\\\n -\\frac{47}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{32}{7} \\\\\n \\frac{40}{7} \\\\\n \\frac{47}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3431}{49} \\\\\n \\frac{611}{7} \\\\\n -\\frac{1304}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(59/7)],\n [(33/7)],\n [-(47/7)]])\nb = np.array([\n [-(32/7)],\n [(40/7)],\n [(47/7)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 5 & -\\frac{13}{8} & \\frac{15}{4} \\\\\n \\frac{7}{4} & \\frac{3}{2} & -\\frac{9}{8} \\\\\n 0 & -\\frac{9}{4} & \\frac{1}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{600}{6689} & \\frac{2108}{6689} & \\frac{972}{6689} \\\\\n \\frac{56}{6689} & -\\frac{160}{6689} & -\\frac{3120}{6689} \\\\\n \\frac{1008}{6689} & -\\frac{2880}{6689} & -\\frac{2648}{6689} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -(13/8), (15/4)],\n [(7/4), (3/2), -(9/8)],\n [0, -(9/4), (1/8)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{14}{5} & \\frac{18}{5} & \\frac{19}{5} \\\\\n -\\frac{8}{5} & -\\frac{19}{5} & \\frac{6}{5} \\\\\n 4 & \\frac{1}{5} & -\\frac{14}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{325}{893} & \\frac{1355}{3572} & \\frac{2345}{3572} \\\\\n \\frac{10}{893} & -\\frac{230}{893} & -\\frac{85}{893} \\\\\n \\frac{465}{893} & \\frac{935}{1786} & \\frac{1025}{1786} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(14/5), (18/5), (19/5)],\n [-(8/5), -(19/5), (6/5)],\n [4, (1/5), -(14/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n \\frac{2}{5} \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{26}{5} \\\\\n -1 \\\\\n \\frac{24}{5} \\\\\n -\\frac{28}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1153}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [(2/5)],\n [-9]])\nb = np.array([\n [(26/5)],\n [-1],\n [(24/5)],\n [-(28/5)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{3}{2},-\\frac{9}{2},\\frac{9}{2}\\right\\}, \\left\\{-\\frac{5}{2},-\\frac{7}{2},-4\\right\\}, \\left\\{0,3,\\frac{7}{2}\\right\\}}$.", - "Output Answer": [ - "$251 x-55 y-36 z+291=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(3/2), -(9/2), (9/2)],\n [-(5/2), -(7/2), -4],\n [0, 3, (7/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n i & 4 \\\\\n -2+2 i & 4 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -9+8 i & 20 i \\\\\n -10-10 i & -24+8 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1j, 4],\n [-2+2j, 4j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{557}{100} & -\\frac{236}{25} & -\\frac{3}{100} & -\\frac{3}{5} \\\\\n \\frac{353}{50} & -\\frac{291}{50} & -\\frac{789}{100} & -\\frac{171}{50} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{13}{2} & -\\frac{137}{20} & -\\frac{151}{20} & \\frac{563}{100} \\\\\n \\frac{727}{100} & -\\frac{203}{100} & \\frac{157}{100} & -\\frac{1}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{1207}{100} & -\\frac{1629}{100} & -\\frac{379}{50} & \\frac{503}{100} \\\\\n \\frac{1433}{100} & -\\frac{157}{20} & -\\frac{158}{25} & -\\frac{343}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(557/100), -(236/25), -(3/100), -(3/5)],\n [(353/50), -(291/50), -(789/100), -(171/50)]])\nb = np.array([\n [(13/2), -(137/20), -(151/20), (563/100)],\n [(727/100), -(203/100), (157/100), -(1/100)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{27}{8} & -\\frac{59}{16} & \\frac{157}{16} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{29}{4} & -8 & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{85}{8} & \\frac{69}{16} & \\frac{229}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(27/8), -(59/16), (157/16)]])\nb = np.array([\n [(29/4), -8, -(9/2)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -2 & -7 & -2 & 8 \\\\\n 0 & 5 & 1 & 1 \\\\\n -5 & -2 & 6 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & -\\frac{326}{79} \\\\\n 0 & 1 & 0 & \\frac{46}{79} \\\\\n 0 & 0 & 1 & -\\frac{151}{79} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, -7, -2, 8],\n [0, 5, 1, 1],\n [-5, -2, 6, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -1 & -5 \\\\\n -4 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+8 x-13$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -5],\n [-4, -7]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{11}{3}, -3, -\\frac{11}{3}}$ to the plane $-\\frac{7 x}{3}+\\frac{4 y}{3}+\\frac{13 z}{3}-\\frac{14}{3}=0$.", - "Output Answer": [ - "$8 \\sqrt{\\frac{2}{13}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(11/3), -3, -(11/3)\nplane = Poly(-((7*x)/3)+((4*y)/3)+((13*z)/3)-(14/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{8}{3},\\frac{2}{3},-1\\right\\}, \\left\\{-\\frac{2}{3},1,-\\frac{4}{3}\\right\\}, \\left\\{-3,2,\\frac{2}{3}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{8}{\\sqrt{77}},\\frac{2}{\\sqrt{77}},-\\frac{3}{\\sqrt{77}}\\right\\}, \\left\\{-\\frac{170}{\\sqrt{171633}},\\frac{227}{\\sqrt{171633}},-\\frac{302}{\\sqrt{171633}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{2229}},\\frac{38}{\\sqrt{2229}},\\frac{28}{\\sqrt{2229}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack((((8/3), (2/3), -1), (-(2/3), 1, -(4/3)), (-3, 2, (2/3))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{2} & -\\frac{20}{3} & \\frac{7}{6} \\\\\n \\frac{13}{6} & \\frac{43}{6} & \\frac{31}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2), -(20/3), (7/6)],\n [(13/6), (43/6), (31/6)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 0 \\\\\n 2 \\\\\n -6 \\\\\n -8 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -9 \\\\\n -8 \\\\\n 2 \\\\\n -6 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [0],\n [2],\n [-6],\n [-8],\n [7]])\nb = np.array([\n [3],\n [-9],\n [-8],\n [2],\n [-6],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -7 & 9 & -\\frac{11}{2} \\\\\n -7 & -\\frac{13}{2} & -\\frac{3}{2} \\\\\n 5 & -9 & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-4.987,-3.507-7.415 i,-3.507+7.415 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 9, -(11/2)],\n [-7, -(13/2), -(3/2)],\n [5, -9, (3/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{22}{3} \\\\\n -\\frac{13}{3} \\\\\n \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{22}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(22/3)],\n [-(13/3)],\n [(5/2)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 4 \\\\\n 10 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -3 \\\\\n -5 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-24$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [4],\n [10],\n [-8]])\nb = np.array([\n [3],\n [-3],\n [-5],\n [-1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 5 & -10 & -8 & 1 & 6 \\\\\n -7 & -10 & 4 & -8 & -4 \\\\\n 8 & 7 & 1 & -9 & 4 \\\\\n 10 & -7 & -10 & -6 & -7 \\\\\n 8 & 4 & 3 & 5 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, -10, -8, 1, 6],\n [-7, -10, 4, -8, -4],\n [8, 7, 1, -9, 4],\n [10, -7, -10, -6, -7],\n [8, 4, 3, 5, 5]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & 2 \\\\\n -3 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{6} \\left(-13-\\sqrt{145}\\right),1\\right\\}, \\left\\{\\frac{1}{6} \\left(\\sqrt{145}-13\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 2],\n [-3, -4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{4}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & -8 \\\\\n 4 & -9 \\\\\n 8 & 3 \\\\\n 5 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & -6 \\\\\n 3 & -\\frac{27}{4} \\\\\n 6 & \\frac{9}{4} \\\\\n \\frac{15}{4} & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -8],\n [4, -9],\n [8, 3],\n [5, -8]])\nprint(a * (3/4))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -4 & \\frac{2}{3} & -\\frac{7}{3} & \\frac{25}{6} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n \\frac{4}{3} & -\\frac{53}{6} & -\\frac{7}{3} & -\\frac{26}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{16}{3} & \\frac{19}{2} & 0 & \\frac{77}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, (2/3), -(7/3), (25/6)]])\nb = np.array([\n [(4/3), -(53/6), -(7/3), -(26/3)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & 4 & 3 \\\\\n -4 & 4 & 0 \\\\\n 1 & 0 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$20$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 4, 3],\n [-4, 4, 0],\n [1, 0, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -7 \\\\\n -5 \\\\\n -10 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-7],\n [-5],\n [-10],\n [2]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & -3 & -3 \\\\\n 0 & -2 & -1 \\\\\n 2 & -2 & -2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 18 & -24 & -12 \\\\\n 8 & -14 & -8 \\\\\n 0 & 8 & 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3, -3],\n [0, -2, -1],\n [2, -2, -2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -2 & 3 \\\\\n 2 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{5}{4} & -\\frac{3}{4} \\\\\n -\\frac{1}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 3],\n [2, -5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & \\frac{15}{2} & -\\frac{9}{2} \\\\\n -1 & 4 & -\\frac{1}{2} \\\\\n -\\frac{17}{2} & \\frac{15}{2} & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.462,-0.008,1.\\}, \\{1.184,0.229,1.\\}, \\{1.398,1.249,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, (15/2), -(9/2)],\n [-1, 4, -(1/2)],\n [-(17/2), (15/2), 5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{10}{3},-2,-\\frac{7}{3}\\right\\}, \\left\\{-1,0,\\frac{1}{3}\\right\\}, \\left\\{-\\frac{13}{3},-1,3\\right\\}}$.", - "Output Answer": [ - "$24 x+8 y+33 z+13=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(10/3), -2, -(7/3)],\n [-1, 0, (1/3)],\n [-(13/3), -1, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\sqrt{2},-\\sqrt{2},2 \\sqrt{2}\\right\\}, \\left\\{\\frac{1}{\\sqrt{2}},\\sqrt{2},-\\frac{3}{\\sqrt{2}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{2}},0,\\sqrt{2}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{6}},-\\frac{1}{\\sqrt{6}},\\sqrt{\\frac{2}{3}}\\right\\}, \\left\\{\\frac{13}{6 \\sqrt{2 \\left(\\frac{185}{72}+\\left(\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}\\right)^2\\right)}},\\frac{\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}}{\\sqrt{\\frac{185}{72}+\\left(\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}\\right)^2}},-\\frac{1}{3} \\sqrt{\\frac{2}{\\frac{185}{72}+\\left(\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}\\right)^2}}\\right\\}, \\left\\{\\frac{\\frac{1}{6 \\sqrt{2}}-\\frac{65}{72 \\sqrt{2} \\left(\\frac{185}{72}+\\left(\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}\\right)^2\\right)}}{\\sqrt{\\left(-\\frac{5}{3 \\sqrt{2}}+\\sqrt{2}+\\frac{5}{18 \\sqrt{2} \\left(\\frac{185}{72}+\\left(\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}\\right)^2\\right)}\\right)^2+\\left(\\frac{65}{72 \\sqrt{2} \\left(\\frac{185}{72}+\\left(\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}\\right)^2\\right)}-\\frac{1}{6 \\sqrt{2}}\\right)^2+\\left(\\frac{5}{6 \\sqrt{2}}-\\frac{5 \\left(\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}\\right)}{12 \\left(\\frac{185}{72}+\\left(\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}\\right)^2\\right)}\\right)^2}},\\frac{\\frac{5}{6 \\sqrt{2}}-\\frac{5 \\left(\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}\\right)}{12 \\left(\\frac{185}{72}+\\left(\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}\\right)^2\\right)}}{\\sqrt{\\left(-\\frac{5}{3 \\sqrt{2}}+\\sqrt{2}+\\frac{5}{18 \\sqrt{2} \\left(\\frac{185}{72}+\\left(\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}\\right)^2\\right)}\\right)^2+\\left(\\frac{65}{72 \\sqrt{2} \\left(\\frac{185}{72}+\\left(\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}\\right)^2\\right)}-\\frac{1}{6 \\sqrt{2}}\\right)^2+\\left(\\frac{5}{6 \\sqrt{2}}-\\frac{5 \\left(\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}\\right)}{12 \\left(\\frac{185}{72}+\\left(\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}\\right)^2\\right)}\\right)^2}},\\frac{-\\frac{5}{3 \\sqrt{2}}+\\sqrt{2}+\\frac{5}{18 \\sqrt{2} \\left(\\frac{185}{72}+\\left(\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}\\right)^2\\right)}}{\\sqrt{\\left(-\\frac{5}{3 \\sqrt{2}}+\\sqrt{2}+\\frac{5}{18 \\sqrt{2} \\left(\\frac{185}{72}+\\left(\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}\\right)^2\\right)}\\right)^2+\\left(\\frac{65}{72 \\sqrt{2} \\left(\\frac{185}{72}+\\left(\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}\\right)^2\\right)}-\\frac{1}{6 \\sqrt{2}}\\right)^2+\\left(\\frac{5}{6 \\sqrt{2}}-\\frac{5 \\left(\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}\\right)}{12 \\left(\\frac{185}{72}+\\left(\\sqrt{2}-\\frac{7}{6 \\sqrt{2}}\\right)^2\\right)}\\right)^2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((math.sqrt(2), -math.sqrt(2), 2*math.sqrt(2)), ((1/(math.sqrt(2))), math.sqrt(2), -(3/(math.sqrt(2)))), ((1/(math.sqrt(2))), 0, math.sqrt(2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & -2 \\\\\n 3 & 1 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.53 \\\\\n -2.48 \\\\\n 1.1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.829 \\\\\n 0.008 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2],\n [3, 1],\n [0, 1]])\nb = np.array([\n [0.53],\n [-2.48],\n [1.1]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 3 & -6 & 8 & -10 & -3 & 10 \\\\\n -9 & 1 & 10 & -10 & -5 & -6 \\\\\n -5 & 4 & -10 & 8 & 1 & 7 \\\\\n 1 & -4 & 2 & 3 & -2 & -5 \\\\\n 1 & 7 & -3 & 0 & -10 & -8 \\\\\n 5 & -6 & 3 & 1 & -6 & -9 \\\\\n 8 & 3 & 10 & 8 & 8 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, -6, 8, -10, -3, 10],\n [-9, 1, 10, -10, -5, -6],\n [-5, 4, -10, 8, 1, 7],\n [1, -4, 2, 3, -2, -5],\n [1, 7, -3, 0, -10, -8],\n [5, -6, 3, 1, -6, -9],\n [8, 3, 10, 8, 8, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{3}{7} & \\frac{27}{7} & -\\frac{48}{7} & -7 \\\\\n \\frac{27}{7} & \\frac{10}{7} & -\\frac{16}{7} & -\\frac{31}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{69}{7} & \\frac{31}{7} & \\frac{59}{7} & \\frac{44}{7} \\\\\n -8 & -6 & -\\frac{59}{7} & -\\frac{68}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{66}{7} & -\\frac{4}{7} & -\\frac{107}{7} & -\\frac{93}{7} \\\\\n \\frac{83}{7} & \\frac{52}{7} & \\frac{43}{7} & \\frac{37}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/7), (27/7), -(48/7), -7],\n [(27/7), (10/7), -(16/7), -(31/7)]])\nb = np.array([\n [-(69/7), (31/7), (59/7), (44/7)],\n [-8, -6, -(59/7), -(68/7)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -3 & 7 & -8 & -9 \\\\\n 5 & 5 & 8 & 4 \\\\\n 1 & 6 & 7 & -7 \\\\\n 4 & -5 & -3 & -5 \\\\\n 3 & -3 & 7 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 7, -8, -9],\n [5, 5, 8, 4],\n [1, 6, 7, -7],\n [4, -5, -3, -5],\n [3, -3, 7, 1]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & -\\frac{4}{5} & -\\frac{2}{5} \\\\\n -5 & -\\frac{21}{5} & -\\frac{11}{5} \\\\\n 0 & -\\frac{24}{5} & -\\frac{1}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{44}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -(4/5), -(2/5)],\n [-5, -(21/5), -(11/5)],\n [0, -(24/5), -(1/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 3 & -4 & 9 & -8 \\\\\n -7 & -1 & -4 & 0 \\\\\n -5 & 5 & -1 & 6 \\\\\n -2 & 9 & 8 & 2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 5 & 7 & -1 & -9 \\\\\n -3 & -3 & -1 & -7 \\\\\n -9 & -3 & 2 & 9 \\\\\n -4 & 9 & 5 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -2 & -11 & 10 & 1 \\\\\n -4 & 2 & -3 & 7 \\\\\n 4 & 8 & -3 & -3 \\\\\n 2 & 0 & 3 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -4, 9, -8],\n [-7, -1, -4, 0],\n [-5, 5, -1, 6],\n [-2, 9, 8, 2]])\nb = np.array([\n [5, 7, -1, -9],\n [-3, -3, -1, -7],\n [-9, -3, 2, 9],\n [-4, 9, 5, 6]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -6 \\\\\n 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [4]])\nb = np.array([\n [-8],\n [7]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-2],\n [-4]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{10}{9}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & 3 \\\\\n 2 & -1 \\\\\n -4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{10}{9} & -\\frac{10}{3} \\\\\n -\\frac{20}{9} & \\frac{10}{9} \\\\\n \\frac{40}{9} & \\frac{10}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3],\n [2, -1],\n [-4, -3]])\nprint(a * -(10/9))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 2 & -\\frac{41}{5} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{17}{5} & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{27}{5} & -\\frac{46}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(41/5)]])\nb = np.array([\n [-(17/5), 1]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, -1, 0}$ to the plane $5 x+z+5=0$.", - "Output Answer": [ - "$5 \\sqrt{\\frac{2}{13}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, -1, 0\nplane = Poly(5*x+z+5, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 8 & -8 & -2 \\\\\n 9 & 7 & 3 \\\\\n 6 & -1 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+14 x^2-128 x-146$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -8, -2],\n [9, 7, 3],\n [6, -1, -1]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & -\\frac{11}{2} \\\\\n 5 & -\\frac{19}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+8 x+\\frac{53}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), -(11/2)],\n [5, -(19/2)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 1 \\\\\n -7 \\\\\n -7 \\\\\n -7 \\\\\n 3 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 3 \\\\\n 4 \\\\\n 4 \\\\\n -1 \\\\\n -10 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{114}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [1],\n [-7],\n [-7],\n [-7],\n [3],\n [-5]])\nb = np.array([\n [-2],\n [3],\n [4],\n [4],\n [-1],\n [-10],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -3 e \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 e \\\\\n e \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-3 e^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [-3*math.e]])\nb = np.array([\n [3*math.e],\n [math.e]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 3 \\\\\n 9 \\\\\n 6 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -8 \\\\\n -6 \\\\\n 4 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-29$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [3],\n [9],\n [6],\n [1]])\nb = np.array([\n [-3],\n [-8],\n [-6],\n [4],\n [1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{3}{2},-2,\\frac{1}{2}\\right\\}, \\left\\{-3,-1,\\frac{3}{2}\\right\\}, \\{4,0,4\\}}$.", - "Output Answer": [ - "$6 x+73 y-46 z+160=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(3/2), -2, (1/2)],\n [-3, -1, (3/2)],\n [4, 0, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{26}{3} \\\\\n \\frac{20}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -\\frac{70}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{47}{3} \\\\\n -\\frac{10}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/3)],\n [(20/3)]])\nb = np.array([\n [7],\n [-(70/9)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 8 & -3 & 2 & 9 \\\\\n -9 & 9 & -6 & 1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -6 & 10 & -4 & 1 \\\\\n -1 & -7 & 9 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 14 & -13 & 6 & 8 \\\\\n -8 & 16 & -15 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -3, 2, 9],\n [-9, 9, -6, 1]])\nb = np.array([\n [-6, 10, -4, 1],\n [-1, -7, 9, -4]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 1 & 1 & 2 & -1 \\\\\n 0 & -1 & 2 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 0 & 0 & 0 & -1 \\\\\n 2 & 0 & -1 & 1 \\\\\n 1 & 1 & -3 & -2 \\\\\n -2 & 1 & 1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 6 & 1 & -8 & -6 \\\\\n 0 & 2 & -5 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1, 2, -1],\n [0, -1, 2, 0]])\nb = np.array([\n [0, 0, 0, -1],\n [2, 0, -1, 1],\n [1, 1, -3, -2],\n [-2, 1, 1, 2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -2 & -6 & -9 & -1 & -5 & -6 & 9 \\\\\n 4 & -1 & -3 & 5 & 3 & -10 & 2 \\\\\n 2 & -3 & -9 & 5 & 6 & 0 & -8 \\\\\n 3 & 10 & -2 & 4 & 5 & 1 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & -\\frac{1346}{305} & -\\frac{681}{61} & \\frac{3557}{305} \\\\\n 0 & 1 & 0 & 0 & \\frac{38}{305} & \\frac{34}{61} & -\\frac{211}{305} \\\\\n 0 & 0 & 1 & 0 & \\frac{567}{610} & \\frac{114}{61} & -\\frac{607}{305} \\\\\n 0 & 0 & 0 & 1 & \\frac{575}{122} & \\frac{498}{61} & -\\frac{626}{61} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, -6, -9, -1, -5, -6, 9],\n [4, -1, -3, 5, 3, -10, 2],\n [2, -3, -9, 5, 6, 0, -8],\n [3, 10, -2, 4, 5, 1, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{7}{2}, 2, -\\frac{5}{2}}$ to the plane $-\\frac{9 x}{2}-4 y-\\frac{7 z}{2}+\\frac{5}{2}=0$.", - "Output Answer": [ - "$\\frac{25}{\\sqrt{194}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (7/2), 2, -(5/2)\nplane = Poly(-((9*x)/2)-4*y-((7*z)/2)+(5/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{6}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & -5 \\\\\n 4 & -2 \\\\\n -8 & 0 \\\\\n -3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & \\frac{5}{6} \\\\\n -\\frac{2}{3} & \\frac{1}{3} \\\\\n \\frac{4}{3} & 0 \\\\\n \\frac{1}{2} & \\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -5],\n [4, -2],\n [-8, 0],\n [-3, -2]])\nprint(a * -(1/6))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${1, \\frac{9}{2}}$ to the line $-\\frac{3 x}{2}-2 y-3=0$.", - "Output Answer": [ - "$\\frac{27}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 1, (9/2)\nline = Poly(-((3*x)/2)-2*y-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{26}{3} & \\frac{8}{9} & \\frac{13}{3} & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{25}{9} & -7 & \\frac{71}{9} & -\\frac{79}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{53}{9} & -\\frac{55}{9} & \\frac{110}{9} & -\\frac{70}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(26/3), (8/9), (13/3), 1]])\nb = np.array([\n [(25/9), -7, (71/9), -(79/9)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -6 & -1 & -3 & 5 \\\\\n 5 & 3 & 9 & -4 \\\\\n 2 & -3 & 4 & 4 \\\\\n -5 & -7 & 8 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-6, -1, -3, 5],\n [5, 3, 9, -4],\n [2, -3, 4, 4],\n [-5, -7, 8, 10]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -7 \\\\\n -8 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -6 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$55$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-7],\n [-8],\n [8]])\nb = np.array([\n [5],\n [-6],\n [-1],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 5 & -5 & -3 & 5 & 6 & 2 & 6 \\\\\n 0 & -6 & -6 & 2 & -8 & -4 & -9 \\\\\n 0 & -7 & 9 & 8 & 8 & 2 & -4 \\\\\n -5 & 2 & -3 & 1 & -9 & -1 & 5 \\\\\n 6 & -10 & -2 & -10 & 1 & -3 & 9 \\\\\n -2 & -7 & -1 & -8 & -4 & -9 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & -\\frac{1210063}{215042} \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & -\\frac{264365}{107521} \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & -\\frac{360793}{107521} \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & -\\frac{529105}{215042} \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & \\frac{13002}{5659} \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & \\frac{553307}{107521} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, -5, -3, 5, 6, 2, 6],\n [0, -6, -6, 2, -8, -4, -9],\n [0, -7, 9, 8, 8, 2, -4],\n [-5, 2, -3, 1, -9, -1, 5],\n [6, -10, -2, -10, 1, -3, 9],\n [-2, -7, -1, -8, -4, -9, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{2}+i & -1+2 i & -2-\\frac{9 i}{2} \\\\\n 1+3 i & \\frac{1}{2}-2 i & -1-4 i \\\\\n \\frac{9}{2}+\\frac{3 i}{2} & -\\frac{5}{2}+\\frac{3 i}{2} & -\\frac{3}{2}+\\frac{5 i}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -8-\\frac{109 i}{4} & \\frac{59}{4}+\\frac{29 i}{4} & \\frac{123}{4}+\\frac{17 i}{2} \\\\\n \\frac{7}{2}-\\frac{47 i}{2} & -\\frac{9}{4}+\\frac{11 i}{2} & \\frac{29}{2}-7 i \\\\\n -\\frac{103}{4}+\\frac{21 i}{4} & -\\frac{23}{4}+\\frac{19 i}{4} & \\frac{9}{4}-\\frac{89 i}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2)+ 1j, -1+2j, -2-((9j)/2)],\n [1+3j, (1/2)-2j, -1-4j],\n [(9/2)+((3j)/2), -(5/2)+((3j)/2), -(3/2)+((5j)/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{4}{5} & -\\frac{27}{5} \\\\\n -\\frac{3}{5} & -\\frac{18}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{3} \\left(-7-\\sqrt{130}\\right),1\\right\\}, \\left\\{\\frac{1}{3} \\left(\\sqrt{130}-7\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/5), -(27/5)],\n [-(3/5), -(18/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{2} & -5 & \\frac{9}{2} \\\\\n 0 & -\\frac{13}{2} & -\\frac{13}{2} \\\\\n -2 & 8 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{17.263,1.965,1.\\}, \\{0.721\\, -0.23 i,-0.769+0.202 i,1.\\}, \\{0.721\\, +0.23 i,-0.769-0.202 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/2), -5, (9/2)],\n [0, -(13/2), -(13/2)],\n [-2, 8, 9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{127}{16} \\\\\n \\frac{31}{16} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{149}{16} \\\\\n \\frac{59}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{69}{4} \\\\\n -\\frac{87}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(127/16)],\n [(31/16)]])\nb = np.array([\n [-(149/16)],\n [(59/8)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{16}{\\sqrt{697}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [8]]).squeeze()\nb = np.array([\n [4],\n [5]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{43}{16} & \\frac{1}{2} & \\frac{21}{8} \\\\\n -\\frac{39}{4} & -3 & -\\frac{123}{16} \\\\\n -\\frac{37}{16} & -\\frac{39}{16} & -\\frac{97}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{51 x^2}{8}+\\frac{1787 x}{128}+\\frac{90225}{4096}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(43/16), (1/2), (21/8)],\n [-(39/4), -3, -(123/16)],\n [-(37/16), -(39/16), -(97/16)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 0 & 5 & 0 \\\\\n -5 & -1 & 7 \\\\\n 4 & 5 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-2 x^2+9 x+115$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 5, 0],\n [-5, -1, 7],\n [4, 5, -1]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n 0 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -10]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{31}{5} \\\\\n \\frac{1}{5} \\\\\n \\frac{11}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{17}{5} \\\\\n -\\frac{33}{5} \\\\\n -\\frac{41}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{26 \\sqrt{6}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(31/5)],\n [(1/5)],\n [(11/5)]])\nb = np.array([\n [(17/5)],\n [-(33/5)],\n [-(41/5)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{20}{7} \\\\\n \\frac{12}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{5}{\\sqrt{34}} \\\\\n \\frac{3}{\\sqrt{34}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(20/7)],\n [(12/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -4 & 5 \\\\\n 0 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$20$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 5],\n [0, -5]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 0 \\\\\n -4 \\\\\n 7 \\\\\n 3 \\\\\n 9 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$14$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [0],\n [-4],\n [7],\n [3],\n [9],\n [5]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{19}{7} \\\\\n -\\frac{15}{7} \\\\\n -\\frac{1}{7} \\\\\n -\\frac{13}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{19}{6 \\sqrt{21}} \\\\\n -\\frac{5}{2 \\sqrt{21}} \\\\\n -\\frac{1}{6 \\sqrt{21}} \\\\\n -\\frac{13}{6 \\sqrt{21}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/7)],\n [-(15/7)],\n [-(1/7)],\n [-(13/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -4 & 5 & -7 & -6 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-7.,0.,4.,0.,0.\\}, \\{-3.,0.,0.,2.,0.\\}, \\{3.,0.,0.,0.,4.\\}, \\{5.,4.,0.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, 5, -7, -6, 3]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4.6 \\\\\n 1.7 \\\\\n 2.1 \\\\\n -6.7 \\\\\n -9.3 \\\\\n 6.7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7.4 \\\\\n 8.3 \\\\\n 0.8 \\\\\n -5.2 \\\\\n -5.8 \\\\\n -6. \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$19.106$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4.6],\n [1.7],\n [2.1],\n [-6.7],\n [-9.3],\n [6.7]])\nb = np.array([\n [7.4],\n [8.3],\n [0.8],\n [-5.2],\n [-5.8],\n [-6.]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 9 & 5 & -3 & 7 & -7 & 6 \\\\\n 2 & -10 & -8 & 2 & -4 & 9 \\\\\n -8 & -3 & -1 & 8 & 2 & 1 \\\\\n 10 & 2 & -9 & -1 & 5 & 1 \\\\\n 7 & 3 & -7 & -1 & 5 & -9 \\\\\n 5 & -2 & 3 & 1 & -9 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, 5, -3, 7, -7, 6],\n [2, -10, -8, 2, -4, 9],\n [-8, -3, -1, 8, 2, 1],\n [10, 2, -9, -1, 5, 1],\n [7, 3, -7, -1, 5, -9],\n [5, -2, 3, 1, -9, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{16}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{15}{8} \\\\\n \\frac{3}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [-4]])\nprint(a * -(3/16))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{2} & 2 & -10 \\\\\n \\frac{11}{2} & -\\frac{17}{2} & -1 \\\\\n 5 & 8 & \\frac{13}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{11 x^2}{2}+\\frac{5 x}{4}-\\frac{6249}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), 2, -10],\n [(11/2), -(17/2), -1],\n [5, 8, (13/2)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{29}{4} & \\frac{17}{2} & -\\frac{17}{4} \\\\\n \\frac{7}{2} & \\frac{33}{4} & -\\frac{33}{4} \\\\\n -\\frac{7}{4} & 9 & \\frac{15}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{4.773,-0.49,1.\\}, \\{0.18\\, -0.465 i,0.383\\, -0.934 i,1.\\}, \\{0.18\\, +0.465 i,0.383\\, +0.934 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/4), (17/2), -(17/4)],\n [(7/2), (33/4), -(33/4)],\n [-(7/4), 9, (15/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2 & \\frac{1}{2} & 0 \\\\\n \\frac{5}{2} & -\\frac{3}{2} & -\\frac{1}{2} \\\\\n \\frac{3}{2} & 2 & 0 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{21}{4} & -\\frac{7}{4} & -\\frac{1}{4} \\\\\n -\\frac{19}{2} & \\frac{5}{2} & \\frac{3}{4} \\\\\n 2 & -\\frac{9}{4} & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, (1/2), 0],\n [(5/2), -(3/2), -(1/2)],\n [(3/2), 2, 0]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{e} \\\\\n -\\frac{10}{e} \\\\\n \\frac{18}{e} \\\\\n -\\frac{21}{e} \\\\\n -\\frac{21}{e} \\\\\n \\frac{26}{e} \\\\\n -\\frac{11}{e} \\\\\n -\\frac{18}{e} \\\\\n \\frac{4}{e} \\\\\n -\\frac{15}{e} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{2}{e} \\\\\n \\frac{16}{e} \\\\\n \\frac{6}{e} \\\\\n \\frac{2}{e} \\\\\n -\\frac{17}{e} \\\\\n -\\frac{25}{e} \\\\\n \\frac{18}{e} \\\\\n \\frac{26}{e} \\\\\n -\\frac{9}{e} \\\\\n \\frac{11}{e} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{7813}}{e}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(17/math.e)],\n [-(10/math.e)],\n [(18/math.e)],\n [-(21/math.e)],\n [-(21/math.e)],\n [(26/math.e)],\n [-(11/math.e)],\n [-(18/math.e)],\n [(4/math.e)],\n [-(15/math.e)]])\nb = np.array([\n [(2/math.e)],\n [(16/math.e)],\n [(6/math.e)],\n [(2/math.e)],\n [-(17/math.e)],\n [-(25/math.e)],\n [(18/math.e)],\n [(26/math.e)],\n [-(9/math.e)],\n [(11/math.e)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -3 & -3 \\\\\n 3 & 1 & 3 \\\\\n 0 & -2 & -1 \\\\\n 1 & 0 & 2 \\\\\n 3 & -3 & -3 \\\\\n -1 & -1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.05 \\\\\n -0.21 \\\\\n 2.25 \\\\\n 2.36 \\\\\n 0.46 \\\\\n 2.68 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.23 \\\\\n -1.167 \\\\\n 0.996 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -3, -3],\n [3, 1, 3],\n [0, -2, -1],\n [1, 0, 2],\n [3, -3, -3],\n [-1, -1, 1]])\nb = np.array([\n [-1.05],\n [-0.21],\n [2.25],\n [2.36],\n [0.46],\n [2.68]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{23}{3} \\\\\n 5 \\\\\n \\frac{25}{3} \\\\\n 3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{28}{3} \\\\\n -3 \\\\\n \\frac{17}{3} \\\\\n -\\frac{26}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{5}{3} \\\\\n 8 \\\\\n \\frac{8}{3} \\\\\n \\frac{35}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/3)],\n [5],\n [(25/3)],\n [3]])\nb = np.array([\n [-(28/3)],\n [-3],\n [(17/3)],\n [-(26/3)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{11}{4} \\\\\n -\\frac{9}{4} \\\\\n 1 \\\\\n -\\frac{5}{4} \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n \\frac{5}{4} \\\\\n -\\frac{1}{2} \\\\\n -1 \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{1}{97},-\\frac{5}{388},\\frac{1}{194},\\frac{1}{97},\\frac{3}{194}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/4)],\n [-(9/4)],\n [1],\n [-(5/4)],\n [(1/2)]]).squeeze()\nb = np.array([\n [1],\n [(5/4)],\n [-(1/2)],\n [-1],\n [-(3/2)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-5,-4,1\\}, \\{-2,-1,4\\}, \\{4,-2,5\\}}$.", - "Output Answer": [ - "$2 x+5 y-7 z+37=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-5, -4, 1],\n [-2, -1, 4],\n [4, -2, 5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 2 \\\\\n -9 \\\\\n 7 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -5 \\\\\n -1 \\\\\n 4 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$36$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [2],\n [-9],\n [7],\n [8]])\nb = np.array([\n [-7],\n [-5],\n [-1],\n [4],\n [9]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -7 \\\\\n 3 \\\\\n 7 \\\\\n 6 \\\\\n 5 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-7],\n [3],\n [7],\n [6],\n [5],\n [-7]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{5}{3}, 3}$ to the line $2 x+\\frac{4 y}{3}-\\frac{11}{3}=0$.", - "Output Answer": [ - "$\\frac{9}{2 \\sqrt{13}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(5/3), 3\nline = Poly(2*x+((4*y)/3)-(11/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{28}{5} & -\\frac{28}{5} & -\\frac{43}{5} \\\\\n -\\frac{23}{5} & \\frac{11}{5} & \\frac{29}{5} \\\\\n -\\frac{21}{5} & -7 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-1.583-1.148 i,-1.583+1.148 i,8.966\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(28/5), -(28/5), -(43/5)],\n [-(23/5), (11/5), (29/5)],\n [-(21/5), -7, -2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -2 & -8 & -6 & -2 & 9 & -10 \\\\\n -6 & 5 & -1 & -5 & 0 & 3 \\\\\n -6 & 1 & 4 & -1 & 5 & 5 \\\\\n -4 & 1 & -3 & 0 & 9 & 4 \\\\\n 1 & -4 & -8 & 5 & 2 & 10 \\\\\n 5 & 9 & 3 & -7 & 2 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, -8, -6, -2, 9, -10],\n [-6, 5, -1, -5, 0, 3],\n [-6, 1, 4, -1, 5, 5],\n [-4, 1, -3, 0, 9, 4],\n [1, -4, -8, 5, 2, 10],\n [5, 9, 3, -7, 2, -10]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{97}{16} \\\\\n \\frac{47}{16} \\\\\n -\\frac{135}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{37}{4} \\\\\n \\frac{111}{16} \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{16489}{256} \\\\\n \\frac{5771}{64} \\\\\n -\\frac{3811}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(97/16)],\n [(47/16)],\n [-(135/16)]])\nb = np.array([\n [-(37/4)],\n [(111/16)],\n [2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{12}{5} \\\\\n \\frac{1}{5} \\\\\n \\frac{12}{5} \\\\\n \\frac{11}{5} \\\\\n \\frac{7}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{4}{\\sqrt{51}} \\\\\n \\frac{1}{3 \\sqrt{51}} \\\\\n \\frac{4}{\\sqrt{51}} \\\\\n \\frac{11}{3 \\sqrt{51}} \\\\\n \\frac{7}{3 \\sqrt{51}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(12/5)],\n [(1/5)],\n [(12/5)],\n [(11/5)],\n [(7/5)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-4, -1, -\\frac{3}{2}}$ to the plane $\\frac{9 x}{2}-4 y+\\frac{7}{2}=0$.", - "Output Answer": [ - "$\\frac{21}{\\sqrt{145}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -4, -1, -(3/2)\nplane = Poly(((9*x)/2)-4*y+(7/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & 2 \\\\\n -3 & -2 \\\\\n 1 & 0 \\\\\n 2 & -3 \\\\\n -2 & 1 \\\\\n -2 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.21 \\\\\n 2.95 \\\\\n 2.64 \\\\\n -1.93 \\\\\n -0.49 \\\\\n 0.45 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.558 \\\\\n -0.069 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2],\n [-3, -2],\n [1, 0],\n [2, -3],\n [-2, 1],\n [-2, 1]])\nb = np.array([\n [2.21],\n [2.95],\n [2.64],\n [-1.93],\n [-0.49],\n [0.45]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 2 & -1 & 6 \\\\\n -2 & 8 & -3 \\\\\n -10 & -8 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+5 x^2+428$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1, 6],\n [-2, 8, -3],\n [-10, -8, -5]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -4 & -3 \\\\\n -1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-19$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -3],\n [-1, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -2 & -3 \\\\\n -10 & 9 \\\\\n -2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, -3],\n [-10, 9],\n [-2, -1]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,-2,0\\}, \\{0,-2,2\\}, \\{5,0,5\\}}$.", - "Output Answer": [ - "$4 x-19 y+6 z-50=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, -2, 0],\n [0, -2, 2],\n [5, 0, 5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -8 & 1 & 1 & -5 \\\\\n -9 & -6 & 8 & 0 \\\\\n 8 & -7 & -8 & -8 \\\\\n -2 & 9 & -3 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -10 & 2 & -9 & 10 \\\\\n -1 & 8 & 8 & -1 \\\\\n -5 & 3 & 1 & 6 \\\\\n 8 & 5 & -4 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -18 & 3 & -8 & 5 \\\\\n -10 & 2 & 16 & -1 \\\\\n 3 & -4 & -7 & -2 \\\\\n 6 & 14 & -7 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 1, 1, -5],\n [-9, -6, 8, 0],\n [8, -7, -8, -8],\n [-2, 9, -3, 8]])\nb = np.array([\n [-10, 2, -9, 10],\n [-1, 8, 8, -1],\n [-5, 3, 1, 6],\n [8, 5, -4, -5]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{17}{5}, \\frac{9}{5}}$ to the line $-\\frac{x}{5}+\\frac{14 y}{5}-3=0$.", - "Output Answer": [ - "$\\frac{34}{5 \\sqrt{197}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (17/5), (9/5)\nline = Poly(-(x/5)+((14*y)/5)-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 9 & -10 & -6 & -9 \\\\\n -4 & 5 & -10 & 7 \\\\\n -1 & -9 & -7 & -9 \\\\\n 8 & -10 & 2 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, -10, -6, -9],\n [-4, 5, -10, 7],\n [-1, -9, -7, -9],\n [8, -10, 2, -4]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{17}{3} & 8 & -\\frac{7}{6} & -3 \\\\\n \\frac{29}{6} & -\\frac{4}{3} & \\frac{22}{3} & -\\frac{25}{6} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n \\frac{28}{3} & \\frac{7}{2} & -\\frac{11}{3} & -\\frac{11}{3} \\\\\n 8 & \\frac{25}{6} & 4 & -\\frac{26}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{11}{3} & \\frac{9}{2} & \\frac{5}{2} & \\frac{2}{3} \\\\\n -\\frac{19}{6} & -\\frac{11}{2} & \\frac{10}{3} & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/3), 8, -(7/6), -3],\n [(29/6), -(4/3), (22/3), -(25/6)]])\nb = np.array([\n [(28/3), (7/2), -(11/3), -(11/3)],\n [8, (25/6), 4, -(26/3)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -2 \\\\\n -9 \\\\\n -8 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 8 \\\\\n 2 \\\\\n -9 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{391}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-2],\n [-9],\n [-8],\n [-5]])\nb = np.array([\n [6],\n [8],\n [2],\n [-9],\n [0]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{16} \\\\\n \\frac{19}{4} \\\\\n -\\frac{41}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{29}{4} \\\\\n \\frac{75}{8} \\\\\n -\\frac{13}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1099}{128} \\\\\n -\\frac{783}{32} \\\\\n -\\frac{6583}{128} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/16)],\n [(19/4)],\n [-(41/16)]])\nb = np.array([\n [(29/4)],\n [(75/8)],\n [-(13/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{\\pi } \\\\\n \\frac{14}{\\pi } \\\\\n \\frac{2}{\\pi } \\\\\n -\\frac{2}{\\pi } \\\\\n \\frac{4}{\\pi } \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{28}{\\pi } \\\\\n \\frac{1}{\\pi } \\\\\n \\frac{13}{\\pi } \\\\\n \\frac{10}{\\pi } \\\\\n -\\frac{10}{\\pi } \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{496}{\\pi ^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(17/math.pi)],\n [(14/math.pi)],\n [(2/math.pi)],\n [-(2/math.pi)],\n [(4/math.pi)]])\nb = np.array([\n [-(28/math.pi)],\n [(1/math.pi)],\n [(13/math.pi)],\n [(10/math.pi)],\n [-(10/math.pi)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -\\frac{39}{5} \\\\\n -\\frac{17}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{12}{5} \\\\\n \\frac{6}{5} \\\\\n \\frac{18}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -24 \\\\\n \\frac{426}{25} \\\\\n \\frac{258}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-(39/5)],\n [-(17/5)]])\nb = np.array([\n [(12/5)],\n [(6/5)],\n [(18/5)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{6}{e} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{e} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{90}{e^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(6/math.e)]])\nb = np.array([\n [-(15/math.e)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & 10 & -3 \\\\\n 5 & -7 & 0 \\\\\n 4 & 9 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-12.598,-7.247,3.845\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 10, -3],\n [5, -7, 0],\n [4, 9, -10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{37}{5} & 8 & \\frac{11}{5} \\\\\n -\\frac{17}{5} & -\\frac{19}{5} & -\\frac{48}{5} \\\\\n -9 & -9 & \\frac{21}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-3.62,-0.898,12.318\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/5), 8, (11/5)],\n [-(17/5), -(19/5), -(48/5)],\n [-9, -9, (21/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2 \\\\\n -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-8]])\nb = np.array([\n [7],\n [-1]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 7 & -\\frac{1}{2} \\\\\n \\frac{19}{2} & -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & \\frac{3}{2} \\\\\n -\\frac{15}{2} & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{15}{2} & 1 \\\\\n 2 & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -(1/2)],\n [(19/2), -(11/2)]])\nb = np.array([\n [(1/2), (3/2)],\n [-(15/2), 1]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{27}{5} \\\\\n 9 \\\\\n -2 \\\\\n -\\frac{16}{5} \\\\\n -\\frac{46}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{144}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(27/5)],\n [9],\n [-2],\n [-(16/5)],\n [-(46/5)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & -\\frac{7}{2} \\\\\n \\frac{7}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{4} \\left(11-3 i \\sqrt{3}\\right),\\frac{1}{4} \\left(11+3 i \\sqrt{3}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -(7/2)],\n [(7/2), -(1/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{23}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{23}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/3)]])\nb = np.array([\n [0]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${2, 2}$ to the line $-5 x+2 y+2=0$.", - "Output Answer": [ - "$\\frac{4}{\\sqrt{29}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 2, 2\nline = Poly(-5*x+2*y+2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -1 \\\\\n 4 \\\\\n 3 \\\\\n -\\frac{4}{5} \\\\\n \\frac{7}{5} \\\\\n -\\frac{46}{5} \\\\\n \\frac{6}{5} \\\\\n \\frac{4}{5} \\\\\n \\frac{17}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{24}{5} \\\\\n -\\frac{26}{5} \\\\\n \\frac{48}{5} \\\\\n \\frac{33}{5} \\\\\n -\\frac{16}{5} \\\\\n \\frac{42}{5} \\\\\n 4 \\\\\n \\frac{49}{5} \\\\\n -\\frac{1}{5} \\\\\n \\frac{11}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4 \\sqrt{23}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-1],\n [4],\n [3],\n [-(4/5)],\n [(7/5)],\n [-(46/5)],\n [(6/5)],\n [(4/5)],\n [(17/5)]])\nb = np.array([\n [-(24/5)],\n [-(26/5)],\n [(48/5)],\n [(33/5)],\n [-(16/5)],\n [(42/5)],\n [4],\n [(49/5)],\n [-(1/5)],\n [(11/5)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -8 & 7 & 4 \\\\\n 5 & 6 & 6 \\\\\n -10 & -2 & 6 \\\\\n 9 & -6 & 9 \\\\\n -8 & -10 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-8, 7, 4],\n [5, 6, 6],\n [-10, -2, 6],\n [9, -6, 9],\n [-8, -10, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${0, -\\frac{2}{3}}$ to the line $\\frac{14 x}{3}-\\frac{y}{3}+\\frac{4}{3}=0$.", - "Output Answer": [ - "$\\frac{14}{3 \\sqrt{197}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 0, -(2/3)\nline = Poly(((14*x)/3)-(y/3)+(4/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{5} & 2 \\\\\n \\frac{11}{5} & -\\frac{2}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{108}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/5), 2],\n [(11/5), -(2/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -1 & -8 & -8 \\\\\n 9 & -6 & -10 \\\\\n -8 & 9 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-15 x^2-160 x-1618$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -8, -8],\n [9, -6, -10],\n [-8, 9, -8]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -3 & 6 & 10 & -5 & -10 & -5 \\\\\n 4 & 0 & -2 & 10 & -8 & 3 \\\\\n 0 & -6 & 6 & -6 & 10 & 0 \\\\\n -7 & 0 & 9 & 10 & -10 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & -\\frac{173}{418} & -\\frac{325}{1672} \\\\\n 0 & 1 & 0 & 0 & -\\frac{86}{57} & -\\frac{35}{76} \\\\\n 0 & 0 & 1 & 0 & -\\frac{249}{418} & -\\frac{173}{1672} \\\\\n 0 & 0 & 0 & 1 & -\\frac{315}{418} & \\frac{597}{1672} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 6, 10, -5, -10, -5],\n [4, 0, -2, 10, -8, 3],\n [0, -6, 6, -6, 10, 0],\n [-7, 0, 9, 10, -10, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 5 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -4 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -35 \\\\\n -49 \\\\\n 43 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [5],\n [0]])\nb = np.array([\n [-3],\n [-4],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{13}{3} & \\frac{23}{3} \\\\\n -8 & \\frac{10}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{6} \\left(23-i \\sqrt{2199}\\right),\\frac{1}{6} \\left(23+i \\sqrt{2199}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/3), (23/3)],\n [-8, (10/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & -\\frac{9}{2} \\\\\n -\\frac{13}{4} & \\frac{17}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{8} \\left(41-\\sqrt{985}\\right),\\frac{1}{8} \\left(41+\\sqrt{985}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -(9/2)],\n [-(13/4), (17/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 14 \\\\\n -2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [0],\n [1]])\nb = np.array([\n [9],\n [-2],\n [-1]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & 0 \\\\\n -2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0],\n [-2, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & 3 & 2 \\\\\n 0 & 1 & 3 \\\\\n 1 & -2 & -3 \\\\\n -1 & 2 & 3 \\\\\n 1 & -1 & -1 \\\\\n 3 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.89 \\\\\n -1.69 \\\\\n 1.98 \\\\\n 2.79 \\\\\n 1.21 \\\\\n -2.33 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2.611 \\\\\n 5.115 \\\\\n -2.41 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 3, 2],\n [0, 1, 3],\n [1, -2, -3],\n [-1, 2, 3],\n [1, -1, -1],\n [3, -1, 2]])\nb = np.array([\n [2.89],\n [-1.69],\n [1.98],\n [2.79],\n [1.21],\n [-2.33]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{19}{3} & 3 \\\\\n \\frac{17}{3} & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{10 x}{3}-36$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/3), 3],\n [(17/3), 3]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,2,1\\}, \\{2,-2,0\\}, \\{0,-2,-3\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{2}{3},\\frac{2}{3},\\frac{1}{3}\\right\\}, \\left\\{\\frac{1}{3 \\sqrt{2}},-\\frac{1}{3 \\sqrt{2}},\\frac{2 \\sqrt{2}}{3}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{2}},-\\frac{1}{\\sqrt{2}},0\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, 2, 1), (2, -2, 0), (0, -2, -3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 4 & 4 \\\\\n 0 & 4 & 2 \\\\\n 4 & 3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-32$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 4, 4],\n [0, 4, 2],\n [4, 3, -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{99}{16} & \\frac{57}{8} & -\\frac{5}{8} \\\\\n \\frac{37}{4} & -\\frac{27}{4} & \\frac{37}{16} \\\\\n -\\frac{39}{8} & \\frac{35}{4} & -\\frac{77}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{361 x^2}{16}-\\frac{9869 x}{128}+\\frac{31643}{128}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(99/16), (57/8), -(5/8)],\n [(37/4), -(27/4), (37/16)],\n [-(39/8), (35/4), -(77/8)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & -7 \\\\\n -3 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+9 x-7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -7],\n [-3, -2]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 2 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 2 & 1 \\\\\n 3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 7 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1]])\nb = np.array([\n [2, 1],\n [3, -1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{16}{5} & \\frac{42}{5} \\\\\n \\frac{49}{5} & \\frac{49}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{81 x}{10}-\\frac{1666}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(16/5), (42/5)],\n [(49/5), (49/10)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{5} & -\\frac{1}{5} & \\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{7}{25} & \\frac{7}{25} & -\\frac{56}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/5)]])\nb = np.array([\n [-(1/5), -(1/5), (8/5)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{1}{4} & \\frac{1}{2} & -\\frac{9}{4} & \\frac{11}{4} & \\frac{3}{2} \\\\\n 2 & -\\frac{1}{4} & -3 & 0 & \\frac{5}{2} \\\\\n -\\frac{7}{4} & \\frac{3}{4} & \\frac{5}{2} & \\frac{5}{4} & -\\frac{9}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{11}{4} & \\frac{5}{2} & -\\frac{3}{2} & \\frac{9}{4} \\\\\n \\frac{1}{2} & \\frac{11}{4} & 0 & 2 \\\\\n \\frac{1}{2} & 0 & 1 & -3 \\\\\n \\frac{7}{4} & 3 & \\frac{5}{4} & -2 \\\\\n \\frac{11}{4} & -\\frac{9}{4} & -\\frac{5}{2} & -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{35}{4} & \\frac{45}{8} & -\\frac{35}{16} & \\frac{21}{16} \\\\\n -\\frac{1}{4} & -\\frac{21}{16} & -\\frac{49}{4} & \\frac{99}{8} \\\\\n \\frac{39}{16} & \\frac{13}{2} & \\frac{197}{16} & -\\frac{95}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/4), (1/2), -(9/4), (11/4), (3/2)],\n [2, -(1/4), -3, 0, (5/2)],\n [-(7/4), (3/4), (5/2), (5/4), -(9/4)]])\nb = np.array([\n [-(11/4), (5/2), -(3/2), (9/4)],\n [(1/2), (11/4), 0, 2],\n [(1/2), 0, 1, -3],\n [(7/4), 3, (5/4), -2],\n [(11/4), -(9/4), -(5/2), -(1/4)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{0,-2 \\sqrt{2},0\\right\\}, \\left\\{-\\frac{1}{\\sqrt{2}},-2 \\sqrt{2},0\\right\\}, \\left\\{2 \\sqrt{2},0,0\\right\\}}$", - "Output Answer": [ - "${\\{0,-1,0\\}, \\{-1,0,0\\}, \\{0,0,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((0, -2*math.sqrt(2), 0), (-(1/(math.sqrt(2))), -2*math.sqrt(2), 0), (2*math.sqrt(2), 0, 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{79}{8} & -\\frac{63}{8} \\\\\n -\\frac{19}{2} & -\\frac{53}{16} \\\\\n -\\frac{1}{2} & -\\frac{71}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{25}{8} & \\frac{77}{8} \\\\\n \\frac{53}{16} & -\\frac{127}{16} \\\\\n \\frac{107}{16} & -\\frac{3}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{27}{4} & -\\frac{35}{2} \\\\\n -\\frac{205}{16} & \\frac{37}{8} \\\\\n -\\frac{115}{16} & -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(79/8), -(63/8)],\n [-(19/2), -(53/16)],\n [-(1/2), -(71/8)]])\nb = np.array([\n [-(25/8), (77/8)],\n [(53/16), -(127/16)],\n [(107/16), -(3/8)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -4 & -2 & 9 \\\\\n 9 & -4 & 6 \\\\\n 10 & -4 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.852,0.164,1.\\}, \\{1.077\\, -0.297 i,1.296\\, -1.976 i,1.\\}, \\{1.077\\, +0.297 i,1.296\\, +1.976 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -2, 9],\n [9, -4, 6],\n [10, -4, -5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 0 & -2 i \\\\\n -4 & 3-4 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 8 i & -8-6 i \\\\\n -12+16 i & -7-16 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2j],\n [-4, 3-4j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & -\\frac{5}{2} & \\frac{5}{2} \\\\\n \\frac{5}{2} & 0 & 1 \\\\\n -\\frac{1}{2} & -\\frac{3}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{15}{2} & -\\frac{15}{4} & -\\frac{15}{4} \\\\\n -\\frac{1}{2} & -\\frac{31}{4} & \\frac{23}{4} \\\\\n -\\frac{7}{2} & 2 & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -(5/2), (5/2)],\n [(5/2), 0, 1],\n [-(1/2), -(3/2), -(1/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -8 & -10 & -8 & -3 \\\\\n -1 & -10 & 6 & 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -6 & 1 & -3 & 4 \\\\\n -1 & -10 & -4 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -14 & -9 & -11 & 1 \\\\\n -2 & -20 & 2 & 13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -10, -8, -3],\n [-1, -10, 6, 6]])\nb = np.array([\n [-6, 1, -3, 4],\n [-1, -10, -4, 7]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -9 & 6 & 5 \\\\\n 6 & -4 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{2.,3.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, 6, 5],\n [6, -4, -9]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{2}{3} \\\\\n \\frac{14}{3} \\\\\n -\\frac{22}{3} \\\\\n 5 \\\\\n -\\frac{13}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{20}{3} \\\\\n -\\frac{28}{3} \\\\\n \\frac{10}{3} \\\\\n -\\frac{8}{3} \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{115 \\sqrt{\\frac{2}{5291}}}{7}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/3)],\n [(14/3)],\n [-(22/3)],\n [5],\n [-(13/3)]]).squeeze()\nb = np.array([\n [-(20/3)],\n [-(28/3)],\n [(10/3)],\n [-(8/3)],\n [-8]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & 4 & -9 \\\\\n -6 & 7 & 0 \\\\\n -3 & 1 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8.468,7.234\\, -4.263 i,7.234\\, +4.263 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 4, -9],\n [-6, 7, 0],\n [-3, 1, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 9 & 1 \\\\\n -7 & -6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -8 & -8 \\\\\n 10 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 17 & 9 \\\\\n -17 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 1],\n [-7, -6]])\nb = np.array([\n [-8, -8],\n [10, -6]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & \\frac{11}{5} \\\\\n \\frac{8}{5} & -\\frac{7}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{70}{211} & \\frac{110}{211} \\\\\n \\frac{80}{211} & -\\frac{25}{211} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), (11/5)],\n [(8/5), -(7/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{4}{3} & -\\frac{17}{6} \\\\\n -\\frac{25}{6} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{233}{36}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/3), -(17/6)],\n [-(25/6), -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -6 \\\\\n 7 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -4 \\\\\n 9 \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 11 \\\\\n -10 \\\\\n 16 \\\\\n -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-6],\n [7],\n [-8]])\nb = np.array([\n [10],\n [-4],\n [9],\n [6]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{3} & -6 \\\\\n 3 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{28 x}{3}+21$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/3), -6],\n [3, -9]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 3 & -2 & -1 & 1 & -2 \\\\\n 3 & 1 & 3 & -2 & -1 \\\\\n 3 & 3 & -1 & -1 & -2 \\\\\n 1 & -1 & 3 & -3 & -3 \\\\\n 3 & -1 & 0 & 1 & -3 \\\\\n 1 & 0 & -1 & 0 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.63 \\\\\n -2.15 \\\\\n -1.49 \\\\\n 0.58 \\\\\n -2.03 \\\\\n -1.24 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.628 \\\\\n -1.814 \\\\\n -1.886 \\\\\n -2.391 \\\\\n 1.165 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2, -1, 1, -2],\n [3, 1, 3, -2, -1],\n [3, 3, -1, -1, -2],\n [1, -1, 3, -3, -3],\n [3, -1, 0, 1, -3],\n [1, 0, -1, 0, -3]])\nb = np.array([\n [2.63],\n [-2.15],\n [-1.49],\n [0.58],\n [-2.03],\n [-1.24]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{2} & \\frac{11}{2} \\\\\n \\frac{17}{4} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+4 x-\\frac{205}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2), (11/2)],\n [(17/4), (1/2)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{12}{7},-\\frac{4}{7},\\frac{8}{7}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [0],\n [1]]).squeeze()\nb = np.array([\n [3],\n [-1],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & 3 & -4 \\\\\n 3 & 2 & -2 \\\\\n 4 & 4 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 3, -4],\n [3, 2, -2],\n [4, 4, -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n \\frac{4}{3} & 3 & -\\frac{4}{3} & -\\frac{5}{3} \\\\\n -\\frac{5}{3} & 2 & -1 & -\\frac{2}{3} \\\\\n -\\frac{8}{3} & -1 & -\\frac{5}{3} & -\\frac{5}{3} \\\\\n \\frac{8}{3} & \\frac{2}{3} & -\\frac{7}{3} & -2 \\\\\n -\\frac{7}{3} & \\frac{8}{3} & -\\frac{4}{3} & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 3 & \\frac{4}{3} \\\\\n \\frac{4}{3} & \\frac{8}{3} \\\\\n 1 & -\\frac{2}{3} \\\\\n -1 & -\\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{25}{3} & \\frac{116}{9} \\\\\n -\\frac{8}{3} & \\frac{14}{3} \\\\\n -\\frac{28}{3} & -\\frac{26}{9} \\\\\n \\frac{77}{9} & \\frac{86}{9} \\\\\n -\\frac{61}{9} & \\frac{20}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3), 3, -(4/3), -(5/3)],\n [-(5/3), 2, -1, -(2/3)],\n [-(8/3), -1, -(5/3), -(5/3)],\n [(8/3), (2/3), -(7/3), -2],\n [-(7/3), (8/3), -(4/3), 2]])\nb = np.array([\n [3, (4/3)],\n [(4/3), (8/3)],\n [1, -(2/3)],\n [-1, -(4/3)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -7 \\\\\n 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 10 \\\\\n 25 \\\\\n 65 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [1],\n [1]])\nb = np.array([\n [-2],\n [-7],\n [3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -2 & 0 & -1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -2 & 0 & -1 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1]])\nb = np.array([\n [-2, 0, -1, 0]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{25}{7} & \\frac{4}{7} & -\\frac{20}{7} \\\\\n -\\frac{68}{7} & \\frac{55}{7} & -\\frac{22}{7} \\\\\n -\\frac{54}{7} & -\\frac{19}{7} & \\frac{69}{7} \\\\\n -\\frac{15}{7} & \\frac{36}{7} & \\frac{44}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{16}{7} & -\\frac{15}{7} & \\frac{10}{7} \\\\\n -8 & \\frac{68}{7} & -\\frac{57}{7} \\\\\n 4 & \\frac{4}{7} & \\frac{4}{7} \\\\\n \\frac{55}{7} & \\frac{58}{7} & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{41}{7} & -\\frac{11}{7} & -\\frac{10}{7} \\\\\n -\\frac{124}{7} & \\frac{123}{7} & -\\frac{79}{7} \\\\\n -\\frac{26}{7} & -\\frac{15}{7} & \\frac{73}{7} \\\\\n \\frac{40}{7} & \\frac{94}{7} & -\\frac{12}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/7), (4/7), -(20/7)],\n [-(68/7), (55/7), -(22/7)],\n [-(54/7), -(19/7), (69/7)],\n [-(15/7), (36/7), (44/7)]])\nb = np.array([\n [-(16/7), -(15/7), (10/7)],\n [-8, (68/7), -(57/7)],\n [4, (4/7), (4/7)],\n [(55/7), (58/7), -8]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 9 & -4 & 9 \\\\\n 4 & 8 & -9 \\\\\n 6 & 4 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+24 x^2-189 x+868$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -4, 9],\n [4, 8, -9],\n [6, 4, 7]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n \\frac{19}{4} \\\\\n \\frac{25}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{39}{4} \\\\\n \\frac{13}{4} \\\\\n -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{67}{4} \\\\\n \\frac{3}{2} \\\\\n \\frac{65}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [(19/4)],\n [(25/4)]])\nb = np.array([\n [(39/4)],\n [(13/4)],\n [-10]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [0],\n [1],\n [0],\n [-1]]).squeeze()\nb = np.array([\n [0],\n [1],\n [-1],\n [-1],\n [1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{191}{50} \\\\\n \\frac{691}{100} \\\\\n \\frac{11}{50} \\\\\n -\\frac{351}{100} \\\\\n -\\frac{71}{100} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{691}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(191/50)],\n [(691/100)],\n [(11/50)],\n [-(351/100)],\n [-(71/100)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -8 & 5 & 1 \\\\\n 1 & 3 & -6 \\\\\n -5 & 5 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.,0.,0.\\}, \\{1.,1.,1.\\}, \\{36.,29.,35.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 5, 1],\n [1, 3, -6],\n [-5, 5, -2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 1 & 0 & -1 \\\\\n 0 & -3 & -2 \\\\\n 5 & -5 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{16}{31} & -\\frac{5}{31} & \\frac{3}{31} \\\\\n \\frac{10}{31} & -\\frac{7}{31} & -\\frac{2}{31} \\\\\n -\\frac{15}{31} & -\\frac{5}{31} & \\frac{3}{31} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 0, -1],\n [0, -3, -2],\n [5, -5, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -6 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 9 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{9}{\\sqrt{11407}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-6],\n [0]]).squeeze()\nb = np.array([\n [-9],\n [9],\n [5]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -9 & -\\frac{15}{4} \\\\\n -\\frac{37}{4} & \\frac{17}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{19 x}{4}-\\frac{1167}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -(15/4)],\n [-(37/4), (17/4)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n 3 & -7 & -3 & -1 \\\\\n 10 & -10 & -9 & -1 \\\\\n 8 & 9 & 8 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -7, -3, -1],\n [10, -10, -9, -1],\n [8, 9, 8, 9]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{46}{5} \\\\\n \\frac{69}{10} \\\\\n -\\frac{6}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{5} \\\\\n \\frac{23}{5} \\\\\n -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1242}{25} \\\\\n \\frac{1918}{25} \\\\\n \\frac{3013}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(46/5)],\n [(69/10)],\n [-(6/5)]])\nb = np.array([\n [-(13/5)],\n [(23/5)],\n [-8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -7 & 6 & -4 \\\\\n 10 & 0 & -8 \\\\\n -1 & 3 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-8 x^2+33 x-180$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 6, -4],\n [10, 0, -8],\n [-1, 3, -1]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -7 \\\\\n -2 \\\\\n 2 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-7],\n [-2],\n [2],\n [8]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{3}{2},0\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2)],\n [(3/2)]]).squeeze()\nb = np.array([\n [2],\n [0]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{2} & \\frac{19}{2} & \\frac{11}{2} \\\\\n 6 & \\frac{17}{2} & -\\frac{7}{2} \\\\\n -1 & 5 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-4.404-3.295 i,-4.404+3.295 i,11.808\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), (19/2), (11/2)],\n [6, (17/2), -(7/2)],\n [-1, 5, -2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 2 & 5 & 2 \\\\\n 8 & 5 & -2 \\\\\n 8 & 2 & -5 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 0 & 7 & -9 \\\\\n 9 & 9 & -9 \\\\\n -9 & 1 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 2 & -2 & 11 \\\\\n -1 & -4 & 7 \\\\\n 17 & 1 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 5, 2],\n [8, 5, -2],\n [8, 2, -5]])\nb = np.array([\n [0, 7, -9],\n [9, 9, -9],\n [-9, 1, -1]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n 9 \\\\\n -7 \\\\\n 4 \\\\\n \\frac{1}{2} \\\\\n -6 \\\\\n -\\frac{17}{2} \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{11}{2} \\\\\n 9 \\\\\n \\frac{13}{2} \\\\\n -\\frac{3}{2} \\\\\n \\frac{1}{2} \\\\\n \\frac{1}{2} \\\\\n 4 \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{9}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2)],\n [9],\n [-7],\n [4],\n [(1/2)],\n [-6],\n [-(17/2)],\n [-8]])\nb = np.array([\n [(11/2)],\n [9],\n [(13/2)],\n [-(3/2)],\n [(1/2)],\n [(1/2)],\n [4],\n [-(5/2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -3 & -2 & -1 & 7 & -9 \\\\\n -2 & 5 & -3 & -3 & 2 \\\\\n -7 & 8 & 10 & 3 & -7 \\\\\n -5 & 4 & -8 & -10 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2223.,-1082.,102.,464.,1331.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, -2, -1, 7, -9],\n [-2, 5, -3, -3, 2],\n [-7, 8, 10, 3, -7],\n [-5, 4, -8, -10, -1]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n 0 & 0 & 0 & 0 \\\\\n 1 & -1 & 0 & -2 \\\\\n 2 & 0 & -2 & -3 \\\\\n 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 1-\\frac{1}{e} & \\frac{1}{e} & 0 & \\frac{1}{e}-e \\\\\n 1-\\frac{1}{e^2} & 0 & \\frac{1}{e^2} & \\frac{1}{e^2}-e \\\\\n 0 & 0 & 0 & e \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [0, 0, 0, 0],\n [1, -1, 0, -2],\n [2, 0, -2, -3],\n [0, 0, 0, 1]])\nprint(expm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & -3 \\\\\n -7 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-21$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3],\n [-7, 0]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{27}{4} \\\\\n 5 \\\\\n 5 \\\\\n \\frac{27}{4} \\\\\n \\frac{13}{2} \\\\\n -9 \\\\\n \\frac{13}{2} \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{2} \\\\\n -10 \\\\\n 2 \\\\\n \\frac{3}{4} \\\\\n -\\frac{5}{2} \\\\\n -10 \\\\\n -\\frac{35}{4} \\\\\n \\frac{21}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{57 \\sqrt{3}}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(27/4)],\n [5],\n [5],\n [(27/4)],\n [(13/2)],\n [-9],\n [(13/2)],\n [(3/2)]])\nb = np.array([\n [-(7/2)],\n [-10],\n [2],\n [(3/4)],\n [-(5/2)],\n [-10],\n [-(35/4)],\n [(21/4)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{2}{7}, \\frac{22}{7}}$ to the line $-\\frac{32 x}{7}+\\frac{23 y}{7}-1=0$.", - "Output Answer": [ - "$\\frac{521}{7 \\sqrt{1553}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(2/7), (22/7)\nline = Poly(-((32*x)/7)+((23*y)/7)-1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 3 & 2 & -4 \\\\\n 10 & 0 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-6.,29.,10.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, 2, -4],\n [10, 0, 6]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{8} & \\frac{117}{16} \\\\\n \\frac{7}{8} & \\frac{93}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{103 x}{16}-\\frac{177}{64}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/8), (117/16)],\n [(7/8), (93/16)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{21}{5} \\\\\n -\\frac{31}{5} \\\\\n \\frac{44}{5} \\\\\n \\frac{1}{5} \\\\\n \\frac{37}{5} \\\\\n \\frac{46}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{2 \\sqrt{1706}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(21/5)],\n [-(31/5)],\n [(44/5)],\n [(1/5)],\n [(37/5)],\n [(46/5)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & 7 & 0 \\\\\n -7 & 5 & 6 \\\\\n 9 & 5 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, 7, 0],\n [-7, 5, 6],\n [9, 5, 9]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4.207 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4.711 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-19.8192$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4.207]])\nb = np.array([\n [4.711]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 4 & -5 \\\\\n 3 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 4 & -5 \\\\\n 3 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -5],\n [3, -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & -2 & 2 \\\\\n -2 & 1 & 1 \\\\\n 0 & -1 & 2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & -12 & 8 \\\\\n -8 & 5 & 2 \\\\\n 4 & -10 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, 2],\n [-2, 1, 1],\n [0, -1, 2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & -5 \\\\\n -4 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} \\left(5-3 \\sqrt{5}\\right),1\\right\\}, \\left\\{\\frac{1}{4} \\left(5+3 \\sqrt{5}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -5],\n [-4, 8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n -\\frac{4}{3} \\\\\n \\frac{13}{6} \\\\\n 1 \\\\\n \\frac{7}{6} \\\\\n \\frac{13}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{15}{2 \\sqrt{178}} \\\\\n -2 \\sqrt{\\frac{2}{89}} \\\\\n \\frac{13}{2 \\sqrt{178}} \\\\\n \\frac{3}{\\sqrt{178}} \\\\\n \\frac{7}{2 \\sqrt{178}} \\\\\n \\frac{13}{2 \\sqrt{178}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2)],\n [-(4/3)],\n [(13/6)],\n [1],\n [(7/6)],\n [(13/6)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -6 & 4 \\\\\n -3 & 1 \\\\\n -3 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -4 & -10 \\\\\n -5 & 5 \\\\\n -9 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -10 & -6 \\\\\n -8 & 6 \\\\\n -12 & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 4],\n [-3, 1],\n [-3, 1]])\nb = np.array([\n [-4, -10],\n [-5, 5],\n [-9, -7]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -1 \\\\\n 5 \\\\\n -5 \\\\\n 4 \\\\\n -5 \\\\\n 6 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-1],\n [5],\n [-5],\n [4],\n [-5],\n [6],\n [-4]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -4 & -9 & -8 & -9 \\\\\n 9 & -5 & -10 & 2 \\\\\n -4 & 4 & -1 & 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -3 & -3 & 1 & 2 \\\\\n 6 & -6 & 3 & 8 \\\\\n -1 & -5 & -8 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -7 & -12 & -7 & -7 \\\\\n 15 & -11 & -7 & 10 \\\\\n -5 & -1 & -9 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -9, -8, -9],\n [9, -5, -10, 2],\n [-4, 4, -1, 7]])\nb = np.array([\n [-3, -3, 1, 2],\n [6, -6, 3, 8],\n [-1, -5, -8, -7]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n \\frac{17}{9} & \\frac{8}{3} & -\\frac{5}{3} & -\\frac{17}{9} \\\\\n -\\frac{4}{3} & \\frac{4}{3} & \\frac{5}{9} & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{8}{9} & \\frac{25}{9} \\\\\n -\\frac{19}{9} & -\\frac{4}{3} \\\\\n \\frac{8}{9} & \\frac{10}{9} \\\\\n \\frac{17}{9} & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -9 & \\frac{140}{81} \\\\\n -\\frac{335}{81} & -\\frac{367}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/9), (8/3), -(5/3), -(17/9)],\n [-(4/3), (4/3), (5/9), -(1/3)]])\nb = np.array([\n [(8/9), (25/9)],\n [-(19/9), -(4/3)],\n [(8/9), (10/9)],\n [(17/9), -1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{53}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-7]])\nb = np.array([\n [-1],\n [7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & 0 & 4 \\\\\n -4 & -3 & 3 \\\\\n -5 & 5 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{27}{194} & -\\frac{10}{97} & -\\frac{6}{97} \\\\\n -\\frac{1}{194} & -\\frac{14}{97} & \\frac{11}{97} \\\\\n \\frac{35}{194} & \\frac{5}{97} & \\frac{3}{97} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, 4],\n [-4, -3, 3],\n [-5, 5, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(-2 \\sqrt{3}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [1],\n [-1],\n [1],\n [-1],\n [1],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [-1],\n [-1],\n [-1],\n [1],\n [0],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{26}{3} & 6 & \\frac{10}{3} \\\\\n -\\frac{7}{3} & -9 & \\frac{29}{3} \\\\\n -\\frac{8}{3} & -3 & \\frac{28}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-7.409-2.487 i,-7.409+2.487 i,6.484\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(26/3), 6, (10/3)],\n [-(7/3), -9, (29/3)],\n [-(8/3), -3, (28/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{11}{3},\\frac{10}{3},\\frac{5}{3}\\right\\}, \\left\\{-3,-\\frac{1}{3},-\\frac{4}{3}\\right\\}, \\left\\{\\frac{10}{3},-2,-1\\right\\}}$.", - "Output Answer": [ - "$168 x+453 y-927 z-581=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(11/3), (10/3), (5/3)],\n [-3, -(1/3), -(4/3)],\n [(10/3), -2, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{3} & -\\frac{7}{2} & -4 \\\\\n -\\frac{13}{3} & \\frac{11}{3} & -3 \\\\\n \\frac{17}{6} & -\\frac{14}{3} & -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{1273}{108}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3), -(7/2), -4],\n [-(13/3), (11/3), -3],\n [(17/6), -(14/3), -(7/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 2 & -4 \\\\\n 9 & -6 \\\\\n 2 & 4 \\\\\n 10 & 9 \\\\\n -1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, -4],\n [9, -6],\n [2, 4],\n [10, 9],\n [-1, -1]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 4 & -1 & -10 & -8 & 7 & 3 \\\\\n -4 & -4 & 10 & -3 & -8 & -10 \\\\\n 7 & 8 & -8 & -10 & -3 & -10 \\\\\n -8 & 5 & 2 & -5 & -4 & 1 \\\\\n -3 & -3 & 2 & -1 & 5 & -4 \\\\\n 1 & 1 & -8 & 4 & 9 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, -1, -10, -8, 7, 3],\n [-4, -4, 10, -3, -8, -10],\n [7, 8, -8, -10, -3, -10],\n [-8, 5, 2, -5, -4, 1],\n [-3, -3, 2, -1, 5, -4],\n [1, 1, -8, 4, 9, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{19}{5}, -\\frac{19}{5}}$ to the line $\\frac{21 x}{5}+\\frac{18 y}{5}-\\frac{33}{10}=0$.", - "Output Answer": [ - "$\\frac{\\sqrt{\\frac{17}{5}}}{10}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (19/5), -(19/5)\nline = Poly(((21*x)/5)+((18*y)/5)-(33/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{4}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -8 & -2 & -7 \\\\\n 7 & -6 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 6 & \\frac{3}{2} & \\frac{21}{4} \\\\\n -\\frac{21}{4} & \\frac{9}{2} & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -2, -7],\n [7, -6, -4]])\nprint(a * -(3/4))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 1 & 2 \\\\\n 0 & -1 & -2 \\\\\n 3 & 3 & 0 \\\\\n -1 & 3 & -3 \\\\\n 1 & -3 & -1 \\\\\n 2 & 3 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.61 \\\\\n -0.51 \\\\\n -2.11 \\\\\n -2.79 \\\\\n 1.42 \\\\\n 2.43 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.457 \\\\\n -0.468 \\\\\n 0.05 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 2],\n [0, -1, -2],\n [3, 3, 0],\n [-1, 3, -3],\n [1, -3, -1],\n [2, 3, 0]])\nb = np.array([\n [-2.61],\n [-0.51],\n [-2.11],\n [-2.79],\n [1.42],\n [2.43]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -10 & \\frac{1}{2} & -\\frac{5}{2} \\\\\n 8 & -5 & -\\frac{5}{2} \\\\\n \\frac{11}{2} & 3 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-16.619,24.275,1.\\}, \\{-0.502,-2.567,1.\\}, \\{-0.167,-0.347,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, (1/2), -(5/2)],\n [8, -5, -(5/2)],\n [(11/2), 3, 8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{5,-3,5\\}, \\{4,-2,-5\\}, \\{3,-1,4\\}}$.", - "Output Answer": [ - "$x+y-2=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [5, -3, 5],\n [4, -2, -5],\n [3, -1, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{2} \\\\\n \\frac{13}{2} \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -9 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{5 \\sqrt{\\frac{5}{23}}}{6}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2)],\n [(13/2)],\n [-7]]).squeeze()\nb = np.array([\n [0],\n [-9],\n [-3]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & 1 & 1 \\\\\n -6 & 6 & -4 \\\\\n 10 & -6 & -8 \\\\\n -2 & -4 & -10 \\\\\n -10 & 8 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, 1, 1],\n [-6, 6, -4],\n [10, -6, -8],\n [-2, -4, -10],\n [-10, 8, -6]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 3 & 9 \\\\\n -1 & 6 \\\\\n 1 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, 9],\n [-1, 6],\n [1, -6]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -3 & \\frac{9}{2} & 1 & \\frac{15}{2} \\\\\n 1 & -2 & -1 & -\\frac{19}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -6 & 1 & \\frac{9}{2} & -\\frac{9}{2} \\\\\n -\\frac{15}{2} & 1 & \\frac{15}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 3 & \\frac{7}{2} & -\\frac{7}{2} & 12 \\\\\n \\frac{17}{2} & -3 & -\\frac{17}{2} & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, (9/2), 1, (15/2)],\n [1, -2, -1, -(19/2)]])\nb = np.array([\n [-6, 1, (9/2), -(9/2)],\n [-(15/2), 1, (15/2), -(1/2)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -5 \\\\\n 7 \\\\\n 2 \\\\\n -8 \\\\\n -6 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 0 \\\\\n 2 \\\\\n 6 \\\\\n -9 \\\\\n -6 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$137$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-5],\n [7],\n [2],\n [-8],\n [-6],\n [1]])\nb = np.array([\n [-10],\n [0],\n [2],\n [6],\n [-9],\n [-6],\n [-7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -3 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 2 & 0 & -3 & 1 & -2 \\\\\n 2 & -2 & 1 & 2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -12 & 6 & 6 & -9 & 15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3]])\nb = np.array([\n [2, 0, -3, 1, -2],\n [2, -2, 1, 2, -3]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{2}{3} & -\\frac{11}{3} \\\\\n 9 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{6} \\left(-25-i \\sqrt{347}\\right),\\frac{1}{6} \\left(-25+i \\sqrt{347}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/3), -(11/3)],\n [9, -9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -\\frac{13}{4} \\\\\n -\\frac{67}{8} \\\\\n -\\frac{49}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{91}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-(13/4)],\n [-(67/8)],\n [-(49/8)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -4 & 0 \\\\\n 3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 0],\n [3, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n \\frac{4}{9} & \\frac{4}{3} \\\\\n -\\frac{1}{9} & -\\frac{8}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n \\frac{17}{9} & -\\frac{16}{9} & \\frac{22}{9} & \\frac{11}{9} & -\\frac{10}{9} \\\\\n -1 & -\\frac{5}{9} & -2 & \\frac{23}{9} & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -\\frac{40}{81} & -\\frac{124}{81} & -\\frac{128}{81} & \\frac{320}{81} & -\\frac{256}{81} \\\\\n \\frac{55}{81} & \\frac{56}{81} & \\frac{122}{81} & -\\frac{65}{27} & \\frac{154}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/9), (4/3)],\n [-(1/9), -(8/9)]])\nb = np.array([\n [(17/9), -(16/9), (22/9), (11/9), -(10/9)],\n [-1, -(5/9), -2, (23/9), -2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -3 & -7 \\\\\n -1 & -1 \\\\\n 9 & 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 6 & -10 \\\\\n 6 & 1 \\\\\n -7 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 3 & -17 \\\\\n 5 & 0 \\\\\n 2 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -7],\n [-1, -1],\n [9, 4]])\nb = np.array([\n [6, -10],\n [6, 1],\n [-7, -7]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{16}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & 2 \\\\\n 9 & 10 \\\\\n 3 & 6 \\\\\n 5 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{3}{16} & \\frac{1}{8} \\\\\n \\frac{9}{16} & \\frac{5}{8} \\\\\n \\frac{3}{16} & \\frac{3}{8} \\\\\n \\frac{5}{16} & -\\frac{9}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2],\n [9, 10],\n [3, 6],\n [5, -9]])\nprint(a * (1/16))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -6 \\\\\n -4 \\\\\n 2 \\\\\n 7 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 8 \\\\\n 6 \\\\\n -2 \\\\\n 8 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-89$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-6],\n [-4],\n [2],\n [7],\n [-3]])\nb = np.array([\n [-9],\n [8],\n [6],\n [-2],\n [8],\n [8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{5} \\\\\n -\\frac{79}{10} \\\\\n -\\frac{33}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{23}{10} \\\\\n \\frac{39}{10} \\\\\n -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3211}{50} \\\\\n -\\frac{3011}{100} \\\\\n -\\frac{4079}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/5)],\n [-(79/10)],\n [-(33/10)]])\nb = np.array([\n [-(23/10)],\n [(39/10)],\n [-(13/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -4 & -\\frac{1}{5} & -\\frac{11}{5} \\\\\n -7 & -\\frac{3}{5} & \\frac{43}{5} \\\\\n -\\frac{39}{5} & \\frac{2}{5} & \\frac{44}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-5.287,-0.95,10.437\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -(1/5), -(11/5)],\n [-7, -(3/5), (43/5)],\n [-(39/5), (2/5), (44/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -5 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 0 \\\\\n -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 45 \\\\\n 94 \\\\\n 40 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-5],\n [5]])\nb = np.array([\n [8],\n [0],\n [-9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{11}{16} & -\\frac{21}{8} \\\\\n -\\frac{7}{8} & \\frac{1}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{5 x}{8}-\\frac{599}{256}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/16), -(21/8)],\n [-(7/8), (1/16)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -9 & -10 \\\\\n -6 & 10 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -2 & -6 \\\\\n 3 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -7 & -4 \\\\\n -9 & 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -10],\n [-6, 10]])\nb = np.array([\n [-2, -6],\n [3, 1]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{16}{5} & \\frac{2}{5} \\\\\n \\frac{6}{5} & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{92}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(16/5), (2/5)],\n [(6/5), -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -9 & 9 & -10 \\\\\n 2 & -4 & -1 \\\\\n 2 & 3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, 9, -10],\n [2, -4, -1],\n [2, 3, -2]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & 3 & 1 \\\\\n 1 & -1 & 1 \\\\\n 3 & 1 & 3 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 6 & -2 & 6 \\\\\n 2 & 5 & 3 \\\\\n 10 & 11 & 13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 3, 1],\n [1, -1, 1],\n [3, 1, 3]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{48}{5} & \\frac{17}{5} & -\\frac{7}{10} \\\\\n -\\frac{51}{10} & \\frac{3}{2} & \\frac{21}{10} \\\\\n -\\frac{48}{5} & -\\frac{49}{5} & -\\frac{43}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{34 x^2}{5}+\\frac{213 x}{100}-\\frac{13131}{250}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(48/5), (17/5), -(7/10)],\n [-(51/10), (3/2), (21/10)],\n [-(48/5), -(49/5), -(43/10)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{4} \\\\\n \\frac{5}{2} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -\\frac{11}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{108}{185},\\frac{297}{370}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/4)],\n [(5/2)]]).squeeze()\nb = np.array([\n [2],\n [-(11/4)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n e \\\\\n 3 e \\\\\n 2 e \\\\\n -2 e \\\\\n -2 e \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n e \\\\\n -4 e \\\\\n -3 e \\\\\n -e \\\\\n e \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-17 e^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.e],\n [3*math.e],\n [2*math.e],\n [-2*math.e],\n [-2*math.e]])\nb = np.array([\n [math.e],\n [-4*math.e],\n [-3*math.e],\n [-math.e],\n [math.e]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{9}{5}, -\\frac{23}{5}}$ to the line $-\\frac{21 x}{5}-3 y-\\frac{24}{5}=0$.", - "Output Answer": [ - "$\\frac{69 \\sqrt{\\frac{2}{37}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(9/5), -(23/5)\nline = Poly(-((21*x)/5)-3*y-(24/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -7 & 3 & 0 \\\\\n -7 & -6 & 7 \\\\\n 8 & -8 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.173,0.608,1.\\}, \\{-0.455-0.652 i,1.016\\, -1.431 i,1.\\}, \\{-0.455+0.652 i,1.016\\, +1.431 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 3, 0],\n [-7, -6, 7],\n [8, -8, 7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{9}{5} & -2 & -\\frac{18}{5} \\\\\n \\frac{23}{5} & \\frac{23}{5} & \\frac{23}{5} \\\\\n \\frac{13}{5} & -\\frac{11}{5} & -\\frac{23}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{5}{3} & \\frac{40}{207} & -\\frac{10}{9} \\\\\n -5 & -\\frac{15}{92} & \\frac{15}{4} \\\\\n \\frac{10}{3} & \\frac{155}{828} & -\\frac{95}{36} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/5), -2, -(18/5)],\n [(23/5), (23/5), (23/5)],\n [(13/5), -(11/5), -(23/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,-3,2\\}, \\{1,-4,3\\}, \\{3,3,-2\\}}$.", - "Output Answer": [ - "$2 x-27 y-37 z+1=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, -3, 2],\n [1, -4, 3],\n [3, 3, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{5,-5,1\\}, \\{2,1,2\\}, \\{2,-2,0\\}}$.", - "Output Answer": [ - "$3 x+2 y-3 z-2=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [5, -5, 1],\n [2, 1, 2],\n [2, -2, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{3}{2},0,-\\frac{3}{2}\\right\\}, \\left\\{-\\frac{1}{4},-\\frac{1}{4},-\\frac{5}{4}\\right\\}, \\left\\{\\frac{1}{4},0,-\\frac{5}{4}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{2}},0,-\\frac{1}{\\sqrt{2}}\\right\\}, \\left\\{-\\frac{3}{\\sqrt{19}},-\\frac{1}{\\sqrt{19}},-\\frac{3}{\\sqrt{19}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{38}},3 \\sqrt{\\frac{2}{19}},-\\frac{1}{\\sqrt{38}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack((((3/2), 0, -(3/2)), (-(1/4), -(1/4), -(5/4)), ((1/4), 0, -(5/4))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -3 \\\\\n 1 \\\\\n 1 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{17}} \\\\\n -\\frac{3}{\\sqrt{17}} \\\\\n \\frac{1}{\\sqrt{17}} \\\\\n \\frac{1}{\\sqrt{17}} \\\\\n -\\frac{2}{\\sqrt{17}} \\\\\n \\frac{1}{\\sqrt{17}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-3],\n [1],\n [1],\n [-2],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{4} \\\\\n 8 \\\\\n \\frac{11}{4} \\\\\n \\frac{19}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{4} \\\\\n 9 \\\\\n -\\frac{13}{4} \\\\\n \\frac{9}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 6 \\\\\n \\frac{5}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/4)],\n [8],\n [(11/4)],\n [(19/4)]])\nb = np.array([\n [-(5/4)],\n [9],\n [-(13/4)],\n [(9/4)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{4} \\\\\n \\frac{1}{2} \\\\\n \\frac{15}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n \\frac{35}{4} \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{533}{8} \\\\\n -\\frac{55}{4} \\\\\n -\\frac{163}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/4)],\n [(1/2)],\n [(15/2)]])\nb = np.array([\n [-(3/2)],\n [(35/4)],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 3 & \\frac{5}{2} & -\\frac{1}{2} \\\\\n \\frac{1}{2} & 1 & -2 \\\\\n -\\frac{5}{2} & \\frac{3}{2} & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{23}{2} & \\frac{37}{4} & -6 \\\\\n 7 & -\\frac{3}{4} & -\\frac{1}{4} \\\\\n -\\frac{17}{4} & -\\frac{25}{4} & -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, (5/2), -(1/2)],\n [(1/2), 1, -2],\n [-(5/2), (3/2), -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -6 & 8 & 5 \\\\\n 4 & 10 & 8 \\\\\n -4 & 3 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+6 x^2+88 x-36$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 8, 5],\n [4, 10, 8],\n [-4, 3, 2]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${0, 5}$ to the line $x-3 y+1=0$.", - "Output Answer": [ - "$7 \\sqrt{\\frac{2}{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 0, 5\nline = Poly(x-3*y+1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & -2 & -3 \\\\\n 4 & 4 & 4 \\\\\n -4 & 0 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$104$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -2, -3],\n [4, 4, 4],\n [-4, 0, 5]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n 10 & -7 \\\\\n -1 & 3 \\\\\n 2 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -7],\n [-1, 3],\n [2, 7]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,-4,0\\}, \\{-1,-3,0\\}, \\{2,-4,1\\}}$.", - "Output Answer": [ - "$x-2 y-5 z-5=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, -4, 0],\n [-1, -3, 0],\n [2, -4, 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [1]])\nb = np.array([\n [2],\n [2]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 4 & 8 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 3 & 5 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 7 & 13 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 8, 0]])\nb = np.array([\n [3, 5, 8]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 3 & -\\frac{5}{2} & -2 \\\\\n 0 & 0 & \\frac{5}{2} \\\\\n 2 & 2 & 0 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 5 & -\\frac{23}{2} & -\\frac{49}{4} \\\\\n 5 & 5 & 0 \\\\\n 6 & -5 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -(5/2), -2],\n [0, 0, (5/2)],\n [2, 2, 0]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{39}{4} & \\frac{9}{2} \\\\\n \\frac{15}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{60} \\left(-41-\\sqrt{3841}\\right),1\\right\\}, \\left\\{\\frac{1}{60} \\left(\\sqrt{3841}-41\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(39/4), (9/2)],\n [(15/2), (1/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, \\frac{4}{3}}$ to the line $\\frac{5 x}{3}+\\frac{5 y}{3}-\\frac{13}{3}=0$.", - "Output Answer": [ - "$\\frac{49}{15 \\sqrt{2}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, (4/3)\nline = Poly(((5*x)/3)+((5*y)/3)-(13/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & 8 \\\\\n -10 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-7-i \\sqrt{271}\\right),\\frac{1}{2} \\left(-7+i \\sqrt{271}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 8],\n [-10, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 5 & 8 & 4 & 9 \\\\\n -4 & -4 & 3 & -5 \\\\\n -9 & -7 & 6 & 8 \\\\\n -2 & -7 & -8 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, 8, 4, 9],\n [-4, -4, 3, -5],\n [-9, -7, 6, 8],\n [-2, -7, -8, -3]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 8 & 5 \\\\\n -2 & -9 \\\\\n 5 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [8, 5],\n [-2, -9],\n [5, 4]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -11 \\log (2) \\\\\n 9 \\log (2) \\\\\n 7 \\log (2) \\\\\n 10 \\log (2) \\\\\n 2 \\log (2) \\\\\n 7 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\log (2) \\\\\n \\log (2) \\\\\n 6 \\log (2) \\\\\n 14 \\log (2) \\\\\n 3 \\log (2) \\\\\n -8 \\log (2) \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{503} \\log (2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-11*math.log(2)],\n [9*math.log(2)],\n [7*math.log(2)],\n [10*math.log(2)],\n [2*math.log(2)],\n [7*math.log(2)]])\nb = np.array([\n [3*math.log(2)],\n [math.log(2)],\n [6*math.log(2)],\n [14*math.log(2)],\n [3*math.log(2)],\n [-8*math.log(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -8 \\\\\n 5 \\\\\n 7 \\\\\n -4 \\\\\n -8 \\\\\n 0 \\\\\n 5 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 7 \\\\\n -8 \\\\\n -7 \\\\\n 0 \\\\\n 7 \\\\\n 1 \\\\\n -9 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{1158}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-8],\n [5],\n [7],\n [-4],\n [-8],\n [0],\n [5],\n [2]])\nb = np.array([\n [-8],\n [7],\n [-8],\n [-7],\n [0],\n [7],\n [1],\n [-9],\n [-1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{469}{100} \\\\\n \\frac{123}{25} \\\\\n \\frac{53}{20} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{517}{100} \\\\\n \\frac{353}{100} \\\\\n \\frac{191}{20} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{75263}{2000} \\\\\n \\frac{31089}{1000} \\\\\n \\frac{88807}{10000} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(469/100)],\n [(123/25)],\n [(53/20)]])\nb = np.array([\n [-(517/100)],\n [(353/100)],\n [(191/20)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & 1 \\\\\n -1 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(15-\\sqrt{5}\\right),\\frac{1}{2} \\left(15+\\sqrt{5}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 1],\n [-1, 9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -9 & -1 & 2 \\\\\n 3 & 9 & 8 \\\\\n -1 & 1 & -4 \\\\\n -4 & 8 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-9, -1, 2],\n [3, 9, 8],\n [-1, 1, -4],\n [-4, 8, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & 2 \\\\\n 3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{4-\\sqrt{15},4+\\sqrt{15}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 2],\n [3, 1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{1,-\\frac{7}{2},\\frac{5}{2}\\right\\}, \\left\\{\\frac{7}{2},\\frac{5}{2},\\frac{7}{2}\\right\\}, \\left\\{\\frac{1}{2},-5,-\\frac{1}{2}\\right\\}}$.", - "Output Answer": [ - "$6 (22 x+z)-7 (8 y+49)=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -(7/2), (5/2)],\n [(7/2), (5/2), (7/2)],\n [(1/2), -5, -(1/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -10 & -1 & 10 & 2 & -5 & -7 \\\\\n 4 & 3 & 9 & 5 & -2 & 4 \\\\\n -4 & 8 & 4 & -3 & -5 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & \\frac{139}{364} & \\frac{109}{364} & \\frac{369}{364} \\\\\n 0 & 1 & 0 & -\\frac{19}{42} & -\\frac{5}{14} & -\\frac{31}{42} \\\\\n 0 & 0 & 1 & \\frac{293}{546} & -\\frac{43}{182} & \\frac{131}{546} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, -1, 10, 2, -5, -7],\n [4, 3, 9, 5, -2, 4],\n [-4, 8, 4, -3, -5, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & 8 \\\\\n 3 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+3 x-52$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 8],\n [3, 4]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,1,-2\\}, \\left\\{-\\frac{4}{3},\\frac{11}{3},1\\right\\}, \\left\\{\\frac{5}{3},-\\frac{4}{3},-\\frac{11}{3}\\right\\}}$.", - "Output Answer": [ - "$23 x+25 y-12 z-49=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, 1, -2],\n [-(4/3), (11/3), 1],\n [(5/3), -(4/3), -(11/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{7}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{0,1\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [1]]).squeeze()\nb = np.array([\n [0],\n [-(7/4)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1}{\\sqrt{6}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [1],\n [-1],\n [0],\n [1],\n [-1],\n [-1],\n [-1],\n [-1]]).squeeze()\nb = np.array([\n [1],\n [-1],\n [0],\n [1],\n [1],\n [-1],\n [0],\n [1],\n [0],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 8 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -2 \\\\\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 54 \\\\\n 27 \\\\\n 48 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [8],\n [-9]])\nb = np.array([\n [-7],\n [-2],\n [9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${0, 4}$ to the line $-3 x-2 y=0$.", - "Output Answer": [ - "$\\frac{8}{\\sqrt{13}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 0, 4\nline = Poly(-3*x-2*y, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 9 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 4 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 32 \\\\\n 4 \\\\\n 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [9],\n [10]])\nb = np.array([\n [-2],\n [4],\n [8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & 7 \\\\\n -10 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-9 x+70$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 7],\n [-10, 9]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -1 & -1 \\\\\n 5 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{0,4\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1],\n [5, 5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{100}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 9 & 4 & 3 \\\\\n -2 & -2 & -1 \\\\\n -10 & -1 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{27}{100} & -\\frac{3}{25} & -\\frac{9}{100} \\\\\n \\frac{3}{50} & \\frac{3}{50} & \\frac{3}{100} \\\\\n \\frac{3}{10} & \\frac{3}{100} & -\\frac{6}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 4, 3],\n [-2, -2, -1],\n [-10, -1, 8]])\nprint(a * -(3/100))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -4-\\frac{7 i}{2} & \\frac{9}{2}+\\frac{7 i}{2} & -2-\\frac{9 i}{2} \\\\\n 4-3 i & -\\frac{5}{2}-\\frac{i}{2} & 4-2 i \\\\\n \\frac{1}{2}-\\frac{9 i}{2} & 4-4 i & \\frac{7}{2}-2 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 11+\\frac{141 i}{4} & -\\frac{165}{4}-\\frac{203 i}{4} & \\frac{5}{4}+\\frac{73 i}{4} \\\\\n -45-\\frac{31 i}{2} & \\frac{85}{2}-21 i & -\\frac{45}{2}-24 i \\\\\n -21-\\frac{57 i}{2} & 12-\\frac{65 i}{2} & -5-\\frac{125 i}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4-((7j)/2), (9/2)+((7j)/2), -2-((9j)/2)],\n [4-3j, -(5/2)-(1j/2), 4-2j],\n [(1/2)-((9j)/2), 4-4j, (7/2)-2j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{16}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 9 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{35}{8} \\\\\n -\\frac{63}{16} \\\\\n \\frac{63}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [9],\n [-9]])\nprint(a * -(7/16))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -7 \\\\\n -6 \\\\\n 0 \\\\\n 5 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$21$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-7],\n [-6],\n [0],\n [5],\n [1]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{20}{3} & \\frac{1}{3} \\\\\n -\\frac{26}{3} & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{3} \\left(2-\\sqrt{458}\\right),\\frac{1}{3} \\left(2+\\sqrt{458}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/3), (1/3)],\n [-(26/3), 8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n \\frac{9}{5} & -\\frac{1}{5} & \\frac{3}{5} & \\frac{8}{5} \\\\\n -1 & -1 & \\frac{3}{5} & 2 \\\\\n -\\frac{12}{5} & -\\frac{11}{5} & \\frac{9}{5} & -1 \\\\\n -\\frac{3}{5} & -3 & -\\frac{9}{5} & 2 \\\\\n 2 & 1 & -\\frac{14}{5} & -\\frac{14}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{8}{5} \\\\\n -\\frac{7}{5} \\\\\n -2 \\\\\n -\\frac{13}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{199}{25} \\\\\n -\\frac{17}{5} \\\\\n \\frac{148}{25} \\\\\n \\frac{89}{25} \\\\\n \\frac{207}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/5), -(1/5), (3/5), (8/5)],\n [-1, -1, (3/5), 2],\n [-(12/5), -(11/5), (9/5), -1],\n [-(3/5), -3, -(9/5), 2],\n [2, 1, -(14/5), -(14/5)]])\nb = np.array([\n [-(8/5)],\n [-(7/5)],\n [-2],\n [-(13/5)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{2} \\\\\n -\\frac{17}{4} \\\\\n \\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/2)],\n [-(17/4)],\n [(9/2)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -6 & 2 & -6 \\\\\n 9 & 6 & -10 \\\\\n 6 & -1 & 5 \\\\\n -8 & 2 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-6, 2, -6],\n [9, 6, -10],\n [6, -1, 5],\n [-8, 2, -8]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 6 & -4 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -7 & 7 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & 3 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -4, 8]])\nb = np.array([\n [-7, 7, -6]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -\\frac{34}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(34/7)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & 2 \\\\\n 3 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-42$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 2],\n [3, -6]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 7 & -1 \\\\\n 1 & 1 \\\\\n 6 & 8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -1 & 8 \\\\\n -7 & 4 \\\\\n -5 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 8 & -9 \\\\\n 8 & -3 \\\\\n 11 & 16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -1],\n [1, 1],\n [6, 8]])\nb = np.array([\n [-1, 8],\n [-7, 4],\n [-5, -8]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 3 & -2 & -1 \\\\\n -7 & 4 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 3 \\\\\n 0 & 1 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, -2, -1],\n [-7, 4, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 7 & 2 & 0 & -10 & 10 & -3 & 1 \\\\\n 2 & -8 & -5 & 0 & 7 & -1 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & -\\frac{1}{6} & -\\frac{4}{3} & \\frac{47}{30} & -\\frac{13}{30} & -\\frac{1}{15} \\\\\n 0 & 1 & \\frac{7}{12} & -\\frac{1}{3} & -\\frac{29}{60} & \\frac{1}{60} & \\frac{11}{15} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, 2, 0, -10, 10, -3, 1],\n [2, -8, -5, 0, 7, -1, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -6 & -9 & -5 \\\\\n 7 & 10 & 0 \\\\\n 9 & -7 & -8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -10 & -3 & 9 \\\\\n 8 & 3 & 8 \\\\\n 7 & -1 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 4 & -6 & -14 \\\\\n -1 & 7 & -8 \\\\\n 2 & -6 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -9, -5],\n [7, 10, 0],\n [9, -7, -8]])\nb = np.array([\n [-10, -3, 9],\n [8, 3, 8],\n [7, -1, -5]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{27}{10} & -\\frac{21}{10} \\\\\n -\\frac{8}{5} & \\frac{9}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{411}{50}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(27/10), -(21/10)],\n [-(8/5), (9/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{5,2,-5\\}, \\left\\{-4,\\frac{3}{2},\\frac{3}{2}\\right\\}, \\left\\{-\\frac{3}{2},2,-\\frac{5}{2}\\right\\}}$.", - "Output Answer": [ - "$5 x+79 y+13 z-118=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [5, 2, -5],\n [-4, (3/2), (3/2)],\n [-(3/2), 2, -(5/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -2 & 1 \\\\\n -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{2}{3} & \\frac{1}{3} \\\\\n -\\frac{1}{3} & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 1],\n [-1, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 4 & 3 \\\\\n -6 & -4 \\\\\n -4 & -4 \\\\\n 2 & 8 \\\\\n 10 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, 3],\n [-6, -4],\n [-4, -4],\n [2, 8],\n [10, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [2],\n [1]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 0 & 1 & 0 \\\\\n 0 & 3 & -4 \\\\\n 0 & -4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 0 & 0 \\\\\n \\frac{1}{17} & 0 & -\\frac{4}{17} \\\\\n \\frac{3}{68} & -\\frac{1}{4} & -\\frac{3}{17} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 0],\n [0, 3, -4],\n [0, -4, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & 1 & 2 \\\\\n -1 & -2 & 3 \\\\\n -1 & 1 & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -8 & 1 & -1 \\\\\n 0 & -22 & 14 \\\\\n 0 & 5 & -13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1, 2],\n [-1, -2, 3],\n [-1, 1, 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{13}{2}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 9 & 2 \\\\\n -1 & -2 \\\\\n -10 & -5 \\\\\n -3 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{117}{2} & -13 \\\\\n \\frac{13}{2} & 13 \\\\\n 65 & \\frac{65}{2} \\\\\n \\frac{39}{2} & \\frac{117}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 2],\n [-1, -2],\n [-10, -5],\n [-3, -9]])\nprint(a * -(13/2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 1 & -2 & -2 \\\\\n 2 & -5 & 2 \\\\\n -5 & -4 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{3} & -\\frac{2}{99} & -\\frac{14}{99} \\\\\n 0 & -\\frac{5}{33} & -\\frac{2}{33} \\\\\n -\\frac{1}{3} & \\frac{14}{99} & -\\frac{1}{99} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2, -2],\n [2, -5, 2],\n [-5, -4, -5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{7} \\\\\n \\frac{12}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{145}} \\\\\n \\frac{12}{\\sqrt{145}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/7)],\n [(12/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & 3 \\\\\n \\frac{7}{3} & \\frac{19}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{3} \\left(23-\\sqrt{79}\\right),\\frac{1}{3} \\left(23+\\sqrt{79}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 3],\n [(7/3), (19/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{33}{10} \\\\\n -\\frac{44}{5} \\\\\n \\frac{43}{5} \\\\\n -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -\\frac{3}{2} \\\\\n -\\frac{28}{5} \\\\\n \\frac{13}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{57}{10} \\\\\n -\\frac{103}{10} \\\\\n 3 \\\\\n -\\frac{16}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(33/10)],\n [-(44/5)],\n [(43/5)],\n [-(9/2)]])\nb = np.array([\n [-9],\n [-(3/2)],\n [-(28/5)],\n [(13/10)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{2}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -10 & 9 & -6 \\\\\n -2 & -6 & -8 \\\\\n -8 & 0 & -4 \\\\\n 6 & 0 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -35 & \\frac{63}{2} & -21 \\\\\n -7 & -21 & -28 \\\\\n -28 & 0 & -14 \\\\\n 21 & 0 & -21 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 9, -6],\n [-2, -6, -8],\n [-8, 0, -4],\n [6, 0, -6]])\nprint(a * (7/2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -3 \\\\\n 2 \\\\\n 7 \\\\\n 9 \\\\\n 5 \\\\\n -7 \\\\\n 9 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -9 \\\\\n 5 \\\\\n 5 \\\\\n -5 \\\\\n 8 \\\\\n -4 \\\\\n 6 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{322}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-3],\n [2],\n [7],\n [9],\n [5],\n [-7],\n [9],\n [-2]])\nb = np.array([\n [3],\n [-9],\n [5],\n [5],\n [-5],\n [8],\n [-4],\n [6],\n [5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -10 & 0 \\\\\n 3 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-10,-4\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 0],\n [3, -4]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n \\frac{4}{3} & -\\frac{41}{6} \\\\\n -\\frac{5}{3} & -\\frac{14}{3} \\\\\n -\\frac{41}{6} & -\\frac{41}{6} \\\\\n -\\frac{11}{3} & -\\frac{23}{6} \\\\\n -\\frac{11}{2} & -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3), -(41/6)],\n [-(5/3), -(14/3)],\n [-(41/6), -(41/6)],\n [-(11/3), -(23/6)],\n [-(11/2), -(15/2)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{36}{5} & -4 \\\\\n -9 & -\\frac{26}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{5} \\left(5-\\sqrt{1861}\\right),\\frac{1}{5} \\left(5+\\sqrt{1861}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(36/5), -4],\n [-9, -(26/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -10 \\\\\n -1 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 7 \\\\\n 8 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{635}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-10],\n [-1],\n [3]])\nb = np.array([\n [5],\n [7],\n [8],\n [-9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & 2 \\\\\n -3 & 3 \\\\\n 2 & -2 \\\\\n 1 & -3 \\\\\n 2 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.26 \\\\\n -0.83 \\\\\n 0.8 \\\\\n 0.69 \\\\\n 1.67 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.358 \\\\\n 0.146 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2],\n [-3, 3],\n [2, -2],\n [1, -3],\n [2, 3]])\nb = np.array([\n [0.26],\n [-0.83],\n [0.8],\n [0.69],\n [1.67]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{7} \\\\\n -\\frac{3}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{10}} \\\\\n -\\frac{3}{\\sqrt{10}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/7)],\n [-(3/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -2 & -3 \\\\\n -3 & 2 & 1 \\\\\n 3 & 0 & 1 \\\\\n 0 & 1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.06 \\\\\n 2.6 \\\\\n 0.14 \\\\\n -1.59 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.491 \\\\\n -0.508 \\\\\n 0.02 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2, -3],\n [-3, 2, 1],\n [3, 0, 1],\n [0, 1, -1]])\nb = np.array([\n [2.06],\n [2.6],\n [0.14],\n [-1.59]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -5 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -1 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 43 \\\\\n -37 \\\\\n -50 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-5],\n [8]])\nb = np.array([\n [-9],\n [-1],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 6 & 4 & 7 \\\\\n -5 & -3 & 5 \\\\\n -8 & 4 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.072,-1.524,1.\\}, \\{-0.281-1.119 i,0.752\\, -0.111 i,1.\\}, \\{-0.281+1.119 i,0.752\\, +0.111 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 4, 7],\n [-5, -3, 5],\n [-8, 4, -1]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 9 & -5 & -9 & -7 \\\\\n -10 & 5 & 6 & -5 \\\\\n 2 & 7 & 3 & -6 \\\\\n -2 & -5 & 2 & 2 \\\\\n 1 & 10 & -5 & -6 \\\\\n -5 & 0 & -1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, -5, -9, -7],\n [-10, 5, 6, -5],\n [2, 7, 3, -6],\n [-2, -5, 2, 2],\n [1, 10, -5, -6],\n [-5, 0, -1, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 8 & 8 & -5 & -9 \\\\\n 5 & -2 & 6 & 7 \\\\\n 2 & 3 & -4 & -3 \\\\\n -4 & -2 & -3 & 5 \\\\\n 2 & -2 & 6 & -5 \\\\\n 1 & -2 & 2 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, 8, -5, -9],\n [5, -2, 6, 7],\n [2, 3, -4, -3],\n [-4, -2, -3, 5],\n [2, -2, 6, -5],\n [1, -2, 2, -10]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -9 & 3 & 1 \\\\\n 7 & 9 & 8 \\\\\n -8 & -2 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+8 x^2+78 x-1094$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 3, 1],\n [7, 9, 8],\n [-8, -2, 8]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & -1 & -1 & -1 & 1 \\\\\n -3 & -3 & 1 & 2 & -3 \\\\\n -3 & -1 & -3 & -1 & -1 \\\\\n -3 & -1 & 0 & 3 & 2 \\\\\n 0 & -2 & -1 & 0 & 2 \\\\\n -2 & -2 & 3 & 2 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.95 \\\\\n -0.99 \\\\\n -0.01 \\\\\n 1.46 \\\\\n 2.91 \\\\\n -0.2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.057 \\\\\n -0.431 \\\\\n -1.078 \\\\\n 1.463 \\\\\n 0.201 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, -1, -1, 1],\n [-3, -3, 1, 2, -3],\n [-3, -1, -3, -1, -1],\n [-3, -1, 0, 3, 2],\n [0, -2, -1, 0, 2],\n [-2, -2, 3, 2, 3]])\nb = np.array([\n [-2.95],\n [-0.99],\n [-0.01],\n [1.46],\n [2.91],\n [-0.2]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{14}{3} & -\\frac{1}{2} & \\frac{13}{6} \\\\\n \\frac{13}{6} & \\frac{10}{3} & \\frac{25}{6} \\\\\n -\\frac{1}{6} & -\\frac{19}{6} & \\frac{29}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1266}{6257} & \\frac{192}{6257} & \\frac{402}{6257} \\\\\n \\frac{2412}{31285} & \\frac{4794}{31285} & -\\frac{5214}{31285} \\\\\n \\frac{1362}{31285} & \\frac{3174}{31285} & \\frac{3126}{31285} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(14/3), -(1/2), (13/6)],\n [(13/6), (10/3), (25/6)],\n [-(1/6), -(19/6), (29/6)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n -6 \\\\\n 5 \\\\\n -5 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 2 \\\\\n 3 \\\\\n -3 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [-6],\n [5],\n [-5],\n [3]])\nb = np.array([\n [-7],\n [2],\n [3],\n [-3],\n [3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{8}{3} & \\frac{9}{2} \\\\\n -\\frac{5}{2} & -\\frac{13}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{156}{821} & -\\frac{162}{821} \\\\\n \\frac{90}{821} & -\\frac{96}{821} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/3), (9/2)],\n [-(5/2), -(13/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & 1 & -1 & 2 \\\\\n -2 & -1 & 1 & 2 \\\\\n 0 & -3 & -3 & -2 \\\\\n -1 & -2 & -2 & 3 \\\\\n -3 & -1 & -1 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.2 \\\\\n -1.89 \\\\\n -2.09 \\\\\n 0.71 \\\\\n 2.22 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.637 \\\\\n 1.062 \\\\\n -0.62 \\\\\n -0.126 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, -1, 2],\n [-2, -1, 1, 2],\n [0, -3, -3, -2],\n [-1, -2, -2, 3],\n [-3, -1, -1, -3]])\nb = np.array([\n [0.2],\n [-1.89],\n [-2.09],\n [0.71],\n [2.22]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 4 \\\\\n -1 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 2 \\\\\n -5 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{23}{\\sqrt{5254}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [4],\n [-1],\n [10]]).squeeze()\nb = np.array([\n [2],\n [2],\n [-5],\n [2]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 0 & 1 & 2 & -2 & 2 \\\\\n 2 & 1 & -3 & -2 & 3 \\\\\n -2 & -2 & 0 & 0 & -3 \\\\\n -1 & -2 & 0 & 3 & -2 \\\\\n 2 & -1 & -2 & 1 & -1 \\\\\n 1 & 1 & 0 & -1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0. \\\\\n 1.02 \\\\\n -1.21 \\\\\n 2.72 \\\\\n -0.93 \\\\\n 1.87 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.868 \\\\\n -1.07 \\\\\n -0.223 \\\\\n 0.983 \\\\\n 1.67 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 2, -2, 2],\n [2, 1, -3, -2, 3],\n [-2, -2, 0, 0, -3],\n [-1, -2, 0, 3, -2],\n [2, -1, -2, 1, -1],\n [1, 1, 0, -1, 3]])\nb = np.array([\n [0.],\n [1.02],\n [-1.21],\n [2.72],\n [-0.93],\n [1.87]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & -1 & 1 & -2 & 0 \\\\\n -3 & -2 & 0 & 1 & 1 \\\\\n -1 & -1 & 1 & 3 & 0 \\\\\n 0 & 2 & -2 & 2 & -2 \\\\\n 0 & 1 & 1 & 2 & -1 \\\\\n 3 & -3 & 2 & 3 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.49 \\\\\n 2.85 \\\\\n 0.61 \\\\\n 1.85 \\\\\n -0.34 \\\\\n -2.46 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.719 \\\\\n -0.182 \\\\\n -0.833 \\\\\n 0.246 \\\\\n -0.042 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, 1, -2, 0],\n [-3, -2, 0, 1, 1],\n [-1, -1, 1, 3, 0],\n [0, 2, -2, 2, -2],\n [0, 1, 1, 2, -1],\n [3, -3, 2, 3, -1]])\nb = np.array([\n [-0.49],\n [2.85],\n [0.61],\n [1.85],\n [-0.34],\n [-2.46]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 10 & -8 & -3 & -4 \\\\\n -2 & -2 & 7 & 9 \\\\\n 6 & -10 & 0 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-274.,-285.,-332.,134.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [10, -8, -3, -4],\n [-2, -2, 7, 9],\n [6, -10, 0, -9]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 0 & 10 & -5 & -9 & 1 \\\\\n -8 & 8 & 1 & -6 & 10 \\\\\n 8 & 5 & 8 & -4 & 4 \\\\\n 7 & 8 & -6 & -2 & -2 \\\\\n -8 & 10 & 4 & 3 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, 10, -5, -9, 1],\n [-8, 8, 1, -6, 10],\n [8, 5, 8, -4, 4],\n [7, 8, -6, -2, -2],\n [-8, 10, 4, 3, 6]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{91}{50} \\\\\n -\\frac{331}{50} \\\\\n \\frac{72}{25} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{489}{100} \\\\\n \\frac{463}{100} \\\\\n \\frac{212}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{8684}{125} \\\\\n -\\frac{844}{625} \\\\\n \\frac{25499}{625} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(91/50)],\n [-(331/50)],\n [(72/25)]])\nb = np.array([\n [(489/100)],\n [(463/100)],\n [(212/25)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -2 & -3 & -2 & -2 \\\\\n 2 & -3 & 2 & 1 \\\\\n -3 & 2 & 3 & 2 \\\\\n 1 & 3 & 2 & -2 \\\\\n 2 & 0 & -1 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -1 & -1 \\\\\n -1 & 2 \\\\\n 2 & 3 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & -10 \\\\\n 5 & -2 \\\\\n 7 & 16 \\\\\n 0 & 11 \\\\\n -4 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, -2, -2],\n [2, -3, 2, 1],\n [-3, 2, 3, 2],\n [1, 3, 2, -2],\n [2, 0, -1, 0]])\nb = np.array([\n [-1, -1],\n [-1, 2],\n [2, 3],\n [0, 0]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & 5 & 0 \\\\\n -10 & -2 & 0 \\\\\n -10 & 9 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.,0.,1.\\}, \\{0.573\\, +0.02 i,-0.086+0.806 i,1.\\}, \\{0.573\\, -0.02 i,-0.086-0.806 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 5, 0],\n [-10, -2, 0],\n [-10, 9, 5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{3} & -\\frac{7}{9} & -\\frac{20}{9} \\\\\n 2 & -\\frac{7}{9} & \\frac{4}{3} \\\\\n \\frac{10}{3} & -\\frac{23}{9} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{99}{227} & -\\frac{39}{227} & \\frac{42}{227} \\\\\n -\\frac{189}{227} & -\\frac{855}{908} & \\frac{135}{908} \\\\\n \\frac{153}{908} & \\frac{1665}{3632} & -\\frac{693}{3632} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/3), -(7/9), -(20/9)],\n [2, -(7/9), (4/3)],\n [(10/3), -(23/9), -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -5 & -2 & -8 \\\\\n -3 & -7 & 8 \\\\\n -8 & 10 & 7 \\\\\n 0 & 9 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, -2, -8],\n [-3, -7, 8],\n [-8, 10, 7],\n [0, 9, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -\\frac{16}{3} \\\\\n \\frac{52}{9} \\\\\n -\\frac{13}{9} \\\\\n \\frac{17}{3} \\\\\n -\\frac{58}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(16/3)],\n [(52/9)],\n [-(13/9)],\n [(17/3)],\n [-(58/9)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 7 \\\\\n 3 \\\\\n -10 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 9 \\\\\n -1 \\\\\n -4 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{181}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [7],\n [3],\n [-10],\n [4]])\nb = np.array([\n [-3],\n [9],\n [-1],\n [-4],\n [-6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{12}{5}, -\\frac{6}{5}}$ to the line $-\\frac{14 x}{5}-\\frac{11 y}{5}+\\frac{11}{5}=0$.", - "Output Answer": [ - "$\\frac{289}{5 \\sqrt{317}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(12/5), -(6/5)\nline = Poly(-((14*x)/5)-((11*y)/5)+(11/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & 0 & -9 \\\\\n 4 & 1 & 6 \\\\\n -1 & 3 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-10.835,0.917\\, -1.742 i,0.917\\, +1.742 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, -9],\n [4, 1, 6],\n [-1, 3, -7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{11}{6} & -\\frac{4}{3} \\\\\n \\frac{7}{3} & \\frac{17}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{299}{36}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/6), -(4/3)],\n [(7/3), (17/6)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{2}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 8 & -2 \\\\\n -1 & -9 \\\\\n -4 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -20 & 5 \\\\\n \\frac{5}{2} & \\frac{45}{2} \\\\\n 10 & 25 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -2],\n [-1, -9],\n [-4, -10]])\nprint(a * -(5/2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 4 & 2 & \\frac{4}{3} \\\\\n -2 & \\frac{1}{6} & \\frac{8}{3} \\\\\n -\\frac{1}{3} & \\frac{7}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{999}{4972} & -\\frac{9}{113} & -\\frac{138}{1243} \\\\\n -\\frac{3}{1243} & -\\frac{6}{113} & \\frac{360}{1243} \\\\\n \\frac{375}{2486} & \\frac{36}{113} & -\\frac{126}{1243} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 2, (4/3)],\n [-2, (1/6), (8/3)],\n [-(1/3), (7/2), (1/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 7 & 4 & 2 \\\\\n -5 & 1 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & -\\frac{38}{27} \\\\\n 0 & 1 & \\frac{80}{27} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, 4, 2],\n [-5, 1, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & 9 \\\\\n -3 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(1-\\sqrt{181}\\right),\\frac{1}{2} \\left(1+\\sqrt{181}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 9],\n [-3, 9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{0,0,0\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-3],\n [2]]).squeeze()\nb = np.array([\n [0],\n [2],\n [3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{3} & -\\frac{7}{3} \\\\\n -\\frac{10}{3} & \\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{5}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3), -(7/3)],\n [-(10/3), (11/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{38}{7} \\\\\n \\frac{52}{7} \\\\\n -\\frac{13}{7} \\\\\n \\frac{25}{7} \\\\\n \\frac{68}{7} \\\\\n -\\frac{1}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{3 \\sqrt{1063}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(38/7)],\n [(52/7)],\n [-(13/7)],\n [(25/7)],\n [(68/7)],\n [-(1/7)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,0,-3\\}, \\{2,-1,3\\}, \\{1,2,2\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{2}{\\sqrt{13}},0,-\\frac{3}{\\sqrt{13}}\\right\\}, \\left\\{\\frac{36}{\\sqrt{2041}},-\\sqrt{\\frac{13}{157}},\\frac{24}{\\sqrt{2041}}\\right\\}, \\left\\{\\frac{3}{\\sqrt{157}},\\frac{12}{\\sqrt{157}},\\frac{2}{\\sqrt{157}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, 0, -3), (2, -1, 3), (1, 2, 2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 5 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 0 \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 30 \\\\\n 32 \\\\\n -20 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [5],\n [-4]])\nb = np.array([\n [4],\n [0],\n [6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -2 & 0 & -1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 6 & 0 & 3 & 0 \\\\\n -4 & 0 & -2 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [2],\n [0]])\nb = np.array([\n [-2, 0, -1, 0]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{513}{100} \\\\\n -\\frac{12}{25} \\\\\n -\\frac{737}{100} \\\\\n \\frac{847}{100} \\\\\n \\frac{104}{25} \\\\\n -\\frac{15}{2} \\\\\n -\\frac{361}{50} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{4033}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(513/100)],\n [-(12/25)],\n [-(737/100)],\n [(847/100)],\n [(104/25)],\n [-(15/2)],\n [-(361/50)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{10}{3} & \\frac{10}{3} \\\\\n \\frac{2}{3} & \\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{70}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(10/3), (10/3)],\n [(2/3), (5/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 1 & -7 & 3 & -9 \\\\\n 6 & -7 & 4 & -8 \\\\\n 7 & -1 & 4 & 3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 10 & 1 & -10 & 8 \\\\\n -4 & 7 & -5 & -8 \\\\\n -8 & -8 & 1 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -9 & -8 & 13 & -17 \\\\\n 10 & -14 & 9 & 0 \\\\\n 15 & 7 & 3 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -7, 3, -9],\n [6, -7, 4, -8],\n [7, -1, 4, 3]])\nb = np.array([\n [10, 1, -10, 8],\n [-4, 7, -5, -8],\n [-8, -8, 1, 8]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [0],\n [1],\n [0],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [0],\n [0],\n [1],\n [0],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n \\frac{25}{4} & \\frac{33}{4} & -\\frac{3}{4} & 2 \\\\\n \\frac{39}{4} & \\frac{11}{4} & -9 & \\frac{27}{4} \\\\\n 7 & \\frac{17}{4} & -\\frac{27}{4} & \\frac{33}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(25/4), (33/4), -(3/4), 2],\n [(39/4), (11/4), -9, (27/4)],\n [7, (17/4), -(27/4), (33/4)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 7 \\\\\n 8 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 2 \\\\\n -7 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-118$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [7],\n [8],\n [-8]])\nb = np.array([\n [-6],\n [2],\n [-7],\n [5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{5,-3,1\\}, \\{-3,4,-4\\}, \\{5,-3,4\\}}$.", - "Output Answer": [ - "$7 x+8 y-11=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [5, -3, 1],\n [-3, 4, -4],\n [5, -3, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & 0 \\\\\n -2 & -1 \\\\\n 2 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.09 \\\\\n 0.66 \\\\\n -1.64 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.932 \\\\\n 1.205 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0],\n [-2, -1],\n [2, 0]])\nb = np.array([\n [-2.09],\n [0.66],\n [-1.64]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,3,4\\}, \\{-2,4,4\\}, \\{3,-4,-2\\}}$.", - "Output Answer": [ - "$2 (x+y)-z=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, 3, 4],\n [-2, 4, 4],\n [3, -4, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -5 \\\\\n 1 \\\\\n -8 \\\\\n -10 \\\\\n -6 \\\\\n 7 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -8 \\\\\n 4 \\\\\n 9 \\\\\n 1 \\\\\n 7 \\\\\n 2 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{158}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-5],\n [1],\n [-8],\n [-10],\n [-6],\n [7],\n [1]])\nb = np.array([\n [1],\n [-8],\n [4],\n [9],\n [1],\n [7],\n [2],\n [4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -7 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-7],\n [9]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 0 & -2 & 0 & 1 & -1 \\\\\n 2 & -1 & -2 & -2 & 1 \\\\\n 1 & 3 & 3 & 2 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 0 & 3 & -1 & 0 \\\\\n -1 & 2 & 1 & -3 \\\\\n 0 & 0 & 0 & 0 \\\\\n 3 & 0 & 2 & -2 \\\\\n 1 & 0 & -3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 4 & -4 & 3 & 4 \\\\\n -4 & 4 & -10 & 7 \\\\\n 3 & 9 & 6 & -13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2, 0, 1, -1],\n [2, -1, -2, -2, 1],\n [1, 3, 3, 2, 0]])\nb = np.array([\n [0, 3, -1, 0],\n [-1, 2, 1, -3],\n [0, 0, 0, 0],\n [3, 0, 2, -2],\n [1, 0, -3, 0]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n \\frac{31}{5} & \\frac{27}{5} & -4 & \\frac{2}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(31/5), (27/5), -4, (2/5)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & -5 & 0 \\\\\n -4 & -1 & 0 \\\\\n 3 & 2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-44$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -5, 0],\n [-4, -1, 0],\n [3, 2, 2]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -5 & 3 & 6 & -3 & 9 \\\\\n 2 & -7 & 3 & -5 & 6 \\\\\n -6 & 6 & 3 & -7 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-375.,-222.,-173.,57.,0.\\}, \\{-216.,-111.,-153.,0.,19.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, 3, 6, -3, 9],\n [2, -7, 3, -5, 6],\n [-6, 6, 3, -7, -9]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{7}{3}, -\\frac{7}{3}, -5}$ to the plane $\\frac{13 x}{3}-\\frac{14 y}{3}-\\frac{8 z}{3}-\\frac{1}{3}=0$.", - "Output Answer": [ - "$34 \\sqrt{\\frac{3}{143}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (7/3), -(7/3), -5\nplane = Poly(((13*x)/3)-((14*y)/3)-((8*z)/3)-(1/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -8 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 3 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{46}{\\sqrt{10549}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-8],\n [8]]).squeeze()\nb = np.array([\n [2],\n [3],\n [8]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{13}{16} & \\frac{13}{4} \\\\\n -3 & -\\frac{27}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{144}{949} & -\\frac{64}{219} \\\\\n \\frac{256}{949} & -\\frac{16}{219} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/16), (13/4)],\n [-3, -(27/16)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n -\\frac{1}{2} \\\\\n \\frac{13}{8} \\\\\n 0 \\\\\n -\\frac{15}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2 \\sqrt{\\frac{2}{213}} \\\\\n -2 \\sqrt{\\frac{2}{213}} \\\\\n \\frac{13}{\\sqrt{426}} \\\\\n 0 \\\\\n -5 \\sqrt{\\frac{3}{142}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2)],\n [-(1/2)],\n [(13/8)],\n [0],\n [-(15/8)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 10 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -\\frac{19}{2} \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{292}{3 \\sqrt{11289}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [10],\n [-8]]).squeeze()\nb = np.array([\n [5],\n [-(19/2)],\n [2]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{7}{2} & \\frac{37}{4} & \\frac{19}{4} & -\\frac{11}{2} \\\\\n -8 & 0 & -\\frac{13}{4} & -\\frac{19}{4} \\\\\n \\frac{9}{2} & -\\frac{1}{2} & \\frac{15}{4} & 9 \\\\\n \\frac{13}{2} & -3 & \\frac{39}{4} & -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{5}{2} & -\\frac{21}{4} & -9 & -\\frac{19}{4} \\\\\n \\frac{39}{4} & 2 & -\\frac{11}{2} & -6 \\\\\n \\frac{1}{4} & \\frac{37}{4} & -\\frac{3}{4} & -\\frac{21}{4} \\\\\n -\\frac{3}{4} & -6 & \\frac{13}{4} & \\frac{17}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 6 & 4 & -\\frac{17}{4} & -\\frac{41}{4} \\\\\n \\frac{7}{4} & 2 & -\\frac{35}{4} & -\\frac{43}{4} \\\\\n \\frac{19}{4} & \\frac{35}{4} & 3 & \\frac{15}{4} \\\\\n \\frac{23}{4} & -9 & 13 & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2), (37/4), (19/4), -(11/2)],\n [-8, 0, -(13/4), -(19/4)],\n [(9/2), -(1/2), (15/4), 9],\n [(13/2), -3, (39/4), -8]])\nb = np.array([\n [(5/2), -(21/4), -9, -(19/4)],\n [(39/4), 2, -(11/2), -6],\n [(1/4), (37/4), -(3/4), -(21/4)],\n [-(3/4), -6, (13/4), (17/2)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & 6 \\\\\n 2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1,1\\}, \\{3,1\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 6],\n [2, -3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -10 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 4 \\\\\n -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2 \\\\\n -60 \\\\\n -74 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-10],\n [8]])\nb = np.array([\n [-9],\n [4],\n [-3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -7 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 4 \\\\\n -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 60 \\\\\n 5 \\\\\n -35 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-7],\n [-1]])\nb = np.array([\n [-5],\n [4],\n [-8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{4} & -\\frac{39}{4} \\\\\n \\frac{3}{4} & -\\frac{15}{4} \\\\\n -\\frac{7}{2} & \\frac{1}{2} \\\\\n \\frac{9}{2} & -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{35}{4} & \\frac{39}{4} \\\\\n \\frac{1}{4} & 3 \\\\\n \\frac{37}{4} & \\frac{11}{2} \\\\\n \\frac{35}{4} & \\frac{27}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{15}{2} & 0 \\\\\n 1 & -\\frac{3}{4} \\\\\n \\frac{23}{4} & 6 \\\\\n \\frac{53}{4} & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/4), -(39/4)],\n [(3/4), -(15/4)],\n [-(7/2), (1/2)],\n [(9/2), -(3/4)]])\nb = np.array([\n [-(35/4), (39/4)],\n [(1/4), 3],\n [(37/4), (11/2)],\n [(35/4), (27/4)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -7 & 7 & -6 & 1 & -7 \\\\\n 2 & -4 & 0 & -4 & -6 \\\\\n 2 & -8 & 5 & -2 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 7, -6, 1, -7],\n [2, -4, 0, -4, -6],\n [2, -8, 5, -2, 10]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{13}{5} & \\frac{3}{5} & -\\frac{11}{5} & \\frac{3}{5} \\\\\n \\frac{12}{5} & -\\frac{4}{5} & -\\frac{6}{5} & \\frac{4}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{1}{5} & -\\frac{6}{5} & -\\frac{8}{5} & 3 & -\\frac{7}{5} \\\\\n \\frac{12}{5} & \\frac{6}{5} & -\\frac{6}{5} & \\frac{14}{5} & -\\frac{4}{5} \\\\\n \\frac{3}{5} & 3 & 0 & -\\frac{6}{5} & -\\frac{12}{5} \\\\\n -\\frac{4}{5} & -\\frac{1}{5} & -\\frac{12}{5} & -\\frac{11}{5} & \\frac{13}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n \\frac{4}{25} & -\\frac{72}{25} & 2 & -\\frac{24}{5} & 10 \\\\\n -\\frac{94}{25} & -\\frac{38}{5} & -\\frac{24}{5} & \\frac{116}{25} & \\frac{56}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/5), (3/5), -(11/5), (3/5)],\n [(12/5), -(4/5), -(6/5), (4/5)]])\nb = np.array([\n [-(1/5), -(6/5), -(8/5), 3, -(7/5)],\n [(12/5), (6/5), -(6/5), (14/5), -(4/5)],\n [(3/5), 3, 0, -(6/5), -(12/5)],\n [-(4/5), -(1/5), -(12/5), -(11/5), (13/5)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -3 & -2 & 6 & 9 \\\\\n 6 & 9 & 6 & 9 \\\\\n -1 & -7 & -9 & 8 \\\\\n 9 & 2 & -3 & -6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 1 & -8 & 2 & 2 \\\\\n 1 & -9 & -9 & -6 \\\\\n -7 & 7 & -1 & 0 \\\\\n -2 & -4 & 1 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -4 & 6 & 4 & 7 \\\\\n 5 & 18 & 15 & 15 \\\\\n 6 & -14 & -8 & 8 \\\\\n 11 & 6 & -4 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2, 6, 9],\n [6, 9, 6, 9],\n [-1, -7, -9, 8],\n [9, 2, -3, -6]])\nb = np.array([\n [1, -8, 2, 2],\n [1, -9, -9, -6],\n [-7, 7, -1, 0],\n [-2, -4, 1, -2]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{1,1,1\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-2],\n [3]]).squeeze()\nb = np.array([\n [-1],\n [-1],\n [-1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & 0 \\\\\n 2 & 1 \\\\\n 1 & 0 \\\\\n 1 & 2 \\\\\n 3 & -2 \\\\\n 0 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.32 \\\\\n 0.82 \\\\\n 0.25 \\\\\n -0.45 \\\\\n 2.98 \\\\\n -1.81 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.653 \\\\\n -0.292 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0],\n [2, 1],\n [1, 0],\n [1, 2],\n [3, -2],\n [0, -1]])\nb = np.array([\n [-1.32],\n [0.82],\n [0.25],\n [-0.45],\n [2.98],\n [-1.81]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 2 & 8 & 7 & -10 & -2 & 9 \\\\\n 4 & 5 & 4 & 4 & 4 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & -\\frac{3}{22} & \\frac{41}{11} & \\frac{21}{11} & \\frac{27}{22} \\\\\n 0 & 1 & \\frac{10}{11} & -\\frac{24}{11} & -\\frac{8}{11} & \\frac{9}{11} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, 8, 7, -10, -2, 9],\n [4, 5, 4, 4, 4, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -2 & 4 & 5 \\\\\n 10 & 9 & 4 \\\\\n 5 & -5 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, 4, 5],\n [10, 9, 4],\n [5, -5, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{21}{4} \\\\\n \\frac{67}{8} \\\\\n \\frac{29}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -\\frac{17}{4} \\\\\n -\\frac{37}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{5}{4} \\\\\n \\frac{101}{8} \\\\\n \\frac{103}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(21/4)],\n [(67/8)],\n [(29/8)]])\nb = np.array([\n [-4],\n [-(17/4)],\n [-(37/4)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & 5 & -5 \\\\\n -1 & -3 & -2 \\\\\n -5 & 4 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{184} & -\\frac{45}{184} & -\\frac{25}{184} \\\\\n \\frac{15}{184} & -\\frac{35}{184} & \\frac{1}{184} \\\\\n -\\frac{19}{184} & -\\frac{17}{184} & \\frac{11}{184} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 5, -5],\n [-1, -3, -2],\n [-5, 4, 5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{8}{5} \\\\\n -\\frac{27}{5} \\\\\n -\\frac{49}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{33}{5} \\\\\n -\\frac{18}{5} \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{612}{25} \\\\\n -\\frac{1697}{25} \\\\\n \\frac{207}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/5)],\n [-(27/5)],\n [-(49/5)]])\nb = np.array([\n [(33/5)],\n [-(18/5)],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n \\frac{15}{4} \\\\\n -\\frac{3}{2} \\\\\n 3 \\\\\n \\frac{23}{4} \\\\\n \\frac{5}{2} \\\\\n 3 \\\\\n -\\frac{17}{2} \\\\\n \\frac{5}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{27}{4} \\\\\n -\\frac{1}{2} \\\\\n \\frac{3}{2} \\\\\n -\\frac{31}{4} \\\\\n \\frac{5}{4} \\\\\n \\frac{3}{2} \\\\\n -\\frac{31}{4} \\\\\n -\\frac{7}{2} \\\\\n -\\frac{27}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{\\frac{97}{2}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2)],\n [(15/4)],\n [-(3/2)],\n [3],\n [(23/4)],\n [(5/2)],\n [3],\n [-(17/2)],\n [(5/4)]])\nb = np.array([\n [-(27/4)],\n [-(1/2)],\n [(3/2)],\n [-(31/4)],\n [(5/4)],\n [(3/2)],\n [-(31/4)],\n [-(7/2)],\n [-(27/4)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -2 & 0 \\\\\n -1 & -1 \\\\\n -4 & 9 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 7 & 0 \\\\\n 0 & 3 \\\\\n 0 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -9 & 0 \\\\\n -1 & -4 \\\\\n -4 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0],\n [-1, -1],\n [-4, 9]])\nb = np.array([\n [7, 0],\n [0, 3],\n [0, 9]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{23}{9} \\\\\n \\frac{14}{9} \\\\\n -\\frac{7}{3} \\\\\n \\frac{14}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{23}{\\sqrt{1362}} \\\\\n 7 \\sqrt{\\frac{2}{681}} \\\\\n -7 \\sqrt{\\frac{3}{454}} \\\\\n 7 \\sqrt{\\frac{2}{681}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/9)],\n [(14/9)],\n [-(7/3)],\n [(14/9)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & 2 & 0 & 2 \\\\\n 3 & -1 & 2 & 3 \\\\\n 0 & -3 & 0 & 3 \\\\\n -3 & -3 & 3 & 3 \\\\\n 2 & -2 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.25 \\\\\n 0.74 \\\\\n 1.4 \\\\\n 1.81 \\\\\n -1.98 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.272 \\\\\n 0.069 \\\\\n 0.443 \\\\\n 0.15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, 0, 2],\n [3, -1, 2, 3],\n [0, -3, 0, 3],\n [-3, -3, 3, 3],\n [2, -2, -1, 2]])\nb = np.array([\n [-0.25],\n [0.74],\n [1.4],\n [1.81],\n [-1.98]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 8 & 10 & -8 & 3 & -6 \\\\\n 3 & 8 & 9 & -3 & -5 \\\\\n 4 & 4 & -6 & -5 & -4 \\\\\n -10 & -8 & -6 & -5 & -9 \\\\\n -7 & -2 & 3 & -4 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, 10, -8, 3, -6],\n [3, 8, 9, -3, -5],\n [4, 4, -6, -5, -4],\n [-10, -8, -6, -5, -9],\n [-7, -2, 3, -4, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 3 & 3 & 6 & -7 \\\\\n 4 & -4 & -1 & 2 \\\\\n -5 & -10 & 7 & 0 \\\\\n 4 & -8 & 7 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, 3, 6, -7],\n [4, -4, -1, 2],\n [-5, -10, 7, 0],\n [4, -8, 7, -7]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 2 & -1 & 0 & 0 \\\\\n -3 & -2 & -2 & -2 \\\\\n -2 & 1 & -2 & 2 \\\\\n -2 & 3 & -1 & -1 \\\\\n -3 & 0 & -2 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 1 & 1 & -1 \\\\\n 1 & -3 & 1 \\\\\n 1 & 1 & 2 \\\\\n -2 & 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 5 & -3 \\\\\n -3 & 1 & -7 \\\\\n -7 & -7 & 3 \\\\\n 2 & -12 & 1 \\\\\n -7 & -5 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1, 0, 0],\n [-3, -2, -2, -2],\n [-2, 1, -2, 2],\n [-2, 3, -1, -1],\n [-3, 0, -2, 1]])\nb = np.array([\n [1, 1, -1],\n [1, -3, 1],\n [1, 1, 2],\n [-2, 0, 2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [0],\n [0],\n [0]]).squeeze()\nb = np.array([\n [1],\n [0],\n [-1],\n [0],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{7}{2},2,-\\frac{1}{2}\\right\\}, \\left\\{3,-5,\\frac{1}{2}\\right\\}, \\left\\{3,-\\frac{9}{2},2\\right\\}}$.", - "Output Answer": [ - "$-88 x+6 y-2 z+295=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(7/2), 2, -(1/2)],\n [3, -5, (1/2)],\n [3, -(9/2), 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{39}{4} \\\\\n \\frac{37}{4} \\\\\n -\\frac{37}{4} \\\\\n \\frac{33}{4} \\\\\n -3 \\\\\n -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{99}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(39/4)],\n [(37/4)],\n [-(37/4)],\n [(33/4)],\n [-3],\n [-10]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n \\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 4 & -1 & -7 & -7 \\\\\n 7 & -3 & -6 & -6 \\\\\n -9 & -1 & 1 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-18.,-30.,-37.,31.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, -1, -7, -7],\n [7, -3, -6, -6],\n [-9, -1, 1, -5]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & 2 \\\\\n -2 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-4 x-8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 2],\n [-2, -2]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n \\frac{28}{5} & -\\frac{2}{5} & 7 & -\\frac{38}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(28/5), -(2/5), 7, -(38/5)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{17}{5} & \\frac{6}{5} \\\\\n -\\frac{6}{5} & \\frac{39}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{6} \\left(11-\\sqrt{85}\\right),1\\right\\}, \\left\\{\\frac{1}{6} \\left(11+\\sqrt{85}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/5), (6/5)],\n [-(6/5), (39/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & 8 & -3 \\\\\n -3 & -9 & -7 \\\\\n 2 & -9 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-10.914,1.547,10.368\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 8, -3],\n [-3, -9, -7],\n [2, -9, 9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -2 & -7 \\\\\n -5 & 4 \\\\\n -6 & -2 \\\\\n -3 & -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -3 & -7 \\\\\n 9 & -9 \\\\\n -1 & -8 \\\\\n -5 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -5 & -14 \\\\\n 4 & -5 \\\\\n -7 & -10 \\\\\n -8 & -13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -7],\n [-5, 4],\n [-6, -2],\n [-3, -8]])\nb = np.array([\n [-3, -7],\n [9, -9],\n [-1, -8],\n [-5, -5]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 2 \\\\\n \\frac{1}{2} \\\\\n 2 \\\\\n -4 \\\\\n \\frac{13}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{35}{4} \\\\\n -\\frac{13}{2} \\\\\n -\\frac{31}{4} \\\\\n -5 \\\\\n -8 \\\\\n -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(329 \\sqrt{\\frac{2}{1264665}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [2],\n [(1/2)],\n [2],\n [-4],\n [(13/2)]]).squeeze()\nb = np.array([\n [(35/4)],\n [-(13/2)],\n [-(31/4)],\n [-5],\n [-8],\n [-(1/4)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & 1 \\\\\n -9 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-2 x+10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1],\n [-9, 1]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & -2 \\\\\n -4 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-20$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2],\n [-4, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{27}{8} & \\frac{27}{16} \\\\\n -\\frac{53}{16} & \\frac{55}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{880}{1539} & \\frac{16}{57} \\\\\n -\\frac{848}{1539} & \\frac{32}{57} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(27/8), (27/16)],\n [-(53/16), (55/16)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 3 \\\\\n -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -12 \\\\\n -87 \\\\\n -33 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [1],\n [1]])\nb = np.array([\n [3],\n [3],\n [-9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 2 \\\\\n -2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -\\frac{3}{2} \\\\\n -1 \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{12}{25},-\\frac{6}{25},-\\frac{4}{25},\\frac{2}{25}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [2],\n [-2],\n [0]]).squeeze()\nb = np.array([\n [-3],\n [-(3/2)],\n [-1],\n [(1/2)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -4 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{146}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-4],\n [-9]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -1 & 1 & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 2 & -2 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2]])\nb = np.array([\n [-1, 1, (5/2)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{8}{5} & \\frac{8}{5} \\\\\n 5 & -\\frac{6}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{248}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(8/5), (8/5)],\n [5, -(6/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n \\frac{19}{8} & \\frac{15}{8} \\\\\n -\\frac{13}{8} & \\frac{15}{8} \\\\\n -\\frac{9}{8} & \\frac{13}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{41}{16} \\\\\n \\frac{73}{16} \\\\\n \\frac{61}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/8), (15/8)],\n [-(13/8), (15/8)],\n [-(9/8), (13/8)]])\nb = np.array([\n [-(1/2)],\n [2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & -2 \\\\\n -3 & 2 \\\\\n 0 & -1 \\\\\n -2 & -2 \\\\\n 1 & 0 \\\\\n 2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2. \\\\\n -2.28 \\\\\n 2.58 \\\\\n -2.66 \\\\\n -0.35 \\\\\n 2.67 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.411 \\\\\n -0.003 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2],\n [-3, 2],\n [0, -1],\n [-2, -2],\n [1, 0],\n [2, -3]])\nb = np.array([\n [-2.],\n [-2.28],\n [2.58],\n [-2.66],\n [-0.35],\n [2.67]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{3} & 2 \\\\\n \\frac{5}{3} & \\frac{26}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{10} \\left(-19-\\sqrt{481}\\right),1\\right\\}, \\left\\{\\frac{1}{10} \\left(\\sqrt{481}-19\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/3), 2],\n [(5/3), (26/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{19}{8} \\\\\n \\frac{5}{4} \\\\\n \\frac{1}{8} \\\\\n -\\frac{13}{8} \\\\\n -\\frac{21}{8} \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{19}{4 \\sqrt{103}} \\\\\n \\frac{5}{2 \\sqrt{103}} \\\\\n \\frac{1}{4 \\sqrt{103}} \\\\\n -\\frac{13}{4 \\sqrt{103}} \\\\\n -\\frac{21}{4 \\sqrt{103}} \\\\\n \\frac{6}{\\sqrt{103}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/8)],\n [(5/4)],\n [(1/8)],\n [-(13/8)],\n [-(21/8)],\n [3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 1 \\\\\n 1 \\\\\n -3 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 2 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{7}{5},\\frac{14}{15},-\\frac{7}{15},\\frac{7}{15}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [1],\n [1],\n [-3]]).squeeze()\nb = np.array([\n [3],\n [2],\n [-1],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -1 & 9 & 8 \\\\\n -5 & 4 & -5 \\\\\n -7 & 3 & -10 \\\\\n 1 & -10 & -10 \\\\\n 3 & -6 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-1, 9, 8],\n [-5, 4, -5],\n [-7, 3, -10],\n [1, -10, -10],\n [3, -6, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -\\frac{3}{2} \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{4} \\\\\n \\frac{9}{4} \\\\\n -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{189}{163},-\\frac{189}{163},\\frac{21}{163}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-(3/2)],\n [-(3/2)]]).squeeze()\nb = np.array([\n [-(9/4)],\n [(9/4)],\n [-(1/4)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 2 \\\\\n 4 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [2],\n [4],\n [-8]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{4}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & -6 & -5 & -5 \\\\\n -5 & 4 & -9 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 0 & -\\frac{3}{2} & -\\frac{5}{4} & -\\frac{5}{4} \\\\\n -\\frac{5}{4} & 1 & -\\frac{9}{4} & -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -6, -5, -5],\n [-5, 4, -9, -3]])\nprint(a * (1/4))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 7 & -10 & -7 \\\\\n -4 & -9 & -3 \\\\\n -8 & -1 & -2 \\\\\n 0 & -8 & 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -1 & -2 & -9 \\\\\n 6 & 7 & 8 \\\\\n -9 & 3 & 8 \\\\\n 1 & 5 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 6 & -12 & -16 \\\\\n 2 & -2 & 5 \\\\\n -17 & 2 & 6 \\\\\n 1 & -3 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -10, -7],\n [-4, -9, -3],\n [-8, -1, -2],\n [0, -8, 5]])\nb = np.array([\n [-1, -2, -9],\n [6, 7, 8],\n [-9, 3, 8],\n [1, 5, 1]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{2}{5}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -9 & -1 \\\\\n -3 & 2 \\\\\n -3 & 1 \\\\\n -10 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{18}{5} & -\\frac{2}{5} \\\\\n -\\frac{6}{5} & \\frac{4}{5} \\\\\n -\\frac{6}{5} & \\frac{2}{5} \\\\\n -4 & \\frac{2}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -1],\n [-3, 2],\n [-3, 1],\n [-10, 1]])\nprint(a * (2/5))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{29}{3} & -\\frac{10}{3} & 8 \\\\\n 3 & -3 & -2 \\\\\n \\frac{10}{3} & -10 & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-12.762,-2.176,2.937\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/3), -(10/3), 8],\n [3, -3, -2],\n [(10/3), -10, (2/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{11}{2}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & -8 \\\\\n 2 & 7 \\\\\n 9 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{33}{2} & 44 \\\\\n -11 & -\\frac{77}{2} \\\\\n -\\frac{99}{2} & 22 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -8],\n [2, 7],\n [9, -4]])\nprint(a * -(11/2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -2 & 4 & 8 & 3 \\\\\n -9 & 7 & -2 & -3 \\\\\n -6 & 5 & 1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-199.,-229.,55.,26.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, 4, 8, 3],\n [-9, 7, -2, -3],\n [-6, 5, 1, -4]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{4} & 2 \\\\\n \\frac{1}{4} & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{4} & -\\frac{3}{4} & \\frac{3}{4} \\\\\n \\frac{3}{2} & \\frac{5}{4} & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{47}{16} & \\frac{43}{16} & -\\frac{83}{16} \\\\\n \\frac{1}{16} & -\\frac{3}{16} & \\frac{3}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/4), 2],\n [(1/4), 0]])\nb = np.array([\n [(1/4), -(3/4), (3/4)],\n [(3/2), (5/4), -(5/2)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{25}{7} & -4 \\\\\n -\\frac{19}{7} & \\frac{32}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{56}{333} & -\\frac{49}{333} \\\\\n -\\frac{133}{1332} & \\frac{175}{1332} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/7), -4],\n [-(19/7), (32/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 0 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 1 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 10 \\\\\n 32 \\\\\n -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [0],\n [-10]])\nb = np.array([\n [-2],\n [1],\n [4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{2} & 0 \\\\\n \\frac{15}{4} & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{2}{9} & 0 \\\\\n \\frac{5}{21} & -\\frac{2}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/2), 0],\n [(15/4), -(7/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 5 \\\\\n -\\frac{13}{2} \\\\\n \\frac{11}{2} \\\\\n -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n -3 \\\\\n \\frac{17}{2} \\\\\n -\\frac{7}{2} \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{55}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [5],\n [-(13/2)],\n [(11/2)],\n [-(11/2)]])\nb = np.array([\n [(5/2)],\n [-3],\n [(17/2)],\n [-(7/2)],\n [-9]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{37}{8} & \\frac{9}{8} & \\frac{23}{8} & -\\frac{11}{2} \\\\\n \\frac{5}{2} & \\frac{19}{2} & -\\frac{39}{4} & \\frac{23}{8} \\\\\n -\\frac{25}{4} & -5 & -\\frac{13}{2} & -\\frac{13}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n \\frac{67}{8} & \\frac{5}{4} & -\\frac{23}{4} & \\frac{3}{8} \\\\\n -\\frac{17}{8} & \\frac{49}{8} & \\frac{67}{8} & -\\frac{7}{4} \\\\\n -\\frac{43}{8} & -1 & 6 & \\frac{11}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -13 & -\\frac{1}{8} & \\frac{69}{8} & -\\frac{47}{8} \\\\\n \\frac{37}{8} & \\frac{27}{8} & -\\frac{145}{8} & \\frac{37}{8} \\\\\n -\\frac{7}{8} & -4 & -\\frac{25}{2} & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(37/8), (9/8), (23/8), -(11/2)],\n [(5/2), (19/2), -(39/4), (23/8)],\n [-(25/4), -5, -(13/2), -(13/8)]])\nb = np.array([\n [(67/8), (5/4), -(23/4), (3/8)],\n [-(17/8), (49/8), (67/8), -(7/4)],\n [-(43/8), -1, 6, (11/8)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -6 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 8 \\\\\n -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 12 \\\\\n 12 \\\\\n -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-6],\n [3]])\nb = np.array([\n [-10],\n [8],\n [-6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & 0 & 0 \\\\\n \\frac{7}{2} & 7 & -7 \\\\\n -6 & 1 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-3.,6.5\\, -2.598 i,6.5\\, +2.598 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, 0],\n [(7/2), 7, -7],\n [-6, 1, 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -4 & 6 & 6 \\\\\n 10 & 4 & -1 \\\\\n -4 & -4 & 8 \\\\\n 4 & 1 & -2 \\\\\n -10 & -8 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, 6, 6],\n [10, 4, -1],\n [-4, -4, 8],\n [4, 1, -2],\n [-10, -8, 9]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & -3 & 1 \\\\\n -3 & -3 & -2 & 3 & -1 \\\\\n 0 & 2 & 3 & -3 & -3 \\\\\n 3 & 1 & -1 & 2 & -2 \\\\\n -1 & 3 & 0 & -3 & 3 \\\\\n 3 & 1 & -3 & 1 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.57 \\\\\n -2.38 \\\\\n 0.65 \\\\\n 1.97 \\\\\n 1.86 \\\\\n -0.08 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.311 \\\\\n 0.552 \\\\\n 0.24 \\\\\n 0.166 \\\\\n 0.246 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 0, 0, -3, 1],\n [-3, -3, -2, 3, -1],\n [0, 2, 3, -3, -3],\n [3, 1, -1, 2, -2],\n [-1, 3, 0, -3, 3],\n [3, 1, -3, 1, -2]])\nb = np.array([\n [0.57],\n [-2.38],\n [0.65],\n [1.97],\n [1.86],\n [-0.08]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{15}{2} & -4 & -\\frac{31}{4} \\\\\n \\frac{11}{4} & \\frac{19}{2} & \\frac{11}{4} \\\\\n -\\frac{25}{4} & -10 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{3.076,-0.598,1.\\}, \\{-0.448-0.208 i,-0.082+0.44 i,1.\\}, \\{-0.448+0.208 i,-0.082-0.44 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/2), -4, -(31/4)],\n [(11/4), (19/2), (11/4)],\n [-(25/4), -10, 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\pi \\\\\n -\\pi \\\\\n -2 \\pi \\\\\n -\\pi \\\\\n -\\pi \\\\\n 2 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\pi \\\\\n -2 \\pi \\\\\n -\\pi \\\\\n 0 \\\\\n -\\pi \\\\\n 3 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{5} \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-2*math.pi],\n [-math.pi],\n [-2*math.pi],\n [-math.pi],\n [-math.pi],\n [2*math.pi]])\nb = np.array([\n [-3*math.pi],\n [-2*math.pi],\n [-math.pi],\n [0],\n [-math.pi],\n [3*math.pi]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{6}{5}, -2}$ to the line $\\frac{22 x}{5}+\\frac{8 y}{5}+\\frac{3}{5}=0$.", - "Output Answer": [ - "$\\frac{197}{10 \\sqrt{137}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(6/5), -2\nline = Poly(((22*x)/5)+((8*y)/5)+(3/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{2} & \\frac{7}{2} & -\\frac{13}{2} \\\\\n \\frac{1}{2} & 3 & -6 \\\\\n \\frac{9}{2} & 3 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.563,1.276,1.\\}, \\{-0.287-0.735 i,-0.036-0.98 i,1.\\}, \\{-0.287+0.735 i,-0.036+0.98 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), (7/2), -(13/2)],\n [(1/2), 3, -6],\n [(9/2), 3, 5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{41}{5} & -\\frac{1}{5} & \\frac{43}{5} \\\\\n \\frac{9}{5} & \\frac{34}{5} & -\\frac{21}{5} \\\\\n \\frac{34}{5} & -\\frac{13}{5} & -\\frac{21}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-14.393,0.978,7.815\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(41/5), -(1/5), (43/5)],\n [(9/5), (34/5), -(21/5)],\n [(34/5), -(13/5), -(21/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -5 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$14$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-5],\n [-3]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 7 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 9 \\\\\n 48 \\\\\n -51 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [7],\n [8]])\nb = np.array([\n [5],\n [-2],\n [-1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -\\frac{55}{16} & \\frac{65}{16} & -\\frac{113}{16} & \\frac{103}{16} \\\\\n \\frac{51}{8} & -\\frac{133}{16} & -\\frac{153}{16} & -\\frac{3}{2} \\\\\n -\\frac{45}{16} & \\frac{49}{8} & -\\frac{41}{8} & \\frac{55}{16} \\\\\n -\\frac{73}{16} & 9 & \\frac{119}{16} & -\\frac{137}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(55/16), (65/16), -(113/16), (103/16)],\n [(51/8), -(133/16), -(153/16), -(3/2)],\n [-(45/16), (49/8), -(41/8), (55/16)],\n [-(73/16), 9, (119/16), -(137/16)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [-1],\n [1],\n [-1],\n [1],\n [0]]).squeeze()\nb = np.array([\n [1],\n [1],\n [-1],\n [1],\n [-1],\n [-1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{9}{2} & -\\frac{7}{2} & 9 & -\\frac{9}{2} \\\\\n -\\frac{15}{2} & 10 & -2 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 0 & -7 & \\frac{1}{2} & 9 \\\\\n \\frac{19}{2} & 2 & 1 & \\frac{19}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{9}{2} & -\\frac{21}{2} & \\frac{19}{2} & \\frac{9}{2} \\\\\n 2 & 12 & -1 & \\frac{17}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2), -(7/2), 9, -(9/2)],\n [-(15/2), 10, -2, -1]])\nb = np.array([\n [0, -7, (1/2), 9],\n [(19/2), 2, 1, (19/2)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{18}{5} \\\\\n -\\frac{9}{10} \\\\\n \\frac{16}{5} \\\\\n \\frac{91}{10} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{73}{10} \\\\\n -\\frac{17}{2} \\\\\n 9 \\\\\n \\frac{19}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{37}{10} \\\\\n -\\frac{47}{5} \\\\\n \\frac{61}{5} \\\\\n \\frac{93}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(18/5)],\n [-(9/10)],\n [(16/5)],\n [(91/10)]])\nb = np.array([\n [-(73/10)],\n [-(17/2)],\n [9],\n [(19/2)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 3 \\\\\n 1 & 3 \\\\\n -3 & -1 \\\\\n 0 & 2 \\\\\n 3 & -3 \\\\\n -3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.5 \\\\\n -0.11 \\\\\n -2.9 \\\\\n 0.61 \\\\\n -0.65 \\\\\n -0.99 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.122 \\\\\n 0.049 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3],\n [1, 3],\n [-3, -1],\n [0, 2],\n [3, -3],\n [-3, -2]])\nb = np.array([\n [-1.5],\n [-0.11],\n [-2.9],\n [0.61],\n [-0.65],\n [-0.99]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{2,1,5\\}, \\{3,5,-3\\}, \\{-4,2,-4\\}}$.", - "Output Answer": [ - "$28 x-57 y-25 z+126=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, 1, 5],\n [3, 5, -3],\n [-4, 2, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 0 & -1 & -3 & -3 & -3 \\\\\n 0 & 0 & 3 & 0 & 1 \\\\\n -3 & 0 & -1 & 1 & 2 \\\\\n 2 & -2 & 0 & -2 & 1 \\\\\n 3 & -1 & 3 & -3 & 0 \\\\\n 0 & -3 & 1 & -2 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.91 \\\\\n 0.01 \\\\\n 2.7 \\\\\n 2.58 \\\\\n -1.19 \\\\\n 0.78 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.501 \\\\\n 0.124 \\\\\n -0.709 \\\\\n -1.104 \\\\\n 0.943 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -1, -3, -3, -3],\n [0, 0, 3, 0, 1],\n [-3, 0, -1, 1, 2],\n [2, -2, 0, -2, 1],\n [3, -1, 3, -3, 0],\n [0, -3, 1, -2, 0]])\nb = np.array([\n [2.91],\n [0.01],\n [2.7],\n [2.58],\n [-1.19],\n [0.78]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -8 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.,2.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-8, -4]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 5 \\\\\n 10 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$28$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [5],\n [10],\n [-4]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{1,2,\\frac{7}{2}\\right\\}, \\left\\{3,5,\\frac{1}{2}\\right\\}, \\left\\{-4,4,-\\frac{9}{2}\\right\\}}$.", - "Output Answer": [ - "$36 x-62 y-38 z+221=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, 2, (7/2)],\n [3, 5, (1/2)],\n [-4, 4, -(9/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\pi \\\\\n 3 \\pi \\\\\n 2 \\pi \\\\\n -2 \\pi \\\\\n -3 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\pi \\\\\n -2 \\pi \\\\\n -2 \\pi \\\\\n -\\pi \\\\\n -2 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-3 \\pi ^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-math.pi],\n [3*math.pi],\n [2*math.pi],\n [-2*math.pi],\n [-3*math.pi]])\nb = np.array([\n [math.pi],\n [-2*math.pi],\n [-2*math.pi],\n [-math.pi],\n [-2*math.pi]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{11}{7}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 5 \\\\\n -6 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{11}{7} & -\\frac{55}{7} \\\\\n \\frac{66}{7} & -\\frac{22}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 5],\n [-6, 2]])\nprint(a * -(11/7))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 0 & 7 \\\\\n 1 & -7 \\\\\n -1 & 0 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -9 & 9 \\\\\n -7 & 9 \\\\\n -6 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 9 & -2 \\\\\n 8 & -16 \\\\\n 5 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 7],\n [1, -7],\n [-1, 0]])\nb = np.array([\n [-9, 9],\n [-7, 9],\n [-6, -5]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -7 & 2 & 9 & 1 & 4 & -1 & -6 \\\\\n -8 & 7 & -6 & 5 & 8 & 10 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & -\\frac{25}{11} & \\frac{1}{11} & -\\frac{4}{11} & \\frac{9}{11} & \\frac{46}{33} \\\\\n 0 & 1 & -\\frac{38}{11} & \\frac{9}{11} & \\frac{8}{11} & \\frac{26}{11} & \\frac{62}{33} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, 2, 9, 1, 4, -1, -6],\n [-8, 7, -6, 5, 8, 10, 2]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & 3 & -1 \\\\\n 1 & -3 & 1 \\\\\n -2 & 2 & 1 \\\\\n 0 & 3 & -2 \\\\\n 1 & 3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.53 \\\\\n 1.72 \\\\\n 1.27 \\\\\n -2.51 \\\\\n -0.75 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.398 \\\\\n -0.525 \\\\\n 0.739 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 3, -1],\n [1, -3, 1],\n [-2, 2, 1],\n [0, 3, -2],\n [1, 3, 2]])\nb = np.array([\n [-2.53],\n [1.72],\n [1.27],\n [-2.51],\n [-0.75]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\pi \\\\\n 2 \\pi \\\\\n 3 \\pi \\\\\n 3 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\pi \\\\\n \\pi \\\\\n -3 \\pi \\\\\n \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-10 \\pi ^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-3*math.pi],\n [2*math.pi],\n [3*math.pi],\n [3*math.pi]])\nb = np.array([\n [2*math.pi],\n [math.pi],\n [-3*math.pi],\n [math.pi]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{5}{2},2,1\\right\\}, \\left\\{-\\frac{3}{2},4,4\\right\\}, \\{5,0,2\\}}$.", - "Output Answer": [ - "$16 x+23 y+6 z-92=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(5/2), 2, 1],\n [-(3/2), 4, 4],\n [5, 0, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 0 & -3 & 1 & 3 \\\\\n 9 & -6 & 1 & 7 \\\\\n 2 & -5 & 6 & -7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 5 & 2 & 8 & -7 \\\\\n 6 & -3 & 0 & 2 \\\\\n -10 & -1 & 5 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -5 & -5 & -7 & 10 \\\\\n 3 & -3 & 1 & 5 \\\\\n 12 & -4 & 1 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3, 1, 3],\n [9, -6, 1, 7],\n [2, -5, 6, -7]])\nb = np.array([\n [5, 2, 8, -7],\n [6, -3, 0, 2],\n [-10, -1, 5, -5]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{2} & \\frac{17}{2} & -10 \\\\\n 5 & -5 & 6 \\\\\n 10 & \\frac{3}{2} & -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.594,1.231,1.\\}, \\{-0.091-0.856 i,0.512\\, +0.798 i,1.\\}, \\{-0.091+0.856 i,0.512\\, -0.798 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), (17/2), -10],\n [5, -5, 6],\n [10, (3/2), -(11/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -3 & -1 & 0 & -3 & -2 \\\\\n -3 & -1 & 2 & 0 & -3 \\\\\n -1 & 1 & -2 & 3 & -2 \\\\\n -1 & -1 & -1 & 3 & -1 \\\\\n -1 & 1 & -2 & -1 & -2 \\\\\n 3 & 1 & -1 & 1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.02 \\\\\n -1.27 \\\\\n -0.89 \\\\\n -0.54 \\\\\n 2.12 \\\\\n -0.31 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2.9 \\\\\n -1.701 \\\\\n -0.637 \\\\\n -0.771 \\\\\n -2.359 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1, 0, -3, -2],\n [-3, -1, 2, 0, -3],\n [-1, 1, -2, 3, -2],\n [-1, -1, -1, 3, -1],\n [-1, 1, -2, -1, -2],\n [3, 1, -1, 1, 3]])\nb = np.array([\n [0.02],\n [-1.27],\n [-0.89],\n [-0.54],\n [2.12],\n [-0.31]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -1 \\\\\n -2 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 0 \\\\\n -2 \\\\\n 1 \\\\\n 3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{5}{11},0,-\\frac{5}{11},\\frac{5}{22},\\frac{15}{22},-\\frac{5}{11}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-1],\n [-2],\n [0],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [2],\n [0],\n [-2],\n [1],\n [3],\n [-2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{13}{3}, -\\frac{4}{3}}$ to the line $2 x-5 y-\\frac{1}{3}=0$.", - "Output Answer": [ - "$\\frac{7}{3 \\sqrt{29}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(13/3), -(4/3)\nline = Poly(2*x-5*y-(1/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{8}{5}, -\\frac{19}{5}, 5}$ to the plane $\\frac{24 x}{5}+\\frac{19 y}{5}-2 z+2=0$.", - "Output Answer": [ - "$\\frac{753}{5 \\sqrt{1037}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(8/5), -(19/5), 5\nplane = Poly(((24*x)/5)+((19*y)/5)-2*z+2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{16}{7} & \\frac{12}{7} & -\\frac{20}{7} & -2 & -\\frac{8}{7} \\\\\n -\\frac{3}{7} & \\frac{9}{7} & -\\frac{16}{7} & -\\frac{5}{7} & \\frac{17}{7} \\\\\n -\\frac{4}{7} & -1 & -\\frac{12}{7} & \\frac{11}{7} & \\frac{16}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{7} & -\\frac{13}{7} \\\\\n -\\frac{3}{7} & 0 \\\\\n -\\frac{10}{7} & \\frac{17}{7} \\\\\n \\frac{15}{7} & -\\frac{9}{7} \\\\\n \\frac{4}{7} & \\frac{6}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{62}{49} & -\\frac{470}{49} \\\\\n \\frac{123}{49} & -\\frac{86}{49} \\\\\n \\frac{366}{49} & -\\frac{155}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(16/7), (12/7), -(20/7), -2, -(8/7)],\n [-(3/7), (9/7), -(16/7), -(5/7), (17/7)],\n [-(4/7), -1, -(12/7), (11/7), (16/7)]])\nb = np.array([\n [(1/7), -(13/7)],\n [-(3/7), 0],\n [-(10/7), (17/7)],\n [(15/7), -(9/7)],\n [(4/7), (6/7)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\pi \\\\\n 0 \\\\\n -\\pi \\\\\n 2 \\pi \\\\\n -\\pi \\\\\n \\pi \\\\\n \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\pi \\\\\n 2 \\pi \\\\\n \\pi \\\\\n -2 \\pi \\\\\n 0 \\\\\n -\\pi \\\\\n -\\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\pi ^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [2*math.pi],\n [0],\n [-math.pi],\n [2*math.pi],\n [-math.pi],\n [math.pi],\n [math.pi]])\nb = np.array([\n [3*math.pi],\n [2*math.pi],\n [math.pi],\n [-2*math.pi],\n [0],\n [-math.pi],\n [-math.pi]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -2 & -9 & 1 & 10 \\\\\n -6 & 2 & -3 & -6 \\\\\n 9 & 8 & 2 & -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -2 & -9 & -9 & 7 \\\\\n -4 & -2 & -10 & 5 \\\\\n -9 & -2 & -4 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -4 & -18 & -8 & 17 \\\\\n -10 & 0 & -13 & -1 \\\\\n 0 & 6 & -2 & -14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -9, 1, 10],\n [-6, 2, -3, -6],\n [9, 8, 2, -6]])\nb = np.array([\n [-2, -9, -9, 7],\n [-4, -2, -10, 5],\n [-9, -2, -4, -8]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 8 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 7 \\\\\n 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 66 \\\\\n 39 \\\\\n -25 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [8],\n [-6]])\nb = np.array([\n [-3],\n [7],\n [3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{7}{52},\\frac{35}{52}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [(1/2)]]).squeeze()\nb = np.array([\n [(1/2)],\n [-(5/2)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -9 & -9 \\\\\n 9 & 9 \\\\\n -10 & 10 \\\\\n 5 & -6 \\\\\n 6 & 8 \\\\\n -4 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-9, -9],\n [9, 9],\n [-10, 10],\n [5, -6],\n [6, 8],\n [-4, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 3 & -1 \\\\\n -\\frac{3}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{21}{2} & -\\frac{7}{2} \\\\\n -\\frac{21}{4} & \\frac{7}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1],\n [-(3/2), (1/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{4}{5}, 4, \\frac{21}{5}}$ to the plane $-3 x+\\frac{7 y}{5}-\\frac{12 z}{5}+1=0$.", - "Output Answer": [ - "$\\frac{147}{5 \\sqrt{418}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (4/5), 4, (21/5)\nplane = Poly(-3*x+((7*y)/5)-((12*z)/5)+1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -3 \\\\\n -6 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 2 \\\\\n 6 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{401}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-3],\n [-6],\n [9]])\nb = np.array([\n [-8],\n [2],\n [6],\n [3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & 2 & 0 & 0 \\\\\n 0 & 1 & -3 & 2 \\\\\n 1 & 3 & 1 & -2 \\\\\n 2 & -1 & -1 & 1 \\\\\n 3 & 2 & -3 & -3 \\\\\n 3 & -1 & 0 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.25 \\\\\n -1.74 \\\\\n 2.21 \\\\\n -0.9 \\\\\n -2.3 \\\\\n -0.68 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.13 \\\\\n 0.15 \\\\\n 0.864 \\\\\n -0.068 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2, 0, 0],\n [0, 1, -3, 2],\n [1, 3, 1, -2],\n [2, -1, -1, 1],\n [3, 2, -3, -3],\n [3, -1, 0, 3]])\nb = np.array([\n [-1.25],\n [-1.74],\n [2.21],\n [-0.9],\n [-2.3],\n [-0.68]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $2$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 9 & 5 & 9 \\\\\n 10 & 10 & 3 \\\\\n 10 & 3 & 2 \\\\\n 7 & 9 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 18 & 10 & 18 \\\\\n 20 & 20 & 6 \\\\\n 20 & 6 & 4 \\\\\n 14 & 18 & -20 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 5, 9],\n [10, 10, 3],\n [10, 3, 2],\n [7, 9, -10]])\nprint(a * 2)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 8 \\\\\n -4 \\\\\n 7 \\\\\n 3 \\\\\n -9 \\\\\n 2 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -10 \\\\\n -3 \\\\\n 7 \\\\\n 2 \\\\\n 1 \\\\\n -8 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [8],\n [-4],\n [7],\n [3],\n [-9],\n [2],\n [-5]])\nb = np.array([\n [7],\n [-10],\n [-3],\n [7],\n [2],\n [1],\n [-8],\n [-8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{5} & -\\frac{8}{5} & \\frac{19}{5} \\\\\n -\\frac{7}{5} & \\frac{37}{10} & -\\frac{3}{2} \\\\\n -\\frac{21}{10} & -\\frac{1}{2} & \\frac{14}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{3911}{250}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/5), -(8/5), (19/5)],\n [-(7/5), (37/10), -(3/2)],\n [-(21/10), -(1/2), (14/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{3} \\\\\n -\\frac{14}{3} \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{22}{3} \\\\\n -1 \\\\\n -\\frac{19}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{566}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/3)],\n [-(14/3)],\n [-7]])\nb = np.array([\n [(22/3)],\n [-1],\n [-(19/3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & -5 \\\\\n 10 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1-7 i,10\\}, \\{1+7 i,10\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -5],\n [10, -6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & 3 \\\\\n 3 & -3 \\\\\n 2 & -2 \\\\\n 1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.33 \\\\\n 0.22 \\\\\n -0.12 \\\\\n -2.73 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.804 \\\\\n -0.642 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 3],\n [3, -3],\n [2, -2],\n [1, 3]])\nb = np.array([\n [1.33],\n [0.22],\n [-0.12],\n [-2.73]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{10} & \\frac{69}{10} \\\\\n -\\frac{43}{5} & \\frac{23}{10} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{27}{5} & -7 \\\\\n \\frac{49}{5} & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{9}{2} & \\frac{139}{10} \\\\\n -\\frac{92}{5} & -\\frac{27}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/10), (69/10)],\n [-(43/5), (23/10)]])\nb = np.array([\n [(27/5), -7],\n [(49/5), 5]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -\\frac{15}{4} & \\frac{17}{4} & -2 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/4), (17/4), -2, 9]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $2$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & 9 \\\\\n 0 & 1 \\\\\n 10 & -10 \\\\\n 9 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 4 & 18 \\\\\n 0 & 2 \\\\\n 20 & -20 \\\\\n 18 & 14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 9],\n [0, 1],\n [10, -10],\n [9, 7]])\nprint(a * 2)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 3 & -1 & 2 \\\\\n 0 & -1 & 5 \\\\\n -2 & 4 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{7}{19} & -\\frac{3}{19} & \\frac{1}{19} \\\\\n \\frac{10}{57} & -\\frac{7}{57} & \\frac{5}{19} \\\\\n \\frac{2}{57} & \\frac{10}{57} & \\frac{1}{19} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, 2],\n [0, -1, 5],\n [-2, 4, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -5 & 4 \\\\\n 2 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{7} & \\frac{1}{7} \\\\\n \\frac{1}{14} & \\frac{5}{28} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 4],\n [2, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{1,3,-2\\}, \\{-3,-3,0\\}, \\{2,0,-1\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{14}},\\frac{3}{\\sqrt{14}},-\\sqrt{\\frac{2}{7}}\\right\\}, \\left\\{-\\frac{5}{\\sqrt{42}},-\\frac{1}{\\sqrt{42}},-2 \\sqrt{\\frac{2}{21}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((1, 3, -2), (-3, -3, 0), (2, 0, -1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{36}{25} & \\frac{473}{100} & \\frac{461}{100} \\\\\n \\frac{951}{100} & -\\frac{407}{50} & \\frac{859}{100} \\\\\n \\frac{234}{25} & -\\frac{279}{100} & -\\frac{13}{20} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{147 x^2}{20}+\\frac{178831 x}{2500}+\\frac{340296573}{500000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(36/25), (473/100), (461/100)],\n [(951/100), -(407/50), (859/100)],\n [(234/25), -(279/100), -(13/20)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 2 & 10 & -6 & -1 \\\\\n -6 & 10 & -6 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.,3.,5.,0.\\}, \\{35.,-3.,0.,40.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, 10, -6, -1],\n [-6, 10, -6, 6]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -2 & -1 & 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 2 & 1 & -1 & 1 \\\\\n -2 & -1 & 1 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1]])\nb = np.array([\n [-2, -1, 1, -1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 0 & 1 \\\\\n -1 & 0 \\\\\n -1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 1 & -2 & 2 & 2 & -2 \\\\\n 1 & 1 & 1 & 1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 1 & 1 & 1 & 0 \\\\\n -1 & 2 & -2 & -2 & 2 \\\\\n 1 & 4 & 0 & 0 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1],\n [-1, 0],\n [-1, 2]])\nb = np.array([\n [1, -2, 2, 2, -2],\n [1, 1, 1, 1, 0]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6.584 \\\\\n 9.074 \\\\\n -4.244 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9.481 \\\\\n -8.053 \\\\\n -1.561 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-4.02513$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6.584],\n [9.074],\n [-4.244]])\nb = np.array([\n [-9.481],\n [-8.053],\n [-1.561]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -2-\\frac{7 i}{2} & 3+i \\\\\n \\frac{3}{2}+\\frac{i}{2} & \\frac{9}{2}-\\frac{3 i}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 93-\\frac{253 i}{8} & \\frac{31}{4}-\\frac{113 i}{4} \\\\\n \\frac{31}{8}-\\frac{113 i}{8} & \\frac{433}{4}-\\frac{371 i}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2-((7j)/2), 3+ 1j],\n [(3/2)+(1j/2), (9/2)-((3j)/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{8} & -\\frac{57}{8} & \\frac{45}{8} \\\\\n -\\frac{35}{4} & \\frac{5}{8} & -\\frac{31}{4} \\\\\n -\\frac{9}{4} & \\frac{1}{8} & -\\frac{51}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/8), -(57/8), (45/8)],\n [-(35/4), (5/8), -(31/4)],\n [-(9/4), (1/8), -(51/8)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -9 & 4 \\\\\n 6 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1,1\\}, \\{2,3\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 4],\n [6, -7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{4}{5}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 6 & -2 & -2 \\\\\n 7 & 0 & -9 \\\\\n -9 & 6 & -5 \\\\\n -7 & -1 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{24}{5} & -\\frac{8}{5} & -\\frac{8}{5} \\\\\n \\frac{28}{5} & 0 & -\\frac{36}{5} \\\\\n -\\frac{36}{5} & \\frac{24}{5} & -4 \\\\\n -\\frac{28}{5} & -\\frac{4}{5} & \\frac{36}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -2, -2],\n [7, 0, -9],\n [-9, 6, -5],\n [-7, -1, 9]])\nprint(a * (4/5))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{83}{16} \\\\\n \\frac{11}{16} \\\\\n \\frac{111}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{91}{16} \\\\\n -\\frac{9}{2} \\\\\n \\frac{29}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{4315}{128} \\\\\n \\frac{5287}{256} \\\\\n -\\frac{6977}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(83/16)],\n [(11/16)],\n [(111/16)]])\nb = np.array([\n [(91/16)],\n [-(9/2)],\n [(29/8)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n \\frac{5}{3} \\\\\n -7 \\\\\n -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3)],\n [-7],\n [-(11/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & -1 & 3 \\\\\n 2 & -\\frac{1}{2} & \\frac{5}{2} \\\\\n \\frac{5}{2} & \\frac{1}{2} & -3 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{23}{4} & \\frac{3}{2} & -10 \\\\\n \\frac{25}{4} & -\\frac{1}{2} & -\\frac{11}{4} \\\\\n -\\frac{21}{4} & -\\frac{17}{4} & \\frac{71}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), -1, 3],\n [2, -(1/2), (5/2)],\n [(5/2), (1/2), -3]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\sqrt{3} \\\\\n \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-3$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-math.sqrt(3)],\n [math.sqrt(3)]])\nb = np.array([\n [-math.sqrt(3)],\n [-2*math.sqrt(3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 9 & 9 & 5 \\\\\n -5 & -5 & 2 \\\\\n 6 & 9 & 1 \\\\\n 3 & 3 & -1 \\\\\n 6 & -1 & -1 \\\\\n 10 & -5 & -7 \\\\\n -3 & 1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, 9, 5],\n [-5, -5, 2],\n [6, 9, 1],\n [3, 3, -1],\n [6, -1, -1],\n [10, -5, -7],\n [-3, 1, -3]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & 2 \\\\\n -5 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(1-\\sqrt{129}\\right),\\frac{1}{2} \\left(1+\\sqrt{129}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 2],\n [-5, 7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -7 & 8 & 7 & 4 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-8.,0.,0.,0.,7.\\}, \\{1.,0.,1.,0.,0.\\}, \\{4.,0.,0.,7.,0.\\}, \\{8.,7.,0.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, 8, 7, 4, -8]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{2} \\\\\n -6 \\\\\n -8 \\\\\n -\\frac{23}{4} \\\\\n \\frac{9}{2} \\\\\n -\\frac{1}{2} \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{169}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/2)],\n [-6],\n [-8],\n [-(23/4)],\n [(9/2)],\n [-(1/2)],\n [-9]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,-4,3\\}, \\{-2,2,2\\}, \\{-3,3,-1\\}}$.", - "Output Answer": [ - "$17 x-y-6 z+48=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, -4, 3],\n [-2, 2, 2],\n [-3, 3, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -9 & 9 & -2 \\\\\n -1 & -1 & -5 \\\\\n 4 & 8 & 4 \\\\\n 9 & -6 & 1 \\\\\n 1 & 1 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, 9, -2],\n [-1, -1, -5],\n [4, 8, 4],\n [9, -6, 1],\n [1, 1, 9]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n 4 & -8 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -8, -3]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 2 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -1 & -1 \\\\\n 2 & 2 \\\\\n 1 & 1 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [2],\n [1],\n [0]])\nb = np.array([\n [1, 1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{30}{7} & -\\frac{31}{7} \\\\\n \\frac{15}{7} & \\frac{25}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{35}{57} & -\\frac{217}{285} \\\\\n \\frac{7}{19} & \\frac{14}{19} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(30/7), -(31/7)],\n [(15/7), (25/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{4}{3} & -\\frac{11}{3} \\\\\n 2 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{6} \\left(-11-\\sqrt{55}\\right),1\\right\\}, \\left\\{\\frac{1}{6} \\left(\\sqrt{55}-11\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/3), -(11/3)],\n [2, 6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -3 \\\\\n -2 \\\\\n 1 \\\\\n -2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{2}{\\sqrt{23}} \\\\\n -\\frac{3}{\\sqrt{23}} \\\\\n -\\frac{2}{\\sqrt{23}} \\\\\n \\frac{1}{\\sqrt{23}} \\\\\n -\\frac{2}{\\sqrt{23}} \\\\\n -\\frac{1}{\\sqrt{23}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-3],\n [-2],\n [1],\n [-2],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -1 & 0 & -1 \\\\\n 1 & 1 & -3 \\\\\n 1 & -2 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 1 & 1 \\\\\n -1 & 0 \\\\\n -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & -2 \\\\\n 3 & -2 \\\\\n 1 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, -1],\n [1, 1, -3],\n [1, -2, 2]])\nb = np.array([\n [1, 1],\n [-1, 0],\n [-1, 1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, \\frac{19}{5}, -\\frac{21}{5}}$ to the plane $\\frac{12 x}{5}+\\frac{24 y}{5}+z+\\frac{16}{5}=0$.", - "Output Answer": [ - "$\\frac{251}{5 \\sqrt{745}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, (19/5), -(21/5)\nplane = Poly(((12*x)/5)+((24*y)/5)+z+(16/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{3} & \\frac{13}{3} \\\\\n \\frac{2}{3} & -\\frac{20}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+5 x-14$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3), (13/3)],\n [(2/3), -(20/3)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & -3 & 0 \\\\\n 2 & 2 & -\\frac{3}{2} \\\\\n \\frac{5}{2} & \\frac{1}{2} & 1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{47}{4} & -\\frac{3}{4} & 18 \\\\\n -\\frac{29}{2} & -\\frac{29}{2} & -\\frac{3}{8} \\\\\n -\\frac{43}{8} & -\\frac{239}{8} & \\frac{37}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3, 0],\n [2, 2, -(3/2)],\n [(5/2), (1/2), 1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8.57 \\\\\n 9.33 \\\\\n -2.69 \\\\\n 7.19 \\\\\n 0.82 \\\\\n 0.74 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4.34 \\\\\n 5.92 \\\\\n 9.26 \\\\\n 3.26 \\\\\n -7.06 \\\\\n 2.91 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$87.3216$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8.57],\n [9.33],\n [-2.69],\n [7.19],\n [0.82],\n [0.74]])\nb = np.array([\n [4.34],\n [5.92],\n [9.26],\n [3.26],\n [-7.06],\n [2.91]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -1 & 4 & 7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 7 & -7 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -8 & 11 & 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 4, 7]])\nb = np.array([\n [7, -7, -4]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{37}{4} \\\\\n -\\frac{65}{8} \\\\\n \\frac{19}{8} \\\\\n \\frac{39}{8} \\\\\n \\frac{31}{8} \\\\\n \\frac{25}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{139}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [(37/4)],\n [-(65/8)],\n [(19/8)],\n [(39/8)],\n [(31/8)],\n [(25/4)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{401}{50} & -\\frac{337}{100} \\\\\n \\frac{923}{100} & \\frac{56}{25} \\\\\n -\\frac{181}{20} & -\\frac{67}{25} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{20} & \\frac{681}{100} \\\\\n \\frac{449}{100} & -\\frac{457}{100} \\\\\n -\\frac{329}{50} & -\\frac{161}{20} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{837}{100} & \\frac{86}{25} \\\\\n \\frac{343}{25} & -\\frac{233}{100} \\\\\n -\\frac{1563}{100} & -\\frac{1073}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(401/50), -(337/100)],\n [(923/100), (56/25)],\n [-(181/20), -(67/25)]])\nb = np.array([\n [-(7/20), (681/100)],\n [(449/100), -(457/100)],\n [-(329/50), -(161/20)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-3,-3,-3\\}, \\{0,2,0\\}, \\{3,-2,-2\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{6}},\\sqrt{\\frac{2}{3}},-\\frac{1}{\\sqrt{6}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{2}},0,-\\frac{1}{\\sqrt{2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-3, -3, -3), (0, 2, 0), (3, -2, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & 3 & -3 & 0 \\\\\n 0 & 3 & 0 & -2 \\\\\n 0 & 0 & 1 & -1 \\\\\n -2 & -1 & 0 & 3 \\\\\n -2 & -3 & 3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.92 \\\\\n 0.46 \\\\\n -2.44 \\\\\n 0.69 \\\\\n -0.29 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.004 \\\\\n 0.202 \\\\\n 0.546 \\\\\n 0.431 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3, -3, 0],\n [0, 3, 0, -2],\n [0, 0, 1, -1],\n [-2, -1, 0, 3],\n [-2, -3, 3, -3]])\nb = np.array([\n [-1.92],\n [0.46],\n [-2.44],\n [0.69],\n [-0.29]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{10}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -2 \\\\\n 7 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{21}{10} \\\\\n -\\frac{3}{5} \\\\\n \\frac{21}{10} \\\\\n -\\frac{3}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-2],\n [7],\n [-2]])\nprint(a * (3/10))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{126}{25} & \\frac{713}{100} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{64}{25} & \\frac{21}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{62}{25} & \\frac{671}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(126/25), (713/100)]])\nb = np.array([\n [(64/25), (21/50)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{16}{9} & -\\frac{5}{3} & -\\frac{5}{3} & \\frac{22}{9} & \\frac{25}{9} \\\\\n \\frac{11}{9} & \\frac{14}{9} & \\frac{20}{9} & \\frac{22}{9} & -\\frac{13}{9} \\\\\n -\\frac{1}{9} & \\frac{2}{3} & \\frac{2}{3} & -\\frac{10}{9} & -\\frac{4}{3} \\\\\n -\\frac{5}{9} & -\\frac{2}{3} & -\\frac{26}{9} & \\frac{20}{9} & -\\frac{16}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n \\frac{8}{3} & 0 & -\\frac{14}{9} & \\frac{4}{3} & -\\frac{4}{9} \\\\\n -\\frac{4}{3} & -\\frac{13}{9} & -1 & \\frac{2}{9} & -\\frac{2}{3} \\\\\n -\\frac{13}{9} & 0 & \\frac{4}{9} & \\frac{5}{9} & \\frac{22}{9} \\\\\n -\\frac{17}{9} & \\frac{7}{3} & \\frac{7}{3} & -1 & -\\frac{13}{9} \\\\\n \\frac{7}{3} & -\\frac{17}{9} & \\frac{2}{9} & \\frac{19}{9} & \\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n \\frac{910}{81} & \\frac{232}{81} & \\frac{121}{27} & \\frac{364}{81} & -\\frac{215}{81} \\\\\n -\\frac{811}{81} & \\frac{167}{27} & \\frac{236}{81} & -\\frac{185}{81} & -\\frac{169}{81} \\\\\n -\\frac{256}{81} & -\\frac{28}{27} & -\\frac{250}{81} & -\\frac{4}{3} & \\frac{50}{81} \\\\\n -\\frac{386}{81} & \\frac{770}{81} & \\frac{136}{27} & -\\frac{686}{81} & -\\frac{1016}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(16/9), -(5/3), -(5/3), (22/9), (25/9)],\n [(11/9), (14/9), (20/9), (22/9), -(13/9)],\n [-(1/9), (2/3), (2/3), -(10/9), -(4/3)],\n [-(5/9), -(2/3), -(26/9), (20/9), -(16/9)]])\nb = np.array([\n [(8/3), 0, -(14/9), (4/3), -(4/9)],\n [-(4/3), -(13/9), -1, (2/9), -(2/3)],\n [-(13/9), 0, (4/9), (5/9), (22/9)],\n [-(17/9), (7/3), (7/3), -1, -(13/9)],\n [(7/3), -(17/9), (2/9), (19/9), (5/3)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{41}{5} \\\\\n -\\frac{3}{5} \\\\\n \\frac{3}{5} \\\\\n -\\frac{26}{5} \\\\\n -\\frac{12}{5} \\\\\n -\\frac{11}{5} \\\\\n -8 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{34}{5} \\\\\n -\\frac{42}{5} \\\\\n 2 \\\\\n -8 \\\\\n -\\frac{19}{5} \\\\\n -\\frac{22}{5} \\\\\n -\\frac{42}{5} \\\\\n \\frac{29}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{10481}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(41/5)],\n [-(3/5)],\n [(3/5)],\n [-(26/5)],\n [-(12/5)],\n [-(11/5)],\n [-8],\n [-5]])\nb = np.array([\n [-(34/5)],\n [-(42/5)],\n [2],\n [-8],\n [-(19/5)],\n [-(22/5)],\n [-(42/5)],\n [(29/5)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -7 \\\\\n 5 \\\\\n 9 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 4 \\\\\n -6 \\\\\n 1 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-29$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-7],\n [5],\n [9],\n [7]])\nb = np.array([\n [-9],\n [4],\n [-6],\n [1],\n [8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n \\frac{17}{2} \\\\\n 1 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{2} \\\\\n \\frac{13}{2} \\\\\n 2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(13 \\sqrt{\\frac{5}{1178}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [(17/2)],\n [1],\n [-7]]).squeeze()\nb = np.array([\n [-(17/2)],\n [(13/2)],\n [2],\n [-2]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & -1 \\\\\n -\\frac{3}{2} & 0 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{15}{4} & -\\frac{3}{2} \\\\\n -\\frac{9}{4} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), -1],\n [-(3/2), 0]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{9}{2}-\\frac{9 i}{2} & -3-3 i & -4-\\frac{5 i}{2} \\\\\n -\\frac{3}{2} & -4-\\frac{9 i}{2} & -3+5 i \\\\\n 3 & 3+\\frac{3 i}{2} & \\frac{7}{2}+\\frac{3 i}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{2229}{8}-168 i & \\frac{1593}{4}-\\frac{1167 i}{8} & 17-\\frac{473 i}{2} \\\\\n \\frac{813}{4}-\\frac{1527 i}{8} & \\frac{3367}{8}-\\frac{1305 i}{8} & -\\frac{693}{8}-288 i \\\\\n -\\frac{507}{8}+153 i & -\\frac{1179}{8}+171 i & \\frac{229}{8}+\\frac{219 i}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2)-((9j)/2), -3-3j, -4-((5j)/2)],\n [-(3/2), -4-((9j)/2), -3+5j],\n [3, 3+((3j)/2), (7/2)+((3j)/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 6 \\\\\n -5 \\\\\n -3 \\\\\n -8 \\\\\n 7 \\\\\n -10 \\\\\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 9 \\\\\n 9 \\\\\n 3 \\\\\n 2 \\\\\n 5 \\\\\n 8 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-95$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [6],\n [-5],\n [-3],\n [-8],\n [7],\n [-10],\n [10]])\nb = np.array([\n [-2],\n [9],\n [9],\n [3],\n [2],\n [5],\n [8],\n [-2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & -7 \\\\\n 6 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-1-i \\sqrt{26},-1+i \\sqrt{26}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -7],\n [6, -5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -1 & -1 & 1 & -1 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 0 & 2 & -1 \\\\\n 2 & -2 & 2 \\\\\n 2 & -2 & -3 \\\\\n -1 & -2 & 3 \\\\\n -1 & 1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 2 & -1 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, 1, -1, -1]])\nb = np.array([\n [0, 2, -1],\n [2, -2, 2],\n [2, -2, -3],\n [-1, -2, 3],\n [-1, 1, -2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -1 & 0 & -1 & 0 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 0 & 0 & 0 & 0 & 0 \\\\\n -1 & 0 & -1 & 0 & -2 \\\\\n -1 & 0 & -1 & 0 & -2 \\\\\n 2 & 0 & 2 & 0 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [1],\n [-2]])\nb = np.array([\n [-1, 0, -1, 0, -2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & -1 & -1 \\\\\n 2 & -4 & -1 \\\\\n -2 & 0 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, -1],\n [2, -4, -1],\n [-2, 0, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{5} & -\\frac{37}{5} \\\\\n \\frac{3}{5} & -\\frac{11}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{3} i \\left(\\sqrt{86}-5 i\\right),1\\right\\}, \\left\\{-\\frac{1}{3} i \\left(\\sqrt{86}+5 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/5), -(37/5)],\n [(3/5), -(11/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -4 & -4 \\\\\n 8 & 9 \\\\\n 8 & 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 8 & -1 \\\\\n -8 & -3 \\\\\n 5 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 4 & -5 \\\\\n 0 & 6 \\\\\n 13 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -4],\n [8, 9],\n [8, 7]])\nb = np.array([\n [8, -1],\n [-8, -3],\n [5, -9]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -7 & 1 & 5 & 7 & 9 & 2 \\\\\n -8 & 1 & -9 & -8 & -2 & 4 \\\\\n -9 & -10 & -2 & 10 & -8 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & -\\frac{200}{577} & -\\frac{310}{577} & -\\frac{146}{577} \\\\\n 0 & 1 & 0 & -\\frac{1047}{1154} & \\frac{1291}{1154} & \\frac{492}{577} \\\\\n 0 & 0 & 1 & \\frac{1265}{1154} & \\frac{951}{1154} & -\\frac{72}{577} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, 1, 5, 7, 9, 2],\n [-8, 1, -9, -8, -2, 4],\n [-9, -10, -2, 10, -8, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 5 & 5 \\\\\n 9 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{2-3 \\sqrt{6},2+3 \\sqrt{6}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 5],\n [9, -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{31}{5} & \\frac{13}{5} \\\\\n \\frac{23}{5} & \\frac{32}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{46} \\left(-63-\\sqrt{5165}\\right),1\\right\\}, \\left\\{\\frac{1}{46} \\left(\\sqrt{5165}-63\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(31/5), (13/5)],\n [(23/5), (32/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{61}{10} & \\frac{27}{5} & \\frac{69}{10} & \\frac{19}{5} \\\\\n \\frac{31}{5} & -\\frac{67}{10} & -\\frac{15}{2} & \\frac{51}{10} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{46}{5} & -\\frac{23}{5} & \\frac{49}{5} & \\frac{42}{5} \\\\\n \\frac{3}{5} & -\\frac{17}{10} & 3 & \\frac{97}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{31}{10} & 10 & -\\frac{29}{10} & -\\frac{23}{5} \\\\\n \\frac{28}{5} & -5 & -\\frac{21}{2} & -\\frac{23}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(61/10), (27/5), (69/10), (19/5)],\n [(31/5), -(67/10), -(15/2), (51/10)]])\nb = np.array([\n [-(46/5), -(23/5), (49/5), (42/5)],\n [(3/5), -(17/10), 3, (97/10)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{12}{5} & 1 & -1 & \\frac{3}{5} & -\\frac{12}{5} \\\\\n -\\frac{7}{5} & -1 & \\frac{7}{5} & \\frac{6}{5} & \\frac{6}{5} \\\\\n -1 & \\frac{7}{5} & -\\frac{14}{5} & -\\frac{14}{5} & -\\frac{9}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{9}{5} & -\\frac{9}{5} & -\\frac{2}{5} & 1 \\\\\n -\\frac{1}{5} & -\\frac{6}{5} & -\\frac{8}{5} & \\frac{14}{5} \\\\\n -\\frac{4}{5} & \\frac{11}{5} & 0 & \\frac{12}{5} \\\\\n -\\frac{13}{5} & \\frac{7}{5} & -2 & \\frac{6}{5} \\\\\n -\\frac{4}{5} & \\frac{9}{5} & -\\frac{14}{5} & -\\frac{13}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{132}{25} & -\\frac{56}{5} & \\frac{74}{25} & \\frac{244}{25} \\\\\n -\\frac{188}{25} & \\frac{266}{25} & -\\frac{18}{5} & -\\frac{63}{25} \\\\\n \\frac{222}{25} & -\\frac{66}{5} & \\frac{44}{5} & -\\frac{62}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(12/5), 1, -1, (3/5), -(12/5)],\n [-(7/5), -1, (7/5), (6/5), (6/5)],\n [-1, (7/5), -(14/5), -(14/5), -(9/5)]])\nb = np.array([\n [(9/5), -(9/5), -(2/5), 1],\n [-(1/5), -(6/5), -(8/5), (14/5)],\n [-(4/5), (11/5), 0, (12/5)],\n [-(13/5), (7/5), -2, (6/5)],\n [-(4/5), (9/5), -(14/5), -(13/5)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 9 \\\\\n 1 \\\\\n -3 \\\\\n -6 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 7 \\\\\n 10 \\\\\n 4 \\\\\n 5 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4 \\sqrt{17}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [9],\n [1],\n [-3],\n [-6],\n [0]])\nb = np.array([\n [-10],\n [7],\n [10],\n [4],\n [5],\n [-1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{26}{3} \\\\\n -\\frac{19}{9} \\\\\n \\frac{73}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{19}{9} \\\\\n \\frac{17}{3} \\\\\n -\\frac{1}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3704}{81} \\\\\n \\frac{1309}{81} \\\\\n -\\frac{3617}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(26/3)],\n [-(19/9)],\n [(73/9)]])\nb = np.array([\n [(19/9)],\n [(17/3)],\n [-(1/9)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -2 & -1 & -1 & 3 \\\\\n 2 & 0 & 2 & 3 \\\\\n 2 & 1 & -3 & -3 \\\\\n -2 & -2 & -1 & 3 \\\\\n -3 & -2 & 3 & -1 \\\\\n 3 & 2 & -3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.29 \\\\\n 1.18 \\\\\n 2.24 \\\\\n -1.64 \\\\\n 1.16 \\\\\n -2.76 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.497 \\\\\n -0.866 \\\\\n 0.323 \\\\\n -0.253 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1, -1, 3],\n [2, 0, 2, 3],\n [2, 1, -3, -3],\n [-2, -2, -1, 3],\n [-3, -2, 3, -1],\n [3, 2, -3, -3]])\nb = np.array([\n [-0.29],\n [1.18],\n [2.24],\n [-1.64],\n [1.16],\n [-2.76]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 4 & 1 \\\\\n 2 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{2}{7} & -\\frac{1}{14} \\\\\n -\\frac{1}{7} & \\frac{2}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 1],\n [2, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{2} & -2 \\\\\n \\frac{9}{2} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{2}{17} & \\frac{8}{51} \\\\\n -\\frac{6}{17} & \\frac{10}{51} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), -2],\n [(9/2), (3/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -4 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 3 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -47 \\\\\n 16 \\\\\n 28 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-4],\n [9]])\nb = np.array([\n [4],\n [3],\n [5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -9 & 0 & -5 \\\\\n 9 & 3 & -10 \\\\\n 8 & 7 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-3.519,3.939,1.\\}, \\{-0.271-0.377 i,0.922\\, -0.819 i,1.\\}, \\{-0.271+0.377 i,0.922\\, +0.819 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 0, -5],\n [9, 3, -10],\n [8, 7, -7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 8 & -7 & 10 \\\\\n -6 & -7 & 6 \\\\\n -1 & -9 & -1 \\\\\n -8 & -10 & 4 \\\\\n -6 & -2 & -3 \\\\\n 10 & -6 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, -7, 10],\n [-6, -7, 6],\n [-1, -9, -1],\n [-8, -10, 4],\n [-6, -2, -3],\n [10, -6, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & -1 & 3 & -2 \\\\\n -3 & 2 & -1 & -2 \\\\\n -2 & 0 & 2 & -2 \\\\\n 0 & 2 & 1 & 1 \\\\\n -1 & -3 & 0 & 1 \\\\\n -2 & 2 & -3 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.41 \\\\\n -1.73 \\\\\n 2.76 \\\\\n -1.18 \\\\\n -2.57 \\\\\n 2.34 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.14 \\\\\n 0.265 \\\\\n 0.017 \\\\\n -0.455 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -1, 3, -2],\n [-3, 2, -1, -2],\n [-2, 0, 2, -2],\n [0, 2, 1, 1],\n [-1, -3, 0, 1],\n [-2, 2, -3, 1]])\nb = np.array([\n [1.41],\n [-1.73],\n [2.76],\n [-1.18],\n [-2.57],\n [2.34]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{23}{3} & -8 \\\\\n \\frac{14}{3} & 0 \\\\\n 5 & -\\frac{1}{3} \\\\\n -\\frac{16}{3} & \\frac{10}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{20}{3} & \\frac{20}{3} \\\\\n \\frac{8}{3} & \\frac{29}{3} \\\\\n -\\frac{2}{3} & -9 \\\\\n 9 & -\\frac{23}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & -\\frac{44}{3} \\\\\n 2 & -\\frac{29}{3} \\\\\n \\frac{17}{3} & \\frac{26}{3} \\\\\n -\\frac{43}{3} & 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/3), -8],\n [(14/3), 0],\n [5, -(1/3)],\n [-(16/3), (10/3)]])\nb = np.array([\n [(20/3), (20/3)],\n [(8/3), (29/3)],\n [-(2/3), -9],\n [9, -(23/3)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-3$ and the matrix\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 10 \\\\\n -4 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -27 \\\\\n -30 \\\\\n 12 \\\\\n -15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [10],\n [-4],\n [5]])\nprint(a * -3)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -3 & -9 & -6 & -6 \\\\\n -4 & 1 & 9 & -1 \\\\\n -3 & 5 & -8 & 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -2 & -2 & 2 & 0 \\\\\n 3 & -5 & 6 & -5 \\\\\n 7 & -3 & -4 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -5 & -11 & -4 & -6 \\\\\n -1 & -4 & 15 & -6 \\\\\n 4 & 2 & -12 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -9, -6, -6],\n [-4, 1, 9, -1],\n [-3, 5, -8, 5]])\nb = np.array([\n [-2, -2, 2, 0],\n [3, -5, 6, -5],\n [7, -3, -4, -5]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{7}{2}, -3, \\frac{3}{2}}$ to the plane $-4 x-5 y+2 z-\\frac{7}{2}=0$.", - "Output Answer": [ - "$\\frac{1}{6 \\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (7/2), -3, (3/2)\nplane = Poly(-4*x-5*y+2*z-(7/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 3 & -2 & -2 \\\\\n 1 & -1 & 2 \\\\\n -2 & 0 & 2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 11 & -4 & -14 \\\\\n -2 & -1 & 0 \\\\\n -10 & 4 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2, -2],\n [1, -1, 2],\n [-2, 0, 2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & -3 & 0 & -1 \\\\\n 0 & 3 & -3 & -3 \\\\\n 3 & -3 & 2 & 0 \\\\\n 1 & 0 & 1 & 2 \\\\\n 1 & 3 & 3 & 3 \\\\\n -2 & -2 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.47 \\\\\n 2.44 \\\\\n 2.97 \\\\\n 2.19 \\\\\n -2.81 \\\\\n -2.52 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.838 \\\\\n 0.011 \\\\\n -1.374 \\\\\n 0.326 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3, 0, -1],\n [0, 3, -3, -3],\n [3, -3, 2, 0],\n [1, 0, 1, 2],\n [1, 3, 3, 3],\n [-2, -2, -1, 2]])\nb = np.array([\n [-0.47],\n [2.44],\n [2.97],\n [2.19],\n [-2.81],\n [-2.52]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 9 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 7 \\\\\n 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 13 \\\\\n 23 \\\\\n -71 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [9],\n [2]])\nb = np.array([\n [4],\n [7],\n [3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -3 & 0 & -3 & 1 & -3 \\\\\n 1 & -2 & -1 & -1 & 3 \\\\\n 1 & 0 & -2 & 1 & 0 \\\\\n 2 & 0 & -1 & 2 & -2 \\\\\n 3 & 1 & -3 & 1 & -1 \\\\\n -1 & 2 & -3 & -2 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.07 \\\\\n -1.13 \\\\\n 2.19 \\\\\n 0. \\\\\n 0.44 \\\\\n -2.99 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.769 \\\\\n 1.009 \\\\\n 0.177 \\\\\n 3.201 \\\\\n 1.738 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, -3, 1, -3],\n [1, -2, -1, -1, 3],\n [1, 0, -2, 1, 0],\n [2, 0, -1, 2, -2],\n [3, 1, -3, 1, -1],\n [-1, 2, -3, -2, 1]])\nb = np.array([\n [-0.07],\n [-1.13],\n [2.19],\n [0.],\n [0.44],\n [-2.99]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n \\frac{3}{2} \\\\\n \\frac{5}{4} \\\\\n -\\frac{25}{4} \\\\\n -\\frac{7}{4} \\\\\n -2 \\\\\n \\frac{17}{4} \\\\\n -\\frac{3}{2} \\\\\n -\\frac{1}{2} \\\\\n \\frac{39}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{2} \\\\\n 3 \\\\\n -2 \\\\\n \\frac{7}{2} \\\\\n -\\frac{7}{4} \\\\\n -\\frac{1}{4} \\\\\n -\\frac{17}{2} \\\\\n \\frac{23}{4} \\\\\n \\frac{7}{4} \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{10811}}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2)],\n [(3/2)],\n [(5/4)],\n [-(25/4)],\n [-(7/4)],\n [-2],\n [(17/4)],\n [-(3/2)],\n [-(1/2)],\n [(39/4)]])\nb = np.array([\n [-(11/2)],\n [3],\n [-2],\n [(7/2)],\n [-(7/4)],\n [-(1/4)],\n [-(17/2)],\n [(23/4)],\n [(7/4)],\n [-7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{5} \\\\\n -\\frac{16}{5} \\\\\n -\\frac{34}{5} \\\\\n \\frac{41}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{3382}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/5)],\n [-(16/5)],\n [-(34/5)],\n [(41/5)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,3,1\\}, \\{4,1,-1\\}, \\{-4,-5,-2\\}}$.", - "Output Answer": [ - "$10 x-21 y+46 z+27=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, 3, 1],\n [4, 1, -1],\n [-4, -5, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-1,-1,3\\}, \\{-3,0,-1\\}, \\{2,-1,-1\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{11}},-\\frac{1}{\\sqrt{11}},\\frac{3}{\\sqrt{11}}\\right\\}, \\left\\{-\\frac{3}{\\sqrt{10}},0,-\\frac{1}{\\sqrt{10}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{110}},-\\sqrt{\\frac{10}{11}},-\\frac{3}{\\sqrt{110}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, -1, 3), (-3, 0, -1), (2, -1, -1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{33}{4} \\\\\n \\frac{17}{2} \\\\\n \\frac{13}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{71}{16} \\\\\n \\frac{17}{16} \\\\\n \\frac{135}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1037}{16} \\\\\n -\\frac{2609}{64} \\\\\n -\\frac{1853}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(33/4)],\n [(17/2)],\n [(13/2)]])\nb = np.array([\n [(71/16)],\n [(17/16)],\n [(135/16)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & 1 & 2 \\\\\n \\frac{5}{2} & -\\frac{3}{2} & \\frac{3}{2} \\\\\n 0 & \\frac{5}{2} & 2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{11}{4} & \\frac{17}{2} & \\frac{71}{4} \\\\\n \\frac{55}{2} & -\\frac{37}{8} & \\frac{47}{4} \\\\\n -\\frac{25}{8} & \\frac{95}{4} & \\frac{239}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, 2],\n [(5/2), -(3/2), (3/2)],\n [0, (5/2), 2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{7} & 3 \\\\\n \\frac{20}{7} & \\frac{25}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{35}{59} & \\frac{147}{295} \\\\\n \\frac{28}{59} & -\\frac{7}{59} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/7), 3],\n [(20/7), (25/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 1 & -9 & 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 0 & -2 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & -11 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -9, 4]])\nb = np.array([\n [0, -2, 0]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{4,2,1\\}, \\{2,-2,0\\}, \\{-2,-2,0\\}}$.", - "Output Answer": [ - "$y-4 z+2=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, 2, 1],\n [2, -2, 0],\n [-2, -2, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{9} \\\\\n \\frac{28}{9} \\\\\n \\frac{37}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{20}{9} \\\\\n -2 \\\\\n \\frac{25}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1366}{81} \\\\\n -\\frac{415}{81} \\\\\n \\frac{794}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/9)],\n [(28/9)],\n [(37/9)]])\nb = np.array([\n [-(20/9)],\n [-2],\n [(25/9)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & -3 \\\\\n -3 & 3 \\\\\n -3 & 0 \\\\\n -2 & -3 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.46 \\\\\n -0.4 \\\\\n -2.06 \\\\\n -2.93 \\\\\n 0.45 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.682 \\\\\n 0.482 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3],\n [-3, 3],\n [-3, 0],\n [-2, -3],\n [0, 1]])\nb = np.array([\n [-0.46],\n [-0.4],\n [-2.06],\n [-2.93],\n [0.45]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $2$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 3 & -5 & 2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 6 & -10 & 4 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -5, 2, 2]])\nprint(a * 2)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 5 \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n 0 \\\\\n -\\sqrt{3} \\\\\n 4 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\sqrt{3} \\\\\n -3 \\sqrt{3} \\\\\n \\sqrt{3} \\\\\n -3 \\sqrt{3} \\\\\n -3 \\sqrt{3} \\\\\n 3 \\sqrt{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{309}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [5*math.sqrt(3)],\n [math.sqrt(3)],\n [0],\n [-math.sqrt(3)],\n [4*math.sqrt(3)]])\nb = np.array([\n [-5*math.sqrt(3)],\n [-3*math.sqrt(3)],\n [math.sqrt(3)],\n [-3*math.sqrt(3)],\n [-3*math.sqrt(3)],\n [3*math.sqrt(3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{3,\\frac{7}{2},-\\frac{3}{2}\\right\\}, \\left\\{\\frac{7}{2},\\frac{7}{2},-3\\right\\}, \\left\\{-\\frac{9}{2},\\frac{3}{2},\\frac{1}{2}\\right\\}}$.", - "Output Answer": [ - "$24 x-82 y+8 z+227=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, (7/2), -(3/2)],\n [(7/2), (7/2), -3],\n [-(9/2), (3/2), (1/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{28}{5} & -\\frac{43}{5} \\\\\n 3 & \\frac{34}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{15} \\left(-31-2 \\sqrt{79}\\right),1\\right\\}, \\left\\{\\frac{1}{15} \\left(2 \\sqrt{79}-31\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(28/5), -(43/5)],\n [3, (34/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -3 & 7 & -4 \\\\\n 1 & -9 & 8 \\\\\n -3 & 4 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-5 x^2+108 x+160$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 7, -4],\n [1, -9, 8],\n [-3, 4, 7]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 9 & 9 & 7 & 1 \\\\\n 1 & 3 & -9 & -4 \\\\\n -2 & -5 & 6 & -9 \\\\\n -6 & 10 & 4 & 4 \\\\\n -4 & 3 & 0 & 6 \\\\\n 3 & 5 & -6 & -4 \\\\\n 6 & 2 & -2 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, 9, 7, 1],\n [1, 3, -9, -4],\n [-2, -5, 6, -9],\n [-6, 10, 4, 4],\n [-4, 3, 0, 6],\n [3, 5, -6, -4],\n [6, 2, -2, -10]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & 0 & 2 \\\\\n 2 & 0 & 5 \\\\\n 2 & 4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{5}{6} & -\\frac{1}{3} & 0 \\\\\n -\\frac{5}{12} & \\frac{1}{6} & \\frac{1}{4} \\\\\n -\\frac{1}{3} & \\frac{1}{3} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, 2],\n [2, 0, 5],\n [2, 4, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{33}{10}, -\\frac{41}{10}}$ to the line $-\\frac{19 x}{10}-\\frac{19 y}{10}+\\frac{9}{10}=0$.", - "Output Answer": [ - "$\\frac{121}{95 \\sqrt{2}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (33/10), -(41/10)\nline = Poly(-((19*x)/10)-((19*y)/10)+(9/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & -4 & 2 \\\\\n -1 & 3 & -5 \\\\\n 1 & -2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{13}{4} & 2 & -\\frac{7}{2} \\\\\n \\frac{3}{2} & 1 & -2 \\\\\n \\frac{1}{4} & 0 & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -4, 2],\n [-1, 3, -5],\n [1, -2, -1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{13}{64}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 7 & 9 & -9 & 0 \\\\\n -4 & -6 & 1 & 8 \\\\\n 6 & 10 & 9 & -7 \\\\\n 7 & -6 & 6 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{91}{64} & \\frac{117}{64} & -\\frac{117}{64} & 0 \\\\\n -\\frac{13}{16} & -\\frac{39}{32} & \\frac{13}{64} & \\frac{13}{8} \\\\\n \\frac{39}{32} & \\frac{65}{32} & \\frac{117}{64} & -\\frac{91}{64} \\\\\n \\frac{91}{64} & -\\frac{39}{32} & \\frac{39}{32} & -\\frac{13}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 9, -9, 0],\n [-4, -6, 1, 8],\n [6, 10, 9, -7],\n [7, -6, 6, -2]])\nprint(a * (13/64))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -1 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 0 & -1 & -3 & 1 & -2 \\\\\n 2 & 2 & 2 & 2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 0 & 1 & 3 & -1 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0]])\nb = np.array([\n [0, -1, -3, 1, -2],\n [2, 2, 2, 2, -2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 10 & 9 & -3 \\\\\n -9 & 0 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-45.,77.,81.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [10, 9, -3],\n [-9, 0, -5]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & -7 \\\\\n -4 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{8} \\left(7-\\sqrt{161}\\right),1\\right\\}, \\left\\{\\frac{1}{8} \\left(7+\\sqrt{161}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -7],\n [-4, 5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 5 & -\\frac{11}{2} & \\frac{11}{4} \\\\\n 0 & \\frac{31}{4} & \\frac{11}{2} \\\\\n -\\frac{17}{4} & 1 & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{4} & -\\frac{11}{4} & \\frac{5}{2} \\\\\n -\\frac{17}{2} & \\frac{21}{4} & -\\frac{23}{4} \\\\\n 7 & -\\frac{9}{2} & \\frac{25}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{33}{4} & -\\frac{33}{4} & \\frac{21}{4} \\\\\n -\\frac{17}{2} & 13 & -\\frac{1}{4} \\\\\n \\frac{11}{4} & -\\frac{7}{2} & \\frac{13}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -(11/2), (11/4)],\n [0, (31/4), (11/2)],\n [-(17/4), 1, (1/4)]])\nb = np.array([\n [(13/4), -(11/4), (5/2)],\n [-(17/2), (21/4), -(23/4)],\n [7, -(9/2), (25/4)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & 3 \\\\\n -3 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$12$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3],\n [-3, -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 7 \\\\\n -4 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-6 x+12$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 7],\n [-4, -2]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 1 & 2 & 1 & -2 & -1 \\\\\n -3 & 1 & 1 & -2 & 1 \\\\\n 3 & 2 & 3 & 3 & 1 \\\\\n 2 & -2 & 2 & -2 & -1 \\\\\n 1 & 2 & -3 & 1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & 2 & 3 & 1 \\\\\n -1 & 1 & -3 & -2 \\\\\n -2 & 2 & 0 & -2 \\\\\n -1 & -3 & 0 & -2 \\\\\n -2 & 1 & 2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 2 & 11 & -5 & -1 \\\\\n -9 & 4 & -10 & -3 \\\\\n -7 & 6 & 5 & -13 \\\\\n 6 & 11 & 10 & 6 \\\\\n 1 & -3 & 1 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, 1, -2, -1],\n [-3, 1, 1, -2, 1],\n [3, 2, 3, 3, 1],\n [2, -2, 2, -2, -1],\n [1, 2, -3, 1, 2]])\nb = np.array([\n [2, 2, 3, 1],\n [-1, 1, -3, -2],\n [-2, 2, 0, -2],\n [-1, -3, 0, -2],\n [-2, 1, 2, 0]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & \\frac{5}{2} \\\\\n 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), (5/2)],\n [1, -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{2} & -\\frac{3}{4} & \\frac{39}{4} \\\\\n -7 & 10 & 2 \\\\\n -\\frac{13}{2} & -\\frac{7}{4} & -\\frac{39}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-5.937-7.393 i,-5.937+7.393 i,10.624\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), -(3/4), (39/4)],\n [-7, 10, 2],\n [-(13/2), -(7/4), -(39/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 5 & -5 & -10 \\\\\n 9 & -5 & 8 \\\\\n -8 & 9 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, -5, -10],\n [9, -5, 8],\n [-8, 9, 1]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n \\frac{69}{16} \\\\\n \\frac{11}{16} \\\\\n \\frac{15}{16} \\\\\n \\frac{109}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(69/16)],\n [(11/16)],\n [(15/16)],\n [(109/16)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 0 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -1 & 3 & 0 & -1 \\\\\n -3 & -1 & 2 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 6 & 2 & -4 & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2]])\nb = np.array([\n [-1, 3, 0, -1],\n [-3, -1, 2, 3]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -9 \\\\\n 1 \\\\\n -8 \\\\\n 0 \\\\\n 10 \\\\\n 8 \\\\\n -1 \\\\\n 0 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 7 \\\\\n -7 \\\\\n 8 \\\\\n 10 \\\\\n 4 \\\\\n -6 \\\\\n 9 \\\\\n -1 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{1297}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-9],\n [1],\n [-8],\n [0],\n [10],\n [8],\n [-1],\n [0],\n [-2]])\nb = np.array([\n [-2],\n [7],\n [-7],\n [8],\n [10],\n [4],\n [-6],\n [9],\n [-1],\n [10]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{1,3,-2\\}, \\{-3,2,1\\}, \\{1,2,2\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{14}},\\frac{3}{\\sqrt{14}},-\\sqrt{\\frac{2}{7}}\\right\\}, \\left\\{-\\frac{43}{\\sqrt{2730}},5 \\sqrt{\\frac{5}{546}},8 \\sqrt{\\frac{2}{1365}}\\right\\}, \\left\\{\\frac{7}{\\sqrt{195}},\\sqrt{\\frac{5}{39}},\\frac{11}{\\sqrt{195}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((1, 3, -2), (-3, 2, 1), (1, 2, 2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -4 & 3 & -1 \\\\\n -1 & -2 & -2 \\\\\n 0 & 4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{2}{7} & \\frac{1}{7} & \\frac{2}{7} \\\\\n 0 & 0 & \\frac{1}{4} \\\\\n \\frac{1}{7} & -\\frac{4}{7} & -\\frac{11}{28} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 3, -1],\n [-1, -2, -2],\n [0, 4, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{7}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{18}{5} \\\\\n \\frac{36}{5} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{26}{5} \\\\\n 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{8}{5} \\\\\n -\\frac{14}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(18/5)],\n [(36/5)]])\nb = np.array([\n [(26/5)],\n [10]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 7 & -5 & 3 & -5 & 7 & 7 & -2 \\\\\n 3 & -1 & -8 & -6 & 4 & 7 & 2 \\\\\n 4 & -2 & -6 & -2 & 5 & -6 & -3 \\\\\n -5 & 6 & 4 & 5 & 3 & 8 & 7 \\\\\n -6 & -3 & -10 & 5 & -10 & -1 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & -\\frac{7070}{1037} & -\\frac{8297}{2074} \\\\\n 0 & 1 & 0 & 0 & 0 & -\\frac{3461}{1037} & -\\frac{28831}{14518} \\\\\n 0 & 0 & 1 & 0 & 0 & \\frac{908}{1037} & \\frac{1157}{14518} \\\\\n 0 & 0 & 0 & 1 & 0 & -\\frac{3592}{1037} & -\\frac{16651}{14518} \\\\\n 0 & 0 & 0 & 0 & 1 & \\frac{2680}{1037} & \\frac{10474}{7259} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, -5, 3, -5, 7, 7, -2],\n [3, -1, -8, -6, 4, 7, 2],\n [4, -2, -6, -2, 5, -6, -3],\n [-5, 6, 4, 5, 3, 8, 7],\n [-6, -3, -10, 5, -10, -1, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 6 & -9 & 1 & 7 \\\\\n 4 & 2 & -7 & -10 \\\\\n -9 & 8 & 2 & -4 \\\\\n 6 & 0 & 5 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [6, -9, 1, 7],\n [4, 2, -7, -10],\n [-9, 8, 2, -4],\n [6, 0, 5, -7]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & -7 & 6 \\\\\n -6 & 1 & 4 \\\\\n 8 & 4 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.032,-1.24,1.\\}, \\{-0.262,0.872,1.\\}, \\{1.074,-0.19,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -7, 6],\n [-6, 1, 4],\n [8, 4, 6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -4 & -4 & 3 \\\\\n -4 & -4 & 1 \\\\\n -1 & 3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-32$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -4, 3],\n [-4, -4, 1],\n [-1, 3, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{1}{2}, 0, -4}$ to the plane $-x+\\frac{y}{2}+\\frac{7 z}{2}-\\frac{1}{2}=0$.", - "Output Answer": [ - "$\\frac{14 \\sqrt{\\frac{2}{3}}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(1/2), 0, -4\nplane = Poly(-x+(y/2)+((7*z)/2)-(1/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{26}{3} & \\frac{5}{3} \\\\\n -\\frac{14}{3} & -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{3} \\left(-14-\\sqrt{74}\\right),\\frac{1}{3} \\left(\\sqrt{74}-14\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(26/3), (5/3)],\n [-(14/3), -(2/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{19}{4} \\\\\n -\\frac{11}{4} \\\\\n 3 \\\\\n \\frac{31}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n \\frac{1}{2} \\\\\n -\\frac{31}{4} \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{505}}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/4)],\n [-(11/4)],\n [3],\n [(31/4)]])\nb = np.array([\n [5],\n [(1/2)],\n [-(31/4)],\n [8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(\\sqrt{3}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [1],\n [0],\n [-1],\n [0],\n [0]]).squeeze()\nb = np.array([\n [0],\n [-1],\n [0],\n [1],\n [-1],\n [0],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 8 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -40 \\\\\n 52 \\\\\n -62 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-3],\n [2]])\nb = np.array([\n [-2],\n [8],\n [8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{24}{5}, \\frac{6}{5}}$ to the line $\\frac{x}{5}-\\frac{13 y}{5}-4=0$.", - "Output Answer": [ - "$\\frac{77 \\sqrt{\\frac{2}{85}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (24/5), (6/5)\nline = Poly((x/5)-((13*y)/5)-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -8 & -7 & -6 \\\\\n 0 & -1 & -10 \\\\\n -4 & -7 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-13.991,-3.018,7.01\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -7, -6],\n [0, -1, -10],\n [-4, -7, -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -2 & 0 \\\\\n 3 & -3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -8 & 0 \\\\\n 57 & -27 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0],\n [3, -3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & -5 \\\\\n \\frac{1}{2} & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{19}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), -5],\n [(1/2), (9/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{5} & -\\frac{22}{5} & \\frac{37}{5} \\\\\n -\\frac{21}{5} & -\\frac{31}{5} & 8 \\\\\n -\\frac{23}{5} & -2 & -\\frac{28}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.537,2.781,1.\\}, \\{0.076\\, -0.892 i,0.451\\, -1.219 i,1.\\}, \\{0.076\\, +0.892 i,0.451\\, +1.219 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/5), -(22/5), (37/5)],\n [-(21/5), -(31/5), 8],\n [-(23/5), -2, -(28/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-4, -\\frac{21}{5}}$ to the line $\\frac{x}{10}+\\frac{23 y}{5}-\\frac{13}{10}=0$.", - "Output Answer": [ - "$\\frac{1051}{5 \\sqrt{2117}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -4, -(21/5)\nline = Poly((x/10)+((23*y)/5)-(13/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, \\frac{3}{5}, \\frac{11}{5}}$ to the plane $-\\frac{17 x}{5}+\\frac{19 y}{5}-\\frac{6 z}{5}+\\frac{21}{5}=0$.", - "Output Answer": [ - "$\\frac{19 \\sqrt{\\frac{2}{7}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, (3/5), (11/5)\nplane = Poly(-((17*x)/5)+((19*y)/5)-((6*z)/5)+(21/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 0 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -1 \\\\\n -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 9 \\\\\n 17 \\\\\n -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [0],\n [9]])\nb = np.array([\n [-7],\n [-1],\n [-10]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 1 \\\\\n -2 & 2 \\\\\n -2 & 2 \\\\\n 0 & 1 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.58 \\\\\n 1.43 \\\\\n -2.54 \\\\\n -1.24 \\\\\n 0.51 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.43 \\\\\n 0.071 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1],\n [-2, 2],\n [-2, 2],\n [0, 1],\n [0, 1]])\nb = np.array([\n [1.58],\n [1.43],\n [-2.54],\n [-1.24],\n [0.51]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -6 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$13$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-6],\n [2],\n [1]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{2} & \\frac{7}{2} & -\\frac{31}{8} \\\\\n -\\frac{19}{8} & \\frac{37}{8} & -\\frac{31}{16} \\\\\n -\\frac{37}{16} & 5 & -\\frac{37}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1032}{3635} & -\\frac{11552}{3635} & \\frac{11408}{3635} \\\\\n -\\frac{1036}{3635} & -\\frac{3256}{3635} & \\frac{4464}{3635} \\\\\n -\\frac{1208}{3635} & \\frac{4512}{3635} & -\\frac{3328}{3635} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), (7/2), -(31/8)],\n [-(19/8), (37/8), -(31/16)],\n [-(37/16), 5, -(37/16)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{4}{3}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -6 & 6 \\\\\n -5 & -5 \\\\\n 10 & -10 \\\\\n 5 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 8 & -8 \\\\\n \\frac{20}{3} & \\frac{20}{3} \\\\\n -\\frac{40}{3} & \\frac{40}{3} \\\\\n -\\frac{20}{3} & \\frac{4}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 6],\n [-5, -5],\n [10, -10],\n [5, -1]])\nprint(a * -(4/3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -5 & -\\frac{20}{3} & 1 \\\\\n 3 & -\\frac{4}{3} & -7 \\\\\n -\\frac{5}{3} & -\\frac{22}{3} & -\\frac{28}{3} \\\\\n \\frac{1}{3} & -7 & -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -(20/3), 1],\n [3, -(4/3), -7],\n [-(5/3), -(22/3), -(28/3)],\n [(1/3), -7, -(14/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -\\frac{3}{2} \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{2} \\\\\n \\frac{3}{2} \\\\\n 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{9}{2} \\\\\n -2 \\\\\n -\\frac{87}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-(3/2)],\n [2]])\nb = np.array([\n [-(11/2)],\n [(3/2)],\n [1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & 2 \\\\\n -5 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-6-\\sqrt{6},\\sqrt{6}-6\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2],\n [-5, -10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -2 & 2 & 2 & 3 & -1 \\\\\n -2 & -1 & -1 & -3 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -1 \\\\\n -2 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -3 \\\\\n 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2, 2, 3, -1],\n [-2, -1, -1, -3, -2]])\nb = np.array([\n [-2],\n [-1],\n [-2],\n [0],\n [1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 0 & \\frac{29}{3} & -\\frac{22}{3} \\\\\n \\frac{8}{3} & \\frac{14}{3} & 0 \\\\\n 7 & -\\frac{22}{3} & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{8 x^2}{3}-\\frac{146 x}{9}+\\frac{11732}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, (29/3), -(22/3)],\n [(8/3), (14/3), 0],\n [7, -(22/3), -2]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -6 & 4 & -4 \\\\\n -8 & -5 & 4 \\\\\n 1 & -4 & 10 \\\\\n -3 & -8 & -9 \\\\\n -10 & -9 & -9 \\\\\n -7 & 1 & 2 \\\\\n -2 & -3 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-6, 4, -4],\n [-8, -5, 4],\n [1, -4, 10],\n [-3, -8, -9],\n [-10, -9, -9],\n [-7, 1, 2],\n [-2, -3, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{25}{3} & \\frac{1}{3} \\\\\n -\\frac{28}{3} & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{3} \\left(-26-3 i \\sqrt{3}\\right),\\frac{1}{3} \\left(-26+3 i \\sqrt{3}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/3), (1/3)],\n [-(28/3), -9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -2 & -1 & 0 & 2 \\\\\n -2 & -2 & -3 & 1 \\\\\n 2 & 3 & -1 & -1 \\\\\n 1 & -2 & 1 & -2 \\\\\n 2 & -2 & 0 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.11 \\\\\n 2.2 \\\\\n -2.81 \\\\\n 0.86 \\\\\n -1.84 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2.999 \\\\\n 0.424 \\\\\n 0.16 \\\\\n -2.47 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1, 0, 2],\n [-2, -2, -3, 1],\n [2, 3, -1, -1],\n [1, -2, 1, -2],\n [2, -2, 0, -2]])\nb = np.array([\n [0.11],\n [2.2],\n [-2.81],\n [0.86],\n [-1.84]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{7}{2},-\\frac{5}{2},-4\\right\\}, \\left\\{-1,\\frac{5}{2},-1\\right\\}, \\left\\{\\frac{7}{2},4,\\frac{3}{2}\\right\\}}$.", - "Output Answer": [ - "$64 x+198 y-234 z-665=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(7/2), -(5/2), -4],\n [-1, (5/2), -1],\n [(7/2), 4, (3/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{99}{16} & -\\frac{31}{4} & \\frac{57}{16} \\\\\n -\\frac{9}{8} & -\\frac{151}{16} & -\\frac{17}{16} \\\\\n \\frac{73}{16} & \\frac{17}{8} & -\\frac{89}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{141 x^2}{16}+\\frac{2017 x}{32}+\\frac{1166821}{2048}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(99/16), -(31/4), (57/16)],\n [-(9/8), -(151/16), -(17/16)],\n [(73/16), (17/8), -(89/16)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -4 & -7 & 8 \\\\\n -8 & -9 & -5 \\\\\n -10 & -10 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-4, -7, 8],\n [-8, -9, -5],\n [-10, -10, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -2 & -3 & 1 \\\\\n -2 & 3 & -3 \\\\\n 2 & 2 & 2 \\\\\n -1 & 1 & 2 \\\\\n -1 & -2 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -2 & 2 & -1 & -2 & 2 \\\\\n 1 & -1 & 1 & -1 & 0 \\\\\n -1 & -3 & -2 & 0 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 0 & -4 & -3 & 7 & -6 \\\\\n 10 & 2 & 11 & 1 & 2 \\\\\n -4 & -4 & -4 & -6 & 0 \\\\\n 1 & -9 & -2 & 1 & -6 \\\\\n 1 & 3 & 1 & 4 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, 1],\n [-2, 3, -3],\n [2, 2, 2],\n [-1, 1, 2],\n [-1, -2, -1]])\nb = np.array([\n [-2, 2, -1, -2, 2],\n [1, -1, 1, -1, 0],\n [-1, -3, -2, 0, -2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{1,-\\frac{9}{2},\\frac{3}{2}\\right\\}, \\left\\{-\\frac{1}{2},-\\frac{5}{2},-\\frac{7}{2}\\right\\}, \\left\\{-\\frac{5}{2},-2,5\\right\\}}$.", - "Output Answer": [ - "$6 x+7 y+z+24=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -(9/2), (3/2)],\n [-(1/2), -(5/2), -(7/2)],\n [-(5/2), -2, 5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -4 & 3 & -4 \\\\\n -1 & 1 & -2 \\\\\n 3 & 0 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & -\\frac{3}{2} & \\frac{1}{2} \\\\\n 2 & -5 & 1 \\\\\n \\frac{3}{4} & -\\frac{9}{4} & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 3, -4],\n [-1, 1, -2],\n [3, 0, -2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -5 & \\frac{25}{4} & \\frac{13}{8} & -\\frac{5}{2} \\\\\n -\\frac{57}{8} & \\frac{7}{8} & -\\frac{15}{8} & \\frac{73}{8} \\\\\n -\\frac{73}{8} & \\frac{67}{8} & \\frac{59}{8} & \\frac{53}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{21}{8} & -\\frac{23}{8} & 2 & -\\frac{45}{8} \\\\\n 2 & -\\frac{29}{8} & \\frac{15}{4} & \\frac{11}{4} \\\\\n \\frac{13}{2} & \\frac{17}{4} & \\frac{11}{8} & \\frac{33}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{19}{8} & \\frac{73}{8} & -\\frac{3}{8} & \\frac{25}{8} \\\\\n -\\frac{73}{8} & \\frac{9}{2} & -\\frac{45}{8} & \\frac{51}{8} \\\\\n -\\frac{125}{8} & \\frac{33}{8} & 6 & -\\frac{13}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, (25/4), (13/8), -(5/2)],\n [-(57/8), (7/8), -(15/8), (73/8)],\n [-(73/8), (67/8), (59/8), (53/8)]])\nb = np.array([\n [-(21/8), -(23/8), 2, -(45/8)],\n [2, -(29/8), (15/4), (11/4)],\n [(13/2), (17/4), (11/8), (33/4)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 3 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{10}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [3],\n [0]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n -7 & 8 & -4 \\\\\n 7 & 6 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 8, -4],\n [7, 6, 1]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 4 & 4 \\\\\n 3 & 7 \\\\\n 8 & 10 \\\\\n -5 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, 4],\n [3, 7],\n [8, 10],\n [-5, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n \\frac{64}{7} \\\\\n \\frac{3}{7} \\\\\n -\\frac{59}{7} \\\\\n -\\frac{68}{7} \\\\\n -\\frac{13}{7} \\\\\n 1 \\\\\n -\\frac{66}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{1}{7} \\\\\n \\frac{53}{7} \\\\\n \\frac{66}{7} \\\\\n -\\frac{52}{7} \\\\\n -\\frac{38}{7} \\\\\n \\frac{60}{7} \\\\\n -\\frac{40}{7} \\\\\n -\\frac{68}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{12617}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [(64/7)],\n [(3/7)],\n [-(59/7)],\n [-(68/7)],\n [-(13/7)],\n [1],\n [-(66/7)]])\nb = np.array([\n [(1/7)],\n [(53/7)],\n [(66/7)],\n [-(52/7)],\n [-(38/7)],\n [(60/7)],\n [-(40/7)],\n [-(68/7)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & 6 \\\\\n -4 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-11-i \\sqrt{95}\\right),\\frac{1}{2} \\left(-11+i \\sqrt{95}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 6],\n [-4, -5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & 2 & -2 \\\\\n 1 & 0 & 1 \\\\\n 1 & -2 & 2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 2 & 0 \\\\\n 0 & 0 & 0 \\\\\n -1 & -2 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2, -2],\n [1, 0, 1],\n [1, -2, 2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{79}{10} & \\frac{28}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{33}{5} & \\frac{53}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{13}{10} & \\frac{109}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(79/10), (28/5)]])\nb = np.array([\n [(33/5), (53/10)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 4 & 7 \\\\\n -5 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, 7],\n [-5, 2]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n \\frac{2}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{5}{\\sqrt{29}} \\\\\n \\frac{2}{\\sqrt{29}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [(2/5)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & 10 \\\\\n -6 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+x+48$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 10],\n [-6, -4]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [-1],\n [0],\n [1]]).squeeze()\nb = np.array([\n [0],\n [1],\n [0],\n [-1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -5 & 9 & -5 \\\\\n 7 & -5 & -10 \\\\\n -1 & 8 & 8 \\\\\n -3 & 7 & 3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 10 & 9 & -4 \\\\\n -7 & 0 & -3 \\\\\n 10 & 2 & -2 \\\\\n 4 & 4 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -15 & 0 & -1 \\\\\n 14 & -5 & -7 \\\\\n -11 & 6 & 10 \\\\\n -7 & 3 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 9, -5],\n [7, -5, -10],\n [-1, 8, 8],\n [-3, 7, 3]])\nb = np.array([\n [10, 9, -4],\n [-7, 0, -3],\n [10, 2, -2],\n [4, 4, 8]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${1, 4, 5}$ to the plane $-4 x-2 y-2 z-3=0$.", - "Output Answer": [ - "$\\frac{25}{2 \\sqrt{6}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 1, 4, 5\nplane = Poly(-4*x-2*y-2*z-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{80}{9} & \\frac{11}{3} & \\frac{11}{3} & -\\frac{32}{9} & -\\frac{4}{3} \\\\\n \\frac{29}{9} & \\frac{38}{9} & \\frac{26}{9} & \\frac{29}{3} & -\\frac{46}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(80/9), (11/3), (11/3), -(32/9), -(4/3)],\n [(29/9), (38/9), (26/9), (29/3), -(46/9)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{3} \\\\\n -\\frac{7}{3} \\\\\n -\\frac{5}{3} \\\\\n \\frac{2}{3} \\\\\n 1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n \\frac{4}{3} \\\\\n -\\frac{8}{3} \\\\\n -\\frac{8}{3} \\\\\n \\frac{7}{3} \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{96}{155},-\\frac{128}{465},\\frac{256}{465},\\frac{256}{465},-\\frac{224}{465},\\frac{64}{155}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3)],\n [-(7/3)],\n [-(5/3)],\n [(2/3)],\n [1],\n [2]]).squeeze()\nb = np.array([\n [-3],\n [(4/3)],\n [-(8/3)],\n [-(8/3)],\n [(7/3)],\n [-2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{4}{3} \\\\\n -\\frac{25}{3} \\\\\n \\frac{19}{3} \\\\\n \\frac{28}{3} \\\\\n -7 \\\\\n -\\frac{1}{3} \\\\\n \\frac{26}{3} \\\\\n -\\frac{29}{3} \\\\\n -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{3} \\\\\n 2 \\\\\n -6 \\\\\n \\frac{7}{3} \\\\\n -\\frac{5}{3} \\\\\n \\frac{29}{3} \\\\\n \\frac{14}{3} \\\\\n \\frac{22}{3} \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{8602}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3)],\n [-(25/3)],\n [(19/3)],\n [(28/3)],\n [-7],\n [-(1/3)],\n [(26/3)],\n [-(29/3)],\n [-(11/3)]])\nb = np.array([\n [-(29/3)],\n [2],\n [-6],\n [(7/3)],\n [-(5/3)],\n [(29/3)],\n [(14/3)],\n [(22/3)],\n [6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{13}{3},-\\frac{2}{3},-\\frac{2}{3}\\right\\}, \\left\\{0,-\\frac{10}{3},-\\frac{5}{3}\\right\\}, \\left\\{-\\frac{2}{3},-2,\\frac{13}{3}\\right\\}}$.", - "Output Answer": [ - "$33 x+57 y-9 z+175=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(13/3), -(2/3), -(2/3)],\n [0, -(10/3), -(5/3)],\n [-(2/3), -2, (13/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{22}{3} \\\\\n -\\frac{29}{6} \\\\\n \\frac{17}{3} \\\\\n \\frac{4}{3} \\\\\n \\frac{23}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$23$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(22/3)],\n [-(29/6)],\n [(17/3)],\n [(4/3)],\n [(23/6)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${2, 2}$ to the line $4 x-4=0$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 2, 2\nline = Poly(4*x-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 2 & 8 & 7 & 6 & -5 & 10 & 6 \\\\\n 9 & 7 & -9 & 10 & 9 & 3 & 1 \\\\\n 9 & -7 & -10 & 5 & 2 & -3 & -1 \\\\\n 4 & -6 & -1 & -7 & -10 & 3 & -8 \\\\\n 2 & -4 & -1 & -4 & 6 & -6 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & \\frac{38911}{104664} & \\frac{62759}{104664} \\\\\n 0 & 1 & 0 & 0 & 0 & \\frac{10751}{14952} & -\\frac{8825}{14952} \\\\\n 0 & 0 & 1 & 0 & 0 & \\frac{1489}{52332} & \\frac{78509}{52332} \\\\\n 0 & 0 & 0 & 1 & 0 & \\frac{1039}{26166} & \\frac{14435}{26166} \\\\\n 0 & 0 & 0 & 0 & 1 & -\\frac{16049}{26166} & \\frac{22445}{26166} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, 8, 7, 6, -5, 10, 6],\n [9, 7, -9, 10, 9, 3, 1],\n [9, -7, -10, 5, 2, -3, -1],\n [4, -6, -1, -7, -10, 3, -8],\n [2, -4, -1, -4, 6, -6, 5]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -5 & -3 \\\\\n -10 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-13-\\sqrt{129}\\right),\\frac{1}{2} \\left(\\sqrt{129}-13\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -3],\n [-10, -8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -9 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -5 \\\\\n -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 34 \\\\\n 37 \\\\\n 19 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-9],\n [5]])\nb = np.array([\n [6],\n [-5],\n [-1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -1 & -1 & 2 & 1 \\\\\n -2 & -3 & 0 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 3 & 3 \\\\\n -2 & 0 \\\\\n 3 & -2 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 5 & -6 \\\\\n 0 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, 2, 1],\n [-2, -3, 0, 1]])\nb = np.array([\n [3, 3],\n [-2, 0],\n [3, -2],\n [0, 1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & 0 \\\\\n 9 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-7 x-18$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0],\n [9, 9]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 10 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 82 \\\\\n -26 \\\\\n -24 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [10],\n [-4]])\nb = np.array([\n [2],\n [-2],\n [9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{17}{2} & \\frac{7}{2} & 3 \\\\\n \\frac{5}{2} & \\frac{19}{2} & -\\frac{5}{2} \\\\\n -\\frac{9}{2} & \\frac{19}{2} & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6.748,1.005,7.743\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/2), (7/2), 3],\n [(5/2), (19/2), -(5/2)],\n [-(9/2), (19/2), 1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -3 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -2 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 28 \\\\\n 4 \\\\\n 33 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-3],\n [8]])\nb = np.array([\n [5],\n [-2],\n [-4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -4 & 2 & 8 & -8 & 5 \\\\\n 10 & -7 & 2 & 9 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-19.,-22.,0.,4.,0.\\}, \\{15.,22.,2.,0.,0.\\}, \\{27.,34.,0.,0.,8.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, 2, 8, -8, 5],\n [10, -7, 2, 9, -4]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{11}{4} & \\frac{5}{4} & -\\frac{3}{2} \\\\\n -\\frac{39}{4} & -3 & -\\frac{7}{2} \\\\\n -\\frac{15}{4} & -\\frac{5}{2} & -\\frac{17}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6.822,1.161\\, -2.261 i,1.161\\, +2.261 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/4), (5/4), -(3/2)],\n [-(39/4), -3, -(7/2)],\n [-(15/4), -(5/2), -(17/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 5 & -\\frac{33}{8} & \\frac{7}{8} & \\frac{47}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n \\frac{23}{8} & -\\frac{13}{8} & -3 & \\frac{15}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{17}{8} & -\\frac{5}{2} & \\frac{31}{8} & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -(33/8), (7/8), (47/8)]])\nb = np.array([\n [(23/8), -(13/8), -3, (15/8)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{8}{5}, -\\frac{3}{2}}$ to the line $-\\frac{11 x}{5}+\\frac{47 y}{10}-\\frac{23}{5}=0$.", - "Output Answer": [ - "$\\frac{1517}{10 \\sqrt{2693}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (8/5), -(3/2)\nline = Poly(-((11*x)/5)+((47*y)/10)-(23/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 1 & 2 & 2 \\\\\n 5 & -1 & \\frac{13}{2} \\\\\n -\\frac{13}{2} & -3 & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{387.406,-837.773,1.\\}, \\{-0.203-0.455 i,0.136\\, -0.892 i,1.\\}, \\{-0.203+0.455 i,0.136\\, +0.892 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, 2],\n [5, -1, (13/2)],\n [-(13/2), -3, (3/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{2} & -1 \\\\\n -1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} \\left(-1-\\sqrt{17}\\right),1\\right\\}, \\left\\{\\frac{1}{4} \\left(\\sqrt{17}-1\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/2), -1],\n [-1, 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{3} \\\\\n -\\frac{14}{3} \\\\\n -\\frac{13}{3} \\\\\n \\frac{35}{6} \\\\\n -\\frac{19}{2} \\\\\n \\frac{5}{6} \\\\\n \\frac{19}{6} \\\\\n \\frac{43}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{29}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/3)],\n [-(14/3)],\n [-(13/3)],\n [(35/6)],\n [-(19/2)],\n [(5/6)],\n [(19/6)],\n [(43/6)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [0],\n [-1],\n [1],\n [-1],\n [-1],\n [0],\n [0]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [1],\n [-1],\n [-1],\n [-1],\n [1],\n [0],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 2 & 2 \\\\\n 2 & -2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 8 & 0 \\\\\n 0 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2],\n [2, -2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{2} & 2 & -1 \\\\\n 2 & 0 & 0 \\\\\n -2 & 3 & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{33}{4} & 0 & -1 \\\\\n 3 & 4 & -2 \\\\\n 4 & -\\frac{11}{2} & \\frac{9}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), 2, -1],\n [2, 0, 0],\n [-2, 3, -(1/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{6}{7} & \\frac{62}{7} & \\frac{48}{7} & -\\frac{39}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{68}{7} & \\frac{54}{7} & \\frac{40}{7} & -\\frac{26}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{74}{7} & \\frac{8}{7} & \\frac{8}{7} & -\\frac{13}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(6/7), (62/7), (48/7), -(39/7)]])\nb = np.array([\n [-(68/7), (54/7), (40/7), -(26/7)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{4} \\\\\n -\\frac{5}{4} \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{21}{8} \\\\\n \\frac{15}{8} \\\\\n \\frac{3}{2} \\\\\n -\\frac{3}{2} \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/4)],\n [-(5/4)],\n [-1],\n [1],\n [-1]])\nb = np.array([\n [-(3/2)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 1 & -10 \\\\\n -10 & -4 \\\\\n -8 & 8 \\\\\n -9 & -6 \\\\\n 5 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, -10],\n [-10, -4],\n [-8, 8],\n [-9, -6],\n [5, -8]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{9}{32}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -4 & -7 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{9}{8} & \\frac{63}{32} & -\\frac{45}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -7, 5]])\nprint(a * -(9/32))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 3 & 2 & 2 & -2 \\\\\n 2 & -3 & 3 & 0 \\\\\n -2 & 0 & -1 & 0 \\\\\n 3 & 2 & 2 & -2 \\\\\n 0 & -3 & -3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.43 \\\\\n -0.04 \\\\\n -2.17 \\\\\n -0.79 \\\\\n -0.87 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.563 \\\\\n 2.934 \\\\\n 3.297 \\\\\n 5.941 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2, 2, -2],\n [2, -3, 3, 0],\n [-2, 0, -1, 0],\n [3, 2, 2, -2],\n [0, -3, -3, 3]])\nb = np.array([\n [-1.43],\n [-0.04],\n [-2.17],\n [-0.79],\n [-0.87]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -\\frac{11}{4} \\\\\n \\frac{37}{4} \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{37}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-(11/4)],\n [(37/4)],\n [7]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & 2 \\\\\n 2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2],\n [2, -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-1, 5, 2}$ to the plane $x+3 y-3 z-1=0$.", - "Output Answer": [ - "$\\frac{7}{\\sqrt{19}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -1, 5, 2\nplane = Poly(x+3*y-3*z-1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{10} & \\frac{109}{50} & -\\frac{204}{25} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{50} & \\frac{37}{5} & \\frac{947}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{57}{25} & \\frac{479}{50} & \\frac{131}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/10), (109/50), -(204/25)]])\nb = np.array([\n [-(19/50), (37/5), (947/100)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{145}{16} \\\\\n -\\frac{91}{16} \\\\\n \\frac{71}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{3}{8} \\\\\n \\frac{15}{2} \\\\\n -\\frac{73}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1877}{256} \\\\\n \\frac{11011}{256} \\\\\n \\frac{8973}{128} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(145/16)],\n [-(91/16)],\n [(71/16)]])\nb = np.array([\n [(3/8)],\n [(15/2)],\n [-(73/16)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{10} \\\\\n \\frac{23}{10} \\\\\n -\\frac{1}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{47}{10} \\\\\n \\frac{8}{5} \\\\\n -\\frac{14}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{153}{25} \\\\\n -\\frac{229}{50} \\\\\n -\\frac{1289}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/10)],\n [(23/10)],\n [-(1/5)]])\nb = np.array([\n [(47/10)],\n [(8/5)],\n [-(14/5)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{8}{5} & -\\frac{8}{5} \\\\\n \\frac{18}{5} & -\\frac{12}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{4} & \\frac{1}{6} \\\\\n -\\frac{3}{8} & -\\frac{1}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/5), -(8/5)],\n [(18/5), -(12/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{13}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-2]])\nb = np.array([\n [0],\n [-8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{28}{3} & \\frac{56}{9} & \\frac{8}{3} \\\\\n -\\frac{7}{3} & \\frac{19}{9} & -\\frac{11}{3} \\\\\n \\frac{29}{3} & -\\frac{80}{9} & -\\frac{25}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{28 x^2}{9}+\\frac{3227 x}{27}-\\frac{21844}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(28/3), (56/9), (8/3)],\n [-(7/3), (19/9), -(11/3)],\n [(29/3), -(80/9), -(25/3)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -2 & -2 \\\\\n 3 & 2 \\\\\n 3 & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -10 \\\\\n 12 \\\\\n 15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2],\n [3, 2],\n [3, 3]])\nb = np.array([\n [2],\n [3]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{77}{100} & -\\frac{177}{20} & \\frac{103}{20} \\\\\n \\frac{847}{100} & -\\frac{238}{25} & -\\frac{22}{25} \\\\\n -\\frac{9}{2} & \\frac{509}{100} & \\frac{297}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{87 x^2}{20}-\\frac{97643 x}{2000}+\\frac{451709367}{1000000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(77/100), -(177/20), (103/20)],\n [(847/100), -(238/25), -(22/25)],\n [-(9/2), (509/100), (297/50)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{e} \\\\\n -\\frac{8}{e} \\\\\n \\frac{19}{e} \\\\\n -\\frac{14}{e} \\\\\n -\\frac{3}{e} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{3}{e} \\\\\n -\\frac{7}{e} \\\\\n \\frac{3}{e} \\\\\n \\frac{16}{e} \\\\\n -\\frac{24}{e} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{90}{e^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(17/math.e)],\n [-(8/math.e)],\n [(19/math.e)],\n [-(14/math.e)],\n [-(3/math.e)]])\nb = np.array([\n [(3/math.e)],\n [-(7/math.e)],\n [(3/math.e)],\n [(16/math.e)],\n [-(24/math.e)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{11}{16} & \\frac{25}{16} & \\frac{15}{16} & \\frac{19}{16} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{21}{16} & -\\frac{43}{16} & -\\frac{29}{16} & -\\frac{27}{16} \\\\\n -\\frac{23}{16} & -\\frac{11}{8} & -\\frac{1}{8} & -\\frac{9}{8} \\\\\n -1 & -\\frac{35}{16} & -\\frac{41}{16} & \\frac{19}{16} \\\\\n \\frac{19}{8} & -\\frac{23}{16} & \\frac{19}{8} & \\frac{9}{4} \\\\\n \\frac{15}{8} & -\\frac{13}{16} & \\frac{9}{4} & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{99}{64} & -\\frac{1351}{256} & \\frac{155}{32} & \\frac{57}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/16), (25/16), (15/16), (19/16), (3/2)]])\nb = np.array([\n [(21/16), -(43/16), -(29/16), -(27/16)],\n [-(23/16), -(11/8), -(1/8), -(9/8)],\n [-1, -(35/16), -(41/16), (19/16)],\n [(19/8), -(23/16), (19/8), (9/4)],\n [(15/8), -(13/16), (9/4), (1/4)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -\\frac{2}{3} \\\\\n 0 \\\\\n 2 \\\\\n 3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{5}{3} \\\\\n \\frac{7}{3} \\\\\n -\\frac{4}{3} \\\\\n \\frac{5}{3} \\\\\n \\frac{5}{3} \\\\\n -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{91}{99},\\frac{637}{495},-\\frac{364}{495},\\frac{91}{99},\\frac{91}{99},-\\frac{91}{99}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-(2/3)],\n [0],\n [2],\n [3],\n [1]]).squeeze()\nb = np.array([\n [(5/3)],\n [(7/3)],\n [-(4/3)],\n [(5/3)],\n [(5/3)],\n [-(5/3)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{8}{7} & \\frac{17}{7} \\\\\n \\frac{16}{7} & -\\frac{16}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{7}{25} & \\frac{119}{400} \\\\\n \\frac{7}{25} & -\\frac{7}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(8/7), (17/7)],\n [(16/7), -(16/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -4 & -2 \\\\\n 6 & 2 \\\\\n -8 & 4 \\\\\n -9 & 8 \\\\\n -4 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-4, -2],\n [6, 2],\n [-8, 4],\n [-9, 8],\n [-4, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{24}{e} \\\\\n -\\frac{11}{e} \\\\\n \\frac{12}{e} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{14}{e} \\\\\n -\\frac{23}{e} \\\\\n \\frac{2}{e} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{59}{e^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(24/math.e)],\n [-(11/math.e)],\n [(12/math.e)]])\nb = np.array([\n [-(14/math.e)],\n [-(23/math.e)],\n [(2/math.e)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 9 & -8 \\\\\n 6 & -3 \\\\\n 5 & -2 \\\\\n 1 & 5 \\\\\n 1 & 7 \\\\\n -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, -8],\n [6, -3],\n [5, -2],\n [1, 5],\n [1, 7],\n [-1, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${1, -\\frac{3}{2}, 2}$ to the plane $\\frac{5 x}{2}+\\frac{9 y}{2}+5 z-\\frac{3}{2}=0$.", - "Output Answer": [ - "$\\frac{17}{2 \\sqrt{206}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 1, -(3/2), 2\nplane = Poly(((5*x)/2)+((9*y)/2)+5*z-(3/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,1,5\\}, \\{-1,-4,-3\\}, \\{3,-4,3\\}}$.", - "Output Answer": [ - "$15 x+13 y-10 z+37=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, 1, 5],\n [-1, -4, -3],\n [3, -4, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{19}{5}, -\\frac{11}{5}, -\\frac{21}{5}}$ to the plane $\\frac{7 x}{5}+\\frac{4 y}{5}-\\frac{13 z}{5}-\\frac{9}{5}=0$.", - "Output Answer": [ - "$\\frac{17}{5 \\sqrt{26}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(19/5), -(11/5), -(21/5)\nplane = Poly(((7*x)/5)+((4*y)/5)-((13*z)/5)-(9/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -3 & 1 \\\\\n 2 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-6-\\sqrt{11},\\sqrt{11}-6\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1],\n [2, -9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{66}{7} & -\\frac{55}{7} & 10 & -\\frac{67}{7} & -\\frac{24}{7} \\\\\n 9 & -\\frac{3}{7} & 3 & -\\frac{58}{7} & -\\frac{8}{7} \\\\\n \\frac{58}{7} & \\frac{69}{7} & \\frac{55}{7} & -\\frac{69}{7} & \\frac{9}{7} \\\\\n \\frac{54}{7} & \\frac{22}{7} & -\\frac{13}{7} & -\\frac{5}{7} & -\\frac{24}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(66/7), -(55/7), 10, -(67/7), -(24/7)],\n [9, -(3/7), 3, -(58/7), -(8/7)],\n [(58/7), (69/7), (55/7), -(69/7), (9/7)],\n [(54/7), (22/7), -(13/7), -(5/7), -(24/7)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n 3 & 8 & 7 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 8, 7, -5]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(3 \\sqrt{2}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [-1],\n [1],\n [1],\n [1],\n [1]]).squeeze()\nb = np.array([\n [0],\n [1],\n [0],\n [-1],\n [0],\n [0],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -2 & 4 & -7 \\\\\n -4 & 7 & -8 \\\\\n 9 & 2 & 0 \\\\\n 5 & -2 & -8 \\\\\n -2 & 6 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, 4, -7],\n [-4, 7, -8],\n [9, 2, 0],\n [5, -2, -8],\n [-2, 6, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -2 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 5 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 17 \\\\\n -29 \\\\\n -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-2],\n [-5]])\nb = np.array([\n [9],\n [5],\n [4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & 0 & 3 & 2 \\\\\n 1 & -2 & 1 & -3 \\\\\n 2 & 1 & 0 & -2 \\\\\n -2 & 1 & -2 & -1 \\\\\n 3 & 0 & -1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.27 \\\\\n 1.49 \\\\\n 2.4 \\\\\n -2.6 \\\\\n -0.8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.506 \\\\\n 0.517 \\\\\n 0.95 \\\\\n -0.49 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, 3, 2],\n [1, -2, 1, -3],\n [2, 1, 0, -2],\n [-2, 1, -2, -1],\n [3, 0, -1, 1]])\nb = np.array([\n [-0.27],\n [1.49],\n [2.4],\n [-2.6],\n [-0.8]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -1 & \\frac{5}{2} \\\\\n \\frac{9}{2} & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-9-\\sqrt{94}\\right),\\frac{1}{2} \\left(\\sqrt{94}-9\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, (5/2)],\n [(9/2), -8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -\\frac{2}{5} & -\\frac{8}{5} & \\frac{1}{5} \\\\\n \\frac{11}{5} & -\\frac{13}{5} & 2 \\\\\n \\frac{13}{5} & \\frac{9}{5} & -\\frac{4}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{5} & -\\frac{1}{5} & -\\frac{7}{5} \\\\\n \\frac{12}{5} & -\\frac{1}{5} & -\\frac{14}{5} \\\\\n \\frac{14}{5} & \\frac{7}{5} & -\\frac{4}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{16}{5} & \\frac{17}{25} & \\frac{122}{25} \\\\\n -\\frac{27}{25} & \\frac{72}{25} & \\frac{13}{5} \\\\\n \\frac{39}{25} & -2 & -\\frac{201}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/5), -(8/5), (1/5)],\n [(11/5), -(13/5), 2],\n [(13/5), (9/5), -(4/5)]])\nb = np.array([\n [-(1/5), -(1/5), -(7/5)],\n [(12/5), -(1/5), -(14/5)],\n [(14/5), (7/5), -(4/5)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -5 & -3 & 4 \\\\\n -6 & -6 & 8 \\\\\n 2 & -10 & 7 \\\\\n -4 & 0 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, -3, 4],\n [-6, -6, 8],\n [2, -10, 7],\n [-4, 0, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 10 & 2 & 4 \\\\\n 10 & -5 & -6 \\\\\n 1 & -2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-35.205,-22.176,1.\\}, \\{-0.736,4.588,1.\\}, \\{-0.309,-1.037,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 2, 4],\n [10, -5, -6],\n [1, -2, 2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & 0 \\\\\n 3 & 2 \\\\\n 3 & -2 \\\\\n 2 & 3 \\\\\n 0 & 2 \\\\\n 1 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.79 \\\\\n -1.78 \\\\\n 2.94 \\\\\n 2.7 \\\\\n -2.75 \\\\\n -1.74 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.488 \\\\\n -0.465 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0],\n [3, 2],\n [3, -2],\n [2, 3],\n [0, 2],\n [1, 0]])\nb = np.array([\n [-1.79],\n [-1.78],\n [2.94],\n [2.7],\n [-2.75],\n [-1.74]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -2 \\\\\n 3 & 2 \\\\\n -1 & -2 \\\\\n -3 & -1 \\\\\n 2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.18 \\\\\n 0.21 \\\\\n -2.4 \\\\\n -2.12 \\\\\n -0.09 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.372 \\\\\n 0.392 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2],\n [3, 2],\n [-1, -2],\n [-3, -1],\n [2, -3]])\nb = np.array([\n [-2.18],\n [0.21],\n [-2.4],\n [-2.12],\n [-0.09]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\pi \\\\\n -\\pi \\\\\n \\pi \\\\\n -3 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\pi \\\\\n -2 \\pi \\\\\n 3 \\pi \\\\\n -\\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6 \\pi ^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.pi],\n [-math.pi],\n [math.pi],\n [-3*math.pi]])\nb = np.array([\n [-2*math.pi],\n [-2*math.pi],\n [3*math.pi],\n [-math.pi]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n 3 \\\\\n \\frac{3}{2} \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{\\sqrt{70}} \\\\\n 3 \\sqrt{\\frac{2}{35}} \\\\\n \\frac{3}{\\sqrt{70}} \\\\\n -2 \\sqrt{\\frac{2}{35}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2)],\n [3],\n [(3/2)],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & 1 & 2 \\\\\n 2 & -2 & -2 \\\\\n 2 & 3 & 3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 29 & 15 & 22 \\\\\n -2 & 0 & -6 \\\\\n 38 & 25 & 39 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1, 2],\n [2, -2, -2],\n [2, 3, 3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{10}{3} & -\\frac{4}{3} & -\\frac{11}{3} \\\\\n -5 & -1 & \\frac{7}{3} \\\\\n -\\frac{14}{3} & \\frac{2}{3} & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1504}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(10/3), -(4/3), -(11/3)],\n [-5, -1, (7/3)],\n [-(14/3), (2/3), -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{1}{5}, \\frac{24}{5}, \\frac{14}{5}}$ to the plane $-\\frac{2 x}{5}-\\frac{18 y}{5}-\\frac{21 z}{5}-\\frac{18}{5}=0$.", - "Output Answer": [ - "$\\frac{818}{5 \\sqrt{769}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (1/5), (24/5), (14/5)\nplane = Poly(-((2*x)/5)-((18*y)/5)-((21*z)/5)-(18/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -3 & -2 \\\\\n 2 & 5 & 2 \\\\\n 0 & -2 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$56$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3, -2],\n [2, 5, 2],\n [0, -2, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 0 & 4 & 7 & -7 \\\\\n 2 & 6 & -2 & -5 \\\\\n -9 & 2 & -3 & 5 \\\\\n 4 & 8 & -10 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, 4, 7, -7],\n [2, 6, -2, -5],\n [-9, 2, -3, 5],\n [4, 8, -10, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{3} \\\\\n -\\frac{5}{3} \\\\\n 2 \\\\\n \\frac{2}{3} \\\\\n -3 \\\\\n \\frac{2}{3} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n \\frac{7}{3} \\\\\n -\\frac{7}{3} \\\\\n \\frac{8}{3} \\\\\n \\frac{1}{3} \\\\\n -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{17}{44},-\\frac{119}{132},\\frac{119}{132},-\\frac{34}{33},-\\frac{17}{132},\\frac{17}{66}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3)],\n [-(5/3)],\n [2],\n [(2/3)],\n [-3],\n [(2/3)]]).squeeze()\nb = np.array([\n [-1],\n [(7/3)],\n [-(7/3)],\n [(8/3)],\n [(1/3)],\n [-(2/3)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -3 & -5 & 5 \\\\\n -6 & -4 & 3 \\\\\n -9 & -6 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-8 x^2-52 x+99$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -5, 5],\n [-6, -4, 3],\n [-9, -6, -1]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{10}{3},-1,-2\\right\\}, \\left\\{-\\frac{2}{3},-\\frac{2}{3},\\frac{7}{3}\\right\\}, \\left\\{-\\frac{4}{3},3,\\frac{13}{3}\\right\\}}$.", - "Output Answer": [ - "$411 x-138 y+390 z-728=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(10/3), -1, -2],\n [-(2/3), -(2/3), (7/3)],\n [-(4/3), 3, (13/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{20}{9} & -\\frac{49}{9} & -\\frac{64}{9} \\\\\n \\frac{68}{9} & \\frac{26}{3} & \\frac{50}{9} \\\\\n -5 & 9 & \\frac{82}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{140 x^2}{9}+\\frac{134 x}{27}-\\frac{240598}{729}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/9), -(49/9), -(64/9)],\n [(68/9), (26/3), (50/9)],\n [-5, 9, (82/9)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -\\frac{16}{3} \\\\\n -2 \\\\\n -\\frac{17}{3} \\\\\n -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(16/3)],\n [-2],\n [-(17/3)],\n [-10]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4.741 \\\\\n -6.344 \\\\\n -9.235 \\\\\n -0.893 \\\\\n -6.153 \\\\\n -8.462 \\\\\n -1.573 \\\\\n -4.757 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4.341 \\\\\n 9.334 \\\\\n 5.263 \\\\\n 5.514 \\\\\n 3.934 \\\\\n -4.516 \\\\\n -2.544 \\\\\n 2.584 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-127.605$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4.741],\n [-6.344],\n [-9.235],\n [-0.893],\n [-6.153],\n [-8.462],\n [-1.573],\n [-4.757]])\nb = np.array([\n [-4.341],\n [9.334],\n [5.263],\n [5.514],\n [3.934],\n [-4.516],\n [-2.544],\n [2.584]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 8 & 4 & 9 \\\\\n 6 & -4 & -1 \\\\\n -5 & -4 & -6 \\\\\n -8 & -8 & 1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -4 & -4 & 0 \\\\\n 6 & 0 & -2 \\\\\n -8 & -3 & -5 \\\\\n -2 & 9 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 12 & 8 & 9 \\\\\n 0 & -4 & 1 \\\\\n 3 & -1 & -1 \\\\\n -6 & -17 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 4, 9],\n [6, -4, -1],\n [-5, -4, -6],\n [-8, -8, 1]])\nb = np.array([\n [-4, -4, 0],\n [6, 0, -2],\n [-8, -3, -5],\n [-2, 9, -6]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -4 \\\\\n 4 \\\\\n 7 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 4 \\\\\n -9 \\\\\n 7 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-38$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-4],\n [4],\n [7],\n [4]])\nb = np.array([\n [7],\n [4],\n [-9],\n [7],\n [7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -2 & 3 & -3 & 7 \\\\\n 4 & 7 & 7 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & \\frac{21}{13} & -\\frac{38}{13} \\\\\n 0 & 1 & \\frac{1}{13} & \\frac{5}{13} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, 3, -3, 7],\n [4, 7, 7, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\sqrt{2} \\\\\n -4 \\sqrt{2} \\\\\n -5 \\sqrt{2} \\\\\n -6 \\sqrt{2} \\\\\n 4 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\sqrt{2} \\\\\n 5 \\sqrt{2} \\\\\n \\sqrt{2} \\\\\n 4 \\sqrt{2} \\\\\n -4 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{165}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [4*math.sqrt(2)],\n [-4*math.sqrt(2)],\n [-5*math.sqrt(2)],\n [-6*math.sqrt(2)],\n [4*math.sqrt(2)]])\nb = np.array([\n [-3*math.sqrt(2)],\n [5*math.sqrt(2)],\n [math.sqrt(2)],\n [4*math.sqrt(2)],\n [-4*math.sqrt(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -\\frac{7}{6} \\\\\n \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{6}{\\sqrt{149}} \\\\\n -\\frac{7}{\\sqrt{149}} \\\\\n \\frac{8}{\\sqrt{149}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-(7/6)],\n [(4/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 5 & -7 \\\\\n 0 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-1,5\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -7],\n [0, -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -6 & -1 & -1 \\\\\n -2 & 0 & 8 \\\\\n 0 & -6 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{7.287,1.047,1.\\}, \\{0.023\\, -0.162 i,-0.023+1.152 i,1.\\}, \\{0.023\\, +0.162 i,-0.023-1.152 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -1, -1],\n [-2, 0, 8],\n [0, -6, 0]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & 1 & 2 \\\\\n -1 & -1 & -2 \\\\\n 3 & -1 & 2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -2 & 10 & 20 \\\\\n -10 & -2 & -20 \\\\\n 30 & -10 & 28 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, 2],\n [-1, -1, -2],\n [3, -1, 2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-1, \\frac{21}{5}}$ to the line $-\\frac{3 x}{10}-\\frac{11 y}{10}-\\frac{39}{10}=0$.", - "Output Answer": [ - "$\\frac{411}{5 \\sqrt{130}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -1, (21/5)\nline = Poly(-((3*x)/10)-((11*y)/10)-(39/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{4}{5} \\\\\n \\frac{8}{5} \\\\\n -\\frac{38}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{43}{5} \\\\\n -\\frac{48}{5} \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{482}{\\sqrt{2191893}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/5)],\n [(8/5)],\n [-(38/5)]]).squeeze()\nb = np.array([\n [-(43/5)],\n [-(48/5)],\n [-8]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{13}{5}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 5 & 1 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -13 & -\\frac{13}{5} & -\\frac{78}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 1, 6]])\nprint(a * -(13/5))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{25}{4} & -8 & -\\frac{29}{4} \\\\\n \\frac{13}{4} & -\\frac{15}{2} & \\frac{9}{4} \\\\\n 2 & 10 & -\\frac{7}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-10.333,-2.584-5.373 i,-2.584+5.373 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/4), -8, -(29/4)],\n [(13/4), -(15/2), (9/4)],\n [2, 10, -(7/4)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{47}{5} & \\frac{32}{5} \\\\\n \\frac{33}{5} & \\frac{43}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{33} \\left(-45-\\sqrt{3081}\\right),1\\right\\}, \\left\\{\\frac{1}{33} \\left(\\sqrt{3081}-45\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(47/5), (32/5)],\n [(33/5), (43/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{10}{3},-\\frac{8}{3},\\frac{7}{3}\\right\\}, \\left\\{3,-\\frac{2}{3},\\frac{8}{3}\\right\\}, \\left\\{4,\\frac{4}{3},\\frac{14}{3}\\right\\}}$.", - "Output Answer": [ - "$30 x+9 y-24 z-20=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(10/3), -(8/3), (7/3)],\n [3, -(2/3), (8/3)],\n [4, (4/3), (14/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{15}{16}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -7 & -6 \\\\\n 6 & -1 \\\\\n 10 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{105}{16} & \\frac{45}{8} \\\\\n -\\frac{45}{8} & \\frac{15}{16} \\\\\n -\\frac{75}{8} & \\frac{15}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -6],\n [6, -1],\n [10, -2]])\nprint(a * -(15/16))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{5,-1,1\\}, \\{0,4,-1\\}, \\{4,-1,-5\\}}$.", - "Output Answer": [ - "$30 x+28 y-5 z-117=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [5, -1, 1],\n [0, 4, -1],\n [4, -1, -5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -4 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3 \\\\\n -3 \\\\\n 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [1],\n [1]])\nb = np.array([\n [-3],\n [-4],\n [5]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & 5 \\\\\n -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{2} \\left(5-\\sqrt{5}\\right),1\\right\\}, \\left\\{\\frac{1}{2} \\left(5+\\sqrt{5}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 5],\n [-1, 3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{15}{8} \\\\\n \\frac{37}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{13}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/8)],\n [(37/8)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2} & 2 \\\\\n -10 & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1-2 i,5\\}, \\{-1+2 i,5\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), 2],\n [-10, -(9/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -7 & 2 & 7 & 1 & 3 \\\\\n -6 & 10 & 7 & 5 & 8 \\\\\n 0 & 5 & -9 & 0 & -9 \\\\\n 9 & 6 & 8 & -3 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & \\frac{3773}{5657} \\\\\n 0 & 1 & 0 & 0 & -\\frac{603}{5657} \\\\\n 0 & 0 & 1 & 0 & \\frac{5322}{5657} \\\\\n 0 & 0 & 0 & 1 & \\frac{7334}{5657} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, 2, 7, 1, 3],\n [-6, 10, 7, 5, 8],\n [0, 5, -9, 0, -9],\n [9, 6, 8, -3, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -5 & -6 & 0 & 5 \\\\\n 2 & 1 & 10 & -4 \\\\\n 0 & 2 & -10 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{51.,-40.,-5.,3.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, -6, 0, 5],\n [2, 1, 10, -4],\n [0, 2, -10, 10]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{139}{16} & \\frac{133}{16} \\\\\n -\\frac{75}{16} & -\\frac{21}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{59 x}{8}+\\frac{441}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(139/16), (133/16)],\n [-(75/16), -(21/16)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{29}{3} \\\\\n \\frac{25}{3} \\\\\n \\frac{25}{3} \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{25}{3} \\\\\n 1 \\\\\n -\\frac{22}{3} \\\\\n \\frac{19}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{\\frac{1990}{3}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/3)],\n [(25/3)],\n [(25/3)],\n [0]])\nb = np.array([\n [-(25/3)],\n [1],\n [-(22/3)],\n [(19/3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & \\frac{15}{2} \\\\\n -6 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+6 x+18$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, (15/2)],\n [-6, -9]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6.096 \\\\\n -3.094 \\\\\n 7.92 \\\\\n -2.694 \\\\\n -1.848 \\\\\n 0.392 \\\\\n 0.84 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8.506 \\\\\n 5.218 \\\\\n -2.727 \\\\\n 0.539 \\\\\n 5.546 \\\\\n -5.332 \\\\\n 0.889 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-102.639$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6.096],\n [-3.094],\n [7.92],\n [-2.694],\n [-1.848],\n [0.392],\n [0.84]])\nb = np.array([\n [8.506],\n [5.218],\n [-2.727],\n [0.539],\n [5.546],\n [-5.332],\n [0.889]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{85}{32}, \\frac{69}{32}}$ to the line $-\\frac{17 x}{4}+\\frac{93 y}{32}+\\frac{15}{32}=0$.", - "Output Answer": [ - "$\\frac{4663}{32 \\sqrt{27145}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (85/32), (69/32)\nline = Poly(-((17*x)/4)+((93*y)/32)+(15/32), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n 6 & 10 & 6 \\\\\n 0 & -8 & -7 \\\\\n 2 & -8 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 10, 6],\n [0, -8, -7],\n [2, -8, -4]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-5,5,2\\}, \\{-1,4,-5\\}, \\{4,4,-1\\}}$.", - "Output Answer": [ - "$4 x+51 y-5 (z+45)=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-5, 5, 2],\n [-1, 4, -5],\n [4, 4, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 7 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [7],\n [7]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{8} \\\\\n \\frac{1}{4} \\\\\n \\frac{9}{4} \\\\\n -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{9}{\\sqrt{413}} \\\\\n \\frac{2}{\\sqrt{413}} \\\\\n \\frac{18}{\\sqrt{413}} \\\\\n -\\frac{2}{\\sqrt{413}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/8)],\n [(1/4)],\n [(9/4)],\n [-(1/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & 7 & 3 \\\\\n -5 & 4 & -5 \\\\\n 8 & -9 & 8 \\\\\n -4 & 8 & -6 \\\\\n -9 & 7 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, 7, 3],\n [-5, 4, -5],\n [8, -9, 8],\n [-4, 8, -6],\n [-9, 7, 3]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{26}{3} & 0 & -\\frac{10}{3} \\\\\n -\\frac{16}{3} & -\\frac{26}{3} & \\frac{29}{3} \\\\\n 3 & 2 & \\frac{16}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-9.779,7.556\\, -2.497 i,7.556\\, +2.497 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/3), 0, -(10/3)],\n [-(16/3), -(26/3), (29/3)],\n [3, 2, (16/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{67}{10} & \\frac{3}{5} \\\\\n -\\frac{1}{2} & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{87 x}{10}+\\frac{137}{10}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(67/10), (3/5)],\n [-(1/2), -2]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n \\frac{6}{5} & -\\frac{7}{5} & -\\frac{9}{5} \\\\\n -2 & \\frac{7}{5} & -\\frac{9}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{1}{2} & \\frac{6}{5} & \\frac{13}{5} & -\\frac{6}{5} \\\\\n \\frac{12}{5} & -\\frac{9}{5} & -\\frac{13}{10} & -\\frac{11}{5} \\\\\n -\\frac{29}{10} & -\\frac{7}{10} & -\\frac{6}{5} & \\frac{27}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{123}{50} & \\frac{261}{50} & \\frac{71}{10} & -\\frac{161}{50} \\\\\n \\frac{379}{50} & -\\frac{183}{50} & -\\frac{243}{50} & -\\frac{277}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(6/5), -(7/5), -(9/5)],\n [-2, (7/5), -(9/5)]])\nb = np.array([\n [(1/2), (6/5), (13/5), -(6/5)],\n [(12/5), -(9/5), -(13/10), -(11/5)],\n [-(29/10), -(7/10), -(6/5), (27/10)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -1 & -3 \\\\\n 3 & 1 & 1 \\\\\n 0 & 0 & -2 \\\\\n -2 & -3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.89 \\\\\n -2.7 \\\\\n -0.59 \\\\\n -0.85 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.259 \\\\\n 1.213 \\\\\n -0.28 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, -3],\n [3, 1, 1],\n [0, 0, -2],\n [-2, -3, -2]])\nb = np.array([\n [1.89],\n [-2.7],\n [-0.59],\n [-0.85]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{0,-\\frac{5}{3}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-(5/3)]]).squeeze()\nb = np.array([\n [0],\n [(1/3)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n 0 & 1 & -6 & 2 & -5 \\\\\n -7 & 2 & -8 & 8 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, -6, 2, -5],\n [-7, 2, -8, 8, 6]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 10 & -8 \\\\\n 4 & 1 \\\\\n -1 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, -8],\n [4, 1],\n [-1, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & -2 & 3 \\\\\n 2 & 2 & -3 \\\\\n -2 & 1 & 2 \\\\\n 1 & 2 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.73 \\\\\n 1.36 \\\\\n -1.84 \\\\\n -2.08 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.506 \\\\\n -0.766 \\\\\n -0.403 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2, 3],\n [2, 2, -3],\n [-2, 1, 2],\n [1, 2, 1]])\nb = np.array([\n [1.73],\n [1.36],\n [-1.84],\n [-2.08]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n -3 & -3 \\\\\n 1 & 0 \\\\\n 1 & -2 \\\\\n 2 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 1 & 1 & -2 \\\\\n 2 & 2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 1 & -2 \\\\\n -9 & -9 & 0 \\\\\n 1 & 1 & -2 \\\\\n -3 & -3 & -6 \\\\\n 6 & 6 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 0],\n [-3, -3],\n [1, 0],\n [1, -2],\n [2, 2]])\nb = np.array([\n [1, 1, -2],\n [2, 2, 2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -7 & 4 & 5 & -7 & 7 \\\\\n 9 & -1 & 1 & 3 & 7 \\\\\n -5 & -10 & -4 & 0 & -1 \\\\\n 1 & 4 & -4 & 4 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-4016.,-886.,7181.,8855.,216.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, 4, 5, -7, 7],\n [9, -1, 1, 3, 7],\n [-5, -10, -4, 0, -1],\n [1, 4, -4, 4, 4]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 0 & -2 & -1 & -1 \\\\\n 2 & -2 & 2 & 3 \\\\\n 0 & -3 & 3 & -1 \\\\\n 0 & -1 & -1 & -1 \\\\\n 2 & 0 & 2 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1 \\\\\n -2 \\\\\n -6 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2, -1, -1],\n [2, -2, 2, 3],\n [0, -3, 3, -1],\n [0, -1, -1, -1],\n [2, 0, 2, -1]])\nb = np.array([\n [1],\n [1],\n [-1],\n [0]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & -3 & -2 & -3 & 0 \\\\\n 1 & 3 & -3 & 1 & -3 \\\\\n 1 & 1 & 3 & 3 & 0 \\\\\n -2 & 1 & -3 & -1 & 1 \\\\\n -2 & 3 & 2 & 0 & 0 \\\\\n 0 & -2 & -3 & 1 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.82 \\\\\n -0.54 \\\\\n -0.32 \\\\\n 1.75 \\\\\n 0.49 \\\\\n 1.5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.588 \\\\\n 0.025 \\\\\n -0.457 \\\\\n 1.003 \\\\\n 0.645 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -3, -2, -3, 0],\n [1, 3, -3, 1, -3],\n [1, 1, 3, 3, 0],\n [-2, 1, -3, -1, 1],\n [-2, 3, 2, 0, 0],\n [0, -2, -3, 1, -2]])\nb = np.array([\n [-2.82],\n [-0.54],\n [-0.32],\n [1.75],\n [0.49],\n [1.5]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{2} & -\\frac{3}{2} \\\\\n -3 & 1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{269}{8} & -\\frac{111}{8} \\\\\n -\\frac{111}{4} & -\\frac{5}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), -(3/2)],\n [-3, 1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 1 \\\\\n 1 \\\\\n -2 \\\\\n 1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n 1 \\\\\n -3 \\\\\n 0 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{2}{19},\\frac{4}{19},-\\frac{2}{19},\\frac{6}{19},0,\\frac{4}{19}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [1],\n [1],\n [-2],\n [1],\n [2]]).squeeze()\nb = np.array([\n [1],\n [-2],\n [1],\n [-3],\n [0],\n [-2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 2 \\\\\n -3 & 0 \\\\\n 2 & -2 \\\\\n 2 & 2 \\\\\n 0 & -1 \\\\\n 3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.59 \\\\\n -1.36 \\\\\n 0.79 \\\\\n 0.82 \\\\\n 2.57 \\\\\n 1.47 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.255 \\\\\n -0.333 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2],\n [-3, 0],\n [2, -2],\n [2, 2],\n [0, -1],\n [3, -3]])\nb = np.array([\n [-0.59],\n [-1.36],\n [0.79],\n [0.82],\n [2.57],\n [1.47]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{2} \\\\\n 8 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{7}{2} \\\\\n \\frac{3}{2} \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{\\frac{687}{2}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/2)],\n [8],\n [-10]])\nb = np.array([\n [(7/2)],\n [(3/2)],\n [(3/2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -1 & 9 \\\\\n -5 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+7 x+51$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 9],\n [-5, -6]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -8 & 2 & 6 & -10 & 0 \\\\\n -6 & -8 & 1 & -4 & 4 \\\\\n 9 & 8 & 2 & 8 & -2 \\\\\n -9 & 9 & 9 & -3 & -9 \\\\\n 0 & -4 & -10 & 6 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-8, 2, 6, -10, 0],\n [-6, -8, 1, -4, 4],\n [9, 8, 2, 8, -2],\n [-9, 9, 9, -3, -9],\n [0, -4, -10, 6, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & \\frac{9}{2} \\\\\n -4 & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{73}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), (9/2)],\n [-4, (1/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & -1 \\\\\n -4 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{8} \\left(-1-\\sqrt{17}\\right),1\\right\\}, \\left\\{\\frac{1}{8} \\left(\\sqrt{17}-1\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1],\n [-4, 2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{3}{2},-3,-3\\right\\}, \\left\\{-\\frac{7}{2},0,\\frac{3}{2}\\right\\}, \\{5,3,-2\\}}$.", - "Output Answer": [ - "$96 x-83 y+162 z+93=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(3/2), -3, -3],\n [-(7/2), 0, (3/2)],\n [5, 3, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & -8 \\\\\n 8 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{8} i \\left(\\sqrt{39}-5 i\\right),1\\right\\}, \\left\\{-\\frac{1}{8} i \\left(\\sqrt{39}+5 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -8],\n [8, -4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 4 & 2 & -2 & 3 & 6 & 5 & 0 \\\\\n 7 & -1 & 2 & 5 & 8 & 5 & -9 \\\\\n 1 & 9 & -8 & 4 & -5 & 3 & -10 \\\\\n -3 & -2 & -4 & 7 & -3 & -6 & -8 \\\\\n -1 & 9 & -8 & 2 & -5 & 6 & -7 \\\\\n 5 & -9 & 8 & -7 & 6 & 4 & 3 \\\\\n 7 & -3 & 2 & 5 & 1 & 3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, 2, -2, 3, 6, 5, 0],\n [7, -1, 2, 5, 8, 5, -9],\n [1, 9, -8, 4, -5, 3, -10],\n [-3, -2, -4, 7, -3, -6, -8],\n [-1, 9, -8, 2, -5, 6, -7],\n [5, -9, 8, -7, 6, 4, 3],\n [7, -3, 2, 5, 1, 3, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [0],\n [0],\n [1],\n [1],\n [1],\n [0]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [-1],\n [0],\n [1],\n [1],\n [-1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, -\\frac{12}{5}}$ to the line $-\\frac{12 x}{5}+\\frac{24 y}{5}+3=0$.", - "Output Answer": [ - "$\\frac{31}{20 \\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, -(12/5)\nline = Poly(-((12*x)/5)+((24*y)/5)+3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{3} & -\\frac{4}{3} \\\\\n -\\frac{14}{3} & -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{14}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/3), -(4/3)],\n [-(14/3), -(14/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 3 & -5 & -1 & 10 \\\\\n -2 & 0 & 3 & -4 \\\\\n 4 & 6 & -8 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & \\frac{28}{11} \\\\\n 0 & 1 & 0 & -\\frac{6}{11} \\\\\n 0 & 0 & 1 & \\frac{4}{11} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, -5, -1, 10],\n [-2, 0, 3, -4],\n [4, 6, -8, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 0 & 5 & -9 \\\\\n -5 & -2 & -10 \\\\\n 3 & -4 & -7 \\\\\n 8 & -7 & -2 \\\\\n 7 & 5 & 3 \\\\\n 1 & -1 & -1 \\\\\n -6 & -3 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, 5, -9],\n [-5, -2, -10],\n [3, -4, -7],\n [8, -7, -2],\n [7, 5, 3],\n [1, -1, -1],\n [-6, -3, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{19}{2} \\\\\n -\\frac{7}{4} \\\\\n -\\frac{23}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{21}{4} \\\\\n 4 \\\\\n -\\frac{21}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{515}{16} \\\\\n \\frac{315}{16} \\\\\n \\frac{755}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/2)],\n [-(7/4)],\n [-(23/4)]])\nb = np.array([\n [(21/4)],\n [4],\n [-(21/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 4 \\\\\n 1 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -9 \\\\\n 0 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$22$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [4],\n [1],\n [-5]])\nb = np.array([\n [7],\n [-9],\n [0],\n [-6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{73}{8} & -7 & \\frac{127}{16} \\\\\n -\\frac{31}{16} & \\frac{43}{16} & -\\frac{3}{2} \\\\\n \\frac{41}{16} & \\frac{25}{4} & -\\frac{145}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{11 x^2}{4}+\\frac{13703 x}{128}-\\frac{563863}{4096}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(73/8), -7, (127/16)],\n [-(31/16), (43/16), -(3/2)],\n [(41/16), (25/4), -(145/16)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -1 & -9 & 5 & -1 & 7 \\\\\n -4 & -1 & 2 & 4 & 3 \\\\\n -4 & 9 & -4 & 0 & -10 \\\\\n -2 & -8 & -6 & -1 & -7 \\\\\n -7 & 3 & 3 & -4 & -10 \\\\\n -2 & -9 & -8 & -4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-1, -9, 5, -1, 7],\n [-4, -1, 2, 4, 3],\n [-4, 9, -4, 0, -10],\n [-2, -8, -6, -1, -7],\n [-7, 3, 3, -4, -10],\n [-2, -9, -8, -4, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -10 \\\\\n -1 \\\\\n 0 \\\\\n 6 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 5 \\\\\n -2 \\\\\n 2 \\\\\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{14}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-10],\n [-1],\n [0],\n [6],\n [-8]])\nb = np.array([\n [-2],\n [5],\n [-2],\n [2],\n [2],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\pi \\\\\n -\\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\pi \\\\\n -2 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-4 \\pi ^2$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [3*math.pi],\n [-math.pi]])\nb = np.array([\n [-2*math.pi],\n [-2*math.pi]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 2 \\\\\n -10 \\\\\n 2 \\\\\n 9 \\\\\n 10 \\\\\n -3 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -3 \\\\\n -8 \\\\\n -5 \\\\\n -4 \\\\\n 6 \\\\\n -9 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{301}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [2],\n [-10],\n [2],\n [9],\n [10],\n [-3],\n [-6]])\nb = np.array([\n [-6],\n [-3],\n [-8],\n [-5],\n [-4],\n [6],\n [-9],\n [-5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 2 & \\frac{1}{2} & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & 2 \\\\\n 0 & \\frac{3}{2} \\\\\n -\\frac{1}{2} & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & \\frac{19}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, (1/2), 0]])\nb = np.array([\n [(1/2), 2],\n [0, (3/2)],\n [-(1/2), -(5/2)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & 3 & 1 & 2 \\\\\n -1 & -1 & 1 & -3 \\\\\n 1 & 3 & 0 & 2 \\\\\n -1 & 3 & -1 & 0 \\\\\n 1 & 2 & 0 & 2 \\\\\n -3 & -3 & -2 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.33 \\\\\n -1.92 \\\\\n -1.4 \\\\\n -2.58 \\\\\n -0.12 \\\\\n 0.19 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.526 \\\\\n -0.802 \\\\\n -1.199 \\\\\n -0.03 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 3, 1, 2],\n [-1, -1, 1, -3],\n [1, 3, 0, 2],\n [-1, 3, -1, 0],\n [1, 2, 0, 2],\n [-3, -3, -2, 2]])\nb = np.array([\n [-0.33],\n [-1.92],\n [-1.4],\n [-2.58],\n [-0.12],\n [0.19]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 6 \\\\\n -1 \\\\\n 3 \\\\\n 7 \\\\\n -6 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -8 \\\\\n -8 \\\\\n 10 \\\\\n -10 \\\\\n -5 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4 \\sqrt{39}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [6],\n [-1],\n [3],\n [7],\n [-6],\n [-9]])\nb = np.array([\n [-8],\n [-8],\n [-8],\n [10],\n [-10],\n [-5],\n [-3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -3 & -3 & 3 & 1 & 2 \\\\\n -2 & -1 & -1 & -1 & -2 \\\\\n 1 & 3 & 3 & 0 & -1 \\\\\n 1 & 3 & -1 & 1 & 3 \\\\\n 3 & -3 & 3 & -1 & 1 \\\\\n 1 & 2 & 0 & -2 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.92 \\\\\n -0.3 \\\\\n 2.82 \\\\\n -2.67 \\\\\n -0.76 \\\\\n -0.5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.444 \\\\\n 0.067 \\\\\n 0.315 \\\\\n 1.319 \\\\\n -1.357 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3, 3, 1, 2],\n [-2, -1, -1, -1, -2],\n [1, 3, 3, 0, -1],\n [1, 3, -1, 1, 3],\n [3, -3, 3, -1, 1],\n [1, 2, 0, -2, -1]])\nb = np.array([\n [-1.92],\n [-0.3],\n [2.82],\n [-2.67],\n [-0.76],\n [-0.5]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -2 & 2 & -1 & 1 & 2 \\\\\n 2 & -2 & -2 & -2 & 2 \\\\\n -3 & 0 & 0 & -2 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 3 \\\\\n 2 \\\\\n -2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 4 \\\\\n -12 \\\\\n 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2, -1, 1, 2],\n [2, -2, -2, -2, 2],\n [-3, 0, 0, -2, 0]])\nb = np.array([\n [-2],\n [3],\n [2],\n [-2],\n [-1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 1 & -\\frac{5}{2} & \\frac{15}{8} \\\\\n -\\frac{23}{8} & -\\frac{17}{8} & -\\frac{37}{8} \\\\\n \\frac{27}{8} & -\\frac{31}{8} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{243}{650} & -\\frac{77}{650} & \\frac{199}{650} \\\\\n -\\frac{907}{3250} & -\\frac{373}{3250} & -\\frac{49}{3250} \\\\\n \\frac{586}{1625} & -\\frac{146}{1625} & -\\frac{298}{1625} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(5/2), (15/8)],\n [-(23/8), -(17/8), -(37/8)],\n [(27/8), -(31/8), (1/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -1 & 3 \\\\\n 1 & 3 & -3 \\\\\n -3 & -2 & 3 \\\\\n -3 & 1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.26 \\\\\n 1.24 \\\\\n -1.59 \\\\\n -1.89 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.201 \\\\\n 0.59 \\\\\n 0.844 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, 3],\n [1, 3, -3],\n [-3, -2, 3],\n [-3, 1, 2]])\nb = np.array([\n [1.26],\n [1.24],\n [-1.59],\n [-1.89]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -5 & 9 & -5 \\\\\n 6 & -1 & -5 \\\\\n 8 & -6 & 1 \\\\\n -3 & -8 & -1 \\\\\n -5 & 3 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, 9, -5],\n [6, -1, -5],\n [8, -6, 1],\n [-3, -8, -1],\n [-5, 3, -9]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{21}{16} & \\frac{125}{16} \\\\\n \\frac{141}{16} & \\frac{1}{16} \\\\\n \\frac{31}{8} & -\\frac{25}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{127}{16} & -\\frac{153}{16} \\\\\n \\frac{19}{2} & \\frac{149}{16} \\\\\n -\\frac{7}{16} & \\frac{61}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{53}{8} & -\\frac{7}{4} \\\\\n \\frac{293}{16} & \\frac{75}{8} \\\\\n \\frac{55}{16} & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(21/16), (125/16)],\n [(141/16), (1/16)],\n [(31/8), -(25/8)]])\nb = np.array([\n [(127/16), -(153/16)],\n [(19/2), (149/16)],\n [-(7/16), (61/8)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-44$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [2],\n [2]])\nb = np.array([\n [-9],\n [2],\n [3]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{45}{8} & -\\frac{43}{16} & \\frac{27}{16} & \\frac{61}{16} & \\frac{43}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(45/8), -(43/16), (27/16), (61/16), (43/16)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 0 & 3 \\\\\n -10 & -6 \\\\\n 1 & -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 3 & -1 \\\\\n -9 & -5 \\\\\n 6 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 3 & 2 \\\\\n -19 & -11 \\\\\n 7 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 3],\n [-10, -6],\n [1, -7]])\nb = np.array([\n [3, -1],\n [-9, -5],\n [6, 6]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -2 \\\\\n -7 \\\\\n 8 \\\\\n -5 \\\\\n 0 \\\\\n -5 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 9 \\\\\n -2 \\\\\n -1 \\\\\n 6 \\\\\n -2 \\\\\n -10 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{582}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-2],\n [-7],\n [8],\n [-5],\n [0],\n [-5],\n [6]])\nb = np.array([\n [10],\n [9],\n [-2],\n [-1],\n [6],\n [-2],\n [-10],\n [3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & 1 & -1 \\\\\n 0 & 1 & -3 \\\\\n 0 & -2 & -3 \\\\\n 1 & 1 & -3 \\\\\n -1 & 2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.09 \\\\\n 2.13 \\\\\n -2.55 \\\\\n -2.54 \\\\\n -1.21 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.194 \\\\\n 0.542 \\\\\n 0.427 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1, -1],\n [0, 1, -3],\n [0, -2, -3],\n [1, 1, -3],\n [-1, 2, -3]])\nb = np.array([\n [1.09],\n [2.13],\n [-2.55],\n [-2.54],\n [-1.21]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -7 \\\\\n 1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 2 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -4 \\\\\n -9 \\\\\n 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-7],\n [1]])\nb = np.array([\n [8],\n [2],\n [-4]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{149}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [6]])\nb = np.array([\n [2],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -5 \\\\\n -1 \\\\\n -7 \\\\\n -5 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 10 \\\\\n 9 \\\\\n 9 \\\\\n -4 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{727}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-5],\n [-1],\n [-7],\n [-5],\n [5]])\nb = np.array([\n [3],\n [10],\n [9],\n [9],\n [-4],\n [4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 1 & \\frac{5}{2} \\\\\n -\\frac{5}{2} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{21}{4} & \\frac{25}{4} \\\\\n -\\frac{25}{4} & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, (5/2)],\n [-(5/2), (3/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{15}{7} \\\\\n 0 \\\\\n -\\frac{1}{7} \\\\\n -\\frac{2}{7} \\\\\n \\frac{8}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{5 \\sqrt{\\frac{3}{2}}}{7} \\\\\n 0 \\\\\n -\\frac{1}{7 \\sqrt{6}} \\\\\n -\\frac{\\sqrt{\\frac{2}{3}}}{7} \\\\\n \\frac{4 \\sqrt{\\frac{2}{3}}}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/7)],\n [0],\n [-(1/7)],\n [-(2/7)],\n [(8/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{6} & 2 \\\\\n -\\frac{4}{3} & \\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{6}{47} & -\\frac{36}{47} \\\\\n \\frac{24}{47} & -\\frac{3}{47} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/6), 2],\n [-(4/3), (1/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{2}{\\pi },\\frac{2}{\\pi },0\\right\\}, \\left\\{\\frac{3}{\\pi },-\\frac{5}{\\pi },-\\frac{8}{\\pi }\\right\\}, \\left\\{\\frac{9}{\\pi },\\frac{5}{\\pi },\\frac{3}{\\pi }\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{2}},\\frac{1}{\\sqrt{2}},0\\right\\}, \\left\\{\\frac{1}{\\sqrt{6}},-\\frac{1}{\\sqrt{6}},-\\sqrt{\\frac{2}{3}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}},\\frac{1}{\\sqrt{3}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((2/math.pi), (2/math.pi), 0), ((3/math.pi), -(5/math.pi), -(8/math.pi)), ((9/math.pi), (5/math.pi), (3/math.pi))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & -2 & 1 & -2 \\\\\n -3 & -2 & 3 & -2 \\\\\n 0 & 2 & 0 & -2 \\\\\n -3 & 2 & -3 & -2 \\\\\n -3 & 2 & -3 & -3 \\\\\n 0 & 3 & -3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.53 \\\\\n -1.2 \\\\\n 0.64 \\\\\n 2.74 \\\\\n -2.8 \\\\\n 1.52 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.693 \\\\\n -0.649 \\\\\n -0.557 \\\\\n -0.709 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, 1, -2],\n [-3, -2, 3, -2],\n [0, 2, 0, -2],\n [-3, 2, -3, -2],\n [-3, 2, -3, -3],\n [0, 3, -3, -2]])\nb = np.array([\n [2.53],\n [-1.2],\n [0.64],\n [2.74],\n [-2.8],\n [1.52]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${4, -4, 3}$ to the plane $3 x+3 y+5 z-1=0$.", - "Output Answer": [ - "$\\frac{14}{\\sqrt{43}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 4, -4, 3\nplane = Poly(3*x+3*y+5*z-1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -6 & -10 \\\\\n 7 & -8 \\\\\n -3 & 7 \\\\\n -9 & 4 \\\\\n 2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-6, -10],\n [7, -8],\n [-3, 7],\n [-9, 4],\n [2, -3]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{85}{32}, -\\frac{65}{16}}$ to the line $\\frac{137 x}{32}+\\frac{11 y}{4}-\\frac{3}{4}=0$.", - "Output Answer": [ - "$\\frac{563}{32 \\sqrt{26513}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (85/32), -(65/16)\nline = Poly(((137*x)/32)+((11*y)/4)-(3/4), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 2 & -3 & -1 & 2 & 2 \\\\\n 3 & -2 & 1 & -3 & 1 \\\\\n 3 & 2 & -1 & 2 & 0 \\\\\n 1 & -1 & 0 & -3 & 0 \\\\\n 2 & 2 & 3 & 0 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -1 & -1 \\\\\n 1 & -1 \\\\\n 1 & 3 \\\\\n -2 & -1 \\\\\n 1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -8 & 0 \\\\\n 3 & 7 \\\\\n -6 & -10 \\\\\n 4 & 3 \\\\\n 4 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3, -1, 2, 2],\n [3, -2, 1, -3, 1],\n [3, 2, -1, 2, 0],\n [1, -1, 0, -3, 0],\n [2, 2, 3, 0, 1]])\nb = np.array([\n [-1, -1],\n [1, -1],\n [1, 3],\n [-2, -1],\n [1, 2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -3 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1 \\\\\n -32 \\\\\n 18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-3],\n [-5]])\nb = np.array([\n [4],\n [1],\n [2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{5} \\\\\n -1 \\\\\n \\frac{7}{5} \\\\\n 1 \\\\\n -\\frac{13}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{8}{5} \\\\\n -\\frac{12}{5} \\\\\n 3 \\\\\n -\\frac{7}{5} \\\\\n \\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{8}{455},\\frac{12}{455},-\\frac{3}{91},\\frac{1}{65},-\\frac{8}{455}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/5)],\n [-1],\n [(7/5)],\n [1],\n [-(13/5)]]).squeeze()\nb = np.array([\n [(8/5)],\n [-(12/5)],\n [3],\n [-(7/5)],\n [(8/5)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 3 & -3 \\\\\n 3 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 0 & 0 & 0 & 3 & 1 \\\\\n -3 & 2 & 1 & 1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 9 & -6 & -3 & 6 & 3 \\\\\n -3 & 2 & 1 & 10 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -3],\n [3, 1]])\nb = np.array([\n [0, 0, 0, 3, 1],\n [-3, 2, 1, 1, 0]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -7 & 4 & 4 & 4 & -9 & 10 \\\\\n -7 & -9 & -4 & -10 & 6 & 9 \\\\\n 6 & -8 & -6 & 5 & 6 & 1 \\\\\n 2 & 5 & 9 & 8 & 6 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & \\frac{8157}{7675} & -\\frac{2202}{1535} \\\\\n 0 & 1 & 0 & 0 & -\\frac{13101}{7675} & -\\frac{1039}{1535} \\\\\n 0 & 0 & 1 & 0 & \\frac{2877}{1535} & -\\frac{24}{307} \\\\\n 0 & 0 & 0 & 1 & -\\frac{4278}{7675} & \\frac{1143}{1535} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, 4, 4, 4, -9, 10],\n [-7, -9, -4, -10, 6, 9],\n [6, -8, -6, 5, 6, 1],\n [2, 5, 9, 8, 6, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 7 \\\\\n -2 \\\\\n 7 \\\\\n -7 \\\\\n 6 \\\\\n -2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -3 \\\\\n -6 \\\\\n 3 \\\\\n 4 \\\\\n -5 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-93$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [7],\n [-2],\n [7],\n [-7],\n [6],\n [-2],\n [-2]])\nb = np.array([\n [9],\n [-3],\n [-6],\n [3],\n [4],\n [-5],\n [0],\n [1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{2}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 7 \\\\\n 4 & 1 \\\\\n 5 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & -\\frac{21}{2} \\\\\n -6 & -\\frac{3}{2} \\\\\n -\\frac{15}{2} & -15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 7],\n [4, 1],\n [5, 10]])\nprint(a * -(3/2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 3 & 2 \\\\\n -5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, 2],\n [-5, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -9 \\\\\n -7 \\\\\n -9 \\\\\n 0 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -1 \\\\\n -5 \\\\\n -1 \\\\\n -3 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{191}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-9],\n [-7],\n [-9],\n [0],\n [2]])\nb = np.array([\n [9],\n [-1],\n [-5],\n [-1],\n [-3],\n [7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -6 & 10 & 2 & -1 & 2 & -8 \\\\\n 4 & -3 & 3 & -9 & -8 & 10 \\\\\n 5 & 4 & -8 & -2 & -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & -\\frac{219}{115} & -\\frac{179}{115} & \\frac{214}{115} \\\\\n 0 & 1 & 0 & -\\frac{441}{460} & -\\frac{59}{115} & \\frac{14}{115} \\\\\n 0 & 0 & 1 & -\\frac{653}{460} & -\\frac{127}{115} & \\frac{112}{115} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-6, 10, 2, -1, 2, -8],\n [4, -3, 3, -9, -8, 10],\n [5, 4, -8, -2, -1, 2]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{4}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -9 & -4 \\\\\n 1 & 1 \\\\\n 9 & -10 \\\\\n -9 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{27}{4} & 3 \\\\\n -\\frac{3}{4} & -\\frac{3}{4} \\\\\n -\\frac{27}{4} & \\frac{15}{2} \\\\\n \\frac{27}{4} & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -4],\n [1, 1],\n [9, -10],\n [-9, 8]])\nprint(a * -(3/4))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 5 & \\frac{26}{3} & \\frac{13}{3} \\\\\n -3 & \\frac{20}{3} & -\\frac{25}{3} \\\\\n -\\frac{13}{3} & \\frac{25}{3} & -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -6 & -\\frac{11}{3} & \\frac{28}{3} \\\\\n -\\frac{26}{3} & 8 & 3 \\\\\n -5 & \\frac{1}{3} & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & 5 & \\frac{41}{3} \\\\\n -\\frac{35}{3} & \\frac{44}{3} & -\\frac{16}{3} \\\\\n -\\frac{28}{3} & \\frac{26}{3} & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, (26/3), (13/3)],\n [-3, (20/3), -(25/3)],\n [-(13/3), (25/3), -4]])\nb = np.array([\n [-6, -(11/3), (28/3)],\n [-(26/3), 8, 3],\n [-5, (1/3), 9]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n 4 & -9 \\\\\n 4 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -9],\n [4, 8]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -10 & 8 & -2 \\\\\n 8 & -2 & 2 \\\\\n 7 & -6 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-13.313,0.856,2.457\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 8, -2],\n [8, -2, 2],\n [7, -6, 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -1 & 0 & -3 \\\\\n -4 & -4 & -2 \\\\\n 1 & -5 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{11}{25} & -\\frac{3}{10} & \\frac{6}{25} \\\\\n -\\frac{1}{5} & 0 & -\\frac{1}{5} \\\\\n -\\frac{12}{25} & \\frac{1}{10} & -\\frac{2}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, -3],\n [-4, -4, -2],\n [1, -5, 3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 4-2 i & -3-i \\\\\n 3+3 i & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -80-160 i & -46+78 i \\\\\n 102-66 i & -48-36 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4-2j, -3- 1j],\n [3+3j, 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -5 \\\\\n 10 \\\\\n 1 \\\\\n -7 \\\\\n 0 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 5 \\\\\n -7 \\\\\n -3 \\\\\n -3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6 \\sqrt{11}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-5],\n [10],\n [1],\n [-7],\n [0],\n [8]])\nb = np.array([\n [-1],\n [0],\n [5],\n [-7],\n [-3],\n [-3],\n [-8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -4 & 0 & -9 \\\\\n 3 & 0 & 6 \\\\\n -6 & 3 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-8 x^2+56 x-9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 0, -9],\n [3, 0, 6],\n [-6, 3, -4]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & 3 \\\\\n -7 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+15 x+77$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 3],\n [-7, -8]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 4 \\\\\n -7 \\\\\n 7 \\\\\n 4 \\\\\n 4 \\\\\n 8 \\\\\n -6 \\\\\n -5 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -2 \\\\\n -7 \\\\\n -5 \\\\\n 6 \\\\\n -2 \\\\\n 0 \\\\\n 2 \\\\\n 4 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{582}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [4],\n [-7],\n [7],\n [4],\n [4],\n [8],\n [-6],\n [-5],\n [8]])\nb = np.array([\n [0],\n [-2],\n [-7],\n [-5],\n [6],\n [-2],\n [0],\n [2],\n [4],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 2 & -4 & 1 \\\\\n 0 & 7 & 6 \\\\\n 9 & -10 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+7 x^2-47 x-187$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -4, 1],\n [0, 7, 6],\n [9, -10, -2]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 1 & -5 & 5 \\\\\n 2 & -4 & -4 \\\\\n -5 & -5 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-6 x^2-20 x-288$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -5, 5],\n [2, -4, -4],\n [-5, -5, -3]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 1 & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3]])\nb = np.array([\n [-1],\n [-2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 10 & 0 & 1 & 7 \\\\\n 0 & -6 & -8 & -5 \\\\\n 10 & 6 & 0 & -8 \\\\\n -2 & 2 & -10 & 10 \\\\\n 0 & -7 & -10 & -8 \\\\\n 0 & 9 & 3 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, 0, 1, 7],\n [0, -6, -8, -5],\n [10, 6, 0, -8],\n [-2, 2, -10, 10],\n [0, -7, -10, -8],\n [0, 9, 3, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -10 & 4 \\\\\n 9 & 3 \\\\\n 4 & 7 \\\\\n 6 & -10 \\\\\n 7 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, 4],\n [9, 3],\n [4, 7],\n [6, -10],\n [7, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -8 & 2 & -5 & 1 & 10 \\\\\n 9 & 2 & -4 & 0 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.,77.,34.,0.,0.\\}, \\{2.,-9.,0.,34.,0.\\}, \\{6.,-61.,0.,0.,17.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-8, 2, -5, 1, 10],\n [9, 2, -4, 0, 4]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{1}{3},\\frac{7}{3},-\\frac{8}{3}\\right\\}, \\left\\{3,\\frac{4}{3},0\\right\\}, \\left\\{-\\frac{2}{3},0,\\frac{13}{3}\\right\\}}$.", - "Output Answer": [ - "$21 x+654 y+219 z-935=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(1/3), (7/3), -(8/3)],\n [3, (4/3), 0],\n [-(2/3), 0, (13/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{2} & -\\frac{1}{2} & -2 \\\\\n -1 & \\frac{5}{2} & \\frac{1}{2} \\\\\n 0 & -\\frac{5}{2} & 0 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{11}{4} & 3 & -\\frac{13}{4} \\\\\n -4 & \\frac{11}{2} & \\frac{13}{4} \\\\\n \\frac{5}{2} & -\\frac{25}{4} & -\\frac{5}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), -(1/2), -2],\n [-1, (5/2), (1/2)],\n [0, -(5/2), 0]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 10 & -9 & 5 \\\\\n -6 & -6 & -2 \\\\\n 6 & 4 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8.985-1.519 i,-8.985+1.519 i,13.97\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -9, 5],\n [-6, -6, -2],\n [6, 4, -8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{5} & \\frac{2}{5} \\\\\n -\\frac{13}{5} & -\\frac{14}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{16}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/5), (2/5)],\n [-(13/5), -(14/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${4, -2, \\frac{9}{2}}$ to the plane $\\frac{5 x}{2}-\\frac{9 y}{2}-z+3=0$.", - "Output Answer": [ - "$7 \\sqrt{\\frac{5}{22}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 4, -2, (9/2)\nplane = Poly(((5*x)/2)-((9*y)/2)-z+3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -9 & 5 \\\\\n 7 & -5 \\\\\n 1 & 4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 9 & -5 \\\\\n 1 & 2 \\\\\n -4 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -18 & 10 \\\\\n 6 & -7 \\\\\n 5 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 5],\n [7, -5],\n [1, 4]])\nb = np.array([\n [9, -5],\n [1, 2],\n [-4, 4]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{3} \\\\\n \\frac{10}{3} \\\\\n -\\frac{17}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{49}{6} \\\\\n -\\frac{49}{6} \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{923}{18} \\\\\n \\frac{394}{9} \\\\\n \\frac{245}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/3)],\n [(10/3)],\n [-(17/3)]])\nb = np.array([\n [-(49/6)],\n [-(49/6)],\n [-(3/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 4 & 0 & 0 \\\\\n -4 & 1 & 1 \\\\\n -2 & -5 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{4} & 0 & 0 \\\\\n -\\frac{7}{4} & -\\frac{3}{2} & -\\frac{1}{2} \\\\\n \\frac{11}{4} & \\frac{5}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 0, 0],\n [-4, 1, 1],\n [-2, -5, -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{6} \\\\\n \\frac{28}{3} \\\\\n \\frac{17}{3} \\\\\n -\\frac{59}{6} \\\\\n -\\frac{17}{6} \\\\\n \\frac{43}{6} \\\\\n \\frac{11}{6} \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{59}{6}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/6)],\n [(28/3)],\n [(17/3)],\n [-(59/6)],\n [-(17/6)],\n [(43/6)],\n [(11/6)],\n [-3]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 1 & 3 \\\\\n -2 & -3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 7 & 3 \\\\\n -2 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3],\n [-2, -3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & \\frac{3}{5} \\\\\n \\frac{4}{5} & -\\frac{17}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(-27-\\sqrt{97}\\right),\\frac{1}{10} \\left(\\sqrt{97}-27\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, (3/5)],\n [(4/5), -(17/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\pi \\\\\n -\\pi \\\\\n -3 \\pi \\\\\n -2 \\pi \\\\\n -2 \\pi \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\pi \\\\\n -\\pi \\\\\n 0 \\\\\n -2 \\pi \\\\\n 0 \\\\\n 2 \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{26} \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-2*math.pi],\n [-math.pi],\n [-3*math.pi],\n [-2*math.pi],\n [-2*math.pi],\n [0]])\nb = np.array([\n [math.pi],\n [-math.pi],\n [0],\n [-2*math.pi],\n [0],\n [2*math.pi]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{7}{2}, 4, \\frac{5}{2}}$ to the plane $4 x-\\frac{9 y}{2}-\\frac{z}{2}=0$.", - "Output Answer": [ - "$\\frac{21}{2 \\sqrt{146}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (7/2), 4, (5/2)\nplane = Poly(4*x-((9*y)/2)-(z/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{11}{3},-\\frac{11}{3},-\\frac{4}{3}\\right\\}, \\left\\{-\\frac{13}{3},-\\frac{1}{3},\\frac{1}{3}\\right\\}, \\left\\{\\frac{4}{3},-\\frac{13}{3},-4\\right\\}}$.", - "Output Answer": [ - "$70 x-59 y+146 z+235=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(11/3), -(11/3), -(4/3)],\n [-(13/3), -(1/3), (1/3)],\n [(4/3), -(13/3), -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-18$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [8]])\nb = np.array([\n [-2],\n [-4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n -3 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{14}} \\\\\n \\frac{1}{\\sqrt{14}} \\\\\n -\\frac{3}{\\sqrt{14}} \\\\\n \\frac{1}{\\sqrt{14}} \\\\\n \\frac{1}{\\sqrt{14}} \\\\\n -\\frac{1}{\\sqrt{14}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [1],\n [-3],\n [1],\n [1],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -10 \\\\\n 5 \\\\\n 1 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$26$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-10],\n [5],\n [1],\n [-5]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & 7 \\\\\n 0 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-2 x-8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 7],\n [0, 4]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -3 \\\\\n -2 \\\\\n 1 \\\\\n 1 \\\\\n 7 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{13}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-3],\n [-2],\n [1],\n [1],\n [7],\n [-7]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [5]])\nb = np.array([\n [3],\n [4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n 9 & -3 & -5 \\\\\n -2 & -3 & 9 \\\\\n 6 & -1 & -3 \\\\\n -2 & -3 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -3, -5],\n [-2, -3, 9],\n [6, -1, -3],\n [-2, -3, 7]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 1 & \\frac{49}{10} \\\\\n \\frac{3}{5} & -\\frac{49}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{5}{8} & \\frac{5}{8} \\\\\n \\frac{15}{196} & -\\frac{25}{196} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, (49/10)],\n [(3/5), -(49/10)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & -3 & 5 \\\\\n 0 & 4 & -2 \\\\\n 3 & -1 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-78$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3, 5],\n [0, 4, -2],\n [3, -1, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -5 \\\\\n 5 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 5 \\\\\n -7 \\\\\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -5 \\\\\n 0 \\\\\n -2 \\\\\n 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-5],\n [5],\n [-4]])\nb = np.array([\n [2],\n [5],\n [-7],\n [9]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{1}{2}, -3, 3}$ to the plane $-4 x+2 y+\\frac{9 z}{2}-\\frac{3}{2}=0$.", - "Output Answer": [ - "$\\frac{8}{\\sqrt{161}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (1/2), -3, 3\nplane = Poly(-4*x+2*y+((9*z)/2)-(3/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 0 & -6 & -2 & -10 \\\\\n -10 & 0 & -1 & 2 \\\\\n 0 & -2 & 9 & 8 \\\\\n 2 & 2 & -10 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, -6, -2, -10],\n [-10, 0, -1, 2],\n [0, -2, 9, 8],\n [2, 2, -10, -10]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{24}{5} & -\\frac{36}{5} \\\\\n \\frac{22}{5} & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{44} i \\left(\\sqrt{3167}-i\\right),1\\right\\}, \\left\\{-\\frac{1}{44} i \\left(\\sqrt{3167}+i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(24/5), -(36/5)],\n [(22/5), -5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{43}{5} \\\\\n \\frac{33}{5} \\\\\n \\frac{38}{5} \\\\\n \\frac{43}{5} \\\\\n -\\frac{16}{5} \\\\\n 8 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{43}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(43/5)],\n [(33/5)],\n [(38/5)],\n [(43/5)],\n [-(16/5)],\n [8],\n [-8]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n \\frac{35}{6} & 1 & -\\frac{23}{3} \\\\\n -\\frac{23}{3} & \\frac{17}{3} & -4 \\\\\n -\\frac{11}{6} & \\frac{4}{3} & \\frac{49}{6} \\\\\n \\frac{15}{2} & \\frac{5}{3} & -\\frac{28}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(35/6), 1, -(23/3)],\n [-(23/3), (17/3), -4],\n [-(11/6), (4/3), (49/6)],\n [(15/2), (5/3), -(28/3)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{9} \\\\\n \\frac{10}{3} \\\\\n -\\frac{28}{9} \\\\\n -\\frac{20}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{74}{9} \\\\\n -\\frac{14}{9} \\\\\n -2 \\\\\n \\frac{47}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{31}{3} \\\\\n \\frac{16}{9} \\\\\n -\\frac{46}{9} \\\\\n -\\frac{13}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/9)],\n [(10/3)],\n [-(28/9)],\n [-(20/3)]])\nb = np.array([\n [-(74/9)],\n [-(14/9)],\n [-2],\n [(47/9)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n -12 & -19 & 7 & -28 \\\\\n 29 & 47 & -18 & 68 \\\\\n -16 & -26 & 10 & -39 \\\\\n -19 & -31 & 12 & -45 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{35}{6} & -\\frac{32}{3} & \\frac{23}{6} & -\\frac{47}{3} \\\\\n \\frac{215}{6} & \\frac{355}{6} & -\\frac{67}{3} & \\frac{505}{6} \\\\\n -\\frac{31}{6} & -\\frac{25}{3} & \\frac{25}{6} & -\\frac{40}{3} \\\\\n -23 & -\\frac{75}{2} & \\frac{29}{2} & -\\frac{107}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [-12, -19, 7, -28],\n [29, 47, -18, 68],\n [-16, -26, 10, -39],\n [-19, -31, 12, -45]])\nprint(expm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -2 & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 1 & -2 & -2 \\\\\n 3 & -1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 7 & 1 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 3]])\nb = np.array([\n [1, -2, -2],\n [3, -1, -2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{11}{2} \\\\\n -1 \\\\\n \\frac{13}{2} \\\\\n 2 \\\\\n \\frac{9}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{2} \\\\\n -\\frac{11}{2} \\\\\n -\\frac{11}{2} \\\\\n -\\frac{11}{2} \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-32 \\sqrt{\\frac{3}{5083}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/2)],\n [-1],\n [(13/2)],\n [2],\n [(9/2)]]).squeeze()\nb = np.array([\n [-(15/2)],\n [-(11/2)],\n [-(11/2)],\n [-(11/2)],\n [-3]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{5,-2,1\\}, \\{0,1,-2\\}, \\{0,0,-2\\}}$.", - "Output Answer": [ - "$3 x-5 (z+2)=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [5, -2, 1],\n [0, 1, -2],\n [0, 0, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{4,\\frac{13}{3},-\\frac{5}{3}\\right\\}, \\left\\{\\frac{13}{3},1,\\frac{13}{3}\\right\\}, \\left\\{4,\\frac{13}{3},-\\frac{10}{3}\\right\\}}$.", - "Output Answer": [ - "$30 x+3 y-133=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, (13/3), -(5/3)],\n [(13/3), 1, (13/3)],\n [4, (13/3), -(10/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -8 & -10 & -3 \\\\\n -2 & 4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-6.,-3.,26.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-8, -10, -3],\n [-2, 4, 0]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{10}{9}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 9 & 7 \\\\\n 8 & -7 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{20}{9} & 10 & \\frac{70}{9} \\\\\n \\frac{80}{9} & -\\frac{70}{9} & -\\frac{20}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 9, 7],\n [8, -7, -2]])\nprint(a * (10/9))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & -2 \\\\\n -2 & -3 \\\\\n 2 & 1 \\\\\n -1 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.36 \\\\\n 0.1 \\\\\n -0.38 \\\\\n -1.74 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.467 \\\\\n -0.109 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2],\n [-2, -3],\n [2, 1],\n [-1, -3]])\nb = np.array([\n [2.36],\n [0.1],\n [-0.38],\n [-1.74]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{2 \\pi }{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [0],\n [-1],\n [-1],\n [0]]).squeeze()\nb = np.array([\n [0],\n [0],\n [1],\n [1],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 4 & 0 & 2 \\\\\n -9 & -1 & -6 \\\\\n 9 & -8 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-6 x^2+97 x+6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 0, 2],\n [-9, -1, -6],\n [9, -8, -9]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{25}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & 6 & 2 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{6}{25} & \\frac{18}{25} & \\frac{6}{25} & -\\frac{21}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 6, 2, -7]])\nprint(a * (3/25))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-1,-2,-3\\}, \\{-1,-1,2\\}, \\{-1,3,-3\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{14}},-\\sqrt{\\frac{2}{7}},-\\frac{3}{\\sqrt{14}}\\right\\}, \\left\\{-\\frac{17}{5 \\sqrt{42}},-2 \\sqrt{\\frac{2}{21}},\\frac{19}{5 \\sqrt{42}}\\right\\}, \\left\\{-\\frac{7}{5 \\sqrt{3}},\\frac{1}{\\sqrt{3}},-\\frac{1}{5 \\sqrt{3}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, -2, -3), (-1, -1, 2), (-1, 3, -3)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -7 & 8 & 4 \\\\\n 7 & 2 & 7 \\\\\n 0 & -2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-11.215,2.608\\, -0.831 i,2.608\\, +0.831 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 8, 4],\n [7, 2, 7],\n [0, -2, -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{ccc}\n -1 & 0 & 1 \\\\\n 0 & -1 & 0 \\\\\n 0 & 0 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{e} & 0 & \\frac{e-1}{e^2} \\\\\n 0 & \\frac{1}{e} & 0 \\\\\n 0 & 0 & \\frac{1}{e^2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [-1, 0, 1],\n [0, -1, 0],\n [0, 0, -2]])\nprint(expm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -1 & -3 & 10 & 8 & -6 & -2 \\\\\n 2 & 1 & -1 & 1 & -9 & -10 \\\\\n -10 & -6 & -5 & -4 & 9 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & \\frac{45}{23} & -\\frac{226}{23} & -\\frac{821}{69} \\\\\n 0 & 1 & 0 & -\\frac{63}{23} & \\frac{298}{23} & \\frac{1223}{69} \\\\\n 0 & 0 & 1 & \\frac{4}{23} & \\frac{53}{23} & \\frac{271}{69} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-1, -3, 10, 8, -6, -2],\n [2, 1, -1, 1, -9, -10],\n [-10, -6, -5, -4, 9, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -5 & -6 & -6 \\\\\n 9 & -3 & 8 \\\\\n 0 & 9 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, -6, -6],\n [9, -3, 8],\n [0, 9, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -6 & 0 & 4 \\\\\n 9 & -10 & -6 \\\\\n -9 & -1 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{2.,0.,3.\\}, \\{-0.876,24.449,1.\\}, \\{0.609,-0.049,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 0, 4],\n [9, -10, -6],\n [-9, -1, 6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{23}{4} & -\\frac{7}{4} \\\\\n \\frac{9}{2} & \\frac{31}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{6} \\left(-9-\\sqrt{67}\\right),1\\right\\}, \\left\\{\\frac{1}{6} \\left(\\sqrt{67}-9\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/4), -(7/4)],\n [(9/2), (31/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -2 & 6 & -3 \\\\\n 4 & -9 & 7 \\\\\n 6 & -2 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, 6, -3],\n [4, -9, 7],\n [6, -2, -4]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{4}{9} \\\\\n \\frac{37}{9} \\\\\n \\frac{16}{3} \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{5714}}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/9)],\n [(37/9)],\n [(16/3)],\n [-5]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{26}{7} & -\\frac{34}{7} \\\\\n \\frac{47}{7} & \\frac{10}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{38}{7} & \\frac{11}{7} \\\\\n -\\frac{39}{7} & -\\frac{10}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{12}{7} & -\\frac{45}{7} \\\\\n \\frac{86}{7} & \\frac{20}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/7), -(34/7)],\n [(47/7), (10/7)]])\nb = np.array([\n [(38/7), (11/7)],\n [-(39/7), -(10/7)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{26}{5} & -7 & -\\frac{43}{5} \\\\\n -2 & \\frac{7}{5} & -\\frac{23}{5} \\\\\n \\frac{4}{5} & -\\frac{37}{5} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.051,-1.23,1.\\}, \\{0.493,-1.271,1.\\}, \\{0.994,0.682,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(26/5), -7, -(43/5)],\n [-2, (7/5), -(23/5)],\n [(4/5), -(37/5), -4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,-4,-2\\}, \\{1,5,-1\\}, \\{-4,-2,0\\}}$.", - "Output Answer": [ - "$16 x-9 y+17 z+46=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, -4, -2],\n [1, 5, -1],\n [-4, -2, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{67}{9} \\\\\n -\\frac{64}{9} \\\\\n -\\frac{85}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{38}{9} \\\\\n -\\frac{58}{9} \\\\\n \\frac{5}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1750}{27} \\\\\n \\frac{3565}{81} \\\\\n \\frac{1454}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(67/9)],\n [-(64/9)],\n [-(85/9)]])\nb = np.array([\n [-(38/9)],\n [-(58/9)],\n [(5/9)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{20}{\\pi } \\\\\n \\frac{20}{\\pi } \\\\\n -\\frac{17}{\\pi } \\\\\n \\frac{14}{\\pi } \\\\\n -\\frac{2}{\\pi } \\\\\n \\frac{27}{\\pi } \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{21}{\\pi } \\\\\n -\\frac{6}{\\pi } \\\\\n -\\frac{13}{\\pi } \\\\\n \\frac{27}{\\pi } \\\\\n -\\frac{17}{\\pi } \\\\\n -\\frac{27}{\\pi } \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{204}{\\pi ^2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(20/math.pi)],\n [(20/math.pi)],\n [-(17/math.pi)],\n [(14/math.pi)],\n [-(2/math.pi)],\n [(27/math.pi)]])\nb = np.array([\n [(21/math.pi)],\n [-(6/math.pi)],\n [-(13/math.pi)],\n [(27/math.pi)],\n [-(17/math.pi)],\n [-(27/math.pi)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{\\sqrt{3}} \\\\\n \\frac{16}{\\sqrt{3}} \\\\\n \\frac{16}{\\sqrt{3}} \\\\\n -\\frac{1}{\\sqrt{3}} \\\\\n \\frac{2}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{10}{\\sqrt{3}} \\\\\n \\sqrt{3} \\\\\n \\frac{17}{\\sqrt{3}} \\\\\n -3 \\sqrt{3} \\\\\n -\\frac{14}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$157$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(17/(math.sqrt(3)))],\n [(16/(math.sqrt(3)))],\n [(16/(math.sqrt(3)))],\n [-(1/(math.sqrt(3)))],\n [(2/(math.sqrt(3)))]])\nb = np.array([\n [(10/(math.sqrt(3)))],\n [math.sqrt(3)],\n [(17/(math.sqrt(3)))],\n [-3*math.sqrt(3)],\n [-(14/(math.sqrt(3)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -4 \\\\\n 5 \\\\\n 6 \\\\\n 5 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -2 \\\\\n -6 \\\\\n -7 \\\\\n -2 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{89}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-4],\n [5],\n [6],\n [5],\n [6]])\nb = np.array([\n [-9],\n [-2],\n [-6],\n [-7],\n [-2],\n [9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{2}{3} & -\\frac{1}{3} \\\\\n -\\frac{11}{3} & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{7}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3), -(1/3)],\n [-(11/3), -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2}+4 i & -4+\\frac{9 i}{2} \\\\\n -4+\\frac{7 i}{2} & \\frac{3 i}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{27}{2}-20 i & -\\frac{123}{4}-\\frac{61 i}{4} \\\\\n -\\frac{101}{4}-\\frac{67 i}{4} & -2-32 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2)+4j, -4+((9j)/2)],\n [-4+((7j)/2), ((3j)/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -1 \\\\\n 1 & 3 \\\\\n 1 & 2 \\\\\n 1 & 3 \\\\\n 1 & 1 \\\\\n 0 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.93 \\\\\n -2.22 \\\\\n -0.33 \\\\\n 0.7 \\\\\n -2.53 \\\\\n -1. \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.388 \\\\\n 0.26 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -1],\n [1, 3],\n [1, 2],\n [1, 3],\n [1, 1],\n [0, -3]])\nb = np.array([\n [1.93],\n [-2.22],\n [-0.33],\n [0.7],\n [-2.53],\n [-1.]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(2 \\sqrt{3}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [0],\n [1],\n [-1],\n [-1],\n [1],\n [1],\n [1],\n [-1]]).squeeze()\nb = np.array([\n [0],\n [1],\n [0],\n [1],\n [1],\n [-1],\n [0],\n [1],\n [-1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{79}{9} & \\frac{76}{9} & -\\frac{11}{9} \\\\\n \\frac{23}{3} & -\\frac{34}{9} & \\frac{50}{9} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{9} & \\frac{35}{9} & -\\frac{34}{9} \\\\\n \\frac{11}{9} & \\frac{28}{3} & -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{86}{9} & \\frac{41}{9} & \\frac{23}{9} \\\\\n \\frac{58}{9} & -\\frac{118}{9} & \\frac{92}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(79/9), (76/9), -(11/9)],\n [(23/3), -(34/9), (50/9)]])\nb = np.array([\n [-(7/9), (35/9), -(34/9)],\n [(11/9), (28/3), -(14/3)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{3} \\\\\n 3 \\\\\n -\\frac{4}{3} \\\\\n -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{8}{3} \\\\\n -\\frac{5}{3} \\\\\n \\frac{7}{3} \\\\\n -\\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{116}{231},\\frac{145}{462},-\\frac{29}{66},\\frac{58}{231}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3)],\n [3],\n [-(4/3)],\n [-(7/3)]]).squeeze()\nb = np.array([\n [-(8/3)],\n [-(5/3)],\n [(7/3)],\n [-(4/3)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -9 & -4 & 9 \\\\\n -8 & 9 & -3 \\\\\n 1 & -5 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-9.923,-0.646,13.569\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -4, 9],\n [-8, 9, -3],\n [1, -5, 3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 9 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 5 \\\\\n -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -45 \\\\\n 30 \\\\\n 15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [9],\n [-9]])\nb = np.array([\n [0],\n [5],\n [-10]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 7 & 4 & -3 \\\\\n -5 & 3 & 5 \\\\\n 3 & -5 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+2 x^2+5 x-141$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 4, -3],\n [-5, 3, 5],\n [3, -5, -8]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{21}{4} & -\\frac{25}{16} & -\\frac{45}{8} \\\\\n -\\frac{65}{8} & -\\frac{29}{4} & -\\frac{153}{16} \\\\\n -\\frac{71}{16} & -\\frac{63}{8} & \\frac{31}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{69 x^2}{8}+\\frac{15787 x}{128}+\\frac{1017445}{4096}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(21/4), -(25/16), -(45/8)],\n [-(65/8), -(29/4), -(153/16)],\n [-(71/16), -(63/8), (31/8)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 4 \\\\\n -7 \\\\\n -9 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 4 \\\\\n -1 \\\\\n -5 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{485}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [4],\n [-7],\n [-9],\n [-2]])\nb = np.array([\n [9],\n [4],\n [-1],\n [-5],\n [10]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & -3 & 3 \\\\\n 3 & 1 & -2 \\\\\n 0 & -3 & 0 \\\\\n -3 & 3 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.65 \\\\\n 1.25 \\\\\n -0.41 \\\\\n 1.14 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.042 \\\\\n 0.134 \\\\\n -0.506 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, 3],\n [3, 1, -2],\n [0, -3, 0],\n [-3, 3, -1]])\nb = np.array([\n [-1.65],\n [1.25],\n [-0.41],\n [1.14]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\sqrt{3},\\frac{2}{\\sqrt{3}},\\frac{5}{\\sqrt{3}}\\right\\}, \\left\\{\\frac{4}{\\sqrt{3}},-\\frac{4}{\\sqrt{3}},\\frac{4}{\\sqrt{3}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}},-\\frac{4}{\\sqrt{3}}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{3}{\\sqrt{38}},\\sqrt{\\frac{2}{19}},\\frac{5}{\\sqrt{38}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}},\\frac{1}{\\sqrt{3}}\\right\\}, \\left\\{\\frac{\\frac{1}{3 \\sqrt{3}}-\\frac{\\sqrt{3}}{2}}{\\sqrt{\\frac{16}{27}+\\left(\\frac{\\sqrt{3}}{2}-\\frac{4}{3 \\sqrt{3}}\\right)^2+\\left(\\frac{\\sqrt{3}}{2}-\\frac{1}{3 \\sqrt{3}}\\right)^2}},-\\frac{4}{3 \\sqrt{3 \\left(\\frac{16}{27}+\\left(\\frac{\\sqrt{3}}{2}-\\frac{4}{3 \\sqrt{3}}\\right)^2+\\left(\\frac{\\sqrt{3}}{2}-\\frac{1}{3 \\sqrt{3}}\\right)^2\\right)}},\\frac{\\frac{4}{3 \\sqrt{3}}-\\frac{\\sqrt{3}}{2}}{\\sqrt{\\frac{16}{27}+\\left(\\frac{\\sqrt{3}}{2}-\\frac{4}{3 \\sqrt{3}}\\right)^2+\\left(\\frac{\\sqrt{3}}{2}-\\frac{1}{3 \\sqrt{3}}\\right)^2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-math.sqrt(3), (2/(math.sqrt(3))), (5/(math.sqrt(3)))), ((4/(math.sqrt(3))), -(4/(math.sqrt(3))), (4/(math.sqrt(3)))), (-(1/(math.sqrt(3))), -(1/(math.sqrt(3))), -(4/(math.sqrt(3))))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -2 & -\\frac{3}{2} & 0 & -\\frac{5}{2} \\\\\n 8 & \\frac{9}{2} & -\\frac{13}{2} & -\\frac{13}{2} \\\\\n \\frac{9}{2} & \\frac{11}{2} & -8 & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{15}{2} & -\\frac{7}{2} & 6 & -\\frac{1}{2} \\\\\n -\\frac{19}{2} & -9 & \\frac{19}{2} & 1 \\\\\n -\\frac{9}{2} & \\frac{11}{2} & -2 & -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{11}{2} & -5 & 6 & -3 \\\\\n -\\frac{3}{2} & -\\frac{9}{2} & 3 & -\\frac{11}{2} \\\\\n 0 & 11 & -10 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -(3/2), 0, -(5/2)],\n [8, (9/2), -(13/2), -(13/2)],\n [(9/2), (11/2), -8, (9/2)]])\nb = np.array([\n [(15/2), -(7/2), 6, -(1/2)],\n [-(19/2), -9, (19/2), 1],\n [-(9/2), (11/2), -2, -(17/2)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -6 \\\\\n 6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 7 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 6 \\\\\n -13 \\\\\n 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-6],\n [6]])\nb = np.array([\n [2],\n [7],\n [-5]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 8 & 5 \\\\\n -3 & -7 \\\\\n -7 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, 5],\n [-3, -7],\n [-7, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & -10 & -4 \\\\\n 1 & -6 & 9 \\\\\n 3 & 2 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.111,-2.639,1.\\}, \\{-0.241-2.01 i,0.763\\, +0.229 i,1.\\}, \\{-0.241+2.01 i,0.763\\, -0.229 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -10, -4],\n [1, -6, 9],\n [3, 2, 3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{3}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & -4 & -10 & 4 \\\\\n 3 & -9 & 10 & -9 \\\\\n 6 & -1 & 2 & 6 \\\\\n 2 & -7 & -5 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -1 & -\\frac{4}{3} & -\\frac{10}{3} & \\frac{4}{3} \\\\\n 1 & -3 & \\frac{10}{3} & -3 \\\\\n 2 & -\\frac{1}{3} & \\frac{2}{3} & 2 \\\\\n \\frac{2}{3} & -\\frac{7}{3} & -\\frac{5}{3} & \\frac{10}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -4, -10, 4],\n [3, -9, 10, -9],\n [6, -1, 2, 6],\n [2, -7, -5, 10]])\nprint(a * (1/3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{3}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{40}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{120}{49}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/7)]])\nb = np.array([\n [(40/7)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{21}{5}, \\frac{6}{5}}$ to the line $\\frac{2 x}{5}-\\frac{18 y}{5}+\\frac{21}{10}=0$.", - "Output Answer": [ - "$\\frac{39}{4 \\sqrt{82}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(21/5), (6/5)\nline = Poly(((2*x)/5)-((18*y)/5)+(21/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{19}{2} & 1 & \\frac{9}{2} \\\\\n \\frac{1}{2} & \\frac{17}{2} & 8 \\\\\n \\frac{13}{2} & 3 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8.804,7.943,12.861\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/2), 1, (9/2)],\n [(1/2), (17/2), 8],\n [(13/2), 3, -6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-2$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 8 & -9 \\\\\n -8 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -16 & 18 \\\\\n 16 & 16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -9],\n [-8, -8]])\nprint(a * -2)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{29}{5} & -\\frac{21}{5} & -\\frac{11}{5} \\\\\n -\\frac{38}{5} & \\frac{37}{5} & \\frac{19}{5} \\\\\n -\\frac{46}{5} & \\frac{32}{5} & -\\frac{1}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.668,-3.673,1.\\}, \\{-0.797,1.262,1.\\}, \\{0.116,-0.279,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/5), -(21/5), -(11/5)],\n [-(38/5), (37/5), (19/5)],\n [-(46/5), (32/5), -(1/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{2} & 2 & 5 \\\\\n \\frac{13}{4} & -\\frac{25}{4} & -\\frac{19}{4} \\\\\n \\frac{35}{4} & -\\frac{17}{4} & -\\frac{23}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{35 x^2}{2}-\\frac{63 x}{2}+72$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/2), 2, 5],\n [(13/4), -(25/4), -(19/4)],\n [(35/4), -(17/4), -(23/4)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n 0 & -4 & -9 \\\\\n -5 & 2 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -4, -9],\n [-5, 2, -6]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 1 & 2 & -2 \\\\\n -2 & -2 & 3 \\\\\n -2 & -3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{3} & -\\frac{2}{3} & -\\frac{2}{3} \\\\\n \\frac{2}{3} & \\frac{2}{3} & -\\frac{1}{3} \\\\\n -\\frac{2}{3} & \\frac{1}{3} & -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, -2],\n [-2, -2, 3],\n [-2, -3, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{18}{5} & -4 & -\\frac{17}{5} \\\\\n -2 & 0 & \\frac{21}{5} \\\\\n -\\frac{6}{5} & \\frac{12}{5} & -\\frac{19}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{12896}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(18/5), -4, -(17/5)],\n [-2, 0, (21/5)],\n [-(6/5), (12/5), -(19/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 1 & \\frac{19}{7} & \\frac{4}{7} \\\\\n \\frac{32}{7} & \\frac{33}{7} & \\frac{24}{7} \\\\\n -\\frac{23}{7} & \\frac{10}{7} & -\\frac{8}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{294}{403} & -\\frac{112}{403} & -\\frac{189}{403} \\\\\n \\frac{518}{1209} & -\\frac{21}{403} & \\frac{70}{1209} \\\\\n -\\frac{581}{372} & \\frac{91}{124} & \\frac{203}{372} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, (19/7), (4/7)],\n [(32/7), (33/7), (24/7)],\n [-(23/7), (10/7), -(8/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 4 & 4 & 6 \\\\\n -7 & 2 & -6 \\\\\n -2 & -9 & -6 \\\\\n -9 & -4 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, 4, 6],\n [-7, 2, -6],\n [-2, -9, -6],\n [-9, -4, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 7 & -6 & -5 & 10 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-10.,0.,0.,7.,0.\\}, \\{0.,0.,0.,0.,1.\\}, \\{5.,0.,7.,0.,0.\\}, \\{6.,7.,0.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, -6, -5, 10, 0]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & -4 & -6 \\\\\n 0 & 3 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{5.,1.,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, -4, -6],\n [0, 3, -3]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\pi \\\\\n 0 \\\\\n -\\pi \\\\\n -2 \\pi \\\\\n -\\pi \\\\\n 2 \\pi \\\\\n \\pi \\\\\n -2 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\pi \\\\\n \\pi \\\\\n \\pi \\\\\n \\pi \\\\\n -2 \\pi \\\\\n -2 \\pi \\\\\n \\pi \\\\\n \\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7 \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [2*math.pi],\n [0],\n [-math.pi],\n [-2*math.pi],\n [-math.pi],\n [2*math.pi],\n [math.pi],\n [-2*math.pi]])\nb = np.array([\n [-math.pi],\n [math.pi],\n [math.pi],\n [math.pi],\n [-2*math.pi],\n [-2*math.pi],\n [math.pi],\n [math.pi]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -6 & -\\frac{19}{2} & \\frac{9}{2} \\\\\n 8 & \\frac{9}{2} & -\\frac{15}{2} \\\\\n -9 & -\\frac{15}{2} & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{0.359\\, -3.54 i,0.359\\, +3.54 i,7.781\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -(19/2), (9/2)],\n [8, (9/2), -(15/2)],\n [-9, -(15/2), 10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 6 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 7 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -32 \\\\\n 100 \\\\\n -103 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [6],\n [8]])\nb = np.array([\n [9],\n [7],\n [4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{16}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 7 & -1 & 3 & -1 \\\\\n 9 & 10 & 8 & 8 \\\\\n 6 & -2 & -10 & 9 \\\\\n 0 & 8 & 6 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{7}{16} & -\\frac{1}{16} & \\frac{3}{16} & -\\frac{1}{16} \\\\\n \\frac{9}{16} & \\frac{5}{8} & \\frac{1}{2} & \\frac{1}{2} \\\\\n \\frac{3}{8} & -\\frac{1}{8} & -\\frac{5}{8} & \\frac{9}{16} \\\\\n 0 & \\frac{1}{2} & \\frac{3}{8} & -\\frac{3}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -1, 3, -1],\n [9, 10, 8, 8],\n [6, -2, -10, 9],\n [0, 8, 6, -3]])\nprint(a * (1/16))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n \\frac{15}{2} \\\\\n \\frac{3}{2} \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -7 \\\\\n -4 \\\\\n \\frac{13}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{164 \\sqrt{\\frac{2}{295}}}{25}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [(15/2)],\n [(3/2)],\n [5]]).squeeze()\nb = np.array([\n [-7],\n [-7],\n [-4],\n [(13/2)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(\\sqrt{42}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [0],\n [-1],\n [1],\n [0],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [-1],\n [-1],\n [1],\n [1],\n [1],\n [1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{3}{2},\\frac{3}{2},0\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [0],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [0]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -e \\\\\n -e \\\\\n -4 e \\\\\n 3 e \\\\\n -3 e \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n e \\\\\n 2 e \\\\\n -e \\\\\n 3 e \\\\\n e \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{38} e$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-math.e],\n [-math.e],\n [-4*math.e],\n [3*math.e],\n [-3*math.e]])\nb = np.array([\n [math.e],\n [2*math.e],\n [-math.e],\n [3*math.e],\n [math.e]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\sqrt{2} \\\\\n -6 \\sqrt{2} \\\\\n 6 \\sqrt{2} \\\\\n -2 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\sqrt{2} \\\\\n 0 \\\\\n 5 \\sqrt{2} \\\\\n \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{334}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [6*math.sqrt(2)],\n [-6*math.sqrt(2)],\n [6*math.sqrt(2)],\n [-2*math.sqrt(2)]])\nb = np.array([\n [-5*math.sqrt(2)],\n [0],\n [5*math.sqrt(2)],\n [math.sqrt(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -1 & 8 & -3 \\\\\n 6 & -9 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & \\frac{7}{13} \\\\\n 0 & 1 & -\\frac{4}{13} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-1, 8, -3],\n [6, -9, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{48}{5} \\\\\n -3 \\\\\n -7 \\\\\n \\frac{19}{5} \\\\\n \\frac{19}{5} \\\\\n -\\frac{18}{5} \\\\\n 9 \\\\\n \\frac{11}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{6946}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(48/5)],\n [-3],\n [-7],\n [(19/5)],\n [(19/5)],\n [-(18/5)],\n [9],\n [(11/5)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{23}{8} \\\\\n \\frac{5}{8} \\\\\n -\\frac{21}{8} \\\\\n \\frac{9}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{23}{\\sqrt{1319}} \\\\\n \\frac{5}{\\sqrt{1319}} \\\\\n -\\frac{21}{\\sqrt{1319}} \\\\\n \\frac{18}{\\sqrt{1319}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/8)],\n [(5/8)],\n [-(21/8)],\n [(9/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -1 & -7 \\\\\n 0 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-5,-1\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -7],\n [0, -5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 8 & 3 \\\\\n -8 & -6 \\\\\n -3 & 9 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 2 & -5 \\\\\n -5 & -1 \\\\\n 9 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 6 & 8 \\\\\n -3 & -5 \\\\\n -12 & 14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 3],\n [-8, -6],\n [-3, 9]])\nb = np.array([\n [2, -5],\n [-5, -1],\n [9, -5]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -10 & -2 \\\\\n 9 & 5 \\\\\n 0 & 4 \\\\\n 8 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, -2],\n [9, 5],\n [0, 4],\n [8, 2]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{4}{5} & \\frac{2}{5} \\\\\n -\\frac{3}{5} & -\\frac{43}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{6} \\left(-39-\\sqrt{1497}\\right),1\\right\\}, \\left\\{\\frac{1}{6} \\left(\\sqrt{1497}-39\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/5), (2/5)],\n [-(3/5), -(43/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 2 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2]])\nb = np.array([\n [1],\n [1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -9 & -2 \\\\\n 8 & 4 \\\\\n -1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-9, -2],\n [8, 4],\n [-1, 0]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 0 & \\frac{5}{3} & 0 & -\\frac{5}{2} & -\\frac{4}{3} \\\\\n \\frac{8}{3} & -\\frac{13}{6} & -\\frac{3}{2} & 1 & -\\frac{1}{6} \\\\\n -\\frac{3}{2} & 0 & -3 & \\frac{8}{3} & -\\frac{11}{6} \\\\\n -\\frac{5}{6} & -\\frac{3}{2} & -2 & \\frac{1}{6} & -\\frac{2}{3} \\\\\n 2 & -\\frac{7}{3} & \\frac{1}{2} & -\\frac{5}{3} & -\\frac{4}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{13}{6} & 3 & -\\frac{11}{6} & -\\frac{7}{6} \\\\\n -\\frac{11}{6} & \\frac{7}{3} & -\\frac{8}{3} & \\frac{4}{3} \\\\\n \\frac{5}{2} & \\frac{4}{3} & 2 & -2 \\\\\n \\frac{5}{6} & -\\frac{1}{3} & \\frac{17}{6} & \\frac{5}{2} \\\\\n \\frac{5}{2} & -3 & \\frac{1}{3} & \\frac{13}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{305}{36} & \\frac{157}{18} & -\\frac{431}{36} & -\\frac{83}{12} \\\\\n -\\frac{185}{36} & \\frac{10}{9} & \\frac{2}{3} & -\\frac{31}{36} \\\\\n -\\frac{119}{18} & -\\frac{35}{9} & \\frac{133}{36} & \\frac{94}{9} \\\\\n -\\frac{71}{36} & -\\frac{121}{18} & \\frac{16}{9} & \\frac{35}{18} \\\\\n -\\frac{127}{36} & \\frac{52}{9} & -\\frac{29}{18} & -\\frac{27}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, (5/3), 0, -(5/2), -(4/3)],\n [(8/3), -(13/6), -(3/2), 1, -(1/6)],\n [-(3/2), 0, -3, (8/3), -(11/6)],\n [-(5/6), -(3/2), -2, (1/6), -(2/3)],\n [2, -(7/3), (1/2), -(5/3), -(4/3)]])\nb = np.array([\n [-(13/6), 3, -(11/6), -(7/6)],\n [-(11/6), (7/3), -(8/3), (4/3)],\n [(5/2), (4/3), 2, -2],\n [(5/6), -(1/3), (17/6), (5/2)],\n [(5/2), -3, (1/3), (13/6)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [1],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 2 & 1 & 7 & -8 & 5 \\\\\n -8 & 3 & 10 & -9 & -3 \\\\\n -4 & 7 & 6 & 9 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & \\frac{35}{202} & \\frac{433}{404} \\\\\n 0 & 1 & 0 & \\frac{277}{101} & \\frac{96}{101} \\\\\n 0 & 0 & 1 & -\\frac{160}{101} & \\frac{55}{202} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, 1, 7, -8, 5],\n [-8, 3, 10, -9, -3],\n [-4, 7, 6, 9, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\sqrt{2} \\\\\n -7 \\sqrt{2} \\\\\n 5 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\sqrt{2} \\\\\n -5 \\sqrt{2} \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{19}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.sqrt(2)],\n [-7*math.sqrt(2)],\n [5*math.sqrt(2)]])\nb = np.array([\n [-2*math.sqrt(2)],\n [-5*math.sqrt(2)],\n [0]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\sqrt{3} \\\\\n 0 \\\\\n \\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n 5 \\sqrt{3} \\\\\n 5 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\sqrt{3} \\\\\n -2 \\sqrt{3} \\\\\n -4 \\sqrt{3} \\\\\n 5 \\sqrt{3} \\\\\n 0 \\\\\n -2 \\sqrt{3} \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-42$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [5*math.sqrt(3)],\n [0],\n [math.sqrt(3)],\n [-2*math.sqrt(3)],\n [-2*math.sqrt(3)],\n [5*math.sqrt(3)],\n [5*math.sqrt(3)]])\nb = np.array([\n [2*math.sqrt(3)],\n [-2*math.sqrt(3)],\n [-4*math.sqrt(3)],\n [5*math.sqrt(3)],\n [0],\n [-2*math.sqrt(3)],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1.796 \\\\\n 7.281 \\\\\n -5.962 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7.942 \\\\\n -0.266 \\\\\n 9.601 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-73.4417$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1.796],\n [7.281],\n [-5.962]])\nb = np.array([\n [7.942],\n [-0.266],\n [9.601]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & -9 \\\\\n 0 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-36$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -9],\n [0, 6]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -3 & -4 & -9 \\\\\n 3 & 5 & -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 3 & -8 & -2 \\\\\n 2 & 3 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & -12 & -11 \\\\\n 5 & 8 & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -4, -9],\n [3, 5, -9]])\nb = np.array([\n [3, -8, -2],\n [2, 3, 0]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 0 & -2 & -2 & 1 & -1 \\\\\n 2 & -1 & -1 & 0 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 3 & 0 & -1 & 3 & 2 \\\\\n -1 & 2 & -1 & 2 & -1 \\\\\n 2 & -3 & 0 & 2 & 3 \\\\\n 1 & 2 & -1 & -2 & -1 \\\\\n 0 & -3 & 1 & -3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -1 & 7 & 0 & -7 & -3 \\\\\n 5 & -5 & 1 & -4 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2, -2, 1, -1],\n [2, -1, -1, 0, 2]])\nb = np.array([\n [3, 0, -1, 3, 2],\n [-1, 2, -1, 2, -1],\n [2, -3, 0, 2, 3],\n [1, 2, -1, -2, -1],\n [0, -3, 1, -3, -2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{6} & \\frac{17}{6} & \\frac{10}{3} \\\\\n \\frac{5}{6} & -\\frac{14}{3} & 1 \\\\\n \\frac{4}{3} & \\frac{1}{2} & -\\frac{13}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{2076}{2203} & \\frac{1686}{2203} & \\frac{3972}{2203} \\\\\n \\frac{678}{2203} & \\frac{54}{2203} & \\frac{1068}{2203} \\\\\n \\frac{1434}{2203} & \\frac{1050}{2203} & \\frac{1674}{2203} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/6), (17/6), (10/3)],\n [(5/6), -(14/3), 1],\n [(4/3), (1/2), -(13/6)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 9 \\\\\n 8 \\\\\n -8 \\\\\n 9 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 9 \\\\\n 7 \\\\\n -8 \\\\\n 1 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$132$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [9],\n [8],\n [-8],\n [9],\n [5]])\nb = np.array([\n [6],\n [9],\n [7],\n [-8],\n [1],\n [-6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 3 & -1 & -1 \\\\\n 0 & 3 & -1 \\\\\n 1 & 1 & -1 \\\\\n 2 & -2 & -2 \\\\\n 0 & -1 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -1 & 2 & 0 & 1 \\\\\n -1 & -1 & -2 & 0 \\\\\n 1 & 0 & 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -3 & 7 & 2 & 1 \\\\\n -4 & -3 & -6 & -2 \\\\\n -3 & 1 & -2 & -1 \\\\\n -2 & 6 & 4 & -2 \\\\\n 2 & 1 & 2 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, -1],\n [0, 3, -1],\n [1, 1, -1],\n [2, -2, -2],\n [0, -1, 1]])\nb = np.array([\n [-1, 2, 0, 1],\n [-1, -1, -2, 0],\n [1, 0, 0, 2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & -1 & -7 \\\\\n -8 & 0 & -9 \\\\\n -9 & -1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.975,-0.201,1.\\}, \\{0.383,-7.964,1.\\}, \\{0.795,1.337,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, -7],\n [-8, 0, -9],\n [-9, -1, -3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, 0, -1}$ to the plane $-\\frac{4 x}{3}-\\frac{14 y}{3}-\\frac{8 z}{3}-\\frac{1}{3}=0$.", - "Output Answer": [ - "$\\frac{19}{2 \\sqrt{69}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, 0, -1\nplane = Poly(-((4*x)/3)-((14*y)/3)-((8*z)/3)-(1/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 3 \\\\\n 0 \\\\\n 1 \\\\\n -3 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -2 \\\\\n 0 \\\\\n -1 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{0,\\frac{16}{7},0,\\frac{8}{7},-\\frac{24}{7}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [3],\n [0],\n [1],\n [-3]]).squeeze()\nb = np.array([\n [0],\n [-2],\n [0],\n [-1],\n [3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -\\frac{7}{4} \\\\\n \\frac{11}{4} \\\\\n 3 \\\\\n \\frac{1}{4} \\\\\n \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{12}{\\sqrt{559}} \\\\\n -\\frac{7}{\\sqrt{559}} \\\\\n \\frac{11}{\\sqrt{559}} \\\\\n \\frac{12}{\\sqrt{559}} \\\\\n \\frac{1}{\\sqrt{559}} \\\\\n \\frac{10}{\\sqrt{559}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-(7/4)],\n [(11/4)],\n [3],\n [(1/4)],\n [(5/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & -\\frac{1}{2} \\\\\n 2 & 0 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{3}{4} & -\\frac{1}{4} \\\\\n 1 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), -(1/2)],\n [2, 0]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & 4 & 3 \\\\\n 1 & 4 & 1 \\\\\n 3 & -4 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 4, 3],\n [1, 4, 1],\n [3, -4, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -4 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 0 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -32 \\\\\n -112 \\\\\n -32 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-4],\n [4]])\nb = np.array([\n [-8],\n [0],\n [8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -2 & -2 & 3 & 0 & 0 \\\\\n -3 & -1 & -1 & 1 & -3 \\\\\n 1 & 0 & -2 & 2 & 2 \\\\\n 3 & 3 & 0 & -3 & -2 \\\\\n 2 & -1 & 0 & -1 & 3 \\\\\n 3 & 2 & -3 & 2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.04 \\\\\n -2.05 \\\\\n 0.76 \\\\\n -2.12 \\\\\n 1.15 \\\\\n -2.59 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.106 \\\\\n 0.186 \\\\\n 0.699 \\\\\n 0.394 \\\\\n 0.648 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2, 3, 0, 0],\n [-3, -1, -1, 1, -3],\n [1, 0, -2, 2, 2],\n [3, 3, 0, -3, -2],\n [2, -1, 0, -1, 3],\n [3, 2, -3, 2, -2]])\nb = np.array([\n [2.04],\n [-2.05],\n [0.76],\n [-2.12],\n [1.15],\n [-2.59]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{27}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{27}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(27/4)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 6 & 4 & -3 & 9 \\\\\n 2 & 6 & -5 & 0 \\\\\n -8 & 3 & 8 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & \\frac{193}{104} \\\\\n 0 & 1 & 0 & \\frac{3}{13} \\\\\n 0 & 0 & 1 & \\frac{53}{52} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, 4, -3, 9],\n [2, 6, -5, 0],\n [-8, 3, 8, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 12 \\\\\n -12 \\\\\n 36 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-3],\n [-2]])\nb = np.array([\n [9],\n [3],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{cccc}\n 4 & 1 & -3 & 1 \\\\\n 6 & 2 & -4 & 1 \\\\\n 5 & 4 & -4 & 3 \\\\\n -9 & -4 & 6 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{10}{3} & -\\frac{7}{3} & -\\frac{5}{3} & -1 \\\\\n \\frac{59}{6} & -\\frac{17}{6} & -\\frac{37}{6} & -\\frac{5}{2} \\\\\n \\frac{5}{2} & -1 & -1 & 0 \\\\\n -\\frac{47}{3} & \\frac{31}{6} & \\frac{59}{6} & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [4, 1, -3, 1],\n [6, 2, -4, 1],\n [5, 4, -4, 3],\n [-9, -4, 6, -2]])\nprint(expm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{23}{10} \\\\\n -\\frac{29}{10} \\\\\n \\frac{9}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{23}{\\sqrt{1451}} \\\\\n -\\frac{29}{\\sqrt{1451}} \\\\\n \\frac{9}{\\sqrt{1451}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/10)],\n [-(29/10)],\n [(9/10)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{2}{e},-\\frac{1}{e},-\\frac{7}{e}\\right\\}, \\left\\{\\frac{4}{e},0,-\\frac{1}{e}\\right\\}, \\left\\{-\\frac{1}{e},\\frac{2}{e},-\\frac{3}{e}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{\\sqrt{\\frac{2}{3}}}{3},-\\frac{1}{3 \\sqrt{6}},-\\frac{7}{3 \\sqrt{6}}\\right\\}, \\left\\{\\frac{31 \\sqrt{\\frac{2}{231}}}{3},\\frac{5}{3 \\sqrt{462}},\\frac{17}{3 \\sqrt{462}}\\right\\}, \\left\\{-\\frac{1}{3 \\sqrt{77}},\\frac{26}{3 \\sqrt{77}},-\\frac{4}{3 \\sqrt{77}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((2/math.e), -(1/math.e), -(7/math.e)), ((4/math.e), 0, -(1/math.e)), (-(1/math.e), (2/math.e), -(3/math.e))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 0 \\\\\n 3 \\\\\n -6 \\\\\n -5 \\\\\n 3 \\\\\n 4 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 1 \\\\\n 6 \\\\\n 5 \\\\\n 2 \\\\\n 6 \\\\\n -4 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-50$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [0],\n [3],\n [-6],\n [-5],\n [3],\n [4],\n [-3]])\nb = np.array([\n [-2],\n [1],\n [6],\n [5],\n [2],\n [6],\n [-4],\n [6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -8 & -3 & 2 \\\\\n 4 & -7 & 1 \\\\\n 0 & 3 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-8, -3, 2],\n [4, -7, 1],\n [0, 3, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & -3 & -1 \\\\\n 2 & -2 & -2 \\\\\n -3 & 1 & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & -1 & 5 \\\\\n 6 & -4 & 4 \\\\\n -1 & 6 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3, -1],\n [2, -2, -2],\n [-3, 1, -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{ccc}\n 3 & -2 & 1 \\\\\n 5 & -3 & 2 \\\\\n -1 & 1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 3 & -\\frac{3}{2} & \\frac{1}{2} \\\\\n 4 & -\\frac{3}{2} & \\frac{3}{2} \\\\\n 0 & \\frac{1}{2} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [3, -2, 1],\n [5, -3, 2],\n [-1, 1, 0]])\nprint(expm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${2, 5, -2}$ to the plane $3 x+2 z+4=0$.", - "Output Answer": [ - "$\\frac{6}{\\sqrt{13}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 2, 5, -2\nplane = Poly(3*x+2*z+4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{10} \\\\\n -\\frac{1}{2} \\\\\n \\frac{33}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{91}{10} \\\\\n \\frac{32}{5} \\\\\n -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3849}{100} \\\\\n -\\frac{5481}{100} \\\\\n -\\frac{7}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/10)],\n [-(1/2)],\n [(33/5)]])\nb = np.array([\n [-(91/10)],\n [(32/5)],\n [-(15/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{49}{5} & -\\frac{44}{5} & \\frac{4}{5} \\\\\n \\frac{1}{5} & 3 & \\frac{31}{5} \\\\\n 0 & -\\frac{43}{5} & -\\frac{21}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-0.511-6.348 i,-0.511+6.348 i,9.623\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(49/5), -(44/5), (4/5)],\n [(1/5), 3, (31/5)],\n [0, -(43/5), -(21/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -2 & 10 \\\\\n 3 & -9 \\\\\n 9 & -5 \\\\\n 4 & 1 \\\\\n 7 & 1 \\\\\n 6 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, 10],\n [3, -9],\n [9, -5],\n [4, 1],\n [7, 1],\n [6, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{62}{7} \\\\\n -\\frac{60}{7} \\\\\n -\\frac{33}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -\\frac{69}{7} \\\\\n \\frac{25}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3777}{49} \\\\\n \\frac{857}{49} \\\\\n \\frac{5538}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(62/7)],\n [-(60/7)],\n [-(33/7)]])\nb = np.array([\n [3],\n [-(69/7)],\n [(25/7)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{7}{2},1,-4\\right\\}, \\left\\{3,2,\\frac{3}{2}\\right\\}, \\left\\{-3,-\\frac{9}{2},2\\right\\}}$.", - "Output Answer": [ - "$2 x-2 (y+z)+1=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(7/2), 1, -4],\n [3, 2, (3/2)],\n [-3, -(9/2), 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-3,-2,2\\}, \\{0,-1,3\\}, \\{-1,0,1\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{3}{\\sqrt{17}},-\\frac{2}{\\sqrt{17}},\\frac{2}{\\sqrt{17}}\\right\\}, \\left\\{12 \\sqrt{\\frac{2}{901}},-\\frac{1}{\\sqrt{1802}},\\frac{35}{\\sqrt{1802}}\\right\\}, \\left\\{-2 \\sqrt{\\frac{2}{53}},\\frac{9}{\\sqrt{106}},\\frac{3}{\\sqrt{106}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-3, -2, 2), (0, -1, 3), (-1, 0, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{719}{100} \\\\\n \\frac{15}{2} \\\\\n \\frac{102}{25} \\\\\n \\frac{183}{50} \\\\\n \\frac{16}{5} \\\\\n -\\frac{339}{100} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1451}{50}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(719/100)],\n [(15/2)],\n [(102/25)],\n [(183/50)],\n [(16/5)],\n [-(339/100)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & 7 \\\\\n 5 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{5-2 \\sqrt{15},5+2 \\sqrt{15}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 7],\n [5, 10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{5,-\\frac{7}{2},\\frac{7}{2}\\right\\}, \\left\\{0,-\\frac{3}{2},-3\\right\\}, \\left\\{-2,3,\\frac{3}{2}\\right\\}}$.", - "Output Answer": [ - "$153 x+142 y-74 z-9=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [5, -(7/2), (7/2)],\n [0, -(3/2), -3],\n [-2, 3, (3/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{16}{3} \\\\\n -\\frac{47}{6} \\\\\n \\frac{23}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{16}{3} \\\\\n \\frac{47}{6} \\\\\n \\frac{5}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{799}{12} \\\\\n \\frac{328}{9} \\\\\n \\frac{752}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(16/3)],\n [-(47/6)],\n [(23/3)]])\nb = np.array([\n [(16/3)],\n [(47/6)],\n [(5/6)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7.111 \\\\\n -7.634 \\\\\n -5.619 \\\\\n -2.968 \\\\\n -5.992 \\\\\n 9.936 \\\\\n 5.574 \\\\\n 8.945 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5.975 \\\\\n 6.633 \\\\\n -0.008 \\\\\n -3.218 \\\\\n -3.301 \\\\\n -0.554 \\\\\n 2.6 \\\\\n -5.142 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-100.756$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7.111],\n [-7.634],\n [-5.619],\n [-2.968],\n [-5.992],\n [9.936],\n [5.574],\n [8.945]])\nb = np.array([\n [-5.975],\n [6.633],\n [-0.008],\n [-3.218],\n [-3.301],\n [-0.554],\n [2.6],\n [-5.142]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 9 \\\\\n -8 \\\\\n -2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n 6 \\\\\n 3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$20$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [9],\n [-8],\n [-2],\n [-1]])\nb = np.array([\n [1],\n [-2],\n [6],\n [3],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 6 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -2 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -24 \\\\\n -20 \\\\\n -26 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [6],\n [0]])\nb = np.array([\n [6],\n [-2],\n [-4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{4}{5} & -\\frac{14}{5} & -\\frac{8}{5} & 3 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{2}{5} \\\\\n -\\frac{14}{5} \\\\\n -\\frac{4}{5} \\\\\n -\\frac{12}{5} \\\\\n \\frac{2}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{56}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/5), -(14/5), -(8/5), 3, 0]])\nb = np.array([\n [(2/5)],\n [-(14/5)],\n [-(4/5)],\n [-(12/5)],\n [(2/5)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{11}{2} \\\\\n 3 \\\\\n -4 \\\\\n \\frac{1}{2} \\\\\n \\frac{13}{2} \\\\\n -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n -2 \\\\\n -\\frac{7}{2} \\\\\n -4 \\\\\n \\frac{9}{2} \\\\\n -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{41 \\sqrt{\\frac{11}{1834}}}{4}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/2)],\n [3],\n [-4],\n [(1/2)],\n [(13/2)],\n [-(15/2)]]).squeeze()\nb = np.array([\n [(5/2)],\n [-2],\n [-(7/2)],\n [-4],\n [(9/2)],\n [-(17/2)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{25}{6} & \\frac{23}{6} \\\\\n -\\frac{17}{6} & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{691}{36}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(25/6), (23/6)],\n [-(17/6), 2]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -\\frac{14}{5} & \\frac{9}{5} & -\\frac{8}{5} \\\\\n 1 & 1 & \\frac{7}{5} \\\\\n \\frac{7}{5} & -\\frac{8}{5} & \\frac{9}{5} \\\\\n \\frac{14}{5} & \\frac{1}{5} & -\\frac{6}{5} \\\\\n -\\frac{11}{5} & -1 & \\frac{2}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{8}{5} & -\\frac{4}{5} & \\frac{3}{5} & -\\frac{11}{5} & -\\frac{4}{5} \\\\\n \\frac{11}{5} & -\\frac{2}{5} & -\\frac{7}{5} & \\frac{8}{5} & \\frac{14}{5} \\\\\n \\frac{13}{5} & \\frac{3}{5} & -\\frac{4}{5} & 0 & -\\frac{14}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n \\frac{107}{25} & \\frac{14}{25} & -\\frac{73}{25} & \\frac{226}{25} & \\frac{294}{25} \\\\\n \\frac{106}{25} & -\\frac{9}{25} & -\\frac{48}{25} & -\\frac{3}{5} & -\\frac{48}{25} \\\\\n -\\frac{27}{25} & \\frac{3}{5} & \\frac{41}{25} & -\\frac{141}{25} & -\\frac{266}{25} \\\\\n -\\frac{179}{25} & -\\frac{76}{25} & \\frac{59}{25} & -\\frac{146}{25} & \\frac{42}{25} \\\\\n \\frac{59}{25} & \\frac{12}{5} & -\\frac{6}{25} & \\frac{81}{25} & -\\frac{54}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(14/5), (9/5), -(8/5)],\n [1, 1, (7/5)],\n [(7/5), -(8/5), (9/5)],\n [(14/5), (1/5), -(6/5)],\n [-(11/5), -1, (2/5)]])\nb = np.array([\n [-(8/5), -(4/5), (3/5), -(11/5), -(4/5)],\n [(11/5), -(2/5), -(7/5), (8/5), (14/5)],\n [(13/5), (3/5), -(4/5), 0, -(14/5)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${2, 3, -3}$ to the plane $-\\frac{x}{3}-\\frac{2 y}{3}+\\frac{z}{3}+\\frac{5}{3}=0$.", - "Output Answer": [ - "$\\sqrt{6}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 2, 3, -3\nplane = Poly(-(x/3)-((2*y)/3)+(z/3)+(5/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{32}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -6 & -10 & -10 & 9 \\\\\n -9 & -7 & 10 & -10 \\\\\n -4 & -6 & 6 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{3}{16} & -\\frac{5}{16} & -\\frac{5}{16} & \\frac{9}{32} \\\\\n -\\frac{9}{32} & -\\frac{7}{32} & \\frac{5}{16} & -\\frac{5}{16} \\\\\n -\\frac{1}{8} & -\\frac{3}{16} & \\frac{3}{16} & \\frac{9}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -10, -10, 9],\n [-9, -7, 10, -10],\n [-4, -6, 6, 9]])\nprint(a * (1/32))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,-3,1\\}, \\{-2,-1,5\\}, \\{2,-2,-2\\}}$.", - "Output Answer": [ - "$5 x-8 y+4 z-18=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, -3, 1],\n [-2, -1, 5],\n [2, -2, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 4 & 1 & -2 \\\\\n -3 & 0 & 5 \\\\\n -2 & 2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{5}{22} & \\frac{1}{22} & -\\frac{5}{44} \\\\\n \\frac{4}{11} & \\frac{3}{11} & \\frac{7}{22} \\\\\n \\frac{3}{22} & \\frac{5}{22} & -\\frac{3}{44} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 1, -2],\n [-3, 0, 5],\n [-2, 2, -2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\sqrt{2} \\\\\n 0 \\\\\n -\\sqrt{2} \\\\\n \\sqrt{2} \\\\\n -3 \\sqrt{2} \\\\\n -7 \\sqrt{2} \\\\\n -5 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\sqrt{2} \\\\\n 3 \\sqrt{2} \\\\\n -7 \\sqrt{2} \\\\\n 2 \\sqrt{2} \\\\\n -4 \\sqrt{2} \\\\\n 5 \\sqrt{2} \\\\\n 2 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4 \\sqrt{38}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [7*math.sqrt(2)],\n [0],\n [-math.sqrt(2)],\n [math.sqrt(2)],\n [-3*math.sqrt(2)],\n [-7*math.sqrt(2)],\n [-5*math.sqrt(2)]])\nb = np.array([\n [-math.sqrt(2)],\n [3*math.sqrt(2)],\n [-7*math.sqrt(2)],\n [2*math.sqrt(2)],\n [-4*math.sqrt(2)],\n [5*math.sqrt(2)],\n [2*math.sqrt(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & -2 & -3 \\\\\n 3 & 0 & -4 \\\\\n 2 & 9 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{2.989,-1.756,1.\\}, \\{-0.297-0.073 i,-0.332-0.638 i,1.\\}, \\{-0.297+0.073 i,-0.332+0.638 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2, -3],\n [3, 0, -4],\n [2, 9, 7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 10 \\\\\n -8 \\\\\n 7 \\\\\n -9 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 2 \\\\\n 5 \\\\\n -8 \\\\\n -7 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$59$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [10],\n [-8],\n [7],\n [-9],\n [3]])\nb = np.array([\n [-8],\n [2],\n [5],\n [-8],\n [-7],\n [0]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -9 & \\frac{55}{6} & -1 \\\\\n \\frac{1}{2} & -\\frac{5}{2} & \\frac{1}{3} \\\\\n -\\frac{14}{3} & -\\frac{19}{6} & \\frac{17}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{35 x^2}{6}+\\frac{1831 x}{36}+\\frac{4915}{54}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, (55/6), -1],\n [(1/2), -(5/2), (1/3)],\n [-(14/3), -(19/6), (17/3)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 9 & 7 & 1 & 9 \\\\\n -10 & 3 & 5 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -8 & -9 & 2 & 6 \\\\\n -1 & 2 & -2 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & -2 & 3 & 15 \\\\\n -11 & 5 & 3 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 7, 1, 9],\n [-10, 3, 5, 8]])\nb = np.array([\n [-8, -9, 2, 6],\n [-1, 2, -2, 0]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{83}{9} \\\\\n \\frac{52}{9} \\\\\n \\frac{17}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n \\frac{43}{9} \\\\\n \\frac{53}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{563}{81} \\\\\n -\\frac{268}{81} \\\\\n -\\frac{643}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(83/9)],\n [(52/9)],\n [(17/3)]])\nb = np.array([\n [9],\n [(43/9)],\n [(53/9)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & -4 & -8 \\\\\n -7 & 10 & -9 \\\\\n -8 & 9 & 5 \\\\\n -2 & -3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, -4, -8],\n [-7, 10, -9],\n [-8, 9, 5],\n [-2, -3, 2]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 3 & 6 \\\\\n 8 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{8} \\left(5-\\sqrt{73}\\right),1\\right\\}, \\left\\{\\frac{1}{8} \\left(5+\\sqrt{73}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 6],\n [8, -7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -1 & -1 & -3 & 1 \\\\\n 8 & 9 & -1 & 2 \\\\\n -8 & 7 & -5 & 3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 7 & -4 & 0 & -6 \\\\\n 6 & 0 & -1 & -6 \\\\\n 9 & -5 & 10 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -8 & 3 & -3 & 7 \\\\\n 2 & 9 & 0 & 8 \\\\\n -17 & 12 & -15 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, -3, 1],\n [8, 9, -1, 2],\n [-8, 7, -5, 3]])\nb = np.array([\n [7, -4, 0, -6],\n [6, 0, -1, -6],\n [9, -5, 10, 8]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 0 & -3 & 1 & 5 & 2 & 7 \\\\\n -6 & 6 & -4 & -1 & 6 & 10 \\\\\n 8 & 8 & -6 & -10 & 4 & 0 \\\\\n -3 & 1 & -9 & -5 & 1 & -7 \\\\\n -1 & -9 & 9 & 0 & 0 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & -\\frac{1525}{24629} \\\\\n 0 & 1 & 0 & 0 & 0 & -\\frac{27}{2239} \\\\\n 0 & 0 & 1 & 0 & 0 & \\frac{21426}{24629} \\\\\n 0 & 0 & 0 & 1 & 0 & \\frac{7852}{24629} \\\\\n 0 & 0 & 0 & 0 & 1 & \\frac{55413}{24629} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, -3, 1, 5, 2, 7],\n [-6, 6, -4, -1, 6, 10],\n [8, 8, -6, -10, 4, 0],\n [-3, 1, -9, -5, 1, -7],\n [-1, -9, 9, 0, 0, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 3 \\\\\n 0 & -1 \\\\\n 0 & -2 \\\\\n 0 & 3 \\\\\n -3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.98 \\\\\n -2.22 \\\\\n -0.24 \\\\\n -1.08 \\\\\n 2.23 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.058 \\\\\n -0.303 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3],\n [0, -1],\n [0, -2],\n [0, 3],\n [-3, 2]])\nb = np.array([\n [-2.98],\n [-2.22],\n [-0.24],\n [-1.08],\n [2.23]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 8 \\\\\n -3 \\\\\n 9 \\\\\n -3 \\\\\n -5 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{305}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [8],\n [-3],\n [9],\n [-3],\n [-5],\n [-9]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{2} & -\\frac{1}{2} & -\\frac{1}{2} \\\\\n -2 & -3 & 1 \\\\\n -\\frac{1}{2} & 2 & \\frac{5}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 7 & -6 & -\\frac{33}{4} \\\\\n -\\frac{41}{2} & -\\frac{145}{4} & 12 \\\\\n -\\frac{47}{4} & \\frac{89}{4} & \\frac{47}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), -(1/2), -(1/2)],\n [-2, -3, 1],\n [-(1/2), 2, (5/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 9 \\\\\n 5 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [9],\n [5],\n [6]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 2 & -2 & 2 & 2 & -1 \\\\\n 0 & 1 & -2 & 0 & 1 \\\\\n 0 & -2 & 1 & 2 & -3 \\\\\n 1 & 0 & 2 & -1 & 1 \\\\\n 3 & 0 & 2 & 1 & 3 \\\\\n 3 & 0 & -2 & 1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.88 \\\\\n -0.02 \\\\\n -0.42 \\\\\n 0.79 \\\\\n -2.91 \\\\\n -1.48 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.25 \\\\\n -14.441 \\\\\n -4.762 \\\\\n -5.788 \\\\\n 4.404 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2, 2, 2, -1],\n [0, 1, -2, 0, 1],\n [0, -2, 1, 2, -3],\n [1, 0, 2, -1, 1],\n [3, 0, 2, 1, 3],\n [3, 0, -2, 1, -1]])\nb = np.array([\n [2.88],\n [-0.02],\n [-0.42],\n [0.79],\n [-2.91],\n [-1.48]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{8}{9}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 10 & -10 & -2 \\\\\n -10 & -2 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{80}{9} & \\frac{80}{9} & \\frac{16}{9} \\\\\n \\frac{80}{9} & \\frac{16}{9} & -\\frac{16}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -10, -2],\n [-10, -2, 2]])\nprint(a * -(8/9))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{3}{4}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [1],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [-1],\n [1],\n [0],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2.72 \\\\\n -4.584 \\\\\n 3.444 \\\\\n -9.492 \\\\\n 3.982 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5.709 \\\\\n 6.319 \\\\\n -3.964 \\\\\n -7.075 \\\\\n -1.368 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$34.6187$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2.72],\n [-4.584],\n [3.444],\n [-9.492],\n [3.982]])\nb = np.array([\n [-5.709],\n [6.319],\n [-3.964],\n [-7.075],\n [-1.368]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{1}{2}, 4}$ to the line $x+4 y+\\frac{1}{2}=0$.", - "Output Answer": [ - "$\\sqrt{17}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (1/2), 4\nline = Poly(x+4*y+(1/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & -6 \\\\\n 10 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{40} i \\left(7 \\sqrt{15}-15 i\\right),1\\right\\}, \\left\\{-\\frac{1}{40} i \\left(7 \\sqrt{15}+15 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), -6],\n [10, -6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 9 \\\\\n -1 \\\\\n -6 \\\\\n -3 \\\\\n -1 \\\\\n 8 \\\\\n -1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -8 \\\\\n 4 \\\\\n -10 \\\\\n -8 \\\\\n 1 \\\\\n -7 \\\\\n 1 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$31$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [9],\n [-1],\n [-6],\n [-3],\n [-1],\n [8],\n [-1],\n [2]])\nb = np.array([\n [-9],\n [-8],\n [4],\n [-10],\n [-8],\n [1],\n [-7],\n [1],\n [-5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -4 & -7 & -3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 2 & 0 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -6 & -7 & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -7, -3]])\nb = np.array([\n [2, 0, 6]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -4 \\\\\n 1 \\\\\n 6 \\\\\n 6 \\\\\n -2 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 10 \\\\\n -8 \\\\\n 1 \\\\\n 9 \\\\\n -6 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{487}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-4],\n [1],\n [6],\n [6],\n [-2],\n [8]])\nb = np.array([\n [5],\n [10],\n [-8],\n [1],\n [9],\n [-6],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 3 & -1 & 3 & 2 & -2 \\\\\n 0 & 1 & -3 & 1 & -2 \\\\\n 2 & 2 & -1 & 1 & 1 \\\\\n 0 & -3 & 2 & 2 & 3 \\\\\n -3 & -3 & 3 & 2 & 1 \\\\\n 2 & 3 & 1 & 1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.19 \\\\\n -0.53 \\\\\n 2.78 \\\\\n -2.13 \\\\\n -2.32 \\\\\n 1.27 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.188 \\\\\n 0.567 \\\\\n -0.065 \\\\\n -0.281 \\\\\n 0.27 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, 3, 2, -2],\n [0, 1, -3, 1, -2],\n [2, 2, -1, 1, 1],\n [0, -3, 2, 2, 3],\n [-3, -3, 3, 2, 1],\n [2, 3, 1, 1, 1]])\nb = np.array([\n [-1.19],\n [-0.53],\n [2.78],\n [-2.13],\n [-2.32],\n [1.27]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & -2 & 1 \\\\\n 0 & 0 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n e & 0 & 0 \\\\\n 0 & \\frac{1}{e^2} & \\frac{e-1}{e^2} \\\\\n 0 & 0 & \\frac{1}{e} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [1, 0, 0],\n [0, -2, 1],\n [0, 0, -1]])\nprint(expm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 3 & 2 & 9 & -8 \\\\\n -5 & -1 & 0 & -8 \\\\\n -3 & -8 & -3 & 6 \\\\\n 6 & -1 & 6 & -4 \\\\\n 10 & -3 & -1 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, 2, 9, -8],\n [-5, -1, 0, -8],\n [-3, -8, -3, 6],\n [6, -1, 6, -4],\n [10, -3, -1, -7]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -2 & 0 & 3 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 3 & 0 & -2 \\\\\n 0 & 1 & 2 \\\\\n -2 & 0 & 0 \\\\\n -1 & 0 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -9 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, 3, -3]])\nb = np.array([\n [3, 0, -2],\n [0, 1, 2],\n [-2, 0, 0],\n [-1, 0, 1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{10}{3} & \\frac{7}{3} & -\\frac{14}{3} \\\\\n -\\frac{1}{3} & -4 & 0 \\\\\n 3 & 3 & \\frac{14}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{392}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(10/3), (7/3), -(14/3)],\n [-(1/3), -4, 0],\n [3, 3, (14/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{2} & 4 \\\\\n -\\frac{7}{3} & \\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{7}{6}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2), 4],\n [-(7/3), (7/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [3]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n \\frac{1}{2} \\\\\n 2 \\\\\n 1 \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2 \\sqrt{\\frac{2}{23}} \\\\\n \\frac{1}{\\sqrt{46}} \\\\\n 2 \\sqrt{\\frac{2}{23}} \\\\\n \\sqrt{\\frac{2}{23}} \\\\\n \\frac{3}{\\sqrt{46}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [(1/2)],\n [2],\n [1],\n [(3/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{10}{3},\\frac{1}{3},\\frac{5}{3}\\right\\}, \\left\\{\\frac{14}{3},\\frac{14}{3},\\frac{11}{3}\\right\\}, \\left\\{\\frac{4}{3},-\\frac{5}{3},\\frac{4}{3}\\right\\}}$.", - "Output Answer": [ - "$23 x-32 y+54 z-156=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(10/3), (1/3), (5/3)],\n [(14/3), (14/3), (11/3)],\n [(4/3), -(5/3), (4/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{31}{4} & \\frac{9}{8} & \\frac{13}{4} \\\\\n -\\frac{5}{8} & -\\frac{29}{4} & \\frac{47}{8} \\\\\n \\frac{77}{8} & \\frac{65}{8} & -\\frac{11}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{9 x^2}{4}+\\frac{1087 x}{8}+\\frac{28949}{512}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(31/4), (9/8), (13/4)],\n [-(5/8), -(29/4), (47/8)],\n [(77/8), (65/8), -(11/4)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{8}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 5 & -9 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{35}{8} & \\frac{63}{8} & \\frac{35}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -9, -5]])\nprint(a * -(7/8))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -1 & 1 \\\\\n -3 & 3 \\\\\n 1 & 2 \\\\\n -1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 1 & -2 & 3 \\\\\n 2 & 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 2 & -1 \\\\\n 3 & 6 & -3 \\\\\n 5 & -2 & 7 \\\\\n 3 & 2 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1],\n [-3, 3],\n [1, 2],\n [-1, 2]])\nb = np.array([\n [1, -2, 3],\n [2, 0, 2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{9} & \\frac{65}{9} & -\\frac{10}{3} \\\\\n \\frac{19}{3} & -\\frac{17}{9} & 6 \\\\\n -\\frac{2}{3} & \\frac{52}{9} & \\frac{46}{9} \\\\\n \\frac{44}{9} & \\frac{44}{9} & \\frac{35}{9} \\\\\n \\frac{25}{9} & \\frac{47}{9} & \\frac{83}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/9), (65/9), -(10/3)],\n [(19/3), -(17/9), 6],\n [-(2/3), (52/9), (46/9)],\n [(44/9), (44/9), (35/9)],\n [(25/9), (47/9), (83/9)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -\\frac{3}{2} \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n \\frac{1}{2} \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{7}{4} \\\\\n -53 \\\\\n 18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-(3/2)],\n [-5]])\nb = np.array([\n [10],\n [(1/2)],\n [(1/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 1 & 2 & 3 \\\\\n -1 & 4 & -3 \\\\\n -3 & 1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{6} & -\\frac{1}{66} & -\\frac{3}{11} \\\\\n \\frac{1}{6} & \\frac{1}{6} & 0 \\\\\n \\frac{1}{6} & -\\frac{7}{66} & \\frac{1}{11} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, 3],\n [-1, 4, -3],\n [-3, 1, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n \\frac{17}{3} & -\\frac{13}{3} & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/3), -(13/3), -6]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -9 & -\\frac{48}{5} \\\\\n -9 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(-55-\\sqrt{9865}\\right),\\frac{1}{10} \\left(\\sqrt{9865}-55\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -(48/5)],\n [-9, -2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -8 & 1 & 8 \\\\\n 7 & -4 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & -\\frac{28}{25} \\\\\n 0 & 1 & -\\frac{24}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-8, 1, 8],\n [7, -4, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -1 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 10 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{122}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-1],\n [8]])\nb = np.array([\n [-9],\n [10],\n [7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{15}{32}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 10 & -10 & 5 & -4 \\\\\n 5 & 8 & -6 & -4 \\\\\n 3 & 6 & 0 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{75}{16} & -\\frac{75}{16} & \\frac{75}{32} & -\\frac{15}{8} \\\\\n \\frac{75}{32} & \\frac{15}{4} & -\\frac{45}{16} & -\\frac{15}{8} \\\\\n \\frac{45}{32} & \\frac{45}{16} & 0 & \\frac{15}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -10, 5, -4],\n [5, 8, -6, -4],\n [3, 6, 0, 4]])\nprint(a * (15/32))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -3 & -2 & -1 & 0 & -1 \\\\\n 3 & 0 & -2 & 3 & -1 \\\\\n 0 & 0 & -2 & 0 & 3 \\\\\n 0 & 3 & 1 & 0 & 3 \\\\\n -2 & 0 & 3 & -3 & -2 \\\\\n 0 & -2 & -1 & -3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.66 \\\\\n 2.88 \\\\\n -2.68 \\\\\n 0.37 \\\\\n 1.77 \\\\\n 1.72 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.255 \\\\\n 3.646 \\\\\n -2.529 \\\\\n -0.418 \\\\\n -2.66 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2, -1, 0, -1],\n [3, 0, -2, 3, -1],\n [0, 0, -2, 0, 3],\n [0, 3, 1, 0, 3],\n [-2, 0, 3, -3, -2],\n [0, -2, -1, -3, -2]])\nb = np.array([\n [1.66],\n [2.88],\n [-2.68],\n [0.37],\n [1.77],\n [1.72]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{36}{5} & -\\frac{9}{5} & \\frac{48}{5} \\\\\n \\frac{17}{5} & 7 & \\frac{29}{5} \\\\\n \\frac{21}{5} & -\\frac{16}{5} & \\frac{38}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.595,-0.064,1.\\}, \\{1.592\\, -0.666 i,1.231\\, -1.989 i,1.\\}, \\{1.592\\, +0.666 i,1.231\\, +1.989 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(36/5), -(9/5), (48/5)],\n [(17/5), 7, (29/5)],\n [(21/5), -(16/5), (38/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 7 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 3 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -67 \\\\\n -37 \\\\\n -35 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [7],\n [6]])\nb = np.array([\n [2],\n [3],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 3 \\\\\n 10 \\\\\n 1 \\\\\n -6 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 10 \\\\\n 1 \\\\\n 2 \\\\\n 6 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-18$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [3],\n [10],\n [1],\n [-6],\n [0]])\nb = np.array([\n [8],\n [10],\n [1],\n [2],\n [6],\n [2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5.041 \\\\\n 2.78 \\\\\n -4.283 \\\\\n -6.096 \\\\\n -6.559 \\\\\n -2.589 \\\\\n -4.473 \\\\\n 1.056 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2.25 \\\\\n -0.775 \\\\\n -4.252 \\\\\n -5.098 \\\\\n -2.461 \\\\\n -4.976 \\\\\n -9.348 \\\\\n -7.221 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$99.0048$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5.041],\n [2.78],\n [-4.283],\n [-6.096],\n [-6.559],\n [-2.589],\n [-4.473],\n [1.056]])\nb = np.array([\n [2.25],\n [-0.775],\n [-4.252],\n [-5.098],\n [-2.461],\n [-4.976],\n [-9.348],\n [-7.221]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -2 & 9 & -7 & 7 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-7.,0.,2.,0.,0.\\}, \\{-3.,0.,0.,0.,2.\\}, \\{7.,0.,0.,2.,0.\\}, \\{9.,2.,0.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, 9, -7, 7, -3]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 5 & -5 & -3 \\\\\n -1 & 8 & -6 \\\\\n 0 & 9 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{5.211,7.894\\, -6.957 i,7.894\\, +6.957 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -5, -3],\n [-1, 8, -6],\n [0, 9, 8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 10 & -9 \\\\\n 5 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{3-6 i,5\\}, \\{3+6 i,5\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -9],\n [5, 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,-1,-1\\}, \\{-1,-1,-1\\}, \\{0,-2,1\\}}$", - "Output Answer": [ - "${\\left\\{\\sqrt{\\frac{2}{3}},-\\frac{1}{\\sqrt{6}},-\\frac{1}{\\sqrt{6}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}},-\\frac{1}{\\sqrt{3}}\\right\\}, \\left\\{0,-\\frac{1}{\\sqrt{2}},\\frac{1}{\\sqrt{2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, -1, -1), (-1, -1, -1), (0, -2, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & -2 & 3 & -3 \\\\\n 2 & 3 & -1 & 2 \\\\\n 0 & -3 & 0 & 1 \\\\\n 1 & 2 & 2 & -3 \\\\\n 2 & -3 & 2 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.71 \\\\\n -1.5 \\\\\n -0.67 \\\\\n -1.55 \\\\\n 0.88 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.564 \\\\\n -0.509 \\\\\n -0.856 \\\\\n -0.359 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2, 3, -3],\n [2, 3, -1, 2],\n [0, -3, 0, 1],\n [1, 2, 2, -3],\n [2, -3, 2, 2]])\nb = np.array([\n [-2.71],\n [-1.5],\n [-0.67],\n [-1.55],\n [0.88]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{3} \\\\\n -\\frac{11}{3} \\\\\n -6 \\\\\n 5 \\\\\n -\\frac{8}{3} \\\\\n -6 \\\\\n -\\frac{14}{3} \\\\\n \\frac{20}{3} \\\\\n -\\frac{16}{3} \\\\\n \\frac{10}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{3} \\\\\n -\\frac{25}{3} \\\\\n \\frac{17}{3} \\\\\n -2 \\\\\n \\frac{16}{3} \\\\\n 5 \\\\\n -\\frac{25}{3} \\\\\n 1 \\\\\n \\frac{8}{3} \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{4682}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/3)],\n [-(11/3)],\n [-6],\n [5],\n [-(8/3)],\n [-6],\n [-(14/3)],\n [(20/3)],\n [-(16/3)],\n [(10/3)]])\nb = np.array([\n [-(29/3)],\n [-(25/3)],\n [(17/3)],\n [-2],\n [(16/3)],\n [5],\n [-(25/3)],\n [1],\n [(8/3)],\n [-1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{52}{7} & \\frac{55}{7} & \\frac{1}{7} & \\frac{18}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{50}{7} & \\frac{64}{7} & -\\frac{6}{7} & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{2}{7} & 17 & -\\frac{5}{7} & \\frac{46}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(52/7), (55/7), (1/7), (18/7)]])\nb = np.array([\n [(50/7), (64/7), -(6/7), 4]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{47}{5} & \\frac{22}{5} & -\\frac{7}{5} \\\\\n \\frac{44}{5} & -8 & -\\frac{32}{5} \\\\\n -\\frac{28}{5} & -\\frac{38}{5} & \\frac{33}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-4.258,6.017,1.\\}, \\{-0.161,-0.419,1.\\}, \\{0.932,0.997,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(47/5), (22/5), -(7/5)],\n [(44/5), -8, -(32/5)],\n [-(28/5), -(38/5), (33/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -6 & 1 & 9 \\\\\n -8 & 7 & 7 \\\\\n -7 & 9 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.872,2.346,1.\\}, \\{-1.498-2.411 i,-1.054-1.578 i,1.\\}, \\{-1.498+2.411 i,-1.054+1.578 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 1, 9],\n [-8, 7, 7],\n [-7, 9, -8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -8 & 3 & 6 \\\\\n 6 & 4 & -4 \\\\\n 5 & -1 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-5 x^2+80 x-134$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 3, 6],\n [6, 4, -4],\n [5, -1, -1]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 0 & 2 & 2 \\\\\n 0 & 4 & 3 \\\\\n 4 & 2 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{11}{4} & -\\frac{3}{2} & \\frac{1}{4} \\\\\n -\\frac{3}{2} & 1 & 0 \\\\\n 2 & -1 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, 2],\n [0, 4, 3],\n [4, 2, -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n -2 \\\\\n -2 \\\\\n 1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{2}{\\sqrt{21}} \\\\\n -\\frac{2}{\\sqrt{21}} \\\\\n -\\frac{2}{\\sqrt{21}} \\\\\n -\\frac{2}{\\sqrt{21}} \\\\\n \\frac{1}{\\sqrt{21}} \\\\\n -\\frac{2}{\\sqrt{21}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-2],\n [-2],\n [-2],\n [1],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -6 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -5 \\\\\n 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -26 \\\\\n -28 \\\\\n -10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-6],\n [-4]])\nb = np.array([\n [5],\n [-5],\n [1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -1 & -\\frac{17}{3} & \\frac{16}{3} & -5 \\\\\n \\frac{23}{3} & -\\frac{26}{3} & \\frac{5}{3} & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -(17/3), (16/3), -5],\n [(23/3), -(26/3), (5/3), 8]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{3}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 9 & -5 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -21 & \\frac{35}{3} & \\frac{14}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -5, -2]])\nprint(a * -(7/3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{4} & \\frac{9}{8} & \\frac{17}{8} \\\\\n \\frac{13}{8} & \\frac{21}{8} & -3 \\\\\n 0 & -\\frac{23}{8} & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 1 & \\frac{11}{8} & -\\frac{5}{2} & \\frac{23}{8} \\\\\n \\frac{17}{8} & \\frac{13}{8} & \\frac{11}{4} & -\\frac{1}{2} \\\\\n \\frac{3}{4} & \\frac{7}{8} & -\\frac{13}{8} & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{175}{64} & \\frac{63}{32} & \\frac{177}{64} & -\\frac{337}{32} \\\\\n \\frac{317}{64} & \\frac{31}{8} & \\frac{257}{32} & \\frac{791}{64} \\\\\n -\\frac{535}{64} & -\\frac{467}{64} & -\\frac{97}{32} & \\frac{167}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/4), (9/8), (17/8)],\n [(13/8), (21/8), -3],\n [0, -(23/8), -3]])\nb = np.array([\n [1, (11/8), -(5/2), (23/8)],\n [(17/8), (13/8), (11/4), -(1/2)],\n [(3/4), (7/8), -(13/8), -3]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 3 \\\\\n 2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3],\n [2, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{31}{4} \\\\\n 3 \\\\\n 0 \\\\\n 6 \\\\\n \\frac{9}{2} \\\\\n -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -\\frac{39}{4} \\\\\n \\frac{29}{4} \\\\\n -\\frac{21}{4} \\\\\n \\frac{31}{4} \\\\\n \\frac{29}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{6545}}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(31/4)],\n [3],\n [0],\n [6],\n [(9/2)],\n [-(1/4)]])\nb = np.array([\n [7],\n [-(39/4)],\n [(29/4)],\n [-(21/4)],\n [(31/4)],\n [(29/4)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & -1 & -2 \\\\\n 5 & 0 & 4 \\\\\n -1 & -4 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$11$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1, -2],\n [5, 0, 4],\n [-1, -4, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -1 & -10 & 0 \\\\\n 4 & 4 & -3 \\\\\n 10 & 6 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-1, -10, 0],\n [4, 4, -3],\n [10, 6, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{19}{3} \\\\\n \\frac{11}{3} \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -\\frac{29}{3} \\\\\n 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{313}{3} \\\\\n -\\frac{316}{3} \\\\\n -\\frac{353}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/3)],\n [(11/3)],\n [7]])\nb = np.array([\n [-6],\n [-(29/3)],\n [10]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n \\frac{47}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{4610}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [(47/7)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{27}{4} & \\frac{33}{4} & -9 \\\\\n \\frac{7}{2} & \\frac{9}{4} & -\\frac{23}{4} \\\\\n -9 & -\\frac{13}{2} & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(27/4), (33/4), -9],\n [(7/2), (9/4), -(23/4)],\n [-9, -(13/2), -7]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{8}{7}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -8 \\\\\n 10 & 7 \\\\\n 4 & -3 \\\\\n -3 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{16}{7} & -\\frac{64}{7} \\\\\n \\frac{80}{7} & 8 \\\\\n \\frac{32}{7} & -\\frac{24}{7} \\\\\n -\\frac{24}{7} & \\frac{48}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -8],\n [10, 7],\n [4, -3],\n [-3, 6]])\nprint(a * (8/7))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{2} \\\\\n -6 \\\\\n 9 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 5 \\\\\n \\frac{13}{2} \\\\\n -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{103}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/2)],\n [-6],\n [9],\n [-10]])\nb = np.array([\n [8],\n [5],\n [(13/2)],\n [-(15/2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -1 \\\\\n 6 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{134}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-1],\n [6],\n [-9]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{2} & \\frac{2}{3} & -\\frac{13}{6} \\\\\n \\frac{1}{3} & \\frac{5}{6} & \\frac{9}{2} \\\\\n \\frac{23}{6} & \\frac{2}{3} & \\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{3421}{216}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), (2/3), -(13/6)],\n [(1/3), (5/6), (9/2)],\n [(23/6), (2/3), (7/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & \\frac{9}{2} \\\\\n -\\frac{5}{2} & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{41}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), (9/2)],\n [-(5/2), -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -9 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -8 \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -102 \\\\\n 72 \\\\\n -40 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-9],\n [-6]])\nb = np.array([\n [-8],\n [-8],\n [6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 1 \\\\\n 8 \\\\\n -3 \\\\\n 9 \\\\\n -3 \\\\\n -9 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 4 \\\\\n 8 \\\\\n 9 \\\\\n -1 \\\\\n 7 \\\\\n -7 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$29$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [1],\n [8],\n [-3],\n [9],\n [-3],\n [-9],\n [5]])\nb = np.array([\n [-6],\n [4],\n [8],\n [9],\n [-1],\n [7],\n [-7],\n [-3]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 1 & -2 & -2 & 2 & -2 \\\\\n -2 & 3 & -1 & 2 & 0 \\\\\n -2 & -1 & 3 & 1 & -1 \\\\\n 1 & -1 & 0 & 1 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -3 & 2 & 2 & -1 \\\\\n 0 & 0 & 0 & 2 \\\\\n -2 & 0 & 0 & -1 \\\\\n -1 & -3 & 2 & 2 \\\\\n -1 & 1 & -1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & -6 & 8 & -3 \\\\\n 6 & -10 & 0 & 13 \\\\\n 0 & -8 & -1 & -3 \\\\\n -4 & -1 & 4 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2, -2, 2, -2],\n [-2, 3, -1, 2, 0],\n [-2, -1, 3, 1, -1],\n [1, -1, 0, 1, 0]])\nb = np.array([\n [-3, 2, 2, -1],\n [0, 0, 0, 2],\n [-2, 0, 0, -1],\n [-1, -3, 2, 2],\n [-1, 1, -1, 2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{61}{7} \\\\\n \\frac{27}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{4}{7} \\\\\n \\frac{59}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{4273}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(61/7)],\n [(27/7)]])\nb = np.array([\n [(4/7)],\n [(59/7)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & 4 \\\\\n -5 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{10} i \\left(\\sqrt{79}-i\\right),1\\right\\}, \\left\\{-\\frac{1}{10} i \\left(\\sqrt{79}+i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 4],\n [-5, -6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -9 & 5 & 8 & 6 & -1 \\\\\n 0 & 9 & 1 & 2 & 6 \\\\\n 4 & -9 & -8 & -7 & 1 \\\\\n 4 & 8 & 8 & -7 & 5 \\\\\n -6 & 10 & -5 & 9 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 5, 8, 6, -1],\n [0, 9, 1, 2, 6],\n [4, -9, -8, -7, 1],\n [4, 8, 8, -7, 5],\n [-6, 10, -5, 9, -6]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n -1 \\\\\n -2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{1}{\\sqrt{15}} \\\\\n -\\frac{1}{\\sqrt{15}} \\\\\n -\\frac{2}{\\sqrt{15}} \\\\\n \\sqrt{\\frac{3}{5}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [1],\n [-1],\n [-2],\n [3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{17}{5}, -\\frac{7}{5}, \\frac{19}{5}}$ to the plane $\\frac{12 x}{5}+2 y-4 z+1=0$.", - "Output Answer": [ - "$\\frac{629}{10 \\sqrt{161}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(17/5), -(7/5), (19/5)\nplane = Poly(((12*x)/5)+2*y-4*z+1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 3 & -2 & 3 & 0 \\\\\n 0 & -1 & -2 & -2 \\\\\n 1 & -1 & 0 & 3 \\\\\n -3 & 1 & 1 & 2 \\\\\n 0 & 1 & -3 & -2 \\\\\n 3 & -2 & -3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.89 \\\\\n 0.01 \\\\\n 1.84 \\\\\n -0.94 \\\\\n -0.26 \\\\\n -0.04 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.279 \\\\\n -0.181 \\\\\n 0.2 \\\\\n 0.016 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2, 3, 0],\n [0, -1, -2, -2],\n [1, -1, 0, 3],\n [-3, 1, 1, 2],\n [0, 1, -3, -2],\n [3, -2, -3, 3]])\nb = np.array([\n [1.89],\n [0.01],\n [1.84],\n [-0.94],\n [-0.26],\n [-0.04]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -3 & 3 & 2 & -1 & -3 \\\\\n 0 & -1 & -1 & -2 & -2 \\\\\n 2 & -1 & -1 & 0 & -1 \\\\\n 1 & -1 & 2 & 3 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -1 \\\\\n 0 \\\\\n -2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 11 \\\\\n 9 \\\\\n -1 \\\\\n -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 3, 2, -1, -3],\n [0, -1, -1, -2, -2],\n [2, -1, -1, 0, -1],\n [1, -1, 2, 3, -1]])\nb = np.array([\n [-2],\n [-1],\n [0],\n [-2],\n [-2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{5} & \\frac{37}{5} \\\\\n -\\frac{26}{5} & \\frac{29}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{26} i \\left(\\sqrt{638}-18 i\\right),1\\right\\}, \\left\\{-\\frac{1}{26} i \\left(\\sqrt{638}+18 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/5), (37/5)],\n [-(26/5), (29/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{1,3,-1\\}, \\{1,1,-1\\}, \\{-2,2,2\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{11}},\\frac{3}{\\sqrt{11}},-\\frac{1}{\\sqrt{11}}\\right\\}, \\left\\{\\frac{3}{\\sqrt{22}},-\\sqrt{\\frac{2}{11}},-\\frac{3}{\\sqrt{22}}\\right\\}, \\{0,0,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((1, 3, -1), (1, 1, -1), (-2, 2, 2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & -2 \\\\\n -1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-14$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -2],\n [-1, -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{10}{9}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & 3 & -9 & -4 \\\\\n -1 & -10 & 5 & -7 \\\\\n 1 & -4 & 0 & -1 \\\\\n -4 & 7 & 3 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{20}{9} & \\frac{10}{3} & -10 & -\\frac{40}{9} \\\\\n -\\frac{10}{9} & -\\frac{100}{9} & \\frac{50}{9} & -\\frac{70}{9} \\\\\n \\frac{10}{9} & -\\frac{40}{9} & 0 & -\\frac{10}{9} \\\\\n -\\frac{40}{9} & \\frac{70}{9} & \\frac{10}{3} & \\frac{20}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 3, -9, -4],\n [-1, -10, 5, -7],\n [1, -4, 0, -1],\n [-4, 7, 3, 6]])\nprint(a * (10/9))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 6 \\\\\n -2 \\\\\n -8 \\\\\n 9 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$37$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [6],\n [-2],\n [-8],\n [9],\n [-4]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{9} \\\\\n 9 \\\\\n \\frac{74}{9} \\\\\n \\frac{26}{3} \\\\\n \\frac{29}{9} \\\\\n -\\frac{23}{3} \\\\\n -\\frac{10}{3} \\\\\n \\frac{67}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/9)],\n [9],\n [(74/9)],\n [(26/3)],\n [(29/9)],\n [-(23/3)],\n [-(10/3)],\n [(67/9)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{11}{8} & \\frac{9}{2} \\\\\n \\frac{3}{8} & \\frac{1}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{8}{119} & \\frac{288}{119} \\\\\n \\frac{24}{119} & \\frac{88}{119} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/8), (9/2)],\n [(3/8), (1/8)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -1 \\\\\n 10 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-1],\n [10],\n [2]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -3 & 1 \\\\\n 5 & 6 \\\\\n 5 & -8 \\\\\n 4 & 8 \\\\\n 1 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 1],\n [5, 6],\n [5, -8],\n [4, 8],\n [1, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -5 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 8 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 59 \\\\\n 9 \\\\\n -15 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-5],\n [-3]])\nb = np.array([\n [-3],\n [8],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{2}{3}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -5 & -6 \\\\\n -4 & -10 & -1 \\\\\n -5 & -5 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{2}{3} & \\frac{10}{3} & 4 \\\\\n \\frac{8}{3} & \\frac{20}{3} & \\frac{2}{3} \\\\\n \\frac{10}{3} & \\frac{10}{3} & \\frac{16}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -5, -6],\n [-4, -10, -1],\n [-5, -5, -8]])\nprint(a * -(2/3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -8 & 10 & 7 \\\\\n 6 & -4 & 3 \\\\\n 6 & 1 & -2 \\\\\n 0 & 9 & 1 \\\\\n 10 & -10 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-8, 10, 7],\n [6, -4, 3],\n [6, 1, -2],\n [0, 9, 1],\n [10, -10, -6]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -3 & -2 \\\\\n 1 & -1 & 2 \\\\\n -1 & 2 & -3 \\\\\n -2 & 2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.04 \\\\\n -1.76 \\\\\n -0.27 \\\\\n 0.58 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.12 \\\\\n -0.7 \\\\\n -0.11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3, -2],\n [1, -1, 2],\n [-1, 2, -3],\n [-2, 2, -2]])\nb = np.array([\n [1.04],\n [-1.76],\n [-0.27],\n [0.58]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{55}{32}, \\frac{65}{16}}$ to the line $-\\frac{17 x}{4}+\\frac{37 y}{16}-\\frac{15}{32}=0$.", - "Output Answer": [ - "$\\frac{4155}{16 \\sqrt{5993}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(55/32), (65/16)\nline = Poly(-((17*x)/4)+((37*y)/16)-(15/32), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{52}{7} & -\\frac{22}{7} & -\\frac{38}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{54}{7} & \\frac{5}{7} & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{106}{7} & -\\frac{27}{7} & -\\frac{101}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(52/7), -(22/7), -(38/7)]])\nb = np.array([\n [-(54/7), (5/7), 9]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{44}{5} \\\\\n -\\frac{1}{2} \\\\\n \\frac{21}{10} \\\\\n \\frac{49}{10} \\\\\n -\\frac{14}{5} \\\\\n -\\frac{11}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{2879}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(44/5)],\n [-(1/2)],\n [(21/10)],\n [(49/10)],\n [-(14/5)],\n [-(11/10)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{3} & \\frac{26}{3} \\\\\n \\frac{1}{3} & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{2} \\left(5-\\sqrt{129}\\right),1\\right\\}, \\left\\{\\frac{1}{2} \\left(5+\\sqrt{129}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/3), (26/3)],\n [(1/3), -2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & -2 \\\\\n 0 & -1 \\\\\n 2 & -1 \\\\\n 2 & -2 \\\\\n 3 & -3 \\\\\n 3 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.07 \\\\\n -2.02 \\\\\n 1.39 \\\\\n -0.75 \\\\\n -1.86 \\\\\n 2.4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.509 \\\\\n 1.933 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2],\n [0, -1],\n [2, -1],\n [2, -2],\n [3, -3],\n [3, -1]])\nb = np.array([\n [-0.07],\n [-2.02],\n [1.39],\n [-0.75],\n [-1.86],\n [2.4]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{19}{5} & \\frac{23}{5} & -\\frac{14}{5} \\\\\n -\\frac{22}{5} & -\\frac{8}{5} & \\frac{1}{5} \\\\\n \\frac{13}{5} & \\frac{21}{5} & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{6682}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/5), (23/5), -(14/5)],\n [-(22/5), -(8/5), (1/5)],\n [(13/5), (21/5), 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${1, 4}$ to the line $x-y=0$.", - "Output Answer": [ - "$\\frac{3}{\\sqrt{2}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 1, 4\nline = Poly(x-y, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{22}{3} & 9 \\\\\n \\frac{16}{3} & -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{6} \\left(-27-\\sqrt{2017}\\right),\\frac{1}{6} \\left(\\sqrt{2017}-27\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(22/3), 9],\n [(16/3), -(5/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [0],\n [-1],\n [1],\n [1],\n [-1]]).squeeze()\nb = np.array([\n [0],\n [1],\n [0],\n [0],\n [-1],\n [1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -4 \\\\\n 9 \\\\\n 10 \\\\\n -6 \\\\\n 8 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -9 \\\\\n -7 \\\\\n 10 \\\\\n 9 \\\\\n 5 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$50$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-4],\n [9],\n [10],\n [-6],\n [8],\n [9]])\nb = np.array([\n [9],\n [-9],\n [-7],\n [10],\n [9],\n [5],\n [2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 4-\\frac{i}{2} & 4+5 i & \\frac{5}{2}-\\frac{9 i}{2} \\\\\n \\frac{7}{2}+4 i & -4-\\frac{9 i}{2} & -4+i \\\\\n \\frac{5}{2}+i & -\\frac{7}{2}-\\frac{i}{2} & 1+\\frac{5 i}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1585}{8}+\\frac{105 i}{4} & -121+\\frac{523 i}{2} & \\frac{1427}{8}-\\frac{293 i}{8} \\\\\n -128+\\frac{1707 i}{8} & 277-\\frac{2719 i}{8} & -\\frac{843}{8}-\\frac{2037 i}{8} \\\\\n \\frac{33}{8}+\\frac{517 i}{4} & \\frac{93}{8}-\\frac{1429 i}{8} & -\\frac{601}{8}-\\frac{225 i}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4-(1j/2), 4+5j, (5/2)-((9j)/2)],\n [(7/2)+4j, -4-((9j)/2), -4+ 1j],\n [(5/2)+ 1j, -(7/2)-(1j/2), 1+((5j)/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & \\frac{11}{2} & \\frac{15}{2} \\\\\n -1 & \\frac{5}{2} & -\\frac{13}{2} \\\\\n 9 & \\frac{17}{2} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.96,0.515,1.\\}, \\{1.292\\, -0.477 i,-0.353+1.197 i,1.\\}, \\{1.292\\, +0.477 i,-0.353-1.197 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), (11/2), (15/2)],\n [-1, (5/2), -(13/2)],\n [9, (17/2), -4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{9}{2}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -2 & -7 & 6 & -10 \\\\\n 6 & 9 & 6 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 9 & \\frac{63}{2} & -27 & 45 \\\\\n -27 & -\\frac{81}{2} & -27 & -\\frac{27}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -7, 6, -10],\n [6, 9, 6, 3]])\nprint(a * -(9/2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{39}{4} \\\\\n \\frac{25}{4} \\\\\n \\frac{9}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{29}{4} \\\\\n \\frac{39}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{309}{4} \\\\\n -\\frac{1521}{16} \\\\\n -\\frac{1131}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(39/4)],\n [(25/4)],\n [(9/4)]])\nb = np.array([\n [0],\n [-(29/4)],\n [(39/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{7} & -\\frac{8}{7} \\\\\n -\\frac{17}{7} & \\frac{13}{7} \\\\\n -\\frac{17}{7} & -\\frac{16}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{7} & -\\frac{9}{7} \\\\\n \\frac{6}{7} & -\\frac{9}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{75}{49} & \\frac{99}{49} \\\\\n -\\frac{75}{49} & \\frac{36}{49} \\\\\n -\\frac{249}{49} & \\frac{297}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/7), -(8/7)],\n [-(17/7), (13/7)],\n [-(17/7), -(16/7)]])\nb = np.array([\n [(9/7), -(9/7)],\n [(6/7), -(9/7)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{1}{2},\\frac{5}{2},-2\\right\\}, \\left\\{5,\\frac{3}{2},-4\\right\\}, \\left\\{-3,\\frac{1}{2},-\\frac{7}{2}\\right\\}}$.", - "Output Answer": [ - "$4 x-22 y+20 z+93=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(1/2), (5/2), -2],\n [5, (3/2), -4],\n [-3, (1/2), -(7/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 0 & -\\frac{23}{3} & -\\frac{1}{3} \\\\\n 5 & -\\frac{16}{3} & -\\frac{22}{3} \\\\\n -\\frac{22}{3} & -\\frac{23}{3} & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.383,0.644,1.\\}, \\{0.016\\, -1.058 i,-0.955+0.153 i,1.\\}, \\{0.016\\, +1.058 i,-0.955-0.153 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -(23/3), -(1/3)],\n [5, -(16/3), -(22/3)],\n [-(22/3), -(23/3), -6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{4} \\\\\n 6 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{53}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/4)],\n [6],\n [7]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{2} \\\\\n \\frac{1}{2} \\\\\n -2 \\\\\n \\frac{77}{8} \\\\\n \\frac{3}{2} \\\\\n \\frac{5}{4} \\\\\n \\frac{39}{4} \\\\\n \\frac{15}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{263}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2)],\n [(1/2)],\n [-2],\n [(77/8)],\n [(3/2)],\n [(5/4)],\n [(39/4)],\n [(15/4)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n \\frac{13}{2} \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -\\frac{9}{2} \\\\\n \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{969}}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [(13/2)],\n [4]])\nb = np.array([\n [-2],\n [-(9/2)],\n [(7/2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 6 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 2 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -38 \\\\\n -24 \\\\\n 64 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [6],\n [7]])\nb = np.array([\n [-8],\n [2],\n [-4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{19}{3} \\\\\n -2 \\\\\n \\frac{28}{3} \\\\\n -\\frac{7}{3} \\\\\n \\frac{29}{3} \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{10}{3} \\\\\n -\\frac{16}{3} \\\\\n -2 \\\\\n -2 \\\\\n -5 \\\\\n -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{487}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/3)],\n [-2],\n [(28/3)],\n [-(7/3)],\n [(29/3)],\n [-7]])\nb = np.array([\n [-(10/3)],\n [-(16/3)],\n [-2],\n [-2],\n [-5],\n [-(8/3)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & 0 & -1 & 0 \\\\\n 1 & 3 & 3 & 3 \\\\\n -3 & -2 & -2 & -1 \\\\\n -3 & -2 & -1 & -2 \\\\\n 1 & 3 & -1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.69 \\\\\n -1.16 \\\\\n 0.35 \\\\\n 1.28 \\\\\n 0.98 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.76 \\\\\n 2.233 \\\\\n -0.352 \\\\\n -1.831 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 0, -1, 0],\n [1, 3, 3, 3],\n [-3, -2, -2, -1],\n [-3, -2, -1, -2],\n [1, 3, -1, 3]])\nb = np.array([\n [-1.69],\n [-1.16],\n [0.35],\n [1.28],\n [0.98]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 3 \\\\\n 3 \\\\\n -1 \\\\\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2}{\\sqrt{31}} \\\\\n \\frac{3}{\\sqrt{31}} \\\\\n \\frac{3}{\\sqrt{31}} \\\\\n -\\frac{1}{\\sqrt{31}} \\\\\n \\frac{2}{\\sqrt{31}} \\\\\n \\frac{2}{\\sqrt{31}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [3],\n [3],\n [-1],\n [2],\n [2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-5]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-1,-3,0\\}, \\{1,3,2\\}, \\{0,-1,2\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{10}},-\\frac{3}{\\sqrt{10}},0\\right\\}, \\{0,0,1\\}, \\left\\{\\frac{3}{\\sqrt{10}},-\\frac{1}{\\sqrt{10}},0\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, -3, 0), (1, 3, 2), (0, -1, 2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 5 & 1 \\\\\n -2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{1}{3} & \\frac{1}{3} \\\\\n -\\frac{2}{3} & -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 1],\n [-2, -1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -4 & 9 & 6 \\\\\n 8 & 5 & -8 \\\\\n 1 & -10 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, 9, 6],\n [8, 5, -8],\n [1, -10, 5]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\sqrt{2} \\\\\n -\\sqrt{2} \\\\\n 2 \\sqrt{2} \\\\\n \\sqrt{2} \\\\\n -4 \\sqrt{2} \\\\\n -7 \\sqrt{2} \\\\\n 3 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\sqrt{2} \\\\\n 5 \\sqrt{2} \\\\\n -\\sqrt{2} \\\\\n -5 \\sqrt{2} \\\\\n 4 \\sqrt{2} \\\\\n 7 \\sqrt{2} \\\\\n -5 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-166$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [3*math.sqrt(2)],\n [-math.sqrt(2)],\n [2*math.sqrt(2)],\n [math.sqrt(2)],\n [-4*math.sqrt(2)],\n [-7*math.sqrt(2)],\n [3*math.sqrt(2)]])\nb = np.array([\n [3*math.sqrt(2)],\n [5*math.sqrt(2)],\n [-math.sqrt(2)],\n [-5*math.sqrt(2)],\n [4*math.sqrt(2)],\n [7*math.sqrt(2)],\n [-5*math.sqrt(2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -1 & -1 \\\\\n \\frac{11}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{22} \\left(-7-i \\sqrt{39}\\right),1\\right\\}, \\left\\{\\frac{1}{22} \\left(-7+i \\sqrt{39}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1],\n [(11/2), (5/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,2,5\\}, \\{2,-4,3\\}, \\{-4,-4,-1\\}}$.", - "Output Answer": [ - "$6 x+5 y-9 z+35=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, 2, 5],\n [2, -4, 3],\n [-4, -4, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 \\\\\n 9 \\\\\n 7 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [3],\n [9],\n [7],\n [-2]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{4 \\log (2),-2 \\log (2),-\\log (2)\\}, \\{-3 \\log (2),4 \\log (2),4 \\log (2)\\}, \\{-3 \\log (2),3 \\log (2),-4 \\log (2)\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{4}{\\sqrt{21}},-\\frac{2}{\\sqrt{21}},-\\frac{1}{\\sqrt{21}}\\right\\}, \\left\\{\\frac{11}{\\sqrt{665}},\\frac{12}{\\sqrt{665}},4 \\sqrt{\\frac{5}{133}}\\right\\}, \\left\\{\\frac{4}{\\sqrt{285}},\\frac{13}{\\sqrt{285}},-2 \\sqrt{\\frac{5}{57}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((4*math.log(2), -2*math.log(2), -math.log(2)), (-3*math.log(2), 4*math.log(2), 4*math.log(2)), (-3*math.log(2), 3*math.log(2), -4*math.log(2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -10 & 3 \\\\\n 4 & 9 \\\\\n -1 & -1 \\\\\n 4 & 3 \\\\\n 5 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, 3],\n [4, 9],\n [-1, -1],\n [4, 3],\n [5, 0]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & 0 \\\\\n -1 & -2 \\\\\n -2 & -2 \\\\\n -3 & -2 \\\\\n 1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.05 \\\\\n 1.55 \\\\\n -2.16 \\\\\n -0.22 \\\\\n -1. \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.714 \\\\\n -0.646 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0],\n [-1, -2],\n [-2, -2],\n [-3, -2],\n [1, 2]])\nb = np.array([\n [0.05],\n [1.55],\n [-2.16],\n [-0.22],\n [-1.]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8.761 \\\\\n 8.708 \\\\\n -3.734 \\\\\n -5.663 \\\\\n -0.906 \\\\\n -6.169 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4.664 \\\\\n 2.963 \\\\\n 4.754 \\\\\n -3.999 \\\\\n 3.78 \\\\\n 1.613 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$58.1827$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8.761],\n [8.708],\n [-3.734],\n [-5.663],\n [-0.906],\n [-6.169]])\nb = np.array([\n [4.664],\n [2.963],\n [4.754],\n [-3.999],\n [3.78],\n [1.613]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{8}{3} \\\\\n \\frac{3}{2} \\\\\n \\frac{35}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{20}{3} \\\\\n \\frac{1}{2} \\\\\n -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{65}{12} \\\\\n -\\frac{310}{9} \\\\\n \\frac{34}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(8/3)],\n [(3/2)],\n [(35/6)]])\nb = np.array([\n [-(20/3)],\n [(1/2)],\n [-(5/3)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -\\frac{4}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{16}{3} \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}+\\tan ^{-1}\\left(\\frac{27}{4}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-(4/3)]]).squeeze()\nb = np.array([\n [-(16/3)],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & -3 \\\\\n 9 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{9} \\left(-5-i \\sqrt{2}\\right),1\\right\\}, \\left\\{\\frac{1}{9} \\left(-5+i \\sqrt{2}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -3],\n [9, 6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -10 & \\frac{28}{5} & -\\frac{11}{5} & \\frac{36}{5} & \\frac{33}{5} \\\\\n -\\frac{9}{5} & \\frac{37}{5} & \\frac{42}{5} & 2 & \\frac{14}{5} \\\\\n \\frac{8}{5} & -\\frac{32}{5} & \\frac{21}{5} & \\frac{28}{5} & \\frac{17}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, (28/5), -(11/5), (36/5), (33/5)],\n [-(9/5), (37/5), (42/5), 2, (14/5)],\n [(8/5), -(32/5), (21/5), (28/5), (17/5)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{3}{25} & \\frac{74}{25} & -\\frac{51}{10} & \\frac{437}{50} \\\\\n \\frac{172}{25} & \\frac{433}{50} & -\\frac{661}{100} & -\\frac{9}{20} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{709}{100} & \\frac{134}{25} & -\\frac{15}{4} & -\\frac{427}{50} \\\\\n -\\frac{451}{100} & -\\frac{39}{10} & \\frac{799}{100} & -\\frac{393}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{697}{100} & \\frac{208}{25} & -\\frac{177}{20} & \\frac{1}{5} \\\\\n \\frac{237}{100} & \\frac{119}{25} & \\frac{69}{50} & -\\frac{831}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/25), (74/25), -(51/10), (437/50)],\n [(172/25), (433/50), -(661/100), -(9/20)]])\nb = np.array([\n [(709/100), (134/25), -(15/4), -(427/50)],\n [-(451/100), -(39/10), (799/100), -(393/50)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{4,-3,-1\\}, \\{3,-3,2\\}, \\{4,1,-4\\}}$.", - "Output Answer": [ - "$12 x+3 y+4 z-35=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, -3, -1],\n [3, -3, 2],\n [4, 1, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{5}{2},-4,\\frac{5}{2}\\right\\}, \\left\\{\\frac{7}{2},\\frac{5}{2},-\\frac{3}{2}\\right\\}, \\left\\{-\\frac{3}{2},-\\frac{9}{2},2\\right\\}}$.", - "Output Answer": [ - "$14 x-44 y-68 z-41=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(5/2), -4, (5/2)],\n [(7/2), (5/2), -(3/2)],\n [-(3/2), -(9/2), 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n \\frac{21}{8} \\\\\n \\frac{11}{4} \\\\\n 2 \\\\\n \\frac{31}{8} \\\\\n \\frac{19}{2} \\\\\n -\\frac{13}{4} \\\\\n \\frac{61}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [(21/8)],\n [(11/4)],\n [2],\n [(31/8)],\n [(19/2)],\n [-(13/4)],\n [(61/8)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{2} & 0 \\\\\n -1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2), 0],\n [-1, -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n \\frac{1}{2} \\\\\n -3 \\\\\n \\frac{3}{4} \\\\\n -\\frac{9}{4} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{3}{4} \\\\\n -\\frac{3}{2} \\\\\n -\\frac{5}{4} \\\\\n \\frac{3}{2} \\\\\n -\\frac{11}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{567}{908},-\\frac{567}{454},-\\frac{945}{908},\\frac{567}{454},-\\frac{2079}{908}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [(1/2)],\n [-3],\n [(3/4)],\n [-(9/4)]]).squeeze()\nb = np.array([\n [(3/4)],\n [-(3/2)],\n [-(5/4)],\n [(3/2)],\n [-(11/4)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -5 \\\\\n 8 \\\\\n 4 \\\\\n -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 9 \\\\\n 7 \\\\\n 10 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{298}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-5],\n [8],\n [4],\n [-4]])\nb = np.array([\n [3],\n [9],\n [7],\n [10],\n [-8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & \\frac{22}{3} & \\frac{26}{3} \\\\\n -7 & -\\frac{8}{3} & -\\frac{2}{3} \\\\\n 5 & 3 & \\frac{19}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.524,-0.418,1.\\}, \\{-0.758-1.337 i,-2.019+0.599 i,1.\\}, \\{-0.758+1.337 i,-2.019-0.599 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, (22/3), (26/3)],\n [-7, -(8/3), -(2/3)],\n [5, 3, (19/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & -\\frac{17}{2} \\\\\n 9 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{18} i \\left(\\sqrt{290}-4 i\\right),1\\right\\}, \\left\\{-\\frac{1}{18} i \\left(\\sqrt{290}+4 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(17/2)],\n [9, -2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & 1 & -3 & 2 & 3 \\\\\n 1 & 2 & 2 & 1 & -1 \\\\\n -2 & 1 & -2 & -3 & 2 \\\\\n 0 & -3 & 2 & 1 & -3 \\\\\n -1 & -2 & 2 & -2 & 0 \\\\\n -2 & -1 & 3 & -3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.85 \\\\\n 1.17 \\\\\n 2.97 \\\\\n -2.64 \\\\\n -0.74 \\\\\n 1.96 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.442 \\\\\n 0.958 \\\\\n -0.375 \\\\\n -1.178 \\\\\n -0.711 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, -3, 2, 3],\n [1, 2, 2, 1, -1],\n [-2, 1, -2, -3, 2],\n [0, -3, 2, 1, -3],\n [-1, -2, 2, -2, 0],\n [-2, -1, 3, -3, -2]])\nb = np.array([\n [-2.85],\n [1.17],\n [2.97],\n [-2.64],\n [-0.74],\n [1.96]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{16}{7} \\\\\n -\\frac{3}{7} \\\\\n -\\frac{11}{7} \\\\\n \\frac{3}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{240}{49} \\\\\n \\frac{45}{49} \\\\\n \\frac{165}{49} \\\\\n -\\frac{45}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(16/7)],\n [-(3/7)],\n [-(11/7)],\n [(3/7)]])\nb = np.array([\n [-(15/7)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -2 \\\\\n -6 \\\\\n 0 \\\\\n 9 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 2 \\\\\n -2 \\\\\n 3 \\\\\n -9 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{370}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-2],\n [-6],\n [0],\n [9],\n [-7]])\nb = np.array([\n [9],\n [2],\n [-2],\n [3],\n [-9],\n [-5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-3]])\nb = np.array([\n [-3],\n [5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -2 \\\\\n -\\frac{1}{2} \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{2 \\sqrt{2}}{3} \\\\\n -\\frac{1}{3 \\sqrt{2}} \\\\\n \\frac{1}{3 \\sqrt{2}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-2],\n [-(1/2)],\n [(1/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{2} & -\\frac{1}{2} \\\\\n -2 & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{17}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2), -(1/2)],\n [-2, (3/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-3 \\log (2),2 \\log (2),\\log (2)\\}, \\{3 \\log (2),-2 \\log (2),-3 \\log (2)\\}, \\{-4 \\log (2),\\log (2),3 \\log (2)\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{3}{\\sqrt{14}},\\sqrt{\\frac{2}{7}},\\frac{1}{\\sqrt{14}}\\right\\}, \\left\\{-\\frac{3}{\\sqrt{182}},\\sqrt{\\frac{2}{91}},-\\sqrt{\\frac{13}{14}}\\right\\}, \\left\\{-\\frac{2}{\\sqrt{13}},-\\frac{3}{\\sqrt{13}},0\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-3*math.log(2), 2*math.log(2), math.log(2)), (3*math.log(2), -2*math.log(2), -3*math.log(2)), (-4*math.log(2), math.log(2), 3*math.log(2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n -1 \\\\\n 2 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 2 \\\\\n 3 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{24}{19},-\\frac{24}{19},-\\frac{36}{19},\\frac{12}{19},-\\frac{12}{19},0\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-2],\n [-1],\n [2],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [-2],\n [2],\n [3],\n [-1],\n [1],\n [0]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{39}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2)]])\nb = np.array([\n [(3/2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{ccc}\n -4 & -7 & -6 \\\\\n -2 & -5 & -3 \\\\\n 6 & 13 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -6 & -\\frac{29}{2} & -\\frac{21}{2} \\\\\n -2 & -4 & -3 \\\\\n 8 & 18 & 13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [-4, -7, -6],\n [-2, -5, -3],\n [6, 13, 9]])\nprint(expm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{8} \\\\\n \\frac{15}{8} \\\\\n -\\frac{7}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{37}{4} \\\\\n \\frac{41}{8} \\\\\n \\frac{27}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1097}{64} \\\\\n \\frac{143}{16} \\\\\n \\frac{1069}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/8)],\n [(15/8)],\n [-(7/8)]])\nb = np.array([\n [-(37/4)],\n [(41/8)],\n [(27/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -2 \\\\\n -5 \\\\\n -7 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 3 \\\\\n 3 \\\\\n -5 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-45$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-2],\n [-5],\n [-7],\n [4]])\nb = np.array([\n [7],\n [3],\n [3],\n [-5],\n [-6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{32}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -7 & -9 & 5 \\\\\n 1 & -8 & -5 \\\\\n -9 & 6 & -6 \\\\\n 2 & -5 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{49}{32} & \\frac{63}{32} & -\\frac{35}{32} \\\\\n -\\frac{7}{32} & \\frac{7}{4} & \\frac{35}{32} \\\\\n \\frac{63}{32} & -\\frac{21}{16} & \\frac{21}{16} \\\\\n -\\frac{7}{16} & \\frac{35}{32} & -\\frac{21}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -9, 5],\n [1, -8, -5],\n [-9, 6, -6],\n [2, -5, 3]])\nprint(a * -(7/32))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -2 & 2 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2} & 1 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 2],\n [0, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-4, \\frac{5}{3}, -\\frac{14}{3}}$ to the plane $-\\frac{10 x}{3}+\\frac{5 y}{3}+3 z-\\frac{8}{3}=0$.", - "Output Answer": [ - "$\\frac{5}{3 \\sqrt{206}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -4, (5/3), -(14/3)\nplane = Poly(-((10*x)/3)+((5*y)/3)+3*z-(8/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${2, \\frac{9}{2}}$ to the line $3 x+4 y+4=0$.", - "Output Answer": [ - "$\\frac{28}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 2, (9/2)\nline = Poly(3*x+4*y+4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{4} & -\\frac{15}{2} \\\\\n -10 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{8} \\left(-13-\\sqrt{5529}\\right),\\frac{1}{8} \\left(\\sqrt{5529}-13\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/4), -(15/2)],\n [-10, -5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{3} \\\\\n \\frac{1}{3} \\\\\n \\frac{1}{3} \\\\\n 3 \\\\\n \\frac{25}{3} \\\\\n -\\frac{17}{3} \\\\\n \\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{6}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/3)],\n [(1/3)],\n [(1/3)],\n [3],\n [(25/3)],\n [-(17/3)],\n [(8/3)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{2} & \\frac{33}{4} & -5 \\\\\n -\\frac{13}{4} & -\\frac{37}{4} & -6 \\\\\n 4 & -\\frac{15}{4} & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.837,1.446,1.\\}, \\{-1.336-0.414 i,-0.227+0.106 i,1.\\}, \\{-1.336+0.414 i,-0.227-0.106 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/2), (33/4), -5],\n [-(13/4), -(37/4), -6],\n [4, -(15/4), (7/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 3 \\\\\n -3 \\\\\n 2 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [3],\n [-3],\n [2],\n [7]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & -7 & -9 \\\\\n -9 & -9 & 8 \\\\\n 5 & -2 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-12.025,-1.213,6.238\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -7, -9],\n [-9, -9, 8],\n [5, -2, -6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 3 & 3 & 3 & 0 & 3 \\\\\n -1 & 2 & 1 & 2 & 1 \\\\\n 2 & -2 & 2 & -1 & -2 \\\\\n -3 & 3 & -3 & 0 & -2 \\\\\n -2 & -2 & 1 & -2 & 0 \\\\\n 1 & -1 & -1 & 0 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.34 \\\\\n -1.69 \\\\\n 0.03 \\\\\n 2.49 \\\\\n -0.08 \\\\\n -2.26 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.049 \\\\\n 0.684 \\\\\n -0.204 \\\\\n -1.198 \\\\\n 0.07 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3, 3, 0, 3],\n [-1, 2, 1, 2, 1],\n [2, -2, 2, -1, -2],\n [-3, 3, -3, 0, -2],\n [-2, -2, 1, -2, 0],\n [1, -1, -1, 0, -2]])\nb = np.array([\n [1.34],\n [-1.69],\n [0.03],\n [2.49],\n [-0.08],\n [-2.26]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n -8 & 1 & 2 \\\\\n -9 & 4 & 6 \\\\\n 1 & 0 & 3 \\\\\n 9 & 3 & 3 \\\\\n 7 & 7 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 1, 2],\n [-9, 4, 6],\n [1, 0, 3],\n [9, 3, 3],\n [7, 7, -4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{41}{7} & \\frac{25}{7} & -\\frac{12}{7} & 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 0 & -\\frac{17}{7} & -\\frac{29}{7} & \\frac{29}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{41}{7} & \\frac{8}{7} & -\\frac{41}{7} & \\frac{64}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(41/7), (25/7), -(12/7), 5]])\nb = np.array([\n [0, -(17/7), -(29/7), (29/7)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{13}{2} & 1 \\\\\n \\frac{9}{2} & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{4} \\left(-1-\\sqrt{697}\\right),\\frac{1}{4} \\left(\\sqrt{697}-1\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/2), 1],\n [(9/2), 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2}-4 i & 4-5 i & \\frac{5}{2}+\\frac{5 i}{2} \\\\\n -\\frac{9}{2}-i & 1-\\frac{7 i}{2} & -2-\\frac{5 i}{2} \\\\\n -i & 1+\\frac{i}{2} & 1+2 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{145}{4}+12 i & -\\frac{121}{4}-\\frac{135 i}{4} & -\\frac{47}{4}-\\frac{5 i}{4} \\\\\n -\\frac{67}{4}+\\frac{137 i}{4} & -35+8 i & -\\frac{33}{2}-\\frac{63 i}{4} \\\\\n -6-\\frac{19 i}{4} & -\\frac{9}{4}-\\frac{9 i}{2} & -\\frac{5}{4}-2 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2)-4j, 4-5j, (5/2)+((5j)/2)],\n [-(9/2)- 1j, 1-((7j)/2), -2-((5j)/2)],\n [- 1j, 1+(1j/2), 1+2j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 0 & 0 & 2 & -1 & 0 \\\\\n 0 & 0 & 3 & -2 & 2 \\\\\n -1 & -1 & 3 & 0 & 3 \\\\\n 2 & 1 & -1 & 2 & -3 \\\\\n 2 & 3 & 0 & 0 & 1 \\\\\n -1 & -2 & 3 & 2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.75 \\\\\n -2.03 \\\\\n -1.43 \\\\\n -0.94 \\\\\n 1.95 \\\\\n -2.58 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2.256 \\\\\n 2.219 \\\\\n -0.366 \\\\\n 0.236 \\\\\n -0.156 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0, 2, -1, 0],\n [0, 0, 3, -2, 2],\n [-1, -1, 3, 0, 3],\n [2, 1, -1, 2, -3],\n [2, 3, 0, 0, 1],\n [-1, -2, 3, 2, -2]])\nb = np.array([\n [-0.75],\n [-2.03],\n [-1.43],\n [-0.94],\n [1.95],\n [-2.58]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -1 & -2 & 1 & 2 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -3 & -2 & -1 \\\\\n -2 & -1 & -2 \\\\\n -2 & -2 & 0 \\\\\n 3 & 1 & 2 \\\\\n -2 & 2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 9 & 6 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, 1, 2, 1]])\nb = np.array([\n [-3, -2, -1],\n [-2, -1, -2],\n [-2, -2, 0],\n [3, 1, 2],\n [-2, 2, -2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{2,-1,2\\}, \\{-1,-1,-2\\}, \\{0,-4,5\\}}$.", - "Output Answer": [ - "$12 x-17 y-9 z-23=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, -1, 2],\n [-1, -1, -2],\n [0, -4, 5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 4 & 7 & 0 \\\\\n -1 & -9 & -10 \\\\\n -9 & 0 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+4 x^2+74 x+369$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 7, 0],\n [-1, -9, -10],\n [-9, 0, 9]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{21}{e} \\\\\n \\frac{10}{e} \\\\\n \\frac{20}{e} \\\\\n -\\frac{23}{e} \\\\\n \\frac{23}{e} \\\\\n \\frac{1}{e} \\\\\n \\frac{10}{e} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{5}{e} \\\\\n -\\frac{16}{e} \\\\\n \\frac{9}{e} \\\\\n -\\frac{26}{e} \\\\\n \\frac{25}{e} \\\\\n -\\frac{13}{e} \\\\\n -\\frac{26}{e} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{2978}}{e}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(21/math.e)],\n [(10/math.e)],\n [(20/math.e)],\n [-(23/math.e)],\n [(23/math.e)],\n [(1/math.e)],\n [(10/math.e)]])\nb = np.array([\n [(5/math.e)],\n [-(16/math.e)],\n [(9/math.e)],\n [-(26/math.e)],\n [(25/math.e)],\n [-(13/math.e)],\n [-(26/math.e)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{19}{16} & \\frac{37}{4} \\\\\n -\\frac{71}{8} & \\frac{145}{16} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{31}{16} & -\\frac{145}{16} \\\\\n \\frac{109}{16} & \\frac{157}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{25}{8} & \\frac{293}{16} \\\\\n -\\frac{251}{16} & -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/16), (37/4)],\n [-(71/8), (145/16)]])\nb = np.array([\n [-(31/16), -(145/16)],\n [(109/16), (157/16)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{51}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{51}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(51/8)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{791}{100} \\\\\n \\frac{191}{25} \\\\\n \\frac{23}{50} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{9}{25} \\\\\n \\frac{39}{5} \\\\\n -\\frac{233}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{53473}{2500} \\\\\n \\frac{185959}{10000} \\\\\n \\frac{147369}{2500} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(791/100)],\n [(191/25)],\n [(23/50)]])\nb = np.array([\n [(9/25)],\n [(39/5)],\n [-(233/100)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{23}{5} & 5 & -\\frac{47}{10} \\\\\n \\frac{7}{2} & -\\frac{39}{10} & -\\frac{39}{10} \\\\\n -\\frac{1}{5} & 0 & \\frac{11}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{4290}{4267} & -\\frac{5500}{4267} & -\\frac{18915}{4267} \\\\\n -\\frac{3460}{4267} & -\\frac{5530}{4267} & -\\frac{17195}{4267} \\\\\n -\\frac{390}{4267} & -\\frac{500}{4267} & \\frac{220}{4267} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/5), 5, -(47/10)],\n [(7/2), -(39/10), -(39/10)],\n [-(1/5), 0, (11/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 0 \\\\\n -6 \\\\\n -8 \\\\\n 10 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -7 \\\\\n 0 \\\\\n -1 \\\\\n -8 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-100$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [0],\n [-6],\n [-8],\n [10],\n [-2]])\nb = np.array([\n [4],\n [-7],\n [0],\n [-1],\n [-8],\n [-4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 2 & 1 & -8 & 7 & -6 & -7 & 1 \\\\\n -6 & 10 & -2 & -8 & 9 & 0 & -1 \\\\\n 5 & -1 & 0 & 4 & -7 & 4 & 3 \\\\\n -6 & 8 & 6 & 1 & -6 & -10 & -2 \\\\\n -1 & 5 & 7 & 9 & -8 & 4 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & \\frac{39863}{15305} & \\frac{3959}{15305} \\\\\n 0 & 1 & 0 & 0 & 0 & \\frac{43993}{45915} & -\\frac{3467}{15305} \\\\\n 0 & 0 & 1 & 0 & 0 & \\frac{10196}{9183} & -\\frac{1557}{3061} \\\\\n 0 & 0 & 0 & 1 & 0 & \\frac{33784}{45915} & -\\frac{19836}{15305} \\\\\n 0 & 0 & 0 & 0 & 1 & \\frac{24068}{15305} & -\\frac{14571}{15305} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, 1, -8, 7, -6, -7, 1],\n [-6, 10, -2, -8, 9, 0, -1],\n [5, -1, 0, 4, -7, 4, 3],\n [-6, 8, 6, 1, -6, -10, -2],\n [-1, 5, 7, 9, -8, 4, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & 9 \\\\\n 5 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{3}{10} \\left(\\sqrt{21}-1\\right),1\\right\\}, \\left\\{-\\frac{3}{10} \\left(1+\\sqrt{21}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 9],\n [5, 9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{58}{7} & \\frac{39}{7} & -\\frac{30}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{9}{7} & \\frac{8}{7} & -\\frac{27}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{67}{7} & \\frac{47}{7} & -\\frac{57}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(58/7), (39/7), -(30/7)]])\nb = np.array([\n [-(9/7), (8/7), -(27/7)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{18}{5} & -\\frac{34}{5} & -\\frac{36}{5} \\\\\n -\\frac{23}{5} & \\frac{14}{5} & -\\frac{16}{5} \\\\\n \\frac{49}{5} & -\\frac{9}{5} & \\frac{19}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.017,-1.064,1.\\}, \\{-0.256-0.697 i,-0.482-0.379 i,1.\\}, \\{-0.256+0.697 i,-0.482+0.379 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(18/5), -(34/5), -(36/5)],\n [-(23/5), (14/5), -(16/5)],\n [(49/5), -(9/5), (19/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{4}{5} & -\\frac{34}{5} \\\\\n -\\frac{31}{5} & -\\frac{21}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(-25-\\sqrt{4505}\\right),\\frac{1}{10} \\left(\\sqrt{4505}-25\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/5), -(34/5)],\n [-(31/5), -(21/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & -1 & 2 \\\\\n 0 & 1 & -3 \\\\\n -\\frac{5}{2} & 1 & \\frac{5}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{5}{4} & -\\frac{3}{2} & 13 \\\\\n \\frac{15}{2} & -2 & -\\frac{21}{2} \\\\\n -\\frac{25}{2} & 6 & -\\frac{7}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), -1, 2],\n [0, 1, -3],\n [-(5/2), 1, (5/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 3+i & 4-3 i \\\\\n -3 i & -1-3 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -1-6 i & 2-14 i \\\\\n -6-6 i & -17-6 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3+ 1j, 4-3j],\n [-3j, -1-3j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -2 \\\\\n 6 \\\\\n -6 \\\\\n -5 \\\\\n -7 \\\\\n -9 \\\\\n 9 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 9 \\\\\n -4 \\\\\n 0 \\\\\n 3 \\\\\n 8 \\\\\n -3 \\\\\n -2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10 \\sqrt{11}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-2],\n [6],\n [-6],\n [-5],\n [-7],\n [-9],\n [9],\n [-6]])\nb = np.array([\n [-10],\n [9],\n [-4],\n [0],\n [3],\n [8],\n [-3],\n [-2],\n [0]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{20}{3} & -\\frac{10}{3} \\\\\n -\\frac{23}{3} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{49 x}{6}-\\frac{140}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(20/3), -(10/3)],\n [-(23/3), (3/2)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & 7 \\\\\n -5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{5} \\left(-3-i \\sqrt{26}\\right),1\\right\\}, \\left\\{\\frac{1}{5} \\left(-3+i \\sqrt{26}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 7],\n [-5, -4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${4, 0}$ to the line $-2 x-4=0$.", - "Output Answer": [ - "$6$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 4, 0\nline = Poly(-2*x-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{61}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{37}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(61/7)]])\nb = np.array([\n [-(37/7)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -5 & 4 & 3 & 9 \\\\\n -9 & 7 & 10 & 0 \\\\\n 8 & 9 & 0 & 2 \\\\\n -3 & 7 & 4 & 9 \\\\\n 9 & 2 & 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, 4, 3, 9],\n [-9, 7, 10, 0],\n [8, 9, 0, 2],\n [-3, 7, 4, 9],\n [9, 2, 0, 2]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{15}{2}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & -4 \\\\\n -8 & -9 \\\\\n -7 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -15 & 30 \\\\\n 60 & \\frac{135}{2} \\\\\n \\frac{105}{2} & \\frac{75}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -4],\n [-8, -9],\n [-7, -5]])\nprint(a * -(15/2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{9}{100}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -9 & -4 & 3 \\\\\n -6 & 5 & 8 \\\\\n -1 & -5 & -1 \\\\\n -2 & -8 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{81}{100} & \\frac{9}{25} & -\\frac{27}{100} \\\\\n \\frac{27}{50} & -\\frac{9}{20} & -\\frac{18}{25} \\\\\n \\frac{9}{100} & \\frac{9}{20} & \\frac{9}{100} \\\\\n \\frac{9}{50} & \\frac{18}{25} & -\\frac{27}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -4, 3],\n [-6, 5, 8],\n [-1, -5, -1],\n [-2, -8, 6]])\nprint(a * -(9/100))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{3}{4} & -1 & -\\frac{53}{8} & \\frac{15}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{33}{8} & 0 & \\frac{17}{4} & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{39}{8} & -1 & -\\frac{87}{8} & \\frac{79}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/4), -1, -(53/8), (15/8)]])\nb = np.array([\n [-(33/8), 0, (17/4), -8]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -6 \\\\\n 6 \\\\\n 3 \\\\\n -4 \\\\\n -5 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -3 \\\\\n 8 \\\\\n 8 \\\\\n 6 \\\\\n -3 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{354}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-6],\n [6],\n [3],\n [-4],\n [-5],\n [-9]])\nb = np.array([\n [6],\n [-3],\n [8],\n [8],\n [6],\n [-3],\n [5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{19}{5} & \\frac{17}{10} \\\\\n 4 & -\\frac{29}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{211}{50}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/5), (17/10)],\n [4, -(29/10)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{21}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-(3/2)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -9 & 1 & -5 \\\\\n -4 & -7 & -6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 8 & 0 & -7 \\\\\n -4 & 3 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -17 & 1 & 2 \\\\\n 0 & -10 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 1, -5],\n [-4, -7, -6]])\nb = np.array([\n [8, 0, -7],\n [-4, 3, -1]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{61}{7} \\\\\n \\frac{37}{7} \\\\\n \\frac{29}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{41}{7} \\\\\n -\\frac{26}{7} \\\\\n -\\frac{23}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{97}{49} \\\\\n \\frac{214}{49} \\\\\n -\\frac{69}{49} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(61/7)],\n [(37/7)],\n [(29/7)]])\nb = np.array([\n [-(41/7)],\n [-(26/7)],\n [-(23/7)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{12}{5} & -\\frac{7}{5} & -\\frac{37}{5} \\\\\n \\frac{9}{5} & \\frac{8}{5} & -\\frac{38}{5} \\\\\n \\frac{16}{5} & \\frac{22}{5} & \\frac{48}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-1.3,5.05\\, -5.979 i,5.05\\, +5.979 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(12/5), -(7/5), -(37/5)],\n [(9/5), (8/5), -(38/5)],\n [(16/5), (22/5), (48/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{31}{10} & \\frac{11}{5} \\\\\n -\\frac{19}{10} & -\\frac{9}{2} \\\\\n -\\frac{47}{10} & -\\frac{42}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{29}{10} & -\\frac{67}{10} \\\\\n \\frac{4}{5} & \\frac{71}{10} \\\\\n -\\frac{5}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{5} & -\\frac{9}{2} \\\\\n -\\frac{11}{10} & \\frac{13}{5} \\\\\n -\\frac{36}{5} & -\\frac{79}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(31/10), (11/5)],\n [-(19/10), -(9/2)],\n [-(47/10), -(42/5)]])\nb = np.array([\n [(29/10), -(67/10)],\n [(4/5), (71/10)],\n [-(5/2), (1/2)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{4} & -7 \\\\\n \\frac{25}{4} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{2} & 1 \\\\\n -8 & -\\frac{17}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{19}{4} & -8 \\\\\n \\frac{57}{4} & \\frac{11}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/4), -7],\n [(25/4), -(3/2)]])\nb = np.array([\n [-(9/2), 1],\n [-8, -(17/4)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$e^\\left(\n\\begin{array}{ccc}\n -39 & -18 & -31 \\\\\n 63 & 30 & 51 \\\\\n 12 & 5 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{61}{2} & -\\frac{29}{2} & -25 \\\\\n \\frac{171}{2} & \\frac{83}{2} & 69 \\\\\n -\\frac{21}{2} & -\\frac{11}{2} & -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom scipy.linalg import expm\n\na = np.array([\n [-39, -18, -31],\n [63, 30, 51],\n [12, 5, 9]])\nprint(expm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 0 \\\\\n 1 & -3 \\\\\n 2 & 1 \\\\\n 3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.93 \\\\\n 0.92 \\\\\n 2.9 \\\\\n -0.19 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.032 \\\\\n 0.053 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 0],\n [1, -3],\n [2, 1],\n [3, -2]])\nb = np.array([\n [-1.93],\n [0.92],\n [2.9],\n [-0.19]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-10]])\nb = np.array([\n [-4],\n [-3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & \\frac{3}{2} \\\\\n 5 & \\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{21}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, (3/2)],\n [5, (9/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [0]])\nb = np.array([\n [-9],\n [-1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{9}{8} & -\\frac{41}{8} & -\\frac{19}{4} \\\\\n -\\frac{51}{8} & -\\frac{29}{8} & \\frac{29}{8} \\\\\n \\frac{11}{8} & -\\frac{13}{8} & -\\frac{45}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{39}{4} & -\\frac{9}{8} & \\frac{25}{8} \\\\\n -6 & \\frac{39}{8} & -\\frac{29}{4} \\\\\n -8 & -\\frac{7}{8} & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{87}{8} & -\\frac{25}{4} & -\\frac{13}{8} \\\\\n -\\frac{99}{8} & \\frac{5}{4} & -\\frac{29}{8} \\\\\n -\\frac{53}{8} & -\\frac{5}{2} & -\\frac{109}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/8), -(41/8), -(19/4)],\n [-(51/8), -(29/8), (29/8)],\n [(11/8), -(13/8), -(45/8)]])\nb = np.array([\n [-(39/4), -(9/8), (25/8)],\n [-6, (39/8), -(29/4)],\n [-8, -(7/8), -8]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & 1 & -1 & -1 & 2 \\\\\n -2 & 2 & 2 & 1 & 2 \\\\\n 1 & -1 & -1 & 0 & 0 \\\\\n 0 & -1 & 0 & 2 & 0 \\\\\n 0 & 0 & 2 & 1 & 2 \\\\\n 0 & 1 & 0 & 1 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.27 \\\\\n 0.46 \\\\\n -2.05 \\\\\n 0.71 \\\\\n 1.98 \\\\\n -1.43 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.297 \\\\\n -1.302 \\\\\n 0.544 \\\\\n -0.464 \\\\\n 0.426 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, -1, -1, 2],\n [-2, 2, 2, 1, 2],\n [1, -1, -1, 0, 0],\n [0, -1, 0, 2, 0],\n [0, 0, 2, 1, 2],\n [0, 1, 0, 1, 0]])\nb = np.array([\n [1.27],\n [0.46],\n [-2.05],\n [0.71],\n [1.98],\n [-1.43]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [7]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n 5 & -1 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -1, 9]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & -9 & -6 \\\\\n 6 & -7 & 1 \\\\\n 9 & 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-5.862,2.431\\, -8.977 i,2.431\\, +8.977 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -9, -6],\n [6, -7, 1],\n [9, 1, -1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -7 & -1 & 7 & -9 \\\\\n -3 & -7 & 8 & -2 \\\\\n 7 & -4 & -2 & 3 \\\\\n -1 & 5 & -3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -1, 7, -9],\n [-3, -7, 8, -2],\n [7, -4, -2, 3],\n [-1, 5, -3, 3]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -9 \\\\\n 7 \\\\\n -3 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-9],\n [7],\n [-3],\n [-6]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & -\\frac{5}{8} & \\frac{13}{8} \\\\\n 2 & -\\frac{3}{8} & \\frac{9}{4} \\\\\n -\\frac{1}{8} & -\\frac{3}{8} & -\\frac{11}{4} \\\\\n \\frac{5}{4} & \\frac{11}{4} & -\\frac{15}{8} \\\\\n -\\frac{5}{2} & \\frac{5}{4} & -\\frac{5}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 3 & -\\frac{11}{4} & \\frac{21}{8} & \\frac{15}{8} & 3 \\\\\n \\frac{7}{4} & 0 & -\\frac{1}{4} & -\\frac{1}{4} & -\\frac{11}{4} \\\\\n -\\frac{1}{4} & -\\frac{9}{8} & \\frac{21}{8} & 1 & \\frac{17}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 6 & -\\frac{557}{64} & \\frac{703}{64} & \\frac{207}{32} & \\frac{811}{64} \\\\\n \\frac{153}{32} & -\\frac{257}{32} & \\frac{45}{4} & \\frac{195}{32} & \\frac{189}{16} \\\\\n -\\frac{11}{32} & \\frac{55}{16} & -\\frac{477}{64} & -\\frac{185}{64} & -\\frac{83}{16} \\\\\n \\frac{289}{32} & -\\frac{85}{64} & -\\frac{149}{64} & -\\frac{7}{32} & -\\frac{499}{64} \\\\\n -\\frac{165}{32} & \\frac{485}{64} & -\\frac{545}{64} & -\\frac{45}{8} & -\\frac{785}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), -(5/8), (13/8)],\n [2, -(3/8), (9/4)],\n [-(1/8), -(3/8), -(11/4)],\n [(5/4), (11/4), -(15/8)],\n [-(5/2), (5/4), -(5/8)]])\nb = np.array([\n [3, -(11/4), (21/8), (15/8), 3],\n [(7/4), 0, -(1/4), -(1/4), -(11/4)],\n [-(1/4), -(9/8), (21/8), 1, (17/8)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{3} \\\\\n \\frac{1}{3} \\\\\n -\\frac{2}{3} \\\\\n -\\frac{13}{3} \\\\\n \\frac{4}{3} \\\\\n -\\frac{29}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4 \\sqrt{\\frac{22}{3}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3)],\n [(1/3)],\n [-(2/3)],\n [-(13/3)],\n [(4/3)],\n [-(29/3)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{4}{5} & -\\frac{1}{5} \\\\\n -\\frac{22}{5} & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{58}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/5), -(1/5)],\n [-(22/5), 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{16}{7} \\\\\n -3 \\\\\n -\\frac{11}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 1 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{157}{7} \\\\\n 34 \\\\\n -\\frac{226}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(16/7)],\n [-3],\n [-(11/7)]])\nb = np.array([\n [-10],\n [1],\n [8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 0 & 0 & 1 & -3 \\\\\n -2 & 1 & 1 & 1 \\\\\n 3 & 1 & 1 & 2 \\\\\n 2 & -1 & -1 & -2 \\\\\n 1 & -3 & 3 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -1 & -1 \\\\\n -1 & -2 \\\\\n -1 & 1 \\\\\n 2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -7 & 7 \\\\\n 2 & -1 \\\\\n -1 & -8 \\\\\n -4 & 3 \\\\\n 1 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0, 1, -3],\n [-2, 1, 1, 1],\n [3, 1, 1, 2],\n [2, -1, -1, -2],\n [1, -3, 3, 1]])\nb = np.array([\n [-1, -1],\n [-1, -2],\n [-1, 1],\n [2, -2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{5,-1,-4\\}, \\{-4,5,-2\\}, \\{4,-4,-2\\}}$.", - "Output Answer": [ - "$18 x+16 y+33 z+58=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [5, -1, -4],\n [-4, 5, -2],\n [4, -4, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & -9 \\\\\n -9 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-14 x-36$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -9],\n [-9, 5]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -6 & -8 & 0 \\\\\n -9 & 2 & 1 \\\\\n -7 & -4 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-10 x^2+56 x+536$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -8, 0],\n [-9, 2, 1],\n [-7, -4, -6]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & -\\frac{19}{3} \\\\\n \\frac{1}{3} & \\frac{13}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{6} \\left(37-3 \\sqrt{5}\\right),\\frac{1}{6} \\left(37+3 \\sqrt{5}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -(19/3)],\n [(1/3), (13/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n -\\frac{15}{16} \\\\\n -\\frac{125}{16} \\\\\n -\\frac{73}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{253}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2)],\n [-(15/16)],\n [-(125/16)],\n [-(73/16)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & 3 & -3 \\\\\n 2 & -1 & -3 \\\\\n 3 & -1 & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -2 & -3 & -3 \\\\\n -13 & 10 & 0 \\\\\n -8 & 11 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, -3],\n [2, -1, -3],\n [3, -1, -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{141}{16} & \\frac{55}{16} \\\\\n \\frac{19}{16} & \\frac{145}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{143 x}{8}+\\frac{2425}{32}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(141/16), (55/16)],\n [(19/16), (145/16)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 2 \\\\\n -4 \\\\\n 10 \\\\\n 0 \\\\\n 4 \\\\\n 6 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -7 \\\\\n 4 \\\\\n -4 \\\\\n -4 \\\\\n 8 \\\\\n 10 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{398}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [2],\n [-4],\n [10],\n [0],\n [4],\n [6],\n [-1]])\nb = np.array([\n [-9],\n [-7],\n [4],\n [-4],\n [-4],\n [8],\n [10],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{1,2,3\\}, \\{-1,2,-3\\}, \\{0,2,-1\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{14}},\\sqrt{\\frac{2}{7}},\\frac{3}{\\sqrt{14}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{35}},\\sqrt{\\frac{5}{7}},-\\frac{3}{\\sqrt{35}}\\right\\}, \\left\\{\\frac{3}{\\sqrt{10}},0,-\\frac{1}{\\sqrt{10}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((1, 2, 3), (-1, 2, -3), (0, 2, -1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 5 & 6 & -3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 2 & 2 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 3 & 4 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 6, -3]])\nb = np.array([\n [2, 2, 1]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{19}{6} & 3 & \\frac{19}{3} & \\frac{29}{6} \\\\\n -\\frac{5}{2} & \\frac{26}{3} & \\frac{43}{6} & \\frac{19}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{26}{3} & -\\frac{8}{3} & \\frac{25}{6} & \\frac{25}{3} \\\\\n -\\frac{26}{3} & -\\frac{17}{2} & \\frac{22}{3} & \\frac{16}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{71}{6} & \\frac{17}{3} & \\frac{13}{6} & -\\frac{7}{2} \\\\\n \\frac{37}{6} & \\frac{103}{6} & -\\frac{1}{6} & \\frac{25}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/6), 3, (19/3), (29/6)],\n [-(5/2), (26/3), (43/6), (19/2)]])\nb = np.array([\n [-(26/3), -(8/3), (25/6), (25/3)],\n [-(26/3), -(17/2), (22/3), (16/3)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 4 & 4 & 1 \\\\\n 4 & 5 & -3 \\\\\n 5 & 2 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{26}{37} & \\frac{14}{37} & \\frac{17}{37} \\\\\n \\frac{31}{37} & -\\frac{11}{37} & -\\frac{16}{37} \\\\\n \\frac{17}{37} & -\\frac{12}{37} & -\\frac{4}{37} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 4, 1],\n [4, 5, -3],\n [5, 2, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 3 & 0 & 0 & -3 \\\\\n -2 & 0 & -2 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 9 \\\\\n -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 0, 0, -3],\n [-2, 0, -2, 0]])\nb = np.array([\n [3],\n [0],\n [-1],\n [0]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{4} & \\frac{39}{4} \\\\\n \\frac{39}{4} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{8} \\left(-7-\\sqrt{6205}\\right),\\frac{1}{8} \\left(\\sqrt{6205}-7\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/4), (39/4)],\n [(39/4), (1/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -4 \\\\\n 4 \\\\\n 7 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-4],\n [4],\n [7],\n [-2]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & 1 & -5 \\\\\n 2 & 2 & 4 \\\\\n -3 & -1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-16$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 1, -5],\n [2, 2, 4],\n [-3, -1, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{4}{7}, \\frac{33}{7}}$ to the line $\\frac{30 x}{7}-\\frac{25 y}{7}-2=0$.", - "Output Answer": [ - "$\\frac{803}{35 \\sqrt{61}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (4/7), (33/7)\nline = Poly(((30*x)/7)-((25*y)/7)-2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & -2 \\\\\n 9 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-9-i \\sqrt{47}\\right),\\frac{1}{2} \\left(-9+i \\sqrt{47}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -2],\n [9, -2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{8} & -\\frac{9}{8} & -\\frac{35}{8} \\\\\n -\\frac{5}{2} & -\\frac{13}{4} & -\\frac{37}{8} \\\\\n \\frac{23}{8} & \\frac{15}{8} & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{970}{189} & \\frac{110}{63} & \\frac{1154}{189} \\\\\n \\frac{34}{63} & -\\frac{10}{21} & \\frac{2}{63} \\\\\n -\\frac{596}{189} & -\\frac{52}{63} & -\\frac{628}{189} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/8), -(9/8), -(35/8)],\n [-(5/2), -(13/4), -(37/8)],\n [(23/8), (15/8), 5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & -7 \\\\\n -8 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+13 x-14$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -7],\n [-8, -7]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 9 \\\\\n 4 \\\\\n -9 \\\\\n 9 \\\\\n 6 \\\\\n -6 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 2 \\\\\n 1 \\\\\n 9 \\\\\n 3 \\\\\n -5 \\\\\n -5 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{718}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [9],\n [4],\n [-9],\n [9],\n [6],\n [-6],\n [5]])\nb = np.array([\n [0],\n [2],\n [1],\n [9],\n [3],\n [-5],\n [-5],\n [-8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n \\frac{12}{5} & -\\frac{13}{5} & 0 & -\\frac{67}{10} \\\\\n \\frac{6}{5} & \\frac{6}{5} & -8 & -\\frac{53}{10} \\\\\n \\frac{37}{10} & -\\frac{48}{5} & -\\frac{42}{5} & -\\frac{3}{5} \\\\\n \\frac{61}{10} & \\frac{1}{2} & 0 & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(12/5), -(13/5), 0, -(67/10)],\n [(6/5), (6/5), -8, -(53/10)],\n [(37/10), -(48/5), -(42/5), -(3/5)],\n [(61/10), (1/2), 0, (7/2)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -2 \\\\\n -2 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{\\sqrt{19}} \\\\\n -\\frac{2}{\\sqrt{19}} \\\\\n -\\frac{2}{\\sqrt{19}} \\\\\n \\frac{1}{\\sqrt{19}} \\\\\n 0 \\\\\n -\\frac{1}{\\sqrt{19}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-2],\n [-2],\n [1],\n [0],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{9}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -6 & -1 & -10 & -4 \\\\\n 4 & -8 & -5 & -1 \\\\\n 1 & 2 & 5 & 9 \\\\\n 5 & 10 & 5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{10}{3} & \\frac{5}{9} & \\frac{50}{9} & \\frac{20}{9} \\\\\n -\\frac{20}{9} & \\frac{40}{9} & \\frac{25}{9} & \\frac{5}{9} \\\\\n -\\frac{5}{9} & -\\frac{10}{9} & -\\frac{25}{9} & -5 \\\\\n -\\frac{25}{9} & -\\frac{50}{9} & -\\frac{25}{9} & \\frac{20}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -1, -10, -4],\n [4, -8, -5, -1],\n [1, 2, 5, 9],\n [5, 10, 5, -4]])\nprint(a * -(5/9))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{97}{10} \\\\\n -\\frac{19}{10} \\\\\n \\frac{11}{10} \\\\\n \\frac{41}{5} \\\\\n \\frac{24}{5} \\\\\n -\\frac{7}{5} \\\\\n -\\frac{7}{10} \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{4891}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(97/10)],\n [-(19/10)],\n [(11/10)],\n [(41/5)],\n [(24/5)],\n [-(7/5)],\n [-(7/10)],\n [-2]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & 7 \\\\\n 5 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{5} \\left(-8-3 \\sqrt{11}\\right),1\\right\\}, \\left\\{\\frac{1}{5} \\left(3 \\sqrt{11}-8\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 7],\n [5, 8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & -1 \\\\\n 1 & 1 \\\\\n 3 & 0 \\\\\n 1 & 1 \\\\\n 2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.46 \\\\\n -0.47 \\\\\n -0.54 \\\\\n 1.01 \\\\\n -0.5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.203 \\\\\n 0.19 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1],\n [1, 1],\n [3, 0],\n [1, 1],\n [2, -3]])\nb = np.array([\n [-1.46],\n [-0.47],\n [-0.54],\n [1.01],\n [-0.5]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -3 & 0 & 4 & -1 & -10 & 4 \\\\\n -6 & 3 & 0 & 10 & -7 & 1 \\\\\n 3 & 2 & -10 & 3 & 5 & 8 \\\\\n 4 & -4 & -2 & -3 & -1 & -5 \\\\\n 10 & -6 & 2 & -8 & 1 & -6 \\\\\n -2 & 10 & -10 & -7 & 2 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 0, 4, -1, -10, 4],\n [-6, 3, 0, 10, -7, 1],\n [3, 2, -10, 3, 5, 8],\n [4, -4, -2, -3, -1, -5],\n [10, -6, 2, -8, 1, -6],\n [-2, 10, -10, -7, 2, 7]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{7}{5} & \\frac{24}{5} & 5 \\\\\n -\\frac{21}{5} & -\\frac{7}{5} & \\frac{12}{5} \\\\\n -\\frac{44}{5} & -\\frac{14}{5} & \\frac{46}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1.251,-1.086,1.\\}, \\{0.484\\, -0.818 i,0.34\\, +0.223 i,1.\\}, \\{0.484\\, +0.818 i,0.34\\, -0.223 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/5), (24/5), 5],\n [-(21/5), -(7/5), (12/5)],\n [-(44/5), -(14/5), (46/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $3$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & 7 & -10 \\\\\n 3 & -8 & 7 \\\\\n 3 & 6 & 6 \\\\\n -7 & -9 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 3 & 21 & -30 \\\\\n 9 & -24 & 21 \\\\\n 9 & 18 & 18 \\\\\n -21 & -27 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 7, -10],\n [3, -8, 7],\n [3, 6, 6],\n [-7, -9, -1]])\nprint(a * 3)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -10 & -6 & 9 \\\\\n -2 & 8 & -2 \\\\\n 7 & -8 & 3 \\\\\n 1 & -1 & 8 \\\\\n 0 & 10 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, -6, 9],\n [-2, 8, -2],\n [7, -8, 3],\n [1, -1, 8],\n [0, 10, -6]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -\\frac{29}{16} \\\\\n -\\frac{5}{8} \\\\\n -\\frac{17}{16} \\\\\n -\\frac{119}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(29/16)],\n [-(5/8)],\n [-(17/16)],\n [-(119/16)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{24}{5}, 3, 0}$ to the plane $\\frac{14 x}{5}+\\frac{22 y}{5}-\\frac{24 z}{5}+\\frac{23}{5}=0$.", - "Output Answer": [ - "$\\frac{109}{10 \\sqrt{314}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(24/5), 3, 0\nplane = Poly(((14*x)/5)+((22*y)/5)-((24*z)/5)+(23/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{2}{\\sqrt{35}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [0],\n [0],\n [-1],\n [1],\n [0],\n [-1],\n [0],\n [0]]).squeeze()\nb = np.array([\n [1],\n [-1],\n [1],\n [0],\n [-1],\n [0],\n [0],\n [-1],\n [1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{15}{8} & -\\frac{11}{4} & \\frac{9}{4} & -2 & \\frac{21}{8} \\\\\n \\frac{3}{8} & \\frac{7}{8} & \\frac{17}{8} & \\frac{7}{8} & 2 \\\\\n -\\frac{5}{2} & \\frac{23}{8} & 1 & -\\frac{7}{4} & -\\frac{11}{4} \\\\\n -\\frac{5}{8} & \\frac{3}{8} & -\\frac{13}{8} & \\frac{17}{8} & -\\frac{7}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{13}{8} \\\\\n \\frac{11}{8} \\\\\n \\frac{3}{2} \\\\\n \\frac{7}{4} \\\\\n -\\frac{15}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{95}{8} \\\\\n \\frac{89}{32} \\\\\n \\frac{223}{64} \\\\\n \\frac{65}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/8), -(11/4), (9/4), -2, (21/8)],\n [(3/8), (7/8), (17/8), (7/8), 2],\n [-(5/2), (23/8), 1, -(7/4), -(11/4)],\n [-(5/8), (3/8), -(13/8), (17/8), -(7/4)]])\nb = np.array([\n [(13/8)],\n [(11/8)],\n [(3/2)],\n [(7/4)],\n [-(15/8)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 0 & -6 & 1 \\\\\n 8 & -2 & -7 \\\\\n 1 & -9 & -3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 4 & -9 & 5 \\\\\n -5 & -5 & 5 \\\\\n -8 & -5 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -4 & 3 & -4 \\\\\n 13 & 3 & -12 \\\\\n 9 & -4 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -6, 1],\n [8, -2, -7],\n [1, -9, -3]])\nb = np.array([\n [4, -9, 5],\n [-5, -5, 5],\n [-8, -5, -2]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{0,-2,3\\}, \\{-1,-2,-4\\}, \\{2,3,2\\}}$.", - "Output Answer": [ - "$7 x-3 y-z-3=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, -2, 3],\n [-1, -2, -4],\n [2, 3, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{4} & -2 & -\\frac{47}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/4), -2, -(47/8)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & 4 & 0 \\\\\n -1 & -\\frac{5}{2} & 8 \\\\\n 9 & 0 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-7.082-5.663 i,-7.082+5.663 i,2.663\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 4, 0],\n [-1, -(5/2), 8],\n [9, 0, -6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{14}{5} \\\\\n \\frac{8}{5} \\\\\n \\frac{3}{2} \\\\\n \\frac{27}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 14 \\sqrt{\\frac{2}{997}} \\\\\n 8 \\sqrt{\\frac{2}{997}} \\\\\n \\frac{15}{\\sqrt{1994}} \\\\\n \\frac{27}{\\sqrt{1994}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/5)],\n [(8/5)],\n [(3/2)],\n [(27/10)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{4} & \\frac{29}{8} \\\\\n -\\frac{43}{8} & -\\frac{9}{2} \\\\\n -\\frac{29}{8} & -\\frac{47}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{31}{4} & -1 \\\\\n -\\frac{61}{8} & \\frac{17}{4} \\\\\n -\\frac{49}{8} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -10 & \\frac{21}{8} \\\\\n -13 & -\\frac{1}{4} \\\\\n -\\frac{39}{4} & -\\frac{43}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/4), (29/8)],\n [-(43/8), -(9/2)],\n [-(29/8), -(47/8)]])\nb = np.array([\n [-(31/4), -1],\n [-(61/8), (17/4)],\n [-(49/8), (1/2)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -4 & -6 & 9 & 9 \\\\\n -3 & -8 & 4 & -9 \\\\\n 2 & -9 & 0 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 0 & 5 & -6 & -7 \\\\\n -10 & 2 & 9 & 2 \\\\\n -3 & -5 & -6 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -4 & -1 & 3 & 2 \\\\\n -13 & -6 & 13 & -7 \\\\\n -1 & -14 & -6 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -6, 9, 9],\n [-3, -8, 4, -9],\n [2, -9, 0, 2]])\nb = np.array([\n [0, 5, -6, -7],\n [-10, 2, 9, 2],\n [-3, -5, -6, 5]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 1 \\\\\n 2 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 6 \\\\\n -1 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{11}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [1],\n [2],\n [4]])\nb = np.array([\n [2],\n [6],\n [-1],\n [-3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{587}{100} \\\\\n \\frac{59}{20} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{539}{100} \\\\\n -\\frac{189}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{12}{25} \\\\\n -\\frac{83}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(587/100)],\n [(59/20)]])\nb = np.array([\n [-(539/100)],\n [-(189/50)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${0, -\\frac{24}{5}, 0}$ to the plane $\\frac{19 x}{5}+\\frac{24 y}{5}+5 z=0$.", - "Output Answer": [ - "$\\frac{288 \\sqrt{\\frac{2}{781}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 0, -(24/5), 0\nplane = Poly(((19*x)/5)+((24*y)/5)+5*z, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{5} \\\\\n \\frac{13}{5} \\\\\n 0 \\\\\n \\frac{9}{10} \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -7 \\sqrt{\\frac{2}{589}} \\\\\n 13 \\sqrt{\\frac{2}{589}} \\\\\n 0 \\\\\n \\frac{9}{\\sqrt{1178}} \\\\\n \\frac{15}{\\sqrt{1178}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/5)],\n [(13/5)],\n [0],\n [(9/10)],\n [(3/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{19}{7}, 1}$ to the line $\\frac{26 x}{7}+\\frac{13 y}{7}-4=0$.", - "Output Answer": [ - "$\\frac{599}{91 \\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(19/7), 1\nline = Poly(((26*x)/7)+((13*y)/7)-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & -\\frac{5}{2} \\\\\n -\\frac{37}{4} & -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{4} \\left(-15-\\sqrt{419}\\right),\\frac{1}{4} \\left(\\sqrt{419}-15\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -(5/2)],\n [-(37/4), -(11/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-2$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -9 & 0 & 5 \\\\\n -7 & -6 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 18 & 0 & -10 \\\\\n 14 & 12 & -18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 0, 5],\n [-7, -6, 9]])\nprint(a * -2)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -3 & 2 & -3 & 1 & 0 \\\\\n -2 & 0 & 1 & -3 & -3 \\\\\n -2 & 3 & 0 & 3 & -2 \\\\\n 0 & -2 & 3 & -1 & -1 \\\\\n -3 & -1 & 1 & 1 & 1 \\\\\n -1 & 3 & 1 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.03 \\\\\n -0.57 \\\\\n -0.1 \\\\\n 1.34 \\\\\n -0.65 \\\\\n 0.16 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.347 \\\\\n 0.068 \\\\\n 0.46 \\\\\n 0.117 \\\\\n -0.028 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2, -3, 1, 0],\n [-2, 0, 1, -3, -3],\n [-2, 3, 0, 3, -2],\n [0, -2, 3, -1, -1],\n [-3, -1, 1, 1, 1],\n [-1, 3, 1, -1, 2]])\nb = np.array([\n [-2.03],\n [-0.57],\n [-0.1],\n [1.34],\n [-0.65],\n [0.16]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 0 & 1 & -1 & 0 & -3 \\\\\n 2 & 0 & -2 & -2 & -1 \\\\\n -1 & 2 & 3 & 0 & 2 \\\\\n 1 & 1 & -1 & 2 & 0 \\\\\n -2 & 0 & 0 & -2 & -3 \\\\\n -2 & 3 & -3 & -1 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.3 \\\\\n -2.18 \\\\\n 2.22 \\\\\n -0.51 \\\\\n -1.05 \\\\\n 2.37 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.367 \\\\\n 0.83 \\\\\n 0.18 \\\\\n 0.395 \\\\\n -0.095 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, -1, 0, -3],\n [2, 0, -2, -2, -1],\n [-1, 2, 3, 0, 2],\n [1, 1, -1, 2, 0],\n [-2, 0, 0, -2, -3],\n [-2, 3, -3, -1, 1]])\nb = np.array([\n [2.3],\n [-2.18],\n [2.22],\n [-0.51],\n [-1.05],\n [2.37]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n 8 & 0 & 3 & -5 \\\\\n -9 & 4 & -4 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 0, 3, -5],\n [-9, 4, -4, 9]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -3 & -1 & 1 & -3 \\\\\n 0 & -1 & 1 & 3 \\\\\n 1 & -3 & -2 & -3 \\\\\n -1 & -3 & 3 & 1 \\\\\n -2 & -3 & -2 & 3 \\\\\n 1 & -3 & 3 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.06 \\\\\n 0.16 \\\\\n -0.53 \\\\\n 1.47 \\\\\n -1.05 \\\\\n 0.84 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.277 \\\\\n -0.018 \\\\\n 0.491 \\\\\n -0.205 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1, 1, -3],\n [0, -1, 1, 3],\n [1, -3, -2, -3],\n [-1, -3, 3, 1],\n [-2, -3, -2, 3],\n [1, -3, 3, 2]])\nb = np.array([\n [2.06],\n [0.16],\n [-0.53],\n [1.47],\n [-1.05],\n [0.84]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{3}{2} & 1 & \\frac{1}{2} & 3 & -1 \\\\\n -\\frac{5}{2} & 1 & 2 & \\frac{5}{2} & 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n \\frac{5}{2} & -\\frac{5}{2} & 1 & -2 & 2 \\\\\n 1 & 1 & -\\frac{5}{2} & \\frac{5}{2} & 2 \\\\\n -2 & -1 & \\frac{1}{2} & -\\frac{3}{2} & -3 \\\\\n 1 & 1 & \\frac{3}{2} & -\\frac{1}{2} & \\frac{5}{2} \\\\\n -\\frac{1}{2} & 3 & \\frac{5}{2} & 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -\\frac{1}{4} & \\frac{17}{4} & -\\frac{7}{4} & \\frac{13}{4} & 3 \\\\\n -\\frac{33}{4} & \\frac{67}{4} & \\frac{29}{4} & \\frac{13}{4} & \\frac{13}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), 1, (1/2), 3, -1],\n [-(5/2), 1, 2, (5/2), 3]])\nb = np.array([\n [(5/2), -(5/2), 1, -2, 2],\n [1, 1, -(5/2), (5/2), 2],\n [-2, -1, (1/2), -(3/2), -3],\n [1, 1, (3/2), -(1/2), (5/2)],\n [-(1/2), 3, (5/2), 0, 2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{7} \\\\\n -\\frac{57}{7} \\\\\n -\\frac{39}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/7)],\n [-(57/7)],\n [-(39/7)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $3$ and the matrix\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -24 \\\\\n -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-2]])\nprint(a * 3)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 8 & -7 & -5 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.,0.,0.,1.\\}, \\{5.,0.,8.,0.\\}, \\{7.,8.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [8, -7, -5, 8]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{11}{3},\\frac{5}{3},2\\right\\}, \\left\\{-1,-\\frac{4}{3},\\frac{7}{3}\\right\\}, \\left\\{-\\frac{14}{3},\\frac{8}{3},-4\\right\\}}$.", - "Output Answer": [ - "$477 x-831 y-801 z+1238=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(11/3), (5/3), 2],\n [-1, -(4/3), (7/3)],\n [-(14/3), (8/3), -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{41}{5} & -\\frac{11}{5} & -6 \\\\\n \\frac{7}{5} & -3 & 3 \\\\\n -\\frac{1}{5} & -\\frac{13}{5} & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-3.987-2.892 i,-3.987+2.892 i,8.174\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(41/5), -(11/5), -6],\n [(7/5), -3, 3],\n [-(1/5), -(13/5), -5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{4}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -9 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{4} \\\\\n \\frac{9}{4} \\\\\n 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-9],\n [-8]])\nprint(a * -(1/4))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -3 \\\\\n 3 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -6 \\\\\n -9 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-49$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-3],\n [3],\n [6]])\nb = np.array([\n [4],\n [-6],\n [-9],\n [-8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{3} & -4 & \\frac{13}{3} \\\\\n \\frac{14}{3} & -3 & \\frac{13}{3} \\\\\n \\frac{13}{3} & -\\frac{1}{3} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{2584}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/3), -4, (13/3)],\n [(14/3), -3, (13/3)],\n [(13/3), -(1/3), -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{14}{5}, -\\frac{16}{5}, -\\frac{16}{5}}$ to the plane $4 x-y+\\frac{7 z}{5}+\\frac{14}{5}=0$.", - "Output Answer": [ - "$\\frac{121 \\sqrt{\\frac{2}{237}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(14/5), -(16/5), -(16/5)\nplane = Poly(4*x-y+((7*z)/5)+(14/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & 8 & 4 \\\\\n -\\frac{28}{5} & -\\frac{38}{5} & \\frac{6}{5} \\\\\n -\\frac{26}{5} & -\\frac{29}{5} & \\frac{21}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-6.352,6.796,1.\\}, \\{-0.372-1.51 i,0.559\\, +0.561 i,1.\\}, \\{-0.372+1.51 i,0.559\\, -0.561 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 8, 4],\n [-(28/5), -(38/5), (6/5)],\n [-(26/5), -(29/5), (21/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,3,5\\}, \\{1,-3,2\\}, \\{3,-1,-4\\}}$.", - "Output Answer": [ - "$21 x+12 y+11 z-7=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, 3, 5],\n [1, -3, 2],\n [3, -1, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & 1 \\\\\n -7 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-2-\\sqrt{29},\\sqrt{29}-2\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 1],\n [-7, -8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 9 & 1 & 8 & -2 \\\\\n 9 & 6 & -4 & -4 \\\\\n 2 & 2 & -4 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{28.,-32.,-19.,34.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, 1, 8, -2],\n [9, 6, -4, -4],\n [2, 2, -4, -2]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{3} & \\frac{10}{3} \\\\\n \\frac{4}{3} & \\frac{14}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{7}{5} & -1 \\\\\n -\\frac{2}{5} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3), (10/3)],\n [(4/3), (14/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{289}{100} & \\frac{153}{25} \\\\\n \\frac{491}{50} & -\\frac{213}{25} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{27}{25} & \\frac{357}{100} \\\\\n \\frac{237}{100} & -\\frac{861}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{397}{100} & \\frac{51}{20} \\\\\n \\frac{149}{20} & \\frac{9}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(289/100), (153/25)],\n [(491/50), -(213/25)]])\nb = np.array([\n [-(27/25), (357/100)],\n [(237/100), -(861/100)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -\\frac{141}{16} & -\\frac{119}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(141/16), -(119/16)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n \\frac{29}{4} & \\frac{15}{8} & \\frac{53}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/4), (15/8), (53/8)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 5 \\\\\n -1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$14$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 5],\n [-1, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{50} \\\\\n \\frac{721}{100} \\\\\n \\frac{67}{10} \\\\\n -6 \\\\\n -\\frac{176}{25} \\\\\n \\frac{517}{100} \\\\\n -\\frac{51}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{934}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/50)],\n [(721/100)],\n [(67/10)],\n [-6],\n [-(176/25)],\n [(517/100)],\n [-(51/10)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n \\frac{29}{8} & \\frac{15}{4} & -7 & 0 & -6 \\\\\n \\frac{39}{8} & \\frac{15}{2} & -\\frac{3}{8} & \\frac{33}{8} & \\frac{5}{8} \\\\\n -\\frac{11}{4} & \\frac{1}{2} & \\frac{1}{8} & -\\frac{15}{4} & -\\frac{31}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/8), (15/4), -7, 0, -6],\n [(39/8), (15/2), -(3/8), (33/8), (5/8)],\n [-(11/4), (1/2), (1/8), -(15/4), -(31/4)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{28}{9} & -\\frac{23}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{20}{3} & \\frac{79}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{88}{9} & \\frac{56}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(28/9), -(23/9)]])\nb = np.array([\n [(20/3), (79/9)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -1 & \\frac{18}{5} & -\\frac{24}{5} \\\\\n \\frac{9}{5} & -\\frac{8}{5} & -1 \\\\\n -\\frac{7}{10} & -\\frac{11}{5} & -\\frac{3}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{155}{4004} & \\frac{795}{2002} & -\\frac{705}{2002} \\\\\n \\frac{445}{8008} & -\\frac{345}{4004} & -\\frac{1205}{4004} \\\\\n -\\frac{635}{4004} & -\\frac{295}{2002} & -\\frac{305}{2002} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, (18/5), -(24/5)],\n [(9/5), -(8/5), -1],\n [-(7/10), -(11/5), -(3/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 2 & 5 & 6 & 10 & 4 \\\\\n -2 & 4 & -2 & 10 & 5 \\\\\n -4 & 9 & -7 & 9 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & -\\frac{242}{31} & -\\frac{201}{62} \\\\\n 0 & 1 & 0 & \\frac{16}{31} & \\frac{11}{31} \\\\\n 0 & 0 & 1 & \\frac{119}{31} & \\frac{45}{31} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, 5, 6, 10, 4],\n [-2, 4, -2, 10, 5],\n [-4, 9, -7, 9, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{4}{5}, 0, -\\frac{21}{5}}$ to the plane $-\\frac{9 x}{5}+\\frac{17 y}{5}-\\frac{3 z}{5}+\\frac{9}{5}=0$.", - "Output Answer": [ - "$\\frac{72}{5 \\sqrt{379}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (4/5), 0, -(21/5)\nplane = Poly(-((9*x)/5)+((17*y)/5)-((3*z)/5)+(9/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -4 & 2 & 5 \\\\\n 0 & -8 & -6 \\\\\n -5 & 3 & -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-22 x^2-195 x-532$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 2, 5],\n [0, -8, -6],\n [-5, 3, -10]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -10 & 7 & -3 \\\\\n -10 & 9 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-31.,-40.,10.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, 7, -3],\n [-10, 9, 5]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n 2 & 1 \\\\\n 8 & -4 \\\\\n 5 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1],\n [8, -4],\n [5, 7]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 0 & 8 & -7 \\\\\n 2 & 7 & 3 \\\\\n -9 & 6 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+4 x^2+118 x-693$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 8, -7],\n [2, 7, 3],\n [-9, 6, -3]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & -2 & 2 \\\\\n 2 & 3 & 2 \\\\\n 1 & 1 & 1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & -6 & 0 \\\\\n 10 & 7 & 12 \\\\\n 4 & 2 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2, 2],\n [2, 3, 2],\n [1, 1, 1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{22}{5}, \\frac{1}{5}, -\\frac{6}{5}}$ to the plane $-\\frac{9 x}{5}+2 y-z-\\frac{4}{5}=0$.", - "Output Answer": [ - "$\\frac{109 \\sqrt{\\frac{2}{103}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(22/5), (1/5), -(6/5)\nplane = Poly(-((9*x)/5)+2*y-z-(4/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n \\frac{19}{16} \\\\\n \\frac{23}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -2 & \\frac{13}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{19}{8} & \\frac{247}{128} \\\\\n -\\frac{23}{8} & \\frac{299}{128} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/16)],\n [(23/16)]])\nb = np.array([\n [-2, (13/8)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 1 & -2 \\\\\n -3 & -1 & 2 \\\\\n 3 & -3 & 2 \\\\\n 2 & 0 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.84 \\\\\n 2.92 \\\\\n 2.53 \\\\\n 2.86 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2.631 \\\\\n -7.699 \\\\\n -6.082 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, -2],\n [-3, -1, 2],\n [3, -3, 2],\n [2, 0, -1]])\nb = np.array([\n [-2.84],\n [2.92],\n [2.53],\n [2.86]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{21}{8} \\\\\n 9 \\\\\n 0 \\\\\n \\frac{69}{8} \\\\\n \\frac{5}{4} \\\\\n \\frac{77}{8} \\\\\n -\\frac{21}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{7 \\sqrt{\\frac{43}{2}}}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(21/8)],\n [9],\n [0],\n [(69/8)],\n [(5/4)],\n [(77/8)],\n [-(21/8)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & 3 & -2 & -2 \\\\\n 2 & 0 & 0 & -3 \\\\\n -1 & 3 & -3 & 3 \\\\\n -1 & 0 & 1 & -2 \\\\\n -2 & 2 & 3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.37 \\\\\n 2.73 \\\\\n 0.13 \\\\\n 0.77 \\\\\n -1.32 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.74 \\\\\n 0.428 \\\\\n 0.069 \\\\\n -0.283 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, -2, -2],\n [2, 0, 0, -3],\n [-1, 3, -3, 3],\n [-1, 0, 1, -2],\n [-2, 2, 3, 3]])\nb = np.array([\n [0.37],\n [2.73],\n [0.13],\n [0.77],\n [-1.32]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1}{10}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/10)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -8 \\\\\n -4 \\\\\n 1 \\\\\n -7 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -7 \\\\\n 7 \\\\\n -8 \\\\\n 1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{367}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-8],\n [-4],\n [1],\n [-7],\n [8]])\nb = np.array([\n [-3],\n [-7],\n [7],\n [-8],\n [1],\n [2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -5 & -3 & -8 \\\\\n 1 & -9 & -4 \\\\\n 8 & -6 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-7.867,-1.566-4.347 i,-1.566+4.347 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -3, -8],\n [1, -9, -4],\n [8, -6, 3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{26}{3} & \\frac{19}{3} & \\frac{7}{3} \\\\\n -\\frac{25}{3} & -5 & -\\frac{26}{3} \\\\\n 10 & -\\frac{7}{3} & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-14 x^2-\\frac{514 x}{9}-\\frac{6578}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(26/3), (19/3), (7/3)],\n [-(25/3), -5, -(26/3)],\n [10, -(7/3), -(1/3)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 2 & -3 & -1 & -2 & -2 \\\\\n 0 & 1 & -1 & 2 & -1 \\\\\n 2 & 1 & 0 & 1 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -2 & 3 & 1 & 2 & -2 \\\\\n 1 & 0 & 0 & -2 & -2 \\\\\n 0 & 2 & -1 & 2 & 1 \\\\\n 0 & 0 & 3 & 2 & -1 \\\\\n -1 & 0 & -3 & -3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -5 & 4 & 3 & 10 & 1 \\\\\n 2 & -2 & 10 & 3 & -6 \\\\\n -3 & 6 & 5 & 4 & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3, -1, -2, -2],\n [0, 1, -1, 2, -1],\n [2, 1, 0, 1, 0]])\nb = np.array([\n [-2, 3, 1, 2, -2],\n [1, 0, 0, -2, -2],\n [0, 2, -1, 2, 1],\n [0, 0, 3, 2, -1],\n [-1, 0, -3, -3, 1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -5 & 10 & -4 & 2 & 3 & -7 \\\\\n 6 & 6 & 8 & 3 & 10 & -8 \\\\\n -10 & -1 & -5 & -10 & -9 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & \\frac{461}{303} & \\frac{77}{101} & -\\frac{127}{101} \\\\\n 0 & 1 & 0 & \\frac{305}{606} & \\frac{74}{101} & -\\frac{105}{101} \\\\\n 0 & 0 & 1 & -\\frac{231}{202} & \\frac{13}{101} & \\frac{73}{101} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, 10, -4, 2, 3, -7],\n [6, 6, 8, 3, 10, -8],\n [-10, -1, -5, -10, -9, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -4 & -2 & 4 \\\\\n 10 & 4 & 3 \\\\\n 1 & -9 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.104,0.788,1.\\}, \\{0.389\\, -0.157 i,-0.19-0.885 i,1.\\}, \\{0.389\\, +0.157 i,-0.19+0.885 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -2, 4],\n [10, 4, 3],\n [1, -9, 2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 2 & -\\frac{5}{4} & -1 \\\\\n -\\frac{1}{2} & 3 & \\frac{5}{4} \\\\\n -\\frac{5}{4} & \\frac{3}{4} & -\\frac{5}{4} \\\\\n 0 & -\\frac{1}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -1 & \\frac{5}{2} \\\\\n \\frac{11}{4} & -\\frac{3}{2} \\\\\n -2 & \\frac{11}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{55}{16} & \\frac{33}{8} \\\\\n \\frac{25}{4} & -\\frac{37}{16} \\\\\n \\frac{93}{16} & -\\frac{123}{16} \\\\\n -\\frac{19}{8} & \\frac{17}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(5/4), -1],\n [-(1/2), 3, (5/4)],\n [-(5/4), (3/4), -(5/4)],\n [0, -(1/2), (1/2)]])\nb = np.array([\n [-1, (5/2)],\n [(11/4), -(3/2)],\n [-2, (11/4)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & -6 \\\\\n -9 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{1-\\sqrt{55},1+\\sqrt{55}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -6],\n [-9, 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-2,\\frac{7}{2},\\frac{3}{2}\\right\\}, \\left\\{-\\frac{9}{2},-3,\\frac{9}{2}\\right\\}, \\left\\{-3,-\\frac{1}{2},0\\right\\}}$.", - "Output Answer": [ - "$174 x-54 y+28 z+495=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, (7/2), (3/2)],\n [-(9/2), -3, (9/2)],\n [-3, -(1/2), 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -4 & 4 \\\\\n -4 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{5}{36} & -\\frac{1}{9} \\\\\n \\frac{1}{9} & -\\frac{1}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 4],\n [-4, -5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & 0 & 0 \\\\\n 3 & -1 & 1 \\\\\n -3 & -1 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{2} & 0 & 0 \\\\\n \\frac{3}{2} & 0 & -1 \\\\\n 3 & 1 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, 0],\n [3, -1, 1],\n [-3, -1, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 2 & 3 & 2 & 3 & 3 \\\\\n 0 & 0 & 2 & -2 & 3 \\\\\n 2 & 2 & 0 & 2 & -3 \\\\\n 0 & 1 & -2 & 1 & -2 \\\\\n 2 & 3 & -2 & 0 & -2 \\\\\n -3 & -2 & 2 & 0 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.67 \\\\\n 1.9 \\\\\n 0.82 \\\\\n -1.05 \\\\\n 2.95 \\\\\n 2.42 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.296 \\\\\n 2.122 \\\\\n 1.091 \\\\\n -0.767 \\\\\n -0.371 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 3, 2, 3, 3],\n [0, 0, 2, -2, 3],\n [2, 2, 0, 2, -3],\n [0, 1, -2, 1, -2],\n [2, 3, -2, 0, -2],\n [-3, -2, 2, 0, -1]])\nb = np.array([\n [2.67],\n [1.9],\n [0.82],\n [-1.05],\n [2.95],\n [2.42]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -4 & -\\frac{13}{7} & -\\frac{8}{7} \\\\\n -\\frac{23}{7} & \\frac{27}{7} & -\\frac{22}{7} \\\\\n -\\frac{29}{7} & -\\frac{32}{7} & -\\frac{16}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{3976}{8073} & \\frac{56}{2691} & \\frac{1757}{8073} \\\\\n \\frac{35}{299} & \\frac{28}{299} & -\\frac{56}{299} \\\\\n \\frac{10633}{16146} & -\\frac{1211}{5382} & -\\frac{7385}{16146} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -(13/7), -(8/7)],\n [-(23/7), (27/7), -(22/7)],\n [-(29/7), -(32/7), -(16/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{5}{2}, -4, 1}$ to the plane $\\frac{9 x}{2}-y-\\frac{7 z}{2}=0$.", - "Output Answer": [ - "$\\frac{47}{2 \\sqrt{134}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (5/2), -4, 1\nplane = Poly(((9*x)/2)-y-((7*z)/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{32}{5} \\\\\n -\\frac{9}{5} \\\\\n -\\frac{7}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{21}{5} \\\\\n -\\frac{19}{5} \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{493}{2 \\sqrt{952627}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(32/5)],\n [-(9/5)],\n [-(7/5)]]).squeeze()\nb = np.array([\n [-(21/5)],\n [-(19/5)],\n [10]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 1 & 2 & -3 \\\\\n -2 & 10 & -2 \\\\\n 8 & 5 & -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -5 & -3 & 1 \\\\\n -7 & 6 & -8 \\\\\n 4 & 7 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -4 & -1 & -2 \\\\\n -9 & 16 & -10 \\\\\n 12 & 12 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, -3],\n [-2, 10, -2],\n [8, 5, -8]])\nb = np.array([\n [-5, -3, 1],\n [-7, 6, -8],\n [4, 7, 9]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n \\frac{15}{2} & -7 & \\frac{25}{16} & \\frac{3}{4} \\\\\n \\frac{137}{16} & -\\frac{27}{8} & \\frac{35}{8} & \\frac{157}{16} \\\\\n \\frac{55}{16} & -\\frac{27}{16} & \\frac{1}{16} & -\\frac{1}{4} \\\\\n -\\frac{9}{8} & -\\frac{67}{8} & -\\frac{97}{16} & \\frac{95}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/2), -7, (25/16), (3/4)],\n [(137/16), -(27/8), (35/8), (157/16)],\n [(55/16), -(27/16), (1/16), -(1/4)],\n [-(9/8), -(67/8), -(97/16), (95/16)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n 3 \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 2 \\\\\n -3 \\\\\n -2 \\\\\n -3 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{22}{39},-\\frac{22}{39},\\frac{11}{13},\\frac{22}{39},\\frac{11}{13},-\\frac{11}{13}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [1],\n [1],\n [1],\n [3],\n [-1]]).squeeze()\nb = np.array([\n [2],\n [2],\n [-3],\n [-2],\n [-3],\n [3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & -2 \\\\\n 2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(9-\\sqrt{33}\\right),\\frac{1}{2} \\left(9+\\sqrt{33}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -2],\n [2, 1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 3 & 0 & -2 & -2 \\\\\n 1 & -3 & 2 & 2 \\\\\n -1 & 1 & -2 & 0 \\\\\n 1 & 0 & 2 & 0 \\\\\n 2 & 2 & 0 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.42 \\\\\n 1.82 \\\\\n 2.91 \\\\\n 0.96 \\\\\n 2.38 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.053 \\\\\n 0.45 \\\\\n -0.356 \\\\\n 1.735 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 0, -2, -2],\n [1, -3, 2, 2],\n [-1, 1, -2, 0],\n [1, 0, 2, 0],\n [2, 2, 0, 1]])\nb = np.array([\n [-2.42],\n [1.82],\n [2.91],\n [0.96],\n [2.38]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{67}{16} & \\frac{65}{16} \\\\\n -\\frac{1}{16} & -\\frac{77}{8} \\\\\n \\frac{49}{8} & \\frac{83}{16} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{17}{2} & -\\frac{59}{8} \\\\\n -\\frac{61}{16} & \\frac{141}{16} \\\\\n 8 & \\frac{97}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{203}{16} & \\frac{183}{16} \\\\\n \\frac{15}{4} & -\\frac{295}{16} \\\\\n -\\frac{15}{8} & -\\frac{7}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(67/16), (65/16)],\n [-(1/16), -(77/8)],\n [(49/8), (83/16)]])\nb = np.array([\n [(17/2), -(59/8)],\n [-(61/16), (141/16)],\n [8, (97/16)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{8}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & 4 & -10 \\\\\n -8 & 10 & -9 \\\\\n 8 & 3 & -7 \\\\\n -3 & 0 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{4} & -\\frac{1}{2} & \\frac{5}{4} \\\\\n 1 & -\\frac{5}{4} & \\frac{9}{8} \\\\\n -1 & -\\frac{3}{8} & \\frac{7}{8} \\\\\n \\frac{3}{8} & 0 & \\frac{3}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 4, -10],\n [-8, 10, -9],\n [8, 3, -7],\n [-3, 0, -3]])\nprint(a * -(1/8))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{17}{6} \\\\\n \\frac{17}{2} \\\\\n -\\frac{1}{2} \\\\\n \\frac{13}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{5 \\sqrt{143}}{6}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/6)],\n [(17/2)],\n [-(1/2)],\n [(13/3)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -3 & 8 \\\\\n 7 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+9 x-38$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 8],\n [7, -6]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n \\frac{45}{8} & -\\frac{159}{16} & 10 & \\frac{23}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(45/8), -(159/16), 10, (23/4)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 5 & 2 & 4 \\\\\n 5 & 2 & 2 \\\\\n 2 & 0 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 2, 4],\n [5, 2, 2],\n [2, 0, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 0 & -8 & 10 \\\\\n -7 & -2 & -1 \\\\\n 5 & 6 & 1 \\\\\n -5 & 6 & 6 \\\\\n -10 & 3 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, -8, 10],\n [-7, -2, -1],\n [5, 6, 1],\n [-5, 6, 6],\n [-10, 3, -1]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 6 & 3 & 8 \\\\\n \\frac{3}{2} & 0 & 10 \\\\\n \\frac{9}{2} & 10 & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{19 x^2}{2}+\\frac{239 x}{2}-\\frac{1443}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 3, 8],\n [(3/2), 0, 10],\n [(9/2), 10, (7/2)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -9 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -4 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{290}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-9],\n [7]])\nb = np.array([\n [-9],\n [-4],\n [-5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & -\\frac{8}{3} \\\\\n -\\frac{13}{3} & \\frac{17}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{157}{18}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(8/3)],\n [-(13/3), (17/6)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 9 & 3 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.,3.,0.\\}, \\{2.,0.,3.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, 3, -6]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{2} & -\\frac{17}{6} \\\\\n -\\frac{7}{3} & -2 \\\\\n 0 & -\\frac{13}{6} \\\\\n -\\frac{2}{3} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{8}{3} & -\\frac{5}{2} & \\frac{17}{6} \\\\\n -\\frac{1}{2} & -\\frac{1}{3} & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{65}{12} & -\\frac{101}{36} & \\frac{34}{3} \\\\\n -\\frac{47}{9} & \\frac{13}{2} & -\\frac{29}{18} \\\\\n \\frac{13}{12} & \\frac{13}{18} & \\frac{65}{12} \\\\\n -\\frac{109}{36} & \\frac{5}{6} & -\\frac{293}{36} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), -(17/6)],\n [-(7/3), -2],\n [0, -(13/6)],\n [-(2/3), (5/2)]])\nb = np.array([\n [(8/3), -(5/2), (17/6)],\n [-(1/2), -(1/3), -(5/2)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 1 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 6 \\\\\n -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -42 \\\\\n 30 \\\\\n 23 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [1],\n [6]])\nb = np.array([\n [1],\n [6],\n [-6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{4} & -\\frac{23}{4} & \\frac{59}{8} \\\\\n \\frac{33}{8} & -\\frac{75}{8} & -\\frac{33}{4} \\\\\n \\frac{9}{2} & -\\frac{53}{8} & \\frac{23}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{39 x^2}{4}+\\frac{4477 x}{64}+\\frac{336117}{512}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/4), -(23/4), (59/8)],\n [(33/8), -(75/8), -(33/4)],\n [(9/2), -(53/8), (23/8)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{19}{3} \\\\\n -5 \\\\\n -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n \\frac{7}{3} \\\\\n \\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{46 \\sqrt{\\frac{2}{5135}}}{5}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/3)],\n [-5],\n [-(8/3)]]).squeeze()\nb = np.array([\n [-5],\n [(7/3)],\n [(11/3)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 9 \\\\\n 9 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 0 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 5 \\\\\n 9 \\\\\n 13 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [9],\n [9]])\nb = np.array([\n [3],\n [0],\n [-4]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n 8 & -10 & -2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -10, -2, -3]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{5}{8} & \\frac{55}{8} & \\frac{15}{2} & -\\frac{5}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -10 & \\frac{35}{8} & -\\frac{25}{8} & -\\frac{59}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{75}{8} & \\frac{5}{2} & \\frac{85}{8} & \\frac{27}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/8), (55/8), (15/2), -(5/8)]])\nb = np.array([\n [-10, (35/8), -(25/8), -(59/8)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 8 & -5 & -\\frac{11}{2} \\\\\n 4 & -\\frac{1}{2} & -\\frac{3}{2} \\\\\n -\\frac{9}{2} & \\frac{1}{2} & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6.686,2.316,6.869\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -5, -(11/2)],\n [4, -(1/2), -(3/2)],\n [-(9/2), (1/2), -5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{659}{100} & \\frac{79}{50} & \\frac{42}{25} & -\\frac{9}{4} \\\\\n -\\frac{67}{20} & -\\frac{241}{50} & 2 & -\\frac{397}{100} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{237}{100} & \\frac{199}{20} & \\frac{101}{100} & \\frac{913}{100} \\\\\n -\\frac{267}{50} & -\\frac{24}{25} & -\\frac{61}{50} & -\\frac{743}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{211}{50} & \\frac{1153}{100} & \\frac{269}{100} & \\frac{172}{25} \\\\\n -\\frac{869}{100} & -\\frac{289}{50} & \\frac{39}{50} & -\\frac{57}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(659/100), (79/50), (42/25), -(9/4)],\n [-(67/20), -(241/50), 2, -(397/100)]])\nb = np.array([\n [-(237/100), (199/20), (101/100), (913/100)],\n [-(267/50), -(24/25), -(61/50), -(743/100)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{4}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 6 \\\\\n -1 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -6 \\\\\n -\\frac{9}{2} \\\\\n \\frac{3}{4} \\\\\n \\frac{9}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [6],\n [-1],\n [-3]])\nprint(a * -(3/4))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n -\\frac{1}{4} \\\\\n \\frac{1}{2} \\\\\n -\\frac{3}{2} \\\\\n \\frac{9}{4} \\\\\n \\frac{9}{4} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n \\frac{1}{2} \\\\\n \\frac{3}{2} \\\\\n -\\frac{9}{4} \\\\\n \\frac{5}{4} \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{193}{428},\\frac{193}{428},\\frac{579}{428},-\\frac{1737}{856},\\frac{965}{856},\\frac{193}{107}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2)],\n [-(1/4)],\n [(1/2)],\n [-(3/2)],\n [(9/4)],\n [(9/4)]]).squeeze()\nb = np.array([\n [-(1/2)],\n [(1/2)],\n [(3/2)],\n [-(9/4)],\n [(5/4)],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{4}{5} & 6 & -\\frac{48}{5} \\\\\n -2 & \\frac{37}{5} & \\frac{13}{5} \\\\\n -\\frac{12}{5} & -9 & \\frac{3}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-4.36,6.58\\, -6.106 i,6.58\\, +6.106 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/5), 6, -(48/5)],\n [-2, (37/5), (13/5)],\n [-(12/5), -9, (3/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{23}{3} \\\\\n 6 \\\\\n 9 \\\\\n \\frac{28}{3} \\\\\n -1 \\\\\n -\\frac{7}{3} \\\\\n -\\frac{10}{3} \\\\\n -\\frac{5}{3} \\\\\n \\frac{22}{3} \\\\\n \\frac{25}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{3} \\\\\n -7 \\\\\n -5 \\\\\n -8 \\\\\n -\\frac{20}{3} \\\\\n 2 \\\\\n -\\frac{17}{3} \\\\\n -\\frac{5}{3} \\\\\n -\\frac{14}{3} \\\\\n \\frac{17}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{\\frac{2827}{3}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(23/3)],\n [6],\n [9],\n [(28/3)],\n [-1],\n [-(7/3)],\n [-(10/3)],\n [-(5/3)],\n [(22/3)],\n [(25/3)]])\nb = np.array([\n [-(2/3)],\n [-7],\n [-5],\n [-8],\n [-(20/3)],\n [2],\n [-(17/3)],\n [-(5/3)],\n [-(14/3)],\n [(17/3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -6 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -8 \\\\\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -30 \\\\\n 54 \\\\\n 38 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-6],\n [3]])\nb = np.array([\n [-3],\n [-8],\n [9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{13}{7}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & 1 \\\\\n 7 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{52}{7} & \\frac{13}{7} \\\\\n 13 & -\\frac{26}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 1],\n [7, -2]])\nprint(a * (13/7))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -4 \\\\\n 8 \\\\\n 3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n -10 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -3 \\\\\n -4 \\\\\n 18 \\\\\n -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-4],\n [8],\n [3]])\nb = np.array([\n [1],\n [0],\n [-10],\n [4]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 3 \\\\\n -1 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{4} \\\\\n \\frac{3}{4} \\\\\n -\\frac{1}{4} \\\\\n -\\frac{1}{2} \\\\\n \\frac{1}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [3],\n [-1],\n [-2],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{21}{5} & -\\frac{23}{5} & \\frac{23}{5} \\\\\n \\frac{16}{5} & \\frac{6}{5} & \\frac{24}{5} \\\\\n -\\frac{9}{5} & -\\frac{22}{5} & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{9202}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(21/5), -(23/5), (23/5)],\n [(16/5), (6/5), (24/5)],\n [-(9/5), -(22/5), 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{2} & 1 & -\\frac{3}{2} \\\\\n \\frac{11}{2} & 2 & -8 \\\\\n -6 & 6 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6.566,2.033\\, -6.447 i,2.033\\, +6.447 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/2), 1, -(3/2)],\n [(11/2), 2, -8],\n [-6, 6, 1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,0,-4\\}, \\{1,-1,-1\\}, \\{5,2,-4\\}}$.", - "Output Answer": [ - "$6 x-21 y-13 z-40=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, 0, -4],\n [1, -1, -1],\n [5, 2, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -7 & 7 & -10 & 3 & -9 & 2 & -6 \\\\\n 0 & -4 & -9 & -9 & -3 & 7 & 3 \\\\\n -3 & -8 & 7 & -5 & 8 & 10 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & -\\frac{64}{1009} & -\\frac{17}{1009} & -\\frac{1013}{1009} & -\\frac{337}{1009} \\\\\n 0 & 1 & 0 & \\frac{1107}{1009} & -\\frac{510}{1009} & -\\frac{1129}{1009} & -\\frac{1029}{1009} \\\\\n 0 & 0 & 1 & \\frac{517}{1009} & \\frac{563}{1009} & -\\frac{283}{1009} & \\frac{121}{1009} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, 7, -10, 3, -9, 2, -6],\n [0, -4, -9, -9, -3, 7, 3],\n [-3, -8, 7, -5, 8, 10, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{1}{2}, 3, -\\frac{7}{2}}$ to the plane $4 x+\\frac{5 y}{2}-\\frac{5 z}{2}-\\frac{3}{2}=0$.", - "Output Answer": [ - "$\\frac{17 \\sqrt{\\frac{3}{38}}}{2}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(1/2), 3, -(7/2)\nplane = Poly(4*x+((5*y)/2)-((5*z)/2)-(3/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{0,\\frac{3}{2},-\\frac{7}{2}\\right\\}, \\left\\{-\\frac{7}{2},-\\frac{7}{2},4\\right\\}, \\left\\{\\frac{5}{2},1,-3\\right\\}}$.", - "Output Answer": [ - "$10 x+164 y+114 z+153=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, (3/2), -(7/2)],\n [-(7/2), -(7/2), 4],\n [(5/2), 1, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{15}{7} & -\\frac{57}{7} \\\\\n \\frac{37}{7} & -\\frac{51}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{66 x}{7}+\\frac{2874}{49}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/7), -(57/7)],\n [(37/7), -(51/7)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 3 & -1 & -2 \\\\\n 1 & -2 & 1 \\\\\n 1 & -1 & -2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 16 & -5 & -5 \\\\\n 2 & 0 & 10 \\\\\n 4 & -7 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, -2],\n [1, -2, 1],\n [1, -1, -2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -6 & 8 & -3 & 8 & 9 \\\\\n -10 & -5 & 9 & 4 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 8, -3, 8, 9],\n [-10, -5, 9, 4, -5]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 0 & -7 \\\\\n 2 & -10 \\\\\n -8 & 0 \\\\\n 5 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, -7],\n [2, -10],\n [-8, 0],\n [5, -5]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 \\sqrt{5} \\\\\n -2 \\sqrt{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\sqrt{5} \\\\\n -3 \\sqrt{5} \\\\\n \\sqrt{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{30}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [3*math.sqrt(5)],\n [-2*math.sqrt(5)]])\nb = np.array([\n [3*math.sqrt(5)],\n [-3*math.sqrt(5)],\n [math.sqrt(5)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{3}} \\\\\n -\\frac{1}{\\sqrt{3}} \\\\\n 0 \\\\\n -\\frac{1}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [0],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -10 & 3 & -5 & 10 & -7 & 10 & 7 \\\\\n -9 & 7 & -8 & 8 & 1 & -9 & -4 \\\\\n -4 & -7 & 4 & -7 & 2 & 9 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & -\\frac{173}{29} & \\frac{241}{29} & -\\frac{388}{29} & -\\frac{288}{29} \\\\\n 0 & 1 & 0 & \\frac{445}{29} & -\\frac{606}{29} & \\frac{905}{29} & \\frac{716}{29} \\\\\n 0 & 0 & 1 & \\frac{555}{29} & -\\frac{805}{29} & \\frac{1261}{29} & \\frac{965}{29} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, 3, -5, 10, -7, 10, 7],\n [-9, 7, -8, 8, 1, -9, -4],\n [-4, -7, 4, -7, 2, 9, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 2 \\\\\n -8 \\\\\n 9 \\\\\n -8 \\\\\n -7 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -4 \\\\\n -1 \\\\\n -4 \\\\\n -8 \\\\\n -7 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{66}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [2],\n [-8],\n [9],\n [-8],\n [-7],\n [-7]])\nb = np.array([\n [6],\n [-4],\n [-1],\n [-4],\n [-8],\n [-7],\n [7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & 1 & -6 \\\\\n 6 & 8 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-20.,22.,7.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, 1, -6],\n [6, 8, -8]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{25}{7}, 3}$ to the line $-\\frac{19 x}{7}+\\frac{25 y}{7}+\\frac{11}{7}=0$.", - "Output Answer": [ - "$\\frac{127}{7 \\sqrt{986}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (25/7), 3\nline = Poly(-((19*x)/7)+((25*y)/7)+(11/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{10}{7} \\\\\n -\\frac{8}{7} \\\\\n -\\frac{18}{7} \\\\\n \\frac{2}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{5}{\\sqrt{123}} \\\\\n -\\frac{4}{\\sqrt{123}} \\\\\n -3 \\sqrt{\\frac{3}{41}} \\\\\n \\frac{1}{\\sqrt{123}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(10/7)],\n [-(8/7)],\n [-(18/7)],\n [(2/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{11}{9}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{11}{9} & \\frac{22}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2]])\nprint(a * (11/9))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & 1 & 2 & 1 \\\\\n -2 & 0 & -3 & 1 \\\\\n -3 & 1 & 0 & -1 \\\\\n 1 & -2 & -1 & -2 \\\\\n 2 & 1 & 1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.33 \\\\\n -1.86 \\\\\n -2.39 \\\\\n 1.79 \\\\\n -1.48 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.133 \\\\\n -1.487 \\\\\n 0.411 \\\\\n -0.004 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 1, 2, 1],\n [-2, 0, -3, 1],\n [-3, 1, 0, -1],\n [1, -2, -1, -2],\n [2, 1, 1, 2]])\nb = np.array([\n [-1.33],\n [-1.86],\n [-2.39],\n [1.79],\n [-1.48]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 7 & \\frac{31}{9} \\\\\n -\\frac{49}{9} & -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{19 x}{3}+\\frac{1141}{81}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, (31/9)],\n [-(49/9), -(2/3)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 4 & -3 & 9 & -3 & -7 \\\\\n -7 & 0 & 1 & 2 & -2 \\\\\n -5 & 7 & 6 & -8 & 6 \\\\\n 10 & -6 & 1 & -9 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & -\\frac{1577}{6239} \\\\\n 0 & 1 & 0 & 0 & \\frac{473}{6239} \\\\\n 0 & 0 & 1 & 0 & -\\frac{399}{367} \\\\\n 0 & 0 & 0 & 1 & -\\frac{8367}{6239} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, -3, 9, -3, -7],\n [-7, 0, 1, 2, -2],\n [-5, 7, 6, -8, 6],\n [10, -6, 1, -9, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{8} \\\\\n \\frac{9}{8} \\\\\n \\frac{3}{4} \\\\\n -\\frac{3}{8} \\\\\n \\frac{11}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{\\sqrt{\\frac{13}{2}}}{4} \\\\\n \\frac{9}{4 \\sqrt{26}} \\\\\n \\frac{3}{2 \\sqrt{26}} \\\\\n -\\frac{3}{4 \\sqrt{26}} \\\\\n \\frac{11}{4 \\sqrt{26}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/8)],\n [(9/8)],\n [(3/4)],\n [-(3/8)],\n [(11/8)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{9}{16} & \\frac{27}{16} & \\frac{33}{16} & \\frac{9}{16} & \\frac{19}{8} \\\\\n -\\frac{1}{4} & -\\frac{1}{2} & -\\frac{41}{16} & \\frac{35}{16} & -\\frac{3}{8} \\\\\n -\\frac{5}{16} & -\\frac{1}{8} & -\\frac{21}{16} & -\\frac{1}{8} & \\frac{7}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{16} & -\\frac{3}{16} & -\\frac{3}{4} \\\\\n 1 & -\\frac{1}{8} & -\\frac{3}{2} \\\\\n \\frac{45}{16} & \\frac{13}{16} & \\frac{27}{16} \\\\\n \\frac{25}{16} & -\\frac{47}{16} & \\frac{15}{8} \\\\\n \\frac{5}{4} & \\frac{21}{16} & \\frac{19}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{2785}{256} & \\frac{723}{256} & \\frac{1849}{256} \\\\\n -\\frac{583}{128} & -\\frac{569}{64} & -\\frac{45}{256} \\\\\n -\\frac{411}{128} & -\\frac{13}{256} & -\\frac{253}{256} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/16), (27/16), (33/16), (9/16), (19/8)],\n [-(1/4), -(1/2), -(41/16), (35/16), -(3/8)],\n [-(5/16), -(1/8), -(21/16), -(1/8), (7/16)]])\nb = np.array([\n [-(13/16), -(3/16), -(3/4)],\n [1, -(1/8), -(3/2)],\n [(45/16), (13/16), (27/16)],\n [(25/16), -(47/16), (15/8)],\n [(5/4), (21/16), (19/8)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 0 & -3 & 2 & 4 \\\\\n 1 & -3 & 3 & 6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n 8 & -1 & 3 & 8 \\\\\n 9 & 8 & -5 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -8 & -2 & -1 & -4 \\\\\n -8 & -11 & 8 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3, 2, 4],\n [1, -3, 3, 6]])\nb = np.array([\n [8, -1, 3, 8],\n [9, 8, -5, 3]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 3 & -6 & -7 \\\\\n -8 & 5 & -3 \\\\\n 3 & 5 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+17 x^2-75 x+187$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -6, -7],\n [-8, 5, -3],\n [3, 5, 9]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 8 & -2 & -1 \\\\\n 9 & -4 & 9 \\\\\n 1 & -9 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+7 x^2-80 x+665$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -2, -1],\n [9, -4, 9],\n [1, -9, 3]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & 3 & -1 & -3 \\\\\n -3 & -3 & -3 & 3 \\\\\n 1 & 3 & 3 & 3 \\\\\n 1 & -3 & 0 & 1 \\\\\n 3 & -1 & 2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.54 \\\\\n -0.92 \\\\\n -2.41 \\\\\n 2.3 \\\\\n 3. \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.283 \\\\\n -0.376 \\\\\n -0.729 \\\\\n -0.125 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 3, -1, -3],\n [-3, -3, -3, 3],\n [1, 3, 3, 3],\n [1, -3, 0, 1],\n [3, -1, 2, -2]])\nb = np.array([\n [2.54],\n [-0.92],\n [-2.41],\n [2.3],\n [3.]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-1,-2,-1\\}, \\{2,2,-3\\}, \\{-2,-2,0\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{6}},-\\sqrt{\\frac{2}{3}},-\\frac{1}{\\sqrt{6}}\\right\\}, \\left\\{\\frac{3}{\\sqrt{62}},\\sqrt{\\frac{2}{31}},-\\frac{7}{\\sqrt{62}}\\right\\}, \\left\\{-\\frac{8}{\\sqrt{93}},\\frac{5}{\\sqrt{93}},-\\frac{2}{\\sqrt{93}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, -2, -1), (2, 2, -3), (-2, -2, 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{13}{3},-1,-3\\right\\}, \\left\\{\\frac{5}{3},-\\frac{10}{3},-\\frac{11}{3}\\right\\}, \\left\\{\\frac{7}{3},\\frac{7}{3},-\\frac{7}{3}\\right\\}}$.", - "Output Answer": [ - "$3 x-38 y+160 z+455=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(13/3), -1, -3],\n [(5/3), -(10/3), -(11/3)],\n [(7/3), (7/3), -(7/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & \\frac{39}{4} \\\\\n \\frac{15}{4} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{x}{2}-\\frac{609}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, (39/4)],\n [(15/4), -(3/2)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 0 & 2 & 3 & 2 \\\\\n -3 & 3 & 2 & 0 \\\\\n 2 & 2 & 0 & 3 \\\\\n -1 & -1 & 0 & 3 \\\\\n -2 & -2 & 3 & 1 \\\\\n -1 & -3 & -3 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.7 \\\\\n -0.14 \\\\\n -0.94 \\\\\n 0.75 \\\\\n -2.52 \\\\\n -2.26 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.03 \\\\\n 0.279 \\\\\n -0.325 \\\\\n -0.378 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 2, 3, 2],\n [-3, 3, 2, 0],\n [2, 2, 0, 3],\n [-1, -1, 0, 3],\n [-2, -2, 3, 1],\n [-1, -3, -3, 3]])\nb = np.array([\n [-1.7],\n [-0.14],\n [-0.94],\n [0.75],\n [-2.52],\n [-2.26]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 1 \\\\\n 10 \\\\\n 6 \\\\\n -4 \\\\\n 5 \\\\\n -4 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$38$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [1],\n [10],\n [6],\n [-4],\n [5],\n [-4],\n [1]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & -1 & 1 \\\\\n -2 & 0 & 3 \\\\\n 2 & 1 & 3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -2 & -4 & 7 \\\\\n 4 & 1 & 42 \\\\\n 26 & 10 & 49 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -1, 1],\n [-2, 0, 3],\n [2, 1, 3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{6}{7} \\\\\n -\\frac{16}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{\\sqrt{73}} \\\\\n -\\frac{8}{\\sqrt{73}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(6/7)],\n [-(16/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{59}{8} & 2 & -\\frac{29}{4} & -\\frac{19}{4} & -\\frac{3}{8} \\\\\n \\frac{19}{2} & -\\frac{17}{8} & -\\frac{57}{8} & \\frac{27}{4} & \\frac{41}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(59/8), 2, -(29/4), -(19/4), -(3/8)],\n [(19/2), -(17/8), -(57/8), (27/4), (41/8)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n -3 & 8 \\\\\n 3 & 7 \\\\\n -7 & 8 \\\\\n -4 & -5 \\\\\n 6 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 8],\n [3, 7],\n [-7, 8],\n [-4, -5],\n [6, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{8} \\\\\n -\\frac{9}{4} \\\\\n \\frac{13}{8} \\\\\n -\\frac{5}{4} \\\\\n -\\frac{3}{2} \\\\\n \\frac{9}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{9}{\\sqrt{899}} \\\\\n -\\frac{18}{\\sqrt{899}} \\\\\n \\frac{13}{\\sqrt{899}} \\\\\n -\\frac{10}{\\sqrt{899}} \\\\\n -\\frac{12}{\\sqrt{899}} \\\\\n \\frac{9}{\\sqrt{899}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/8)],\n [-(9/4)],\n [(13/8)],\n [-(5/4)],\n [-(3/2)],\n [(9/8)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{20}{3} & 6 \\\\\n -2 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{6} \\left(-5-\\sqrt{793}\\right),\\frac{1}{6} \\left(\\sqrt{793}-5\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(20/3), 6],\n [-2, 5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{4} & -\\frac{13}{4} & -\\frac{19}{8} \\\\\n -\\frac{33}{8} & -\\frac{31}{8} & \\frac{15}{4} \\\\\n -\\frac{29}{8} & -\\frac{15}{8} & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{776}{5011} & \\frac{674}{5011} & -\\frac{2738}{5011} \\\\\n -\\frac{1608}{5011} & -\\frac{1190}{5011} & \\frac{2574}{5011} \\\\\n -\\frac{808}{5011} & \\frac{848}{5011} & -\\frac{352}{5011} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/4), -(13/4), -(19/8)],\n [-(33/8), -(31/8), (15/4)],\n [-(29/8), -(15/8), (1/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -5 & -7 & 2 & 9 \\\\\n -8 & -5 & 5 & -6 \\\\\n 7 & -2 & -5 & 9 \\\\\n -3 & 5 & -1 & -6 \\\\\n 3 & 7 & 6 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, -7, 2, 9],\n [-8, -5, 5, -6],\n [7, -2, -5, 9],\n [-3, 5, -1, -6],\n [3, 7, 6, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{2}{3} \\\\\n 0 \\\\\n 0 \\\\\n -\\frac{1}{3} \\\\\n \\frac{2}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [0],\n [0],\n [-1],\n [2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{31}{8} \\\\\n \\frac{7}{4} \\\\\n \\frac{33}{4} \\\\\n -\\frac{51}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{\\frac{4057}{2}}}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(31/8)],\n [(7/4)],\n [(33/4)],\n [-(51/8)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -9 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -5 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{29}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-9],\n [7]])\nb = np.array([\n [2],\n [-5],\n [5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 1 & -10 & 2 & -2 \\\\\n 2 & -5 & -6 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-10.,-4.,0.,15.\\}, \\{14.,2.,3.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [1, -10, 2, -2],\n [2, -5, -6, 0]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{55}{8} & -10 \\\\\n -\\frac{79}{8} & \\frac{3}{8} \\\\\n -\\frac{55}{8} & -\\frac{19}{2} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{17}{8} & \\frac{79}{8} \\\\\n \\frac{19}{2} & -\\frac{3}{2} \\\\\n -\\frac{13}{4} & -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 9 & -\\frac{159}{8} \\\\\n -\\frac{155}{8} & \\frac{15}{8} \\\\\n -\\frac{29}{8} & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(55/8), -10],\n [-(79/8), (3/8)],\n [-(55/8), -(19/2)]])\nb = np.array([\n [-(17/8), (79/8)],\n [(19/2), -(3/2)],\n [-(13/4), -(15/2)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{37}{4} & 2 \\\\\n -\\frac{3}{2} & -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{8} \\left(11-\\sqrt{3777}\\right),\\frac{1}{8} \\left(11+\\sqrt{3777}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/4), 2],\n [-(3/2), -(13/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{9}{4} & \\frac{33}{4} & 8 \\\\\n -\\frac{39}{4} & \\frac{17}{4} & -1 \\\\\n 9 & \\frac{5}{4} & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-3.763,6.131\\, -6.387 i,6.131\\, +6.387 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/4), (33/4), 8],\n [-(39/4), (17/4), -1],\n [9, (5/4), 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & 2 & -1 \\\\\n 2 & -\\frac{5}{2} & \\frac{3}{2} \\\\\n -2 & -\\frac{1}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{49}{4} & \\frac{1}{2} & 0 \\\\\n -3 & \\frac{19}{2} & -5 \\\\\n -7 & -3 & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), 2, -1],\n [2, -(5/2), (3/2)],\n [-2, -(1/2), (1/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\sqrt{2} \\\\\n \\sqrt{2} \\\\\n 0 \\\\\n -2 \\sqrt{2} \\\\\n 6 \\sqrt{2} \\\\\n 2 \\sqrt{2} \\\\\n 5 \\sqrt{2} \\\\\n -2 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\sqrt{2} \\\\\n -6 \\sqrt{2} \\\\\n -2 \\sqrt{2} \\\\\n -4 \\sqrt{2} \\\\\n -7 \\sqrt{2} \\\\\n 2 \\sqrt{2} \\\\\n 0 \\\\\n 6 \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{170}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [6*math.sqrt(2)],\n [math.sqrt(2)],\n [0],\n [-2*math.sqrt(2)],\n [6*math.sqrt(2)],\n [2*math.sqrt(2)],\n [5*math.sqrt(2)],\n [-2*math.sqrt(2)]])\nb = np.array([\n [math.sqrt(2)],\n [-6*math.sqrt(2)],\n [-2*math.sqrt(2)],\n [-4*math.sqrt(2)],\n [-7*math.sqrt(2)],\n [2*math.sqrt(2)],\n [0],\n [6*math.sqrt(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -6 \\\\\n 3 \\\\\n -5 \\\\\n -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n -5 \\\\\n -6 \\\\\n -2 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{43}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-6],\n [3],\n [-5],\n [-7]])\nb = np.array([\n [-10],\n [-5],\n [-6],\n [-2],\n [-7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{4} & \\frac{19}{8} & -\\frac{37}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/4), (19/8), -(37/4)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 8 & 7 & 3 & -8 & 2 & 10 \\\\\n 4 & 10 & 10 & 7 & -6 & -8 \\\\\n -6 & -2 & 10 & 0 & -6 & -9 \\\\\n 3 & 8 & 3 & -6 & 9 & 2 \\\\\n 6 & 10 & -5 & -2 & -5 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & \\frac{169157}{77607} \\\\\n 0 & 1 & 0 & 0 & 0 & -\\frac{28367}{17246} \\\\\n 0 & 0 & 1 & 0 & 0 & \\frac{25567}{51738} \\\\\n 0 & 0 & 0 & 1 & 0 & -\\frac{11735}{77607} \\\\\n 0 & 0 & 0 & 0 & 1 & \\frac{107443}{155214} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, 7, 3, -8, 2, 10],\n [4, 10, 10, 7, -6, -8],\n [-6, -2, 10, 0, -6, -9],\n [3, 8, 3, -6, 9, 2],\n [6, 10, -5, -2, -5, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{27}{4} & 9 & 3 \\\\\n -\\frac{35}{4} & -\\frac{25}{4} & 5 \\\\\n -\\frac{19}{2} & \\frac{31}{4} & \\frac{15}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{37 x^2}{4}-\\frac{991 x}{16}-\\frac{6015}{64}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(27/4), 9, 3],\n [-(35/4), -(25/4), 5],\n [-(19/2), (31/4), (15/4)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{9}{8}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -2 \\\\\n 7 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{63}{8} \\\\\n \\frac{9}{4} \\\\\n -\\frac{63}{8} \\\\\n \\frac{45}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-2],\n [7],\n [-5]])\nprint(a * -(9/8))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -4 & -4 & -6 & 0 & 1 \\\\\n 1 & -4 & -5 & 3 & 2 \\\\\n 3 & 7 & -4 & 1 & 2 \\\\\n 3 & -1 & 8 & 10 & 1 \\\\\n 5 & 3 & -1 & 0 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, -4, -6, 0, 1],\n [1, -4, -5, 3, 2],\n [3, 7, -4, 1, 2],\n [3, -1, 8, 10, 1],\n [5, 3, -1, 0, -5]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 0 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, -10]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{13}{5}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 4 \\\\\n -6 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{26}{5} \\\\\n \\frac{52}{5} \\\\\n -\\frac{78}{5} \\\\\n 26 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [4],\n [-6],\n [10]])\nprint(a * (13/5))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -9 & -1 & 0 \\\\\n 3 & 0 & -1 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 5 & -3 & -6 \\\\\n 2 & 3 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -14 & 2 & 6 \\\\\n 1 & -3 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -1, 0],\n [3, 0, -1]])\nb = np.array([\n [5, -3, -6],\n [2, 3, -2]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 2 \\\\\n -6 \\\\\n -9 \\\\\n 1 \\\\\n 9 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 2 \\\\\n 9 \\\\\n 2 \\\\\n 5 \\\\\n -4 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{631}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [2],\n [-6],\n [-9],\n [1],\n [9],\n [6]])\nb = np.array([\n [5],\n [2],\n [9],\n [2],\n [5],\n [-4],\n [-2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n 3 & -9 & -6 & -4 \\\\\n -6 & -5 & 0 & 3 \\\\\n 6 & -9 & 2 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -9, -6, -4],\n [-6, -5, 0, 3],\n [6, -9, 2, -6]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 4 & 2 & -2 & 2 \\\\\n 1 & 1 & 4 & 0 \\\\\n 2 & -7 & -7 & -5 \\\\\n -6 & -4 & 3 & -7 \\\\\n -7 & -4 & -4 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, 2, -2, 2],\n [1, 1, 4, 0],\n [2, -7, -7, -5],\n [-6, -4, 3, -7],\n [-7, -4, -4, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{14}{3} & -10 \\\\\n 3 & \\frac{23}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{6} \\left(37-3 i \\sqrt{111}\\right),\\frac{1}{6} \\left(37+3 i \\sqrt{111}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/3), -10],\n [3, (23/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 1 \\\\\n -3 \\\\\n -8 \\\\\n 8 \\\\\n 5 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 6 \\\\\n -6 \\\\\n 2 \\\\\n -3 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-59$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [1],\n [-3],\n [-8],\n [8],\n [5],\n [1]])\nb = np.array([\n [-5],\n [6],\n [-6],\n [2],\n [-3],\n [-2],\n [2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${3, 1, -\\frac{1}{2}}$ to the plane $-\\frac{3 x}{2}-\\frac{7 y}{2}+\\frac{9 z}{2}-\\frac{7}{2}=0$.", - "Output Answer": [ - "$\\frac{55}{2 \\sqrt{139}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 3, 1, -(1/2)\nplane = Poly(-((3*x)/2)-((7*y)/2)+((9*z)/2)-(7/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & 1 \\\\\n 5 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{5} \\left(-8-\\sqrt{69}\\right),1\\right\\}, \\left\\{\\frac{1}{5} \\left(\\sqrt{69}-8\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 1],\n [5, 8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -6 & 6 & -8 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 0 & -5 & -6 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -6 & 1 & -14 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 6, -8, 1]])\nb = np.array([\n [0, -5, -6, -3]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 5 & 0 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -2 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 7 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 0]])\nb = np.array([\n [-2, 4]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n \\frac{11}{9} & -\\frac{26}{9} & -\\frac{23}{9} & -3 \\\\\n -\\frac{7}{3} & -\\frac{25}{9} & \\frac{14}{9} & \\frac{26}{9} \\\\\n -\\frac{1}{9} & -1 & -\\frac{4}{3} & \\frac{19}{9} \\\\\n \\frac{17}{9} & -\\frac{2}{9} & \\frac{19}{9} & -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{16}{9} \\\\\n -\\frac{2}{9} \\\\\n \\frac{17}{9} \\\\\n -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{133}{81} \\\\\n 0 \\\\\n -\\frac{626}{81} \\\\\n \\frac{631}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/9), -(26/9), -(23/9), -3],\n [-(7/3), -(25/9), (14/9), (26/9)],\n [-(1/9), -1, -(4/3), (19/9)],\n [(17/9), -(2/9), (19/9), -(8/3)]])\nb = np.array([\n [-(16/9)],\n [-(2/9)],\n [(17/9)],\n [-(8/3)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{33}{7}, \\frac{2}{7}}$ to the line $\\frac{17 x}{7}+\\frac{9 y}{7}+\\frac{13}{7}=0$.", - "Output Answer": [ - "$\\frac{226 \\sqrt{\\frac{2}{185}}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(33/7), (2/7)\nline = Poly(((17*x)/7)+((9*y)/7)+(13/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{2} & -9 & -\\frac{13}{2} \\\\\n 8 & -\\frac{17}{2} & 4 \\\\\n \\frac{19}{2} & 5 & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.676,-0.727,1.\\}, \\{-0.787-0.684 i,0.302\\, -0.466 i,1.\\}, \\{-0.787+0.684 i,0.302\\, +0.466 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/2), -9, -(13/2)],\n [8, -(17/2), 4],\n [(19/2), 5, (7/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{19}{5} & 8 \\\\\n \\frac{46}{5} & -\\frac{17}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{36 x}{5}-\\frac{1517}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/5), 8],\n [(46/5), -(17/5)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -4 \\\\\n -9 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 8 \\\\\n -5 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{3}{2 \\sqrt{77}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-4],\n [-9],\n [1]]).squeeze()\nb = np.array([\n [1],\n [8],\n [-5],\n [8]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccccc}\n \\frac{29}{5} & 1 & \\frac{19}{5} & -\\frac{37}{5} & -8 \\\\\n \\frac{6}{5} & -\\frac{13}{5} & -\\frac{34}{5} & -\\frac{8}{5} & \\frac{38}{5} \\\\\n -\\frac{32}{5} & -\\frac{9}{5} & \\frac{21}{5} & \\frac{47}{5} & -\\frac{14}{5} \\\\\n -3 & \\frac{9}{5} & \\frac{37}{5} & -\\frac{23}{5} & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/5), 1, (19/5), -(37/5), -8],\n [(6/5), -(13/5), -(34/5), -(8/5), (38/5)],\n [-(32/5), -(9/5), (21/5), (47/5), -(14/5)],\n [-3, (9/5), (37/5), -(23/5), -1]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,3,5\\}, \\{-4,1,1\\}, \\{2,-1,-1\\}}$.", - "Output Answer": [ - "$2 x+19 y-13 z+2=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, 3, 5],\n [-4, 1, 1],\n [2, -1, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{25}{3} & -\\frac{8}{3} \\\\\n \\frac{13}{3} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{26} \\left(-13-i \\sqrt{247}\\right),1\\right\\}, \\left\\{\\frac{1}{26} \\left(-13+i \\sqrt{247}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(25/3), -(8/3)],\n [(13/3), -4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{37}{9} & \\frac{23}{9} \\\\\n \\frac{4}{3} & -\\frac{29}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{261}{1349} & \\frac{207}{1349} \\\\\n \\frac{108}{1349} & -\\frac{333}{1349} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/9), (23/9)],\n [(4/3), -(29/9)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{6}{\\sqrt{5}},\\frac{6}{\\sqrt{5}},\\frac{1}{\\sqrt{5}}\\right\\}, \\left\\{\\sqrt{5},\\frac{7}{\\sqrt{5}},\\frac{6}{\\sqrt{5}}\\right\\}, \\left\\{-\\frac{3}{\\sqrt{5}},\\frac{4}{\\sqrt{5}},0\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{6}{\\sqrt{73}},\\frac{6}{\\sqrt{73}},\\frac{1}{\\sqrt{73}}\\right\\}, \\left\\{\\frac{\\sqrt{5}-\\frac{468}{73 \\sqrt{5}}}{\\sqrt{\\frac{131449}{26645}+\\left(\\frac{468}{73 \\sqrt{5}}-\\sqrt{5}\\right)^2}},\\frac{43}{73 \\sqrt{5 \\left(\\frac{131449}{26645}+\\left(\\frac{468}{73 \\sqrt{5}}-\\sqrt{5}\\right)^2\\right)}},\\frac{72}{73} \\sqrt{\\frac{5}{\\frac{131449}{26645}+\\left(\\frac{468}{73 \\sqrt{5}}-\\sqrt{5}\\right)^2}}\\right\\}, \\left\\{\\frac{-\\frac{51 \\sqrt{5}}{73}-\\frac{\\left(-\\frac{468}{73 \\sqrt{5}}+\\sqrt{5}\\right) \\left(\\frac{172}{365}-\\frac{3 \\left(-\\frac{468}{73 \\sqrt{5}}+\\sqrt{5}\\right)}{\\sqrt{5}}\\right)}{\\frac{131449}{26645}+\\left(\\frac{468}{73 \\sqrt{5}}-\\sqrt{5}\\right)^2}}{\\sqrt{\\left(\\frac{256}{73 \\sqrt{5}}-\\frac{43 \\left(\\frac{172}{365}-\\frac{3 \\left(-\\frac{468}{73 \\sqrt{5}}+\\sqrt{5}\\right)}{\\sqrt{5}}\\right)}{73 \\sqrt{5} \\left(\\frac{131449}{26645}+\\left(\\frac{468}{73 \\sqrt{5}}-\\sqrt{5}\\right)^2\\right)}\\right)^2+\\left(\\frac{6}{73 \\sqrt{5}}+\\frac{72 \\sqrt{5} \\left(\\frac{172}{365}-\\frac{3 \\left(-\\frac{468}{73 \\sqrt{5}}+\\sqrt{5}\\right)}{\\sqrt{5}}\\right)}{73 \\left(\\frac{131449}{26645}+\\left(\\frac{468}{73 \\sqrt{5}}-\\sqrt{5}\\right)^2\\right)}\\right)^2+\\left(\\frac{51 \\sqrt{5}}{73}-\\frac{\\left(\\frac{468}{73 \\sqrt{5}}-\\sqrt{5}\\right) \\left(\\frac{172}{365}-\\frac{3 \\left(-\\frac{468}{73 \\sqrt{5}}+\\sqrt{5}\\right)}{\\sqrt{5}}\\right)}{\\frac{131449}{26645}+\\left(\\frac{468}{73 \\sqrt{5}}-\\sqrt{5}\\right)^2}\\right)^2}},\\frac{\\frac{256}{73 \\sqrt{5}}-\\frac{43 \\left(\\frac{172}{365}-\\frac{3 \\left(-\\frac{468}{73 \\sqrt{5}}+\\sqrt{5}\\right)}{\\sqrt{5}}\\right)}{73 \\sqrt{5} \\left(\\frac{131449}{26645}+\\left(\\frac{468}{73 \\sqrt{5}}-\\sqrt{5}\\right)^2\\right)}}{\\sqrt{\\left(\\frac{256}{73 \\sqrt{5}}-\\frac{43 \\left(\\frac{172}{365}-\\frac{3 \\left(-\\frac{468}{73 \\sqrt{5}}+\\sqrt{5}\\right)}{\\sqrt{5}}\\right)}{73 \\sqrt{5} \\left(\\frac{131449}{26645}+\\left(\\frac{468}{73 \\sqrt{5}}-\\sqrt{5}\\right)^2\\right)}\\right)^2+\\left(\\frac{6}{73 \\sqrt{5}}+\\frac{72 \\sqrt{5} \\left(\\frac{172}{365}-\\frac{3 \\left(-\\frac{468}{73 \\sqrt{5}}+\\sqrt{5}\\right)}{\\sqrt{5}}\\right)}{73 \\left(\\frac{131449}{26645}+\\left(\\frac{468}{73 \\sqrt{5}}-\\sqrt{5}\\right)^2\\right)}\\right)^2+\\left(\\frac{51 \\sqrt{5}}{73}-\\frac{\\left(\\frac{468}{73 \\sqrt{5}}-\\sqrt{5}\\right) \\left(\\frac{172}{365}-\\frac{3 \\left(-\\frac{468}{73 \\sqrt{5}}+\\sqrt{5}\\right)}{\\sqrt{5}}\\right)}{\\frac{131449}{26645}+\\left(\\frac{468}{73 \\sqrt{5}}-\\sqrt{5}\\right)^2}\\right)^2}},\\frac{-\\frac{6}{73 \\sqrt{5}}-\\frac{72 \\sqrt{5} \\left(\\frac{172}{365}-\\frac{3 \\left(-\\frac{468}{73 \\sqrt{5}}+\\sqrt{5}\\right)}{\\sqrt{5}}\\right)}{73 \\left(\\frac{131449}{26645}+\\left(\\frac{468}{73 \\sqrt{5}}-\\sqrt{5}\\right)^2\\right)}}{\\sqrt{\\left(\\frac{256}{73 \\sqrt{5}}-\\frac{43 \\left(\\frac{172}{365}-\\frac{3 \\left(-\\frac{468}{73 \\sqrt{5}}+\\sqrt{5}\\right)}{\\sqrt{5}}\\right)}{73 \\sqrt{5} \\left(\\frac{131449}{26645}+\\left(\\frac{468}{73 \\sqrt{5}}-\\sqrt{5}\\right)^2\\right)}\\right)^2+\\left(\\frac{6}{73 \\sqrt{5}}+\\frac{72 \\sqrt{5} \\left(\\frac{172}{365}-\\frac{3 \\left(-\\frac{468}{73 \\sqrt{5}}+\\sqrt{5}\\right)}{\\sqrt{5}}\\right)}{73 \\left(\\frac{131449}{26645}+\\left(\\frac{468}{73 \\sqrt{5}}-\\sqrt{5}\\right)^2\\right)}\\right)^2+\\left(\\frac{51 \\sqrt{5}}{73}-\\frac{\\left(\\frac{468}{73 \\sqrt{5}}-\\sqrt{5}\\right) \\left(\\frac{172}{365}-\\frac{3 \\left(-\\frac{468}{73 \\sqrt{5}}+\\sqrt{5}\\right)}{\\sqrt{5}}\\right)}{\\frac{131449}{26645}+\\left(\\frac{468}{73 \\sqrt{5}}-\\sqrt{5}\\right)^2}\\right)^2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((6/(math.sqrt(5))), (6/(math.sqrt(5))), (1/(math.sqrt(5)))), (math.sqrt(5), (7/(math.sqrt(5))), (6/(math.sqrt(5)))), (-(3/(math.sqrt(5))), (4/(math.sqrt(5))), 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{277}{50} \\\\\n -\\frac{99}{100} \\\\\n -\\frac{283}{50} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{801}{100} \\\\\n \\frac{231}{50} \\\\\n \\frac{307}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{231099}{10000} \\\\\n -\\frac{155861}{2500} \\\\\n \\frac{335247}{10000} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(277/50)],\n [-(99/100)],\n [-(283/50)]])\nb = np.array([\n [(801/100)],\n [(231/50)],\n [(307/100)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -1 & -2 \\\\\n 2 & -3 \\\\\n 0 & 0 \\\\\n 1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 1.43 \\\\\n 2.47 \\\\\n 2.83 \\\\\n -1.53 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.219 \\\\\n -0.665 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2],\n [2, -3],\n [0, 0],\n [1, 3]])\nb = np.array([\n [1.43],\n [2.47],\n [2.83],\n [-1.53]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{3}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -5 & 2 \\\\\n 10 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{5}{3} & \\frac{2}{3} \\\\\n \\frac{10}{3} & \\frac{2}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 2],\n [10, 2]])\nprint(a * (1/3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -8 \\\\\n -2 \\\\\n 5 \\\\\n -6 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -2 \\\\\n -9 \\\\\n 3 \\\\\n -1 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$62$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [-8],\n [-2],\n [5],\n [-6],\n [1]])\nb = np.array([\n [3],\n [-2],\n [-9],\n [3],\n [-1],\n [-8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 3 & -2 \\\\\n 2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & -1 \\\\\n 1 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -2],\n [2, -2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -9 & -5 & 7 & 5 & 9 & -8 & 7 \\\\\n -2 & 6 & -5 & -8 & -2 & -5 & -7 \\\\\n -10 & -2 & -4 & -6 & 3 & -6 & 2 \\\\\n -10 & 10 & -9 & 4 & -4 & 9 & 2 \\\\\n -8 & -10 & -7 & -3 & -8 & 0 & 4 \\\\\n -7 & 5 & 5 & -2 & -9 & -6 & -1 \\\\\n -7 & -8 & -5 & 10 & -6 & -2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-9, -5, 7, 5, 9, -8, 7],\n [-2, 6, -5, -8, -2, -5, -7],\n [-10, -2, -4, -6, 3, -6, 2],\n [-10, 10, -9, 4, -4, 9, 2],\n [-8, -10, -7, -3, -8, 0, 4],\n [-7, 5, 5, -2, -9, -6, -1],\n [-7, -8, -5, 10, -6, -2, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & -\\frac{1}{2} \\\\\n -1 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{45}{8} & -\\frac{29}{8} \\\\\n -\\frac{29}{4} & -\\frac{45}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), -(1/2)],\n [-1, -(3/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{10}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 6 & 1 & 9 & 3 \\\\\n 7 & 8 & 0 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{3}{5} & \\frac{1}{10} & \\frac{9}{10} & \\frac{3}{10} \\\\\n \\frac{7}{10} & \\frac{4}{5} & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, 1, 9, 3],\n [7, 8, 0, 0]])\nprint(a * (1/10))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 6 \\\\\n -7 \\\\\n -6 \\\\\n -7 \\\\\n 7 \\\\\n 8 \\\\\n 2 \\\\\n 9 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -8 \\\\\n 1 \\\\\n 9 \\\\\n 0 \\\\\n 9 \\\\\n 9 \\\\\n -2 \\\\\n 7 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{611}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [6],\n [-7],\n [-6],\n [-7],\n [7],\n [8],\n [2],\n [9],\n [7]])\nb = np.array([\n [1],\n [-8],\n [1],\n [9],\n [0],\n [9],\n [9],\n [-2],\n [7],\n [3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & 4 & -5 \\\\\n 2 & -2 & 5 \\\\\n 1 & 4 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 4, -5],\n [2, -2, 5],\n [1, 4, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & 4 & 2 \\\\\n -2 & -5 & -2 \\\\\n -1 & -2 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{12}{43} & -\\frac{10}{43} & \\frac{1}{43} \\\\\n \\frac{5}{43} & -\\frac{3}{43} & -\\frac{4}{43} \\\\\n -\\frac{1}{86} & -\\frac{4}{43} & \\frac{9}{43} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 4, 2],\n [-2, -5, -2],\n [-1, -2, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -5 & 2 & 1 \\\\\n 3 & 0 & 2 \\\\\n 3 & 5 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{10}{53} & -\\frac{3}{53} & \\frac{4}{53} \\\\\n -\\frac{6}{53} & -\\frac{23}{53} & \\frac{13}{53} \\\\\n \\frac{15}{53} & \\frac{31}{53} & -\\frac{6}{53} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 2, 1],\n [3, 0, 2],\n [3, 5, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{37}{32}, \\frac{7}{8}}$ to the line $-\\frac{75 x}{32}+\\frac{117 y}{32}+\\frac{1}{2}=0$.", - "Output Answer": [ - "$\\frac{1013}{96 \\sqrt{2146}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (37/32), (7/8)\nline = Poly(-((75*x)/32)+((117*y)/32)+(1/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{1}{2},-\\frac{9}{2},\\frac{3}{2}\\right\\}, \\left\\{-\\frac{3}{2},-5,-\\frac{9}{2}\\right\\}, \\left\\{-\\frac{1}{2},2,-\\frac{1}{2}\\right\\}}$.", - "Output Answer": [ - "$160 x-8 y-26 z+83=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(1/2), -(9/2), (3/2)],\n [-(3/2), -5, -(9/2)],\n [-(1/2), 2, -(1/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 5 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 9 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -8 \\\\\n -12 \\\\\n -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [5],\n [-3]])\nb = np.array([\n [-10],\n [9],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{2}{5}, \\frac{7}{5}}$ to the line $-\\frac{39 x}{10}+\\frac{7 y}{2}+\\frac{3}{5}=0$.", - "Output Answer": [ - "$\\frac{353}{5 \\sqrt{2746}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(2/5), (7/5)\nline = Poly(-((39*x)/10)+((7*y)/2)+(3/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -6 \\\\\n 0 \\\\\n 9 \\\\\n -1 \\\\\n -2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-6],\n [0],\n [9],\n [-1],\n [-2],\n [3]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 1 & 1 & -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 4 & -6 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 5 & -5 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1, -6]])\nb = np.array([\n [4, -6, 6]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{757}{100} & -\\frac{653}{100} & \\frac{111}{50} & \\frac{183}{50} \\\\\n \\frac{267}{50} & \\frac{627}{100} & -\\frac{227}{25} & -\\frac{957}{100} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{19}{5} & -\\frac{36}{25} & \\frac{197}{50} & \\frac{731}{100} \\\\\n \\frac{167}{50} & \\frac{123}{20} & -\\frac{32}{25} & \\frac{453}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{377}{100} & -\\frac{797}{100} & \\frac{154}{25} & \\frac{1097}{100} \\\\\n \\frac{217}{25} & \\frac{621}{50} & -\\frac{259}{25} & -\\frac{51}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(757/100), -(653/100), (111/50), (183/50)],\n [(267/50), (627/100), -(227/25), -(957/100)]])\nb = np.array([\n [(19/5), -(36/25), (197/50), (731/100)],\n [(167/50), (123/20), -(32/25), (453/50)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{2}{25}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 8 & -1 & 7 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{16}{25} & -\\frac{2}{25} & \\frac{14}{25} & -\\frac{2}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -1, 7, -5]])\nprint(a * (2/25))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -4 \\\\\n -7 \\\\\n -7 \\\\\n -2 \\\\\n -8 \\\\\n 0 \\\\\n 6 \\\\\n -8 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 6 \\\\\n -3 \\\\\n 3 \\\\\n 4 \\\\\n -1 \\\\\n -9 \\\\\n -8 \\\\\n -8 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{149}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-4],\n [-7],\n [-7],\n [-2],\n [-8],\n [0],\n [6],\n [-8],\n [0]])\nb = np.array([\n [-9],\n [6],\n [-3],\n [3],\n [4],\n [-1],\n [-9],\n [-8],\n [-8],\n [-3]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{14}{\\sqrt{3}} \\\\\n \\frac{2}{\\sqrt{3}} \\\\\n \\frac{16}{\\sqrt{3}} \\\\\n -\\frac{4}{\\sqrt{3}} \\\\\n -\\frac{4}{\\sqrt{3}} \\\\\n 5 \\sqrt{3} \\\\\n -\\frac{2}{\\sqrt{3}} \\\\\n -4 \\sqrt{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\sqrt{3} \\\\\n \\frac{5}{\\sqrt{3}} \\\\\n -\\frac{8}{\\sqrt{3}} \\\\\n -\\frac{1}{\\sqrt{3}} \\\\\n \\frac{5}{\\sqrt{3}} \\\\\n \\frac{17}{\\sqrt{3}} \\\\\n 0 \\\\\n -\\frac{7}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{373}{3}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(14/(math.sqrt(3)))],\n [(2/(math.sqrt(3)))],\n [(16/(math.sqrt(3)))],\n [-(4/(math.sqrt(3)))],\n [-(4/(math.sqrt(3)))],\n [5*math.sqrt(3)],\n [-(2/(math.sqrt(3)))],\n [-4*math.sqrt(3)]])\nb = np.array([\n [-4*math.sqrt(3)],\n [(5/(math.sqrt(3)))],\n [-(8/(math.sqrt(3)))],\n [-(1/(math.sqrt(3)))],\n [(5/(math.sqrt(3)))],\n [(17/(math.sqrt(3)))],\n [0],\n [-(7/(math.sqrt(3)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 1 \\\\\n -9 \\\\\n -1 \\\\\n 3 \\\\\n 7 \\\\\n 5 \\\\\n 9 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -2 \\\\\n 4 \\\\\n 8 \\\\\n -6 \\\\\n -3 \\\\\n -1 \\\\\n -1 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$5 \\sqrt{37}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [1],\n [-9],\n [-1],\n [3],\n [7],\n [5],\n [9],\n [1]])\nb = np.array([\n [-8],\n [-2],\n [4],\n [8],\n [-6],\n [-3],\n [-1],\n [-1],\n [-4]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -3 & 5 \\\\\n 0 & 4 & 1 \\\\\n -3 & 5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$90$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -3, 5],\n [0, 4, 1],\n [-3, 5, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 9 & -10 \\\\\n 7 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, -10],\n [7, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9.074 \\\\\n -0.071 \\\\\n 8.012 \\\\\n -1.538 \\\\\n -4.314 \\\\\n -7.98 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1.739 \\\\\n 1.428 \\\\\n 1.335 \\\\\n -2.188 \\\\\n -4.634 \\\\\n -8.657 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10.0804$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9.074],\n [-0.071],\n [8.012],\n [-1.538],\n [-4.314],\n [-7.98]])\nb = np.array([\n [1.739],\n [1.428],\n [1.335],\n [-2.188],\n [-4.634],\n [-8.657]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 5 & 5 & -7 \\\\\n 3 & 9 & 6 \\\\\n 6 & -3 & 7 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -4 & 3 & -4 \\\\\n -2 & 7 & 5 \\\\\n -6 & -7 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 9 & 2 & -3 \\\\\n 5 & 2 & 1 \\\\\n 12 & 4 & 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 5, -7],\n [3, 9, 6],\n [6, -3, 7]])\nb = np.array([\n [-4, 3, -4],\n [-2, 7, 5],\n [-6, -7, -4]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{5}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 8 \\\\\n -1 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 6 \\\\\n \\frac{24}{5} \\\\\n -\\frac{3}{5} \\\\\n 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [8],\n [-1],\n [10]])\nprint(a * (3/5))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,0,2\\}, \\{3,2,-2\\}, \\{-3,-1,-1\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{2}},0,\\frac{1}{\\sqrt{2}}\\right\\}, \\left\\{\\frac{1}{3 \\sqrt{2}},\\frac{2 \\sqrt{2}}{3},\\frac{1}{3 \\sqrt{2}}\\right\\}, \\left\\{-\\frac{2}{3},\\frac{1}{3},-\\frac{2}{3}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, 0, 2), (3, 2, -2), (-3, -1, -1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{101}{16} \\\\\n \\frac{31}{4} \\\\\n \\frac{55}{8} \\\\\n -\\frac{17}{2} \\\\\n \\frac{1}{4} \\\\\n -\\frac{3}{4} \\\\\n -\\frac{133}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{13 \\sqrt{\\frac{219}{2}}}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(101/16)],\n [(31/4)],\n [(55/8)],\n [-(17/2)],\n [(1/4)],\n [-(3/4)],\n [-(133/16)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -2 \\\\\n -3 \\\\\n 0 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{2}{\\sqrt{17}} \\\\\n -\\frac{3}{\\sqrt{17}} \\\\\n 0 \\\\\n -\\frac{2}{\\sqrt{17}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-2],\n [-3],\n [0],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{17}{3} & \\frac{28}{3} \\\\\n -\\frac{29}{3} & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{3} \\left(-7-2 i \\sqrt{178}\\right),\\frac{1}{3} \\left(-7+2 i \\sqrt{178}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(17/3), (28/3)],\n [-(29/3), 1]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 0 & -5 & 7 \\\\\n -10 & 0 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 0 & 9 & -2 \\\\\n -2 & 2 & 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 4 & 5 \\\\\n -12 & 2 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -5, 7],\n [-10, 0, -3]])\nb = np.array([\n [0, 9, -2],\n [-2, 2, 4]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -\\frac{97}{50} & \\frac{603}{100} & -\\frac{879}{100} \\\\\n \\frac{469}{100} & -\\frac{287}{100} & -\\frac{699}{100} \\\\\n -\\frac{953}{100} & \\frac{116}{25} & \\frac{46}{5} \\\\\n -\\frac{497}{50} & -\\frac{114}{25} & -\\frac{499}{50} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{881}{100} & \\frac{861}{100} & -\\frac{399}{50} \\\\\n -\\frac{214}{25} & \\frac{619}{100} & \\frac{7}{2} \\\\\n -\\frac{41}{50} & \\frac{477}{100} & -\\frac{41}{100} \\\\\n -\\frac{1}{100} & -\\frac{146}{25} & -\\frac{107}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{687}{100} & \\frac{366}{25} & -\\frac{1677}{100} \\\\\n -\\frac{387}{100} & \\frac{83}{25} & -\\frac{349}{100} \\\\\n -\\frac{207}{20} & \\frac{941}{100} & \\frac{879}{100} \\\\\n -\\frac{199}{20} & -\\frac{52}{5} & -\\frac{221}{20} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(97/50), (603/100), -(879/100)],\n [(469/100), -(287/100), -(699/100)],\n [-(953/100), (116/25), (46/5)],\n [-(497/50), -(114/25), -(499/50)]])\nb = np.array([\n [(881/100), (861/100), -(399/50)],\n [-(214/25), (619/100), (7/2)],\n [-(41/50), (477/100), -(41/100)],\n [-(1/100), -(146/25), -(107/100)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -1 \\\\\n -2 \\\\\n -2 \\\\\n 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 7 \\\\\n -4 \\\\\n 6 \\\\\n -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-135$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-1],\n [-2],\n [-2],\n [7]])\nb = np.array([\n [6],\n [7],\n [-4],\n [6],\n [-10]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -1 & -3 & 1 \\\\\n -3 & -2 & -4 \\\\\n -1 & 5 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{42} & -\\frac{5}{21} & -\\frac{1}{6} \\\\\n -\\frac{19}{84} & \\frac{1}{21} & \\frac{1}{12} \\\\\n \\frac{17}{84} & -\\frac{2}{21} & \\frac{1}{12} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -3, 1],\n [-3, -2, -4],\n [-1, 5, 5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{4,5,-1\\}, \\{5,-2,3\\}, \\{-1,2,1\\}}$.", - "Output Answer": [ - "$x+11 y+19 z-40=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [4, 5, -1],\n [5, -2, 3],\n [-1, 2, 1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 5 & -2 \\\\\n 9 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+x-12$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -2],\n [9, -6]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 5 & 10 \\\\\n -6 & 2 \\\\\n -2 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 1 & -9 \\\\\n -8 & -3 \\\\\n -4 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 6 & 1 \\\\\n -14 & -1 \\\\\n -6 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 10],\n [-6, 2],\n [-2, 2]])\nb = np.array([\n [1, -9],\n [-8, -3],\n [-4, 3]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -2 & 0 & -1 & 2 \\\\\n 2 & 1 & 3 & -1 \\\\\n 0 & -1 & 2 & 0 \\\\\n 3 & 0 & 0 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 0 & -2 & 3 \\\\\n -2 & 0 & 3 \\\\\n -1 & -2 & 1 \\\\\n 0 & -2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 2 & -9 \\\\\n -5 & -8 & 13 \\\\\n 0 & -4 & -1 \\\\\n 0 & -4 & 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, -1, 2],\n [2, 1, 3, -1],\n [0, -1, 2, 0],\n [3, 0, 0, -1]])\nb = np.array([\n [0, -2, 3],\n [-2, 0, 3],\n [-1, -2, 1],\n [0, -2, -1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -6 & 6 & -2 & 0 \\\\\n 7 & -8 & 8 & 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -8 & -4 & 8 & 4 \\\\\n 5 & 1 & -5 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -14 & 2 & 6 & 4 \\\\\n 12 & -7 & 3 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 6, -2, 0],\n [7, -8, 8, 6]])\nb = np.array([\n [-8, -4, 8, 4],\n [5, 1, -5, -9]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n 3 & 6 & -3 \\\\\n -1 & 4 & -7 \\\\\n -1 & 9 & 3 \\\\\n -4 & 6 & 6 \\\\\n -6 & 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 6, -3],\n [-1, 4, -7],\n [-1, 9, 3],\n [-4, 6, 6],\n [-6, 0, 2]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{0,\\frac{9}{4},\\frac{9}{4}\\right\\}, \\left\\{\\frac{7}{4},\\frac{7}{4},1\\right\\}, \\left\\{\\frac{5}{2},-\\frac{3}{4},-\\frac{3}{2}\\right\\}}$", - "Output Answer": [ - "${\\left\\{0,\\frac{1}{\\sqrt{2}},\\frac{1}{\\sqrt{2}}\\right\\}, \\left\\{7 \\sqrt{\\frac{2}{107}},\\frac{3}{\\sqrt{214}},-\\frac{3}{\\sqrt{214}}\\right\\}, \\left\\{\\frac{3}{\\sqrt{107}},-\\frac{7}{\\sqrt{107}},\\frac{7}{\\sqrt{107}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, (9/4), (9/4)), ((7/4), (7/4), 1), ((5/2), -(3/4), -(3/2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 8 & 10 & 5 & -1 \\\\\n -3 & -10 & -7 & 9 \\\\\n -5 & 2 & 7 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -5 & 10 & 2 & 5 \\\\\n -1 & 5 & 4 & 4 \\\\\n -7 & -10 & -7 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 3 & 20 & 7 & 4 \\\\\n -4 & -5 & -3 & 13 \\\\\n -12 & -8 & 0 & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 10, 5, -1],\n [-3, -10, -7, 9],\n [-5, 2, 7, -1]])\nb = np.array([\n [-5, 10, 2, 5],\n [-1, 5, 4, 4],\n [-7, -10, -7, -6]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{\\sqrt{11}} \\\\\n \\frac{1}{\\sqrt{11}} \\\\\n 0 \\\\\n -\\frac{1}{\\sqrt{11}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [1],\n [0],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -5 \\\\\n 0 \\\\\n 0 \\\\\n 9 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-5],\n [0],\n [0],\n [9],\n [-2]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-69$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-9]])\nb = np.array([\n [-4],\n [5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & -1 & -3 \\\\\n -1 & 3 & 2 \\\\\n -1 & 0 & 1 \\\\\n 1 & -3 & 3 \\\\\n 0 & -3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.13 \\\\\n -1.9 \\\\\n -1.74 \\\\\n 2.71 \\\\\n 1.92 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.229 \\\\\n -0.444 \\\\\n 0.038 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -1, -3],\n [-1, 3, 2],\n [-1, 0, 1],\n [1, -3, 3],\n [0, -3, -3]])\nb = np.array([\n [-0.13],\n [-1.9],\n [-1.74],\n [2.71],\n [1.92]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{11}{6} & \\frac{25}{6} \\\\\n 4 & \\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{179}{18}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/6), (25/6)],\n [4, (11/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & 0 & 4 \\\\\n -1 & -4 & -3 \\\\\n 4 & 5 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$35$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 0, 4],\n [-1, -4, -3],\n [4, 5, 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{62}{7} & \\frac{10}{7} & -\\frac{31}{7} & 1 & \\frac{34}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(62/7), (10/7), -(31/7), 1, (34/7)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & 7 \\\\\n 4 & 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+4 x-49$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 7],\n [4, 3]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 1 & \\frac{8}{3} & -\\frac{7}{3} \\\\\n 4 & -\\frac{14}{3} & -3 \\\\\n -\\frac{2}{3} & \\frac{13}{3} & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{393}{263} & \\frac{249}{263} & \\frac{510}{263} \\\\\n -\\frac{90}{263} & \\frac{51}{263} & \\frac{171}{263} \\\\\n -\\frac{384}{263} & \\frac{165}{263} & \\frac{414}{263} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, (8/3), -(7/3)],\n [4, -(14/3), -3],\n [-(2/3), (13/3), -(1/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{19}{7}, \\frac{4}{7}}$ to the line $\\frac{15 x}{7}+4 y+\\frac{17}{7}=0$.", - "Output Answer": [ - "$\\frac{54}{7 \\sqrt{1009}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(19/7), (4/7)\nline = Poly(((15*x)/7)+4*y+(17/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -9 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -1 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -69 \\\\\n 82 \\\\\n 62 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-9],\n [3]])\nb = np.array([\n [6],\n [-1],\n [8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & \\frac{7}{2} \\\\\n -\\frac{9}{5} & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{63}{10}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, (7/2)],\n [-(9/5), 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -5 & 4 \\\\\n 10 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-10,3\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 4],\n [10, -2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -1 \\\\\n 0 \\\\\n 2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 3 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{14}{13},-\\frac{21}{13},0,0\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-1],\n [0],\n [2]]).squeeze()\nb = np.array([\n [2],\n [3],\n [0],\n [0]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{15}{8} \\\\\n 1 \\\\\n \\frac{3}{4} \\\\\n -\\frac{3}{8} \\\\\n -\\frac{3}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{15}{7 \\sqrt{7}} \\\\\n \\frac{8}{7 \\sqrt{7}} \\\\\n \\frac{6}{7 \\sqrt{7}} \\\\\n -\\frac{3}{7 \\sqrt{7}} \\\\\n -\\frac{3}{7 \\sqrt{7}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/8)],\n [1],\n [(3/4)],\n [-(3/8)],\n [-(3/8)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & -2 & 2 \\\\\n 0 & 1 & -1 \\\\\n 3 & -2 & -2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 10 & -10 & 2 \\\\\n -3 & 3 & 1 \\\\\n 0 & -4 & 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2, 2],\n [0, 1, -1],\n [3, -2, -2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -2 & 4 & 1 \\\\\n 4 & 2 & -3 \\\\\n 1 & 3 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{60} & \\frac{19}{60} & -\\frac{7}{30} \\\\\n \\frac{13}{60} & \\frac{7}{60} & -\\frac{1}{30} \\\\\n \\frac{1}{6} & \\frac{1}{6} & -\\frac{1}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 4, 1],\n [4, 2, -3],\n [1, 3, -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 0 & -\\frac{17}{8} \\\\\n -\\frac{9}{8} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{8} & -\\frac{7}{8} & -\\frac{5}{8} \\\\\n -\\frac{9}{4} & 1 & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{153}{32} & -\\frac{17}{8} & \\frac{17}{16} \\\\\n \\frac{189}{64} & \\frac{31}{64} & \\frac{61}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -(17/8)],\n [-(9/8), -(1/2)]])\nb = np.array([\n [-(13/8), -(7/8), -(5/8)],\n [-(9/4), 1, -(1/2)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{8}{5} & \\frac{4}{5} & \\frac{22}{5} \\\\\n -\\frac{14}{5} & -4 & -\\frac{3}{5} \\\\\n -\\frac{17}{5} & 1 & -\\frac{14}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{2392}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/5), (4/5), (22/5)],\n [-(14/5), -4, -(3/5)],\n [-(17/5), 1, -(14/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{21}{4} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{27}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(21/4)]])\nb = np.array([\n [(3/2)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 2 & 10 & -8 & -8 \\\\\n -6 & -4 & 3 & -9 \\\\\n 9 & 0 & -3 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-190.,-186.,-367.,87.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, 10, -8, -8],\n [-6, -4, 3, -9],\n [9, 0, -3, 7]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & 0 & 3 \\\\\n -1 & 0 & 3 \\\\\n -3 & 2 & -3 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -5 & 6 & -3 \\\\\n -11 & 6 & -12 \\\\\n 1 & -6 & 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, 3],\n [-1, 0, 3],\n [-3, 2, -3]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 7 & -10 & -5 & 3 & 5 & -3 & 7 \\\\\n 9 & 10 & -8 & -8 & 2 & 10 & 8 \\\\\n -10 & -4 & -4 & -3 & 6 & -10 & 1 \\\\\n -8 & 9 & 5 & 4 & -10 & 9 & -7 \\\\\n 7 & -4 & 9 & -3 & 10 & 3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & \\frac{41386}{98015} & \\frac{5346}{19603} \\\\\n 0 & 1 & 0 & 0 & 0 & \\frac{212246}{98015} & \\frac{9085}{19603} \\\\\n 0 & 0 & 1 & 0 & 0 & -\\frac{1127}{19603} & -\\frac{12290}{19603} \\\\\n 0 & 0 & 0 & 1 & 0 & \\frac{235226}{98015} & \\frac{14363}{19603} \\\\\n 0 & 0 & 0 & 0 & 1 & \\frac{160972}{98015} & \\frac{17222}{19603} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, -10, -5, 3, 5, -3, 7],\n [9, 10, -8, -8, 2, 10, 8],\n [-10, -4, -4, -3, 6, -10, 1],\n [-8, 9, 5, 4, -10, 9, -7],\n [7, -4, 9, -3, 10, 3, 1]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{2,-\\frac{5}{2},-\\frac{1}{2}\\right\\}, \\left\\{-2,-3,\\frac{7}{2}\\right\\}, \\left\\{\\frac{1}{2},-3,0\\right\\}}$.", - "Output Answer": [ - "$-14 x+32 y-10 z+103=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, -(5/2), -(1/2)],\n [-2, -3, (7/2)],\n [(1/2), -3, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 4 & 7 & 1 \\\\\n -10 & -3 & 9 \\\\\n 6 & 3 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-9.322,0.661\\, -5.281 i,0.661\\, +5.281 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 7, 1],\n [-10, -3, 9],\n [6, 3, -9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,-3,-5\\}, \\left\\{5,-\\frac{1}{2},-\\frac{1}{2}\\right\\}, \\left\\{-\\frac{3}{2},2,-\\frac{7}{2}\\right\\}}$.", - "Output Answer": [ - "$75 x+9 y-155 z-448=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, -3, -5],\n [5, -(1/2), -(1/2)],\n [-(3/2), 2, -(7/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & 1 & -2 \\\\\n -\\frac{3}{2} & \\frac{3}{2} & \\frac{1}{2} \\\\\n -\\frac{3}{2} & -2 & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{7}{2} & \\frac{87}{4} & -6 \\\\\n -\\frac{135}{8} & -\\frac{107}{8} & \\frac{81}{8} \\\\\n \\frac{27}{8} & -9 & -\\frac{35}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, -2],\n [-(3/2), (3/2), (1/2)],\n [-(3/2), -2, -(1/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -2 & -4 \\\\\n -1 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & 2 \\\\\n \\frac{1}{2} & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -4],\n [-1, -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{3}{2} & \\frac{12}{5} & \\frac{97}{10} & -\\frac{3}{10} \\\\\n -\\frac{7}{10} & \\frac{47}{10} & \\frac{16}{5} & -\\frac{21}{10} \\\\\n \\frac{9}{10} & -\\frac{29}{5} & \\frac{67}{10} & -4 \\\\\n -\\frac{13}{2} & -\\frac{1}{10} & \\frac{11}{5} & -\\frac{9}{10} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{87}{10} & \\frac{13}{2} & \\frac{34}{5} & -\\frac{23}{5} \\\\\n 4 & -\\frac{46}{5} & \\frac{13}{10} & -\\frac{81}{10} \\\\\n -\\frac{67}{10} & \\frac{1}{2} & \\frac{57}{10} & -\\frac{49}{10} \\\\\n \\frac{4}{5} & \\frac{18}{5} & \\frac{49}{10} & \\frac{83}{10} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{51}{5} & -\\frac{41}{10} & \\frac{29}{10} & \\frac{43}{10} \\\\\n -\\frac{47}{10} & \\frac{139}{10} & \\frac{19}{10} & 6 \\\\\n \\frac{38}{5} & -\\frac{63}{10} & 1 & \\frac{9}{10} \\\\\n -\\frac{73}{10} & -\\frac{37}{10} & -\\frac{27}{10} & -\\frac{46}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), (12/5), (97/10), -(3/10)],\n [-(7/10), (47/10), (16/5), -(21/10)],\n [(9/10), -(29/5), (67/10), -4],\n [-(13/2), -(1/10), (11/5), -(9/10)]])\nb = np.array([\n [-(87/10), (13/2), (34/5), -(23/5)],\n [4, -(46/5), (13/10), -(81/10)],\n [-(67/10), (1/2), (57/10), -(49/10)],\n [(4/5), (18/5), (49/10), (83/10)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -9 \\\\\n -9 \\\\\n 0 \\\\\n 10 \\\\\n -7 \\\\\n -6 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -3 \\\\\n -6 \\\\\n -8 \\\\\n 2 \\\\\n -7 \\\\\n 4 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{307}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-9],\n [-9],\n [0],\n [10],\n [-7],\n [-6],\n [8]])\nb = np.array([\n [-5],\n [-3],\n [-6],\n [-8],\n [2],\n [-7],\n [4],\n [5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${0, 3}$ to the line $\\frac{7 y}{2}-5 x=0$.", - "Output Answer": [ - "$\\frac{21}{\\sqrt{149}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 0, 3\nline = Poly(((7*y)/2)-5*x, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{170}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-1]])\nb = np.array([\n [-7],\n [6]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-2$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 6 & -4 \\\\\n -9 & -6 \\\\\n 6 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -12 & 8 \\\\\n 18 & 12 \\\\\n -12 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -4],\n [-9, -6],\n [6, -4]])\nprint(a * -2)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -\\frac{19}{2} \\\\\n 1 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n \\frac{29}{4} \\\\\n \\frac{31}{4} \\\\\n \\frac{39}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(25 \\sqrt{\\frac{3}{737237}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-(19/2)],\n [1],\n [6]]).squeeze()\nb = np.array([\n [-2],\n [(29/4)],\n [(31/4)],\n [(39/4)]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n 2 & -5 & -1 & 7 \\\\\n 1 & 0 & -7 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -5, -1, 7],\n [1, 0, -7, 3]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 3 & -10 & -5 & 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 7 & 3 & 8 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 10 & -7 & 3 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -10, -5, 9]])\nb = np.array([\n [7, 3, 8, -2]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\sqrt{5} \\\\\n -4 \\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n -4 \\sqrt{5} \\\\\n 0 \\\\\n -3 \\sqrt{5} \\\\\n -\\sqrt{5} \\\\\n 3 \\sqrt{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\sqrt{5} \\\\\n 0 \\\\\n 2 \\sqrt{5} \\\\\n -3 \\sqrt{5} \\\\\n -\\sqrt{5} \\\\\n -2 \\sqrt{5} \\\\\n -3 \\sqrt{5} \\\\\n -2 \\sqrt{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$175$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-3*math.sqrt(5)],\n [-4*math.sqrt(5)],\n [4*math.sqrt(5)],\n [-4*math.sqrt(5)],\n [0],\n [-3*math.sqrt(5)],\n [-math.sqrt(5)],\n [3*math.sqrt(5)]])\nb = np.array([\n [-4*math.sqrt(5)],\n [0],\n [2*math.sqrt(5)],\n [-3*math.sqrt(5)],\n [-math.sqrt(5)],\n [-2*math.sqrt(5)],\n [-3*math.sqrt(5)],\n [-2*math.sqrt(5)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{82}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [4]])\nb = np.array([\n [1],\n [-5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{3}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 10 & -3 & 1 \\\\\n -5 & -6 & -6 \\\\\n -6 & 8 & 7 \\\\\n 10 & -4 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{50}{3} & -5 & \\frac{5}{3} \\\\\n -\\frac{25}{3} & -10 & -10 \\\\\n -10 & \\frac{40}{3} & \\frac{35}{3} \\\\\n \\frac{50}{3} & -\\frac{20}{3} & \\frac{35}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -3, 1],\n [-5, -6, -6],\n [-6, 8, 7],\n [10, -4, 7]])\nprint(a * (5/3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{359}{100} \\\\\n -\\frac{31}{20} \\\\\n \\frac{129}{20} \\\\\n -\\frac{837}{100} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{47}{20} \\\\\n \\frac{43}{10} \\\\\n -\\frac{49}{10} \\\\\n -\\frac{35}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{297}{50} \\\\\n \\frac{11}{4} \\\\\n \\frac{31}{20} \\\\\n -\\frac{428}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(359/100)],\n [-(31/20)],\n [(129/20)],\n [-(837/100)]])\nb = np.array([\n [(47/20)],\n [(43/10)],\n [-(49/10)],\n [-(35/4)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{9}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -10 \\\\\n 6 \\\\\n 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{56}{9} \\\\\n \\frac{70}{9} \\\\\n -\\frac{14}{3} \\\\\n -\\frac{70}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-10],\n [6],\n [10]])\nprint(a * -(7/9))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -3 & 7 & 10 & -3 & -3 \\\\\n -10 & -4 & 8 & 10 & 4 \\\\\n 9 & 10 & 0 & 1 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-464.,402.,-405.,0.,52.\\}, \\{-334.,298.,-301.,26.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-3, 7, 10, -3, -3],\n [-10, -4, 8, 10, 4],\n [9, 10, 0, 1, 3]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{4} \\\\\n -\\frac{3}{2} \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{4} \\\\\n \\frac{33}{4} \\\\\n -\\frac{39}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{279}{16} \\\\\n -\\frac{489}{32} \\\\\n -\\frac{285}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/4)],\n [-(3/2)],\n [3]])\nb = np.array([\n [-(9/4)],\n [(33/4)],\n [-(39/8)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{25}{3} & -\\frac{13}{3} & -\\frac{5}{3} \\\\\n -\\frac{14}{3} & \\frac{25}{3} & -\\frac{26}{3} \\\\\n -\\frac{17}{3} & \\frac{13}{3} & -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-2.148,-1.035,1.\\}, \\{-1.841,-0.267,1.\\}, \\{1.177,1.778,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(25/3), -(13/3), -(5/3)],\n [-(14/3), (25/3), -(26/3)],\n [-(17/3), (13/3), -(2/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 3 \\\\\n -8 \\\\\n -10 \\\\\n 0 \\\\\n -5 \\\\\n 2 \\\\\n -6 \\\\\n -9 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -3 \\\\\n 7 \\\\\n 2 \\\\\n -4 \\\\\n -5 \\\\\n -9 \\\\\n 6 \\\\\n -1 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{818}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [3],\n [-8],\n [-10],\n [0],\n [-5],\n [2],\n [-6],\n [-9],\n [3]])\nb = np.array([\n [5],\n [-3],\n [7],\n [2],\n [-4],\n [-5],\n [-9],\n [6],\n [-1],\n [5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, \\frac{9}{2}}$ to the line $\\frac{7 y}{2}-5 x=0$.", - "Output Answer": [ - "$\\frac{123}{2 \\sqrt{149}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, (9/2)\nline = Poly(((7*y)/2)-5*x, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & -6 \\\\\n -8 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(9-\\sqrt{217}\\right),\\frac{1}{2} \\left(9+\\sqrt{217}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -6],\n [-8, 7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -4 & \\frac{1}{2} & -1 \\\\\n -\\frac{7}{2} & 2 & \\frac{9}{2} \\\\\n -4 & -\\frac{3}{2} & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{247}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, (1/2), -1],\n [-(7/2), 2, (9/2)],\n [-4, -(3/2), 2]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,-3,-3\\}, \\{2,2,-1\\}, \\{0,4,-4\\}}$.", - "Output Answer": [ - "$19 x+y-12 z-52=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -3, -3],\n [2, 2, -1],\n [0, 4, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & 1 & 1 \\\\\n -2 & 2 & -2 \\\\\n 2 & 0 & -3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -13 & 7 & 7 \\\\\n -14 & -6 & -14 \\\\\n 14 & 0 & -41 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1, 1],\n [-2, 2, -2],\n [2, 0, -3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 0 \\\\\n 3 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 3 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{21}{20},\\frac{21}{20},0,\\frac{7}{20},\\frac{7}{20}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [0],\n [3],\n [0],\n [1]]).squeeze()\nb = np.array([\n [3],\n [3],\n [0],\n [1],\n [1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{2}{3},\\frac{4}{3},-\\frac{7}{3}\\right\\}, \\left\\{\\frac{5}{3},5,-\\frac{4}{3}\\right\\}, \\left\\{\\frac{1}{3},-\\frac{14}{3},-\\frac{4}{3}\\right\\}}$.", - "Output Answer": [ - "$29 x-4 y-53 z-99=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(2/3), (4/3), -(7/3)],\n [(5/3), 5, -(4/3)],\n [(1/3), -(14/3), -(4/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{2} & 1 & \\frac{3}{2} \\\\\n -\\frac{1}{2} & -\\frac{3}{2} & -\\frac{3}{2} \\\\\n \\frac{5}{2} & \\frac{3}{2} & 1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{19}{2} & \\frac{13}{4} & \\frac{15}{4} \\\\\n -\\frac{17}{4} & -\\frac{1}{2} & 0 \\\\\n 8 & \\frac{7}{4} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2), 1, (3/2)],\n [-(1/2), -(3/2), -(3/2)],\n [(5/2), (3/2), 1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & -7 \\\\\n 5 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+8 x+47$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -7],\n [5, -6]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 3 \\\\\n 9 \\\\\n -3 \\\\\n -3 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -6 \\\\\n 5 \\\\\n 3 \\\\\n 1 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [3],\n [9],\n [-3],\n [-3],\n [3]])\nb = np.array([\n [1],\n [-6],\n [5],\n [3],\n [1],\n [-6]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-4]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -1 & -3 & -3 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -1 & -3 & -3 & -3 \\\\\n -2 & -6 & -6 & -6 \\\\\n 2 & 6 & 6 & 6 \\\\\n -2 & -6 & -6 & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [2],\n [-2],\n [2]])\nb = np.array([\n [-1, -3, -3, -3]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -5 & -5 & -8 & -10 \\\\\n -8 & -7 & 1 & 0 \\\\\n -6 & 2 & -1 & 6 \\\\\n 5 & 7 & -8 & -6 \\\\\n -2 & -4 & -2 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, -5, -8, -10],\n [-8, -7, 1, 0],\n [-6, 2, -1, 6],\n [5, 7, -8, -6],\n [-2, -4, -2, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{3} & -\\frac{11}{3} & \\frac{5}{3} \\\\\n -2 & -\\frac{2}{3} & -\\frac{11}{3} \\\\\n \\frac{5}{3} & -\\frac{1}{3} & -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{9}{1114} & -\\frac{123}{557} & \\frac{393}{1114} \\\\\n -\\frac{291}{1114} & \\frac{78}{557} & -\\frac{453}{1114} \\\\\n \\frac{24}{557} & -\\frac{99}{557} & -\\frac{66}{557} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/3), -(11/3), (5/3)],\n [-2, -(2/3), -(11/3)],\n [(5/3), -(1/3), -(7/3)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 1 & 3 \\\\\n 7 & -2 \\\\\n 10 & 5 \\\\\n -9 & 2 \\\\\n 5 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [1, 3],\n [7, -2],\n [10, 5],\n [-9, 2],\n [5, -3]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{4}{3},-\\frac{13}{3},5\\right\\}, \\left\\{\\frac{14}{3},\\frac{8}{3},0\\right\\}, \\left\\{-1,-\\frac{8}{3},-3\\right\\}}$.", - "Output Answer": [ - "$429 x-417 y-69 z-890=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(4/3), -(13/3), 5],\n [(14/3), (8/3), 0],\n [-1, -(8/3), -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{5}{\\sqrt{3}},-\\frac{4}{\\sqrt{3}},\\frac{5}{\\sqrt{3}}\\right\\}, \\left\\{\\frac{4}{\\sqrt{3}},-\\frac{5}{\\sqrt{3}},\\frac{4}{\\sqrt{3}}\\right\\}, \\left\\{\\sqrt{3},\\frac{1}{\\sqrt{3}},\\frac{2}{\\sqrt{3}}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{5}{\\sqrt{66}},-2 \\sqrt{\\frac{2}{33}},\\frac{5}{\\sqrt{66}}\\right\\}, \\left\\{-\\frac{2}{\\sqrt{33}},-\\frac{5}{\\sqrt{33}},-\\frac{2}{\\sqrt{33}}\\right\\}, \\left\\{\\frac{\\sqrt{3}-\\frac{5}{2 \\sqrt{3}}}{\\sqrt{\\left(\\frac{10}{11 \\sqrt{3}}-\\frac{3 \\sqrt{3}}{22}\\right)^2+\\left(\\sqrt{3}-\\frac{5}{2 \\sqrt{3}}\\right)^2}},0,\\frac{\\frac{3 \\sqrt{3}}{22}-\\frac{10}{11 \\sqrt{3}}}{\\sqrt{\\left(\\frac{10}{11 \\sqrt{3}}-\\frac{3 \\sqrt{3}}{22}\\right)^2+\\left(\\sqrt{3}-\\frac{5}{2 \\sqrt{3}}\\right)^2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((5/(math.sqrt(3))), -(4/(math.sqrt(3))), (5/(math.sqrt(3)))), ((4/(math.sqrt(3))), -(5/(math.sqrt(3))), (4/(math.sqrt(3)))), (math.sqrt(3), (1/(math.sqrt(3))), (2/(math.sqrt(3))))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -2 & 10 & -\\frac{40}{9} \\\\\n 5 & -\\frac{74}{9} & \\frac{32}{9} \\\\\n -\\frac{26}{3} & -\\frac{11}{9} & \\frac{17}{3} \\\\\n -\\frac{44}{9} & -\\frac{55}{9} & \\frac{74}{9} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{23}{3} & \\frac{65}{9} & -\\frac{23}{3} \\\\\n -\\frac{19}{3} & -\\frac{2}{3} & \\frac{17}{3} \\\\\n \\frac{50}{9} & \\frac{88}{9} & \\frac{25}{3} \\\\\n \\frac{55}{9} & \\frac{59}{9} & \\frac{28}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{29}{3} & \\frac{25}{9} & \\frac{29}{9} \\\\\n \\frac{34}{3} & -\\frac{68}{9} & -\\frac{19}{9} \\\\\n -\\frac{128}{9} & -11 & -\\frac{8}{3} \\\\\n -11 & -\\frac{38}{3} & -\\frac{10}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 10, -(40/9)],\n [5, -(74/9), (32/9)],\n [-(26/3), -(11/9), (17/3)],\n [-(44/9), -(55/9), (74/9)]])\nb = np.array([\n [(23/3), (65/9), -(23/3)],\n [-(19/3), -(2/3), (17/3)],\n [(50/9), (88/9), (25/3)],\n [(55/9), (59/9), (28/3)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 10 & 0 & -1 & 3 & 4 & 9 \\\\\n 5 & 7 & 6 & 0 & 1 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & -\\frac{1}{10} & \\frac{3}{10} & \\frac{2}{5} & \\frac{9}{10} \\\\\n 0 & 1 & \\frac{13}{14} & -\\frac{3}{14} & -\\frac{1}{7} & \\frac{3}{14} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, 0, -1, 3, 4, 9],\n [5, 7, 6, 0, 1, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 6 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -3 \\\\\n 4 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [6],\n [1],\n [0]])\nb = np.array([\n [-3],\n [-3],\n [4],\n [-1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${5, 4}$ to the line $-\\frac{33 x}{7}+\\frac{34 y}{7}-\\frac{17}{7}=0$.", - "Output Answer": [ - "$\\frac{46}{\\sqrt{2245}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 5, 4\nline = Poly(-((33*x)/7)+((34*y)/7)-(17/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -8 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$17$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-8],\n [-1]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -1 \\\\\n -1 \\\\\n 2 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -3 \\\\\n 1 \\\\\n 0 \\\\\n 3 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{10}{23},\\frac{15}{23},-\\frac{5}{23},0,-\\frac{15}{23},0\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-1],\n [-1],\n [2],\n [-1],\n [-1]]).squeeze()\nb = np.array([\n [-2],\n [-3],\n [1],\n [0],\n [3],\n [0]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{32}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 7 \\\\\n 9 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{5}{16} \\\\\n \\frac{7}{32} \\\\\n \\frac{9}{32} \\\\\n -\\frac{5}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [7],\n [9],\n [-5]])\nprint(a * (1/32))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 0 & \\frac{19}{4} & -\\frac{19}{4} \\\\\n -\\frac{11}{4} & -\\frac{9}{2} & -2 \\\\\n -\\frac{9}{2} & \\frac{9}{2} & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{504}{12863} & -\\frac{76}{677} & -\\frac{104}{677} \\\\\n \\frac{620}{12863} & -\\frac{72}{677} & \\frac{44}{677} \\\\\n -\\frac{2088}{12863} & -\\frac{72}{677} & \\frac{44}{677} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, (19/4), -(19/4)],\n [-(11/4), -(9/2), -2],\n [-(9/2), (9/2), (1/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 3 & -1 & -3 \\\\\n 2 & -2 & -1 \\\\\n -3 & -4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{2}{39} & \\frac{3}{13} & -\\frac{5}{39} \\\\\n \\frac{3}{13} & -\\frac{6}{13} & -\\frac{1}{13} \\\\\n -\\frac{14}{39} & \\frac{5}{13} & -\\frac{4}{39} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, -3],\n [2, -2, -1],\n [-3, -4, -3]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{3}{4} & 0 & -\\frac{17}{8} & \\frac{23}{8} \\\\\n -\\frac{7}{8} & \\frac{21}{8} & -\\frac{5}{4} & \\frac{5}{4} \\\\\n \\frac{1}{8} & -\\frac{5}{4} & \\frac{11}{8} & \\frac{17}{8} \\\\\n -\\frac{13}{8} & \\frac{5}{8} & \\frac{13}{8} & -\\frac{1}{4} \\\\\n 2 & \\frac{19}{8} & \\frac{3}{2} & -\\frac{19}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{8} & \\frac{9}{8} & -2 \\\\\n \\frac{1}{2} & -\\frac{9}{8} & -\\frac{11}{8} \\\\\n \\frac{19}{8} & -\\frac{9}{4} & -\\frac{3}{2} \\\\\n -\\frac{9}{8} & \\frac{5}{8} & \\frac{13}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{2} & \\frac{367}{64} & \\frac{599}{64} \\\\\n -\\frac{63}{64} & -\\frac{11}{32} & \\frac{131}{64} \\\\\n -\\frac{3}{64} & -\\frac{7}{32} & \\frac{183}{64} \\\\\n \\frac{133}{16} & -\\frac{203}{32} & -\\frac{29}{64} \\\\\n \\frac{171}{64} & -\\frac{169}{32} & -\\frac{107}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/4), 0, -(17/8), (23/8)],\n [-(7/8), (21/8), -(5/4), (5/4)],\n [(1/8), -(5/4), (11/8), (17/8)],\n [-(13/8), (5/8), (13/8), -(1/4)],\n [2, (19/8), (3/2), -(19/8)]])\nb = np.array([\n [-(19/8), (9/8), -2],\n [(1/2), -(9/8), -(11/8)],\n [(19/8), -(9/4), -(3/2)],\n [-(9/8), (5/8), (13/8)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n \\frac{5}{2} \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n \\frac{9}{2} \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{47}{\\sqrt{2526}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2)],\n [(5/2)],\n [-5]]).squeeze()\nb = np.array([\n [7],\n [(9/2)],\n [-6]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 2 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 9 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 11 & -4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2]])\nb = np.array([\n [9, -6]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{5}{\\sqrt{26}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-2]]).squeeze()\nb = np.array([\n [-9],\n [-6]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{3}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{7}{3} \\\\\n -\\frac{14}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-2]])\nprint(a * (7/3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -10 & -8 & 0 \\\\\n -4 & 7 & -1 \\\\\n 3 & 10 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-11.566,3.359,7.207\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -8, 0],\n [-4, 7, -1],\n [3, 10, 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & 0 & 0 \\\\\n 1 & -3 & -1 \\\\\n 1 & 1 & -2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 0 & 0 \\\\\n -4 & 8 & 5 \\\\\n -1 & -5 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0, 0],\n [1, -3, -1],\n [1, 1, -2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 7 & -6 \\\\\n -5 & 9 \\\\\n 6 & -2 \\\\\n -3 & -8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n 3 & -1 \\\\\n -7 & 4 \\\\\n 2 & 4 \\\\\n 2 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 4 & -5 \\\\\n 2 & 5 \\\\\n 4 & -6 \\\\\n -5 & -14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, -6],\n [-5, 9],\n [6, -2],\n [-3, -8]])\nb = np.array([\n [3, -1],\n [-7, 4],\n [2, 4],\n [2, 6]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{9}{5}, 1}$ to the line $\\frac{23 x}{5}-\\frac{16 y}{5}-3=0$.", - "Output Answer": [ - "$\\frac{52}{5 \\sqrt{785}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (9/5), 1\nline = Poly(((23*x)/5)-((16*y)/5)-3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{2}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -10 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -5 & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 5]])\nprint(a * (1/2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{5} & \\frac{28}{5} & 3 \\\\\n \\frac{38}{5} & -\\frac{36}{5} & -\\frac{31}{5} \\\\\n -\\frac{4}{5} & -\\frac{26}{5} & \\frac{7}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-12.649,4.119,5.329\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/5), (28/5), 3],\n [(38/5), -(36/5), -(31/5)],\n [-(4/5), -(26/5), (7/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 10 & -7 & 0 & 8 & -10 \\\\\n -5 & 2 & -4 & 9 & -4 \\\\\n 7 & -4 & 8 & 2 & -4 \\\\\n -10 & 1 & 9 & 10 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{7876.,9310.,-981.,3840.,4431.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [10, -7, 0, 8, -10],\n [-5, 2, -4, 9, -4],\n [7, -4, 8, 2, -4],\n [-10, 1, 9, 10, 9]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & 10 & -4 \\\\\n 9 & 10 & 1 \\\\\n 1 & -7 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-4.893,3.897,15.996\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 10, -4],\n [9, 10, 1],\n [1, -7, 6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 3 & 7 & -9 \\\\\n 3 & -6 & -9 \\\\\n 5 & 0 & -3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-6 x^2-15 x-468$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 7, -9],\n [3, -6, -9],\n [5, 0, -3]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{40}{7} \\\\\n 0 \\\\\n \\frac{2}{7} \\\\\n -\\frac{48}{7} \\\\\n 6 \\\\\n -\\frac{38}{7} \\\\\n \\frac{25}{7} \\\\\n -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{48}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(40/7)],\n [0],\n [(2/7)],\n [-(48/7)],\n [6],\n [-(38/7)],\n [(25/7)],\n [-6]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n 2 \\\\\n 1 \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\sqrt{\\frac{2}{11}} \\\\\n -\\sqrt{\\frac{2}{11}} \\\\\n \\sqrt{\\frac{2}{11}} \\\\\n \\frac{1}{\\sqrt{22}} \\\\\n -\\frac{3}{\\sqrt{22}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-2],\n [2],\n [1],\n [-3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{137}{50} & \\frac{37}{50} \\\\\n -\\frac{211}{100} & \\frac{129}{25} \\\\\n -\\frac{181}{20} & \\frac{53}{100} \\\\\n -\\frac{149}{100} & \\frac{81}{50} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{156}{25} & \\frac{79}{25} \\\\\n \\frac{201}{100} & -\\frac{991}{100} \\\\\n \\frac{263}{100} & -\\frac{134}{25} \\\\\n \\frac{121}{100} & -\\frac{34}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{7}{2} & \\frac{39}{10} \\\\\n -\\frac{1}{10} & -\\frac{19}{4} \\\\\n -\\frac{321}{50} & -\\frac{483}{100} \\\\\n -\\frac{7}{25} & \\frac{13}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(137/50), (37/50)],\n [-(211/100), (129/25)],\n [-(181/20), (53/100)],\n [-(149/100), (81/50)]])\nb = np.array([\n [-(156/25), (79/25)],\n [(201/100), -(991/100)],\n [(263/100), -(134/25)],\n [(121/100), -(34/25)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{2}{3} \\\\\n -\\frac{2}{3} \\\\\n \\frac{2}{3} \\\\\n 1 \\\\\n -\\frac{1}{3} \\\\\n \\frac{5}{3} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{8}{3} \\\\\n -3 \\\\\n \\frac{7}{3} \\\\\n \\frac{2}{3} \\\\\n -\\frac{5}{3} \\\\\n \\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{632}{717},-\\frac{237}{239},\\frac{553}{717},\\frac{158}{717},-\\frac{395}{717},\\frac{316}{717}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/3)],\n [-(2/3)],\n [(2/3)],\n [1],\n [-(1/3)],\n [(5/3)]]).squeeze()\nb = np.array([\n [(8/3)],\n [-3],\n [(7/3)],\n [(2/3)],\n [-(5/3)],\n [(4/3)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-3$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -7 & -7 & 5 & 5 \\\\\n -2 & 10 & -10 & 7 \\\\\n 3 & -2 & 4 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 21 & 21 & -15 & -15 \\\\\n 6 & -30 & 30 & -21 \\\\\n -9 & 6 & -12 & -27 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -7, 5, 5],\n [-2, 10, -10, 7],\n [3, -2, 4, 9]])\nprint(a * -3)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2}+\\frac{i}{2} & \\frac{3}{2}+\\frac{3 i}{2} \\\\\n -\\frac{9}{2}+2 i & \\frac{9}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{31}{4}-\\frac{21 i}{4} & \\frac{15}{4}+\\frac{21 i}{4} \\\\\n -\\frac{29}{2}+\\frac{15 i}{4} & \\frac{21}{2}-\\frac{15 i}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2)+(1j/2), (3/2)+((3j)/2)],\n [-(9/2)+2j, (9/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -6 \\\\\n -8 \\\\\n 9 \\\\\n 9 \\\\\n 0 \\\\\n -9 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 1 \\\\\n -6 \\\\\n 7 \\\\\n 1 \\\\\n -7 \\\\\n 1 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$123$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-6],\n [-8],\n [9],\n [9],\n [0],\n [-9],\n [0]])\nb = np.array([\n [-2],\n [1],\n [-6],\n [7],\n [1],\n [-7],\n [1],\n [4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 4 & 3 & -6 & -10 & -5 \\\\\n 7 & 0 & -5 & 4 & 7 \\\\\n -5 & 9 & -1 & 1 & -1 \\\\\n 5 & -9 & 6 & 0 & -10 \\\\\n -2 & 0 & -7 & -10 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, 3, -6, -10, -5],\n [7, 0, -5, 4, 7],\n [-5, 9, -1, 1, -1],\n [5, -9, 6, 0, -10],\n [-2, 0, -7, -10, -4]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 1 & -8 & 2 & -6 & -8 \\\\\n 3 & 10 & -7 & -3 & 3 \\\\\n -2 & 6 & -5 & -6 & 2 \\\\\n -3 & -9 & 4 & 4 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & -\\frac{1630}{1301} \\\\\n 0 & 1 & 0 & 0 & -\\frac{1951}{1301} \\\\\n 0 & 0 & 1 & 0 & -\\frac{5062}{1301} \\\\\n 0 & 0 & 0 & 1 & \\frac{2377}{1301} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, -8, 2, -6, -8],\n [3, 10, -7, -3, 3],\n [-2, 6, -5, -6, 2],\n [-3, -9, 4, 4, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 7 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -6 \\\\\n -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -109 \\\\\n -100 \\\\\n -70 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [7],\n [-10]])\nb = np.array([\n [10],\n [-6],\n [-7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 9 & -4 & 10 & 0 \\\\\n -7 & 7 & 10 & 10 \\\\\n -3 & 10 & -10 & -9 \\\\\n -7 & 9 & -6 & -3 \\\\\n 6 & -5 & -10 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, -4, 10, 0],\n [-7, 7, 10, 10],\n [-3, 10, -10, -9],\n [-7, 9, -6, -3],\n [6, -5, -10, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 3 & 7 & 7 & -1 \\\\\n -3 & 9 & 9 & -6 \\\\\n 4 & 1 & -7 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-88.,205.,-149.,128.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [3, 7, 7, -1],\n [-3, 9, 9, -6],\n [4, 1, -7, -7]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-1$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & -2 & 1 & -1 \\\\\n 7 & -2 & 9 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -1 & 2 & -1 & 1 \\\\\n -7 & 2 & -9 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2, 1, -1],\n [7, -2, 9, 0]])\nprint(a * -1)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -1 & 2 & 1 & 0 \\\\\n -2 & -1 & -1 & -1 \\\\\n 2 & 2 & -2 & 0 \\\\\n -1 & 0 & 2 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n -2 & 0 \\\\\n 1 & -1 \\\\\n 2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -4 & -1 \\\\\n -3 & 2 \\\\\n -4 & 2 \\\\\n -3 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 2, 1, 0],\n [-2, -1, -1, -1],\n [2, 2, -2, 0],\n [-1, 0, 2, -2]])\nb = np.array([\n [1, 0],\n [-2, 0],\n [1, -1],\n [2, -1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -3 \\\\\n 3 \\\\\n -4 \\\\\n 9 \\\\\n -5 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$28$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-3],\n [3],\n [-4],\n [9],\n [-5],\n [1]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 4 & -7 & 4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 2 & 10 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 2 & -17 & 12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -7, 4]])\nb = np.array([\n [2, 10, -8]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-1,-\\frac{3}{2},1\\right\\}, \\left\\{0,-\\frac{1}{2},-\\frac{1}{2}\\right\\}, \\left\\{-\\frac{3}{2},-2,1\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{2}{\\sqrt{17}},-\\frac{3}{\\sqrt{17}},\\frac{2}{\\sqrt{17}}\\right\\}, \\left\\{\\frac{2}{\\sqrt{561}},-\\frac{14}{\\sqrt{561}},-\\frac{19}{\\sqrt{561}}\\right\\}, \\left\\{-\\frac{5}{\\sqrt{33}},\\frac{2}{\\sqrt{33}},-\\frac{2}{\\sqrt{33}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, -(3/2), 1), (0, -(1/2), -(1/2)), (-(3/2), -2, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 9 & 5 \\\\\n -6 & -2 \\\\\n -4 & -5 \\\\\n -7 & 10 \\\\\n -2 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [9, 5],\n [-6, -2],\n [-4, -5],\n [-7, 10],\n [-2, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -6 & 3 \\\\\n 2 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+12 x+30$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 3],\n [2, -6]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & 0 \\\\\n -5 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+2 x-8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0],\n [-5, -4]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 4 & 9 & 0 & 7 \\\\\n 3 & 3 & -3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{7.,-7.,0.,5.\\}, \\{9.,-4.,5.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [4, 9, 0, 7],\n [3, 3, -3, 0]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-1, 1, -\\frac{5}{2}}$ to the plane $-\\frac{5 x}{2}+\\frac{7 y}{2}+4 z+\\frac{7}{2}=0$.", - "Output Answer": [ - "$\\frac{1}{\\sqrt{138}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -1, 1, -(5/2)\nplane = Poly(-((5*x)/2)+((7*y)/2)+4*z+(7/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{2} & -\\frac{1}{2} \\\\\n -\\frac{5}{2} & -3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{19}{8} & -\\frac{9}{2} \\\\\n -\\frac{45}{2} & -\\frac{271}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), -(1/2)],\n [-(5/2), -3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -6 & 8 & 0 & -9 \\\\\n -2 & 4 & 10 & 1 \\\\\n 4 & -2 & 3 & -7 \\\\\n -8 & 5 & 9 & -5 \\\\\n -2 & -5 & -2 & -9 \\\\\n -9 & -3 & 5 & 1 \\\\\n 4 & 6 & -6 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-6, 8, 0, -9],\n [-2, 4, 10, 1],\n [4, -2, 3, -7],\n [-8, 5, 9, -5],\n [-2, -5, -2, -9],\n [-9, -3, 5, 1],\n [4, 6, -6, 5]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & -8 \\\\\n -\\frac{11}{2} & \\frac{19}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{23 x}{2}-25$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -8],\n [-(11/2), (19/2)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -3 \\\\\n -9 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-3],\n [-9],\n [-7]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -10 & -4 & -10 \\\\\n -3 & -9 & 4 \\\\\n 1 & 2 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-10, -4, -10],\n [-3, -9, 4],\n [1, 2, -4]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n -8 & -5 \\\\\n -2 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-8, -5],\n [-2, 7]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 2 & 1 & -5 \\\\\n -1 & 4 & -1 \\\\\n 0 & -1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{15}{29} & \\frac{1}{29} & \\frac{19}{29} \\\\\n \\frac{4}{29} & \\frac{8}{29} & \\frac{7}{29} \\\\\n \\frac{1}{29} & \\frac{2}{29} & \\frac{9}{29} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, -5],\n [-1, 4, -1],\n [0, -1, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 3 \\\\\n 3 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n \\frac{1}{2} \\\\\n \\frac{1}{2} \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [3],\n [3],\n [3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -7 & -3 & -8 & -9 \\\\\n -8 & 4 & 5 & -7 \\\\\n 4 & 10 & -9 & -2 \\\\\n 10 & -6 & -3 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, -3, -8, -9],\n [-8, 4, 5, -7],\n [4, 10, -9, -2],\n [10, -6, -3, 5]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{31}{10} & \\frac{17}{5} & \\frac{23}{5} \\\\\n -\\frac{19}{10} & -\\frac{17}{10} & \\frac{9}{2} \\\\\n -\\frac{11}{10} & \\frac{7}{10} & \\frac{13}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{7570}{8713} & -\\frac{5620}{8713} & \\frac{23120}{8713} \\\\\n -\\frac{10}{8713} & -\\frac{3000}{8713} & \\frac{5210}{8713} \\\\\n -\\frac{3200}{8713} & -\\frac{1570}{8713} & \\frac{11730}{8713} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(31/10), (17/5), (23/5)],\n [-(19/10), -(17/10), (9/2)],\n [-(11/10), (7/10), (13/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{5} & \\frac{18}{5} \\\\\n \\frac{7}{5} & -\\frac{9}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{7} \\left(8-\\sqrt{190}\\right),1\\right\\}, \\left\\{\\frac{1}{7} \\left(8+\\sqrt{190}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/5), (18/5)],\n [(7/5), -(9/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & -2 & -6 \\\\\n -5 & 9 & 1 \\\\\n -4 & 4 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-10.652,1.402,11.25\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2, -6],\n [-5, 9, 1],\n [-4, 4, -9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & -\\frac{47}{5} \\\\\n -\\frac{19}{5} & -\\frac{36}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{19} \\left(-28-\\sqrt{1677}\\right),1\\right\\}, \\left\\{\\frac{1}{19} \\left(\\sqrt{1677}-28\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -(47/5)],\n [-(19/5), -(36/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n 2 & 1 & 0 \\\\\n 2 & 3 & 1 \\\\\n -1 & 2 & 1 \\\\\n 1 & 2 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -1 & -1 \\\\\n -3 & 1 \\\\\n -1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -5 & -1 \\\\\n -12 & 0 \\\\\n -6 & 2 \\\\\n -6 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, 0],\n [2, 3, 1],\n [-1, 2, 1],\n [1, 2, -1]])\nb = np.array([\n [-1, -1],\n [-3, 1],\n [-1, -1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{4} & \\frac{3}{4} \\\\\n -\\frac{15}{4} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{8}{39} & -\\frac{4}{13} \\\\\n \\frac{20}{13} & -\\frac{4}{13} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/4), (3/4)],\n [-(15/4), (1/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 6 & 9 & -9 & 7 & 0 \\\\\n -4 & 4 & 9 & -9 & -5 \\\\\n 6 & -5 & -6 & 0 & 0 \\\\\n 4 & -5 & 3 & 2 & -9 \\\\\n 1 & -1 & -9 & -4 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [6, 9, -9, 7, 0],\n [-4, 4, 9, -9, -5],\n [6, -5, -6, 0, 0],\n [4, -5, 3, 2, -9],\n [1, -1, -9, -4, -5]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & 2 & -1 \\\\\n 10 & -6 & -6 \\\\\n 5 & 5 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-7.041,-3.979-3.889 i,-3.979+3.889 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2, -1],\n [10, -6, -6],\n [5, 5, -6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 5 \\\\\n 7 \\\\\n 6 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 9 \\\\\n 1 \\\\\n -3 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$56$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [5],\n [7],\n [6],\n [2]])\nb = np.array([\n [8],\n [9],\n [1],\n [-3],\n [-9]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6.409 \\\\\n 9.887 \\\\\n -9.182 \\\\\n -8.328 \\\\\n -1.452 \\\\\n 1.714 \\\\\n -8.882 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9.142 \\\\\n -4.561 \\\\\n -6.971 \\\\\n 3.885 \\\\\n -3.563 \\\\\n 6.555 \\\\\n 8.43 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$30.5323$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6.409],\n [9.887],\n [-9.182],\n [-8.328],\n [-1.452],\n [1.714],\n [-8.882]])\nb = np.array([\n [-9.142],\n [-4.561],\n [-6.971],\n [3.885],\n [-3.563],\n [6.555],\n [8.43]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{8}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -10 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{5}{4} & -\\frac{5}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 10]])\nprint(a * -(1/8))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{145}{16} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{85}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{115}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(145/16)]])\nb = np.array([\n [-(85/16)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{16}{5} & -3 \\\\\n 1 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{10}{17} & -\\frac{15}{17} \\\\\n \\frac{5}{17} & \\frac{16}{17} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(16/5), -3],\n [1, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -2 & -9 & -3 \\\\\n 4 & 3 & 10 \\\\\n 3 & -6 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+2 x^2-100 x-261$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -9, -3],\n [4, 3, 10],\n [3, -6, 1]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -6 & -2 & 0 & 8 & -10 \\\\\n 8 & 3 & 9 & 3 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -2, 0, 8, -10],\n [8, 3, 9, 3, -5]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{2} & \\frac{3}{2} & \\frac{5}{2} \\\\\n -\\frac{15}{2} & -5 & -\\frac{5}{2} \\\\\n -\\frac{19}{2} & 9 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{45 x^2}{2}-221 x-\\frac{7485}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/2), (3/2), (5/2)],\n [-(15/2), -5, -(5/2)],\n [-(19/2), 9, -8]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 2 & 1 & -2 & -2 & -1 \\\\\n 0 & -3 & 0 & 2 & 2 \\\\\n 1 & 3 & 1 & 1 & 3 \\\\\n 2 & 3 & -3 & 3 & 1 \\\\\n -2 & 0 & 0 & -1 & -3 \\\\\n 1 & 3 & -3 & 3 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.11 \\\\\n 0.68 \\\\\n -2.66 \\\\\n -1.98 \\\\\n 0.16 \\\\\n -1.17 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.269 \\\\\n -0.508 \\\\\n -0.353 \\\\\n -0.255 \\\\\n 0.034 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, -2, -2, -1],\n [0, -3, 0, 2, 2],\n [1, 3, 1, 1, 3],\n [2, 3, -3, 3, 1],\n [-2, 0, 0, -1, -3],\n [1, 3, -3, 3, 1]])\nb = np.array([\n [-0.11],\n [0.68],\n [-2.66],\n [-1.98],\n [0.16],\n [-1.17]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{3}{2}, 3, -\\frac{5}{2}}$ to the plane $-\\frac{3 x}{2}-3 y+2 z+\\frac{3}{2}=0$.", - "Output Answer": [ - "$\\frac{41}{2 \\sqrt{61}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(3/2), 3, -(5/2)\nplane = Poly(-((3*x)/2)-3*y+2*z+(3/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 6 & -6 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 9 & -2 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 15 & -8 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -6, 8]])\nb = np.array([\n [9, -2, -7]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & -10 \\\\\n 0 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0,0\\}, \\{1,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -10],\n [0, 9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 2 & 1 & 1 & -1 & 2 \\\\\n -3 & -1 & 3 & 2 & 1 \\\\\n -1 & 0 & 1 & -3 & 0 \\\\\n -2 & 2 & 0 & 3 & -3 \\\\\n 2 & 1 & 1 & 2 & 1 \\\\\n -3 & 3 & -1 & -2 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.39 \\\\\n 0.62 \\\\\n -2.72 \\\\\n -1.25 \\\\\n -0.05 \\\\\n 2.94 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.53 \\\\\n 0.67 \\\\\n -2.379 \\\\\n 0.704 \\\\\n 2.445 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1, 1, -1, 2],\n [-3, -1, 3, 2, 1],\n [-1, 0, 1, -3, 0],\n [-2, 2, 0, 3, -3],\n [2, 1, 1, 2, 1],\n [-3, 3, -1, -2, -2]])\nb = np.array([\n [-1.39],\n [0.62],\n [-2.72],\n [-1.25],\n [-0.05],\n [2.94]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{8}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{5}{4} \\\\\n -\\frac{3}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [3]])\nprint(a * -(1/8))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -3 & 1 & 7 \\\\\n 8 & 7 & -6 \\\\\n 2 & -5 & -10 \\\\\n 7 & 6 & 1 \\\\\n 7 & -4 & -4 \\\\\n -6 & -1 & -1 \\\\\n -6 & 7 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 1, 7],\n [8, 7, -6],\n [2, -5, -10],\n [7, 6, 1],\n [7, -4, -4],\n [-6, -1, -1],\n [-6, 7, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{10} & \\frac{11}{10} \\\\\n \\frac{29}{10} & -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{141}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/10), (11/10)],\n [(29/10), -(7/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{32}{9} & \\frac{49}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{58}{9} & \\frac{10}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{26}{9} & \\frac{79}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(32/9), (49/9)]])\nb = np.array([\n [(58/9), (10/3)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,-4,0\\}, \\{-3,-3,-2\\}, \\{4,-2,3\\}}$.", - "Output Answer": [ - "$7 x-19 y-6 z-48=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, -4, 0],\n [-3, -3, -2],\n [4, -2, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{2} & -2 \\\\\n -\\frac{3}{2} & -\\frac{13}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{x}{4}-\\frac{115}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2), -2],\n [-(3/2), -(13/4)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{2} & 3 & -\\frac{5}{6} \\\\\n -2 & -4 & \\frac{11}{3} \\\\\n \\frac{2}{3} & -\\frac{10}{3} & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{157}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), 3, -(5/6)],\n [-2, -4, (11/3)],\n [(2/3), -(10/3), 3]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-3$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 9 & 3 & 5 \\\\\n 3 & 2 & -9 \\\\\n -6 & 10 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -27 & -9 & -15 \\\\\n -9 & -6 & 27 \\\\\n 18 & -30 & 24 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 3, 5],\n [3, 2, -9],\n [-6, 10, -8]])\nprint(a * -3)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{19}{2} & -6 \\\\\n -\\frac{5}{2} & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{10} \\left(5-\\sqrt{265}\\right),1\\right\\}, \\left\\{\\frac{1}{10} \\left(5+\\sqrt{265}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/2), -6],\n [-(5/2), -7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n -2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 0 & -7 \\\\\n 2 & 0 \\\\\n 10 & 10 \\\\\n 6 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, -7],\n [2, 0],\n [10, 10],\n [6, -5]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -6 & -3 & -9 \\\\\n -2 & 1 & 6 \\\\\n 0 & 8 & 8 \\\\\n -8 & -7 & 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 3 & 9 & 0 \\\\\n 10 & 0 & 2 \\\\\n -1 & 3 & -6 \\\\\n -10 & 4 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -3 & 6 & -9 \\\\\n 8 & 1 & 8 \\\\\n -1 & 11 & 2 \\\\\n -18 & -3 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, -3, -9],\n [-2, 1, 6],\n [0, 8, 8],\n [-8, -7, 6]])\nb = np.array([\n [3, 9, 0],\n [10, 0, 2],\n [-1, 3, -6],\n [-10, 4, -6]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 3 & -3 \\\\\n 3 & 1 & 1 \\\\\n -1 & 2 & 0 \\\\\n -2 & 0 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.27 \\\\\n 2.19 \\\\\n 1.28 \\\\\n 2.53 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.301 \\\\\n 0.398 \\\\\n 0.316 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 3, -3],\n [3, 1, 1],\n [-1, 2, 0],\n [-2, 0, -2]])\nb = np.array([\n [-1.27],\n [2.19],\n [1.28],\n [2.53]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{16}{3} \\\\\n -\\frac{25}{3} \\\\\n -\\frac{16}{3} \\\\\n \\frac{20}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{3} \\\\\n -\\frac{5}{3} \\\\\n \\frac{26}{3} \\\\\n -\\frac{10}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 6 \\\\\n -\\frac{20}{3} \\\\\n -14 \\\\\n 10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(16/3)],\n [-(25/3)],\n [-(16/3)],\n [(20/3)]])\nb = np.array([\n [-(2/3)],\n [-(5/3)],\n [(26/3)],\n [-(10/3)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{49}{8} & -\\frac{45}{8} \\\\\n -\\frac{5}{8} & -\\frac{43}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{23 x}{2}+\\frac{941}{32}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(49/8), -(45/8)],\n [-(5/8), -(43/8)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{7}{4} \\\\\n \\frac{5}{4} \\\\\n 0 \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{7}{\\sqrt{174}} \\\\\n \\frac{5}{\\sqrt{174}} \\\\\n 0 \\\\\n -5 \\sqrt{\\frac{2}{87}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/4)],\n [(5/4)],\n [0],\n [-(5/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -2 & 1 \\\\\n -1 & 1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 3 & -1 \\\\\n 1 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 1],\n [-1, 1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -10 \\\\\n 7 \\\\\n -5 \\\\\n 7 \\\\\n -1 \\\\\n 5 \\\\\n -3 \\\\\n -8 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -10 \\\\\n -10 \\\\\n -7 \\\\\n 6 \\\\\n -6 \\\\\n -5 \\\\\n 1 \\\\\n -4 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{629}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-10],\n [7],\n [-5],\n [7],\n [-1],\n [5],\n [-3],\n [-8],\n [8]])\nb = np.array([\n [0],\n [-10],\n [-10],\n [-7],\n [6],\n [-6],\n [-5],\n [1],\n [-4],\n [-5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -\\frac{10}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{7}{\\sqrt{74}} \\\\\n -\\frac{5}{\\sqrt{74}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-(10/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\pi \\\\\n 3 \\pi \\\\\n \\pi \\\\\n 2 \\pi \\\\\n -2 \\pi \\\\\n -\\pi \\\\\n -3 \\pi \\\\\n 0 \\\\\n -2 \\pi \\\\\n 2 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\pi \\\\\n \\pi \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n -\\pi \\\\\n -\\pi \\\\\n 2 \\pi \\\\\n -\\pi \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{53} \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-math.pi],\n [3*math.pi],\n [math.pi],\n [2*math.pi],\n [-2*math.pi],\n [-math.pi],\n [-3*math.pi],\n [0],\n [-2*math.pi],\n [2*math.pi]])\nb = np.array([\n [2*math.pi],\n [math.pi],\n [0],\n [0],\n [0],\n [0],\n [-math.pi],\n [-math.pi],\n [2*math.pi],\n [-math.pi]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -1 & -5 & 7 & 8 \\\\\n -8 & 2 & 4 & -3 \\\\\n 1 & 9 & -7 & 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -6 & -8 & -3 & -5 \\\\\n 7 & -8 & 6 & -4 \\\\\n 3 & -8 & -2 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -7 & -13 & 4 & 3 \\\\\n -1 & -6 & 10 & -7 \\\\\n 4 & 1 & -9 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -5, 7, 8],\n [-8, 2, 4, -3],\n [1, 9, -7, 10]])\nb = np.array([\n [-6, -8, -3, -5],\n [7, -8, 6, -4],\n [3, -8, -2, -9]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 1 & -1 & 0 & 0 & 2 \\\\\n -1 & -2 & -2 & 2 & 3 \\\\\n -3 & -2 & 1 & -1 & -2 \\\\\n -1 & -2 & -3 & -1 & -3 \\\\\n -1 & 1 & -2 & -2 & 2 \\\\\n 3 & -3 & 0 & -1 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.04 \\\\\n 1.33 \\\\\n 1.29 \\\\\n 0.39 \\\\\n -1.38 \\\\\n -2.37 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.464 \\\\\n -0.306 \\\\\n 0.206 \\\\\n 0.406 \\\\\n 0.2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -1, 0, 0, 2],\n [-1, -2, -2, 2, 3],\n [-3, -2, 1, -1, -2],\n [-1, -2, -3, -1, -3],\n [-1, 1, -2, -2, 2],\n [3, -3, 0, -1, -3]])\nb = np.array([\n [2.04],\n [1.33],\n [1.29],\n [0.39],\n [-1.38],\n [-2.37]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 8 \\\\\n -9 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 3 \\\\\n -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 14 \\\\\n 5 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [8],\n [-9]])\nb = np.array([\n [-6],\n [3],\n [-9]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\sqrt{\\frac{2}{15}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [0],\n [1],\n [0],\n [1],\n [-1],\n [0]]).squeeze()\nb = np.array([\n [0],\n [-1],\n [1],\n [-1],\n [1],\n [-1],\n [1],\n [0]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n \\frac{5}{8} & -2 & \\frac{155}{16} & \\frac{99}{16} \\\\\n -4 & \\frac{105}{16} & \\frac{57}{8} & -\\frac{9}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/8), -2, (155/16), (99/16)],\n [-4, (105/16), (57/8), -(9/16)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -7 \\\\\n -6 \\\\\n 1 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{127}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-7],\n [-6],\n [1],\n [4]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{1}{5}, -\\frac{6}{5}, \\frac{19}{5}}$ to the plane $\\frac{18 x}{5}+\\frac{14 y}{5}+\\frac{11 z}{5}-2=0$.", - "Output Answer": [ - "$\\frac{93}{5 \\sqrt{641}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (1/5), -(6/5), (19/5)\nplane = Poly(((18*x)/5)+((14*y)/5)+((11*z)/5)-2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 5 & -8 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-8.,0.,5.\\}, \\{8.,5.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [5, -8, 8]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{2} \\\\\n -6 \\\\\n \\frac{17}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n \\frac{29}{4} \\\\\n \\frac{15}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{673}{8} \\\\\n -\\frac{187}{8} \\\\\n \\frac{541}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/2)],\n [-6],\n [(17/2)]])\nb = np.array([\n [1],\n [(29/4)],\n [(15/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{4} & \\frac{67}{16} & -\\frac{75}{16} \\\\\n -\\frac{39}{8} & \\frac{15}{4} & -\\frac{31}{16} \\\\\n -\\frac{39}{8} & -\\frac{29}{8} & -\\frac{71}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1864}{8441} & -\\frac{36428}{109733} & -\\frac{9692}{109733} \\\\\n \\frac{960}{8441} & \\frac{1816}{109733} & -\\frac{13976}{109733} \\\\\n -\\frac{2832}{8441} & \\frac{38536}{109733} & -\\frac{2664}{109733} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/4), (67/16), -(75/16)],\n [-(39/8), (15/4), -(31/16)],\n [-(39/8), -(29/8), -(71/16)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{3} & -4 & -\\frac{10}{3} \\\\\n \\frac{11}{6} & -\\frac{10}{3} & \\frac{2}{3} \\\\\n -\\frac{13}{3} & -\\frac{5}{2} & \\frac{13}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{205}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/3), -4, -(10/3)],\n [(11/6), -(10/3), (2/3)],\n [-(13/3), -(5/2), (13/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{19}{6} & -\\frac{5}{6} \\\\\n \\frac{9}{2} & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{121}{12}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/6), -(5/6)],\n [(9/2), 2]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{33}{7} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{39}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{6}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(33/7)]])\nb = np.array([\n [(39/7)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -9 & 1 & -1 \\\\\n 9 & 8 & 5 \\\\\n 5 & 0 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 1, -1],\n [9, 8, 5],\n [5, 0, -5]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -9 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 6 \\\\\n 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -54 \\\\\n 36 \\\\\n 36 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-9],\n [0]])\nb = np.array([\n [8],\n [6],\n [6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -9 \\\\\n -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -45 \\\\\n 44 \\\\\n -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [-5]])\nb = np.array([\n [-7],\n [-9],\n [-9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -7 & 6 & -10 & -7 & 0 \\\\\n -1 & 10 & 6 & -10 & 10 \\\\\n -7 & -9 & -2 & -7 & -5 \\\\\n 3 & -5 & -3 & 7 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-31620.,5521.,12190.,18938.,2941.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, 6, -10, -7, 0],\n [-1, 10, 6, -10, 10],\n [-7, -9, -2, -7, -5],\n [3, -5, -3, 7, 9]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(\\sqrt{3}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [1],\n [-1],\n [0]]).squeeze()\nb = np.array([\n [1],\n [-1],\n [0],\n [-1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2} & -\\frac{5}{2} \\\\\n -\\frac{5}{2} & -1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{101}{8} & -20 \\\\\n -20 & -\\frac{133}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), -(5/2)],\n [-(5/2), -1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -3 \\\\\n 3 \\\\\n \\frac{5}{2} \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{4}{3 \\sqrt{13}} \\\\\n -\\frac{2}{\\sqrt{13}} \\\\\n \\frac{2}{\\sqrt{13}} \\\\\n \\frac{5}{3 \\sqrt{13}} \\\\\n \\frac{2}{3 \\sqrt{13}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-3],\n [3],\n [(5/2)],\n [1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-\\frac{11}{3},3,-\\frac{2}{3}\\right\\}, \\left\\{\\frac{5}{3},2,-\\frac{5}{3}\\right\\}, \\left\\{-\\frac{14}{3},\\frac{14}{3},\\frac{10}{3}\\right\\}}$.", - "Output Answer": [ - "$63 x+549 y-213 z-1558=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-(11/3), 3, -(2/3)],\n [(5/3), 2, -(5/3)],\n [-(14/3), (14/3), (10/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n 10 & \\frac{26}{3} & 0 & \\frac{26}{3} \\\\\n -\\frac{28}{3} & -\\frac{28}{3} & \\frac{14}{3} & \\frac{23}{3} \\\\\n -\\frac{10}{3} & -1 & \\frac{19}{3} & -7 \\\\\n \\frac{26}{3} & -10 & -10 & \\frac{13}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, (26/3), 0, (26/3)],\n [-(28/3), -(28/3), (14/3), (23/3)],\n [-(10/3), -1, (19/3), -7],\n [(26/3), -10, -10, (13/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n 3 & -8 & -1 & 8 \\\\\n 2 & 4 & 7 & -2 \\\\\n 6 & -7 & 5 & 7 \\\\\n -4 & 6 & 5 & 3 \\\\\n -6 & -7 & 5 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -8, -1, 8],\n [2, 4, 7, -2],\n [6, -7, 5, 7],\n [-4, 6, 5, 3],\n [-6, -7, 5, -4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 1 & 3 \\\\\n \\frac{3}{2} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{67}{4} & \\frac{111}{4} \\\\\n \\frac{111}{8} & \\frac{171}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3],\n [(3/2), (3/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -1 & 3 & -10 \\\\\n -9 & -6 & 0 \\\\\n -8 & 6 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, 3, -10],\n [-9, -6, 0],\n [-8, 6, 0]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{8}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{8}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(8/7)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{2}{5} \\\\\n -\\frac{83}{10} \\\\\n -\\frac{39}{5} \\\\\n -\\frac{17}{10} \\\\\n -\\frac{31}{10} \\\\\n -\\frac{17}{10} \\\\\n 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{2 \\sqrt{1133}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/5)],\n [-(83/10)],\n [-(39/5)],\n [-(17/10)],\n [-(31/10)],\n [-(17/10)],\n [6]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{4}{5} & 2 & \\frac{8}{5} & -\\frac{44}{5} \\\\\n \\frac{9}{5} & -\\frac{28}{5} & \\frac{42}{5} & \\frac{16}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{12}{5} & -\\frac{14}{5} & \\frac{12}{5} & 3 \\\\\n -\\frac{47}{5} & -\\frac{13}{5} & 8 & -\\frac{32}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{16}{5} & -\\frac{4}{5} & 4 & -\\frac{29}{5} \\\\\n -\\frac{38}{5} & -\\frac{41}{5} & \\frac{82}{5} & -\\frac{16}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/5), 2, (8/5), -(44/5)],\n [(9/5), -(28/5), (42/5), (16/5)]])\nb = np.array([\n [(12/5), -(14/5), (12/5), 3],\n [-(47/5), -(13/5), 8, -(32/5)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,2,-5\\}, \\{4,3,4\\}, \\left\\{-\\frac{5}{2},\\frac{9}{2},-\\frac{1}{2}\\right\\}}$.", - "Output Answer": [ - "$9 (x+2 y)-7 z-62=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, 2, -5],\n [4, 3, 4],\n [-(5/2), (9/2), -(1/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{4}{5}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5]])\nprint(a * (4/5))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 10 & 8 & 7 & 5 \\\\\n -10 & -3 & -5 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-19.,-20.,50.,0.\\}, \\{39.,-80.,0.,50.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [10, 8, 7, 5],\n [-10, -3, -5, 3]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{7}{2},2,2\\right\\}, \\{-4,2,-1\\}, \\left\\{\\frac{9}{2},\\frac{7}{2},-\\frac{9}{2}\\right\\}}$.", - "Output Answer": [ - "$2 x-23 y-5 z+49=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(7/2), 2, 2],\n [-4, 2, -1],\n [(9/2), (7/2), -(9/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\pi }{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [1],\n [0],\n [-1]]).squeeze()\nb = np.array([\n [1],\n [0],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 5 & 0 & 5 \\\\\n -5 & 6 & -1 \\\\\n 1 & 5 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{1.123,8.938\\, -4.245 i,8.938\\, +4.245 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 0, 5],\n [-5, 6, -1],\n [1, 5, 8]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 6 & -2 & 9 & 9 & -4 \\\\\n -3 & -8 & -5 & 3 & 10 \\\\\n -4 & -6 & 6 & -8 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & \\frac{742}{335} & \\frac{341}{335} \\\\\n 0 & 1 & 0 & -\\frac{267}{335} & -\\frac{547}{670} \\\\\n 0 & 0 & 1 & -\\frac{219}{335} & -\\frac{437}{335} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, -2, 9, 9, -4],\n [-3, -8, -5, 3, 10],\n [-4, -6, 6, -8, -7]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-4, 4}$ to the line $\\frac{9 x}{2}+\\frac{3 y}{2}+\\frac{5}{2}=0$.", - "Output Answer": [ - "$\\frac{19}{3 \\sqrt{10}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -4, 4\nline = Poly(((9*x)/2)+((3*y)/2)+(5/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{23}{8} \\\\\n -\\frac{21}{8} \\\\\n \\frac{1}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{23}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{529}{64} \\\\\n -\\frac{483}{64} \\\\\n \\frac{23}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/8)],\n [-(21/8)],\n [(1/4)]])\nb = np.array([\n [(23/8)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -\\frac{59}{8} & -\\frac{35}{8} \\\\\n -\\frac{35}{16} & 6 \\\\\n -\\frac{75}{8} & -\\frac{17}{8} \\\\\n -\\frac{115}{16} & -\\frac{127}{16} \\\\\n -\\frac{27}{16} & -\\frac{59}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(59/8), -(35/8)],\n [-(35/16), 6],\n [-(75/8), -(17/8)],\n [-(115/16), -(127/16)],\n [-(27/16), -(59/8)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 9 & 5 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-5.,9.,0.\\}, \\{2.,0.,9.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, 5, -2]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 3 & -3 & -3 & -3 & 1 \\\\\n 1 & 0 & -3 & -1 & -2 \\\\\n 2 & 0 & -2 & -2 & 1 \\\\\n -1 & 0 & 2 & 3 & 1 \\\\\n 3 & -3 & -1 & -1 & 0 \\\\\n -3 & -3 & -2 & 0 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.25 \\\\\n -1.35 \\\\\n -0.55 \\\\\n 0.27 \\\\\n 0.38 \\\\\n -2.59 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.365 \\\\\n 0.04 \\\\\n 0.714 \\\\\n -0.249 \\\\\n -0.046 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -3, -3, -3, 1],\n [1, 0, -3, -1, -2],\n [2, 0, -2, -2, 1],\n [-1, 0, 2, 3, 1],\n [3, -3, -1, -1, 0],\n [-3, -3, -2, 0, -3]])\nb = np.array([\n [-0.25],\n [-1.35],\n [-0.55],\n [0.27],\n [0.38],\n [-2.59]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{2} & \\frac{39}{8} & -\\frac{79}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n -\\frac{39}{8} & \\frac{9}{4} & \\frac{59}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{35}{8} & \\frac{21}{8} & -\\frac{69}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), (39/8), -(79/8)]])\nb = np.array([\n [-(39/8), (9/4), (59/8)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 0 & 6 & -6 & 5 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.,-5.,0.,6.,0.\\}, \\{0.,1.,1.,0.,0.\\}, \\{0.,5.,0.,0.,3.\\}, \\{1.,0.,0.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, 6, -6, 5, -10]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{11}{2} & -\\frac{39}{4} \\\\\n \\frac{15}{2} & \\frac{5}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{60} i \\left(\\sqrt{4391}-17 i\\right),1\\right\\}, \\left\\{-\\frac{1}{60} i \\left(\\sqrt{4391}+17 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/2), -(39/4)],\n [(15/2), (5/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{7}{2}, \\frac{3}{2}}$ to the line $5 x+\\frac{7 y}{2}+5=0$.", - "Output Answer": [ - "$\\frac{29}{2 \\sqrt{149}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(7/2), (3/2)\nline = Poly(5*x+((7*y)/2)+5, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{11}{3}, -1}$ to the line $2 x+\\frac{7 y}{3}+3=0$.", - "Output Answer": [ - "$\\frac{24}{\\sqrt{85}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (11/3), -1\nline = Poly(2*x+((7*y)/3)+3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n 1 & 5 & -6 \\\\\n -3 & -1 & 2 \\\\\n -1 & 1 & -9 \\\\\n -2 & -1 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 5, -6],\n [-3, -1, 2],\n [-1, 1, -9],\n [-2, -1, -2]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{9}{5}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & 1 & -2 \\\\\n -1 & -8 & 7 \\\\\n -5 & 1 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{36}{5} & \\frac{9}{5} & -\\frac{18}{5} \\\\\n -\\frac{9}{5} & -\\frac{72}{5} & \\frac{63}{5} \\\\\n -9 & \\frac{9}{5} & 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 1, -2],\n [-1, -8, 7],\n [-5, 1, 5]])\nprint(a * (9/5))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 2 & 1 \\\\\n 4 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 1],\n [4, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -10 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 60 \\\\\n -37 \\\\\n -10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [-10],\n [-5]])\nb = np.array([\n [-1],\n [0],\n [-6]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{2} \\\\\n -\\frac{17}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{17}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2)],\n [-(17/2)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 1 \\\\\n 0 & -3 \\\\\n 3 & -2 \\\\\n -1 & 1 \\\\\n 0 & 1 \\\\\n 2 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.46 \\\\\n -0.79 \\\\\n 2.86 \\\\\n 1.41 \\\\\n -2.93 \\\\\n -2.66 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.277 \\\\\n -0.085 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1],\n [0, -3],\n [3, -2],\n [-1, 1],\n [0, 1],\n [2, -3]])\nb = np.array([\n [-2.46],\n [-0.79],\n [2.86],\n [1.41],\n [-2.93],\n [-2.66]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{3}{5}, \\frac{17}{5}}$ to the line $-\\frac{7 x}{10}-\\frac{14 y}{5}+\\frac{29}{10}=0$.", - "Output Answer": [ - "$\\frac{352}{35 \\sqrt{17}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (3/5), (17/5)\nline = Poly(-((7*x)/10)-((14*y)/5)+(29/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -5 & -7 & -8 & 3 & -5 & 4 \\\\\n 0 & -7 & 6 & -10 & -1 & -3 \\\\\n 10 & 0 & 9 & -8 & 0 & -2 \\\\\n -3 & 7 & 6 & -7 & 7 & -2 \\\\\n 7 & -1 & 9 & -4 & -3 & -9 \\\\\n 1 & 4 & 7 & -10 & 8 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, -7, -8, 3, -5, 4],\n [0, -7, 6, -10, -1, -3],\n [10, 0, 9, -8, 0, -2],\n [-3, 7, 6, -7, 7, -2],\n [7, -1, 9, -4, -3, -9],\n [1, 4, 7, -10, 8, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -10 & -\\frac{33}{4} & \\frac{23}{4} & -9 & -\\frac{13}{4} \\\\\n -\\frac{33}{4} & -\\frac{19}{4} & \\frac{23}{4} & -\\frac{1}{2} & -\\frac{3}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -(33/4), (23/4), -9, -(13/4)],\n [-(33/4), -(19/4), (23/4), -(1/2), -(3/4)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -3 & -1 & -3 & 0 & 3 \\\\\n 1 & 2 & 1 & 2 & 1 \\\\\n 0 & 3 & 2 & 2 & -2 \\\\\n 3 & 2 & 2 & -2 & 0 \\\\\n 1 & 0 & 3 & -2 & -1 \\\\\n 0 & 0 & 0 & -1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.46 \\\\\n -0.39 \\\\\n -2.8 \\\\\n -2.43 \\\\\n 1.71 \\\\\n 0.75 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.233 \\\\\n -1.327 \\\\\n 0.862 \\\\\n 0.234 \\\\\n 0.34 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1, -3, 0, 3],\n [1, 2, 1, 2, 1],\n [0, 3, 2, 2, -2],\n [3, 2, 2, -2, 0],\n [1, 0, 3, -2, -1],\n [0, 0, 0, -1, -1]])\nb = np.array([\n [0.46],\n [-0.39],\n [-2.8],\n [-2.43],\n [1.71],\n [0.75]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{4} \\\\\n -\\frac{11}{8} \\\\\n \\frac{3}{4} \\\\\n -\\frac{3}{4} \\\\\n -\\frac{15}{8} \\\\\n \\frac{23}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{6}{\\sqrt{983}} \\\\\n -\\frac{11}{\\sqrt{983}} \\\\\n \\frac{6}{\\sqrt{983}} \\\\\n -\\frac{6}{\\sqrt{983}} \\\\\n -\\frac{15}{\\sqrt{983}} \\\\\n \\frac{23}{\\sqrt{983}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/4)],\n [-(11/8)],\n [(3/4)],\n [-(3/4)],\n [-(15/8)],\n [(23/8)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 3 \\\\\n 3 & -3 \\\\\n 2 & -3 \\\\\n 2 & -2 \\\\\n -3 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.66 \\\\\n 2.43 \\\\\n 1.47 \\\\\n -0.23 \\\\\n 0.85 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.184 \\\\\n -0.154 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3],\n [3, -3],\n [2, -3],\n [2, -2],\n [-3, 1]])\nb = np.array([\n [0.66],\n [2.43],\n [1.47],\n [-0.23],\n [0.85]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{8}{3}, \\frac{1}{3}}$ to the line $-\\frac{14 x}{3}+\\frac{10 y}{3}-\\frac{1}{3}=0$.", - "Output Answer": [ - "$\\frac{35}{2 \\sqrt{74}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (8/3), (1/3)\nline = Poly(-((14*x)/3)+((10*y)/3)-(1/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & 4 \\\\\n -2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 4],\n [-2, -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{13}{9}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -6 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{26}{3} & \\frac{91}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 7]])\nprint(a * (13/9))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{19}{5}, \\frac{2}{5}}$ to the line $\\frac{4 x}{5}-\\frac{6 y}{5}-\\frac{8}{5}=0$.", - "Output Answer": [ - "$\\frac{12}{5 \\sqrt{13}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (19/5), (2/5)\nline = Poly(((4*x)/5)-((6*y)/5)-(8/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -\\frac{157}{25} & -\\frac{783}{100} & \\frac{493}{50} & -\\frac{683}{100} \\\\\n -\\frac{379}{50} & \\frac{53}{25} & 3 & -\\frac{91}{100} \\\\\n \\frac{469}{50} & -\\frac{899}{100} & -\\frac{129}{20} & \\frac{721}{100} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{148}{25} & \\frac{731}{100} & -\\frac{229}{25} & \\frac{281}{50} \\\\\n -\\frac{91}{100} & \\frac{59}{50} & -\\frac{467}{50} & \\frac{331}{100} \\\\\n -\\frac{141}{50} & -\\frac{14}{5} & \\frac{61}{25} & -\\frac{131}{20} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{9}{25} & -\\frac{13}{25} & \\frac{7}{10} & -\\frac{121}{100} \\\\\n -\\frac{849}{100} & \\frac{33}{10} & -\\frac{317}{50} & \\frac{12}{5} \\\\\n \\frac{164}{25} & -\\frac{1179}{100} & -\\frac{401}{100} & \\frac{33}{50} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(157/25), -(783/100), (493/50), -(683/100)],\n [-(379/50), (53/25), 3, -(91/100)],\n [(469/50), -(899/100), -(129/20), (721/100)]])\nb = np.array([\n [(148/25), (731/100), -(229/25), (281/50)],\n [-(91/100), (59/50), -(467/50), (331/100)],\n [-(141/50), -(14/5), (61/25), -(131/20)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -\\frac{1}{3} \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{4}{3} \\\\\n \\frac{2}{3} \\\\\n -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{14}{9},\\frac{7}{9},-\\frac{7}{9}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-(1/3)],\n [-1]]).squeeze()\nb = np.array([\n [(4/3)],\n [(2/3)],\n [-(2/3)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{3} & 7 & -\\frac{20}{3} \\\\\n -\\frac{22}{3} & -9 & -1 \\\\\n \\frac{8}{3} & -\\frac{22}{3} & \\frac{1}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-13 x^2-\\frac{289 x}{3}-\\frac{12833}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/3), 7, -(20/3)],\n [-(22/3), -9, -1],\n [(8/3), -(22/3), (1/3)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{61}{8} \\\\\n \\frac{19}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{11}{8} \\\\\n -\\frac{25}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{25}{4} \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(61/8)],\n [(19/4)]])\nb = np.array([\n [(11/8)],\n [-(25/4)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{2} & -\\frac{5}{2} & 0 \\\\\n \\frac{5}{2} & -\\frac{5}{2} & \\frac{3}{2} \\\\\n -2 & 3 & \\frac{3}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{31}{4} & -\\frac{15}{2} & -\\frac{15}{8} \\\\\n 6 & -2 & \\frac{9}{2} \\\\\n -\\frac{25}{4} & \\frac{23}{2} & \\frac{105}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), -(5/2), 0],\n [(5/2), -(5/2), (3/2)],\n [-2, 3, (3/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{0,-5,-\\frac{7}{3}\\right\\}, \\left\\{\\frac{10}{3},-3,1\\right\\}, \\left\\{\\frac{11}{3},\\frac{14}{3},\\frac{1}{3}\\right\\}}$.", - "Output Answer": [ - "$363 x-45 y-336 z-1009=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [0, -5, -(7/3)],\n [(10/3), -3, 1],\n [(11/3), (14/3), (1/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,4,2\\}, \\{-4,3,-2\\}, \\{-2,-1,-3\\}}$.", - "Output Answer": [ - "$15 x+8 y-2 z+32=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, 4, 2],\n [-4, 3, -2],\n [-2, -1, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{7}{2} & \\frac{17}{4} & \\frac{19}{4} \\\\\n -\\frac{39}{8} & -\\frac{19}{4} & -\\frac{3}{4} \\\\\n -\\frac{39}{8} & -1 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{34}{427} & -\\frac{26}{1281} & -\\frac{310}{1281} \\\\\n \\frac{39}{854} & -\\frac{191}{854} & \\frac{219}{854} \\\\\n \\frac{195}{854} & \\frac{551}{2562} & -\\frac{131}{2562} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/2), (17/4), (19/4)],\n [-(39/8), -(19/4), -(3/4)],\n [-(39/8), -1, -(3/2)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{11}{5}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -9 & -1 \\\\\n -10 & -7 \\\\\n 6 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{99}{5} & \\frac{11}{5} \\\\\n 22 & \\frac{77}{5} \\\\\n -\\frac{66}{5} & -22 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -1],\n [-10, -7],\n [6, 10]])\nprint(a * -(11/5))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 10 & -5 & 7 \\\\\n -7 & 6 & -2 \\\\\n 3 & -6 & -7 \\\\\n 6 & 6 & -6 \\\\\n -7 & 7 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, -5, 7],\n [-7, 6, -2],\n [3, -6, -7],\n [6, 6, -6],\n [-7, 7, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 7 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -9 \\\\\n 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 7 \\\\\n 5 \\\\\n -25 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [7],\n [0]])\nb = np.array([\n [10],\n [-9],\n [1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{2} \\\\\n -\\frac{9}{4} \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{39}{4} \\\\\n 2 \\\\\n -\\frac{7}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{97}{16} \\\\\n -\\frac{383}{8} \\\\\n -\\frac{335}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2)],\n [-(9/4)],\n [5]])\nb = np.array([\n [-(39/4)],\n [2],\n [-(7/4)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{351}{100} & \\frac{483}{100} & \\frac{144}{25} & \\frac{587}{100} \\\\\n -\\frac{78}{25} & -\\frac{327}{50} & -\\frac{63}{10} & -\\frac{67}{20} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -\\frac{74}{25} & -\\frac{757}{100} & -\\frac{107}{20} & -\\frac{783}{100} \\\\\n \\frac{499}{50} & -\\frac{941}{100} & -\\frac{139}{50} & \\frac{76}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{11}{20} & -\\frac{137}{50} & \\frac{41}{100} & -\\frac{49}{25} \\\\\n \\frac{343}{50} & -\\frac{319}{20} & -\\frac{227}{25} & -\\frac{31}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(351/100), (483/100), (144/25), (587/100)],\n [-(78/25), -(327/50), -(63/10), -(67/20)]])\nb = np.array([\n [-(74/25), -(757/100), -(107/20), -(783/100)],\n [(499/50), -(941/100), -(139/50), (76/25)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 10 \\\\\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -13 \\\\\n 13 \\\\\n 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [3],\n [2]])\nb = np.array([\n [-4],\n [10],\n [9]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 6 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n 2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{185}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [6],\n [1]])\nb = np.array([\n [10],\n [2],\n [1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 2 \\\\\n -4 \\\\\n -10 \\\\\n -10 \\\\\n 9 \\\\\n -8 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 8 \\\\\n 5 \\\\\n -4 \\\\\n -1 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{211}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [2],\n [-4],\n [-10],\n [-10],\n [9],\n [-8],\n [0]])\nb = np.array([\n [1],\n [0],\n [-1],\n [8],\n [5],\n [-4],\n [-1],\n [-8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -5 & -8 \\\\\n 0 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+9 x+20$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -8],\n [0, -4]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{9}{2}, 5, -2}$ to the plane $\\frac{3 x}{2}+y-\\frac{9 z}{2}+2=0$.", - "Output Answer": [ - "$\\frac{37}{2 \\sqrt{94}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(9/2), 5, -2\nplane = Poly(((3*x)/2)+y-((9*z)/2)+2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-16$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [0]])\nb = np.array([\n [-2],\n [-7]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 10 & 5 & 4 \\\\\n 2 & 7 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & \\frac{19}{30} \\\\\n 0 & 1 & -\\frac{7}{15} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, 5, 4],\n [2, 7, -2]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{29}{10} \\\\\n \\frac{13}{10} \\\\\n -\\frac{19}{10} \\\\\n \\frac{21}{10} \\\\\n \\frac{1}{2} \\\\\n \\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{29}{\\sqrt{2093}} \\\\\n \\sqrt{\\frac{13}{161}} \\\\\n -\\frac{19}{\\sqrt{2093}} \\\\\n 3 \\sqrt{\\frac{7}{299}} \\\\\n \\frac{5}{\\sqrt{2093}} \\\\\n \\frac{16}{\\sqrt{2093}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/10)],\n [(13/10)],\n [-(19/10)],\n [(21/10)],\n [(1/2)],\n [(8/5)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{1,\\frac{3}{2},-5\\right\\}, \\left\\{\\frac{5}{2},-\\frac{7}{2},\\frac{5}{2}\\right\\}, \\{2,4,4\\}}$.", - "Output Answer": [ - "$255 x+24 y-35 z-466=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, (3/2), -5],\n [(5/2), -(7/2), (5/2)],\n [2, 4, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & -7 \\\\\n -2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} \\left(-11-\\sqrt{177}\\right),1\\right\\}, \\left\\{\\frac{1}{4} \\left(\\sqrt{177}-11\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -7],\n [-2, -3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & 4 \\\\\n 0 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 4],\n [0, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 5 & -5 \\\\\n 1 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{4}{25} & \\frac{1}{5} \\\\\n -\\frac{1}{25} & \\frac{1}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -5],\n [1, 4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{2}{3} \\\\\n \\frac{5}{3} \\\\\n -2 \\\\\n -2 \\\\\n 0 \\\\\n \\frac{4}{3} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{3} \\\\\n -\\frac{7}{3} \\\\\n 1 \\\\\n 0 \\\\\n -3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{91}{96},\\frac{91}{96},-\\frac{13}{32},0,\\frac{39}{32},\\frac{13}{16}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/3)],\n [(5/3)],\n [-2],\n [-2],\n [0],\n [(4/3)]]).squeeze()\nb = np.array([\n [-(7/3)],\n [-(7/3)],\n [1],\n [0],\n [-3],\n [-2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{39}{32}, -\\frac{155}{32}}$ to the line $\\frac{47 x}{32}+2 y+\\frac{17}{16}=0$.", - "Output Answer": [ - "$\\frac{2133 \\sqrt{\\frac{5}{1261}}}{32}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(39/32), -(155/32)\nline = Poly(((47*x)/32)+2*y+(17/16), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & 3 & -3 & -2 \\\\\n 2 & -2 & -1 & 1 \\\\\n -3 & 0 & 2 & 0 \\\\\n 0 & -2 & 3 & 0 \\\\\n 3 & 1 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.89 \\\\\n -0.12 \\\\\n -0.51 \\\\\n 1.81 \\\\\n 2.55 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.705 \\\\\n 0.448 \\\\\n 0.93 \\\\\n 0.491 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3, -3, -2],\n [2, -2, -1, 1],\n [-3, 0, 2, 0],\n [0, -2, 3, 0],\n [3, 1, -1, 2]])\nb = np.array([\n [-1.89],\n [-0.12],\n [-0.51],\n [1.81],\n [2.55]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 9 & -4 & 7 & 10 \\\\\n 9 & 8 & 7 & 4 \\\\\n -8 & 6 & 9 & 0 \\\\\n 7 & -8 & 3 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -2 & 9 & -3 & -7 \\\\\n -2 & -6 & -5 & -5 \\\\\n -8 & 8 & -9 & 2 \\\\\n 3 & 0 & -8 & -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 7 & 5 & 4 & 3 \\\\\n 7 & 2 & 2 & -1 \\\\\n -16 & 14 & 0 & 2 \\\\\n 10 & -8 & -5 & -10 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -4, 7, 10],\n [9, 8, 7, 4],\n [-8, 6, 9, 0],\n [7, -8, 3, 0]])\nb = np.array([\n [-2, 9, -3, -7],\n [-2, -6, -5, -5],\n [-8, 8, -9, 2],\n [3, 0, -8, -10]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cc}\n 0 & \\frac{7}{4} \\\\\n \\frac{9}{4} & \\frac{7}{2} \\\\\n \\frac{7}{2} & -3 \\\\\n 3 & 9 \\\\\n -\\frac{11}{4} & \\frac{21}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, (7/4)],\n [(9/4), (7/2)],\n [(7/2), -3],\n [3, 9],\n [-(11/4), (21/4)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{2} & 2 & -\\frac{3}{2} \\\\\n 2 & \\frac{1}{2} & -3 \\\\\n -\\frac{5}{2} & 0 & -1 \\\\\n 2 & 0 & -\\frac{1}{2} \\\\\n 0 & -\\frac{5}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{2} & -1 & \\frac{5}{2} \\\\\n -1 & 1 & 2 \\\\\n 0 & -\\frac{3}{2} & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{4} & \\frac{19}{4} & \\frac{23}{4} \\\\\n -\\frac{3}{2} & 3 & 12 \\\\\n \\frac{5}{4} & 4 & -\\frac{17}{4} \\\\\n -1 & -\\frac{5}{4} & 6 \\\\\n \\frac{5}{2} & -\\frac{13}{4} & -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), 2, -(3/2)],\n [2, (1/2), -3],\n [-(5/2), 0, -1],\n [2, 0, -(1/2)],\n [0, -(5/2), (1/2)]])\nb = np.array([\n [-(1/2), -1, (5/2)],\n [-1, 1, 2],\n [0, -(3/2), -2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{2} & -2 & -\\frac{33}{4} \\\\\n 3 & \\frac{1}{4} & \\frac{19}{2} \\\\\n -\\frac{1}{2} & \\frac{5}{4} & -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{3 x^2}{4}+59 x-\\frac{5019}{32}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2), -2, -(33/4)],\n [3, (1/4), (19/2)],\n [-(1/2), (5/4), -(15/2)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{6}{5} & -\\frac{7}{5} \\\\\n -\\frac{4}{5} & -\\frac{3}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{46}{25}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(6/5), -(7/5)],\n [-(4/5), -(3/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\sqrt{5} \\\\\n 0 \\\\\n 4 \\sqrt{5} \\\\\n 3 \\sqrt{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\sqrt{5} \\\\\n -\\sqrt{5} \\\\\n 4 \\sqrt{5} \\\\\n -2 \\sqrt{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$40$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [math.sqrt(5)],\n [0],\n [4*math.sqrt(5)],\n [3*math.sqrt(5)]])\nb = np.array([\n [-2*math.sqrt(5)],\n [-math.sqrt(5)],\n [4*math.sqrt(5)],\n [-2*math.sqrt(5)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{10}{3}, -\\frac{4}{3}, \\frac{5}{3}}$ to the plane $2 x+\\frac{10 y}{3}-\\frac{5 z}{3}+2=0$.", - "Output Answer": [ - "$\\frac{13}{3 \\sqrt{161}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (10/3), -(4/3), (5/3)\nplane = Poly(2*x+((10*y)/3)-((5*z)/3)+2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 3 & -2 \\\\\n -2 & 3 & -2 \\\\\n 4 & -4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-34$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 3, -2],\n [-2, 3, -2],\n [4, -4, -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,4,-1\\}, \\left\\{-\\frac{5}{2},-\\frac{5}{2},-\\frac{3}{2}\\right\\}, \\left\\{\\frac{5}{2},\\frac{5}{2},-\\frac{9}{2}\\right\\}}$.", - "Output Answer": [ - "$22 x-y+35 (z+3)=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, 4, -1],\n [-(5/2), -(5/2), -(3/2)],\n [(5/2), (5/2), -(9/2)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 9 \\\\\n -3 \\\\\n -6 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 2 \\\\\n 2 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-33$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [9],\n [-3],\n [-6],\n [3]])\nb = np.array([\n [0],\n [0],\n [2],\n [2],\n [-5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & 0 & 0 \\\\\n 1 & -2 & 2 \\\\\n -2 & -1 & -2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 0 & 0 \\\\\n 18 & 4 & 20 \\\\\n 0 & -10 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0, 0],\n [1, -2, 2],\n [-2, -1, -2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{4} & \\frac{9}{2} \\\\\n \\frac{15}{4} & \\frac{19}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{76}{213} & \\frac{24}{71} \\\\\n \\frac{20}{71} & -\\frac{4}{71} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/4), (9/2)],\n [(15/4), (19/4)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{24}{5}, \\frac{7}{5}}$ to the line $-\\frac{22 x}{5}+\\frac{23 y}{5}+2=0$.", - "Output Answer": [ - "$\\frac{317}{5 \\sqrt{1013}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (24/5), (7/5)\nline = Poly(-((22*x)/5)+((23*y)/5)+2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{19}{2} & 7 \\\\\n -8 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{32} \\left(-35-\\sqrt{329}\\right),1\\right\\}, \\left\\{\\frac{1}{32} \\left(\\sqrt{329}-35\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/2), 7],\n [-8, -8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{2} \\\\\n -\\frac{19}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{2} \\\\\n -\\frac{59}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -11 \\\\\n -\\frac{97}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/2)],\n [-(19/4)]])\nb = np.array([\n [-(7/2)],\n [-(59/8)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 0 & 3 & 0 \\\\\n -9 & -4 & -1 \\\\\n -8 & -6 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-2.468-4.419 i,-2.468+4.419 i,0.937\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 3, 0],\n [-9, -4, -1],\n [-8, -6, 0]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 14 \\log (2) \\\\\n 9 \\log (2) \\\\\n 14 \\log (2) \\\\\n -7 \\log (2) \\\\\n 4 \\log (2) \\\\\n 11 \\log (2) \\\\\n 11 \\log (2) \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -3 \\log (2) \\\\\n -11 \\log (2) \\\\\n 11 \\log (2) \\\\\n 13 \\log (2) \\\\\n -6 \\log (2) \\\\\n -12 \\log (2) \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{547} \\log (2)$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [14*math.log(2)],\n [9*math.log(2)],\n [14*math.log(2)],\n [-7*math.log(2)],\n [4*math.log(2)],\n [11*math.log(2)],\n [11*math.log(2)]])\nb = np.array([\n [0],\n [-3*math.log(2)],\n [-11*math.log(2)],\n [11*math.log(2)],\n [13*math.log(2)],\n [-6*math.log(2)],\n [-12*math.log(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{8} & -\\frac{57}{8} \\\\\n -\\frac{9}{8} & -\\frac{33}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+5 x-\\frac{141}{32}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/8), -(57/8)],\n [-(9/8), -(33/8)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 4 & 1 & -8 & 5 \\\\\n 3 & 0 & 2 & 4 \\\\\n 3 & -9 & 0 & 4 \\\\\n 2 & -6 & -4 & -9 \\\\\n 9 & 1 & -2 & 0 \\\\\n 7 & 3 & 10 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, 1, -8, 5],\n [3, 0, 2, 4],\n [3, -9, 0, 4],\n [2, -6, -4, -9],\n [9, 1, -2, 0],\n [7, 3, 10, -3]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 5 \\\\\n -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-2]])\nb = np.array([\n [-2],\n [10]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 7 & -9 & 4 & 7 & 10 \\\\\n 10 & 0 & -2 & -3 & -4 \\\\\n -5 & 8 & 8 & 10 & 2 \\\\\n 0 & 2 & -10 & 3 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & -\\frac{945}{4618} \\\\\n 0 & 1 & 0 & 0 & -\\frac{7585}{9236} \\\\\n 0 & 0 & 1 & 0 & \\frac{14333}{18472} \\\\\n 0 & 0 & 0 & 1 & \\frac{1237}{9236} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, -9, 4, 7, 10],\n [10, 0, -2, -3, -4],\n [-5, 8, 8, 10, 2],\n [0, 2, -10, 3, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n 1 & -3 \\\\\n 0 & 2 \\\\\n -2 & 3 \\\\\n 2 & 2 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 2 & -3 & -1 & -2 \\\\\n 1 & 2 & 0 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -1 & -9 & -1 & -5 \\\\\n 2 & 4 & 0 & 2 \\\\\n -1 & 12 & 2 & 7 \\\\\n 6 & -2 & -2 & -2 \\\\\n 1 & 2 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -3],\n [0, 2],\n [-2, 3],\n [2, 2],\n [0, 1]])\nb = np.array([\n [2, -3, -1, -2],\n [1, 2, 0, 1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n -10 \\\\\n -5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -9 \\\\\n 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -75 \\\\\n 15 \\\\\n 120 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [-10],\n [-5]])\nb = np.array([\n [3],\n [-9],\n [3]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-1,-\\frac{1}{3},\\frac{1}{3}\\right\\}, \\left\\{\\frac{11}{3},\\frac{8}{3},-\\frac{14}{3}\\right\\}, \\left\\{\\frac{5}{3},-2,-\\frac{14}{3}\\right\\}}$.", - "Output Answer": [ - "$315 x-135 y+213 z+199=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, -(1/3), (1/3)],\n [(11/3), (8/3), -(14/3)],\n [(5/3), -2, -(14/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{3} & 2 & -10 \\\\\n -5 & 6 & -\\frac{25}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{17}{3} & 4 & -\\frac{23}{3} \\\\\n -5 & -\\frac{26}{3} & \\frac{28}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -4 & 6 & -\\frac{53}{3} \\\\\n -10 & -\\frac{8}{3} & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3), 2, -10],\n [-5, 6, -(25/3)]])\nb = np.array([\n [-(17/3), 4, -(23/3)],\n [-5, -(26/3), (28/3)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{13}{3}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 4 & -2 \\\\\n 7 & -10 \\\\\n 2 & -9 \\\\\n 7 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{52}{3} & \\frac{26}{3} \\\\\n -\\frac{91}{3} & \\frac{130}{3} \\\\\n -\\frac{26}{3} & 39 \\\\\n -\\frac{91}{3} & 39 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -2],\n [7, -10],\n [2, -9],\n [7, -9]])\nprint(a * -(13/3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-3]])\nb = np.array([\n [-7],\n [5]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{3} \\\\\n -\\frac{5}{9} \\\\\n \\frac{8}{9} \\\\\n -\\frac{4}{9} \\\\\n \\frac{5}{9} \\\\\n \\frac{14}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -3 \\sqrt{\\frac{2}{181}} \\\\\n -\\frac{5}{\\sqrt{362}} \\\\\n 4 \\sqrt{\\frac{2}{181}} \\\\\n -2 \\sqrt{\\frac{2}{181}} \\\\\n \\frac{5}{\\sqrt{362}} \\\\\n 7 \\sqrt{\\frac{2}{181}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3)],\n [-(5/9)],\n [(8/9)],\n [-(4/9)],\n [(5/9)],\n [(14/9)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 3 & 3 \\\\\n 1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 3],\n [1, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 5 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-9 x+8$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 5],\n [0, 1]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-4,-3,\\frac{7}{2}\\right\\}, \\left\\{-4,4,\\frac{5}{2}\\right\\}, \\left\\{-\\frac{3}{2},\\frac{9}{2},-3\\right\\}}$.", - "Output Answer": [ - "$152 x+10 y+70 z+393=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, -3, (7/2)],\n [-4, 4, (5/2)],\n [-(3/2), (9/2), -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{4} \\\\\n -\\frac{3}{2} \\\\\n -\\frac{5}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{3}{\\sqrt{70}} \\\\\n -3 \\sqrt{\\frac{2}{35}} \\\\\n -\\sqrt{\\frac{5}{14}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/4)],\n [-(3/2)],\n [-(5/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{3} & 9 & -2 \\\\\n -3 & -\\frac{2}{3} & \\frac{23}{3} \\\\\n \\frac{16}{3} & \\frac{29}{3} & \\frac{26}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.168,0.481,1.\\}, \\{0.295\\, -2.236 i,-1.364+0.618 i,1.\\}, \\{0.295\\, +2.236 i,-1.364-0.618 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/3), 9, -2],\n [-3, -(2/3), (23/3)],\n [(16/3), (29/3), (26/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 2 & \\frac{5}{2} & -\\frac{5}{2} \\\\\n \\frac{1}{2} & 3 & \\frac{17}{2} \\\\\n \\frac{7}{2} & 5 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{0.842,-1.189,1.\\}, \\{5.708,-3.708,1.\\}, \\{0.292,1.708,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, (5/2), -(5/2)],\n [(1/2), 3, (17/2)],\n [(7/2), 5, -(3/2)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n 3 & -1 & 1 \\\\\n 6 & 4 & -10 \\\\\n -8 & 8 & 8 \\\\\n -5 & 5 & -6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 9 & -2 & 6 \\\\\n -6 & -2 & 8 \\\\\n 1 & 6 & -9 \\\\\n -9 & 8 & -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -6 & 1 & -5 \\\\\n 12 & 6 & -18 \\\\\n -9 & 2 & 17 \\\\\n 4 & -3 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, 1],\n [6, 4, -10],\n [-8, 8, 8],\n [-5, 5, -6]])\nb = np.array([\n [9, -2, 6],\n [-6, -2, 8],\n [1, 6, -9],\n [-9, 8, -8]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{7}{3} \\\\\n -2 \\\\\n -\\frac{1}{3} \\\\\n \\frac{14}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -\\frac{22}{3} \\\\\n 6 \\\\\n 0 \\\\\n -\\frac{23}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 5 \\\\\n -8 \\\\\n -\\frac{1}{3} \\\\\n \\frac{37}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/3)],\n [-2],\n [-(1/3)],\n [(14/3)]])\nb = np.array([\n [-(22/3)],\n [6],\n [0],\n [-(23/3)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & 3 \\\\\n -3 & -1 \\\\\n -3 & -1 \\\\\n -2 & 3 \\\\\n 0 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.22 \\\\\n 1.56 \\\\\n -0.32 \\\\\n -0.36 \\\\\n 2.83 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.066 \\\\\n -0.635 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 3],\n [-3, -1],\n [-3, -1],\n [-2, 3],\n [0, -2]])\nb = np.array([\n [-2.22],\n [1.56],\n [-0.32],\n [-0.36],\n [2.83]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 0 \\\\\n -1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(\\sqrt{10}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-1],\n [0],\n [1],\n [-1],\n [1],\n [-1],\n [1],\n [-1]]).squeeze()\nb = np.array([\n [1],\n [0],\n [-1],\n [0],\n [0],\n [-1],\n [0],\n [1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 1 & 5 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & -5 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 5],\n [0, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{9}{8} \\\\\n \\frac{9}{4} \\\\\n \\frac{23}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{9}{\\sqrt{934}} \\\\\n 9 \\sqrt{\\frac{2}{467}} \\\\\n \\frac{23}{\\sqrt{934}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/8)],\n [(9/4)],\n [(23/8)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, 3}$ to the line $-3 x-y-2=0$.", - "Output Answer": [ - "$2 \\sqrt{\\frac{2}{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, 3\nline = Poly(-3*x-y-2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -7 & -1 & -7 & -4 & 2 & -5 & -8 \\\\\n -1 & 5 & 9 & -9 & 10 & -8 & -7 \\\\\n 6 & 2 & 8 & -3 & 0 & -7 & -1 \\\\\n 9 & 7 & -5 & 2 & 9 & -10 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & -\\frac{328}{521} & -\\frac{1429}{1042} & -\\frac{116}{521} \\\\\n 0 & 1 & 0 & 0 & \\frac{2149}{1042} & \\frac{180}{521} & \\frac{131}{1042} \\\\\n 0 & 0 & 1 & 0 & -\\frac{7}{1042} & \\frac{883}{1042} & \\frac{563}{1042} \\\\\n 0 & 0 & 0 & 1 & \\frac{51}{521} & \\frac{1084}{521} & \\frac{736}{521} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, -1, -7, -4, 2, -5, -8],\n [-1, 5, 9, -9, 10, -8, -7],\n [6, 2, 8, -3, 0, -7, -1],\n [9, 7, -5, 2, 9, -10, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{-3,\\frac{3}{2},\\frac{9}{2}\\right\\}, \\left\\{-\\frac{9}{2},-3,-\\frac{5}{2}\\right\\}, \\{4,-3,0\\}}$.", - "Output Answer": [ - "$45 x+223 y-153 z+489=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, (3/2), (9/2)],\n [-(9/2), -3, -(5/2)],\n [4, -3, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n 6 & -6 & 8 & 6 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-4.,0.,3.,0.,0.\\}, \\{-1.,0.,0.,0.,3.\\}, \\{-1.,0.,0.,1.,0.\\}, \\{1.,1.,0.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [6, -6, 8, 6, 2]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{3}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & -2 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{3} & \\frac{10}{3} & \\frac{20}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2, -4]])\nprint(a * -(5/3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\sqrt{2} \\\\\n 0 \\\\\n 7 \\sqrt{2} \\\\\n \\frac{5}{\\sqrt{2}} \\\\\n -5 \\sqrt{2} \\\\\n -7 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\sqrt{2} \\\\\n -\\frac{11}{\\sqrt{2}} \\\\\n 3 \\sqrt{2} \\\\\n \\frac{11}{\\sqrt{2}} \\\\\n 7 \\sqrt{2} \\\\\n \\sqrt{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{33}{\\sqrt{2}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-4*math.sqrt(2)],\n [0],\n [7*math.sqrt(2)],\n [(5/(math.sqrt(2)))],\n [-5*math.sqrt(2)],\n [-7*math.sqrt(2)]])\nb = np.array([\n [-math.sqrt(2)],\n [-(11/(math.sqrt(2)))],\n [3*math.sqrt(2)],\n [(11/(math.sqrt(2)))],\n [7*math.sqrt(2)],\n [math.sqrt(2)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{103}{50} \\\\\n \\frac{69}{50} \\\\\n \\frac{187}{50} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{128}{25} \\\\\n -\\frac{77}{25} \\\\\n \\frac{31}{50} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{30937}{2500} \\\\\n -\\frac{44679}{2500} \\\\\n \\frac{16763}{1250} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(103/50)],\n [(69/50)],\n [(187/50)]])\nb = np.array([\n [-(128/25)],\n [-(77/25)],\n [(31/50)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{1}{2} & -3 & \\frac{3}{2} & -1 & 1 \\\\\n -2 & -\\frac{3}{2} & -2 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{3}{2} \\\\\n 1 \\\\\n 1 \\\\\n \\frac{5}{2} \\\\\n \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{13}{4} \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), -3, (3/2), -1, 1],\n [-2, -(3/2), -2, -1, 2]])\nb = np.array([\n [-(3/2)],\n [1],\n [1],\n [(5/2)],\n [(3/2)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -2 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -4 \\\\\n 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 30 \\\\\n -39 \\\\\n 24 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-2],\n [8]])\nb = np.array([\n [-6],\n [-4],\n [1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n \\frac{29}{3} & -\\frac{10}{3} & -\\frac{17}{3} & \\frac{28}{3} \\\\\n \\frac{20}{3} & \\frac{17}{3} & -3 & -\\frac{29}{3} \\\\\n 5 & \\frac{17}{3} & -\\frac{14}{3} & \\frac{2}{3} \\\\\n -\\frac{10}{3} & \\frac{7}{3} & -9 & -\\frac{25}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n \\frac{19}{3} & \\frac{1}{3} & 5 & -\\frac{7}{3} \\\\\n -\\frac{1}{3} & \\frac{23}{3} & \\frac{13}{3} & \\frac{16}{3} \\\\\n -\\frac{29}{3} & -10 & \\frac{25}{3} & -6 \\\\\n -\\frac{19}{3} & -\\frac{2}{3} & -3 & -\\frac{10}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{10}{3} & -\\frac{11}{3} & -\\frac{32}{3} & \\frac{35}{3} \\\\\n 7 & -2 & -\\frac{22}{3} & -15 \\\\\n \\frac{44}{3} & \\frac{47}{3} & -13 & \\frac{20}{3} \\\\\n 3 & 3 & -6 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/3), -(10/3), -(17/3), (28/3)],\n [(20/3), (17/3), -3, -(29/3)],\n [5, (17/3), -(14/3), (2/3)],\n [-(10/3), (7/3), -9, -(25/3)]])\nb = np.array([\n [(19/3), (1/3), 5, -(7/3)],\n [-(1/3), (23/3), (13/3), (16/3)],\n [-(29/3), -10, (25/3), -6],\n [-(19/3), -(2/3), -3, -(10/3)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & 5 & 3 \\\\\n 1 & 1 & -4 \\\\\n -4 & 0 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$112$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 5, 3],\n [1, 1, -4],\n [-4, 0, -4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{363}{100} \\\\\n \\frac{187}{50} \\\\\n -\\frac{817}{100} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{199}{50} \\\\\n -\\frac{76}{25} \\\\\n -\\frac{837}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{280703}{5000} \\\\\n \\frac{4267}{2000} \\\\\n \\frac{64801}{2500} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(363/100)],\n [(187/50)],\n [-(817/100)]])\nb = np.array([\n [-(199/50)],\n [-(76/25)],\n [-(837/100)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & 0 & -1 & -1 \\\\\n 0 & 1 & -2 & -2 \\\\\n -3 & -2 & -1 & -1 \\\\\n 3 & 1 & -2 & 3 \\\\\n 1 & -1 & 0 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.47 \\\\\n 2.16 \\\\\n 1.67 \\\\\n -0.32 \\\\\n -0.34 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.019 \\\\\n -0.097 \\\\\n -0.792 \\\\\n -0.554 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 0, -1, -1],\n [0, 1, -2, -2],\n [-3, -2, -1, -1],\n [3, 1, -2, 3],\n [1, -1, 0, -1]])\nb = np.array([\n [2.47],\n [2.16],\n [1.67],\n [-0.32],\n [-0.34]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 6 & -1 \\\\\n 7 & 6 \\\\\n -4 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [6, -1],\n [7, 6],\n [-4, -3]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -1 & 8 & -4 & -3 & 6 \\\\\n 2 & 1 & -7 & 0 & -9 \\\\\n -6 & -2 & -6 & -10 & -1 \\\\\n -5 & -3 & 8 & 9 & -6 \\\\\n -6 & -7 & -7 & -2 & -7 \\\\\n 8 & -3 & -8 & 10 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-1, 8, -4, -3, 6],\n [2, 1, -7, 0, -9],\n [-6, -2, -6, -10, -1],\n [-5, -3, 8, 9, -6],\n [-6, -7, -7, -2, -7],\n [8, -3, -8, 10, -3]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{3} \\\\\n -\\frac{2}{3} \\\\\n \\frac{14}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{13}{3} \\\\\n \\frac{17}{3} \\\\\n \\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{506}}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3)],\n [-(2/3)],\n [(14/3)]])\nb = np.array([\n [(13/3)],\n [(17/3)],\n [(5/3)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{15}{7}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{75}{7} \\\\\n \\frac{45}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [3]])\nprint(a * (15/7))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\sqrt{\\frac{2}{3}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [1],\n [-1],\n [-1],\n [1],\n [-1]]).squeeze()\nb = np.array([\n [0],\n [-1],\n [1],\n [0],\n [-1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{3} \\\\\n \\frac{3}{2} \\\\\n \\frac{13}{6} \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -4 \\sqrt{\\frac{2}{229}} \\\\\n \\frac{9}{\\sqrt{458}} \\\\\n \\frac{13}{\\sqrt{458}} \\\\\n -6 \\sqrt{\\frac{2}{229}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/3)],\n [(3/2)],\n [(13/6)],\n [-2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n \\frac{147}{16} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{15}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{27}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(147/16)]])\nb = np.array([\n [(15/2)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{5}{4} \\\\\n \\frac{3}{2} \\\\\n -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{3}{2} \\\\\n \\frac{1}{4} \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{144}{181},\\frac{24}{181},-\\frac{288}{181}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/4)],\n [(3/2)],\n [-(5/2)]]).squeeze()\nb = np.array([\n [(3/2)],\n [(1/4)],\n [-3]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{10}{3} & -\\frac{8}{3} & -\\frac{1}{3} \\\\\n 5 & -\\frac{4}{3} & \\frac{5}{3} \\\\\n -\\frac{13}{3} & \\frac{5}{3} & -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{427}{27}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(10/3), -(8/3), -(1/3)],\n [5, -(4/3), (5/3)],\n [-(13/3), (5/3), -(2/3)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{20}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -5 \\\\\n 5 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{20} \\\\\n -\\frac{1}{4} \\\\\n \\frac{1}{4} \\\\\n -\\frac{9}{20} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-5],\n [5],\n [-9]])\nprint(a * (1/20))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{14}{5}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & 2 & 10 & -4 \\\\\n 0 & 10 & 1 & 9 \\\\\n 4 & 1 & -2 & -9 \\\\\n 10 & -6 & 2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{28}{5} & -\\frac{28}{5} & -28 & \\frac{56}{5} \\\\\n 0 & -28 & -\\frac{14}{5} & -\\frac{126}{5} \\\\\n -\\frac{56}{5} & -\\frac{14}{5} & \\frac{28}{5} & \\frac{126}{5} \\\\\n -28 & \\frac{84}{5} & -\\frac{28}{5} & -\\frac{14}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, 10, -4],\n [0, 10, 1, 9],\n [4, 1, -2, -9],\n [10, -6, 2, 1]])\nprint(a * -(14/5))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{37}{5} \\\\\n \\frac{53}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{127}{10}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/5)],\n [(53/10)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{44}{9} \\\\\n \\frac{23}{3} \\\\\n -\\frac{61}{9} \\\\\n \\frac{19}{9} \\\\\n \\frac{50}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$27$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(44/9)],\n [(23/3)],\n [-(61/9)],\n [(19/9)],\n [(50/9)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n -5 & 7 & 4 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 7, 4, -9]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{10} & \\frac{7}{2} & -\\frac{21}{10} \\\\\n \\frac{3}{10} & -\\frac{19}{10} & \\frac{41}{10} \\\\\n -\\frac{3}{2} & \\frac{49}{10} & \\frac{39}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{434}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/10), (7/2), -(21/10)],\n [(3/10), -(19/10), (41/10)],\n [-(3/2), (49/10), (39/10)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -5 & -9 & -2 & 3 \\\\\n -4 & 10 & 1 & 0 \\\\\n 0 & -1 & 9 & -6 \\\\\n 6 & -5 & 8 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, -9, -2, 3],\n [-4, 10, 1, 0],\n [0, -1, 9, -6],\n [6, -5, 8, 4]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -2 & 1 & 1 & 1 & -2 \\\\\n 3 & -2 & 2 & -2 & 3 \\\\\n -3 & 2 & -2 & -2 & 1 \\\\\n 3 & -3 & 0 & 3 & -3 \\\\\n -2 & -1 & -3 & 3 & 2 \\\\\n -3 & 1 & 0 & 1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.91 \\\\\n -1.18 \\\\\n -0.23 \\\\\n 2.96 \\\\\n -2.58 \\\\\n -2.84 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.28 \\\\\n -0.882 \\\\\n -0.139 \\\\\n -0.73 \\\\\n -1.089 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 1, 1, 1, -2],\n [3, -2, 2, -2, 3],\n [-3, 2, -2, -2, 1],\n [3, -3, 0, 3, -3],\n [-2, -1, -3, 3, 2],\n [-3, 1, 0, 1, 2]])\nb = np.array([\n [0.91],\n [-1.18],\n [-0.23],\n [2.96],\n [-2.58],\n [-2.84]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 5 \\\\\n 1 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 10 \\\\\n 4 \\\\\n -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-46$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [5],\n [1],\n [6]])\nb = np.array([\n [8],\n [10],\n [4],\n [-10]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{21}{5} & -\\frac{7}{10} \\\\\n \\frac{16}{5} & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{1057}{50}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(21/5), -(7/10)],\n [(16/5), -(9/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{35}{16} \\\\\n -1 \\\\\n -\\frac{1}{8} \\\\\n \\frac{7}{16} \\\\\n \\frac{9}{4} \\\\\n -\\frac{5}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 7 \\sqrt{\\frac{5}{646}} \\\\\n -8 \\sqrt{\\frac{2}{1615}} \\\\\n -\\sqrt{\\frac{2}{1615}} \\\\\n \\frac{7}{\\sqrt{3230}} \\\\\n 18 \\sqrt{\\frac{2}{1615}} \\\\\n -2 \\sqrt{\\frac{10}{323}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(35/16)],\n [-1],\n [-(1/8)],\n [(7/16)],\n [(9/4)],\n [-(5/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,5,3\\}, \\{-3,5,-4\\}, \\{2,2,4\\}}$.", - "Output Answer": [ - "$21 x+19 y-6 z-56=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, 5, 3],\n [-3, 5, -4],\n [2, 2, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{2,4,1\\}, \\{1,0,3\\}, \\{-4,-2,5\\}}$.", - "Output Answer": [ - "$2 x+4 y+9 z-29=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [2, 4, 1],\n [1, 0, 3],\n [-4, -2, 5]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{20}{3} \\\\\n \\frac{64}{9} \\\\\n -\\frac{44}{9} \\\\\n -\\frac{8}{3} \\\\\n \\frac{79}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{271}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(20/3)],\n [(64/9)],\n [-(44/9)],\n [-(8/3)],\n [(79/9)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n -4 \\\\\n -6 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$10$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10],\n [-4],\n [-6],\n [-4]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 9 \\\\\n -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0]])\nb = np.array([\n [-8],\n [7]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 0 & 3 & -3 \\\\\n -1 & -3 & -2 \\\\\n 3 & 2 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{16}{51} & -\\frac{2}{17} & \\frac{5}{17} \\\\\n \\frac{10}{51} & -\\frac{3}{17} & -\\frac{1}{17} \\\\\n -\\frac{7}{51} & -\\frac{3}{17} & -\\frac{1}{17} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 3, -3],\n [-1, -3, -2],\n [3, 2, -4]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n \\frac{8}{5} \\\\\n \\frac{1}{5} \\\\\n \\frac{3}{5} \\\\\n 2 \\\\\n \\frac{11}{5} \\\\\n -\\frac{2}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{14}{5} \\\\\n -\\frac{12}{5} \\\\\n -\\frac{11}{5} \\\\\n \\frac{1}{5} \\\\\n -\\frac{6}{5} \\\\\n \\frac{8}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1603}{1405},\\frac{1374}{1405},\\frac{2519}{2810},-\\frac{229}{2810},\\frac{687}{1405},-\\frac{916}{1405}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(8/5)],\n [(1/5)],\n [(3/5)],\n [2],\n [(11/5)],\n [-(2/5)]]).squeeze()\nb = np.array([\n [-(14/5)],\n [-(12/5)],\n [-(11/5)],\n [(1/5)],\n [-(6/5)],\n [(8/5)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -\\frac{7}{2} \\\\\n 0 \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -1 \\\\\n \\frac{5}{2} \\\\\n \\frac{11}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{65}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-(7/2)],\n [0],\n [(1/2)]])\nb = np.array([\n [1],\n [-1],\n [(5/2)],\n [(11/2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & -2 & 2 & 2 & -3 \\\\\n 2 & 0 & 2 & -2 & 0 \\\\\n -2 & -1 & 0 & -2 & 2 \\\\\n -1 & -3 & -3 & -3 & -3 \\\\\n -3 & 3 & -1 & -3 & -1 \\\\\n 3 & -3 & 1 & 3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.41 \\\\\n 0.85 \\\\\n -0.04 \\\\\n 0.85 \\\\\n 2.2 \\\\\n -2.24 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.067 \\\\\n 0.36 \\\\\n -0.1 \\\\\n -0.432 \\\\\n -0.105 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, 2, 2, -3],\n [2, 0, 2, -2, 0],\n [-2, -1, 0, -2, 2],\n [-1, -3, -3, -3, -3],\n [-3, 3, -1, -3, -1],\n [3, -3, 1, 3, -3]])\nb = np.array([\n [-1.41],\n [0.85],\n [-0.04],\n [0.85],\n [2.2],\n [-2.24]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & 4 \\\\\n 6 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-x-24$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 4],\n [6, 0]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 3 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1 \\\\\n 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [4]])\nb = np.array([\n [1],\n [3]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{8}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -3 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -5 \\\\\n \\frac{15}{8} \\\\\n \\frac{45}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-3],\n [-9]])\nprint(a * -(5/8))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 1 & 7 \\\\\n 0 & 0 \\\\\n -9 & -2 \\\\\n 8 & 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -3 & -9 \\\\\n 10 & 1 \\\\\n -6 & 6 \\\\\n -6 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -2 & -2 \\\\\n 10 & 1 \\\\\n -15 & 4 \\\\\n 2 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 7],\n [0, 0],\n [-9, -2],\n [8, 5]])\nb = np.array([\n [-3, -9],\n [10, 1],\n [-6, 6],\n [-6, -6]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -3 & -4 & 8 & 5 \\\\\n 5 & 2 & -6 & 0 \\\\\n 8 & 5 & -6 & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & \\frac{29}{45} \\\\\n 0 & 1 & 0 & -\\frac{89}{45} \\\\\n 0 & 0 & 1 & -\\frac{11}{90} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, -4, 8, 5],\n [5, 2, -6, 0],\n [8, 5, -6, -4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & 2 & 1 \\\\\n -1 & 0 & 2 \\\\\n 0 & -2 & 2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & 0 & 7 \\\\\n -1 & -6 & 3 \\\\\n 2 & -4 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, 1],\n [-1, 0, 2],\n [0, -2, 2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{5} \\\\\n -\\frac{24}{5} \\\\\n -\\frac{12}{5} \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{41}{5} \\\\\n 3 \\\\\n 5 \\\\\n \\frac{43}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{\\frac{1226}{5}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/5)],\n [-(24/5)],\n [-(12/5)],\n [5]])\nb = np.array([\n [-(41/5)],\n [3],\n [5],\n [(43/5)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 1 & 2 & -1 \\\\\n -2 & 3 & -1 \\\\\n 3 & 0 & 3 \\\\\n -2 & 1 & 2 \\\\\n -3 & 3 & 3 \\\\\n 2 & 2 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.49 \\\\\n -1.07 \\\\\n 0.74 \\\\\n 1.81 \\\\\n 2.15 \\\\\n 2.65 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.351 \\\\\n 0.668 \\\\\n 0.292 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, -1],\n [-2, 3, -1],\n [3, 0, 3],\n [-2, 1, 2],\n [-3, 3, 3],\n [2, 2, -1]])\nb = np.array([\n [2.49],\n [-1.07],\n [0.74],\n [1.81],\n [2.15],\n [2.65]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{14}{9} & \\frac{83}{9} & \\frac{62}{9} & -\\frac{56}{9} \\\\\n \\frac{10}{9} & \\frac{29}{9} & \\frac{20}{3} & -\\frac{31}{9} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n \\frac{88}{9} & \\frac{17}{9} & -\\frac{55}{9} & -\\frac{40}{9} \\\\\n \\frac{2}{3} & -\\frac{74}{9} & -\\frac{28}{9} & \\frac{19}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{34}{3} & \\frac{22}{3} & 13 & -\\frac{16}{9} \\\\\n \\frac{4}{9} & \\frac{103}{9} & \\frac{88}{9} & -\\frac{50}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(14/9), (83/9), (62/9), -(56/9)],\n [(10/9), (29/9), (20/3), -(31/9)]])\nb = np.array([\n [(88/9), (17/9), -(55/9), -(40/9)],\n [(2/3), -(74/9), -(28/9), (19/9)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -1 & 5 \\\\\n -1 & 4 \\\\\n 9 & -5 \\\\\n -7 & 2 \\\\\n -10 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 5],\n [-1, 4],\n [9, -5],\n [-7, 2],\n [-10, -5]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -4 & -2 & 7 & 7 \\\\\n -9 & -8 & -2 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{60.,-71.,14.,0.\\}, \\{76.,-103.,0.,14.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-4, -2, 7, 7],\n [-9, -8, -2, -10]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{\\frac{14}{3},-\\frac{10}{3},-\\frac{8}{3}\\right\\}, \\left\\{4,-3,\\frac{4}{3}\\right\\}, \\left\\{\\frac{4}{3},-\\frac{8}{3},\\frac{2}{3}\\right\\}}$.", - "Output Answer": [ - "$7 x+50 y-3 z+126=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [(14/3), -(10/3), -(8/3)],\n [4, -3, (4/3)],\n [(4/3), -(8/3), (2/3)]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{15}{2} & -\\frac{19}{2} & \\frac{13}{2} \\\\\n -\\frac{17}{2} & \\frac{5}{2} & -5 \\\\\n \\frac{13}{2} & \\frac{9}{2} & -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{7 x^2}{2}+\\frac{587 x}{4}+\\frac{2105}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/2), -(19/2), (13/2)],\n [-(17/2), (5/2), -5],\n [(13/2), (9/2), -(13/2)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -4 & \\frac{7}{2} & \\frac{3}{4} \\\\\n -\\frac{9}{4} & -1 & -\\frac{7}{2} \\\\\n -\\frac{17}{4} & -\\frac{1}{4} & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{8}{213} & -\\frac{20}{213} & -\\frac{32}{213} \\\\\n \\frac{1240}{4899} & -\\frac{308}{4899} & -\\frac{1004}{4899} \\\\\n -\\frac{236}{4899} & -\\frac{1016}{4899} & \\frac{760}{4899} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, (7/2), (3/4)],\n [-(9/4), -1, -(7/2)],\n [-(17/4), -(1/4), 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n -10 & -9 & 0 & 4 & 6 & 4 & 4 \\\\\n 8 & 6 & -10 & 2 & 10 & -6 & 6 \\\\\n 9 & 0 & 9 & 3 & 3 & 0 & -3 \\\\\n 4 & -6 & 9 & -6 & 0 & -10 & -8 \\\\\n -4 & -10 & -10 & 10 & 5 & 1 & -10 \\\\\n -9 & 1 & 3 & -7 & 5 & -4 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & \\frac{91187}{179820} \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & -\\frac{7192}{44955} \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & -\\frac{47407}{89910} \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & -\\frac{4891}{1998} \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & \\frac{30139}{19980} \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & \\frac{376373}{179820} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, -9, 0, 4, 6, 4, 4],\n [8, 6, -10, 2, 10, -6, 6],\n [9, 0, 9, 3, 3, 0, -3],\n [4, -6, 9, -6, 0, -10, -8],\n [-4, -10, -10, 10, 5, 1, -10],\n [-9, 1, 3, -7, 5, -4, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -2 & 3 & 5 & 0 & 6 & 3 \\\\\n 5 & 7 & -7 & -8 & 2 & 4 \\\\\n 1 & -3 & 10 & 9 & 2 & 0 \\\\\n 5 & 2 & -8 & -10 & 3 & -10 \\\\\n -8 & -4 & -10 & 2 & -6 & -9 \\\\\n 0 & -4 & 6 & -5 & 10 & -5 \\\\\n 3 & 8 & 3 & 2 & -2 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, 3, 5, 0, 6, 3],\n [5, 7, -7, -8, 2, 4],\n [1, -3, 10, 9, 2, 0],\n [5, 2, -8, -10, 3, -10],\n [-8, -4, -10, 2, -6, -9],\n [0, -4, 6, -5, 10, -5],\n [3, 8, 3, 2, -2, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{22}{3} & \\frac{1}{3} & -\\frac{25}{3} \\\\\n \\frac{9}{2} & \\frac{1}{2} & 3 \\\\\n -\\frac{22}{3} & -\\frac{28}{3} & \\frac{7}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{61 x^2}{6}+\\frac{38 x}{3}+\\frac{1045}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(22/3), (1/3), -(25/3)],\n [(9/2), (1/2), 3],\n [-(22/3), -(28/3), (7/3)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 0 & 10 & -9 & 10 \\\\\n 0 & -4 & 7 & 0 \\\\\n -10 & 6 & 9 & 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 10 & -7 & 1 & -8 \\\\\n 4 & 9 & 3 & 7 \\\\\n -7 & 4 & 9 & 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 10 & 3 & -8 & 2 \\\\\n 4 & 5 & 10 & 7 \\\\\n -17 & 10 & 18 & 18 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 10, -9, 10],\n [0, -4, 7, 0],\n [-10, 6, 9, 10]])\nb = np.array([\n [10, -7, 1, -8],\n [4, 9, 3, 7],\n [-7, 4, 9, 8]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{23}{5}, -\\frac{11}{5}, -\\frac{2}{5}}$ to the plane $-\\frac{4 x}{5}+\\frac{9 y}{5}-\\frac{21 z}{5}-\\frac{7}{5}=0$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(23/5), -(11/5), -(2/5)\nplane = Poly(-((4*x)/5)+((9*y)/5)-((21*z)/5)-(7/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{8}{3} & \\frac{26}{3} \\\\\n -4 & -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{6} \\left(-13-i \\sqrt{1239}\\right),\\frac{1}{6} \\left(-13+i \\sqrt{1239}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/3), (26/3)],\n [-4, -(5/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\sqrt{5} \\\\\n 0 \\\\\n -3 \\sqrt{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\sqrt{5} \\\\\n 3 \\sqrt{5} \\\\\n \\sqrt{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{130}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-3*math.sqrt(5)],\n [0],\n [-3*math.sqrt(5)]])\nb = np.array([\n [-4*math.sqrt(5)],\n [3*math.sqrt(5)],\n [math.sqrt(5)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & 4 \\\\\n -\\frac{37}{5} & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(15-\\sqrt{65}\\right),\\frac{1}{10} \\left(15+\\sqrt{65}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 4],\n [-(37/5), 7]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\pi \\\\\n 3 \\pi \\\\\n \\pi \\\\\n \\pi \\\\\n 3 \\pi \\\\\n 0 \\\\\n 3 \\pi \\\\\n -\\pi \\\\\n 2 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\pi \\\\\n -3 \\pi \\\\\n -\\pi \\\\\n 0 \\\\\n -3 \\pi \\\\\n 3 \\pi \\\\\n 0 \\\\\n 2 \\pi \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{13} \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-2*math.pi],\n [3*math.pi],\n [math.pi],\n [math.pi],\n [3*math.pi],\n [0],\n [3*math.pi],\n [-math.pi],\n [2*math.pi]])\nb = np.array([\n [math.pi],\n [-3*math.pi],\n [-math.pi],\n [0],\n [-3*math.pi],\n [3*math.pi],\n [0],\n [2*math.pi],\n [0]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -3 \\\\\n 2 \\\\\n 1 \\\\\n -2 \\\\\n -1 \\\\\n -1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$15$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-3],\n [2],\n [1],\n [-2],\n [-1],\n [-1],\n [2]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{32}{5} & \\frac{37}{5} \\\\\n -\\frac{31}{5} & -\\frac{24}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{5} \\left(-28-i \\sqrt{1131}\\right),\\frac{1}{5} \\left(-28+i \\sqrt{1131}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(32/5), (37/5)],\n [-(31/5), -(24/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & 4 & -1 \\\\\n -4 & -4 & 2 \\\\\n 0 & -5 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$32$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 4, -1],\n [-4, -4, 2],\n [0, -5, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -2 & 1 \\\\\n -2 & 1 \\\\\n -1 & 1 \\\\\n 0 & -3 \\\\\n 1 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 4 \\\\\n 4 \\\\\n 2 \\\\\n 0 \\\\\n -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 1],\n [-2, 1],\n [-1, 1],\n [0, -3],\n [1, 1]])\nb = np.array([\n [-2],\n [0]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -\\frac{59}{10} \\\\\n -\\frac{1}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(59/10)],\n [-(1/10)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 0 & -\\frac{12}{7} \\\\\n \\frac{8}{7} & \\frac{30}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{35}{16} & \\frac{7}{8} \\\\\n -\\frac{7}{12} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -(12/7)],\n [(8/7), (30/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & -\\frac{19}{4} \\\\\n -\\frac{33}{4} & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{4} \\left(28-\\sqrt{691}\\right),\\frac{1}{4} \\left(28+\\sqrt{691}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -(19/4)],\n [-(33/4), 5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n \\frac{22}{3} & 1 & -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{6} & -\\frac{35}{6} & \\frac{19}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{15}{2} & -\\frac{29}{6} & -\\frac{11}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(22/3), 1, -10]])\nb = np.array([\n [(1/6), -(35/6), (19/3)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{11}{2} \\\\\n -\\frac{11}{2} \\\\\n -\\frac{17}{2} \\\\\n -2 \\\\\n -4 \\\\\n -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{19}{2} \\\\\n 4 \\\\\n 4 \\\\\n -\\frac{3}{2} \\\\\n 6 \\\\\n \\frac{1}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{57}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/2)],\n [-(11/2)],\n [-(17/2)],\n [-2],\n [-4],\n [-(15/2)]])\nb = np.array([\n [(19/2)],\n [4],\n [4],\n [-(3/2)],\n [6],\n [(1/2)]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2} & 3 \\\\\n \\frac{1}{2} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{31}{8} & \\frac{57}{4} \\\\\n \\frac{19}{8} & -\\frac{69}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), 3],\n [(1/2), -(3/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -4 & 0 \\\\\n -3 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-16$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 0],\n [-3, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -3 & 8 & 10 & -6 \\\\\n 2 & 8 & 6 & -2 \\\\\n -2 & 9 & -4 & -9 \\\\\n -5 & -4 & 1 & 10 \\\\\n -1 & 7 & -2 & 10 \\\\\n 5 & 6 & -7 & 1 \\\\\n -8 & 10 & -4 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-3, 8, 10, -6],\n [2, 8, 6, -2],\n [-2, 9, -4, -9],\n [-5, -4, 1, 10],\n [-1, 7, -2, 10],\n [5, 6, -7, 1],\n [-8, 10, -4, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{23}{4} & \\frac{43}{8} \\\\\n \\frac{11}{8} & -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{63 x}{4}+\\frac{3207}{64}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/4), (43/8)],\n [(11/8), -10]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -5 & -7 & 8 \\\\\n -7 & 4 & 4 \\\\\n -4 & -5 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1.842,-2.26,1.\\}, \\{0.937\\, -0.524 i,0.544\\, -0.275 i,1.\\}, \\{0.937\\, +0.524 i,0.544\\, +0.275 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -7, 8],\n [-7, 4, 4],\n [-4, -5, 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -7 & 8 & -8 \\\\\n 1 & -1 & -5 \\\\\n 4 & 0 & 1 \\\\\n -2 & 6 & -5 \\\\\n -10 & 3 & -3 \\\\\n -1 & 5 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, 8, -8],\n [1, -1, -5],\n [4, 0, 1],\n [-2, 6, -5],\n [-10, 3, -3],\n [-1, 5, -3]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{15}{4} & -\\frac{61}{8} & -\\frac{41}{8} \\\\\n -\\frac{49}{8} & \\frac{37}{4} & -\\frac{67}{8} \\\\\n \\frac{17}{2} & -\\frac{61}{8} & \\frac{3}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{55 x^2}{4}+\\frac{361 x}{16}+\\frac{234455}{512}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(15/4), -(61/8), -(41/8)],\n [-(49/8), (37/4), -(67/8)],\n [(17/2), -(61/8), (3/4)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -2 \\\\\n -3 \\\\\n -10 \\\\\n -7 \\\\\n 4 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$40$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [-2],\n [-3],\n [-10],\n [-7],\n [4],\n [8]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n 8 & -7 & 5 & -1 & -6 & -4 \\\\\n 0 & -8 & 3 & -9 & 0 & -4 \\\\\n 6 & -1 & 4 & 10 & -5 & -9 \\\\\n 2 & 8 & -7 & 8 & -3 & 0 \\\\\n -8 & 10 & 1 & 2 & -1 & 6 \\\\\n -9 & -10 & 4 & 0 & -4 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [8, -7, 5, -1, -6, -4],\n [0, -8, 3, -9, 0, -4],\n [6, -1, 4, 10, -5, -9],\n [2, 8, -7, 8, -3, 0],\n [-8, 10, 1, 2, -1, 6],\n [-9, -10, 4, 0, -4, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & -2 & -2 & -3 \\\\\n 3 & 0 & 1 & -1 \\\\\n -3 & 2 & -3 & 0 \\\\\n -2 & 1 & -2 & -1 \\\\\n 0 & 1 & 3 & -3 \\\\\n -1 & -2 & -2 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.77 \\\\\n -2.18 \\\\\n -1.86 \\\\\n 0.13 \\\\\n 1.67 \\\\\n -1.72 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.765 \\\\\n -0.456 \\\\\n 0.804 \\\\\n -0.226 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2, -2, -3],\n [3, 0, 1, -1],\n [-3, 2, -3, 0],\n [-2, 1, -2, -1],\n [0, 1, 3, -3],\n [-1, -2, -2, 3]])\nb = np.array([\n [-0.77],\n [-2.18],\n [-1.86],\n [0.13],\n [1.67],\n [-1.72]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cccc}\n -\\frac{18}{7} & -\\frac{65}{7} & \\frac{19}{7} & \\frac{62}{7} \\\\\n -\\frac{20}{7} & -\\frac{69}{7} & -\\frac{17}{7} & -\\frac{6}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(18/7), -(65/7), (19/7), (62/7)],\n [-(20/7), -(69/7), -(17/7), -(6/7)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{23}{7} & -\\frac{9}{7} \\\\\n \\frac{22}{7} & \\frac{13}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{91}{101} & -\\frac{63}{101} \\\\\n \\frac{154}{101} & \\frac{161}{101} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(23/7), -(9/7)],\n [(22/7), (13/7)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n \\frac{79}{16} & -\\frac{17}{16} \\\\\n \\frac{15}{8} & -\\frac{47}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{752}{3203} & -\\frac{272}{3203} \\\\\n \\frac{480}{3203} & -\\frac{1264}{3203} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(79/16), -(17/16)],\n [(15/8), -(47/16)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -8 & 9 & 5 & 6 & 4 \\\\\n -8 & 9 & 9 & -9 & -9 \\\\\n 1 & -3 & 6 & -3 & -9 \\\\\n 9 & -1 & 6 & -7 & -3 \\\\\n 7 & -2 & -3 & -3 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-8, 9, 5, 6, 4],\n [-8, 9, 9, -9, -9],\n [1, -3, 6, -3, -9],\n [9, -1, 6, -7, -3],\n [7, -2, -3, -3, -7]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & 7 \\\\\n -9 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-2-i \\sqrt{47},-2+i \\sqrt{47}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 7],\n [-9, -6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{16}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -7 & -9 \\\\\n -3 & -9 \\\\\n 0 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{49}{16} & -\\frac{63}{16} \\\\\n -\\frac{21}{16} & -\\frac{63}{16} \\\\\n 0 & \\frac{49}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, -9],\n [-3, -9],\n [0, 7]])\nprint(a * (7/16))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 2 \\\\\n -8 \\\\\n -8 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -8 \\\\\n -7 \\\\\n 4 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3 \\sqrt{46}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [2],\n [-8],\n [-8],\n [4]])\nb = np.array([\n [-6],\n [-8],\n [-7],\n [4],\n [9]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{29}{4} & -\\frac{29}{4} & -\\frac{39}{4} \\\\\n -\\frac{11}{2} & -\\frac{39}{4} & \\frac{39}{4} \\\\\n -3 & -\\frac{3}{2} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-6.128,2.066,1.\\}, \\{1.115\\, -0.308 i,1.031\\, -1.076 i,1.\\}, \\{1.115\\, +0.308 i,1.031\\, +1.076 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(29/4), -(29/4), -(39/4)],\n [-(11/2), -(39/4), (39/4)],\n [-3, -(3/2), -4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 0 & 4 & 1 \\\\\n 9 & -2 & 7 \\\\\n 10 & 2 & -7 \\\\\n 8 & 4 & -9 \\\\\n 5 & -6 & 9 \\\\\n 1 & 2 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, 4, 1],\n [9, -2, 7],\n [10, 2, -7],\n [8, 4, -9],\n [5, -6, 9],\n [1, 2, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{3} & -\\frac{20}{3} \\\\\n -4 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{16 x}{3}-\\frac{115}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3), -(20/3)],\n [-4, -7]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & -4 \\\\\n 7 & -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+10 x+44$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -4],\n [7, -2]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{4}{3} \\\\\n -1 \\\\\n -\\frac{2}{3} \\\\\n \\frac{4}{3} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n \\frac{7}{3} \\\\\n -\\frac{1}{3} \\\\\n -\\frac{5}{3} \\\\\n -\\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{49}{60},\\frac{7}{60},\\frac{7}{12},\\frac{7}{12}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(4/3)],\n [-1],\n [-(2/3)],\n [(4/3)]]).squeeze()\nb = np.array([\n [(7/3)],\n [-(1/3)],\n [-(5/3)],\n [-(5/3)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -1 & \\frac{33}{5} \\\\\n \\frac{19}{5} & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{38} \\left(-25-\\sqrt{3133}\\right),1\\right\\}, \\left\\{\\frac{1}{38} \\left(\\sqrt{3133}-25\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, (33/5)],\n [(19/5), 4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 0 & 5 \\\\\n 7 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-9 x-35$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 5],\n [7, 9]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n -\\frac{41}{8} & \\frac{63}{8} & \\frac{45}{8} & \\frac{23}{4} \\\\\n -\\frac{9}{8} & -\\frac{73}{8} & \\frac{9}{2} & -10 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -\\frac{57}{8} & \\frac{7}{8} & -\\frac{71}{8} & -1 \\\\\n 2 & \\frac{11}{4} & -\\frac{39}{4} & \\frac{17}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 2 & 7 & \\frac{29}{2} & \\frac{27}{4} \\\\\n -\\frac{25}{8} & -\\frac{95}{8} & \\frac{57}{4} & -\\frac{37}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(41/8), (63/8), (45/8), (23/4)],\n [-(9/8), -(73/8), (9/2), -10]])\nb = np.array([\n [-(57/8), (7/8), -(71/8), -1],\n [2, (11/4), -(39/4), (17/2)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${0, -3, 4}$ to the plane $-\\frac{9 x}{2}+2 y+\\frac{7 z}{2}=0$.", - "Output Answer": [ - "$8 \\sqrt{\\frac{2}{73}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 0, -3, 4\nplane = Poly(-((9*x)/2)+2*y+((7*z)/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{5} \\\\\n \\frac{8}{5} \\\\\n -\\frac{9}{5} \\\\\n 0 \\\\\n -\\frac{4}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{14}{5} & 1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{14}{25} & -\\frac{1}{5} & \\frac{1}{5} \\\\\n -\\frac{112}{25} & \\frac{8}{5} & -\\frac{8}{5} \\\\\n \\frac{126}{25} & -\\frac{9}{5} & \\frac{9}{5} \\\\\n 0 & 0 & 0 \\\\\n \\frac{56}{25} & -\\frac{4}{5} & \\frac{4}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/5)],\n [(8/5)],\n [-(9/5)],\n [0],\n [-(4/5)]])\nb = np.array([\n [-(14/5), 1, -1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -3 \\\\\n 4 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 0 \\\\\n 8 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{24}{\\sqrt{2329}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-3],\n [4],\n [-8]]).squeeze()\nb = np.array([\n [8],\n [0],\n [8],\n [3]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n -\\frac{1}{2} & -1 \\\\\n 2 & -\\frac{13}{6} \\\\\n 2 & -2 \\\\\n 3 & -\\frac{5}{3} \\\\\n \\frac{4}{3} & \\frac{7}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{2} & 2 & \\frac{5}{2} \\\\\n \\frac{1}{2} & \\frac{7}{6} & \\frac{5}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{4} & -\\frac{13}{6} & -\\frac{35}{12} \\\\\n -\\frac{49}{12} & \\frac{53}{36} & \\frac{25}{18} \\\\\n -4 & \\frac{5}{3} & \\frac{5}{3} \\\\\n -\\frac{16}{3} & \\frac{73}{18} & \\frac{85}{18} \\\\\n -\\frac{17}{12} & \\frac{145}{36} & \\frac{95}{18} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), -1],\n [2, -(13/6)],\n [2, -2],\n [3, -(5/3)],\n [(4/3), (7/6)]])\nb = np.array([\n [-(3/2), 2, (5/2)],\n [(1/2), (7/6), (5/3)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 9 & 10 & -9 \\\\\n -4 & 3 & -5 \\\\\n 3 & 3 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [9, 10, -9],\n [-4, 3, -5],\n [3, 3, -5]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & 3 & -1 \\\\\n 3 & -2 & 1 \\\\\n -1 & 0 & 1 \\\\\n 2 & 1 & -3 \\\\\n 1 & -3 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.22 \\\\\n 0.69 \\\\\n -0.27 \\\\\n -0.43 \\\\\n -1.76 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.386 \\\\\n 0.288 \\\\\n 0.591 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, -1],\n [3, -2, 1],\n [-1, 0, 1],\n [2, 1, -3],\n [1, -3, -1]])\nb = np.array([\n [-1.22],\n [0.69],\n [-0.27],\n [-0.43],\n [-1.76]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -7 \\\\\n -2 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 6 \\\\\n -1 \\\\\n -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-43$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-7],\n [-2],\n [1]])\nb = np.array([\n [-7],\n [6],\n [-1],\n [-10]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 9 & -5 \\\\\n -2 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{4} \\left(-15-\\sqrt{265}\\right),1\\right\\}, \\left\\{\\frac{1}{4} \\left(\\sqrt{265}-15\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -5],\n [-2, -6]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -4 & 1 \\\\\n 2 & -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$16$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 1],\n [2, -(9/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & -3 & -1 \\\\\n -1 & 1 & -2 \\\\\n 1 & 1 & -3 \\\\\n 0 & -1 & -3 \\\\\n -2 & 2 & 0 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.47 \\\\\n -1.32 \\\\\n 1.95 \\\\\n 1.03 \\\\\n 0.56 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.186 \\\\\n 0.669 \\\\\n -0.163 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -3, -1],\n [-1, 1, -2],\n [1, 1, -3],\n [0, -1, -3],\n [-2, 2, 0]])\nb = np.array([\n [-2.47],\n [-1.32],\n [1.95],\n [1.03],\n [0.56]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{8}{3} \\\\\n \\frac{16}{3} \\\\\n -5 \\\\\n \\frac{5}{3} \\\\\n \\frac{25}{3} \\\\\n -8 \\\\\n -\\frac{1}{3} \\\\\n -\\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{98}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/3)],\n [(16/3)],\n [-5],\n [(5/3)],\n [(25/3)],\n [-8],\n [-(1/3)],\n [-(4/3)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{7}{100}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 5 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{63}{100} \\\\\n \\frac{7}{20} \\\\\n -\\frac{7}{100} \\\\\n \\frac{7}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [5],\n [-1],\n [1]])\nprint(a * (7/100))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{0,0,0\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-2],\n [2]]).squeeze()\nb = np.array([\n [0],\n [2],\n [2]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -3 & 1 & -3 \\\\\n 2 & -2 & 1 \\\\\n 4 & -1 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-21$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1, -3],\n [2, -2, 1],\n [4, -1, -1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -8 \\\\\n 2 \\\\\n 2 \\\\\n 2 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 6 \\\\\n 8 \\\\\n 8 \\\\\n 6 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$45$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-8],\n [2],\n [2],\n [2],\n [5]])\nb = np.array([\n [-6],\n [6],\n [8],\n [8],\n [6],\n [5]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{27}{8}, \\frac{83}{32}}$ to the line $\\frac{75 x}{16}+\\frac{37 y}{8}-\\frac{67}{32}=0$.", - "Output Answer": [ - "$\\frac{6585}{16 \\sqrt{11101}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (27/8), (83/32)\nline = Poly(((75*x)/16)+((37*y)/8)-(67/32), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 6 \\\\\n -2 \\\\\n 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$16$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [6],\n [-2],\n [4]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -5 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -10 \\\\\n -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 85 \\\\\n 87 \\\\\n -55 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-5],\n [6]])\nb = np.array([\n [7],\n [-10],\n [-5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{9}{10}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -2 & 0 & -9 & -9 \\\\\n 5 & 2 & 3 & -8 \\\\\n -5 & 8 & 3 & 0 \\\\\n 2 & 0 & -8 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{9}{5} & 0 & -\\frac{81}{10} & -\\frac{81}{10} \\\\\n \\frac{9}{2} & \\frac{9}{5} & \\frac{27}{10} & -\\frac{36}{5} \\\\\n -\\frac{9}{2} & \\frac{36}{5} & \\frac{27}{10} & 0 \\\\\n \\frac{9}{5} & 0 & -\\frac{36}{5} & \\frac{81}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 0, -9, -9],\n [5, 2, 3, -8],\n [-5, 8, 3, 0],\n [2, 0, -8, 9]])\nprint(a * (9/10))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -6 \\\\\n 3 \\\\\n 6 \\\\\n 4 \\\\\n -4 \\\\\n -6 \\\\\n -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -2 \\\\\n -8 \\\\\n -1 \\\\\n 9 \\\\\n 4 \\\\\n 3 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-69$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-6],\n [3],\n [6],\n [4],\n [-4],\n [-6],\n [-10]])\nb = np.array([\n [7],\n [-2],\n [-8],\n [-1],\n [9],\n [4],\n [3],\n [-1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{2}{\\sqrt{3}} \\\\\n -\\frac{4}{\\sqrt{3}} \\\\\n -\\frac{8}{\\sqrt{3}} \\\\\n 3 \\sqrt{3} \\\\\n -\\frac{13}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{\\sqrt{3}} \\\\\n \\frac{14}{\\sqrt{3}} \\\\\n \\frac{2}{\\sqrt{3}} \\\\\n 3 \\sqrt{3} \\\\\n -\\frac{16}{\\sqrt{3}} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{\\frac{602}{3}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [(2/(math.sqrt(3)))],\n [-(4/(math.sqrt(3)))],\n [-(8/(math.sqrt(3)))],\n [3*math.sqrt(3)],\n [-(13/(math.sqrt(3)))]])\nb = np.array([\n [-(11/(math.sqrt(3)))],\n [(14/(math.sqrt(3)))],\n [(2/(math.sqrt(3)))],\n [3*math.sqrt(3)],\n [-(16/(math.sqrt(3)))]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n \\frac{16}{3} & -1 \\\\\n \\frac{14}{3} & -6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -6 & -\\frac{16}{3} \\\\\n \\frac{20}{3} & -\\frac{16}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{34}{3} & \\frac{13}{3} \\\\\n -2 & -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(16/3), -1],\n [(14/3), -6]])\nb = np.array([\n [-6, -(16/3)],\n [(20/3), -(16/3)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{3}{4} & -\\frac{5}{4} & -\\frac{9}{4} & \\frac{43}{16} \\\\\n \\frac{35}{16} & -\\frac{25}{16} & \\frac{5}{16} & \\frac{41}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{1}{4} \\\\\n -3 \\\\\n \\frac{17}{8} \\\\\n \\frac{19}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{661}{128} \\\\\n \\frac{767}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/4), -(5/4), -(9/4), (43/16)],\n [(35/16), -(25/16), (5/16), (41/16)]])\nb = np.array([\n [(1/4)],\n [-3],\n [(17/8)],\n [(19/8)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -2 & -2 & 0 \\\\\n -3 & 0 & 0 \\\\\n 2 & 1 & 3 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 10 & 4 & 0 \\\\\n 6 & 6 & 0 \\\\\n -1 & -1 & 9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2, 0],\n [-3, 0, 0],\n [2, 1, 3]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n 10 & 0 & 4 & -5 & -1 \\\\\n -6 & 1 & -9 & 8 & -1 \\\\\n 2 & 2 & 9 & -1 & -3 \\\\\n 9 & 8 & 2 & -6 & 5 \\\\\n -2 & 1 & 4 & 7 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, 0, 4, -5, -1],\n [-6, 1, -9, 8, -1],\n [2, 2, 9, -1, -3],\n [9, 8, 2, -6, 5],\n [-2, 1, 4, 7, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 9 & -7 & -7 \\\\\n -8 & 6 & -3 \\\\\n -6 & -5 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-5.324,9.58,15.744\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, -7, -7],\n [-8, 6, -3],\n [-6, -5, 5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 4 & -2 & -8 \\\\\n 1 & 1 & 5 \\\\\n 2 & -7 & 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 2 & -1 & -7 \\\\\n -1 & 3 & 5 \\\\\n 7 & 1 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 6 & -3 & -15 \\\\\n 0 & 4 & 10 \\\\\n 9 & -6 & 14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -2, -8],\n [1, 1, 5],\n [2, -7, 7]])\nb = np.array([\n [2, -1, -7],\n [-1, 3, 5],\n [7, 1, 7]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{2} & -\\frac{5}{2} & -2 \\\\\n 1 & -\\frac{5}{2} & 2 \\\\\n \\frac{1}{2} & 0 & -3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{69}{8} & -\\frac{305}{8} & \\frac{3}{2} \\\\\n \\frac{29}{4} & \\frac{5}{8} & \\frac{109}{2} \\\\\n \\frac{77}{8} & 10 & -21 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), -(5/2), -2],\n [1, -(5/2), 2],\n [(1/2), 0, -3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & -\\frac{1}{2} & 3 \\\\\n 3 & 1 & -2 \\\\\n -\\frac{3}{2} & -1 & \\frac{1}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -2 & -\\frac{9}{2} & \\frac{17}{2} \\\\\n 12 & \\frac{3}{2} & 6 \\\\\n -\\frac{27}{4} & -\\frac{3}{4} & -\\frac{9}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -(1/2), 3],\n [3, 1, -2],\n [-(3/2), -1, (1/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{3} \\\\\n -\\frac{8}{3} \\\\\n -7 \\\\\n \\frac{31}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{5542}}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(2/3)],\n [-(8/3)],\n [-7],\n [(31/9)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{4}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -3 \\\\\n 2 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{9}{4} \\\\\n \\frac{9}{4} \\\\\n -\\frac{3}{2} \\\\\n 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [-3],\n [2],\n [-8]])\nprint(a * -(3/4))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{35}{8} \\\\\n 7 \\\\\n -\\frac{47}{8} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{27}{4} \\\\\n \\frac{37}{8} \\\\\n \\frac{19}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{5995}{64} \\\\\n -\\frac{2599}{32} \\\\\n -\\frac{1729}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(35/8)],\n [7],\n [-(47/8)]])\nb = np.array([\n [(27/4)],\n [(37/8)],\n [(19/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{2} & -\\frac{10}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{43}{6} & \\frac{22}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{8}{3} & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/2), -(10/3)]])\nb = np.array([\n [-(43/6), (22/3)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 3 & -1 & -2 \\\\\n 0 & -3 & 1 \\\\\n -2 & 0 & -2 \\\\\n 1 & 1 & 1 \\\\\n -3 & -1 & -3 \\\\\n -3 & 3 & -3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.87 \\\\\n -2.8 \\\\\n -0.73 \\\\\n 0.74 \\\\\n -1.46 \\\\\n -1.91 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.929 \\\\\n 0.348 \\\\\n -0.355 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, -2],\n [0, -3, 1],\n [-2, 0, -2],\n [1, 1, 1],\n [-3, -1, -3],\n [-3, 3, -3]])\nb = np.array([\n [2.87],\n [-2.8],\n [-0.73],\n [0.74],\n [-1.46],\n [-1.91]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{1}{5} \\\\\n -\\frac{1}{5} \\\\\n -\\frac{3}{5} \\\\\n \\frac{3}{5} \\\\\n -\\frac{9}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1}{\\sqrt{101}} \\\\\n -\\frac{1}{\\sqrt{101}} \\\\\n -\\frac{3}{\\sqrt{101}} \\\\\n \\frac{3}{\\sqrt{101}} \\\\\n -\\frac{9}{\\sqrt{101}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/5)],\n [-(1/5)],\n [-(3/5)],\n [(3/5)],\n [-(9/5)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{10}{3} & -8 \\\\\n -6 & \\frac{25}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-5 x-\\frac{682}{9}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(10/3), -8],\n [-6, (25/3)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -6 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -5 \\\\\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -99 \\\\\n -135 \\\\\n 24 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6],\n [-6],\n [-9]])\nb = np.array([\n [9],\n [-5],\n [9]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 6 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 8 \\\\\n -2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -4 \\\\\n 8 \\\\\n 44 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [6],\n [-1]])\nb = np.array([\n [-6],\n [8],\n [-2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 10 \\\\\n 8 \\\\\n 5 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 10 \\\\\n -6 \\\\\n -5 \\\\\n -5 \\\\\n -5 \\\\\n -6 \\\\\n 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{397}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [10],\n [8],\n [5],\n [-1],\n [1],\n [1],\n [8]])\nb = np.array([\n [5],\n [10],\n [-6],\n [-5],\n [-5],\n [-5],\n [-6],\n [8]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 3 & -\\frac{22}{5} & -\\frac{2}{5} \\\\\n -\\frac{6}{5} & -\\frac{6}{5} & \\frac{9}{5} \\\\\n -\\frac{7}{5} & -\\frac{12}{5} & \\frac{36}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+9 x^2-\\frac{196 x}{25}-\\frac{5046}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -(22/5), -(2/5)],\n [-(6/5), -(6/5), (9/5)],\n [-(7/5), -(12/5), (36/5)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & 1 & \\frac{5}{2} \\\\\n \\frac{5}{2} & -\\frac{3}{2} & -3 \\\\\n 1 & 2 & 1 \\\\\n \\frac{1}{2} & -1 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 6 \\\\\n -14 \\\\\n 4 \\\\\n -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/2), 1, (5/2)],\n [(5/2), -(3/2), -3],\n [1, 2, 1],\n [(1/2), -1, 0]])\nb = np.array([\n [-2],\n [2],\n [2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -8 & -9 & 7 \\\\\n -9 & 1 & -9 \\\\\n 6 & 0 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-13.972,-1.14,11.112\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -9, 7],\n [-9, 1, -9],\n [6, 0, 3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{11}{2} & -2 & -\\frac{13}{2} \\\\\n -\\frac{15}{2} & -\\frac{11}{2} & \\frac{17}{2} \\\\\n -8 & 5 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.919,1.492,1.\\}, \\{0.523,-0.424,1.\\}, \\{8.236,13.276,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/2), -2, -(13/2)],\n [-(15/2), -(11/2), (17/2)],\n [-8, 5, -10]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{2}-i & \\frac{3}{2}+3 i \\\\\n 2-\\frac{5 i}{2} & -4 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{119}{4}+\\frac{45 i}{4} & \\frac{33}{4}-21 i \\\\\n -\\frac{43}{2}+\\frac{5 i}{4} & -\\frac{11}{2}+\\frac{9 i}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2)- 1j, (3/2)+3j],\n [2-((5j)/2), -4j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 6 & 1 \\\\\n 7 & 3 \\\\\n 5 & -6 \\\\\n 4 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [6, 1],\n [7, 3],\n [5, -6],\n [4, 9]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -6 & 6 & -3 & 5 & -7 & 5 \\\\\n 10 & -8 & -6 & 3 & 10 & 7 \\\\\n -6 & 5 & -2 & 1 & 5 & -2 \\\\\n -1 & 3 & 7 & -9 & -6 & 3 \\\\\n -4 & -6 & 6 & -1 & 7 & 4 \\\\\n -9 & -6 & -4 & 3 & 0 & 10 \\\\\n 0 & -9 & -2 & 8 & 1 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-6, 6, -3, 5, -7, 5],\n [10, -8, -6, 3, 10, 7],\n [-6, 5, -2, 1, 5, -2],\n [-1, 3, 7, -9, -6, 3],\n [-4, -6, 6, -1, 7, 4],\n [-9, -6, -4, 3, 0, 10],\n [0, -9, -2, 8, 1, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n 3 \\\\\n -4 \\\\\n 5 \\\\\n -4 \\\\\n -3 \\\\\n 0 \\\\\n -7 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n 1 \\\\\n 3 \\\\\n 10 \\\\\n -4 \\\\\n -9 \\\\\n -2 \\\\\n 0 \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2 \\sqrt{43}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [3],\n [-4],\n [5],\n [-4],\n [-3],\n [0],\n [-7],\n [8]])\nb = np.array([\n [9],\n [1],\n [3],\n [10],\n [-4],\n [-9],\n [-2],\n [0],\n [7]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -9 & -4 & -8 \\\\\n -9 & -9 & 8 \\\\\n -2 & 7 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.017,-3.315,1.\\}, \\{-0.491,0.588,1.\\}, \\{0.905,-2.017,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -4, -8],\n [-9, -9, 8],\n [-2, 7, 7]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 8 & -1 & -2 \\\\\n 8 & -1 & 0 \\\\\n 6 & -8 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+9 x^2-26 x+116$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -1, -2],\n [8, -1, 0],\n [6, -8, 2]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{17}{9} \\\\\n \\frac{5}{3} \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\sqrt{\\frac{17}{35}} \\\\\n 3 \\sqrt{\\frac{5}{119}} \\\\\n -\\frac{9}{\\sqrt{595}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/9)],\n [(5/3)],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 1 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -1 \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 5 \\\\\n -20 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [1],\n [3]])\nb = np.array([\n [-4],\n [-1],\n [2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{5}{2}, 3}$ to the line $\\frac{5 x}{2}-\\frac{y}{2}+3=0$.", - "Output Answer": [ - "$\\frac{31}{2 \\sqrt{26}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (5/2), 3\nline = Poly(((5*x)/2)-(y/2)+3, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,-1,-4\\}, \\{-2,-1,1\\}, \\{4,-3,-4\\}}$.", - "Output Answer": [ - "$10 x+15 y+6 z+29=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -1, -4],\n [-2, -1, 1],\n [4, -3, -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{5}{32}, -\\frac{13}{32}}$ to the line $-\\frac{65 x}{32}-\\frac{33 y}{8}-\\frac{7}{16}=0$.", - "Output Answer": [ - "$\\frac{943}{32 \\sqrt{21649}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (5/32), -(13/32)\nline = Poly(-((65*x)/32)-((33*y)/8)-(7/16), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{2} & -\\frac{47}{10} & \\frac{12}{5} \\\\\n 4 & \\frac{31}{10} & -\\frac{29}{10} \\\\\n \\frac{49}{10} & -4 & \\frac{11}{10} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{10319}{250}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), -(47/10), (12/5)],\n [4, (31/10), -(29/10)],\n [(49/10), -4, (11/10)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n \\frac{3}{5} \\\\\n -\\frac{1}{5} \\\\\n \\frac{2}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{12}{5} & \\frac{7}{5} & 1 & -\\frac{14}{5} & -\\frac{3}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -\\frac{36}{25} & \\frac{21}{25} & \\frac{3}{5} & -\\frac{42}{25} & -\\frac{9}{25} \\\\\n \\frac{12}{25} & -\\frac{7}{25} & -\\frac{1}{5} & \\frac{14}{25} & \\frac{3}{25} \\\\\n -\\frac{24}{25} & \\frac{14}{25} & \\frac{2}{5} & -\\frac{28}{25} & -\\frac{6}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/5)],\n [-(1/5)],\n [(2/5)]])\nb = np.array([\n [-(12/5), (7/5), 1, -(14/5), -(3/5)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{11}{3} \\\\\n -\\frac{14}{3} \\\\\n \\frac{25}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{50}{3}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(11/3)],\n [-(14/3)],\n [(25/3)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -1 & -\\frac{3}{2} & -\\frac{5}{2} & -\\frac{3}{2} \\\\\n -\\frac{5}{2} & -1 & 0 & 0 \\\\\n -1 & 3 & \\frac{1}{2} & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 0 & 0 & 0 & 2 \\\\\n -\\frac{5}{2} & -2 & 1 & 1 \\\\\n 0 & 3 & -\\frac{5}{2} & 0 \\\\\n \\frac{5}{2} & -2 & 1 & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 0 & -\\frac{3}{2} & \\frac{13}{4} & -\\frac{29}{4} \\\\\n \\frac{5}{2} & 2 & -1 & -6 \\\\\n -5 & -\\frac{13}{2} & \\frac{11}{4} & \\frac{7}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -(3/2), -(5/2), -(3/2)],\n [-(5/2), -1, 0, 0],\n [-1, 3, (1/2), 1]])\nb = np.array([\n [0, 0, 0, 2],\n [-(5/2), -2, 1, 1],\n [0, 3, -(5/2), 0],\n [(5/2), -2, 1, (5/2)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{83}{20} \\\\\n \\frac{969}{100} \\\\\n -\\frac{417}{100} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{829}{100} \\\\\n \\frac{413}{100} \\\\\n -\\frac{44}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{680499}{10000} \\\\\n -\\frac{19507}{10000} \\\\\n \\frac{315953}{5000} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(83/20)],\n [(969/100)],\n [-(417/100)]])\nb = np.array([\n [-(829/100)],\n [(413/100)],\n [-(44/5)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 1 & -\\frac{11}{3} \\\\\n \\frac{26}{3} & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{52} \\left(-21-i \\sqrt{703}\\right),1\\right\\}, \\left\\{\\frac{1}{52} \\left(-21+i \\sqrt{703}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -(11/3)],\n [(26/3), 8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{19}{10}, -\\frac{9}{5}}$ to the line $-\\frac{47 x}{10}-\\frac{8 y}{5}+\\frac{22}{5}=0$.", - "Output Answer": [ - "$\\frac{33}{2 \\sqrt{2465}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (19/10), -(9/5)\nline = Poly(-((47*x)/10)-((8*y)/5)+(22/5), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -6 & 2 & -4 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-5.,0.,0.,3.\\}, \\{-2.,0.,3.,0.\\}, \\{1.,3.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-6, 2, -4, -10]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -3 & -3 & -4 \\\\\n -3 & 0 & 1 \\\\\n -1 & -4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{4}{57} & -\\frac{16}{57} & \\frac{1}{19} \\\\\n \\frac{1}{57} & \\frac{4}{57} & -\\frac{5}{19} \\\\\n -\\frac{4}{19} & \\frac{3}{19} & \\frac{3}{19} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -3, -4],\n [-3, 0, 1],\n [-1, -4, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & -2 & 2 \\\\\n -1 & 2 & 3 \\\\\n 1 & 2 & 2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 22 & -20 & 8 \\\\\n -4 & 46 & 54 \\\\\n 10 & 32 & 46 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -2, 2],\n [-1, 2, 3],\n [1, 2, 2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{133}{16} & -\\frac{63}{8} \\\\\n -9 & -\\frac{35}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n \\frac{17}{2} & \\frac{27}{8} \\\\\n -\\frac{141}{16} & \\frac{143}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{269}{16} & -\\frac{45}{4} \\\\\n -\\frac{3}{16} & -\\frac{213}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(133/16), -(63/8)],\n [-9, -(35/8)]])\nb = np.array([\n [(17/2), (27/8)],\n [-(141/16), (143/16)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 5 & -7 & -1 & 1 \\\\\n -10 & -2 & -3 & 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -4 & 5 & -8 & -2 \\\\\n 4 & -8 & -8 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & -2 & -9 & -1 \\\\\n -6 & -10 & -11 & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -7, -1, 1],\n [-10, -2, -3, 7]])\nb = np.array([\n [-4, 5, -8, -2],\n [4, -8, -8, -4]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 8 & 1 & 7 \\\\\n -7 & -4 & 4 \\\\\n 5 & -5 & 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+9 x^2+20 x+440$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 1, 7],\n [-7, -4, 4],\n [5, -5, 5]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 9.157 \\\\\n -0.669 \\\\\n -5.94 \\\\\n -1.054 \\\\\n -4.749 \\\\\n 9.358 \\\\\n 6.931 \\\\\n 8.023 \\\\\n 6.12 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 7.658 \\\\\n -2.285 \\\\\n -2.193 \\\\\n 4.763 \\\\\n 4.831 \\\\\n 8.252 \\\\\n -0.224 \\\\\n 4.511 \\\\\n -4.226 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$17.7849$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9.157],\n [-0.669],\n [-5.94],\n [-1.054],\n [-4.749],\n [9.358],\n [6.931],\n [8.023],\n [6.12]])\nb = np.array([\n [7.658],\n [-2.285],\n [-2.193],\n [4.763],\n [4.831],\n [8.252],\n [-0.224],\n [4.511],\n [-4.226]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 5 & -6 & 8 & -2 \\\\\n -10 & 9 & -7 & 3 \\\\\n -5 & -3 & 4 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & \\frac{6}{5} \\\\\n 0 & 1 & 0 & \\frac{32}{15} \\\\\n 0 & 0 & 1 & \\frac{3}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [5, -6, 8, -2],\n [-10, 9, -7, 3],\n [-5, -3, 4, -10]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -4 & -1 \\\\\n -\\frac{29}{3} & -\\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{29} \\left(4-\\sqrt{103}\\right),1\\right\\}, \\left\\{\\frac{1}{29} \\left(4+\\sqrt{103}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -1],\n [-(29/3), -(4/3)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n \\frac{11}{4} \\\\\n -1 \\\\\n \\frac{3}{4} \\\\\n \\frac{9}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{8}{\\sqrt{291}} \\\\\n \\frac{11}{\\sqrt{291}} \\\\\n -\\frac{4}{\\sqrt{291}} \\\\\n \\sqrt{\\frac{3}{97}} \\\\\n 3 \\sqrt{\\frac{3}{97}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [(11/4)],\n [-1],\n [(3/4)],\n [(9/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -7 & 6 \\\\\n -9 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{9} i \\left(\\sqrt{29}-5 i\\right),1\\right\\}, \\left\\{-\\frac{1}{9} i \\left(\\sqrt{29}+5 i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7, 6],\n [-9, 3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{5} & -\\frac{37}{5} \\\\\n \\frac{8}{5} & -\\frac{2}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(-1-5 i \\sqrt{47}\\right),\\frac{1}{10} \\left(-1+5 i \\sqrt{47}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/5), -(37/5)],\n [(8/5), -(2/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-1,0,-4\\}, \\{-1,-1,1\\}, \\{1,-1,3\\}}$.", - "Output Answer": [ - "$x-5 y-z-3=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-1, 0, -4],\n [-1, -1, 1],\n [1, -1, 3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{24}{7} \\\\\n -\\frac{36}{7} \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{15}{7} \\\\\n \\frac{32}{7} \\\\\n -\\frac{32}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{\\sqrt{5729}}{7}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(24/7)],\n [-(36/7)],\n [0]])\nb = np.array([\n [-(15/7)],\n [(32/7)],\n [-(32/7)]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -3 & 1 \\\\\n -4 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{8} i \\left(\\sqrt{15}-i\\right),1\\right\\}, \\left\\{-\\frac{1}{8} i \\left(\\sqrt{15}+i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1],\n [-4, -2]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 6 & -\\frac{7}{2} \\\\\n 10 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{20} i \\left(\\sqrt{139}-i\\right),1\\right\\}, \\left\\{-\\frac{1}{20} i \\left(\\sqrt{139}+i\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6, -(7/2)],\n [10, 5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n \\frac{45}{8} & -\\frac{11}{4} & -\\frac{3}{4} \\\\\n -\\frac{7}{2} & -\\frac{57}{8} & \\frac{47}{8} \\\\\n -2 & \\frac{3}{4} & -\\frac{31}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{37 x^2}{4}+\\frac{2815 x}{64}+\\frac{51889}{128}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(45/8), -(11/4), -(3/4)],\n [-(7/2), -(57/8), (47/8)],\n [-2, (3/4), -(31/4)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -1 & -1 & 1 & -2 \\\\\n -3 & 0 & 1 & 2 \\\\\n -2 & 0 & -3 & -2 \\\\\n 2 & -2 & 0 & 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -1 & 3 & 0 \\\\\n -1 & 3 & 0 \\\\\n 2 & 0 & -3 \\\\\n -2 & 0 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 8 & -6 & -3 \\\\\n 1 & -9 & -3 \\\\\n 0 & -6 & 9 \\\\\n -2 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -1, 1, -2],\n [-3, 0, 1, 2],\n [-2, 0, -3, -2],\n [2, -2, 0, 1]])\nb = np.array([\n [-1, 3, 0],\n [-1, 3, 0],\n [2, 0, -3],\n [-2, 0, 0]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{3}{2}, \\frac{7}{2}}$ to the line $-2 x-\\frac{y}{2}=0$.", - "Output Answer": [ - "$\\frac{5}{2 \\sqrt{17}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(3/2), (7/2)\nline = Poly(-2*x-(y/2), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 8 \\\\\n 0 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-2 x-48$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 8],\n [0, -6]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 0 & -3 & 3 \\\\\n 0 & -3 & 1 \\\\\n 2 & 2 & -2 \\\\\n -1 & -2 & -3 \\\\\n 2 & 3 & 2 \\\\\n 2 & 1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -0.54 \\\\\n 1.42 \\\\\n 2.92 \\\\\n 1.97 \\\\\n -2.7 \\\\\n 2.73 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.183 \\\\\n -0.754 \\\\\n -0.894 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3, 3],\n [0, -3, 1],\n [2, 2, -2],\n [-1, -2, -3],\n [2, 3, 2],\n [2, 1, -1]])\nb = np.array([\n [-0.54],\n [1.42],\n [2.92],\n [1.97],\n [-2.7],\n [2.73]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{729}{100} & -\\frac{241}{100} \\\\\n -\\frac{123}{20} & \\frac{114}{25} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{273 x}{100}-\\frac{480639}{10000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(729/100), -(241/100)],\n [-(123/20), (114/25)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -1 \\\\\n 1 \\\\\n -2 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{\\sqrt{\\frac{3}{2}}}{2} \\\\\n -\\frac{1}{2 \\sqrt{6}} \\\\\n \\frac{1}{2 \\sqrt{6}} \\\\\n -\\frac{1}{\\sqrt{6}} \\\\\n \\frac{\\sqrt{\\frac{3}{2}}}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-1],\n [1],\n [-2],\n [3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-2, -2}$ to the line $2 x-4 y+2=0$.", - "Output Answer": [ - "$\\frac{3}{\\sqrt{5}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -2, -2\nline = Poly(2*x-4*y+2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{18}{7} \\\\\n -\\frac{3}{7} \\\\\n \\frac{6}{7} \\\\\n -1 \\\\\n \\frac{5}{7} \\\\\n -\\frac{20}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 6 \\sqrt{\\frac{3}{281}} \\\\\n -\\sqrt{\\frac{3}{281}} \\\\\n 2 \\sqrt{\\frac{3}{281}} \\\\\n -\\frac{7}{\\sqrt{843}} \\\\\n \\frac{5}{\\sqrt{843}} \\\\\n -\\frac{20}{\\sqrt{843}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(18/7)],\n [-(3/7)],\n [(6/7)],\n [-1],\n [(5/7)],\n [-(20/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -3 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n -2 & 2 & 0 & 2 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 4 & -4 & 0 & -4 & -2 \\\\\n 6 & -6 & 0 & -6 & -3 \\\\\n 2 & -2 & 0 & -2 & -1 \\\\\n -2 & 2 & 0 & 2 & 1 \\\\\n -2 & 2 & 0 & 2 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-3],\n [-1],\n [1],\n [1]])\nb = np.array([\n [-2, 2, 0, 2, 1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 8 & 7 \\\\\n 4 & 6 \\\\\n -7 & 8 \\\\\n -2 & -6 \\\\\n 5 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [8, 7],\n [4, 6],\n [-7, 8],\n [-2, -6],\n [5, 5]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-2,-4,0\\}, \\{-2,4,-4\\}, \\{-1,3,-3\\}}$.", - "Output Answer": [ - "$x-y-2 z-2=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-2, -4, 0],\n [-2, 4, -4],\n [-1, 3, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n 1 & 3 \\\\\n -2 & -1 \\\\\n 2 & 0 \\\\\n 4 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3],\n [-2, -1],\n [2, 0],\n [4, -6]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n -1 & 3 & 2 \\\\\n 1 & -1 & 3 \\\\\n 4 & 4 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{16} & \\frac{1}{8} & \\frac{11}{64} \\\\\n \\frac{3}{16} & -\\frac{1}{8} & \\frac{5}{64} \\\\\n \\frac{1}{8} & \\frac{1}{4} & -\\frac{1}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 3, 2],\n [1, -1, 3],\n [4, 4, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{2} \\\\\n -3 \\\\\n -8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -9 \\\\\n -\\frac{13}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{105}{2} \\\\\n \\frac{265}{4} \\\\\n -\\frac{135}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2)],\n [-3],\n [-8]])\nb = np.array([\n [-3],\n [-9],\n [-(13/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & \\frac{1}{2} & -1 \\\\\n \\frac{3}{2} & -1 & -\\frac{1}{2} \\\\\n \\frac{5}{2} & \\frac{5}{2} & -2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{7}{8} & \\frac{5}{2} & -\\frac{3}{4} \\\\\n \\frac{5}{4} & -\\frac{3}{8} & -\\frac{1}{2} \\\\\n -\\frac{5}{4} & \\frac{35}{4} & -\\frac{9}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, (1/2), -1],\n [(3/2), -1, -(1/2)],\n [(5/2), (5/2), -2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 1 \\\\\n -4 \\\\\n -6 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [1],\n [-4],\n [-6],\n [-5]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n -1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}\\left(2 \\sqrt{5}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [1],\n [-1],\n [-1],\n [0]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [-1],\n [-1],\n [0],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -9 & -5 & -10 \\\\\n 1 & -5 & 6 \\\\\n 10 & 8 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-15 x^2-116 x-498$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -5, -10],\n [1, -5, 6],\n [10, 8, -1]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\left\\{5,\\frac{9}{2},\\frac{9}{2}\\right\\}, \\left\\{-\\frac{7}{2},\\frac{7}{2},0\\right\\}, \\left\\{-\\frac{3}{2},\\frac{5}{2},-4\\right\\}}$.", - "Output Answer": [ - "$2 (x+86 y)-7 (6 z+85)=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [5, (9/2), (9/2)],\n [-(7/2), (7/2), 0],\n [-(3/2), (5/2), -4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{9}{8} \\\\\n -3 \\\\\n \\frac{5}{2} \\\\\n \\frac{3}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{9}{\\sqrt{1093}} \\\\\n -\\frac{24}{\\sqrt{1093}} \\\\\n \\frac{20}{\\sqrt{1093}} \\\\\n \\frac{6}{\\sqrt{1093}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(9/8)],\n [-3],\n [(5/2)],\n [(3/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n 5 & -8 & 10 \\\\\n -6 & 6 & -1 \\\\\n -10 & -1 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -8, 10],\n [-6, 6, -1],\n [-10, -1, 7]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n -1 & -3 & 2 \\\\\n 3 & -3 & -1 \\\\\n 0 & -1 & -2 \\\\\n 3 & -2 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.48 \\\\\n 1.23 \\\\\n 1.38 \\\\\n 0.16 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.399 \\\\\n 0.201 \\\\\n -0.739 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -3, 2],\n [3, -3, -1],\n [0, -1, -2],\n [3, -2, 1]])\nb = np.array([\n [-2.48],\n [1.23],\n [1.38],\n [0.16]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{23}{10} \\\\\n -\\frac{1}{10} \\\\\n -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{23}{\\sqrt{755}} \\\\\n -\\frac{1}{\\sqrt{755}} \\\\\n -3 \\sqrt{\\frac{5}{151}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-(23/10)],\n [-(1/10)],\n [-(3/2)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n -\\frac{71}{9} & -\\frac{10}{3} \\\\\n -\\frac{29}{9} & -\\frac{85}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(71/9), -(10/3)],\n [-(29/9), -(85/9)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{5}{4} & -1 & -2 & -\\frac{11}{4} & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{2} & -\\frac{5}{4} & -\\frac{9}{4} \\\\\n \\frac{1}{4} & -\\frac{1}{2} & 0 \\\\\n 1 & \\frac{5}{2} & -\\frac{7}{4} \\\\\n 0 & \\frac{5}{2} & -\\frac{9}{4} \\\\\n \\frac{3}{4} & \\frac{11}{4} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{13}{8} & -\\frac{207}{16} & \\frac{55}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/4), -1, -2, -(11/4), 0]])\nb = np.array([\n [(1/2), -(5/4), -(9/4)],\n [(1/4), -(1/2), 0],\n [1, (5/2), -(7/4)],\n [0, (5/2), -(9/4)],\n [(3/4), (11/4), (3/2)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 0 & 9 & 1 & -3 \\\\\n -7 & 3 & 3 & -6 \\\\\n -2 & 9 & -6 & 0 \\\\\n 9 & -6 & 2 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -7 & -9 & -7 & -9 \\\\\n 0 & 8 & 1 & 8 \\\\\n 7 & -6 & -1 & 5 \\\\\n -9 & -9 & 2 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -7 & 0 & -6 & -12 \\\\\n -7 & 11 & 4 & 2 \\\\\n 5 & 3 & -7 & 5 \\\\\n 0 & -15 & 4 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 9, 1, -3],\n [-7, 3, 3, -6],\n [-2, 9, -6, 0],\n [9, -6, 2, -1]])\nb = np.array([\n [-7, -9, -7, -9],\n [0, 8, 1, 8],\n [7, -6, -1, 5],\n [-9, -9, 2, 6]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 3 \\\\\n 5 \\\\\n 5 \\\\\n \\frac{14}{3} \\\\\n -\\frac{2}{3} \\\\\n -7 \\\\\n \\frac{20}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [3],\n [5],\n [5],\n [(14/3)],\n [-(2/3)],\n [-7],\n [(20/3)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 0 & -7 & -5 & -6 \\\\\n -4 & -5 & 9 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-13.,-12.,0.,14.\\}, \\{22.,-5.,7.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [0, -7, -5, -6],\n [-4, -5, 9, -8]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -3 & 6 & 3 & -4 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 6, 3, -4, 5]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sec ^{-1}(7)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [-1],\n [-1],\n [1],\n [-1],\n [1],\n [0],\n [0],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [1],\n [0],\n [1],\n [0],\n [-1],\n [1],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cc}\n \\frac{5}{3} & \\frac{4}{3} \\\\\n -\\frac{8}{3} & -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{2}{3} & \\frac{4}{3} & \\frac{8}{3} & -\\frac{5}{3} \\\\\n 0 & -2 & \\frac{1}{3} & -\\frac{8}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{10}{9} & -\\frac{4}{9} & \\frac{44}{9} & -\\frac{19}{3} \\\\\n -\\frac{16}{9} & \\frac{10}{9} & -\\frac{71}{9} & \\frac{32}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3), (4/3)],\n [-(8/3), -(7/3)]])\nb = np.array([\n [(2/3), (4/3), (8/3), -(5/3)],\n [0, -2, (1/3), -(8/3)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{21}{10} \\\\\n 0 \\\\\n \\frac{19}{2} \\\\\n -\\frac{19}{10} \\\\\n -6 \\\\\n -\\frac{31}{5} \\\\\n \\frac{23}{5} \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{19}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(21/10)],\n [0],\n [(19/2)],\n [-(19/10)],\n [-6],\n [-(31/5)],\n [(23/5)],\n [9]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -2 & 3 & -2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-3.,0.,0.,2.\\}, \\{-1.,0.,1.,0.\\}, \\{3.,2.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, 3, -2, -3]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -6 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n 10 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -14 \\\\\n -10 \\\\\n 46 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-6],\n [-1]])\nb = np.array([\n [6],\n [10],\n [4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-1, -\\frac{41}{10}}$ to the line $-\\frac{12 x}{5}+\\frac{22 y}{5}-\\frac{27}{10}=0$.", - "Output Answer": [ - "$\\frac{917}{20 \\sqrt{157}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -1, -(41/10)\nline = Poly(-((12*x)/5)+((22*y)/5)-(27/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -4 & -4 & -6 \\\\\n 1 & -5 & -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -3 & 8 & 1 \\\\\n 8 & 6 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -7 & 4 & -5 \\\\\n 9 & 1 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -4, -6],\n [1, -5, -9]])\nb = np.array([\n [-3, 8, 1],\n [8, 6, 9]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 3 & -6 & -\\frac{7}{2} \\\\\n \\frac{15}{2} & 3 & 7 \\\\\n -\\frac{15}{2} & \\frac{7}{2} & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.495,0.305,1.\\}, \\{0.302\\, -1.219 i,-1.749-0.804 i,1.\\}, \\{0.302\\, +1.219 i,-1.749+0.804 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -6, -(7/2)],\n [(15/2), 3, 7],\n [-(15/2), (7/2), 9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n -8 \\\\\n 3 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n -6 \\\\\n -6 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -3 \\\\\n -14 \\\\\n -3 \\\\\n 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [-8],\n [3],\n [4]])\nb = np.array([\n [5],\n [-6],\n [-6],\n [-4]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{8} & -\\frac{1}{4} \\\\\n \\frac{79}{8} & -\\frac{1}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{3 x}{4}+\\frac{163}{64}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/8), -(1/4)],\n [(79/8), -(1/8)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{22}{3} & -\\frac{23}{3} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(22/3), -(23/3), -4]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{8}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 9 \\\\\n -10 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{45}{8} \\\\\n -\\frac{25}{4} \\\\\n -\\frac{45}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9],\n [-10],\n [-9]])\nprint(a * (5/8))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -10 \\\\\n 4 \\\\\n 8 \\\\\n -7 \\\\\n -9 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$42$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [-10],\n [4],\n [8],\n [-7],\n [-9],\n [2]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -8 & -9 & -6 \\\\\n -7 & -6 & 4 \\\\\n 8 & 10 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.044,-1.383,1.\\}, \\{-0.694,0.609,1.\\}, \\{3.499,-3.635,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, -9, -6],\n [-7, -6, 4],\n [8, 10, 8]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 7 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 6 \\\\\n -8 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{314}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [7],\n [3]])\nb = np.array([\n [6],\n [-8],\n [-5]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 7 \\\\\n 6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -4 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 52 \\\\\n -8 \\\\\n -60 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [7],\n [6]])\nb = np.array([\n [4],\n [-4],\n [4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{1}{3}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -10 & 9 & -5 & 9 \\\\\n 3 & -4 & -4 & -8 \\\\\n -4 & -8 & -2 & 5 \\\\\n 2 & -10 & -4 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{10}{3} & 3 & -\\frac{5}{3} & 3 \\\\\n 1 & -\\frac{4}{3} & -\\frac{4}{3} & -\\frac{8}{3} \\\\\n -\\frac{4}{3} & -\\frac{8}{3} & -\\frac{2}{3} & \\frac{5}{3} \\\\\n \\frac{2}{3} & -\\frac{10}{3} & -\\frac{4}{3} & 3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 9, -5, 9],\n [3, -4, -4, -8],\n [-4, -8, -2, 5],\n [2, -10, -4, 9]])\nprint(a * (1/3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{2}{5}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{4}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2]])\nprint(a * (2/5))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{3}{\\sqrt{5}},\\sqrt{5},0\\right\\}, \\left\\{\\frac{3}{\\sqrt{5}},-\\frac{4}{\\sqrt{5}},-\\frac{3}{\\sqrt{5}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{5}},-\\frac{3}{\\sqrt{5}},\\frac{2}{\\sqrt{5}}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{3}{\\sqrt{34}},\\frac{5}{\\sqrt{34}},0\\right\\}, \\left\\{\\frac{27}{34} \\sqrt{\\frac{5}{\\frac{28629}{5780}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{11 \\sqrt{5}}{34}\\right)^2}},\\frac{\\frac{11 \\sqrt{5}}{34}-\\frac{4}{\\sqrt{5}}}{\\sqrt{\\frac{28629}{5780}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{11 \\sqrt{5}}{34}\\right)^2}},-\\frac{3}{\\sqrt{5 \\left(\\frac{28629}{5780}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{11 \\sqrt{5}}{34}\\right)^2\\right)}}\\right\\}, \\left\\{\\frac{\\frac{2 \\sqrt{5}}{17}-\\frac{27 \\sqrt{5} \\left(-\\frac{339}{170}-\\frac{3 \\left(-\\frac{4}{\\sqrt{5}}+\\frac{11 \\sqrt{5}}{34}\\right)}{\\sqrt{5}}\\right)}{34 \\left(\\frac{28629}{5780}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{11 \\sqrt{5}}{34}\\right)^2\\right)}}{\\sqrt{\\left(\\frac{2}{\\sqrt{5}}+\\frac{3 \\left(-\\frac{339}{170}-\\frac{3 \\left(-\\frac{4}{\\sqrt{5}}+\\frac{11 \\sqrt{5}}{34}\\right)}{\\sqrt{5}}\\right)}{\\sqrt{5} \\left(\\frac{28629}{5780}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{11 \\sqrt{5}}{34}\\right)^2\\right)}\\right)^2+\\left(\\frac{2 \\sqrt{5}}{17}-\\frac{27 \\sqrt{5} \\left(-\\frac{339}{170}-\\frac{3 \\left(-\\frac{4}{\\sqrt{5}}+\\frac{11 \\sqrt{5}}{34}\\right)}{\\sqrt{5}}\\right)}{34 \\left(\\frac{28629}{5780}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{11 \\sqrt{5}}{34}\\right)^2\\right)}\\right)^2+\\left(\\frac{3}{\\sqrt{5}}-\\frac{9 \\sqrt{5}}{17}-\\frac{\\left(\\frac{4}{\\sqrt{5}}-\\frac{11 \\sqrt{5}}{34}\\right) \\left(-\\frac{339}{170}-\\frac{3 \\left(-\\frac{4}{\\sqrt{5}}+\\frac{11 \\sqrt{5}}{34}\\right)}{\\sqrt{5}}\\right)}{\\frac{28629}{5780}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{11 \\sqrt{5}}{34}\\right)^2}\\right)^2}},\\frac{-\\frac{3}{\\sqrt{5}}+\\frac{9 \\sqrt{5}}{17}-\\frac{\\left(-\\frac{4}{\\sqrt{5}}+\\frac{11 \\sqrt{5}}{34}\\right) \\left(-\\frac{339}{170}-\\frac{3 \\left(-\\frac{4}{\\sqrt{5}}+\\frac{11 \\sqrt{5}}{34}\\right)}{\\sqrt{5}}\\right)}{\\frac{28629}{5780}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{11 \\sqrt{5}}{34}\\right)^2}}{\\sqrt{\\left(\\frac{2}{\\sqrt{5}}+\\frac{3 \\left(-\\frac{339}{170}-\\frac{3 \\left(-\\frac{4}{\\sqrt{5}}+\\frac{11 \\sqrt{5}}{34}\\right)}{\\sqrt{5}}\\right)}{\\sqrt{5} \\left(\\frac{28629}{5780}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{11 \\sqrt{5}}{34}\\right)^2\\right)}\\right)^2+\\left(\\frac{2 \\sqrt{5}}{17}-\\frac{27 \\sqrt{5} \\left(-\\frac{339}{170}-\\frac{3 \\left(-\\frac{4}{\\sqrt{5}}+\\frac{11 \\sqrt{5}}{34}\\right)}{\\sqrt{5}}\\right)}{34 \\left(\\frac{28629}{5780}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{11 \\sqrt{5}}{34}\\right)^2\\right)}\\right)^2+\\left(\\frac{3}{\\sqrt{5}}-\\frac{9 \\sqrt{5}}{17}-\\frac{\\left(\\frac{4}{\\sqrt{5}}-\\frac{11 \\sqrt{5}}{34}\\right) \\left(-\\frac{339}{170}-\\frac{3 \\left(-\\frac{4}{\\sqrt{5}}+\\frac{11 \\sqrt{5}}{34}\\right)}{\\sqrt{5}}\\right)}{\\frac{28629}{5780}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{11 \\sqrt{5}}{34}\\right)^2}\\right)^2}},\\frac{\\frac{2}{\\sqrt{5}}+\\frac{3 \\left(-\\frac{339}{170}-\\frac{3 \\left(-\\frac{4}{\\sqrt{5}}+\\frac{11 \\sqrt{5}}{34}\\right)}{\\sqrt{5}}\\right)}{\\sqrt{5} \\left(\\frac{28629}{5780}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{11 \\sqrt{5}}{34}\\right)^2\\right)}}{\\sqrt{\\left(\\frac{2}{\\sqrt{5}}+\\frac{3 \\left(-\\frac{339}{170}-\\frac{3 \\left(-\\frac{4}{\\sqrt{5}}+\\frac{11 \\sqrt{5}}{34}\\right)}{\\sqrt{5}}\\right)}{\\sqrt{5} \\left(\\frac{28629}{5780}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{11 \\sqrt{5}}{34}\\right)^2\\right)}\\right)^2+\\left(\\frac{2 \\sqrt{5}}{17}-\\frac{27 \\sqrt{5} \\left(-\\frac{339}{170}-\\frac{3 \\left(-\\frac{4}{\\sqrt{5}}+\\frac{11 \\sqrt{5}}{34}\\right)}{\\sqrt{5}}\\right)}{34 \\left(\\frac{28629}{5780}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{11 \\sqrt{5}}{34}\\right)^2\\right)}\\right)^2+\\left(\\frac{3}{\\sqrt{5}}-\\frac{9 \\sqrt{5}}{17}-\\frac{\\left(\\frac{4}{\\sqrt{5}}-\\frac{11 \\sqrt{5}}{34}\\right) \\left(-\\frac{339}{170}-\\frac{3 \\left(-\\frac{4}{\\sqrt{5}}+\\frac{11 \\sqrt{5}}{34}\\right)}{\\sqrt{5}}\\right)}{\\frac{28629}{5780}+\\left(\\frac{4}{\\sqrt{5}}-\\frac{11 \\sqrt{5}}{34}\\right)^2}\\right)^2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((3/(math.sqrt(5))), math.sqrt(5), 0), ((3/(math.sqrt(5))), -(4/(math.sqrt(5))), -(3/(math.sqrt(5)))), (-(1/(math.sqrt(5))), -(3/(math.sqrt(5))), (2/(math.sqrt(5))))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & -1 & -3 \\\\\n 3 & 3 & 3 \\\\\n 1 & 3 & -2 \\\\\n 2 & -1 & -1 \\\\\n -3 & -2 & -1 \\\\\n 3 & 0 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.74 \\\\\n -0.69 \\\\\n 2.74 \\\\\n 0.79 \\\\\n 1.55 \\\\\n 0.71 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.367 \\\\\n 0.548 \\\\\n -0.446 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1, -3],\n [3, 3, 3],\n [1, 3, -2],\n [2, -1, -1],\n [-3, -2, -1],\n [3, 0, -2]])\nb = np.array([\n [-1.74],\n [-0.69],\n [2.74],\n [0.79],\n [1.55],\n [0.71]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{4}{3} \\\\\n -\\frac{4}{3} \\\\\n \\frac{7}{3} \\\\\n \\frac{4}{3} \\\\\n -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{4}{\\sqrt{101}} \\\\\n -\\frac{4}{\\sqrt{101}} \\\\\n \\frac{7}{\\sqrt{101}} \\\\\n \\frac{4}{\\sqrt{101}} \\\\\n -\\frac{2}{\\sqrt{101}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(4/3)],\n [-(4/3)],\n [(7/3)],\n [(4/3)],\n [-(2/3)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{3}{2} & -1 & -\\frac{9}{2} \\\\\n 1 & \\frac{7}{2} & -4 \\\\\n 0 & -\\frac{15}{2} & -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.381,-1.413,1.\\}, \\{1.002,0.306,1.\\}, \\{5.312,-0.226,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), -1, -(9/2)],\n [1, (7/2), -4],\n [0, -(15/2), -4]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{7}{3} & \\frac{31}{6} \\\\\n \\frac{11}{6} & \\frac{43}{6} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{19 x}{2}+\\frac{29}{4}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/3), (31/6)],\n [(11/6), (43/6)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-1,0,-2\\}, \\{-3,3,1\\}, \\{-1,-3,0\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{5}},0,-\\frac{2}{\\sqrt{5}}\\right\\}, \\left\\{-7 \\sqrt{\\frac{2}{235}},3 \\sqrt{\\frac{5}{94}},\\frac{7}{\\sqrt{470}}\\right\\}, \\left\\{-3 \\sqrt{\\frac{2}{47}},-\\frac{7}{\\sqrt{94}},\\frac{3}{\\sqrt{94}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, 0, -2), (-3, 3, 1), (-1, -3, 0)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{14}{9} \\\\\n \\frac{7}{3} \\\\\n -\\frac{82}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{62}{9} \\\\\n \\frac{23}{3} \\\\\n \\frac{85}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{827}{9} \\\\\n \\frac{1298}{27} \\\\\n 28 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(14/9)],\n [(7/3)],\n [-(82/9)]])\nb = np.array([\n [-(62/9)],\n [(23/3)],\n [(85/9)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -1 & 8 \\\\\n -3 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+23$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 8],\n [-3, 1]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{4}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 5 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n -\\frac{15}{4} \\\\\n -\\frac{15}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [5],\n [5]])\nprint(a * -(3/4))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 1 & 3 & 2 & 1 \\\\\n 0 & -1 & -3 & 2 \\\\\n -1 & -2 & -1 & 1 \\\\\n 3 & -2 & -1 & 0 \\\\\n -1 & -2 & -1 & 0 \\\\\n 1 & 0 & 1 & 3 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.01 \\\\\n -0.94 \\\\\n -1.46 \\\\\n -0.58 \\\\\n -2.61 \\\\\n 2.01 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.111 \\\\\n -0.066 \\\\\n 0.374 \\\\\n 0.069 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 3, 2, 1],\n [0, -1, -3, 2],\n [-1, -2, -1, 1],\n [3, -2, -1, 0],\n [-1, -2, -1, 0],\n [1, 0, 1, 3]])\nb = np.array([\n [-2.01],\n [-0.94],\n [-1.46],\n [-0.58],\n [-2.61],\n [2.01]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-4, -3}$ to the line $-\\frac{x}{3}+\\frac{y}{3}+1=0$.", - "Output Answer": [ - "$2 \\sqrt{2}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -4, -3\nline = Poly(-(x/3)+(y/3)+1, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{cc}\n 5 & -3 \\\\\n -2 & -8 \\\\\n -3 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -3],\n [-2, -8],\n [-3, 4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1}{\\sqrt{3}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [0],\n [-1],\n [-1]]).squeeze()\nb = np.array([\n [0],\n [0],\n [0],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{2,-\\frac{5}{4},-\\frac{7}{4}\\right\\}, \\left\\{0,\\frac{7}{4},\\frac{11}{4}\\right\\}, \\left\\{0,1,-\\frac{5}{2}\\right\\}}$", - "Output Answer": [ - "${\\left\\{4 \\sqrt{\\frac{2}{69}},-\\frac{5}{\\sqrt{138}},-\\frac{7}{\\sqrt{138}}\\right\\}, \\left\\{224 \\sqrt{\\frac{2}{188301}},\\frac{203}{\\sqrt{376602}},\\frac{367}{\\sqrt{376602}}\\right\\}, \\left\\{\\frac{3}{\\sqrt{2729}},\\frac{44}{\\sqrt{2729}},-\\frac{28}{\\sqrt{2729}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, -(5/4), -(7/4)), (0, (7/4), (11/4)), (0, 1, -(5/2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7.9 \\\\\n -3.5 \\\\\n -3.3 \\\\\n 7.2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9. \\\\\n 6.4 \\\\\n -7.5 \\\\\n -1.1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$13.629$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7.9],\n [-3.5],\n [-3.3],\n [7.2]])\nb = np.array([\n [-9.],\n [6.4],\n [-7.5],\n [-1.1]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -5 & 2 & 4 & -2 \\\\\n -2 & -4 & 0 & -8 \\\\\n -6 & -8 & 1 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{98.,-53.,150.,2.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-5, 2, 4, -2],\n [-2, -4, 0, -8],\n [-6, -8, 1, 7]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{2} \\\\\n -\\frac{11}{2} \\\\\n -4 \\\\\n \\frac{15}{2} \\\\\n -3 \\\\\n -\\frac{9}{2} \\\\\n \\frac{7}{2} \\\\\n 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{15}{2}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/2)],\n [-(11/2)],\n [-4],\n [(15/2)],\n [-3],\n [-(9/2)],\n [(7/2)],\n [7]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{19}{10}, -\\frac{7}{2}}$ to the line $\\frac{19 x}{5}-\\frac{16 y}{5}-\\frac{11}{10}=0$.", - "Output Answer": [ - "$\\frac{433}{5 \\sqrt{617}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (19/10), -(7/2)\nline = Poly(((19*x)/5)-((16*y)/5)-(11/10), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 7 & -4 & 4 \\\\\n 7 & 1 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & \\frac{4}{5} \\\\\n 0 & 1 & \\frac{2}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [7, -4, 4],\n [7, 1, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-5,2,3\\}, \\{0,-3,-3\\}, \\{-5,4,0\\}}$.", - "Output Answer": [ - "$27 x+15 y+10 z+75=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-5, 2, 3],\n [0, -3, -3],\n [-5, 4, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-80$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10]])\nb = np.array([\n [-8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -6 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 6 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -54 \\\\\n 19 \\\\\n -48 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-6],\n [1]])\nb = np.array([\n [-5],\n [6],\n [8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n \\frac{139}{50} & \\frac{91}{100} & \\frac{451}{50} & -\\frac{717}{100} \\\\\n -\\frac{181}{100} & \\frac{243}{50} & \\frac{169}{25} & -\\frac{227}{50} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n \\frac{97}{100} & -\\frac{277}{50} & -\\frac{87}{10} & -\\frac{142}{25} \\\\\n \\frac{841}{100} & -\\frac{203}{25} & \\frac{21}{4} & -\\frac{1}{4} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{15}{4} & -\\frac{463}{100} & \\frac{8}{25} & -\\frac{257}{20} \\\\\n \\frac{33}{5} & -\\frac{163}{50} & \\frac{1201}{100} & -\\frac{479}{100} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(139/50), (91/100), (451/50), -(717/100)],\n [-(181/100), (243/50), (169/25), -(227/50)]])\nb = np.array([\n [(97/100), -(277/50), -(87/10), -(142/25)],\n [(841/100), -(203/25), (21/4), -(1/4)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{13}{9}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -8 & 10 & -2 \\\\\n -9 & 10 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{104}{9} & -\\frac{130}{9} & \\frac{26}{9} \\\\\n 13 & -\\frac{130}{9} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 10, -2],\n [-9, 10, 0]])\nprint(a * -(13/9))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{\\frac{1}{\\sqrt{2}},\\sqrt{2},\\frac{1}{\\sqrt{2}}\\right\\}, \\left\\{\\sqrt{2},-\\frac{1}{\\sqrt{2}},-2 \\sqrt{2}\\right\\}, \\left\\{\\frac{3}{\\sqrt{2}},-\\frac{3}{\\sqrt{2}},\\frac{3}{\\sqrt{2}}\\right\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{6}},\\sqrt{\\frac{2}{3}},\\frac{1}{\\sqrt{6}}\\right\\}, \\left\\{\\frac{4}{3} \\sqrt{\\frac{2}{\\frac{82}{9}+\\left(\\frac{2 \\sqrt{2}}{3}-\\frac{1}{\\sqrt{2}}\\right)^2}},\\frac{\\frac{2 \\sqrt{2}}{3}-\\frac{1}{\\sqrt{2}}}{\\sqrt{\\frac{82}{9}+\\left(\\frac{2 \\sqrt{2}}{3}-\\frac{1}{\\sqrt{2}}\\right)^2}},-\\frac{5}{3} \\sqrt{\\frac{2}{\\frac{82}{9}+\\left(\\frac{2 \\sqrt{2}}{3}-\\frac{1}{\\sqrt{2}}\\right)^2}}\\right\\}, \\left\\{\\frac{\\frac{3}{\\sqrt{2}}-\\frac{4 \\sqrt{2} \\left(-1-\\frac{3 \\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)}{\\sqrt{2}}\\right)}{3 \\left(\\frac{82}{9}+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)^2\\right)}}{\\sqrt{\\left(\\frac{3}{\\sqrt{2}}-\\frac{4 \\sqrt{2} \\left(-1-\\frac{3 \\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)}{\\sqrt{2}}\\right)}{3 \\left(\\frac{82}{9}+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)^2\\right)}\\right)^2+\\left(\\frac{3}{\\sqrt{2}}+\\frac{5 \\sqrt{2} \\left(-1-\\frac{3 \\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)}{\\sqrt{2}}\\right)}{3 \\left(\\frac{82}{9}+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)^2\\right)}\\right)^2+\\left(\\frac{3}{\\sqrt{2}}-\\frac{\\left(\\frac{1}{\\sqrt{2}}-\\frac{2 \\sqrt{2}}{3}\\right) \\left(-1-\\frac{3 \\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)}{\\sqrt{2}}\\right)}{\\frac{82}{9}+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)^2}\\right)^2}},\\frac{-\\frac{3}{\\sqrt{2}}-\\frac{\\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right) \\left(-1-\\frac{3 \\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)}{\\sqrt{2}}\\right)}{\\frac{82}{9}+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)^2}}{\\sqrt{\\left(\\frac{3}{\\sqrt{2}}-\\frac{4 \\sqrt{2} \\left(-1-\\frac{3 \\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)}{\\sqrt{2}}\\right)}{3 \\left(\\frac{82}{9}+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)^2\\right)}\\right)^2+\\left(\\frac{3}{\\sqrt{2}}+\\frac{5 \\sqrt{2} \\left(-1-\\frac{3 \\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)}{\\sqrt{2}}\\right)}{3 \\left(\\frac{82}{9}+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)^2\\right)}\\right)^2+\\left(\\frac{3}{\\sqrt{2}}-\\frac{\\left(\\frac{1}{\\sqrt{2}}-\\frac{2 \\sqrt{2}}{3}\\right) \\left(-1-\\frac{3 \\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)}{\\sqrt{2}}\\right)}{\\frac{82}{9}+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)^2}\\right)^2}},\\frac{\\frac{3}{\\sqrt{2}}+\\frac{5 \\sqrt{2} \\left(-1-\\frac{3 \\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)}{\\sqrt{2}}\\right)}{3 \\left(\\frac{82}{9}+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)^2\\right)}}{\\sqrt{\\left(\\frac{3}{\\sqrt{2}}-\\frac{4 \\sqrt{2} \\left(-1-\\frac{3 \\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)}{\\sqrt{2}}\\right)}{3 \\left(\\frac{82}{9}+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)^2\\right)}\\right)^2+\\left(\\frac{3}{\\sqrt{2}}+\\frac{5 \\sqrt{2} \\left(-1-\\frac{3 \\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)}{\\sqrt{2}}\\right)}{3 \\left(\\frac{82}{9}+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)^2\\right)}\\right)^2+\\left(\\frac{3}{\\sqrt{2}}-\\frac{\\left(\\frac{1}{\\sqrt{2}}-\\frac{2 \\sqrt{2}}{3}\\right) \\left(-1-\\frac{3 \\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)}{\\sqrt{2}}\\right)}{\\frac{82}{9}+\\left(-\\frac{1}{\\sqrt{2}}+\\frac{2 \\sqrt{2}}{3}\\right)^2}\\right)^2}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack((((1/(math.sqrt(2))), math.sqrt(2), (1/(math.sqrt(2)))), (math.sqrt(2), -(1/(math.sqrt(2))), -2*math.sqrt(2)), ((3/(math.sqrt(2))), -(3/(math.sqrt(2))), (3/(math.sqrt(2))))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\pi \\\\\n -3 \\pi \\\\\n -3 \\pi \\\\\n -2 \\pi \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 2 \\pi \\\\\n 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{47} \\pi$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [3*math.pi],\n [-3*math.pi],\n [-3*math.pi],\n [-2*math.pi]])\nb = np.array([\n [0],\n [0],\n [2*math.pi],\n [0]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{16}$ and the matrix\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -5 \\\\\n -5 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{7}{4} \\\\\n \\frac{35}{16} \\\\\n \\frac{35}{16} \\\\\n -\\frac{7}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-5],\n [-5],\n [2]])\nprint(a * -(7/16))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 6. \\\\\n 4.8 \\\\\n -1.8 \\\\\n -9.3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -4.9 \\\\\n 6.2 \\\\\n 8.7 \\\\\n 8.4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-93.42$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [6.],\n [4.8],\n [-1.8],\n [-9.3]])\nb = np.array([\n [-4.9],\n [6.2],\n [8.7],\n [8.4]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & \\frac{5}{2} & -\\frac{1}{2} \\\\\n \\frac{1}{2} & 2 & -3 \\\\\n -\\frac{5}{2} & 3 & \\frac{5}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{237}{8} & -7 & -\\frac{343}{8} \\\\\n \\frac{83}{2} & -\\frac{105}{4} & -\\frac{221}{8} \\\\\n \\frac{1}{8} & -\\frac{65}{8} & -\\frac{175}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, (5/2), -(1/2)],\n [(1/2), 2, -3],\n [-(5/2), 3, (5/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{37}{4} & \\frac{1}{2} & -\\frac{27}{4} \\\\\n -\\frac{3}{4} & \\frac{31}{4} & -4 \\\\\n \\frac{5}{2} & -\\frac{1}{2} & \\frac{5}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{1.049,1.083,1.\\}, \\{2.482\\, -1.37 i,-0.011-3.474 i,1.\\}, \\{2.482\\, +1.37 i,-0.011+3.474 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(37/4), (1/2), -(27/4)],\n [-(3/4), (31/4), -4],\n [(5/2), -(1/2), (5/4)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n -\\frac{8}{5} & -\\frac{9}{5} & \\frac{9}{5} & \\frac{9}{5} \\\\\n -1 & 2 & -\\frac{3}{5} & \\frac{2}{5} \\\\\n \\frac{6}{5} & \\frac{13}{5} & \\frac{2}{5} & \\frac{14}{5} \\\\\n -2 & -\\frac{1}{5} & -3 & \\frac{14}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{9}{5} & \\frac{9}{5} \\\\\n 1 & -2 \\\\\n \\frac{13}{5} & -\\frac{14}{5} \\\\\n \\frac{4}{5} & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{36}{25} & -\\frac{108}{25} \\\\\n -\\frac{26}{25} & -\\frac{103}{25} \\\\\n \\frac{201}{25} & -\\frac{104}{25} \\\\\n -\\frac{234}{25} & \\frac{26}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(8/5), -(9/5), (9/5), (9/5)],\n [-1, 2, -(3/5), (2/5)],\n [(6/5), (13/5), (2/5), (14/5)],\n [-2, -(1/5), -3, (14/5)]])\nb = np.array([\n [(9/5), (9/5)],\n [1, -2],\n [(13/5), -(14/5)],\n [(4/5), 0]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & 1 & 9 \\\\\n -2 & 1 & -3 \\\\\n -3 & -4 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{1.569,4.216\\, -3. i,4.216\\, +3. i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 1, 9],\n [-2, 1, -3],\n [-3, -4, 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 3 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -3 & 2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 6 & -4 & 6 \\\\\n -9 & 6 & -9 \\\\\n -3 & 2 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [3],\n [1]])\nb = np.array([\n [-3, 2, -3]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{5}{3} \\\\\n -\\frac{7}{3} \\\\\n -\\frac{7}{3} \\\\\n 1 \\\\\n \\frac{1}{3} \\\\\n -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{5}{\\sqrt{214}} \\\\\n -\\frac{7}{\\sqrt{214}} \\\\\n -\\frac{7}{\\sqrt{214}} \\\\\n \\frac{3}{\\sqrt{214}} \\\\\n \\frac{1}{\\sqrt{214}} \\\\\n -\\frac{9}{\\sqrt{214}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3)],\n [-(7/3)],\n [-(7/3)],\n [1],\n [(1/3)],\n [-3]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{3}{100}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & -2 \\\\\n -4 & 6 \\\\\n -6 & -7 \\\\\n 3 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{3}{100} & \\frac{3}{50} \\\\\n \\frac{3}{25} & -\\frac{9}{50} \\\\\n \\frac{9}{50} & \\frac{21}{100} \\\\\n -\\frac{9}{100} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2],\n [-4, 6],\n [-6, -7],\n [3, 0]])\nprint(a * -(3/100))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{13}{7}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -10 & -10 & -5 \\\\\n -4 & -7 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{130}{7} & \\frac{130}{7} & \\frac{65}{7} \\\\\n \\frac{52}{7} & 13 & \\frac{104}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, -10, -5],\n [-4, -7, -8]])\nprint(a * -(13/7))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{11}{5}, -\\frac{19}{5}, 2}$ to the plane $-\\frac{17 x}{5}-4 y-\\frac{17 z}{5}-4=0$.", - "Output Answer": [ - "$\\frac{99 \\sqrt{\\frac{3}{326}}}{5}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(11/5), -(19/5), 2\nplane = Poly(-((17*x)/5)-4*y-((17*z)/5)-4, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -6 \\\\\n -\\frac{5}{6} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{6} \\\\\n \\frac{29}{6} \\\\\n -\\frac{11}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{1333}{36} \\\\\n \\frac{1451}{36} \\\\\n \\frac{125}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-6],\n [-(5/6)]])\nb = np.array([\n [-(13/6)],\n [(29/6)],\n [-(11/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -3 & 2 & 5 \\\\\n -3 & 3 & 6 \\\\\n -7 & -8 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-5.162-7.53 i,-5.162+7.53 i,0.324\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2, 5],\n [-3, 3, 6],\n [-7, -8, -10]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 5 \\\\\n 17 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [8]])\nb = np.array([\n [8],\n [9]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n \\frac{18}{5} & \\frac{21}{5} & 3 \\\\\n \\frac{21}{5} & -\\frac{13}{5} & -\\frac{2}{5} \\\\\n -\\frac{21}{5} & \\frac{22}{5} & \\frac{19}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{8316}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(18/5), (21/5), 3],\n [(21/5), -(13/5), -(2/5)],\n [-(21/5), (22/5), (19/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{22}{3} & -\\frac{13}{3} \\\\\n 2 & \\frac{19}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{20}{3},\\frac{17}{3}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(22/3), -(13/3)],\n [2, (19/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -2 & -\\frac{3}{2} \\\\\n \\frac{3}{2} & \\frac{5}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{7}{4} & -\\frac{3}{4} \\\\\n \\frac{3}{4} & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -(3/2)],\n [(3/2), (5/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n 10 & 1 \\\\\n 3 & 9 \\\\\n 5 & -3 \\\\\n 7 & 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n 9 & 4 \\\\\n 1 & -6 \\\\\n 1 & -6 \\\\\n -2 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 19 & 5 \\\\\n 4 & 3 \\\\\n 6 & -9 \\\\\n 5 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 1],\n [3, 9],\n [5, -3],\n [7, 4]])\nb = np.array([\n [9, 4],\n [1, -6],\n [1, -6],\n [-2, -7]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 4 & -7 \\\\\n 2 & -5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+x-6$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -7],\n [2, -5]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{9}{2} & -\\frac{19}{2} & \\frac{31}{4} \\\\\n -3 & -\\frac{29}{4} & -\\frac{1}{2} \\\\\n -\\frac{7}{4} & \\frac{11}{4} & -2 \\\\\n -\\frac{19}{4} & -\\frac{5}{2} & -8 \\\\\n -8 & 6 & \\frac{3}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2), -(19/2), (31/4)],\n [-3, -(29/4), -(1/2)],\n [-(7/4), (11/4), -2],\n [-(19/4), -(5/2), -8],\n [-8, 6, (3/4)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccc}\n -3 & 2 & -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccccc}\n 1 & -1 & 3 & 3 & 1 \\\\\n -2 & -3 & -2 & 0 & -2 \\\\\n -2 & -1 & 1 & -3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n -5 & -2 & -14 & -6 & -9 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 2, -1]])\nb = np.array([\n [1, -1, 3, 3, 1],\n [-2, -3, -2, 0, -2],\n [-2, -1, 1, -3, 2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -1 & 10 & 5 & 9 & -2 \\\\\n 7 & -4 & -9 & 1 & -6 \\\\\n -5 & 3 & 10 & 1 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-34.,-23.,-13.,29.,0.\\}, \\{583.,-137.,437.,0.,116.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, 10, 5, 9, -2],\n [7, -4, -9, 1, -6],\n [-5, 3, 10, 1, -9]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{cccc}\n \\frac{19}{5} & \\frac{41}{5} & -\\frac{3}{5} & 7 \\\\\n \\frac{4}{5} & -\\frac{26}{5} & -5 & \\frac{3}{5} \\\\\n \\frac{33}{5} & 7 & \\frac{32}{5} & \\frac{47}{5} \\\\\n -\\frac{24}{5} & -\\frac{49}{5} & \\frac{21}{5} & \\frac{3}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(19/5), (41/5), -(3/5), 7],\n [(4/5), -(26/5), -5, (3/5)],\n [(33/5), 7, (32/5), (47/5)],\n [-(24/5), -(49/5), (21/5), (3/5)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -6 & -10 & 0 & -5 \\\\\n -7 & -9 & -4 & 8 \\\\\n 2 & 4 & -8 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{400.,-268.,15.,56.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-6, -10, 0, -5],\n [-7, -9, -4, 8],\n [2, 4, -8, 7]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 2 & -3 & -2 & -2 & -3 \\\\\n 1 & 1 & 0 & 1 & -2 \\\\\n 0 & -2 & 0 & 1 & -1 \\\\\n 0 & 2 & -2 & 1 & -2 \\\\\n -2 & 1 & 1 & 3 & 1 \\\\\n 0 & 0 & -3 & 3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.35 \\\\\n 0.1 \\\\\n -1.22 \\\\\n 2.08 \\\\\n -1.9 \\\\\n 2.07 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 1.393 \\\\\n 0.655 \\\\\n -1.101 \\\\\n 0.314 \\\\\n 1.053 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -3, -2, -2, -3],\n [1, 1, 0, 1, -2],\n [0, -2, 0, 1, -1],\n [0, 2, -2, 1, -2],\n [-2, 1, 1, 3, 1],\n [0, 0, -3, 3, -2]])\nb = np.array([\n [-1.35],\n [0.1],\n [-1.22],\n [2.08],\n [-1.9],\n [2.07]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 0 & 6 & -6 & 8 \\\\\n -7 & -9 & -9 & 7 \\\\\n -1 & -9 & -8 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & -\\frac{107}{101} \\\\\n 0 & 1 & 0 & \\frac{209}{303} \\\\\n 0 & 0 & 1 & -\\frac{65}{101} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [0, 6, -6, 8],\n [-7, -9, -9, 7],\n [-1, -9, -8, 0]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{27}{16} \\\\\n \\frac{35}{16} \\\\\n -\\frac{15}{16} \\\\\n \\frac{7}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{27}{\\sqrt{2963}} \\\\\n \\frac{35}{\\sqrt{2963}} \\\\\n -\\frac{15}{\\sqrt{2963}} \\\\\n \\frac{28}{\\sqrt{2963}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(27/16)],\n [(35/16)],\n [-(15/16)],\n [(7/4)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n -4 & 4 & 8 \\\\\n 3 & -3 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 4, 8],\n [3, -3, 6]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n \\frac{3}{2} & 2 & -\\frac{3}{2} \\\\\n -\\frac{5}{2} & \\frac{3}{2} & -2 \\\\\n -\\frac{5}{2} & -\\frac{1}{2} & \\frac{1}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & \\frac{27}{4} & -7 \\\\\n -\\frac{5}{2} & -\\frac{7}{4} & -\\frac{1}{4} \\\\\n -\\frac{15}{4} & -6 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/2), 2, -(3/2)],\n [-(5/2), (3/2), -2],\n [-(5/2), -(1/2), (1/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 5 & 3 & 3 \\\\\n -\\frac{5}{3} & -\\frac{28}{3} & -\\frac{11}{3} \\\\\n \\frac{23}{3} & 2 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8.872,0.13,8.409\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 3, 3],\n [-(5/3), -(28/3), -(11/3)],\n [(23/3), 2, 4]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-4,2,4\\}, \\{2,-4,4\\}, \\{2,3,-2\\}}$.", - "Output Answer": [ - "$6 (x+y)+7 z-16=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-4, 2, 4],\n [2, -4, 4],\n [2, 3, -2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -3 & -7 & -5 & 8 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -7, -5, 8, 4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -6 \\\\\n 0 \\\\\n 4 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 9 \\\\\n 5 \\\\\n 1 \\\\\n 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{58}{13 \\sqrt{37}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-6],\n [0],\n [4],\n [-6]]).squeeze()\nb = np.array([\n [4],\n [9],\n [5],\n [1],\n [5]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 4 & -3 & 4 \\\\\n 5 & -3 & 0 \\\\\n -3 & 0 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-33$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -3, 4],\n [5, -3, 0],\n [-3, 0, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{1,1,1\\}, \\{-3,2,1\\}, \\{2,-1,-1\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{1}{\\sqrt{3}},\\frac{1}{\\sqrt{3}},\\frac{1}{\\sqrt{3}}\\right\\}, \\left\\{-\\frac{3}{\\sqrt{14}},\\sqrt{\\frac{2}{7}},\\frac{1}{\\sqrt{14}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{42}},2 \\sqrt{\\frac{2}{21}},-\\frac{5}{\\sqrt{42}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((1, 1, 1), (-3, 2, 1), (2, -1, -1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$71$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [-1]])\nb = np.array([\n [-8],\n [1]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n -2 & -2 \\\\\n 3 & 3 \\\\\n -1 & 2 \\\\\n 0 & -1 \\\\\n -2 & -1 \\\\\n 3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 0.84 \\\\\n -0.75 \\\\\n -1. \\\\\n 0.37 \\\\\n -0.05 \\\\\n -0.5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.11 \\\\\n -0.195 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -2],\n [3, 3],\n [-1, 2],\n [0, -1],\n [-2, -1],\n [3, -2]])\nb = np.array([\n [0.84],\n [-0.75],\n [-1.],\n [0.37],\n [-0.05],\n [-0.5]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -9 \\\\\n 3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -10 \\\\\n 7 \\\\\n 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -84 \\\\\n -100 \\\\\n -20 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10],\n [-9],\n [3]])\nb = np.array([\n [-10],\n [7],\n [7]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -4 & -3 & 4 \\\\\n 1 & 4 & -4 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-13$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, -3, 4],\n [1, 4, -4],\n [0, 0, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 4 \\\\\n 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-3]])\nb = np.array([\n [-3],\n [8]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-3, 4, 2}$ to the plane $5 x+2 y-z-5=0$.", - "Output Answer": [ - "$7 \\sqrt{\\frac{2}{15}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -3, 4, 2\nplane = Poly(5*x+2*y-z-5, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n \\frac{10}{3} \\\\\n \\frac{11}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{17}{3} \\\\\n -\\frac{1}{3} \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{109}{9} \\\\\n \\frac{187}{9} \\\\\n -\\frac{170}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [(10/3)],\n [(11/3)]])\nb = np.array([\n [(17/3)],\n [-(1/3)],\n [-4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,-1,2\\}, \\{-3,4,2\\}, \\{-5,3,2\\}}$.", - "Output Answer": [ - "$z-2=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -1, 2],\n [-3, 4, 2],\n [-5, 3, 2]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -5 & -2 \\\\\n -3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -2],\n [-3, -2]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 1 & 7 & -8 \\\\\n 8 & -6 & 7 \\\\\n 2 & 9 & -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -8 & 8 & -3 \\\\\n -8 & -6 & -7 \\\\\n -1 & -1 & 6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -7 & 15 & -11 \\\\\n 0 & -12 & 0 \\\\\n 1 & 8 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 7, -8],\n [8, -6, 7],\n [2, 9, -4]])\nb = np.array([\n [-8, 8, -3],\n [-8, -6, -7],\n [-1, -1, 6]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & -2 & 1 \\\\\n 0 & -2 & 2 \\\\\n 0 & 2 & -2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & -24 & 24 \\\\\n 0 & -32 & 32 \\\\\n 0 & 32 & -32 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -2, 1],\n [0, -2, 2],\n [0, 2, -2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -7 & 2 & 8 & 10 \\\\\n 6 & 6 & 2 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{22.,-31.,27.,0.\\}, \\{62.,-53.,0.,54.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-7, 2, 8, 10],\n [6, 6, 2, -1]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$34$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [1]])\nb = np.array([\n [8],\n [2]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & -10 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{8.,0.,7.\\}, \\{10.,7.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [7, -10, -8]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n -6 \\\\\n 9 \\\\\n -6 \\\\\n 9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -6 \\\\\n 10 \\\\\n 8 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(\\frac{115}{\\sqrt{55167}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [-6],\n [9],\n [-6],\n [9]]).squeeze()\nb = np.array([\n [-2],\n [-6],\n [10],\n [8],\n [3]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -5 & 9 & 7 \\\\\n -6 & 5 & 7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 1 & -7 & -3 \\\\\n 3 & 2 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -4 & 2 & 4 \\\\\n -3 & 7 & 16 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 9, 7],\n [-6, 5, 7]])\nb = np.array([\n [1, -7, -3],\n [3, 2, 9]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n 3 & 6 & 8 \\\\\n 3 & -3 & 7 \\\\\n -2 & -9 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+x^2-52 x-186$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 6, 8],\n [3, -3, 7],\n [-2, -9, 1]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n \\frac{52}{9} & -\\frac{22}{9} & -\\frac{44}{9} & -\\frac{25}{3} & \\frac{58}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(52/9), -(22/9), -(44/9), -(25/3), (58/9)]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 2 & 7 & 10 \\\\\n 1 & 0 & -5 \\\\\n -8 & 4 & -3 \\\\\n 7 & 6 & -5 \\\\\n -8 & 7 & -5 \\\\\n -6 & -8 & 5 \\\\\n -9 & 9 & -10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, 7, 10],\n [1, 0, -5],\n [-8, 4, -3],\n [7, 6, -5],\n [-8, 7, -5],\n [-6, -8, 5],\n [-9, 9, -10]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n 5 \\\\\n -9 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n -2 \\\\\n -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -38 \\\\\n 27 \\\\\n 53 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9],\n [5],\n [-9]])\nb = np.array([\n [-7],\n [-2],\n [-4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 4 \\\\\n 4 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{57}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [4],\n [4],\n [-4]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -1 & 1 & -7 & -6 \\\\\n 4 & 1 & -8 & 1 \\\\\n 2 & -4 & 5 & 5 \\\\\n 1 & -10 & 4 & 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 6 & 8 & 1 & -6 \\\\\n -4 & 7 & 10 & 1 \\\\\n 3 & 10 & -8 & -10 \\\\\n 3 & -5 & 10 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 5 & 9 & -6 & -12 \\\\\n 0 & 8 & 2 & 2 \\\\\n 5 & 6 & -3 & -5 \\\\\n 4 & -15 & 14 & -3 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, -7, -6],\n [4, 1, -8, 1],\n [2, -4, 5, 5],\n [1, -10, 4, 4]])\nb = np.array([\n [6, 8, 1, -6],\n [-4, 7, 10, 1],\n [3, 10, -8, -10],\n [3, -5, 10, -7]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccccc}\n -2 & -3 & 1 & -9 & 2 \\\\\n -6 & -1 & -6 & 1 & 2 \\\\\n 9 & -8 & -6 & 3 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$2$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -3, 1, -9, 2],\n [-6, -1, -6, 1, 2],\n [9, -8, -6, 3, 5]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 4 & 9 & 5 & -6 & -5 & -5 & 4 \\\\\n -3 & 1 & -3 & -8 & -9 & -10 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & \\frac{32}{31} & \\frac{66}{31} & \\frac{76}{31} & \\frac{85}{31} & \\frac{85}{31} \\\\\n 0 & 1 & \\frac{3}{31} & -\\frac{50}{31} & -\\frac{51}{31} & -\\frac{55}{31} & -\\frac{24}{31} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [4, 9, 5, -6, -5, -5, 4],\n [-3, 1, -3, -8, -9, -10, -9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n \\frac{11}{5} & \\frac{13}{5} \\\\\n -2 & -\\frac{18}{5} \\\\\n -\\frac{29}{5} & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{37}{5} & \\frac{24}{5} \\\\\n -\\frac{42}{5} & \\frac{43}{5} \\\\\n -\\frac{34}{5} & -\\frac{29}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{48}{5} & \\frac{37}{5} \\\\\n -\\frac{52}{5} & 5 \\\\\n -\\frac{63}{5} & -\\frac{29}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/5), (13/5)],\n [-2, -(18/5)],\n [-(29/5), 0]])\nb = np.array([\n [(37/5), (24/5)],\n [-(42/5), (43/5)],\n [-(34/5), -(29/5)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{5,-5,1\\}, \\{5,-2,0\\}, \\{-1,-4,-3\\}}$.", - "Output Answer": [ - "$11 x-6 y-18 z-67=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [5, -5, 1],\n [5, -2, 0],\n [-1, -4, -3]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 4 & -3 & -4 & 4 \\\\\n 0 & 10 & 3 & -9 \\\\\n -3 & -8 & 3 & 8 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 9 & 4 & -7 & -4 \\\\\n -8 & 7 & -4 & -2 \\\\\n -5 & 0 & 4 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 13 & 1 & -11 & 0 \\\\\n -8 & 17 & -1 & -11 \\\\\n -8 & -8 & 7 & -1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -3, -4, 4],\n [0, 10, 3, -9],\n [-3, -8, 3, 8]])\nb = np.array([\n [9, 4, -7, -4],\n [-8, 7, -4, -2],\n [-5, 0, 4, -9]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{2,3,2\\}, \\{0,0,-2\\}, \\{0,-3,-1\\}}$", - "Output Answer": [ - "${\\left\\{\\frac{2}{\\sqrt{17}},\\frac{3}{\\sqrt{17}},\\frac{2}{\\sqrt{17}}\\right\\}, \\left\\{\\frac{4}{\\sqrt{221}},\\frac{6}{\\sqrt{221}},-\\sqrt{\\frac{13}{17}}\\right\\}, \\left\\{\\frac{3}{\\sqrt{13}},-\\frac{2}{\\sqrt{13}},0\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((2, 3, 2), (0, 0, -2), (0, -3, -1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1}{\\sqrt{6}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [-1],\n [0],\n [-1],\n [-1],\n [-1]]).squeeze()\nb = np.array([\n [1],\n [1],\n [-1],\n [1],\n [1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${-\\frac{34}{7}, \\frac{26}{7}}$ to the line $2 x-\\frac{17 y}{7}-\\frac{13}{7}=0$.", - "Output Answer": [ - "$\\frac{1009}{7 \\sqrt{485}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = -(34/7), (26/7)\nline = Poly(2*x-((17*y)/7)-(13/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -2 & 8 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{4.,0.,1.\\}, \\{4.,1.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, 8, 8]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${1, 4, 3}$ to the plane $2 x-3 y-2 z+2=0$.", - "Output Answer": [ - "$\\frac{14}{\\sqrt{17}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = 1, 4, 3\nplane = Poly(2*x-3*y-2*z+2, x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(plane.get(key, 0))\ncoeffs.append(plane.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -3 & 1 & \\frac{3}{2} \\\\\n -\\frac{5}{2} & -1 & -2 \\\\\n 0 & 1 & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{53}{4} & \\frac{1}{4} & \\frac{223}{8} \\\\\n -\\frac{85}{4} & \\frac{59}{4} & \\frac{161}{8} \\\\\n \\frac{55}{4} & \\frac{1}{4} & \\frac{7}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1, (3/2)],\n [-(5/2), -1, -2],\n [0, 1, -(3/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n 4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 2 \\\\\n -6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [4]])\nb = np.array([\n [-6],\n [-10]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{13}{7}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & 8 \\\\\n -4 & 4 \\\\\n 5 & 4 \\\\\n -7 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 0 & -\\frac{104}{7} \\\\\n \\frac{52}{7} & -\\frac{52}{7} \\\\\n -\\frac{65}{7} & -\\frac{52}{7} \\\\\n 13 & -\\frac{78}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 8],\n [-4, 4],\n [5, 4],\n [-7, 6]])\nprint(a * -(13/7))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -2 & 5 \\\\\n 7 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{14} \\left(7-3 \\sqrt{21}\\right),1\\right\\}, \\left\\{\\frac{1}{14} \\left(7+3 \\sqrt{21}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 5],\n [7, -9]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -\\frac{19}{16} & -\\frac{35}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -\\frac{63}{16} & \\frac{81}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{11}{4} & -\\frac{151}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/16), -(35/8)]])\nb = np.array([\n [-(63/16), (81/16)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{2} \\\\\n -\\frac{27}{20} \\\\\n -\\frac{477}{100} \\\\\n -\\frac{77}{50} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{477}{100}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2)],\n [-(27/20)],\n [-(477/100)],\n [-(77/50)]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{13}{8} \\\\\n \\frac{39}{4} \\\\\n \\frac{27}{4} \\\\\n -\\frac{41}{16} \\\\\n \\frac{9}{4} \\\\\n -\\frac{11}{8} \\\\\n -\\frac{113}{16} \\\\\n -\\frac{7}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{279}{8}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/8)],\n [(39/4)],\n [(27/4)],\n [-(41/16)],\n [(9/4)],\n [-(11/8)],\n [-(113/16)],\n [-(7/2)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -7 & 3 & -1 \\\\\n -4 & -1 & 5 \\\\\n 7 & -5 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, 3, -1],\n [-4, -1, 5],\n [7, -5, -1]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -\\frac{7}{2} & -\\frac{11}{2} & -\\frac{1}{2} \\\\\n 7 & \\frac{11}{2} & \\frac{11}{2} \\\\\n 8 & -\\frac{19}{2} & -\\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-4.285,2.392\\, -9.342 i,2.392\\, +9.342 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(7/2), -(11/2), -(1/2)],\n [7, (11/2), (11/2)],\n [8, -(19/2), -(3/2)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n 1 & -2 & -3 & -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 0 & 3 & -2 \\\\\n 2 & 3 & -2 \\\\\n 3 & 2 & -2 \\\\\n -2 & 3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -7 & -18 & 14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, -2, -3, -3]])\nb = np.array([\n [0, 3, -2],\n [2, 3, -2],\n [3, 2, -2],\n [-2, 3, -2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{9}{2}+\\frac{7 i}{2} & -\\frac{1}{2}+\\frac{5 i}{2} & 2+4 i \\\\\n -2+\\frac{7 i}{2} & 2-3 i & 2-4 i \\\\\n -2+\\frac{7 i}{2} & -\\frac{9}{2}-2 i & -1+\\frac{7 i}{2} \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{765}{2}+65 i & \\frac{305}{2}-\\frac{57 i}{4} & 39-\\frac{613 i}{2} \\\\\n \\frac{321}{8}-\\frac{903 i}{8} & -\\frac{77}{2}+\\frac{625 i}{4} & -45+128 i \\\\\n \\frac{1115}{4}+20 i & \\frac{2207}{8}+106 i & \\frac{575}{4}-\\frac{1799 i}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/2)+((7j)/2), -(1/2)+((5j)/2), 2+4j],\n [-2+((7j)/2), 2-3j, 2-4j],\n [-2+((7j)/2), -(9/2)-2j, -1+((7j)/2)]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 3 & 1 & \\frac{3}{2} \\\\\n \\frac{3}{2} & -\\frac{1}{2} & 2 \\\\\n 2 & \\frac{1}{2} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{27}{2} & \\frac{13}{4} & \\frac{35}{4} \\\\\n \\frac{31}{4} & \\frac{11}{4} & \\frac{17}{4} \\\\\n \\frac{39}{4} & \\frac{5}{2} & \\frac{25}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 1, (3/2)],\n [(3/2), -(1/2), 2],\n [2, (1/2), (3/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{3}{5} & \\frac{8}{5} \\\\\n \\frac{38}{5} & -\\frac{24}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{76} \\left(27-\\sqrt{1945}\\right),1\\right\\}, \\left\\{\\frac{1}{76} \\left(27+\\sqrt{1945}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(3/5), (8/5)],\n [(38/5), -(24/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n -1 & -10 & 1 & -4 \\\\\n 0 & -10 & 8 & -3 \\\\\n -6 & -7 & -1 & -3 \\\\\n -5 & 8 & -5 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, -10, 1, -4],\n [0, -10, 8, -3],\n [-6, -7, -1, -3],\n [-5, 8, -5, 5]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -7 & 2 & 5 & 6 & 5 \\\\\n -9 & 9 & 8 & 2 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & -\\frac{29}{45} & -\\frac{10}{9} & -\\frac{11}{9} \\\\\n 0 & 1 & \\frac{11}{45} & -\\frac{8}{9} & -\\frac{16}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-7, 2, 5, 6, 5],\n [-9, 9, 8, 2, -5]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{1}{2} & \\frac{1}{2} & -2 \\\\\n 2 & -1 & -\\frac{5}{2} \\\\\n -\\frac{3}{2} & -\\frac{3}{2} & -3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{25}{4} & -\\frac{35}{4} & -\\frac{251}{8} \\\\\n \\frac{17}{8} & -\\frac{115}{8} & -\\frac{271}{8} \\\\\n -\\frac{57}{4} & -\\frac{111}{4} & -\\frac{519}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), (1/2), -2],\n [2, -1, -(5/2)],\n [-(3/2), -(3/2), -3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{ccc}\n 10 & -3 & 5 \\\\\n 2 & -9 & -8 \\\\\n 3 & -5 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, -3, 5],\n [2, -9, -8],\n [3, -5, 10]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -4 i & -4-4 i \\\\\n 3 i & -2-5 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -4-12 i & -28+44 i \\\\\n 27-6 i & -9+8 i \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4j, -4-4j],\n [3j, -2-5j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & -3 \\\\\n -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, -3],\n [-1, 1]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n -5 & 10 & -6 & -3 \\\\\n -1 & -1 & 1 & -5 \\\\\n 10 & -6 & 0 & 2 \\\\\n 2 & 10 & -10 & 3 \\\\\n -2 & 3 & -1 & -1 \\\\\n 7 & 0 & 3 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-5, 10, -6, -3],\n [-1, -1, 1, -5],\n [10, -6, 0, 2],\n [2, 10, -10, 3],\n [-2, 3, -1, -1],\n [7, 0, 3, 3]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 2-\\frac{9 i}{2} & \\frac{7}{2}-4 i \\\\\n -2-\\frac{7 i}{2} & 1+3 i \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{149}{4}-\\frac{89 i}{4} & \\frac{9}{2}-\\frac{69 i}{4} \\\\\n -\\frac{45}{4}-\\frac{15 i}{2} & -29+\\frac{7 i}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2-((9j)/2), (7/2)-4j],\n [-2-((7j)/2), 1+3j]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{41}{10} & \\frac{52}{25} & \\frac{209}{25} \\\\\n -\\frac{89}{25} & -\\frac{267}{100} & -\\frac{17}{2} \\\\\n -\\frac{397}{100} & -\\frac{174}{25} & \\frac{677}{100} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+\\frac{534519 x}{10000}+\\frac{277756429}{500000}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(41/10), (52/25), (209/25)],\n [-(89/25), -(267/100), -(17/2)],\n [-(397/100), -(174/25), (677/100)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cc}\n 2 & 5 \\\\\n 1 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [2, 5],\n [1, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{15}{2} & -\\frac{35}{6} & \\frac{20}{3} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{13}{3} & -\\frac{23}{3} & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{71}{6} & \\frac{11}{6} & \\frac{55}{6} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(15/2), -(35/6), (20/3)]])\nb = np.array([\n [(13/3), -(23/3), -(5/2)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 1 & 1 & 8 & -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -8 & 2 & -6 & 7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -7 & 3 & 2 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 1, 8, -6]])\nb = np.array([\n [-8, 2, -6, 7]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n -2 \\\\\n -6 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -4 \\\\\n -8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -8 \\\\\n -26 \\\\\n 14 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [-2],\n [-6]])\nb = np.array([\n [-1],\n [-4],\n [-8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n \\frac{20}{9} & -\\frac{23}{9} & -\\frac{14}{9} \\\\\n \\frac{22}{9} & \\frac{23}{9} & -\\frac{35}{9} \\\\\n -\\frac{19}{9} & -\\frac{38}{9} & \\frac{29}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1989}{2765} & -\\frac{3597}{2765} & -\\frac{483}{395} \\\\\n -\\frac{81}{2765} & -\\frac{942}{2765} & -\\frac{168}{395} \\\\\n \\frac{171}{395} & -\\frac{513}{395} & -\\frac{414}{395} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(20/9), -(23/9), -(14/9)],\n [(22/9), (23/9), -(35/9)],\n [-(19/9), -(38/9), (29/9)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 5 & 4 \\\\\n -7 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-2-\\sqrt{21},\\sqrt{21}-2\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, 4],\n [-7, -9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n 2 & 2 & -6 \\\\\n -4 & -5 & -4 \\\\\n 7 & -6 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$3$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 2, -6],\n [-4, -5, -4],\n [7, -6, -6]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{0,\\frac{5}{3},\\frac{5}{3}\\right\\}, \\left\\{\\frac{8}{3},-\\frac{8}{3},-\\frac{7}{3}\\right\\}, \\left\\{2,\\frac{4}{3},-\\frac{4}{3}\\right\\}}$", - "Output Answer": [ - "${\\left\\{0,\\frac{1}{\\sqrt{2}},\\frac{1}{\\sqrt{2}}\\right\\}, \\left\\{8 \\sqrt{\\frac{2}{129}},-\\frac{1}{\\sqrt{258}},\\frac{1}{\\sqrt{258}}\\right\\}, \\left\\{\\frac{1}{\\sqrt{129}},\\frac{8}{\\sqrt{129}},-\\frac{8}{\\sqrt{129}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, (5/3), (5/3)), ((8/3), -(8/3), -(7/3)), (2, (4/3), -(4/3))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n \\frac{1}{3} & -\\frac{41}{6} & \\frac{25}{6} \\\\\n \\frac{2}{3} & -\\frac{17}{3} & \\frac{31}{6} \\\\\n -\\frac{55}{6} & \\frac{13}{2} & -2 \\\\\n -\\frac{11}{2} & \\frac{19}{3} & -\\frac{23}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -\\frac{55}{6} & -\\frac{37}{6} & -\\frac{25}{6} \\\\\n -\\frac{47}{6} & \\frac{43}{6} & \\frac{7}{2} \\\\\n -\\frac{9}{2} & \\frac{13}{6} & -\\frac{13}{2} \\\\\n \\frac{37}{6} & \\frac{59}{6} & -\\frac{13}{3} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{53}{6} & -13 & 0 \\\\\n -\\frac{43}{6} & \\frac{3}{2} & \\frac{26}{3} \\\\\n -\\frac{41}{3} & \\frac{26}{3} & -\\frac{17}{2} \\\\\n \\frac{2}{3} & \\frac{97}{6} & -12 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/3), -(41/6), (25/6)],\n [(2/3), -(17/3), (31/6)],\n [-(55/6), (13/2), -2],\n [-(11/2), (19/3), -(23/3)]])\nb = np.array([\n [-(55/6), -(37/6), -(25/6)],\n [-(47/6), (43/6), (7/2)],\n [-(9/2), (13/6), -(13/2)],\n [(37/6), (59/6), -(13/3)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 8 & 2 \\\\\n -6 & 10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-18 x+92$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 2],\n [-6, 10]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -\\frac{43}{5} & -\\frac{32}{5} & -5 \\\\\n \\frac{23}{5} & \\frac{21}{5} & \\frac{27}{5} \\\\\n \\frac{43}{5} & 8 & \\frac{1}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3-\\frac{21 x^2}{5}+\\frac{194 x}{25}+\\frac{8696}{125}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(43/5), -(32/5), -5],\n [(23/5), (21/5), (27/5)],\n [(43/5), 8, (1/5)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 1 & 2 & 0 & 0 & 2 \\\\\n -1 & 0 & 0 & 0 & -1 \\\\\n 0 & -1 & -2 & 3 & 1 \\\\\n 0 & 1 & 1 & -2 & 2 \\\\\n 2 & 3 & 0 & 2 & -2 \\\\\n -3 & -3 & 0 & -2 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -1.86 \\\\\n -0.63 \\\\\n -0.35 \\\\\n 2.55 \\\\\n 2.35 \\\\\n -1.54 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -1.243 \\\\\n -0.568 \\\\\n 6.547 \\\\\n 3.473 \\\\\n 0.836 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, 0, 0, 2],\n [-1, 0, 0, 0, -1],\n [0, -1, -2, 3, 1],\n [0, 1, 1, -2, 2],\n [2, 3, 0, 2, -2],\n [-3, -3, 0, -2, -1]])\nb = np.array([\n [-1.86],\n [-0.63],\n [-0.35],\n [2.55],\n [2.35],\n [-1.54]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -\\frac{19}{10} & 5 & -\\frac{14}{5} \\\\\n -\\frac{1}{5} & 2 & -\\frac{23}{5} \\\\\n \\frac{17}{5} & -\\frac{11}{5} & -\\frac{1}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{10151}{250}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(19/10), 5, -(14/5)],\n [-(1/5), 2, -(23/5)],\n [(17/5), -(11/5), -(1/5)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{64}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -9 & -3 & -1 & 9 \\\\\n -7 & 1 & -4 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{27}{64} & -\\frac{9}{64} & -\\frac{3}{64} & \\frac{27}{64} \\\\\n -\\frac{21}{64} & \\frac{3}{64} & -\\frac{3}{16} & -\\frac{21}{64} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, -3, -1, 9],\n [-7, 1, -4, -7]])\nprint(a * (3/64))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cccc}\n 2 & 5 & -10 & -5 \\\\\n -8 & 2 & 2 & -10 \\\\\n 6 & 0 & -5 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{5.,86.,34.,20.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [2, 5, -10, -5],\n [-8, 2, 2, -10],\n [6, 0, -5, 7]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{4} & -\\frac{13}{4} \\\\\n -\\frac{17}{2} & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{8} \\left(27-\\sqrt{3793}\\right),\\frac{1}{8} \\left(27+\\sqrt{3793}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(9/4), -(13/4)],\n [-(17/2), 9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n 8 & 3 \\\\\n 4 & -2 \\\\\n -8 & -4 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -8 & -2 \\\\\n -8 & -8 \\\\\n -6 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 16 & 5 \\\\\n 12 & 6 \\\\\n -2 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, 3],\n [4, -2],\n [-8, -4]])\nb = np.array([\n [-8, -2],\n [-8, -8],\n [-6, 1]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n -2 & 3 & 5 \\\\\n -4 & 5 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & -7 \\\\\n -4 & 9 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & 2 & -2 \\\\\n -8 & 14 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, 3, 5],\n [-4, 5, 2]])\nb = np.array([\n [1, -1, -7],\n [-4, 9, 2]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -2 & 5 & -7 & 1 & 9 \\\\\n -5 & -10 & 5 & -3 & -3 \\\\\n -6 & -6 & 0 & -10 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.,1.,1.,0.,0.\\}, \\{106.,-50.,0.,-69.,59.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-2, 5, -7, 1, 9],\n [-5, -10, 5, -3, -3],\n [-6, -6, 0, -10, -6]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cc}\n 1 & 0 \\\\\n 3 & -3 \\\\\n 2 & -1 \\\\\n -1 & 1 \\\\\n -1 & -1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.46 \\\\\n -0.18 \\\\\n -1.66 \\\\\n 0.23 \\\\\n 0.99 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.22 \\\\\n -0.081 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 0],\n [3, -3],\n [2, -1],\n [-1, 1],\n [-1, -1]])\nb = np.array([\n [2.46],\n [-0.18],\n [-1.66],\n [0.23],\n [0.99]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n \\frac{27}{4} & -\\frac{3}{4} & \\frac{1}{4} \\\\\n -9 & -6 & -\\frac{19}{2} \\\\\n \\frac{15}{2} & \\frac{25}{4} & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-2.381-6.469 i,-2.381+6.469 i,7.511\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(27/4), -(3/4), (1/4)],\n [-9, -6, -(19/2)],\n [(15/2), (25/4), 2]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -2 & \\frac{42}{5} & \\frac{24}{5} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 2 & -\\frac{6}{5} & \\frac{7}{5} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -4 & \\frac{48}{5} & \\frac{17}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, (42/5), (24/5)]])\nb = np.array([\n [2, -(6/5), (7/5)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 1 \\\\\n -1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{3}{\\sqrt{13}} \\\\\n \\frac{1}{\\sqrt{13}} \\\\\n -\\frac{1}{\\sqrt{13}} \\\\\n 0 \\\\\n -\\frac{1}{\\sqrt{13}} \\\\\n -\\frac{1}{\\sqrt{13}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [1],\n [-1],\n [0],\n [-1],\n [-1]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 1 \\\\\n 3 & 0 & 0 \\\\\n -2 & 1 & -2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 4 & -1 & 1 \\\\\n -3 & 3 & -3 \\\\\n -5 & 2 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 0, 1],\n [3, 0, 0],\n [-2, 1, -2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 1 \\\\\n -1 \\\\\n 3 \\\\\n 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n \\frac{1}{\\sqrt{15}} \\\\\n -\\frac{1}{\\sqrt{15}} \\\\\n \\sqrt{\\frac{3}{5}} \\\\\n \\frac{2}{\\sqrt{15}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [1],\n [-1],\n [3],\n [2]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,2,5\\}, \\{-1,-5,-1\\}, \\{-1,1,0\\}}$.", - "Output Answer": [ - "$29 x+2 y-12 z+27=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, 2, 5],\n [-1, -5, -1],\n [-1, 1, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -7 \\\\\n 7 \\\\\n -\\frac{15}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n -\\frac{3}{2} \\\\\n \\frac{9}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{81}{4} \\\\\n 9 \\\\\n -\\frac{21}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7],\n [7],\n [-(15/2)]])\nb = np.array([\n [3],\n [-(3/2)],\n [(9/2)]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -5 & -2 \\\\\n -5 & -10 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+15 x+40$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -2],\n [-5, -10]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{2} & 0 & \\frac{3}{2} \\\\\n -2 & -\\frac{1}{2} & -2 \\\\\n \\frac{3}{2} & \\frac{3}{2} & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{251}{8} & -\\frac{27}{4} & \\frac{33}{4} \\\\\n -5 & -\\frac{13}{8} & 10 \\\\\n \\frac{69}{4} & -\\frac{3}{4} & -\\frac{69}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), 0, (3/2)],\n [-2, -(1/2), -2],\n [(3/2), (3/2), 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 2 & -1 & 5 \\\\\n -1 & -5 & -4 \\\\\n -5 & -3 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-99$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1, 5],\n [-1, -5, -4],\n [-5, -3, -5]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n -\\frac{1}{5} \\\\\n -\\frac{7}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{7}{5} & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{21}{5} & 0 \\\\\n \\frac{7}{25} & 0 \\\\\n \\frac{49}{25} & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [-(1/5)],\n [-(7/5)]])\nb = np.array([\n [-(7/5), 0]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{3} & \\frac{5}{3} & \\frac{17}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/3), (5/3), (17/3)]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 1 & 3 & 4 & 9 & 5 & 9 & -6 \\\\\n 0 & -10 & 8 & -2 & 4 & -7 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & \\frac{32}{5} & \\frac{42}{5} & \\frac{31}{5} & \\frac{69}{10} & -\\frac{24}{5} \\\\\n 0 & 1 & -\\frac{4}{5} & \\frac{1}{5} & -\\frac{2}{5} & \\frac{7}{10} & -\\frac{2}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, 3, 4, 9, 5, 9, -6],\n [0, -10, 8, -2, 4, -7, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -3 & 1 & 2 \\\\\n 0 & 0 & -2 \\\\\n 2 & -2 & -1 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -59 & 33 & 50 \\\\\n 16 & -8 & -18 \\\\\n 42 & -26 & -33 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, 1, 2],\n [0, 0, -2],\n [2, -2, -1]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n 3 & -3 & 2 & -3 \\\\\n -2 & 1 & 1 & 3 \\\\\n -1 & -3 & 2 & -1 \\\\\n -3 & 2 & -1 & 2 \\\\\n -2 & 1 & 1 & -1 \\\\\n 3 & -2 & -1 & 2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.25 \\\\\n -2.4 \\\\\n 0.44 \\\\\n -2.02 \\\\\n 1.82 \\\\\n -0.74 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.148 \\\\\n 0.126 \\\\\n 0.126 \\\\\n -0.731 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -3, 2, -3],\n [-2, 1, 1, 3],\n [-1, -3, 2, -1],\n [-3, 2, -1, 2],\n [-2, 1, 1, -1],\n [3, -2, -1, 2]])\nb = np.array([\n [2.25],\n [-2.4],\n [0.44],\n [-2.02],\n [1.82],\n [-0.74]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -4 & 5 \\\\\n -4 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{1}{8} & -\\frac{1}{8} \\\\\n \\frac{1}{10} & -\\frac{1}{10} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 5],\n [-4, -5]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -10 & -7 & -5 \\\\\n -7 & -8 & -5 \\\\\n 5 & 0 & -4 \\\\\n 4 & 6 & -1 \\\\\n 1 & 1 & 2 \\\\\n -2 & -2 & 1 \\\\\n 1 & 7 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, -7, -5],\n [-7, -8, -5],\n [5, 0, -4],\n [4, 6, -1],\n [1, 1, 2],\n [-2, -2, 1],\n [1, 7, 8]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\left\\{-\\frac{3}{\\sqrt{2}},-\\sqrt{2},-\\frac{1}{\\sqrt{2}}\\right\\}, \\left\\{-\\sqrt{2},-2 \\sqrt{2},0\\right\\}, \\left\\{\\sqrt{2},0,-\\sqrt{2}\\right\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{3}{\\sqrt{14}},-\\sqrt{\\frac{2}{7}},-\\frac{1}{\\sqrt{14}}\\right\\}, \\left\\{\\frac{\\frac{3}{\\sqrt{2}}-\\sqrt{2}}{\\sqrt{\\frac{5}{2}+\\left(\\frac{3}{\\sqrt{2}}-\\sqrt{2}\\right)^2}},-\\sqrt{\\frac{2}{\\frac{5}{2}+\\left(\\frac{3}{\\sqrt{2}}-\\sqrt{2}\\right)^2}},\\frac{1}{\\sqrt{2 \\left(\\frac{5}{2}+\\left(\\frac{3}{\\sqrt{2}}-\\sqrt{2}\\right)^2\\right)}}\\right\\}, \\left\\{\\frac{2}{\\sqrt{21}},-\\frac{1}{\\sqrt{21}},-\\frac{4}{\\sqrt{21}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\nmatrix = np.column_stack(((-(3/(math.sqrt(2))), -math.sqrt(2), -(1/(math.sqrt(2)))), (-math.sqrt(2), -2*math.sqrt(2), 0), (math.sqrt(2), 0, -math.sqrt(2))))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{33}{5} & \\frac{38}{5} \\\\\n 10 & -\\frac{13}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{50} \\left(23-\\sqrt{2429}\\right),1\\right\\}, \\left\\{\\frac{1}{50} \\left(23+\\sqrt{2429}\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(33/5), (38/5)],\n [10, -(13/5)]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -\\frac{1}{\\sqrt{2}} \\\\\n -\\frac{1}{\\sqrt{2}} \\\\\n 4 \\sqrt{2} \\\\\n -5 \\sqrt{2} \\\\\n 4 \\sqrt{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 3 \\sqrt{2} \\\\\n -\\frac{13}{\\sqrt{2}} \\\\\n \\frac{3}{\\sqrt{2}} \\\\\n -\\sqrt{2} \\\\\n -\\frac{7}{\\sqrt{2}} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{5}{2}$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-(1/(math.sqrt(2)))],\n [-(1/(math.sqrt(2)))],\n [4*math.sqrt(2)],\n [-5*math.sqrt(2)],\n [4*math.sqrt(2)]])\nb = np.array([\n [3*math.sqrt(2)],\n [-(13/(math.sqrt(2)))],\n [(3/(math.sqrt(2)))],\n [-math.sqrt(2)],\n [-(7/(math.sqrt(2)))]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{20}{9} & -\\frac{31}{9} \\\\\n \\frac{40}{9} & \\frac{56}{9} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-\\frac{76 x}{9}+\\frac{2360}{81}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(20/9), -(31/9)],\n [(40/9), (56/9)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n -1 & 1 & 2 & 0 & -1 \\\\\n -3 & 0 & -3 & 2 & -1 \\\\\n -2 & 0 & 2 & -3 & 2 \\\\\n 0 & 0 & 2 & 2 & -1 \\\\\n 1 & 0 & 0 & -1 & 1 \\\\\n 3 & -3 & -2 & 3 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n -2.49 \\\\\n 2.09 \\\\\n -1.72 \\\\\n -2.02 \\\\\n 1.87 \\\\\n -0.39 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.463 \\\\\n 4.031 \\\\\n -1.16 \\\\\n 1.645 \\\\\n 3.227 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, 2, 0, -1],\n [-3, 0, -3, 2, -1],\n [-2, 0, 2, -3, 2],\n [0, 0, 2, 2, -1],\n [1, 0, 0, -1, 1],\n [3, -3, -2, 3, 1]])\nb = np.array([\n [-2.49],\n [2.09],\n [-1.72],\n [-2.02],\n [1.87],\n [-0.39]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{ccccc}\n 1 & 2 & -2 & 3 & 2 \\\\\n 1 & 2 & 3 & -2 & -2 \\\\\n 3 & -1 & -3 & -1 & 2 \\\\\n -3 & -2 & -3 & 3 & -1 \\\\\n 0 & -1 & -3 & -2 & 1 \\\\\n 0 & -1 & -1 & -3 & 1 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.09 \\\\\n 2.42 \\\\\n 0.16 \\\\\n -2.18 \\\\\n 1.22 \\\\\n 1.49 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -0.295 \\\\\n 1.518 \\\\\n -0.59 \\\\\n -0.66 \\\\\n 0.014 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1, 2, -2, 3, 2],\n [1, 2, 3, -2, -2],\n [3, -1, -3, -1, 2],\n [-3, -2, -3, 3, -1],\n [0, -1, -3, -2, 1],\n [0, -1, -1, -3, 1]])\nb = np.array([\n [2.09],\n [2.42],\n [0.16],\n [-2.18],\n [1.22],\n [1.49]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -6 & -2 & 8 & -10 & 8 & 1 \\\\\n -3 & -4 & 2 & 6 & -1 & 9 \\\\\n 2 & 3 & 6 & 10 & 6 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & \\frac{199}{32} & -\\frac{27}{32} & \\frac{175}{64} \\\\\n 0 & 1 & 0 & -\\frac{163}{32} & \\frac{39}{32} & -\\frac{235}{64} \\\\\n 0 & 0 & 1 & \\frac{137}{64} & \\frac{43}{64} & \\frac{161}{128} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-6, -2, 8, -10, 8, 1],\n [-3, -4, 2, 6, -1, 9],\n [2, 3, 6, 10, 6, 2]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{44}{7} & \\frac{59}{7} \\\\\n \\frac{18}{7} & \\frac{25}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2+\\frac{19 x}{7}-\\frac{2162}{49}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(44/7), (59/7)],\n [(18/7), (25/7)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{3}{2} & \\frac{5}{2} \\\\\n -\\frac{1}{2} & -\\frac{5}{2} \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 1 & -10 \\\\\n 2 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(3/2), (5/2)],\n [-(1/2), -(5/2)]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n -6 & 6 & 2 \\\\\n 10 & -8 & -6 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n 8 & -4 & 2 \\\\\n 6 & 8 & -6 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -14 & 10 & 0 \\\\\n 4 & -16 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6, 6, 2],\n [10, -8, -6]])\nb = np.array([\n [8, -4, 2],\n [6, 8, -6]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cc}\n -9 & 8 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cc}\n -7 & 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -2 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-9, 8]])\nb = np.array([\n [-7, 1]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{32}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 4 & -5 & 1 & -4 \\\\\n 5 & -8 & -8 & 10 \\\\\n -1 & 4 & 6 & 4 \\\\\n 6 & 3 & 5 & -7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{7}{8} & \\frac{35}{32} & -\\frac{7}{32} & \\frac{7}{8} \\\\\n -\\frac{35}{32} & \\frac{7}{4} & \\frac{7}{4} & -\\frac{35}{16} \\\\\n \\frac{7}{32} & -\\frac{7}{8} & -\\frac{21}{16} & -\\frac{7}{8} \\\\\n -\\frac{21}{16} & -\\frac{21}{32} & -\\frac{35}{32} & \\frac{49}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, -5, 1, -4],\n [5, -8, -8, 10],\n [-1, 4, 6, 4],\n [6, 3, 5, -7]])\nprint(a * -(7/32))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n 0 & 0 \\\\\n -5 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0],\n [-5, 0]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -6 \\\\\n 4 \\\\\n -7 \\\\\n 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$7$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-6],\n [4],\n [-7],\n [3]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -7.96 \\\\\n 9.71 \\\\\n -2.23 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2.06 \\\\\n 7.95 \\\\\n -5.31 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$6.88433$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-7.96],\n [9.71],\n [-2.23]])\nb = np.array([\n [-2.06],\n [7.95],\n [-5.31]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the rank of\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n -4 \\\\\n 1 \\\\\n -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$1$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [-4],\n [1],\n [-5]])\nprint(np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 9 & 7 & -10 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n -9 & 5 & -9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 12 & -19 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [9, 7, -10]])\nb = np.array([\n [-9, 5, -9]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccc}\n -2 & 7 & -3 & 7 & -9 \\\\\n -6 & 4 & -2 & 10 & 4 \\\\\n -2 & -9 & 6 & -7 & 9 \\\\\n 4 & -3 & -6 & -5 & 0 \\\\\n -9 & -2 & -8 & -5 & 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccc}\n 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-2, 7, -3, 7, -9],\n [-6, 4, -2, 10, 4],\n [-2, -9, 6, -7, 9],\n [4, -3, -6, -5, 0],\n [-9, -2, -8, -5, 9]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -3 & -\\frac{11}{9} \\\\\n \\frac{29}{9} & -\\frac{40}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{360}{1399} & \\frac{99}{1399} \\\\\n -\\frac{261}{1399} & -\\frac{243}{1399} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -(11/9)],\n [(29/9), -(40/9)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{17}{32}, \\frac{137}{32}}$ to the line $-\\frac{159 x}{32}+5 y+\\frac{139}{32}=0$.", - "Output Answer": [ - "$\\frac{23665}{32 \\sqrt{50881}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (17/32), (137/32)\nline = Poly(-((159*x)/32)+5*y+(139/32), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{2}{9} & -\\frac{1}{3} & -\\frac{19}{9} & \\frac{4}{3} & -\\frac{1}{9} \\\\\n \\frac{2}{9} & \\frac{2}{9} & -\\frac{23}{9} & 0 & -\\frac{5}{3} \\\\\n -\\frac{25}{9} & \\frac{1}{3} & 0 & \\frac{1}{3} & -\\frac{2}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{9} \\\\\n \\frac{4}{3} \\\\\n -\\frac{14}{9} \\\\\n 0 \\\\\n -\\frac{10}{9} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{214}{81} \\\\\n \\frac{470}{81} \\\\\n \\frac{127}{27} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(2/9), -(1/3), -(19/9), (4/3), -(1/9)],\n [(2/9), (2/9), -(23/9), 0, -(5/3)],\n [-(25/9), (1/3), 0, (1/3), -(2/9)]])\nb = np.array([\n [-(13/9)],\n [(4/3)],\n [-(14/9)],\n [0],\n [-(10/9)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & 0 & -3 \\\\\n -2 & -2 & 2 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 3 \\\\\n 6 & 4 & 2 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 0, -3],\n [-2, -2, 2],\n [0, 0, 0]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -8 & 3 \\\\\n -\\frac{11}{2} & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-8-i \\sqrt{2}\\right),\\frac{1}{2} \\left(-8+i \\sqrt{2}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 3],\n [-(11/2), 0]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n -5 & -9 & 2 & 4 \\\\\n -9 & -5 & -6 & 3 \\\\\n 8 & -6 & -3 & 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -2 & 10 & 0 & -2 \\\\\n -10 & 1 & -4 & 7 \\\\\n -2 & -5 & -1 & -7 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -7 & 1 & 2 & 2 \\\\\n -19 & -4 & -10 & 10 \\\\\n 6 & -11 & -4 & -7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -9, 2, 4],\n [-9, -5, -6, 3],\n [8, -6, -3, 0]])\nb = np.array([\n [-2, 10, 0, -2],\n [-10, 1, -4, 7],\n [-2, -5, -1, -7]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{3,-2,3\\}, \\{-3,0,4\\}, \\{-1,3,0\\}}$.", - "Output Answer": [ - "$x+2 (y+z)-5=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [3, -2, 3],\n [-3, 0, 4],\n [-1, 3, 0]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -9 & 10 & -8 \\\\\n 10 & 8 & -2 \\\\\n 4 & 3 & -6 \\\\\n -6 & 10 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-9, 10, -8],\n [10, 8, -2],\n [4, 3, -6],\n [-6, 10, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 3 \\\\\n 5 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 10 \\\\\n -2 \\\\\n 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 12 \\\\\n 4 \\\\\n -56 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3],\n [5],\n [1]])\nb = np.array([\n [10],\n [-2],\n [2]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccccc}\n -10 & -8 & 9 & -10 & 8 & -9 \\\\\n 3 & 5 & 8 & -5 & -10 & -2 \\\\\n 4 & 4 & 6 & -7 & -4 & 10 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccccc}\n 1 & 0 & 0 & -\\frac{363}{164} & \\frac{105}{41} & \\frac{310}{41} \\\\\n 0 & 1 & 0 & \\frac{409}{164} & -\\frac{161}{41} & -\\frac{284}{41} \\\\\n 0 & 0 & 1 & -\\frac{111}{82} & \\frac{10}{41} & \\frac{51}{41} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, -8, 9, -10, 8, -9],\n [3, 5, 8, -5, -10, -2],\n [4, 4, 6, -7, -4, 10]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -1 & -5 & 2 & -2 & 1 \\\\\n 5 & 10 & 2 & 3 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-10.,4.,5.,0.,0.\\}, \\{5.,-7.,0.,15.,0.\\}, \\{5.,2.,0.,0.,15.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-1, -5, 2, -2, 1],\n [5, 10, 2, 3, -3]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 4 & 0 & -3 \\\\\n 1 & 3 & -4 \\\\\n 4 & 3 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{2}{11} & -\\frac{1}{11} & \\frac{1}{11} \\\\\n -\\frac{2}{11} & \\frac{20}{99} & \\frac{13}{99} \\\\\n -\\frac{1}{11} & -\\frac{4}{33} & \\frac{4}{33} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 0, -3],\n [1, 3, -4],\n [4, 3, 2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-2,2,0\\}, \\{-2,1,0\\}, \\{0,-1,1\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{2}},\\frac{1}{\\sqrt{2}},0\\right\\}, \\left\\{-\\frac{1}{\\sqrt{2}},-\\frac{1}{\\sqrt{2}},0\\right\\}, \\{0,0,1\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-2, 2, 0), (-2, 1, 0), (0, -1, 1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 5 \\\\\n 6 \\\\\n 2 \\\\\n 4 \\\\\n -6 \\\\\n -5 \\\\\n -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{223}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5],\n [6],\n [2],\n [4],\n [-6],\n [-5],\n [-9]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 6 & 4 & 0 & 3 \\\\\n -9 & 9 & 2 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & -\\frac{4}{45} & \\frac{11}{90} \\\\\n 0 & 1 & \\frac{2}{15} & \\frac{17}{30} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [6, 4, 0, 3],\n [-9, 9, 2, 4]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 10 & 5 & 5 \\\\\n -1 & -9 & -2 \\\\\n -7 & -2 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-8.785,-3.615,7.4\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [10, 5, 5],\n [-1, -9, -2],\n [-7, -2, -6]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 3 & 2 & -3 \\\\\n 1 & -2 & 2 \\\\\n 0 & -1 & 0 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 11 & 5 & -5 \\\\\n 1 & 4 & -7 \\\\\n -1 & 2 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2, -3],\n [1, -2, 2],\n [0, -1, 0]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{1,-4,1\\}, \\{-1,2,4\\}, \\{-3,-2,-1\\}}$.", - "Output Answer": [ - "$9 x+8 y-10 z+33=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [1, -4, 1],\n [-1, 2, 4],\n [-3, -2, -1]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n -10 & 3 & -1 \\\\\n -4 & -10 & -4 \\\\\n -6 & -8 & 7 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [-10, 3, -1],\n [-4, -10, -4],\n [-6, -8, 7]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n 3 & 0 \\\\\n 1 & -3 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 27 & 0 \\\\\n 9 & -27 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 0],\n [1, -3]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_2$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{6}{5} \\\\\n \\frac{3}{5} \\\\\n \\frac{16}{5} \\\\\n -4 \\\\\n -\\frac{17}{5} \\\\\n \\frac{17}{5} \\\\\n \\frac{14}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{59}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(6/5)],\n [(3/5)],\n [(16/5)],\n [-4],\n [-(17/5)],\n [(17/5)],\n [(14/5)]])\nprint(np.linalg.norm(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -4 & 0 \\\\\n 5 & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{4}{41} & \\frac{5}{41} \\\\\n 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 0],\n [5, 0]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccc}\n 3 & -9 & -3 \\\\\n -8 & -5 & 8 \\\\\n -5 & 8 & -10 \\\\\n -2 & -1 & -6 \\\\\n 8 & -2 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 1 & 0 & 0 \\\\\n 0 & 1 & 0 \\\\\n 0 & 0 & 1 \\\\\n 0 & 0 & 0 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [3, -9, -3],\n [-8, -5, 8],\n [-5, 8, -10],\n [-2, -1, -6],\n [8, -2, 5]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n -\\frac{13}{3} & 4 \\\\\n \\frac{5}{3} & \\frac{3}{2} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{79}{6}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/3), 4],\n [(5/3), (3/2)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{cc}\n 1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-1.,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [1, 1]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the least squares vector given the matrix\n$\\left(\n\\begin{array}{cccc}\n -1 & -2 & -1 & -1 \\\\\n 0 & 1 & 1 & -3 \\\\\n 3 & 1 & 3 & 2 \\\\\n 0 & 3 & 2 & -3 \\\\\n 1 & -1 & -3 & -2 \\\\\n\\end{array}\n\\right)$ and the vector\n$\\left(\n\\begin{array}{c}\n 2.53 \\\\\n -1.24 \\\\\n 2.06 \\\\\n -0.02 \\\\\n -0.24 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 0.327 \\\\\n -1.172 \\\\\n 0.804 \\\\\n -0.223 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, -2, -1, -1],\n [0, 1, 1, -3],\n [3, 1, 3, 2],\n [0, 3, 2, -3],\n [1, -1, -3, -2]])\nb = np.array([\n [2.53],\n [-1.24],\n [2.06],\n [-0.02],\n [-0.24]])\nlstsq, *_ = np.linalg.lstsq(a, b)\nprint(lstsq)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{18}{7}, \\frac{5}{7}}$ to the line $2 x-\\frac{34}{7}=0$.", - "Output Answer": [ - "$\\frac{1}{7}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (18/7), (5/7)\nline = Poly(2*x-(34/7), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{ccc}\n 3 & 4 & 3 \\\\\n 1 & -7 & 0 \\\\\n -4 & 8 & -7 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 6 & 3 & 0 \\\\\n -6 & -2 & 2 \\\\\n -9 & -1 & -4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 9 & 7 & 3 \\\\\n -5 & -9 & 2 \\\\\n -13 & 7 & -11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 4, 3],\n [1, -7, 0],\n [-4, 8, -7]])\nb = np.array([\n [6, 3, 0],\n [-6, -2, 2],\n [-9, -1, -4]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 1 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [1],\n [-4]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n \\frac{7}{4} & \\frac{9}{4} & \\frac{5}{2} & -\\frac{7}{4} & -2 \\\\\n \\frac{5}{4} & \\frac{3}{2} & \\frac{11}{4} & -\\frac{3}{2} & -1 \\\\\n 2 & -\\frac{5}{2} & -\\frac{1}{4} & -1 & \\frac{5}{2} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -1 & \\frac{9}{4} \\\\\n \\frac{3}{2} & \\frac{3}{2} \\\\\n -\\frac{5}{4} & \\frac{7}{4} \\\\\n \\frac{5}{4} & \\frac{3}{2} \\\\\n -\\frac{7}{4} & \\frac{1}{4} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{3}{16} & \\frac{137}{16} \\\\\n -\\frac{41}{16} & \\frac{59}{8} \\\\\n -\\frac{177}{16} & -\\frac{9}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(7/4), (9/4), (5/2), -(7/4), -2],\n [(5/4), (3/2), (11/4), -(3/2), -1],\n [2, -(5/2), -(1/4), -1, (5/2)]])\nb = np.array([\n [-1, (9/4)],\n [(3/2), (3/2)],\n [-(5/4), (7/4)],\n [(5/4), (3/2)],\n [-(7/4), (1/4)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n -\\frac{1}{2} & \\frac{3}{2} & -\\frac{7}{4} & -\\frac{7}{4} & -1 \\\\\n \\frac{3}{4} & -\\frac{1}{2} & 3 & \\frac{1}{2} & -\\frac{11}{4} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n -\\frac{9}{4} & -\\frac{3}{4} \\\\\n -\\frac{7}{4} & -\\frac{5}{4} \\\\\n 0 & \\frac{11}{4} \\\\\n -3 & \\frac{1}{4} \\\\\n 0 & 2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{15}{4} & -\\frac{35}{4} \\\\\n -\\frac{37}{16} & \\frac{47}{16} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(1/2), (3/2), -(7/4), -(7/4), -1],\n [(3/4), -(1/2), 3, (1/2), -(11/4)]])\nb = np.array([\n [-(9/4), -(3/4)],\n [-(7/4), -(5/4)],\n [0, (11/4)],\n [-3, (1/4)],\n [0, 2]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{2}{3}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n -5 & -8 & 3 & 3 \\\\\n -1 & -3 & -9 & -6 \\\\\n 4 & -5 & -1 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{10}{3} & \\frac{16}{3} & -2 & -2 \\\\\n \\frac{2}{3} & 2 & 6 & 4 \\\\\n -\\frac{8}{3} & \\frac{10}{3} & \\frac{2}{3} & -\\frac{2}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -8, 3, 3],\n [-1, -3, -9, -6],\n [4, -5, -1, 1]])\nprint(a * -(2/3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{12}{7} \\\\\n \\frac{12}{7} \\\\\n \\frac{16}{7} \\\\\n -\\frac{19}{7} \\\\\n -\\frac{9}{7} \\\\\n \\frac{13}{7} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -4 \\sqrt{\\frac{3}{385}} \\\\\n 4 \\sqrt{\\frac{3}{385}} \\\\\n \\frac{16}{\\sqrt{1155}} \\\\\n -\\frac{19}{\\sqrt{1155}} \\\\\n -3 \\sqrt{\\frac{3}{385}} \\\\\n \\frac{13}{\\sqrt{1155}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(12/7)],\n [(12/7)],\n [(16/7)],\n [-(19/7)],\n [-(9/7)],\n [(13/7)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nNormalize the following vector:\n$\\left(\n\\begin{array}{c}\n \\frac{11}{16} \\\\\n \\frac{19}{8} \\\\\n \\frac{1}{8} \\\\\n \\frac{11}{16} \\\\\n -\\frac{23}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\sqrt{\\frac{11}{346}} \\\\\n 19 \\sqrt{\\frac{2}{1903}} \\\\\n \\sqrt{\\frac{2}{1903}} \\\\\n \\sqrt{\\frac{11}{346}} \\\\\n -23 \\sqrt{\\frac{2}{1903}} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/16)],\n [(19/8)],\n [(1/8)],\n [(11/16)],\n [-(23/8)]])\nprint(a / np.linalg.norm(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the nullity of\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1],\n [9]])\nprint(len(a[0]) - np.linalg.matrix_rank(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cc}\n -\\frac{55}{8} & -\\frac{151}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cc}\n \\frac{23}{4} & -\\frac{79}{16} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{9}{8} & -\\frac{115}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(55/8), -(151/16)]])\nb = np.array([\n [(23/4), -(79/16)]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance from the point ${\\frac{11}{3}, \\frac{1}{3}}$ to the line $-\\frac{11 x}{3}-4 y-\\frac{10}{3}=0$.", - "Output Answer": [ - "$\\frac{163}{3 \\sqrt{265}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\nfrom sympy.abc import x, y, z\n\npoint = (11/3), (1/3)\nline = Poly(-((11*x)/3)-4*y-(10/3), x, y, z).as_dict()\ncoeffs = list()\nfor i in range(len(point)):\n key = tuple(1 if j == i else 0 for j in range(len(point)))\n coeffs.append(line.get(key, 0))\ncoeffs.append(line.get((0,0,0),0))\ncoeffs = list(map(float, coeffs))\nprint(abs(np.dot(coeffs, (*point, 1))) / np.linalg.norm(coeffs[:-1]))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 3 e \\\\\n 0 \\\\\n -3 e \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -e \\\\\n 3 e \\\\\n 3 e \\\\\n 3 e \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$0$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [0],\n [3*math.e],\n [0],\n [-3*math.e]])\nb = np.array([\n [-math.e],\n [3*math.e],\n [3*math.e],\n [3*math.e]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n -\\frac{24}{5} & 5 \\\\\n -\\frac{23}{5} & -\\frac{17}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{85}{983} & -\\frac{125}{983} \\\\\n \\frac{115}{983} & -\\frac{120}{983} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(24/5), 5],\n [-(23/5), -(17/5)]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -\\frac{13}{5} \\\\\n -\\frac{13}{5} \\\\\n -\\frac{12}{5} \\\\\n \\frac{1}{5} \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n -\\frac{2}{5} \\\\\n \\frac{12}{5} \\\\\n \\frac{2}{5} \\\\\n -\\frac{7}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{322}{1005},-\\frac{644}{335},-\\frac{322}{1005},\\frac{1127}{1005}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(13/5)],\n [-(13/5)],\n [-(12/5)],\n [(1/5)]]).squeeze()\nb = np.array([\n [-(2/5)],\n [(12/5)],\n [(2/5)],\n [-(7/5)]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{-1,-1,3\\}, \\{3,-3,3\\}, \\{-1,0,-1\\}}$", - "Output Answer": [ - "${\\left\\{-\\frac{1}{\\sqrt{11}},-\\frac{1}{\\sqrt{11}},\\frac{3}{\\sqrt{11}}\\right\\}, \\left\\{\\frac{7}{\\sqrt{66}},-2 \\sqrt{\\frac{2}{33}},\\frac{1}{\\sqrt{66}}\\right\\}, \\left\\{-\\frac{1}{\\sqrt{6}},-\\sqrt{\\frac{2}{3}},-\\frac{1}{\\sqrt{6}}\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((-1, -1, 3), (3, -3, 3), (-1, 0, -1)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n -4 & 0 & -1 \\\\\n 4 & 0 & 0 \\\\\n 3 & -4 & 4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$16$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4, 0, -1],\n [4, 0, 0],\n [3, -4, 4]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{ccc}\n 5 & -3 & 3 \\\\\n -1 & 4 & 2 \\\\\n 1 & -5 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-4$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [5, -3, 3],\n [-1, 4, 2],\n [1, -5, -3]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -3 & -1 \\\\\n 3 & 2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -15 & -4 \\\\\n 12 & 5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -1],\n [3, 2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -5 & 4 \\\\\n 10 & 3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{5} \\left(-2-\\sqrt{14}\\right),1\\right\\}, \\left\\{\\frac{1}{5} \\left(\\sqrt{14}-2\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 4],\n [10, 3]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{c}\n -\\frac{27}{7} \\\\\n \\frac{17}{7} \\\\\n -\\frac{69}{7} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{c}\n \\frac{17}{7} \\\\\n \\frac{29}{7} \\\\\n \\frac{69}{7} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{44}{7} \\\\\n -\\frac{12}{7} \\\\\n -\\frac{138}{7} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(27/7)],\n [(17/7)],\n [-(69/7)]])\nb = np.array([\n [(17/7)],\n [(29/7)],\n [(69/7)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{cc}\n -\\frac{5}{2} & -\\frac{5}{2} \\\\\n \\frac{1}{2} & 0 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -\\frac{75}{8} & -\\frac{25}{2} \\\\\n \\frac{5}{2} & \\frac{25}{8} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(5/2), -(5/2)],\n [(1/2), 0]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the plane defined by the following points:\n${\\{-3,5,-3\\}, \\{0,4,-2\\}, \\{4,4,4\\}}$.", - "Output Answer": [ - "$3 x+7 y-2 z-32=0$" - ], - "Output Program": [ - "import numpy as np\n\npoints = np.array([\n [-3, 5, -3],\n [0, 4, -2],\n [4, 4, 4]])\nvectors = points[1] - points[0], points[2] - points[0]\ncross_product = np.cross(*vectors)\nd = np.dot(cross_product, points[0])\nprint(*cross_product, -d)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 3 \\\\\n -8 \\\\\n -4 \\\\\n 3 \\\\\n 4 \\\\\n -3 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -4 \\\\\n -5 \\\\\n 7 \\\\\n -7 \\\\\n -3 \\\\\n 0 \\\\\n 9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-70$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5],\n [3],\n [-8],\n [-4],\n [3],\n [4],\n [-3],\n [-3]])\nb = np.array([\n [2],\n [-4],\n [-5],\n [7],\n [-7],\n [-3],\n [0],\n [9]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{cccc}\n \\frac{5}{3} & -\\frac{2}{3} & -\\frac{1}{3} & \\frac{8}{3} \\\\\n -\\frac{8}{3} & \\frac{1}{3} & -\\frac{4}{3} & \\frac{4}{3} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n \\frac{2}{3} \\\\\n -\\frac{4}{3} \\\\\n -\\frac{7}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{86}{9} \\\\\n \\frac{38}{9} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/3), -(2/3), -(1/3), (8/3)],\n [-(8/3), (1/3), -(4/3), (4/3)]])\nb = np.array([\n [-2],\n [(2/3)],\n [-(4/3)],\n [-(7/3)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{ccccc}\n 3 & -1 & 1 & -1 & 1 \\\\\n 3 & -3 & -2 & 2 & 1 \\\\\n -3 & -1 & 3 & 3 & -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{ccc}\n 1 & -1 & 2 \\\\\n -2 & 2 & 0 \\\\\n 3 & 0 & 1 \\\\\n -2 & 3 & 3 \\\\\n 2 & 0 & -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 12 & -8 & 3 \\\\\n 1 & -3 & 9 \\\\\n -2 & 10 & 8 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -1, 1, -1, 1],\n [3, -3, -2, 2, 1],\n [-3, -1, 3, 3, -2]])\nb = np.array([\n [1, -1, 2],\n [-2, 2, 0],\n [3, 0, 1],\n [-2, 3, 3],\n [2, 0, -1]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{ccc}\n \\frac{5}{8} & -\\frac{105}{16} & \\frac{27}{4} \\\\\n \\frac{9}{2} & \\frac{9}{8} & -\\frac{3}{16} \\\\\n -\\frac{3}{2} & \\frac{9}{8} & \\frac{77}{16} \\\\\n -\\frac{83}{16} & -10 & \\frac{25}{8} \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{ccc}\n \\frac{159}{16} & -\\frac{27}{8} & \\frac{105}{16} \\\\\n -\\frac{47}{16} & \\frac{19}{8} & -\\frac{37}{4} \\\\\n -\\frac{31}{16} & \\frac{57}{16} & \\frac{9}{8} \\\\\n -\\frac{59}{16} & \\frac{9}{4} & \\frac{55}{8} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{149}{16} & -\\frac{51}{16} & \\frac{3}{16} \\\\\n \\frac{119}{16} & -\\frac{5}{4} & \\frac{145}{16} \\\\\n \\frac{7}{16} & -\\frac{39}{16} & \\frac{59}{16} \\\\\n -\\frac{3}{2} & -\\frac{49}{4} & -\\frac{15}{4} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/8), -(105/16), (27/4)],\n [(9/2), (9/8), -(3/16)],\n [-(3/2), (9/8), (77/16)],\n [-(83/16), -10, (25/8)]])\nb = np.array([\n [(159/16), -(27/8), (105/16)],\n [-(47/16), (19/8), -(37/4)],\n [-(31/16), (57/16), (9/8)],\n [-(59/16), (9/4), (55/8)]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nGive a list of vectors that forms a basis for the null space of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccccc}\n -6 & -6 & 7 & -2 & 6 \\\\\n -4 & -7 & 3 & -3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{2.,-5.,0.,9.,0.\\}, \\{2.,-1.,0.,0.,1.\\}, \\{31.,-10.,18.,0.,0.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = Matrix(np.array([\n [-6, -6, 7, -2, 6],\n [-4, -7, 3, -3, 1]]))\nprint(a.nullspace())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_1$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n -\\frac{107}{16} \\\\\n \\frac{27}{16} \\\\\n -\\frac{9}{16} \\\\\n \\frac{87}{16} \\\\\n -10 \\\\\n -\\frac{153}{16} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\frac{543}{16}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(107/16)],\n [(27/16)],\n [-(9/16)],\n [(87/16)],\n [-10],\n [-(153/16)]])\nprint(np.linalg.norm(a, 1))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the determinant of the matrix\n$\\left(\n\\begin{array}{cc}\n \\frac{1}{3} & -\\frac{7}{2} \\\\\n -\\frac{7}{6} & -\\frac{7}{6} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-\\frac{161}{36}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(1/3), -(7/2)],\n [-(7/6), -(7/6)]])\nprint(np.linalg.det(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -8 \\\\\n 4 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -8 \\\\\n 8 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 32 \\\\\n 64 \\\\\n 32 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8],\n [4],\n [0]])\nb = np.array([\n [8],\n [-8],\n [8]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{3}{50}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 8 & -9 & 7 & 8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n \\frac{12}{25} & -\\frac{27}{50} & \\frac{21}{50} & \\frac{12}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8, -9, 7, 8]])\nprint(a * (3/50))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 4 \\\\\n -3 \\\\\n -3 \\\\\n 3 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -9 \\\\\n -8 \\\\\n 2 \\\\\n 1 \\\\\n -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$4 \\sqrt{17}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4],\n [-3],\n [-3],\n [3],\n [5]])\nb = np.array([\n [-9],\n [-8],\n [2],\n [1],\n [-2]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{22}{3} & 8 \\\\\n -\\frac{14}{3} & -\\frac{4}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{3} \\left(-13-i \\sqrt{255}\\right),\\frac{1}{3} \\left(-13+i \\sqrt{255}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(22/3), 8],\n [-(14/3), -(4/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 0 & 0 & 2 \\\\\n -2 & 2 & 1 \\\\\n 0 & 0 & -1 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 0 & 0 & -2 \\\\\n -4 & 4 & -3 \\\\\n 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0, 2],\n [-2, 2, 1],\n [0, 0, -1]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 1 \\\\\n 0 \\\\\n 1 \\\\\n 0 \\\\\n -1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n -1 \\\\\n -1 \\\\\n 1 \\\\\n 1 \\\\\n 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\cos ^{-1}\\left(-\\frac{1}{\\sqrt{6}}\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [1],\n [0],\n [1],\n [0],\n [-1],\n [1]]).squeeze()\nb = np.array([\n [-1],\n [-1],\n [-1],\n [1],\n [1],\n [1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n \\frac{5}{2} \\\\\n \\frac{5}{2} \\\\\n \\frac{31}{16} \\\\\n \\frac{27}{16} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -\\frac{21}{8} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -\\frac{105}{16} \\\\\n -\\frac{105}{16} \\\\\n -\\frac{651}{128} \\\\\n -\\frac{567}{128} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(5/2)],\n [(5/2)],\n [(31/16)],\n [(27/16)]])\nb = np.array([\n [-(21/8)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{ccc}\n 4 & 4 & -1 \\\\\n 1 & 1 & 1 \\\\\n -2 & -2 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n \\frac{1}{10} & \\frac{1}{50} & -\\frac{1}{25} \\\\\n \\frac{1}{10} & \\frac{1}{50} & -\\frac{1}{25} \\\\\n -\\frac{1}{5} & \\frac{4}{25} & -\\frac{8}{25} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [4, 4, -1],\n [1, 1, 1],\n [-2, -2, -2]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 3 & -7 & -1 \\\\\n -9 & -7 & 3 \\\\\n 9 & 10 & 5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.519,-1.316,1.\\}, \\{0.231\\, -0.835 i,-0.017+0.538 i,1.\\}, \\{0.231\\, +0.835 i,-0.017-0.538 i,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, -7, -1],\n [-9, -7, 3],\n [9, 10, 5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{13}{2} & -7 \\\\\n -\\frac{3}{2} & 0 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\left\\{\\frac{1}{6} \\left(-13-\\sqrt{337}\\right),1\\right\\}, \\left\\{\\frac{1}{6} \\left(\\sqrt{337}-13\\right),1\\right\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(13/2), -7],\n [-(3/2), 0]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 0 & 0 & 7 & 2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 7 & 4 & 1 & 9 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 7 & 4 & 8 & 11 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0, 0, 7, 2]])\nb = np.array([\n [7, 4, 1, 9]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n 2 & 7 \\\\\n 2 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{2} \\left(-3-\\sqrt{105}\\right),\\frac{1}{2} \\left(\\sqrt{105}-3\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 7],\n [2, -5]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvectors of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n -10 & 4 & 6 \\\\\n 5 & -7 & 9 \\\\\n 8 & 9 & -5 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "${\\{-0.542,-0.716,1.\\}, \\{0.551,0.841,1.\\}, \\{6.588,-6.767,1.\\}}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-10, 4, 6],\n [5, -7, 9],\n [8, 9, -5]])\nprint(np.linalg.eig(a)[1])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nOrthogonalize the following vectors:\n${\\{0,-2,1\\}, \\{0,-2,2\\}, \\{2,1,-2\\}}$", - "Output Answer": [ - "${\\left\\{0,-\\frac{2}{\\sqrt{5}},\\frac{1}{\\sqrt{5}}\\right\\}, \\left\\{0,\\frac{1}{\\sqrt{5}},\\frac{2}{\\sqrt{5}}\\right\\}, \\{1,0,0\\}}$" - ], - "Output Program": [ - "import numpy as np\n\nmatrix = np.column_stack(((0, -2, 1), (0, -2, 2), (2, 1, -2)))\nprint(np.linalg.qr(matrix)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 3 & 2 & 4 \\\\\n -2 & -7 & 2 \\\\\n -7 & -2 & -3 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-6.346,-0.327-4.769 i,-0.327+4.769 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [3, 2, 4],\n [-2, -7, 2],\n [-7, -2, -3]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{cccc}\n 10 & -8 & 0 & -10 \\\\\n -8 & -4 & -9 & 4 \\\\\n 6 & -6 & 1 & -8 \\\\\n -3 & -4 & -2 & 1 \\\\\n -5 & -5 & 6 & -3 \\\\\n 9 & -4 & -2 & 4 \\\\\n 7 & -8 & -8 & 6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 1 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 1 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [10, -8, 0, -10],\n [-8, -4, -9, 4],\n [6, -6, 1, -8],\n [-3, -4, -2, 1],\n [-5, -5, 6, -3],\n [9, -4, -2, 4],\n [7, -8, -8, 6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n -4 \\\\\n 1 \\\\\n -3 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n -2 \\\\\n 4 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n -2 \\\\\n 10 \\\\\n 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-4],\n [1],\n [-3]])\nb = np.array([\n [2],\n [-2],\n [4]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n 0 & 2 & 0 & \\frac{3}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 0 & -4 & 0 & -\\frac{6}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2]])\nb = np.array([\n [0, 2, 0, (3/5)]])\nprint(a @ b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n 2 & -1 & 0 \\\\\n -2 & 2 & -2 \\\\\n 1 & 2 & -2 \\\\\n\\end{array}\n\\right)^3$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n 22 & -10 & 4 \\\\\n -24 & 14 & -4 \\\\\n -6 & 2 & 2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1, 0],\n [-2, 2, -2],\n [1, 2, -2]])\nprint(np.linalg.matrix_power(a, 3))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n 7 \\\\\n -3 \\\\\n -2 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -5 \\\\\n 3 \\\\\n -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 9 \\\\\n 17 \\\\\n 6 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7],\n [-3],\n [-2]])\nb = np.array([\n [-5],\n [3],\n [-1]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the projection of the first vector onto the second:\n$\\left(\n\\begin{array}{c}\n -3 \\\\\n 0 \\\\\n -2 \\\\\n -2 \\\\\n -1 \\\\\n\\end{array}\n\\right)$,\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 3 \\\\\n 2 \\\\\n 1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{-\\frac{22}{19},-\\frac{33}{19},-\\frac{22}{19},-\\frac{11}{19},\\frac{11}{19}\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3],\n [0],\n [-2],\n [-2],\n [-1]]).squeeze()\nb = np.array([\n [2],\n [3],\n [2],\n [1],\n [-1]]).squeeze()\nprint(b * np.dot(a, b) / np.dot(b, b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{1}{2}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -5 & 9 \\\\\n 8 & 4 \\\\\n 5 & 1 \\\\\n -7 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{5}{2} & -\\frac{9}{2} \\\\\n -4 & -2 \\\\\n -\\frac{5}{2} & -\\frac{1}{2} \\\\\n \\frac{7}{2} & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, 9],\n [8, 4],\n [5, 1],\n [-7, -2]])\nprint(a * -(1/2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nSubtract the second matrix from the first:\n$\\left(\n\\begin{array}{cccc}\n 2 & -7 & 4 & 9 \\\\\n 3 & 9 & 4 & -9 \\\\\n 9 & 4 & -8 & 3 \\\\\n\\end{array}\n\\right)$\n$\\left(\n\\begin{array}{cccc}\n -6 & 9 & 3 & -9 \\\\\n -3 & -5 & -1 & -4 \\\\\n 10 & 4 & 0 & 2 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n 8 & -16 & 1 & 18 \\\\\n 6 & 14 & 5 & -5 \\\\\n -1 & 0 & -8 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -7, 4, 9],\n [3, 9, 4, -9],\n [9, 4, -8, 3]])\nb = np.array([\n [-6, 9, 3, -9],\n [-3, -5, -1, -4],\n [10, 4, 0, 2]])\nprint(a - b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{7}{6}$ and the matrix\n$\\left(\n\\begin{array}{cccc}\n 2 & 6 & -6 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -\\frac{7}{3} & -7 & 7 & 7 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 6, -6, -6]])\nprint(a * -(7/6))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{c}\n \\frac{44}{5} \\\\\n \\frac{38}{5} \\\\\n -\\frac{36}{5} \\\\\n -\\frac{37}{5} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{14}{5} \\\\\n \\frac{34}{5} \\\\\n -\\frac{14}{5} \\\\\n 1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{58}{5} \\\\\n \\frac{72}{5} \\\\\n -10 \\\\\n -\\frac{32}{5} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(44/5)],\n [(38/5)],\n [-(36/5)],\n [-(37/5)]])\nb = np.array([\n [(14/5)],\n [(34/5)],\n [-(14/5)],\n [1]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix (round your answer to three decimal places):\n$\\left(\n\\begin{array}{ccc}\n 7 & 2 & 7 \\\\\n 5 & 1 & -7 \\\\\n -4 & -9 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\{-13.125,6.063\\, -3.52 i,6.063\\, +3.52 i\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [7, 2, 7],\n [5, 1, -7],\n [-4, -9, -9]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{17}{2} & \\frac{17}{3} \\\\\n -\\frac{19}{2} & -\\frac{1}{2} \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$x^2-8 x+\\frac{595}{12}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(17/2), (17/3)],\n [-(19/2), -(1/2)]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute the (pseudo)inverse of\n$\\left(\n\\begin{array}{cc}\n 2 & -1 \\\\\n -3 & 1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n -1 & -1 \\\\\n -3 & -2 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, -1],\n [-3, 1]])\nprint(np.linalg.pinv(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nConvert the following matrix to reduced row echelon form:\n$\\left(\n\\begin{array}{ccccccc}\n 1 & 1 & -10 & 4 & 3 & -3 & 0 \\\\\n -4 & -9 & 8 & 10 & 2 & 8 & -1 \\\\\n -7 & 0 & -5 & -8 & -10 & -3 & 3 \\\\\n -3 & 10 & -4 & 0 & -10 & -7 & -7 \\\\\n -5 & 3 & -5 & -10 & -10 & 8 & 2 \\\\\n 2 & 2 & 6 & 2 & -3 & 5 & -6 \\\\\n -3 & -7 & -6 & 7 & 3 & -9 & -6 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccccccc}\n 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 1 & 0 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n 0 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\nfrom sympy import *\n\na = np.array([\n [1, 1, -10, 4, 3, -3, 0],\n [-4, -9, 8, 10, 2, 8, -1],\n [-7, 0, -5, -8, -10, -3, 3],\n [-3, 10, -4, 0, -10, -7, -7],\n [-5, 3, -5, -10, -10, 8, 2],\n [2, 2, 6, 2, -3, 5, -6],\n [-3, -7, -6, 7, 3, -9, -6]])\nprint(Matrix(a).rref())\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-\\frac{5}{6}$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -5 & -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n \\frac{25}{6} & \\frac{20}{3} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-5, -8]])\nprint(a * -(5/6))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the dot product of the following two vectors:\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n -5 \\\\\n -4 \\\\\n 3 \\\\\n -9 \\\\\n 5 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -2 \\\\\n 1 \\\\\n -5 \\\\\n -4 \\\\\n -2 \\\\\n -8 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$-15$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2],\n [-5],\n [-4],\n [3],\n [-9],\n [5]])\nb = np.array([\n [-2],\n [1],\n [-5],\n [-4],\n [-2],\n [-8]])\nprint(np.dot(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the cross product of the following vectors:\n$\\left(\n\\begin{array}{c}\n \\frac{11}{3} \\\\\n \\frac{68}{9} \\\\\n \\frac{29}{9} \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n \\frac{32}{9} \\\\\n -\\frac{73}{9} \\\\\n 5 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n \\frac{5177}{81} \\\\\n -\\frac{557}{81} \\\\\n -\\frac{4585}{81} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(11/3)],\n [(68/9)],\n [(29/9)]])\nb = np.array([\n [(32/9)],\n [-(73/9)],\n [5]])\nprint(np.cross(a.squeeze(), b.squeeze()))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the $\\ell_\\infty$ norm of the following vector:\n$\\left(\n\\begin{array}{c}\n 2 \\\\\n 3 \\\\\n 5 \\\\\n -1 \\\\\n -9 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$9$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2],\n [3],\n [5],\n [-1],\n [-9],\n [-4]])\nprint(np.linalg.norm(a, np.inf))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the characteristic polynomial of the following matrix:\n$\\left(\n\\begin{array}{ccc}\n -8 & 7 & 6 \\\\\n 1 & 9 & 0 \\\\\n -1 & -2 & 0 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$-x^3+x^2+73 x+42$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-8, 7, 6],\n [1, 9, 0],\n [-1, -2, 0]])\nprint(np.poly(a))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the distance between the following two vectors:\n$\\left(\n\\begin{array}{c}\n -3 e \\\\\n -3 e \\\\\n -e \\\\\n 3 e \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n 2 e \\\\\n e \\\\\n -e \\\\\n 2 e \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\sqrt{42} e$" - ], - "Output Program": [ - "import numpy as np\n\nimport math\n\na = np.array([\n [-3*math.e],\n [-3*math.e],\n [-math.e],\n [3*math.e]])\nb = np.array([\n [2*math.e],\n [math.e],\n [-math.e],\n [2*math.e]])\nprint(np.linalg.norm(a - b))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nAdd the two matrices\n$\\left(\n\\begin{array}{cccc}\n 2 & 3 & 2 & -10 \\\\\n 5 & 5 & -5 & 8 \\\\\n 5 & 8 & 10 & -4 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{cccc}\n -8 & -7 & 3 & -4 \\\\\n -1 & 7 & 3 & 4 \\\\\n -8 & -8 & 9 & -1 \\\\\n\\end{array}\n\\right)$", - "Output Answer": [ - "$\\left(\n\\begin{array}{cccc}\n -6 & -4 & 5 & -14 \\\\\n 4 & 12 & -2 & 12 \\\\\n -3 & 0 & 19 & -5 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [2, 3, 2, -10],\n [5, 5, -5, 8],\n [5, 8, 10, -4]])\nb = np.array([\n [-8, -7, 3, -4],\n [-1, 7, 3, 4],\n [-8, -8, 9, -1]])\nprint(a + b)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n -\\frac{14}{5} & \\frac{28}{5} \\\\\n \\frac{32}{5} & -\\frac{33}{5} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{10} \\left(-47-\\sqrt{3945}\\right),\\frac{1}{10} \\left(\\sqrt{3945}-47\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-(14/5), (28/5)],\n [(32/5), -(33/5)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the angle between the following two vectors:\n$\\left(\n\\begin{array}{c}\n 0 \\\\\n 0 \\\\\n 0 \\\\\n 0 \\\\\n\\end{array}\n\\right)$ and\n$\\left(\n\\begin{array}{c}\n -1 \\\\\n 0 \\\\\n -1 \\\\\n -1 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\text{Indeterminate}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [0],\n [0],\n [0],\n [0]]).squeeze()\nb = np.array([\n [-1],\n [0],\n [-1],\n [-1]]).squeeze()\nprint(np.arccos(np.dot(a, b) / np.linalg.norm(a) / np.linalg.norm(b)))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $-2$ and the matrix\n$\\left(\n\\begin{array}{cc}\n -3 & -2 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{cc}\n 6 & 4 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-3, -2]])\nprint(a * -2)\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{5}{32}$ and the matrix\n$\\left(\n\\begin{array}{ccc}\n -2 & -7 & 4 \\\\\n 8 & -10 & 6 \\\\\n -1 & -3 & -9 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -\\frac{5}{16} & -\\frac{35}{32} & \\frac{5}{8} \\\\\n \\frac{5}{4} & -\\frac{25}{16} & \\frac{15}{16} \\\\\n -\\frac{5}{32} & -\\frac{15}{32} & -\\frac{45}{32} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-2, -7, 4],\n [8, -10, 6],\n [-1, -3, -9]])\nprint(a * (5/32))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nMultiply the scalar $\\frac{9}{8}$ and the matrix\n$\\left(\n\\begin{array}{c}\n 8 \\\\\n -4 \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{c}\n 9 \\\\\n -\\frac{9}{2} \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [8],\n [-4]])\nprint(a * (9/8))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nCompute\n$\\left(\n\\begin{array}{ccc}\n -1 & 1 & -2 \\\\\n 2 & 0 & 0 \\\\\n 2 & -1 & 2 \\\\\n\\end{array}\n\\right)^2$.", - "Output Answer": [ - "$\\left(\n\\begin{array}{ccc}\n -1 & 1 & -2 \\\\\n -2 & 2 & -4 \\\\\n 0 & 0 & 0 \\\\\n\\end{array}\n\\right)$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [-1, 1, -2],\n [2, 0, 0],\n [2, -1, 2]])\nprint(np.linalg.matrix_power(a, 2))\n" - ], - "split": "test" - }, - { - "Input": "Problem:\nFind the eigenvalues of the following matrix:\n$\\left(\n\\begin{array}{cc}\n \\frac{20}{3} & -\\frac{20}{3} \\\\\n \\frac{14}{3} & \\frac{11}{3} \\\\\n\\end{array}\n\\right)$.", - "Output Answer": [ - "$\\left\\{\\frac{1}{6} \\left(31-i \\sqrt{1039}\\right),\\frac{1}{6} \\left(31+i \\sqrt{1039}\\right)\\right\\}$" - ], - "Output Program": [ - "import numpy as np\n\na = np.array([\n [(20/3), -(20/3)],\n [(14/3), (11/3)]])\nprint(np.linalg.eig(a)[0])\n" - ], - "split": "test" - } - ] -} \ No newline at end of file