{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Zadanie 4.6" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "ename": "NameError", "evalue": "name 'QQ' is not defined", "output_type": "error", "traceback": [ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)", "Cell \u001b[1;32mIn[1], line 5\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39msympy\u001b[39;00m \u001b[39mimport\u001b[39;00m symbols, Matrix\n\u001b[0;32m 3\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mnumpy\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mlinalg\u001b[39;00m \u001b[39mimport\u001b[39;00m eig\n\u001b[1;32m----> 5\u001b[0m A\u001b[39m=\u001b[39mnp\u001b[39m.\u001b[39mmatrix(QQ,\u001b[39m5\u001b[39m,\u001b[39m3\u001b[39m,[\u001b[39m2\u001b[39m, \u001b[39m4\u001b[39m, \u001b[39m6\u001b[39m, \u001b[39m8\u001b[39m, \u001b[39m10\u001b[39m, \u001b[39m12\u001b[39m, \u001b[39m14\u001b[39m, \u001b[39m16\u001b[39m, \u001b[39m18\u001b[39m, \u001b[39m20\u001b[39m, \u001b[39m22\u001b[39m, \u001b[39m24\u001b[39m, \u001b[39m26\u001b[39m, \u001b[39m28\u001b[39m, \u001b[39m31\u001b[39m])\n\u001b[0;32m 6\u001b[0m \u001b[39mprint\u001b[39m(A\u001b[39m.\u001b[39mtranspose()\u001b[39m*\u001b[39mA)\n\u001b[0;32m 7\u001b[0m \u001b[39mprint\u001b[39m((A\u001b[39m.\u001b[39mtranspose()\u001b[39m*\u001b[39mA)\u001b[39m^\u001b[39m(\u001b[39m-\u001b[39m\u001b[39m1\u001b[39m))\n", "\u001b[1;31mNameError\u001b[0m: name 'QQ' is not defined" ] } ], "source": [ "import numpy as np\n", "from sympy import symbols, Matrix\n", "from numpy.linalg import eig\n", "\n", "A=np.matrix(QQ,5,3,[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 31])\n", "print(A.transpose()*A)\n", "print((A.transpose()*A)^(-1))\n", "mm=(A.transpose()*A)^(-1)\n", "mm=(A.transpose()*A)^(-1)*A.transpose()\n", "print(mm)\n", "\n", "b1=np.vector([-1,0,1,0,1])\n", "mm1=mm*b1\n", "print(mm1)\n", "print((b1-A*mm1))\n", "b2=np.vector([1,1,1,1,1])\n", "mm2=mm*b2\n", "print(mm2)\n", "print((b2-A*mm2))\n", "\n", "b2 in (m.transpose()).image()" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Zadanie 4.7\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "zb1=[(1,1),(2,3),(4,5)]\n", "zb2=[(1,1),(2,3),(3,4),(4,5),(5,7),(6,9)]\n", "\n", "m1=matrix(3,2,[1,exp(1.0),1,exp(2.0),1,exp(4.0)])\n", "m2=matrix(6,2,[1,exp(1.0),1,exp(2.0),1,exp(3.0),1,exp(4.0),1,exp(5.0),1,exp(6.0)])\n", "\n", "a,b,t=var('a,b,t')\n", "\n", "m1*vector([a,b])-vector([1,3,5])\n", "m2*vector([a,b])-vector([1,3,4,5,7,9])\n", "\n", "\n", "\n", "M1=m1.transpose()*m1\n", "M1.det()\n", "\n", "\n", "\n", "M2=m2.transpose()*m2\n", "M2.det()\n", "\n", "\n", "\n", "M1^(-1)*m1.transpose()*vector([1,3,5])\n", "\n", "M2^(-1)*m2.transpose()*vector([1,3,4,5,7,9])\n", "\n", "\n", "plot(1.64148598265947+ 0.0629860338045423*exp(t),(t,0,4))+sum([point(x) for x in zb1])\n", "\n", "plot(3.10041190358990+ 0.0163320609303546*exp(t),(t,0,6))+sum([point(x) for x in zb2])" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Zadanie 4.9" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m=matrix(3,3,[1,1,0,1,2,2,0,2,3])\n", "\n", "eigenvalues = np.m.eigvals(matrix)\n", "\n", "eigen=m.right_eigenvectors()\n", "e1=eigen[0][1][0]\n", "e2=eigen[1][1][0]\n", "print(e1.dot_product(e2))\n", "e3=eigen[2][1][0]\n", "print(e3.dot_product(e1))\n", "print(e2.dot_product(e3))" ] } ], "metadata": { "kernelspec": { "display_name": "base", "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.10.9" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }