{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 11: Vibrations in Strings"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 1, Page number 371"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "amplitude is 10 cm\n",
      "frequency is 1 Hz\n",
      "wavelength is 200.0 cm\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "#given Y=10sinmath.pi(0.01x-2t)\n",
    "#by comparing with Y=Asin(kx-omegat) we get\n",
    "A=10;     #amplitude(cm)\n",
    "omega=2*math.pi;\n",
    "k=0.01*math.pi;      #wavelength constant\n",
    "\n",
    "#Calculation\n",
    "f=omega/(2*math.pi);        #frequency(Hz)\n",
    "lamda=2*math.pi/k;          #wavelength(cm) \n",
    "\n",
    "#Result\n",
    "print \"amplitude is\",A,\"cm\"\n",
    "print \"frequency is\",int(f),\"Hz\"\n",
    "print \"wavelength is\",lamda,\"cm\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 2, Page number 371"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "along negative axis displacement y= 0.01 sin( 10 *math.pi/3 x + 1100 t)\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "f=550;       #frequency(Hz)\n",
    "A=0.01;      #amplitude(cm)\n",
    "v=330;       #wave velocity(m/sec)\n",
    "\n",
    "#Calculation\n",
    "omega=2*math.pi*f;     #angular frequency\n",
    "k=omega/v;             #wavelength constant\n",
    "#along negative axis displacement y=Asin(kx+omegat) substitute the values\n",
    "\n",
    "#Result\n",
    "print \"along negative axis displacement y=\",A,\"sin(\",int(k*3/math.pi),\"*math.pi/3 x +\",int(omega/math.pi),\"t)\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 3, Page number 371"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "wave velocity is 40.82 m/s\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "l=2;          #length(m)\n",
    "m=0.6;       #mass(kg)\n",
    "T=500;        #tension(N)\n",
    "\n",
    "#Calculation\n",
    "mew=m/l;      #linear density(kg/m)\n",
    "v=math.sqrt(T/mew);       #wave velocity(m/s)\n",
    "\n",
    "#Result\n",
    "print \"wave velocity is\",round(v,2),\"m/s\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 4, Page number 372"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "amplitude is 1.028 units\n",
      "answer given in the book is wrong\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "x=10;       #stationary wave point\n",
    "t=1;        #assume\n",
    "y1=5*math.sin(((2*math.pi*t)-(2*x))*math.pi/180);          #transverse wave\n",
    "y2=5*math.sin(((2*math.pi*t)+(2*x))*math.pi/180);          #transverse wave\n",
    "\n",
    "#Calculation\n",
    "y=y1+y2;        #amplitude(units)\n",
    "\n",
    "#Result\n",
    "print \"amplitude is\",round(y,3),\"units\"\n",
    "print \"answer given in the book is wrong\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 5, Page number 372"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "string linear density is 0.0249 kg/m\n",
      "wave velocity is 633.56 m/s\n",
      "fundamental frequency is 316.78 Hz\n",
      "frequency of 1st overtone is 633.56 Hz\n",
      "frequency of 2nd overtone is 950.34 Hz\n",
      "fundamental wavelength is 2 m\n",
      "1st overtone wavelength is 1 m\n",
      "2nd overtone wavelength is 0.667 m\n",
      "answers in the book varies due to rounding off errors\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "r=1*10**-3;           #string radius(m)\n",
    "l=1;                  #length(m)\n",
    "rho=7930;             #density(kg/m**3)\n",
    "T=10**4;              #tension(N)\n",
    "\n",
    "#Calculation\n",
    "mew=math.pi*r**2*rho/l;       #string linear density(kg/m)\n",
    "v=math.sqrt(T/mew);           #wave velocity(m/s)\n",
    "f1=v/(2*l);                   #fundamental frequency(Hz)\n",
    "f2=2*f1;                      #frequency of 1st overtone(Hz)\n",
    "f3=3*f1;                      #frequency of 2nd overtone(Hz)\n",
    "lamda1=2*l/1;                 #fundamental wavelength(m)\n",
    "lamda2=2*l/2;                 #1st overtone wavelength(m)\n",
    "lamda3=2*l/3;                 #2nd overtone wavelength(m)\n",
    "\n",
    "#Result\n",
    "print \"string linear density is\",round(mew,4),\"kg/m\"\n",
    "print \"wave velocity is\",round(v,2),\"m/s\"\n",
    "print \"fundamental frequency is\",round(f1,2),\"Hz\"\n",
    "print \"frequency of 1st overtone is\",round(f2,2),\"Hz\"\n",
    "print \"frequency of 2nd overtone is\",round(f3,2),\"Hz\"\n",
    "print \"fundamental wavelength is\",int(lamda1),\"m\"\n",
    "print \"1st overtone wavelength is\",int(lamda2),\"m\"\n",
    "print \"2nd overtone wavelength is\",round(lamda3,3),\"m\"\n",
    "print \"answers in the book varies due to rounding off errors\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 6, Page number 373"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "power is 19.74 watts\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "mew=0.1;      #string linear density(kg/m)\n",
    "A=0.1;        #amplitude(m)\n",
    "f=10;         #frequency(Hz)\n",
    "T=10;        #tension(N)\n",
    "\n",
    "#Calculation\n",
    "v=math.sqrt(T/mew);       #wave velocity(m/s)\n",
    "P=2*math.pi**2*f**2*A**2*v*mew;      #power(watt)\n",
    "\n",
    "#Result\n",
    "print \"power is\",round(P,2),\"watts\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 7, Page number 373"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tension in string is 524.29 N\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "f=500;         #frequency(Hz)\n",
    "T=500;         #tension(N)\n",
    "f1=512;        #required frequency(Hz)\n",
    "\n",
    "#Calculation\n",
    "T1=T*f1**2/f**2;       #tension in string(N)\n",
    "\n",
    "#Result\n",
    "print \"tension in string is\",round(T1,2),\"N\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example number 8, Page number 374"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "amplitude at x=5 is 4.0\n",
      "first node position is 0.0 m\n",
      "second node position is 30.0 m\n",
      "third node position is 60.0 m\n",
      "wavelength is 60.0 m\n",
      "component transverse wave equations are y1= 4.0 sin math.pi((x/30)-(48*t))\n"
     ]
    }
   ],
   "source": [
    "#importing modules\n",
    "import math\n",
    "from __future__ import division\n",
    "\n",
    "#Variable declaration\n",
    "#given Y=8sin(math.pi*x/30)cos(48*math.pi*t)\n",
    "#by comparing with Y=2Asin(kx)cos(omegat) we get\n",
    "A=8/2;     #amplitude(cm)\n",
    "omega=48*math.pi;\n",
    "x=5;       #stationary wave point\n",
    "k=math.pi/30;      #wavelength constant\n",
    "y1=0;\n",
    "y2=math.pi;\n",
    "y3=2*math.pi;\n",
    "\n",
    "#Calculation\n",
    "y=2*A*math.sin(math.pi*x/30);      #amplitude at x=5\n",
    "x1=y1*30/math.pi;                  #first node position(m)  \n",
    "x2=y2*30/math.pi;                  #second node position(m)  \n",
    "x3=y3*30/math.pi;                  #third node position(m)  \n",
    "lamda=2*(x3-x2);                   #wavelength(m) \n",
    "\n",
    "#Result\n",
    "print \"amplitude at x=5 is\",y\n",
    "print \"first node position is\",x1,\"m\"\n",
    "print \"second node position is\",x2,\"m\"\n",
    "print \"third node position is\",x3,\"m\"\n",
    "print \"wavelength is\",lamda,\"m\"\n",
    "print \"component transverse wave equations are y1=\",A,\"sin math.pi((x/30)-(48*t))\""
   ]
  }
 ],
 "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.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
