07: Add matrices to begin with

This commit is contained in:
2022-02-17 12:58:07 +01:00
parent bc721d8bec
commit f5ff90cb80

View File

@ -39,7 +39,7 @@
"cell_type": "raw",
"metadata": {},
"source": [
"team_members = \"\""
"team_members = \"Koen Vendrig, Kees van Kempen\""
]
},
{
@ -70,7 +70,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {
"deletable": false,
"nbgrader": {
@ -85,12 +85,38 @@
"task": false
}
},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"array([[ 1.75781401, 1.51265934, -2.74738978, -1.07039898, 0.8011521 ,\n",
" 1.4647544 ],\n",
" [-2.71620167, -0.86457733, 0.10081129, -0.73161518, -2.78224414,\n",
" 0.41565052],\n",
" [-0.67163289, 1.56932333, 2.48595706, -2.40628501, 0.71051658,\n",
" -0.69975624],\n",
" [ 1.58537064, 1.68053005, 2.06468208, 2.35512153, -0.66624755,\n",
" 2.62150694],\n",
" [-3.14413521, -2.23161046, 1.14029891, -1.55518494, 2.72967878,\n",
" -2.42673772],\n",
" [-2.97430088, -2.15350692, -2.82033592, 2.92079141, 2.94935414,\n",
" -0.35649436]])"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Import packages here ...\n",
"import numpy as np\n",
"\n",
"# YOUR CODE HERE\n",
"raise NotImplementedError()"
"# We'll generate a random matrix, but for now we're unsure whether it results in a\n",
"# solvable system.\n",
"n = 6\n",
"A = 7*(np.random.rand(n,n) - .5)\n",
"b = 13*(np.random.rand(n) - .5)\n",
"A"
]
},
{
@ -118,7 +144,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {
"deletable": false,
"nbgrader": {
@ -136,8 +162,7 @@
"outputs": [],
"source": [
"def diff(a, b):\n",
" # YOUR CODE HERE\n",
" raise NotImplementedError()"
" return np.max(a - b)"
]
},
{
@ -312,6 +337,12 @@
},
"outputs": [],
"source": [
"# Here, Koen, I made the matrix.\n",
"A = np.array([[ 10, - 1, 2, 0],\n",
" [- 1, 11, - 1, 3],\n",
" [ 2, - 1, 10, - 1],\n",
" [ 0, 3, - 1, 8]])\n",
"b = np.array( [ 6, 25, -11, 15])\n",
"# Do your plotting here ...\n",
"\n",
"# YOUR CODE HERE\n",
@ -583,6 +614,12 @@
},
"outputs": [],
"source": [
"A = np.array([[ .2, .1, 1.0, 1.0, 0.0],\n",
" [ .1, 4.0, - 1.0, 1.0, - 1.0],\n",
" [ 1.0, -1.0, 60.0, .0, .0],\n",
" [ 1.0, 1.0, .0, 8.0, 4.0],\n",
" [ .0, -1.0, - 2.0, 4.0, 700.0]])\n",
"b = np.array( [ 1 , 2 , 3 , 4 , 5 ] )\n",
"# YOUR CODE HERE\n",
"raise NotImplementedError()"
]
@ -647,7 +684,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},