summaryrefslogtreecommitdiff
path: root/Engineering_Mechancis,_Schaum_Series_by_McLean/chapter1.ipynb
diff options
context:
space:
mode:
authorThomas Stephen Lee2015-08-28 16:53:23 +0530
committerThomas Stephen Lee2015-08-28 16:53:23 +0530
commitdb0855dbeb41ecb8a51dde8587d43e5d7e83620f (patch)
treeb95975d958cba9af36cb1680e3f77205354f6512 /Engineering_Mechancis,_Schaum_Series_by_McLean/chapter1.ipynb
parent5a86a20b9de487553d4ef88719fb0fd76a5dd6a7 (diff)
downloadPython-Textbook-Companions-db0855dbeb41ecb8a51dde8587d43e5d7e83620f.tar.gz
Python-Textbook-Companions-db0855dbeb41ecb8a51dde8587d43e5d7e83620f.tar.bz2
Python-Textbook-Companions-db0855dbeb41ecb8a51dde8587d43e5d7e83620f.zip
add books
Diffstat (limited to 'Engineering_Mechancis,_Schaum_Series_by_McLean/chapter1.ipynb')
-rwxr-xr-xEngineering_Mechancis,_Schaum_Series_by_McLean/chapter1.ipynb928
1 files changed, 928 insertions, 0 deletions
diff --git a/Engineering_Mechancis,_Schaum_Series_by_McLean/chapter1.ipynb b/Engineering_Mechancis,_Schaum_Series_by_McLean/chapter1.ipynb
new file mode 100755
index 00000000..1c446b6f
--- /dev/null
+++ b/Engineering_Mechancis,_Schaum_Series_by_McLean/chapter1.ipynb
@@ -0,0 +1,928 @@
+{
+ "metadata": {
+ "name": "chapter 1.ipynb"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Chapter 1:Vectors"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1-1,Page no: 8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Initialisation of Variables\n",
+ "\n",
+ "f1=120 #lb\n",
+ "f2=100 #lb\n",
+ "theta=((60*pi)/180) #radians\n",
+ "\n",
+ "#Calculations\n",
+ "\n",
+ "R=sqrt(120**2+100**2-(2*120*100*cos(theta))) #Applying Thr rule of Cosines\n",
+ "alpha1=(((arcsin(120*sin(theta)/111))*180)/pi) #Applying the Law of Sines\n",
+ "alpha=alpha1+270 #As the vector lies in the fourth Quadrant by obsrevaton\n",
+ "\n",
+ "#Results\n",
+ "\n",
+ "print'The Resultant of The force system is equal to',round(R),\"lb\" #lb\n",
+ "print'The Resultant is at',round(alpha),\"degrees\" #degrees\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Resultant of The force system is equal to 111.0 lb\n",
+ "The Resultant is at 339.0 degrees\n"
+ ]
+ }
+ ],
+ "prompt_number": 32
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1-2,Page no: 9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Initilization of variables\n",
+ "\n",
+ "P=100 #lb\n",
+ "Q=120 #lb\n",
+ "theta=((30*pi)/180) #radians\n",
+ "\n",
+ "#Calculations\n",
+ "\n",
+ "R_x=Q*cos(theta) #lb\n",
+ "R_y=Q*sin(theta)-P #lb\n",
+ "R=sqrt(R_x**2+R_y**2) #lb Triangle law\n",
+ "Theta_1=((arctan(R_y/R_x))*180)/pi #degrees\n",
+ "Theta_R=360+Theta_1 #degrees\n",
+ "\n",
+ "#Result\n",
+ "\n",
+ "print'The resultant of the force system is',round(R),\"lb\"\n",
+ "print'The resultant is at',round(Theta_R),\"degrees\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The resultant of the force system is 111.0 lb\n",
+ "The resultant is at 339.0 degrees\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1-3,Page No: 9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "# Initialization of variables\n",
+ "\n",
+ "R=400 # N\n",
+ "F2=200 # N\n",
+ "Theta1=((120*pi)/180) # radians\n",
+ "Theta2=((20*pi)/180) # radians\n",
+ "Theta=Theta1-Theta2 # radians\n",
+ "\n",
+ "# Calculation\n",
+ "\n",
+ "F=sqrt(R**2+F2**2-(2*R*F2*cos(Theta))) # N.Applying the Rule of Cosine\n",
+ "Theta_r=arcsin((400*sin(Theta))/F) #radians Applying the rule of sines\n",
+ "Theta_R=(Theta_r*180)/pi\n",
+ "\n",
+ "# Result\n",
+ "\n",
+ "print'The resultant of the force system is',round(F),\"N\"\n",
+ "print'The Angle between F and 200N force is',round(Theta_R,1),\"degrees\"\n",
+ "\n",
+ "# Theta_R is off by 0.1 degrees"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The resultant of the force system is 477.0 N\n",
+ "The Angle between F and 200N force is 55.6 degrees\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1-4, Page No: 9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "# Initilization of variables\n",
+ "\n",
+ "F1=280 # N\n",
+ "F2=130 # N\n",
+ "Theta1=((320*pi)/180) # Radians\n",
+ "Theta2=((60*pi)/180) # Radians\n",
+ "\n",
+ "# Calculations\n",
+ "\n",
+ "R_x=-F1*cos(Theta1)+F2*cos(Theta2) # N\n",
+ "R_y=F1*sin(Theta1)-F2*sin(Theta2) # N\n",
+ "R=sqrt(R_x**2+R_y**2) # N Applying Triangle Law\n",
+ "ThetaR=arctan(R_y/R_x) # radians\n",
+ "Theta_R=360-(ThetaR*180/pi) # degrees\n",
+ "\n",
+ "# Result\n",
+ "\n",
+ "print'The resultant of the force system is',round(R),\"N\"\n",
+ "print'The resultant is at',round(Theta_R),\"degrees\"\n",
+ "\n",
+ "# The answer for R waries from textbook. "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The resultant of the force system is 329.0 N\n",
+ "The resultant is at 297.0 degrees\n"
+ ]
+ }
+ ],
+ "prompt_number": 35
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1-5, Page No: 10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "# Initialization of variables\n",
+ "\n",
+ "F1=26 #lb\n",
+ "F2=39 #lb\n",
+ "F3=63 #lb\n",
+ "F4=57 #lb\n",
+ "T1=((10*pi)/180) #Radians\n",
+ "T2=((114*pi)/180) #Radians\n",
+ "T3=((183*pi)/180) #radians\n",
+ "T4=((261*pi)/180) #radians\n",
+ "\n",
+ "# Calculations\n",
+ "\n",
+ "R_x=F1*cos(T1)+F2*cos(T2)+F3*cos(T3)+F4*cos(T4) # lb Resolving vectors\n",
+ "R_y=F1*sin(T1)+F2*sin(T2)+F3*sin(T3)+F4*sin(T4) # lb resolving vectors\n",
+ "R=sqrt(R_x**2+R_y**2) # lb Applying Triangle Law\n",
+ "theta=arctan(R_y/R_x)# radians\n",
+ "Theta=(theta*180)/pi # degrees\n",
+ "Theta_R=180+Theta\n",
+ "\n",
+ "# Results\n",
+ "\n",
+ "print'The Resultant of the force system is',round(R),\"lb\"\n",
+ "print'The resultant is at',round(Theta_R),\"degrees\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Resultant of the force system is 65.0 lb\n",
+ "The resultant is at 197.0 degrees\n"
+ ]
+ }
+ ],
+ "prompt_number": 36
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1-6, Page No: 11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Initilization of variables\n",
+ "\n",
+ "F=10 #lb\n",
+ "theta1=((60*pi)/180) #radians\n",
+ "theta2=((45*pi)/180) #radians\n",
+ "theta=theta1-theta2 #radians\n",
+ "\n",
+ "#Calculation\n",
+ "\n",
+ "F_OH=F/cos(theta) #lb resolving vectors\n",
+ "\n",
+ "# Result\n",
+ "\n",
+ "print'The component of F in the direction of OH is',round(F_OH,2),\"lb\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The component of F in the direction of OH is 10.35 lb\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1-7, Page No: 11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Initilization of variables\n",
+ "\n",
+ "weight=80 #kg\n",
+ "theta=((20*pi)/180) #radians\n",
+ "theta_p=((70*pi)/180) # radians\n",
+ "\n",
+ "#Calcuations\n",
+ "\n",
+ "#Part (a)\n",
+ "F=weight*9.81 # N\n",
+ "R=F*cos(theta) #N\n",
+ "#part (b)\n",
+ "R_p=F*cos(theta_p) #N\n",
+ "\n",
+ "#Result\n",
+ "\n",
+ "print'The normal component is',round(R),\"N\"\n",
+ "print'The parallel component is',round(R_p),\"N\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The normal component is 737.0 N\n",
+ "The parallel component is 268.0 N\n"
+ ]
+ }
+ ],
+ "prompt_number": 37
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1-8, Page No: 11"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Initilization of variables\n",
+ "\n",
+ "P=235 #N\n",
+ "theta=((60*pi)/180) #radians\n",
+ "bet=((22*pi)/180) #radians\n",
+ "gam=((38*pi)/180) #radians\n",
+ "\n",
+ "#Calculations\n",
+ "\n",
+ "#Part (a)\n",
+ "P_h=P*cos(theta) #N\n",
+ "P_v=P*sin(theta) #N\n",
+ "#Part (b)\n",
+ "P_l=P*cos(theta-bet) #N\n",
+ "P_p=P*sin(gam) #N\n",
+ "\n",
+ "#Result\n",
+ "\n",
+ "print'The horizontal component is',round(P_h,1),\"N\"\n",
+ "print'The vertical component is',round(P_v,1),\"N\"\n",
+ "print'The component parallel to plane is',round(P_l),\"N\"\n",
+ "print'The component perpendicular to the plane is',round(P_p,1),\"N\"\n",
+ "\n",
+ "#The decimal point accuracy might cause a small discrepancy in the answers\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The horizontal component is 117.5 N\n",
+ "The vertical component is 203.5 N\n",
+ "The component parallel to plane is 185.0 N\n",
+ "The component perpendicular to the plane is 144.7 N\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1-9, Page No: 12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Initilization of variables\n",
+ "\n",
+ "F1=90 #lb\n",
+ "theta1=((40*pi)/180) #radians\n",
+ "theta2=((30*pi)/180) #radians\n",
+ "\n",
+ "# Calculations\n",
+ "\n",
+ "R_x=0 #lb\n",
+ "R_y=20 # lb\n",
+ "#Taking the sum of forces in the X-Direction\n",
+ "P=((F1*cos(theta1))/cos(theta2)) # lb\n",
+ "# Taking the sum of the forces in the Y-Direction\n",
+ "F=(P*sin(theta2))+(F1*sin(theta1))-20 #lb\n",
+ "\n",
+ "# Results\n",
+ "\n",
+ "print'The value of P is',round(P,1),\"lb\"\n",
+ "print'The value of F is',round(F,1),\"lb\"\n",
+ "\n",
+ "# Decimal point error may cause a small discrepancy in the answers."
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of P is 79.6 lb\n",
+ "The value of F is 77.7 lb\n"
+ ]
+ }
+ ],
+ "prompt_number": 23
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1-10, Page No: 12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Initilization of variables\n",
+ "\n",
+ "x=4 # m\n",
+ "y=3 # m\n",
+ "z=2 # m\n",
+ "F=50 #N\n",
+ "\n",
+ "# Calculations\n",
+ "\n",
+ "OP=sqrt(x**2+y**2+z**2) #m\n",
+ "thetax=(x/OP) #radians\n",
+ "thetay=(y/OP) #Radians\n",
+ "thetaz=(z/OP) #radians\n",
+ "P_x=F*(thetax) #N\n",
+ "P_y=F*(thetay) #N\n",
+ "P_z=F*(thetaz) #N\n",
+ "\n",
+ "# Result\n",
+ "\n",
+ "print'The vector P is',round(P_x,1),\"i +\",round(P_y,1),\"j +\",round(P_z,1),\"k\"\n",
+ "\n",
+ "# component of i is off by 0.1 units"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The vector P is 37.1 i + 27.9 j + 18.6 k\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1-11, Page No: 12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Initilization of variables\n",
+ "\n",
+ "x=2 \n",
+ "y=-4\n",
+ "z=1\n",
+ "F=100 #N\n",
+ "\n",
+ "#Calculation\n",
+ "\n",
+ "thetax=x/sqrt(x**2+y**2+z**2) #radians\n",
+ "thetay=y/sqrt(x**2+y**2+z**2) #radians\n",
+ "thetaz=z/sqrt(x**2+y**2+z**2) #radians\n",
+ "P_x=F*thetax #N\n",
+ "P_y=F*thetay #N\n",
+ "P_z=F*thetaz #N\n",
+ "\n",
+ "#Result\n",
+ "\n",
+ "print'The vector P is',round(P_x,1),\"i\",round(P_y,1),\"j +\",round(P_z,1),\"k\"\n",
+ "\n",
+ "# component off i is off by 0.1 units"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The vector P is 43.6 i -87.3 j + 21.8 k\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1-12, Page No: 13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Solution\n",
+ "\n",
+ "print'P X Q=(Pxi+Pyj+Pzk)x(Qxi+Qyj+Qzk)'\n",
+ "print' =(PxQx)i x i+(PxQy)i x j +(PxQz)i x k'\n",
+ "print'But i x i = j x j = k x k =0; and i x j =k and j x i= -k, etc. Hence'\n",
+ "print'P X Q= (PxQy)k-(PxQz)j-(PyQx)k+(PxQz)i+(PzQx)j-(PzQy)i'\n",
+ "print'These terms can be grouped as'\n",
+ "print'P X Q=(PyQz-PzQy)i+(PzQx-PxQz)j+(PxQy-PyQx)k'\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "P X Q=(Pxi+Pyj+Pzk)x(Qxi+Qyj+Qzk)\n",
+ " =(PxQx)i x i+(PxQy)i x j +(PxQz)i x k\n",
+ "But i x i = j x j = k x k =0; and i x j =k and j x i= -k, etc. Hence\n",
+ "P X Q= (PxQy)k-(PxQz)j-(PyQx)k+(PxQz)i+(PzQx)j-(PzQy)i\n",
+ "These terms can be grouped as\n",
+ "P X Q=(PyQz-PzQy)i+(PzQx-PxQz)j+(PxQy-PyQx)k\n"
+ ]
+ }
+ ],
+ "prompt_number": 21
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1-13,Page No: 13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Initilization of variables\n",
+ "\n",
+ "Fx=2.63 #N\n",
+ "Fy=4.28 #N\n",
+ "Fz=-5.92 #N\n",
+ "\n",
+ "#Calculation\n",
+ "\n",
+ "F=sqrt(Fx**2+Fy**2+Fz**2) #N\n",
+ "thetax=((arccos(Fx/F))*180)/pi #degrees\n",
+ "thetay=((arccos(Fy/F))*180)/pi #degrees\n",
+ "thetaz=((arccos(Fz/F))*180)/pi #degrees\n",
+ "\n",
+ "#Result\n",
+ "\n",
+ "print'The magnitude of force is',round(F,2),\"N\"\n",
+ "print'Thetax',round(thetax,1),\"degrees\"\n",
+ "print'Thetay',round(thetay,1),\"degrees\"\n",
+ "print'Thetaz',round(thetaz,1),\"degrees\"\n",
+ "\n",
+ "# Decimal point error may cause a small discrepancy in the answers."
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The magnitude of force is 7.76 N\n",
+ "Thetax 70.2 degrees\n",
+ "Thetay 56.5 degrees\n",
+ "Thetaz 139.7 degrees\n"
+ ]
+ }
+ ],
+ "prompt_number": 24
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1-14, Page No: 13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Initilization of variables\n",
+ "\n",
+ "P=[4.82, -2.33, 5.47] #N\n",
+ "Q=[-2.81,-6.09,1.12 ] #m\n",
+ "\n",
+ "#Calculations\n",
+ "\n",
+ "M=P[0]*Q[0]+P[1]*Q[1]+P[2]*Q[2] #Nm\n",
+ "\n",
+ "#Results\n",
+ "\n",
+ "print'Result is',round(M,2),\"N.m\"\n",
+ "\n",
+ "# Decimal point error in calculation causes a small discrepancy in the answer."
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Result is 6.77 N.m\n"
+ ]
+ }
+ ],
+ "prompt_number": 29
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1-15, Page No: 13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "import numpy as np\n",
+ "#Initilization of variables\n",
+ "\n",
+ "x1=2 #units\n",
+ "x2=-2 #units\n",
+ "y1=3 #units\n",
+ "y2=4 #units\n",
+ "z1=0 #units\n",
+ "z2=6 #units\n",
+ "P=np.array([2,3,-1]) #units\n",
+ "\n",
+ "#Calculations\n",
+ "\n",
+ "X=sqrt((x2-x1)**2+(y2-y1)**2+(z2-z1)**2) #units\n",
+ "eLx=(x2-x1)/X #units\n",
+ "eLy=(y2-y1)/X #units\n",
+ "eLz=(z2-z1)/X #units\n",
+ "Q=np.array([eLx,eLy,eLz]) #units\n",
+ "Z=P[0]*Q[0]+P[1]*Q[1]+P[2]*Q[2] # units\n",
+ "\n",
+ "#Result\n",
+ "\n",
+ "print'The unit vector is',round(eLx,3),\"i +\",round(eLy,3),\"j +\",round(eLz,3),\"k\"\n",
+ "print'The projection of P is',round(Z,2),\"units\"\n",
+ "\n",
+ "#Note:The final answer for the projection of P is off by 0.1 units\n",
+ "#The answer mentioned in the textbook is -1.41\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The unit vector is -0.549 i + 0.137 j + 0.824 k\n",
+ "The projection of P is -1.51 units\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1-16, Page No: 14"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "import numpy as np\n",
+ "#Initilization of variables\n",
+ "\n",
+ "x1=2 #units\n",
+ "x2=5 #units\n",
+ "y1=-5 #units\n",
+ "y2=2 #units\n",
+ "z1=3 #units\n",
+ "z2=-4 #units\n",
+ "P=np.array([10,-8,14]) #units\n",
+ "\n",
+ "#Calculations\n",
+ "\n",
+ "X=sqrt((x2-x1)**2+(y2-y1)**2+(z2-z1)**2) #units\n",
+ "eLx=(x2-x1)/X #units\n",
+ "eLy=(y2-y1)/X #units\n",
+ "eLz=(z2-z1)/X #units\n",
+ "Q=np.array([eLx,eLy,eLz]) #units\n",
+ "Z=P[0]*Q[0]+P[1]*Q[1]+P[2]*Q[2] #units\n",
+ "\n",
+ "#Result\n",
+ "\n",
+ "print'The unit vector is',round(eLx,3),\"i +\",round(eLy,3),\"j\",round(eLz,3),\"k\" \n",
+ "print'The projection of P is',round(Z),\"lb\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The unit vector is 0.29 i + 0.677 j -0.677 k\n",
+ "The projection of P is -12.0 lb\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1-17, Page No: 14\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "Px=2.85 #ft\n",
+ "Py=4.67 #ft\n",
+ "Pz=-8.09 #ft\n",
+ "Qx=28.3 #lb\n",
+ "Qy=44.6 #lb\n",
+ "Qz=53.3 #lb\n",
+ "\n",
+ "#Calculations\n",
+ "\n",
+ "X=(Py*Qz-Pz*Qy) #N.m \n",
+ "Y=(Pz*Qx-Px*Qz) #N.m\n",
+ "Z=(Px*Qy-Py*Qx) #N.m\n",
+ "\n",
+ "#Result\n",
+ "\n",
+ "print'The cross product is',round(X),\"i\",round(Y),\"j\",round(Z),\"k lb-ft\"\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The cross product is 610.0 i -381.0 j -5.0 k lb-ft\n"
+ ]
+ }
+ ],
+ "prompt_number": 45
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1-18, Page No: 14"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "\n",
+ "#Result\n",
+ "#As this is symbolic solution directly print command is being used to give the required output\n",
+ "\n",
+ "print'The Time derivative is '\n",
+ "print'dr/dt=(dx/dt)i+12*y(dy/dt)j-3*(dz/dt)k'\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Time derivative is \n",
+ "dr/dt=(dx/dt)i+12*y(dy/dt)j-3*(dz/dt)k\n"
+ ]
+ }
+ ],
+ "prompt_number": 47
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1.1-19, Page No: 14"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import math\n",
+ "from scipy.integrate import quad\n",
+ "def integrand(x, a, b):\n",
+ " return x**2\n",
+ "a=1\n",
+ "b=1\n",
+ "I=quad(integrand, 1, 3, args=(a,b))\n",
+ "\n",
+ "def integrand(y, a, b):\n",
+ " return 2*y\n",
+ "a=1\n",
+ "b=1\n",
+ "J=quad(integrand, 1, 3, args=(a,b))\n",
+ "\n",
+ "def integrand(z, a, b):\n",
+ " return 1\n",
+ "a=1\n",
+ "b=1\n",
+ "K=quad(integrand, 1, 3, args=(a,b))\n",
+ "\n",
+ "# Results\n",
+ "print'The answer is',round(I[0],2),\"i +\",round(J[0]),\"j -\",round(K[0]),\"k.\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The answer is 8.67 i + 8.0 j - 2.0 k.\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file