Files
DTU-Noter/01001 - Matematik 1a/Noter/Andenordens differentialligninger/python-mobius.ipynb

143 lines
2.9 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "8d87a703",
"metadata": {},
"outputs": [],
"source": [
"import sympy as sp\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "dffe7f14",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}52 & -8 & -8\\\\-4 & 50 & 2\\\\-4 & 2 & 50\\end{matrix}\\right]$"
],
"text/plain": [
"Matrix([\n",
"[52, -8, -8],\n",
"[-4, 50, 2],\n",
"[-4, 2, 50]])"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"{60: 1, 48: 1, 44: 1}\n"
]
}
],
"source": [
"# Opgave 1\n",
"A = sp.Matrix([[52, -8, -8], [-4, 50, 2], [-4, 2, 50]])\n",
"display(A)\n",
"eigenvalsA = A.eigenvals()\n",
"print(eigenvalsA)\n"
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "debdde8b",
"metadata": {},
"outputs": [
{
"data": {
"text/latex": [
"$\\displaystyle \\left[\\begin{matrix}9 & -2 & 1\\\\-1 & 10 & -1\\\\1 & -2 & 9\\end{matrix}\\right]$"
],
"text/plain": [
"Matrix([\n",
"[ 9, -2, 1],\n",
"[-1, 10, -1],\n",
"[ 1, -2, 9]])"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[(8, 2, [Matrix([\n",
"[2],\n",
"[1],\n",
"[0]]), Matrix([\n",
"[-1],\n",
"[ 0],\n",
"[ 1]])]), (12, 1, [Matrix([\n",
"[ 1],\n",
"[-1],\n",
"[ 1]])])]\n",
"hej\n",
"Matrix([[2], [1], [0]])\n",
"Matrix([[-1], [0], [1]])\n",
"Matrix([[1], [-1], [1]])\n",
"Matrix([[12], [20], [-20]])\n"
]
}
],
"source": [
"# Opgave 2\n",
"\n",
"B = sp.Matrix([[9, -2, 1], [-1, 10, -1], [1, -2, 9]])\n",
"display(B)\n",
"eigenvectsB = B.eigenvects()\n",
"\n",
"print(eigenvectsB)\n",
"print(\"hej\")\n",
"print(eigenvectsB[0][2][0])\n",
"print(eigenvectsB[0][2][1])\n",
"print(eigenvectsB[1][2][0])\n",
"\n",
"print(sp.Matrix([[9, -2, 1], [-1, 10, -1], [1,-2,9]]) * sp.Matrix([2, 2, -2]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fa460b84",
"metadata": {},
"outputs": [],
"source": [
"# Opgave 3\n",
"\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}