{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Chapter 23 : Mirrors and lenses"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 23.1 Page No: 760"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The hight = 0.90 m\n"
     ]
    }
   ],
   "source": [
    "from __future__ import division\n",
    "AC= 1.8-.1#in m\n",
    "AD=.5*AC\n",
    "CF=.10#/in m\n",
    "X=.5*CF#in m\n",
    "FA=1.8#in m\n",
    "d=FA-AD-X\n",
    "print \"The hight = %0.2f m\"%d"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 23.2 Page No : 767"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part a\n",
      "The magnification when object is at 25cm : -0.67\n",
      "part c\n",
      "The magnification when object is at 5cm : 2.00\n"
     ]
    }
   ],
   "source": [
    "p=25#in cm\n",
    "f=10#in cm\n",
    "x=(1/f)-(1/p)\n",
    "q=1/x\n",
    "p=25\n",
    "M=-(q/p)\n",
    "print \"part a\"\n",
    "print \"The magnification when object is at 25cm : %0.2f\"%M\n",
    "p=5#in cm\n",
    "f=10#in cm\n",
    "x=(1/f)-(1/p)\n",
    "q=1/x\n",
    "p=5\n",
    "M=-(q/p)\n",
    "print \"part c\"\n",
    "print \"The magnification when object is at 5cm : %0.2f\"%M"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 23.3 Page No: 768"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part a\n",
      "The position of final image = -5.71 cm\n",
      "part b\n",
      "The magnification : 0.23\n"
     ]
    }
   ],
   "source": [
    "p=20#in cm\n",
    "f=-8#in cm\n",
    "x=(1/f)-(1/p)\n",
    "q=1/x\n",
    "p=25\n",
    "M=-(q/p)\n",
    "print \"part a\"\n",
    "print \"The position of final image = %0.2f cm\"%q\n",
    "print \"part b\"\n",
    "print \"The magnification : %0.2f\"%M"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 23.4 Page No: 769"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The focal length = 26.67 cm\n"
     ]
    }
   ],
   "source": [
    "p=40#in cm\n",
    "q=-(2*p)\n",
    "\n",
    "x=(1/p)-(1/q)\n",
    "f=1/x\n",
    "print \"The focal length = %0.2f cm\"%f\n",
    "#Answer given in book is wrong"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 23.5 Page No: 770"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The position of final image = -17.14 cm\n",
      "The magnification when object = -1.29 cm\n",
      "The Position of image = 2.57 cm\n"
     ]
    }
   ],
   "source": [
    "p=20#in cm\n",
    "n1=1.5#in cm\n",
    "n2=1#in cm\n",
    "R=-30#in cm\n",
    "x=(n2-n1)/R\n",
    "y=n1/p\n",
    "s=x-y\n",
    "q=1/s\n",
    "print \"The position of final image = %0.2f cm\"%q\n",
    "M=(n1*q)/(n2*p)\n",
    "print \"The magnification when object = %0.2f cm\"%M\n",
    "h=2#in cm\n",
    "h1=-M*h\n",
    "print \"The Position of image = %0.2f cm\"%h1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 23.7 Page No: 777"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part a\n",
      "The position of final image = 15.00 cm\n",
      "The magnification : -0.50\n",
      "part b\n",
      "The position of final image = -10.00 cm\n",
      "The magnification : 2.00\n"
     ]
    }
   ],
   "source": [
    "p=30#in cm\n",
    "f=10#in cm\n",
    "x=(1/f)-(1/p)\n",
    "q=1/x\n",
    "\n",
    "M=-(q/p)\n",
    "print \"part a\"\n",
    "print \"The position of final image = %0.2f cm\"%q\n",
    "print \"The magnification : %0.2f\"%M\n",
    "p=5#in cm\n",
    "f=10#in cm\n",
    "x=(1/f)-(1/p)\n",
    "q=1/x\n",
    "M=-(q/p)\n",
    "print \"part b\"\n",
    "print \"The position of final image = %0.2f cm\"%q\n",
    "print \"The magnification : %0.2f\"%M"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 23.8 Page No: 778"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "part a\n",
      "The position of final image = -7.50 cm\n",
      "The magnification : 0.25\n",
      "part b\n",
      "The position of final image = -5.00 cm\n",
      "The magnification : 0.50\n",
      "part c\n",
      "The position of final image = -3.33 cm\n",
      "The magnification : 0.67\n"
     ]
    }
   ],
   "source": [
    "p=30#in cm\n",
    "f=-10#in cm\n",
    "x=(1/f)-(1/p)\n",
    "q=1/x\n",
    "\n",
    "M=-(q/p)\n",
    "print \"part a\"\n",
    "print \"The position of final image = %0.2f cm\"%q\n",
    "print \"The magnification : %0.2f\"%M\n",
    "p=10#in cm\n",
    "f=-10#in cm\n",
    "x=(1/f)-(1/p)\n",
    "q=1/x\n",
    "M=-(q/p)\n",
    "print \"part b\"\n",
    "print \"The position of final image = %0.2f cm\"%q\n",
    "print \"The magnification : %0.2f\"%M\n",
    "p=5#in cm\n",
    "f=-10#in cm\n",
    "x=(1/f)-(1/p)\n",
    "q=1/x\n",
    "M=-(q/p)\n",
    "print \"part c\"\n",
    "print \"The position of final image = %0.2f cm\"%q\n",
    "print \"The magnification : %0.2f\"%M"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 23.9 Page No: 779"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The magnification : -0.67\n"
     ]
    }
   ],
   "source": [
    "p=30#in cm\n",
    "f=10#in cm\n",
    "x=(1/f)-(1/p)\n",
    "q=1/x\n",
    "\n",
    "M1=-(q/p)\n",
    "\n",
    "p=5#in cm\n",
    "f=20#in cm\n",
    "x=(1/f)-(1/p)\n",
    "q=1/x\n",
    "\n",
    "M2=-(q/p)\n",
    "\n",
    "\n",
    "M=M1*M2\n",
    "print \"The magnification : %0.2f\"%M"
   ]
  }
 ],
 "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
}
