{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "heading", "level": 1, "metadata": {}, "source": [ "Chapter 6:Particle in a box" ] }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example no:1,Page no:202" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Variable declaration\n", "L=1.0\n", "x0=L/3.0 \n", "x1=2*L/3.0 \n", "\n", "\n", "#calculation\n", "import math\n", "from scipy import integrate\n", "def f(x):\n", " w=math.sqrt(2/L)*math.sin(math.pi*x/L)\n", " return(w**2)\n", "P=integrate.quad(f,x0,x1)\n", "\n", "#Result\n", "print\"The required probability =\",round(P[0],2)\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The required probability = 0.61\n" ] } ], "prompt_number": 31 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ "Example no:2,Page no:202" ] }, { "cell_type": "code", "collapsed": false, "input": [ "#Variable declaration\n", "L=1.0 \n", "x0=0.0 \n", "x1=L/3.0 \n", "y0=0.0 \n", "y1=L/3.0 \n", "\n", "#Calculation\n", "from scipy.integrate import dblquad\n", "import numpy as np\n", "def f(x,y):\n", "#w=(2.0/L)*(np.sin(np.pi*x/L))*(np.sin(np.pi*y/L))\n", " return((1-np.cos(2*np.pi*x/L))*(1-np.cos(2*np.pi*y/L))) \n", "\n", "p=dblquad(f,x0,x1,lambda y:0,lambda y:L/3.0)\n", "\n", "#Result\n", "print\"The required probability = \",round(p[0],3)\n", "print\"NOTE:Wrong answer in book\"\n" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "The required probability = 0.038\n", "NOTE:Wrong answer in book\n" ] } ], "prompt_number": 66 } ], "metadata": {} } ] }