Commit a9d1363f by Éamonn Murray

### Minor fixes

parent 49e010dc
 ... ... @@ -3,9 +3,7 @@ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", ... ... @@ -69,7 +67,7 @@ "$$\\begin{pmatrix} -1 & 1 \\\\ 1 & -1 \\end{pmatrix} \\begin{pmatrix} v_1 \\\\ v_2 \\end{pmatrix} = \\begin{pmatrix} 0 \\\\ 0 \\end{pmatrix}.$$\n", "In this case, any $\\vec v$ where $v_1 = v_2$ would satisfy this expression. So we can say the eigenvector is any scalar multiple of $\\begin{pmatrix} 1 \\\\ 1 \\end{pmatrix}$.\n", "\n", "Note that since the eigenvector corresponding to a given eigenvalue can always be multiplied by a non-zero scalar and still be a valid eigenvector, they are often normalized such that $\\left|\\vec v\\right| = 1$." "> Note that since the eigenvector corresponding to a given eigenvalue can always be multiplied by a non-zero scalar and still be a valid eigenvector, they are often normalized such that $\\left|\\vec v\\right| = 1$." ] }, { ... ... @@ -103,9 +101,7 @@ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "metadata": {}, "outputs": [], "source": [ "def power_iteration(a, eig_conv=0.0001, max_iter=100):\n", ... ... @@ -170,22 +166,19 @@ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "metadata": {}, "outputs": [], "source": [ "power_iteration(np.array([[2, 1], [1, 2]]), eig_conv=1e-10)\n", "# For our simple system we had previously, you can converge very accurately in a fairly small number of steps.\n", "# Since we have a random starting point, the number of steps to convergence can vary a bit." "# For our simple system we had previously, you can converge very accurately in a\n", "# fairly small number of steps. Since we have a random starting point, the number\n", "# of steps to convergence can vary a bit." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "metadata": {}, "outputs": [], "source": [ "# Lets see what we get for a large random matrix\n", ... ... @@ -212,9 +205,7 @@ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "metadata": {}, "outputs": [], "source": [ "# Let's see what happens for a matrix with a degenerate dominant eigenvalue\n", ... ... @@ -225,9 +216,7 @@ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "metadata": {}, "outputs": [], "source": [ "power_iteration(m, eig_conv=1e-5, max_iter=1000)" ... ... @@ -303,7 +292,7 @@ "\n", "- [scipy.linalg.eigvals](https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigvals.html) calculates eigenvalues, and [scipy.linalg.eig](https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eig.html) calculates eigenvalues and eigenvectors.\n", "- [scipy.linalg.eigvalsh](https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigvalsh.html) and [scipy.linalg.eigh](https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh.html) do the same thing for real symmetric or Hermitian matrices.\n", "- In addition recent SciPy versions (you may need to update via pip: sudo pip3 install scipy --upgrade) have dedicated functions for:\n", "- In addition recent SciPy versions have dedicated functions for:\n", " - Real symmetric or Hermitian banded matrices [scipy.linalg.eigvals_banded](https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigvals_banded.html) and [scipy.linalg.eig.banded](https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eig_banded.html)\n", " - Real symmetric tridiagonal matrices [scipy.linalg.eigh_tridiagonal](https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh_tridiagonal.html) and [scipy.linalg.eigh_tridiagonal](https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh_tridiagonal.html) \n", "- There is also QR decomposition with [scipy.linalg.qr](https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.qr.html) and many related functions that offer more advanced options relative to the NumPy version, such as the ability to also generate a pivot matrix which orders the diagonal elements of R.\n", ... ... @@ -315,7 +304,6 @@ "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true, "scrolled": true }, "outputs": [], ... ... @@ -327,7 +315,6 @@ "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true, "scrolled": true }, "outputs": [], ... ... @@ -402,9 +389,7 @@ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "metadata": {}, "outputs": [], "source": [ "# np.loadtxt won't work for this even if we skip the header as we don't\n", ... ... @@ -478,7 +463,6 @@ "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true, "scrolled": true }, "outputs": [], ... ... @@ -506,9 +490,7 @@ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "metadata": {}, "outputs": [], "source": [ "eigvals = scipy.linalg.eigvalsh(dynmat)\n", ... ... @@ -525,9 +507,7 @@ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "metadata": {}, "outputs": [], "source": [ "# Convert energy, distance and mass to SI\n", ... ... @@ -573,7 +553,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.2" "version": "3.5.3" } }, "nbformat": 4, ... ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!