diff options
author | Trupti Kini | 2016-09-03 23:30:23 +0600 |
---|---|---|
committer | Trupti Kini | 2016-09-03 23:30:23 +0600 |
commit | 07cf280d177584baac74e351b3d76d085d0e6619 (patch) | |
tree | 202a15d7bc23aa1d1dc2a4a9397c94d344ff8dc8 /Linear_Algebra_And_Its_Applications_by_G._Strang/CHAPTER7.ipynb | |
parent | 3c5945f0aaf1d2d1f84e43ead6676aa497c9c4f8 (diff) | |
download | Python-Textbook-Companions-07cf280d177584baac74e351b3d76d085d0e6619.tar.gz Python-Textbook-Companions-07cf280d177584baac74e351b3d76d085d0e6619.tar.bz2 Python-Textbook-Companions-07cf280d177584baac74e351b3d76d085d0e6619.zip |
Added(A)/Deleted(D) following books
A Linear_Algebra_And_Its_Applications_by_G._Strang/CHAPTER1.ipynb
A Linear_Algebra_And_Its_Applications_by_G._Strang/CHAPTER2.ipynb
A Linear_Algebra_And_Its_Applications_by_G._Strang/CHAPTER3.ipynb
A Linear_Algebra_And_Its_Applications_by_G._Strang/CHAPTER4.ipynb
A Linear_Algebra_And_Its_Applications_by_G._Strang/CHAPTER5.ipynb
A Linear_Algebra_And_Its_Applications_by_G._Strang/CHAPTER6.ipynb
A Linear_Algebra_And_Its_Applications_by_G._Strang/CHAPTER7.ipynb
A Linear_Algebra_And_Its_Applications_by_G._Strang/CHAPTER8.ipynb
A Linear_Algebra_And_Its_Applications_by_G._Strang/screenshots/Ch5Eigenmatrix.png
A Linear_Algebra_And_Its_Applications_by_G._Strang/screenshots/Ch5eigenVectors.png
A Linear_Algebra_And_Its_Applications_by_G._Strang/screenshots/ch5eigenvaluematrix.png
Diffstat (limited to 'Linear_Algebra_And_Its_Applications_by_G._Strang/CHAPTER7.ipynb')
-rw-r--r-- | Linear_Algebra_And_Its_Applications_by_G._Strang/CHAPTER7.ipynb | 352 |
1 files changed, 352 insertions, 0 deletions
diff --git a/Linear_Algebra_And_Its_Applications_by_G._Strang/CHAPTER7.ipynb b/Linear_Algebra_And_Its_Applications_by_G._Strang/CHAPTER7.ipynb new file mode 100644 index 00000000..b791345b --- /dev/null +++ b/Linear_Algebra_And_Its_Applications_by_G._Strang/CHAPTER7.ipynb @@ -0,0 +1,352 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 7 Computations with Matrices" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex:7.4.1 Pg: 238" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "intial v & w:\n", + "[[ 0.]\n", + " [ 0.]] \n", + "\n", + "k= 0\n", + "v(k+1) & w(k+1)= [[ 1.]\n", + " [ 1.]] \n", + "\n", + "k= 1\n", + "v(k+1) & w(k+1)= [[ 1.5]\n", + " [ 1.5]] \n", + "\n", + "k= 2\n", + "v(k+1) & w(k+1)= [[ 1.75]\n", + " [ 1.75]] \n", + "\n", + "k= 3\n", + "v(k+1) & w(k+1)= [[ 1.875]\n", + " [ 1.875]] \n", + "\n", + "k= 4\n", + "v(k+1) & w(k+1)= [[ 1.9375]\n", + " [ 1.9375]] \n", + "\n", + "k= 5\n", + "v(k+1) & w(k+1)= [[ 1.96875]\n", + " [ 1.96875]] \n", + "\n", + "k= 6\n", + "v(k+1) & w(k+1)= [[ 1.984375]\n", + " [ 1.984375]] \n", + "\n", + "k= 7\n", + "v(k+1) & w(k+1)= [[ 1.9921875]\n", + " [ 1.9921875]] \n", + "\n", + "k= 8\n", + "v(k+1) & w(k+1)= [[ 1.99609375]\n", + " [ 1.99609375]] \n", + "\n", + "k= 9\n", + "v(k+1) & w(k+1)= [[ 1.99804688]\n", + " [ 1.99804688]] \n", + "\n", + "k= 10\n", + "v(k+1) & w(k+1)= [[ 1.99902344]\n", + " [ 1.99902344]] \n", + "\n", + "k= 11\n", + "v(k+1) & w(k+1)= [[ 1.99951172]\n", + " [ 1.99951172]] \n", + "\n", + "k= 12\n", + "v(k+1) & w(k+1)= [[ 1.99975586]\n", + " [ 1.99975586]] \n", + "\n", + "k= 13\n", + "v(k+1) & w(k+1)= [[ 1.99987793]\n", + " [ 1.99987793]] \n", + "\n", + "k= 14\n", + "v(k+1) & w(k+1)= [[ 1.99993896]\n", + " [ 1.99993896]] \n", + "\n", + "k= 15\n", + "v(k+1) & w(k+1)= [[ 1.99996948]\n", + " [ 1.99996948]] \n", + "\n", + "k= 16\n", + "v(k+1) & w(k+1)= [[ 1.99998474]\n", + " [ 1.99998474]] \n", + "\n", + "k= 17\n", + "v(k+1) & w(k+1)= [[ 1.99999237]\n", + " [ 1.99999237]] \n", + "\n", + "k= 18\n", + "v(k+1) & w(k+1)= [[ 1.99999619]\n", + " [ 1.99999619]] \n", + "\n", + "k= 19\n", + "v(k+1) & w(k+1)= [[ 1.99999809]\n", + " [ 1.99999809]] \n", + "\n", + "k= 20\n", + "v(k+1) & w(k+1)= [[ 1.99999905]\n", + " [ 1.99999905]] \n", + "\n", + "k= 21\n", + "v(k+1) & w(k+1)= [[ 1.99999952]\n", + " [ 1.99999952]] \n", + "\n", + "k= 22\n", + "v(k+1) & w(k+1)= [[ 1.99999976]\n", + " [ 1.99999976]] \n", + "\n", + "k= 23\n", + "v(k+1) & w(k+1)= [[ 1.99999988]\n", + " [ 1.99999988]] \n", + "\n", + "k= 24\n", + "v(k+1) & w(k+1)= [[ 1.99999994]\n", + " [ 1.99999994]] \n", + "\n", + "k= 25\n", + "v(k+1) & w(k+1)= [[ 1.99999997]\n", + " [ 1.99999997]] \n", + "\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "from numpy import mat,transpose,zeros\n", + "A=mat([[2 ,-1],[-1, 2]])\n", + "S=mat([[2, 0],[0, 2]])\n", + "T=mat([[0, 1],[1, 0]])\n", + "p=S**-1*T\n", + "b=transpose(mat([2 ,2]))\n", + "x=zeros([2,1])\n", + "print 'intial v & w:\\n',x,'\\n'\n", + "x_1=zeros([1,2])\n", + "for k in range(0,26):\n", + " x_1=p*x+(S**-1)*b\n", + " x=x_1\n", + " print 'k=',k\n", + " print 'v(k+1) & w(k+1)=',x_1,'\\n'\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex:7.4.2 Pg: 238" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "intial v & w: [[ 0.]\n", + " [ 0.]]\n", + "k=\n", + "0\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.10887353]\n", + " [ 0.53877511]]\n", + "k=\n", + "1\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.37826108]\n", + " [ 0.67346888]]\n", + "k=\n", + "2\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.44560797]\n", + " [ 0.70714233]]\n", + "k=\n", + "3\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46244469]\n", + " [ 0.71556069]]\n", + "k=\n", + "4\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46665387]\n", + " [ 0.71766528]]\n", + "k=\n", + "5\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46770617]\n", + " [ 0.71819143]]\n", + "k=\n", + "6\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46796924]\n", + " [ 0.71832296]]\n", + "k=\n", + "7\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46803501]\n", + " [ 0.71835585]]\n", + "k=\n", + "8\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46805145]\n", + " [ 0.71836407]]\n", + "k=\n", + "9\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46805556]\n", + " [ 0.71836612]]\n", + "k=\n", + "10\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46805659]\n", + " [ 0.71836664]]\n", + "k=\n", + "11\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46805685]\n", + " [ 0.71836676]]\n", + "k=\n", + "12\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46805691]\n", + " [ 0.7183668 ]]\n", + "k=\n", + "13\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46805693]\n", + " [ 0.71836681]]\n", + "k=\n", + "14\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46805693]\n", + " [ 0.71836681]]\n", + "k=\n", + "15\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46805693]\n", + " [ 0.71836681]]\n", + "k=\n", + "16\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46805693]\n", + " [ 0.71836681]]\n", + "k=\n", + "17\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46805693]\n", + " [ 0.71836681]]\n", + "k=\n", + "18\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46805693]\n", + " [ 0.71836681]]\n", + "k=\n", + "19\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46805693]\n", + " [ 0.71836681]]\n", + "k=\n", + "20\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46805693]\n", + " [ 0.71836681]]\n", + "k=\n", + "21\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46805693]\n", + " [ 0.71836681]]\n", + "k=\n", + "22\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46805693]\n", + " [ 0.71836681]]\n", + "k=\n", + "23\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46805693]\n", + " [ 0.71836681]]\n", + "k=\n", + "24\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46805693]\n", + " [ 0.71836681]]\n", + "k=\n", + "25\n", + "v(k+1) & w(k+1)=\n", + "[[ 0.46805693]\n", + " [ 0.71836681]]\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "from numpy import mat,transpose,zeros\n", + "from numpy.random import rand\n", + "from numpy.linalg import inv\n", + "A=mat([[2, -1],[-1, 2]])\n", + "S=mat([[2, 0],[-1, 2]])\n", + "T=mat([[0, 1],[0, 0]])\n", + "b=rand(2,1)\n", + "p=inv(S)*T\n", + "x=zeros([2,1])\n", + "print 'intial v & w:',x\n", + "x_1=zeros([1,2])\n", + "for k in range(0,26):\n", + " x_1=p*x+inv(S)*b\n", + " x=x_1\n", + " print 'k=\\n',k\n", + " print 'v(k+1) & w(k+1)=\\n',x_1" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} |