diff options
author | kinitrupti | 2017-05-12 18:53:46 +0530 |
---|---|---|
committer | kinitrupti | 2017-05-12 18:53:46 +0530 |
commit | 6279fa19ac6e2a4087df2e6fe985430ecc2c2d5d (patch) | |
tree | 22789c9dbe468dae6697dcd12d8e97de4bcf94a2 /Antenna_and_Wave_Propagation_by_G.S.N._Raju/chapter1_2.ipynb | |
parent | d36fc3b8f88cc3108ffff6151e376b619b9abb01 (diff) | |
download | Python-Textbook-Companions-6279fa19ac6e2a4087df2e6fe985430ecc2c2d5d.tar.gz Python-Textbook-Companions-6279fa19ac6e2a4087df2e6fe985430ecc2c2d5d.tar.bz2 Python-Textbook-Companions-6279fa19ac6e2a4087df2e6fe985430ecc2c2d5d.zip |
Removed duplicates
Diffstat (limited to 'Antenna_and_Wave_Propagation_by_G.S.N._Raju/chapter1_2.ipynb')
-rwxr-xr-x | Antenna_and_Wave_Propagation_by_G.S.N._Raju/chapter1_2.ipynb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Antenna_and_Wave_Propagation_by_G.S.N._Raju/chapter1_2.ipynb b/Antenna_and_Wave_Propagation_by_G.S.N._Raju/chapter1_2.ipynb new file mode 100755 index 00000000..d9a04491 --- /dev/null +++ b/Antenna_and_Wave_Propagation_by_G.S.N._Raju/chapter1_2.ipynb @@ -0,0 +1 @@ +{"nbformat_minor": 0, "cells": [{"source": "# Chapter 1 : Mathematical Preliminaries", "cell_type": "markdown", "metadata": {}}, {"source": "## Example 1.1,Page Number 45", "cell_type": "markdown", "metadata": {}}, {"execution_count": 26, "cell_type": "code", "source": "import numpy as np\n\n#variable Declaration\nA = np.array([1,2,3]) # A is a vector\n\n#calculations\nl=np.linalg.norm(A) # magnitude or length of vector A\na=A/l # direction of vector A\n\n#results\nprint \"magnitude of vector:\",round(l,2)\nprint \"direction of vector\",np.around(a,3)\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "magnitude of vector: 3.74\ndirection of vector [ 0.267 0.535 0.802]\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.2,Page Number 45", "cell_type": "markdown", "metadata": {"collapsed": true}}, {"execution_count": 2, "cell_type": "code", "source": "import numpy as np\n\n#variable Declaration\nA=np.array([2,5,6]) # vector A\nB=np.array([1,-3,6]) # vector B\n\n#calculations\nSum = A+B # summation of two vectors\nSub = A-B # subtraction of two vectors\n\n#results\nprint \"summation of two vectors:\",Sum\nprint \"subtraction of two vectors:\",Sub\n\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "summation of two vectors: [ 3 2 12]\nsubtraction of two vectors: [1 8 0]\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.3,Page Number 45", "cell_type": "markdown", "metadata": {}}, {"execution_count": 3, "cell_type": "code", "source": "import numpy as np\n\n#Variable Declaration\n\nA = np.array([1,1,2]) # vector A\nB = np.array([2,1,1]) # vector B\n\n#Calculations\nk = np.dot(A,B) # dot product of vector A and B\n\n#Results\n\nprint \"dot product of vector A and B:\",k\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "dot product of vector A and B: 5\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.4,Page Number 45", "cell_type": "markdown", "metadata": {}}, {"execution_count": 4, "cell_type": "code", "source": "import numpy as np\n\n#Variable Declaration\n\nA = np.array([2,1,2]) # vector A\nB = np.array([1,2,1]) # vector B\n\n#Calculations\nCross = np.cross(A,B) # dot product of vector A and B\n\n#Results\n\nprint \"cross product of vector A and B:\",Cross\n\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "cross product of vector A and B: [-3 0 3]\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.5,Page Number 46", "cell_type": "markdown", "metadata": {}}, {"execution_count": 5, "cell_type": "code", "source": "import numpy as np\n\n#Variable Declaration\n\nA = np.array([1,3,4]) # vector A\nB = np.array([1,0,2]) # vector B\n\n#Calculations\nk = np.dot(A,B) # dot product of vector A and B\n\n#Results\n\nprint \"dot product of vector A and B:\",k\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "dot product of vector A and B: 9\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.9,Page Number 46", "cell_type": "markdown", "metadata": {}}, {"execution_count": 6, "cell_type": "code", "source": "from __future__ import division\nimport math\n\n#variable declaration\np = [1,2,3] # coordinates of point p\nx = 1 # x coordinate of P\ny = 2 # y coordinate of P\nz = 3 # z coordinate of P\n\n#Calculations\nrho = math.sqrt(x**2+y**2) #radius of cylinder in m\nphi = (math.atan(y/x))*(180/math.pi) # azimuthal angle in degrees\nz = 3 # in m\n\n\n#results\nprint \"radius of cylinder is:\",round(rho,2),\"m\"\nprint \"azimuthal angle is:\",round(phi,2),\"degrees\"\nprint \"z coordinate is:\",z,\"m\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "radius of cylinder is: 2.24 m\nazimuthal angle is: 63.43 degrees\nz coordinate is: 3 m\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.10,Page Number 47", "cell_type": "markdown", "metadata": {}}, {"execution_count": 27, "cell_type": "code", "source": "from __future__ import division\nfrom math import cos,sin,pi,atan\nimport numpy as np\n\n#Variable Declaration\n\nA = np.array([4,2,1]) # vector A\nA_x = 4 # x coordinate of P\nA_y = 2 # y coordinate of P\nA_z = 1 # z coordinate of P\n\n\n#calculations\nphi = atan(A_y/A_x) # azimuthal in radians\nA_rho = (A_x*cos((phi)))+(A_y*sin((phi))) # x coordinate of cylinder\nA_phi = (-A_x*sin(phi))+(A_y*cos(phi)) # y coordinate of cylinder\nA_z = 1 # z coordinate of cylinder\nA = [A_rho,A_phi,A_z] # cylindrical coordinates if vector A\n\n#Result\nprint \"cylindrical coordinates of vector A:\",np.around(A,3)\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "cylindrical coordinates of vector A: [ 4.472 0. 1. ]\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.12,Page Number 47", "cell_type": "markdown", "metadata": {}}, {"execution_count": 22, "cell_type": "code", "source": "from __future__ import division\nfrom math import sqrt,acos,atan\nimport numpy as np\n\n#Variable Declaration\nP = np.array([1,2,3]) # coordinates of point P in cartezian system\nx = 1 # x coordinate of point P in cartezian system\ny = 2 # y coordinate of point P in cartezian system\nz = 3 # z coordinate of point P in cartezian system\n\n#calculations\nr = sqrt(x**2+y**2+z**2) # radius of sphere in m\ntheta = acos(z/r) # angle of elevation in degrees\nphi = atan(x/y) # azimuthal angle in degrees\n\n#results\nprint \"radius of sphere is:\",round(r,3),\"m\"\nprint \"angle of elevation is:\",round(theta,3),\"radians\"\nprint \"azimuthal angle is:\",round(phi,3),\"radians\"\n\n\n# note : answer in the book is incomplete they find only one coordinate but there are three\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "radius of sphere is: 3.742 m\nangle of elevation is: 0.641 radians\nazimuthal angle is: 0.464 radians\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.17,Page Number 48", "cell_type": "markdown", "metadata": {}}, {"execution_count": 9, "cell_type": "code", "source": "import numpy as np\n\n#variable declaration\nA_p=22 # power gain\n\n#calulation\nA_p_dB=10*(np.log10(A_p)) # power gain in dB\n\n#result\nprint \"power gain is:\",round(A_p_dB,3),\"dB\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "power gain is: 13.424 dB\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.18,Page Number 48", "cell_type": "markdown", "metadata": {}}, {"execution_count": 10, "cell_type": "code", "source": "import numpy as np\n\n#variable declaration\nA_v=95 # voltage gain\n\n#calculation\nA_v_dB=20*(np.log10(A_v)) # voltage gain in dB\n\n#result\nprint \"voltage gain is:\",round(A_v_dB,3),\"dB\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "voltage gain is: 39.554 dB\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.19,Page Number 48", "cell_type": "markdown", "metadata": {}}, {"execution_count": 11, "cell_type": "code", "source": "import numpy as np\nfrom math import sqrt\n\n#variable declaration\nA_p = 16 # power gain\n\n#calculations\nA_p_Np = np.log(sqrt(A_p)) # power gain in Np\n\n#results\nprint \"power gain is:\",round(A_p_Np,3),\"Np\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "power gain is: 1.386 Np\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.20,Page Number 49", "cell_type": "markdown", "metadata": {}}, {"execution_count": 12, "cell_type": "code", "source": "import numpy as np\n\n#variable declaration\nA_i = 34 # current gain\n\n#calculations\nA_i_Np = np.log(A_i) # current gain in Nepers\n\n#result\nprint \"power gain is:\",round(A_i_Np,3),\"Np\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "power gain is: 3.526 Np\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.21,Page Number 49", "cell_type": "markdown", "metadata": {}}, {"execution_count": 13, "cell_type": "code", "source": "from __future__ import division\nimport cmath \nfrom math import sqrt,pi\n\n\n#variable declaration\nA=2+4j # complex number A\n\n#calculations\nmagnitude = abs(A) # magnitude of complex number A\nphi = cmath.phase(A)*(180/pi) # phase of complex number A in degrees\n\n#results\nprint \"magnitude of complex number A is:\",round(magnitude,3)\nprint \"phase of complex number A is:\",round(phi,3),\"degrees\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "magnitude of complex number A is: 4.472\nphase of complex number A is: 63.435 degrees\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.22,Page Number 49", "cell_type": "markdown", "metadata": {}}, {"execution_count": 14, "cell_type": "code", "source": "from __future__ import division\nfrom math import pi\nimport cmath\n\n#variable declaration\nA = 1+3j # complex no. A\n\n#calculations\nc = A.conjugate() # conjugate of complex no. A\nmagnitude = abs(A) # magnitude of complex number A\nphi = cmath.phase(A)*(180/pi) # phase of complex number A in degrees\n\n\n#results\nprint \"magnitude of complex number A is:\",round(magnitude,3)\nprint \"phase of complex number A in degrees:\",round(phi,3)\nprint \"conjugate of complex no. A:\",c\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "magnitude of complex number A is: 3.162\nphase of complex number A in degrees: 71.565\nconjugate of complex no. A: (1-3j)\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.23,Page Number 49", "cell_type": "markdown", "metadata": {}}, {"execution_count": 24, "cell_type": "code", "source": "from __future__ import division\nfrom math import cos,sin,radians\nimport numpy as np\n\n#variable declaration\nrho = 5 # magnitude of the complex number A\nphi = 45 # phase of a complex number A in Degrees\n\n#calculations\nx = rho*cos(radians(phi)) # real part of complex number A\ny = rho*sin(radians(phi)) # imaginary part of complex number A\nA = complex(x,y) # complex number A\n\n#results\nprint \"real part of complex number A:\",round(x,3)\nprint \"imaginary part of complex number A:\",round(y,3)\nprint \"complex number A:\",np.around(A,3)\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "real part of complex number A: 3.536\nimaginary part of complex number A: 3.536\ncomplex number A: (3.536+3.536j)\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.24,Page Number 49", "cell_type": "markdown", "metadata": {}}, {"execution_count": 16, "cell_type": "code", "source": "#Variable Declaration\n\nA_1 = 2+3j # complex number A_1\nA_2 = 4+5j # complex number A_2\n\n\n#calculation\nA = A_1 + A_2\n\n#Result\nprint \"sum of complex numbers A_1 and A_2 is:\",A\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "sum of complex numbers A_1 and A_2 is: (6+8j)\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.25,Page Number 49", "cell_type": "markdown", "metadata": {}}, {"execution_count": 17, "cell_type": "code", "source": "#Variable Declaration\n\nA_1 = 6j # complex number A_1\nA_2 = 1-2j # complex number A_2\n\n\n#calculation\nA = A_1 - A_2\n\n#Result\nprint \"Difference of complex numbers A_1 and A_2 is:\",A\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Difference of complex numbers A_1 and A_2 is: (-1+8j)\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.26,Page Number 49", "cell_type": "markdown", "metadata": {}}, {"execution_count": 18, "cell_type": "code", "source": "#Variable Declaration\n\nA = 0.4 + 5j # complex number A\nB = 2+3j # complex number B\n\n\n#calculation\nP = A*B\n\n#Result\nprint \"Product of complex numbers A and B is:\",P\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Product of complex numbers A and B is: (-14.2+11.2j)\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.27,Page Number 50", "cell_type": "markdown", "metadata": {}}, {"execution_count": 25, "cell_type": "code", "source": "import numpy as np\n\n#Variable Declaration\n\nA = 10+6j # complex number A\nB = 2-3j # complex number B \n\n#calculation\nD = A/B\n\n#Result\nprint \"Division of complex numbers A and B is:\",np.around(D,3)\n\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Division of complex numbers A and B is: (0.154+3.231j)\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.28,Page Number 50", "cell_type": "markdown", "metadata": {}}, {"execution_count": 20, "cell_type": "code", "source": "from sympy import *\n\n#variable Declaration\n\nx = Symbol('x')\np = (x)**2 + 2*x + 4\n\n#calculations\nRoots = solve(p,x)\n\n\n#result\nprint \"The roots of the given quadratic equation are:\",Roots\n\nfor i in range(len(Roots)):\n print \"Root %i = %s\" % (i + 1, str(Roots[i].n(5)))\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "The roots of the given quadratic equation are: [-1 - sqrt(3)*I, -1 + sqrt(3)*I]\nRoot 1 = -1.0 - 1.732*I\nRoot 2 = -1.0 + 1.732*I\n"}], "metadata": {"collapsed": false, "trusted": false}}, {"source": "## Example 1.31,Page Number 51", "cell_type": "markdown", "metadata": {}}, {"execution_count": 21, "cell_type": "code", "source": "from math import factorial\n\nf1 = factorial(4) # factorial of 4\nf2 = factorial(6) # factorial of 6\nprint \"factorial of 4 is:\",f1\nprint \"factorial of 6 is:\",f2\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "factorial of 4 is: 24\nfactorial of 6 is: 720\n"}], "metadata": {"collapsed": false, "trusted": false}}], "nbformat": 4, "metadata": {"kernelspec": {"display_name": "Python 2", "name": "python2", "language": "python"}, "language_info": {"mimetype": "text/x-python", "nbconvert_exporter": "python", "version": "2.7.8", "name": "python", "file_extension": ".py", "pygments_lexer": "ipython2", "codemirror_mode": {"version": 2, "name": "ipython"}}}}
\ No newline at end of file |