summaryrefslogtreecommitdiff
path: root/Higher_Engineering_Mathematics_by_B._S._Grewal/chapter4.ipynb
diff options
context:
space:
mode:
authorTrupti Kini2016-05-03 23:30:25 +0600
committerTrupti Kini2016-05-03 23:30:25 +0600
commit6142c8add48d9e8b4445d0693739e1fddb39d09f (patch)
tree3a239c80048fa82b06eb555796d60d9adfc27b79 /Higher_Engineering_Mathematics_by_B._S._Grewal/chapter4.ipynb
parent09174527d359bd85404d15d76fabd891c7e5ad6b (diff)
downloadPython-Textbook-Companions-6142c8add48d9e8b4445d0693739e1fddb39d09f.tar.gz
Python-Textbook-Companions-6142c8add48d9e8b4445d0693739e1fddb39d09f.tar.bz2
Python-Textbook-Companions-6142c8add48d9e8b4445d0693739e1fddb39d09f.zip
Added(A)/Deleted(D) following books
A Engineering_Thermodynamics_by_Dr._S._S._Khandare/README.txt A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter1.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter10.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter13.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter2.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter21.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter22.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter23.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter24.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter26.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter27.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter28.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter34.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter35.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter4.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter5.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter6.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/chapter9.ipynb A Higher_Engineering_Mathematics_by_B._S._Grewal/screenshots/screen1.png A Higher_Engineering_Mathematics_by_B._S._Grewal/screenshots/screen2.png A Higher_Engineering_Mathematics_by_B._S._Grewal/screenshots/screen3.png A sample_notebooks/ManikandanD/Chapter_2_Light_propagation_in_optical_fiber.ipynb
Diffstat (limited to 'Higher_Engineering_Mathematics_by_B._S._Grewal/chapter4.ipynb')
-rw-r--r--Higher_Engineering_Mathematics_by_B._S._Grewal/chapter4.ipynb1208
1 files changed, 1208 insertions, 0 deletions
diff --git a/Higher_Engineering_Mathematics_by_B._S._Grewal/chapter4.ipynb b/Higher_Engineering_Mathematics_by_B._S._Grewal/chapter4.ipynb
new file mode 100644
index 00000000..e40044d7
--- /dev/null
+++ b/Higher_Engineering_Mathematics_by_B._S._Grewal/chapter4.ipynb
@@ -0,0 +1,1208 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 4: Diffrentiations And Applications"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "## Example 4.1, page no. 133"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "We have to find yn for F=cosxcos2xcos3x\n",
+ "Enter the order of differentiation: 0\n",
+ "calculating yn..\n",
+ "The expression for yn is\n",
+ "cos(x)*cos(2*x)*cos(3*x)\n"
+ ]
+ }
+ ],
+ "source": [
+ "import sympy\n",
+ "import numpy\n",
+ "import math\n",
+ "\n",
+ "print \"We have to find yn for F=cosxcos2xcos3x\"\n",
+ "x = sympy.Symbol('x')\n",
+ "F = sympy.cos(x)*sympy.cos(2*x)*sympy.cos(3*x)\n",
+ "n = int(raw_input(\"Enter the order of differentiation: \"))\n",
+ "print \"calculating yn..\"\n",
+ "yn= sympy.diff(F,x,n)\n",
+ "print \"The expression for yn is\"\n",
+ "print yn "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.5, page no. 137"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "we have to find yn for F=cosxcos2xcos3x\n",
+ "Enter the order of differentiation: 0\n",
+ "calculating yn\n",
+ "The expression for yn is\n",
+ "x/((x - 1)*(2*x + 3))\n"
+ ]
+ }
+ ],
+ "source": [
+ "import sympy\n",
+ "\n",
+ "print 'we have to find yn for F=cosxcos2xcos3x'\n",
+ "x = sympy.Symbol('x')\n",
+ "F = x/((x-1)*(2*x+3))\n",
+ "n = int(raw_input(\"Enter the order of differentiation: \"))\n",
+ "print \"calculating yn\"\n",
+ "yn= sympy.diff(F,x,n)\n",
+ "print \"The expression for yn is\"\n",
+ "print yn"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.6, page no. 138"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 26,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "We have to find yn for F=cosxcos2xcos3x\n",
+ "Enter the orde of differentiation:0\n",
+ "calculating yn\n",
+ "the expression for yn is\n",
+ "x/(a**2 + x**2)\n"
+ ]
+ }
+ ],
+ "source": [
+ "import sympy\n",
+ "\n",
+ "print \"We have to find yn for F=cosxcos2xcos3x\"\n",
+ "x = sympy.Symbol('x')\n",
+ "a = sympy.Symbol('a')\n",
+ "F = x/(x**2+a**2)\n",
+ "n = raw_input (\"Enter the orde of differentiation:\")\n",
+ "print \"calculating yn\"\n",
+ "yn = diff(F,x,n)\n",
+ "print \"the expression for yn is\"\n",
+ "print yn"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.7, page no. 139"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 27,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "we have to find yn for F=cosxcos2xcos3x\n",
+ "Enter the order of differentiation: 0\n",
+ "calculating yn\n",
+ "the expression for yn is\n",
+ "2.71828182845905**x*(2*x + 3)**3\n"
+ ]
+ }
+ ],
+ "source": [
+ "import sympy, math\n",
+ "\n",
+ "print \"we have to find yn for F=cosxcos2xcos3x\"\n",
+ "x = sympy.Symbol('x')\n",
+ "a = sympy.Symbol('a')\n",
+ "F = math.e**(x)*(2*x+3)**3\n",
+ "n = raw_input (\"Enter the order of differentiation: \")\n",
+ "print \"calculating yn\"\n",
+ "yn = diff(F,x,n)\n",
+ "print \"the expression for yn is\"\n",
+ "print yn"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.8, page no. 139"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 20,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "y=(sinˆ-1)x) --sign inverse x\n",
+ "we have to prove (1-xˆ2)y(n+2)-(2n+1)xy(n+1)-nˆ2 yn\n",
+ "Calculating yn for various values of n\n",
+ "1\n",
+ "The expression for yn is\n",
+ "-6*x*(x*asin(x)/(-x**2 + 1)**(3/2) - 1/(x**2 - 1)) - 2*(a**2 + 1)*asin(x)/sqrt(-x**2 + 1) + 2*(-x**2 + 1)*(3*x**2*asin(x)/(-x**2 + 1)**(5/2) + 3*x/(x**2 - 1)**2 + asin(x)/(-x**2 + 1)**(3/2))\n",
+ "Which is equal to 0\n",
+ "2\n",
+ "The expression for yn is\n",
+ "-10*x*(3*x**2*asin(x)/(-x**2 + 1)**(5/2) + 3*x/(x**2 - 1)**2 + asin(x)/(-x**2 + 1)**(3/2)) - 2*(a**2 + 4)*(x*asin(x)/(-x**2 + 1)**(3/2) - 1/(x**2 - 1)) + 2*(-x**2 + 1)*(15*x**3*asin(x)/(-x**2 + 1)**(7/2) - 15*x**2/(x**2 - 1)**3 + 9*x*asin(x)/(-x**2 + 1)**(5/2) + 4/(x**2 - 1)**2)\n",
+ "Which is equal to 0\n",
+ "3\n",
+ "The expression for yn is\n",
+ "-14*x*(15*x**3*asin(x)/(-x**2 + 1)**(7/2) - 15*x**2/(x**2 - 1)**3 + 9*x*asin(x)/(-x**2 + 1)**(5/2) + 4/(x**2 - 1)**2) - 2*(a**2 + 9)*(3*x**2*asin(x)/(-x**2 + 1)**(5/2) + 3*x/(x**2 - 1)**2 + asin(x)/(-x**2 + 1)**(3/2)) + 2*(-x**2 + 1)*(105*x**4*asin(x)/(-x**2 + 1)**(9/2) + 105*x**3/(x**2 - 1)**4 + 90*x**2*asin(x)/(-x**2 + 1)**(7/2) - 55*x/(x**2 - 1)**3 + 9*asin(x)/(-x**2 + 1)**(5/2))\n",
+ "Which is equal to 0\n",
+ "4\n",
+ "The expression for yn is\n",
+ "-18*x*(105*x**4*asin(x)/(-x**2 + 1)**(9/2) + 105*x**3/(x**2 - 1)**4 + 90*x**2*asin(x)/(-x**2 + 1)**(7/2) - 55*x/(x**2 - 1)**3 + 9*asin(x)/(-x**2 + 1)**(5/2)) - 2*(a**2 + 16)*(15*x**3*asin(x)/(-x**2 + 1)**(7/2) - 15*x**2/(x**2 - 1)**3 + 9*x*asin(x)/(-x**2 + 1)**(5/2) + 4/(x**2 - 1)**2) + 2*(-x**2 + 1)*(945*x**5*asin(x)/(-x**2 + 1)**(11/2) - 945*x**4/(x**2 - 1)**5 + 1050*x**3*asin(x)/(-x**2 + 1)**(9/2) + 735*x**2/(x**2 - 1)**4 + 225*x*asin(x)/(-x**2 + 1)**(7/2) - 64/(x**2 - 1)**3)\n",
+ "Which is equal to 0\n",
+ "Hence Proved\n"
+ ]
+ }
+ ],
+ "source": [
+ "import sympy\n",
+ "\n",
+ "print 'y=(sinˆ-1)x) --sign inverse x'\n",
+ "x = sympy.Symbol('x')\n",
+ "a = sympy.Symbol('a')\n",
+ "y = (sympy.asin(x))**2;\n",
+ "print 'we have to prove (1-xˆ2)y(n+2)-(2n+1)xy(n+1)-nˆ2 yn'\n",
+ "print 'Calculating yn for various values of n'\n",
+ "for n in range(1,5):\n",
+ " F=(1-x**2)*sympy.diff(y,x,n+2)-(2*n+1)*x*sympy.diff(y,x,n+1)-(n**2+a**2)*sympy.diff(y,x,n)\n",
+ " print n\n",
+ " print 'The expression for yn is'\n",
+ " print F\n",
+ " print 'Which is equal to 0'\n",
+ "print 'Hence Proved'"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.9, page no. 140"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "y=eˆ(a(sinˆ-1)x))--sign inverse x\n",
+ "We have to prove (1-xˆ2)y(n+2)-(2n+1)xy(n+1)-(nˆ2+aˆ2)yn\n",
+ "Calculating yn for various values of n\n",
+ "1\n",
+ "The expression for yn is\n",
+ "-3.0*2.71828182845905**(a*asin(x))*a*x*(-a/(x**2 - 1) + x/(-x**2 + 1)**(3/2)) - 1.0*2.71828182845905**(a*asin(x))*a*(a**2 + 1)/sqrt(-x**2 + 1) + 2.71828182845905**(a*asin(x))*a*(-x**2 + 1)*(1.0*a**2/(-x**2 + 1)**(3/2) + 3.0*a*x/(x**2 - 1)**2 + 3.0*x**2/(-x**2 + 1)**(5/2) + 1.0/(-x**2 + 1)**(3/2))\n",
+ "Which is equal to 0\n",
+ "2\n",
+ "The expression for yn is\n",
+ "-5*2.71828182845905**(a*asin(x))*a*x*(1.0*a**2/(-x**2 + 1)**(3/2) + 3.0*a*x/(x**2 - 1)**2 + 3.0*x**2/(-x**2 + 1)**(5/2) + 1.0/(-x**2 + 1)**(3/2)) - 1.0*2.71828182845905**(a*asin(x))*a*(a**2 + 4)*(-a/(x**2 - 1) + x/(-x**2 + 1)**(3/2)) + 2.71828182845905**(a*asin(x))*a*(-x**2 + 1)*(1.0*a**3/(x**2 - 1)**2 + 6.0*a**2*x/(-x**2 + 1)**(5/2) - 15.0*a*x**2/(x**2 - 1)**3 + 4.0*a/(x**2 - 1)**2 + 15.0*x**3/(-x**2 + 1)**(7/2) + 9.0*x/(-x**2 + 1)**(5/2))\n",
+ "Which is equal to 0\n",
+ "3\n",
+ "The expression for yn is\n",
+ "-7*2.71828182845905**(a*asin(x))*a*x*(1.0*a**3/(x**2 - 1)**2 + 6.0*a**2*x/(-x**2 + 1)**(5/2) - 15.0*a*x**2/(x**2 - 1)**3 + 4.0*a/(x**2 - 1)**2 + 15.0*x**3/(-x**2 + 1)**(7/2) + 9.0*x/(-x**2 + 1)**(5/2)) - 2.71828182845905**(a*asin(x))*a*(a**2 + 9)*(1.0*a**2/(-x**2 + 1)**(3/2) + 3.0*a*x/(x**2 - 1)**2 + 3.0*x**2/(-x**2 + 1)**(5/2) + 1.0/(-x**2 + 1)**(3/2)) + 2.71828182845905**(a*asin(x))*a*(-x**2 + 1)*(1.0*a**4/(-x**2 + 1)**(5/2) - 10.0*a**3*x/(x**2 - 1)**3 + 45.0*a**2*x**2/(-x**2 + 1)**(7/2) + 10.0*a**2/(-x**2 + 1)**(5/2) + 105.0*a*x**3/(x**2 - 1)**4 - 55.0*a*x/(x**2 - 1)**3 + 105.0*x**4/(-x**2 + 1)**(9/2) + 90.0*x**2/(-x**2 + 1)**(7/2) + 9.0/(-x**2 + 1)**(5/2))\n",
+ "Which is equal to 0\n",
+ "4\n",
+ "The expression for yn is\n",
+ "-9*2.71828182845905**(a*asin(x))*a*x*(1.0*a**4/(-x**2 + 1)**(5/2) - 10.0*a**3*x/(x**2 - 1)**3 + 45.0*a**2*x**2/(-x**2 + 1)**(7/2) + 10.0*a**2/(-x**2 + 1)**(5/2) + 105.0*a*x**3/(x**2 - 1)**4 - 55.0*a*x/(x**2 - 1)**3 + 105.0*x**4/(-x**2 + 1)**(9/2) + 90.0*x**2/(-x**2 + 1)**(7/2) + 9.0/(-x**2 + 1)**(5/2)) - 2.71828182845905**(a*asin(x))*a*(a**2 + 16)*(1.0*a**3/(x**2 - 1)**2 + 6.0*a**2*x/(-x**2 + 1)**(5/2) - 15.0*a*x**2/(x**2 - 1)**3 + 4.0*a/(x**2 - 1)**2 + 15.0*x**3/(-x**2 + 1)**(7/2) + 9.0*x/(-x**2 + 1)**(5/2)) + 2.71828182845905**(a*asin(x))*a*(-x**2 + 1)*(-1.0*a**5/(x**2 - 1)**3 + 15.0*a**4*x/(-x**2 + 1)**(7/2) + 105.0*a**3*x**2/(x**2 - 1)**4 - 20.0*a**3/(x**2 - 1)**3 + 420.0*a**2*x**3/(-x**2 + 1)**(9/2) + 195.0*a**2*x/(-x**2 + 1)**(7/2) - 945.0*a*x**4/(x**2 - 1)**5 + 735.0*a*x**2/(x**2 - 1)**4 - 64.0*a/(x**2 - 1)**3 + 945.0*x**5/(-x**2 + 1)**(11/2) + 1050.0*x**3/(-x**2 + 1)**(9/2) + 225.0*x/(-x**2 + 1)**(7/2))\n",
+ "Which is equal to 0\n",
+ "Hence proved\n"
+ ]
+ }
+ ],
+ "source": [
+ "import sympy, math\n",
+ "\n",
+ "print 'y=eˆ(a(sinˆ-1)x))--sign inverse x'\n",
+ "x = sympy.Symbol('x')\n",
+ "a = sympy.Symbol('a')\n",
+ "y = math.e**(a*(sympy.asin(x)))\n",
+ "print 'We have to prove (1-xˆ2)y(n+2)-(2n+1)xy(n+1)-(nˆ2+aˆ2)yn'\n",
+ "print 'Calculating yn for various values of n'\n",
+ "for n in range(1,5):\n",
+ " F =(1-x**2)*sympy.diff(y,x,n+2)-(2*n+1)*x*sympy.diff(y,x,n+1)-(n**2+a**2)*sympy.diff(y,x,n)\n",
+ " print n\n",
+ " print 'The expression for yn is'\n",
+ " print F\n",
+ " print 'Which is equal to 0'\n",
+ "print 'Hence proved'\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.10, page no. 141"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "y^(1/m)+y^-(1/m)=2x\n",
+ "OR y^(2/m)-2xy^(1/m)+1\n",
+ "OR y=[ x+(xˆ2-1)]ˆm and y=[x-(xˆ2 −1)]ˆm\n",
+ "For y=[x+(xˆ2−1)]ˆm\n",
+ "We have to prove (xˆ2−1)y(n+2)+(2n+1)xy(n+1)+(nˆ2−mˆ2)yn\n",
+ "Calculating various values for yn\n",
+ "1\n",
+ "The expression for yn is\n",
+ "3*m*x*(x**2 + x - 1)**m*(m*(2*x + 1)**2/(x**2 + x - 1) - (2*x + 1)**2/(x**2 + x - 1) + 2)/(x**2 + x - 1) + m*(-m**2 + 1)*(2*x + 1)*(x**2 + x - 1)**m/(x**2 + x - 1) + m*(2*x + 1)*(x**2 - 1)*(x**2 + x - 1)**m*(m**2*(2*x + 1)**2/(x**2 + x - 1) - 3*m*(2*x + 1)**2/(x**2 + x - 1) + 6*m + 2*(2*x + 1)**2/(x**2 + x - 1) - 6)/(x**2 + x - 1)**2\n",
+ "Which is equal to 0\n",
+ "2\n",
+ "The expression for yn is\n",
+ "5*m*x*(2*x + 1)*(x**2 + x - 1)**m*(m**2*(2*x + 1)**2/(x**2 + x - 1) - 3*m*(2*x + 1)**2/(x**2 + x - 1) + 6*m + 2*(2*x + 1)**2/(x**2 + x - 1) - 6)/(x**2 + x - 1)**2 + m*(-m**2 + 4)*(x**2 + x - 1)**m*(m*(2*x + 1)**2/(x**2 + x - 1) - (2*x + 1)**2/(x**2 + x - 1) + 2)/(x**2 + x - 1) + m*(x**2 - 1)*(x**2 + x - 1)**m*(m**3*(2*x + 1)**4/(x**2 + x - 1)**2 - 6*m**2*(2*x + 1)**4/(x**2 + x - 1)**2 + 12*m**2*(2*x + 1)**2/(x**2 + x - 1) + 11*m*(2*x + 1)**4/(x**2 + x - 1)**2 - 36*m*(2*x + 1)**2/(x**2 + x - 1) + 12*m - 6*(2*x + 1)**4/(x**2 + x - 1)**2 + 24*(2*x + 1)**2/(x**2 + x - 1) - 12)/(x**2 + x - 1)**2\n",
+ "Which is equal to 0\n",
+ "3\n",
+ "The expression for yn is\n",
+ "7*m*x*(x**2 + x - 1)**m*(m**3*(2*x + 1)**4/(x**2 + x - 1)**2 - 6*m**2*(2*x + 1)**4/(x**2 + x - 1)**2 + 12*m**2*(2*x + 1)**2/(x**2 + x - 1) + 11*m*(2*x + 1)**4/(x**2 + x - 1)**2 - 36*m*(2*x + 1)**2/(x**2 + x - 1) + 12*m - 6*(2*x + 1)**4/(x**2 + x - 1)**2 + 24*(2*x + 1)**2/(x**2 + x - 1) - 12)/(x**2 + x - 1)**2 + m*(-m**2 + 9)*(2*x + 1)*(x**2 + x - 1)**m*(m**2*(2*x + 1)**2/(x**2 + x - 1) - 3*m*(2*x + 1)**2/(x**2 + x - 1) + 6*m + 2*(2*x + 1)**2/(x**2 + x - 1) - 6)/(x**2 + x - 1)**2 + m*(2*x + 1)*(x**2 - 1)*(x**2 + x - 1)**m*(m**4*(2*x + 1)**4/(x**2 + x - 1)**2 - 10*m**3*(2*x + 1)**4/(x**2 + x - 1)**2 + 20*m**3*(2*x + 1)**2/(x**2 + x - 1) + 35*m**2*(2*x + 1)**4/(x**2 + x - 1)**2 - 120*m**2*(2*x + 1)**2/(x**2 + x - 1) + 60*m**2 - 50*m*(2*x + 1)**4/(x**2 + x - 1)**2 + 220*m*(2*x + 1)**2/(x**2 + x - 1) - 180*m + 24*(2*x + 1)**4/(x**2 + x - 1)**2 - 120*(2*x + 1)**2/(x**2 + x - 1) + 120)/(x**2 + x - 1)**3\n",
+ "Which is equal to 0\n",
+ "4\n",
+ "The expression for yn is\n",
+ "9*m*x*(2*x + 1)*(x**2 + x - 1)**m*(m**4*(2*x + 1)**4/(x**2 + x - 1)**2 - 10*m**3*(2*x + 1)**4/(x**2 + x - 1)**2 + 20*m**3*(2*x + 1)**2/(x**2 + x - 1) + 35*m**2*(2*x + 1)**4/(x**2 + x - 1)**2 - 120*m**2*(2*x + 1)**2/(x**2 + x - 1) + 60*m**2 - 50*m*(2*x + 1)**4/(x**2 + x - 1)**2 + 220*m*(2*x + 1)**2/(x**2 + x - 1) - 180*m + 24*(2*x + 1)**4/(x**2 + x - 1)**2 - 120*(2*x + 1)**2/(x**2 + x - 1) + 120)/(x**2 + x - 1)**3 + m*(-m**2 + 16)*(x**2 + x - 1)**m*(m**3*(2*x + 1)**4/(x**2 + x - 1)**2 - 6*m**2*(2*x + 1)**4/(x**2 + x - 1)**2 + 12*m**2*(2*x + 1)**2/(x**2 + x - 1) + 11*m*(2*x + 1)**4/(x**2 + x - 1)**2 - 36*m*(2*x + 1)**2/(x**2 + x - 1) + 12*m - 6*(2*x + 1)**4/(x**2 + x - 1)**2 + 24*(2*x + 1)**2/(x**2 + x - 1) - 12)/(x**2 + x - 1)**2 + m*(x**2 - 1)*(x**2 + x - 1)**m*(m**5*(2*x + 1)**6/(x**2 + x - 1)**3 - 15*m**4*(2*x + 1)**6/(x**2 + x - 1)**3 + 30*m**4*(2*x + 1)**4/(x**2 + x - 1)**2 + 85*m**3*(2*x + 1)**6/(x**2 + x - 1)**3 - 300*m**3*(2*x + 1)**4/(x**2 + x - 1)**2 + 180*m**3*(2*x + 1)**2/(x**2 + x - 1) - 225*m**2*(2*x + 1)**6/(x**2 + x - 1)**3 + 1050*m**2*(2*x + 1)**4/(x**2 + x - 1)**2 - 1080*m**2*(2*x + 1)**2/(x**2 + x - 1) + 120*m**2 + 274*m*(2*x + 1)**6/(x**2 + x - 1)**3 - 1500*m*(2*x + 1)**4/(x**2 + x - 1)**2 + 1980*m*(2*x + 1)**2/(x**2 + x - 1) - 360*m - 120*(2*x + 1)**6/(x**2 + x - 1)**3 + 720*(2*x + 1)**4/(x**2 + x - 1)**2 - 1080*(2*x + 1)**2/(x**2 + x - 1) + 240)/(x**2 + x - 1)**3\n",
+ "Which is equal to 0\n",
+ "Hence Proved\n"
+ ]
+ }
+ ],
+ "source": [
+ "import sympy\n",
+ "\n",
+ "print 'y^(1/m)+y^-(1/m)=2x'\n",
+ "print 'OR y^(2/m)-2xy^(1/m)+1'\n",
+ "print 'OR y=[ x+(xˆ2-1)]ˆm and y=[x-(xˆ2 −1)]ˆm'\n",
+ "x = sympy.Symbol('x')\n",
+ "m = sympy.Symbol('m')\n",
+ "print 'For y=[x+(xˆ2−1)]ˆm'\n",
+ "y=(x+(x**2-1))**m\n",
+ "print 'We have to prove (xˆ2−1)y(n+2)+(2n+1)xy(n+1)+(nˆ2−mˆ2)yn'\n",
+ "print 'Calculating various values for yn'\n",
+ "for n in range(1,5):\n",
+ " F=(x**2-1)*sympy.diff(y,x,n+2)+(2*n+1)*x*sympy.diff(y,x,n+1)+(n**2-m**2)*sympy.diff(y,x,n)\n",
+ " print n\n",
+ " print 'The expression for yn is'\n",
+ " print F\n",
+ " print 'Which is equal to 0'\n",
+ "print 'Hence Proved'"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.11, page no. 144"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false,
+ "scrolled": true
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "For roles theorem F9x should be differentiable in (a, b) and f(a)=f(b)\n",
+ "Here f(x)=sin(x)/e^x\n",
+ "-1.0*2.71828182845905**(-x)*sin(x) + 2.71828182845905**(-x)*cos(x)\n",
+ "Putting this to zero we get tan(x)=1 ie x=pi/4\n",
+ "Value pi/2 lies b/w 0 and pi. Hence roles theroem is verified\n"
+ ]
+ }
+ ],
+ "source": [
+ "import sympy, math\n",
+ "\n",
+ "print 'For roles theorem F9x should be differentiable in (a, b) and f(a)=f(b)'\n",
+ "print 'Here f(x)=sin(x)/e^x'\n",
+ "x = sympy.Symbol('x')\n",
+ "y = sympy.sin(x)/math.e**x\n",
+ "y1 = sympy.diff(y,x)\n",
+ "print y1\n",
+ "print 'Putting this to zero we get tan(x)=1 ie x=pi/4'\n",
+ "print 'Value pi/2 lies b/w 0 and pi. Hence roles theroem is verified'"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.16 page no. 149"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 56,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Maclaurin's Series\n",
+ "f(x)=f(0)+xf1(0)+xˆ2/2!∗f2(0)+xˆ3/3!∗f3(0)+......\n",
+ "Enter the orde of differentiation: 6\n",
+ "-I*x**5*atanh(sqrt(-sqrt(105)/30 + 1/2))/120 - I*x**3*atanh(sqrt(3)/3)/6\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy, sympy, math\n",
+ "\n",
+ "print \"Maclaurin's Series\"\n",
+ "print 'f(x)=f(0)+xf1(0)+xˆ2/2!∗f2(0)+xˆ3/3!∗f3(0)+......'\n",
+ "x = sympy.Symbol('x')\n",
+ "a = sympy.Symbol('a')\n",
+ "y = sympy.tan(a)\n",
+ "n = int(raw_input(\"Enter the orde of differentiation: \"))\n",
+ "a = 1\n",
+ "t = sympy.solve(y)[0]\n",
+ "a = 0\n",
+ "for i in range(2,n+1):\n",
+ " y1 = sympy.diff (y,'a',i-1)\n",
+ " if sympy.solve(y1):\n",
+ " t = t+x**(i-1)*sympy.solve(y1)[0]/math.factorial(i-1)\n",
+ "print t"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.17, page no. 150"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Maclaurins series\n",
+ "f(x)=f(0)+xf1(0)+xˆ2/2!∗f2(0)+xˆ3/3!∗f3(0)+......\n",
+ "enter the number of expression in series:2\n",
+ "1.5707963267949*x\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy,sympy,math\n",
+ "\n",
+ "print \"Maclaurins series\"\n",
+ "print \"f(x)=f(0)+xf1(0)+xˆ2/2!∗f2(0)+xˆ3/3!∗f3(0)+......\"\n",
+ "x = sympy.Symbol('x')\n",
+ "a = sympy.Symbol('a')\n",
+ "y = math.e**(sympy.sin(a))\n",
+ "n = int(raw_input('enter the number of expression in series:'))\n",
+ "a = 0\n",
+ "t = 0\n",
+ "a = 0\n",
+ "for i in range(2,n+1):\n",
+ " y1 = sympy.diff(y,'a',i-1) \n",
+ " t = t+x**(i-1)*sympy.solve(y1)[0]/math.factorial(i-1) \n",
+ "print t"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "## Example 4.18, page no. 150"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Maclaurins series\n",
+ "f(x)=f(0)+xf1(0)+xˆ2/2!∗f2(0)+xˆ3/3!∗f3(0)+......\n",
+ "enter the number of differentiation involved in maclaurins series :3\n",
+ "x**2*atan(RootOf(tan(a/2)**4 - 10*tan(a/2)**2 + 1, 0))\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy,sympy,math\n",
+ "\n",
+ "print \"Maclaurins series\"\n",
+ "print \"f(x)=f(0)+xf1(0)+xˆ2/2!∗f2(0)+xˆ3/3!∗f3(0)+......\"\n",
+ "x = sympy.Symbol('x')\n",
+ "a = sympy.Symbol('a')\n",
+ "y = sympy.log(1+(sympy.sin(a))**2)\n",
+ "n = int(raw_input(\"enter the number of differentiation involved in maclaurins series :\"))\n",
+ "a = 0\n",
+ "t = 0\n",
+ "a = 0\n",
+ "for i in range(2,n+1):\n",
+ " y1 = sympy.diff(y,'a',i-1) \n",
+ " t = t+x**(i-1)*sympy.solve(y1)[0]/math.factorial(i-1) \n",
+ "print t"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "collapsed": true
+ },
+ "source": [
+ "## Example 4.19, page no. 151"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 33,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Maclaurins series\n",
+ "f(x)=f(0)+xf1(0)+xˆ2/2!∗f2(0)+xˆ3/3!∗f3(0)+......\n",
+ "enter the number of expression in series :2\n",
+ "1.0*2.71828182845905**(a*asin(b))*a*x*(-b**2 + 1.0)**(-0.5)\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy,sympy,math\n",
+ "\n",
+ "print \"Maclaurins series\"\n",
+ "print \"f(x)=f(0)+xf1(0)+xˆ2/2!∗f2(0)+xˆ3/3!∗f3(0)+......\"\n",
+ "x = sympy.Symbol('x')\n",
+ "a = sympy.Symbol('a')\n",
+ "b = sympy.Symbol('b')\n",
+ "y = math.e**(a*sympy.asin(b))\n",
+ "y1 = sympy.diff(y, 'b', 1)\n",
+ "n = int(raw_input(\"enter the number of expression in series :\"))\n",
+ "b = 0\n",
+ "t = 0\n",
+ "for i in range(2,n+1):\n",
+ " y1 = sympy.diff(y,'b',i-1) \n",
+ " t = t+x**(i-1)*y1.evalf()/math.factorial(i-1) \n",
+ "print t"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.20, page no. 152"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Advantage of scilab is that we can calculate log1.1 directly without using Taylor series\n",
+ "Use of taylor series are given in subsequent examples\n",
+ "log(1.1) = 0.0953101798043\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy,math,sympy\n",
+ "\n",
+ "print \"Use of taylor series are given in subsequent examples\"\n",
+ "y = math.log(1.1)\n",
+ "print \"log(1.1) = \",math.log (1.1) "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.21, page no. 152"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 29,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Taylor series\n",
+ "f(x+h)=f(x)+hf1(x)+hˆ2/2!∗f2(x)+hˆ3/3!∗f3(x)+......\n",
+ "To finf the taylor expansion of tan−1(x+h)\n",
+ "enter the number of expression in series : 2\n",
+ "h/(x**2 + 1) + atan(x)\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy,sympy,math\n",
+ "\n",
+ "print \"Taylor series\"\n",
+ "print \"f(x+h)=f(x)+hf1(x)+hˆ2/2!∗f2(x)+hˆ3/3!∗f3(x)+......\"\n",
+ "print \"To finf the taylor expansion of tan−1(x+h)\"\n",
+ "x = sympy.Symbol('x')\n",
+ "h = sympy.Symbol('h')\n",
+ "y = sympy.atan ( x )\n",
+ "n = int(raw_input (\"enter the number of expression in series : \"))\n",
+ "t = y \n",
+ "for i in range (2,n+1):\n",
+ " y1 = sympy.diff (y,'x',i-1)\n",
+ " t = t+h**(i-1)*(y1)/math.factorial(i-1)\n",
+ "print t"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.22, page no. 153"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 38,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Here we need to find the limit off(x) at x=0\n",
+ "2.46828182845905\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy,sympy,math\n",
+ "\n",
+ "print \"Here we need to find the limit off(x) at x=0\"\n",
+ "x = sympy.Symbol('x')\n",
+ "y = (x*math.e**x-sympy.log(1+x))/x**2\n",
+ "f = 1\n",
+ "while f==1:\n",
+ " yn = x*math.e**x-sympy.log(1+x)\n",
+ " yd = x**2;\n",
+ " yn1 = sympy.diff(yn,'x',1)\n",
+ " yd1 = sympy.diff(yd,'x',1)\n",
+ " x = 0\n",
+ " a = yn1.evalf(subs=dict(x=1))\n",
+ " b = yd1.evalf(subs=dict(x=1))\n",
+ " if a == b:\n",
+ " yn = yn1 \n",
+ " yd = yd1 \n",
+ " else:\n",
+ " f =0\n",
+ "h = a / b \n",
+ "print h"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.32, page no. 162"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Equation of tangent\n",
+ "Equation is g=0 where g is x - y\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy,sympy,math\n",
+ "\n",
+ "print \"Equation of tangent\"\n",
+ "x = sympy.Symbol('x')\n",
+ "a = sympy.Symbol('a')\n",
+ "y = sympy.Symbol('y')\n",
+ "f = (a**(2/3)-x**(2/3))**(3/2)\n",
+ "s = sympy.diff(f,x)\n",
+ "Y1 = s*(-x)+y\n",
+ "X1 = -y/s*x\n",
+ "g = x-(Y1-s*(X1-x))\n",
+ "print \"Equation is g=0 where g is\",g"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example, 4.34, page no. 163"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Equation of tangent\n",
+ "y = a*(-t*cos(t) + sin(t)) + (-a*(t*sin(t) + cos(t)) + x)*cos(t)/sin(t)\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy,sympy,math\n",
+ "\n",
+ "print \"Equation of tangent\"\n",
+ "x = sympy.Symbol('x')\n",
+ "a = sympy.Symbol('a')\n",
+ "y = sympy.Symbol('y')\n",
+ "t = sympy.Symbol('t')\n",
+ "xo = a*(sympy.cos(t)+t*sympy.sin(t))\n",
+ "yo = a*(sympy.sin(t)-t*sympy.cos(t))\n",
+ "s = sympy.diff(xo,t)/sympy.diff(yo,t)\n",
+ "y = yo+s*(x-xo)\n",
+ "print \"y = \",y"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.35, page no. 163"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 32,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The two given curves are xˆ=4y and yˆ2=4x which intersects at (0,0) and (4,4)\n",
+ "for (4 ,4)\n",
+ "Angle between them is (radians):−\n",
+ "atan(x/2)\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy,sympy,math\n",
+ "\n",
+ "print \"The two given curves are xˆ=4y and yˆ2=4x which intersects at (0,0) and (4,4)\"\n",
+ "print \"for (4 ,4)\"\n",
+ "x = 4\n",
+ "x = sympy.Symbol('x')\n",
+ "y1= x**2/4\n",
+ "y2 = 2*x**(1/2)\n",
+ "m1= sympy.diff(y1,x,1)\n",
+ "m2= sympy.diff(y2,x,1)\n",
+ "x = 4\n",
+ "print \"Angle between them is (radians):−\"\n",
+ "t= sympy.atan((m1-m2)/(1+m1*m2)) \n",
+ "print t"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.37, page no. 165"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 50,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "length of tangent\n",
+ "a*(((tan(t/2)**2/2 + 1/2)/tan(t/2) - sin(t))/cos(t) + 1)**0.5*sin(t)\n",
+ "checking for its dependency on t\n",
+ "verified and equal to a\n",
+ "subtangent\n",
+ "a*sin(t)*cos(t)/((tan(t/2)**2/2 + 1/2)/tan(t/2) - sin(t))\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy,sympy,math\n",
+ "\n",
+ "a = sympy.Symbol('a')\n",
+ "t = sympy.Symbol('t')\n",
+ "x = a*(sympy.cos(t)+sympy.log(sympy.tan(t/2)))\n",
+ "y = a*sympy.sin(t)\n",
+ "s = sympy.diff(x,t,1)/sympy.diff(y,t,1)\n",
+ "print \"length of tangent\"\n",
+ "l = y*(1+s)**(0.5)\n",
+ "print l\n",
+ "print \"checking for its dependency on t\"\n",
+ "f = 1\n",
+ "t = 0\n",
+ "k = sympy.solve(l)\n",
+ "for i in range(1,11):\n",
+ " t = i\n",
+ " if(sympy.solve(l)!=k):\n",
+ " f = 0\n",
+ "if(f==1):\n",
+ " print \"verified and equal to a\"\n",
+ "print \"subtangent\"\n",
+ "m = y/s\n",
+ "print m"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.39, page no. 168"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 39,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Angle of intersection\n",
+ "point of intersection of r=sint+cost and r=2 sint is t=pi/4\n",
+ "tanu=dQ/dr∗r\n",
+ "The angle at point of intersection in radians is : \n",
+ "atan(2*(-sin(Q) + cos(Q))*sin(Q))\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy,sympy,math\n",
+ "\n",
+ "print \"Angle of intersection\"\n",
+ "print \"point of intersection of r=sint+cost and r=2 sint is t=pi/4\"\n",
+ "print \"tanu=dQ/dr∗r\"\n",
+ "Q = sympy.Symbol('Q')\n",
+ "r1 = 2*sympy.sin(Q)\n",
+ "r2 = sympy.sin(Q)+sympy.cos(Q)\n",
+ "u = sympy.atan(r1*sympy.diff(r2,Q,1))\n",
+ "Q = math.pi/4\n",
+ "u = u.evalf()\n",
+ "print \"The angle at point of intersection in radians is : \"\n",
+ "print u"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.41, page no. 170"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 41,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "tanu=dQ/dr∗r\n",
+ "atan(2*a/((-sin(Q) + cos(Q))*(-cos(Q) + 1)))\n",
+ "4.0*a**2*(4.0*a**2/((-sin(Q) + cos(Q))**2*(-cos(Q) + 1.0)**2) + 1.0)**(-0.5)/((-sin(Q) + cos(Q))*(-cos(Q) + 1.0)**2)\n"
+ ]
+ }
+ ],
+ "source": [
+ "import sympy,math\n",
+ "\n",
+ "print \"tanu=dQ/dr∗r\"\n",
+ "Q = sympy.Symbol('Q')\n",
+ "a = sympy.Symbol('a')\n",
+ "r = 2*a/(1-sympy.cos(Q))\n",
+ "u = sympy.atan(r/sympy.diff(r2,Q,1))\n",
+ "u = u.evalf()\n",
+ "print u\n",
+ "p = r*sympy.sin(u)\n",
+ "r = sympy.Symbol('r')\n",
+ "Q = sympy.acos(1-2*a/r)\n",
+ "p = p.evalf()\n",
+ "print p"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.43, page no. 172"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 19,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The radius of curvature is : -(1 + sin(t)**2/(cos(t) + 1)**2)*sin(t)/cos(t)\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy,sympy,math\n",
+ "\n",
+ "a = sympy.Symbol('a')\n",
+ "t = sympy.Symbol('t')\n",
+ "x = a*(t+sympy.sin(t))\n",
+ "y = a*(1-sympy.cos(t))\n",
+ "s2 = sympy.diff(y,t,2)/sympy.diff(x,t,2)\n",
+ "s1 = sympy.diff(y,t,1)/sympy.diff(x,t,1)\n",
+ "r = (1+s1**2)**(3/2)/s2\n",
+ "print \"The radius of curvature is :\",r"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.46, page no. 176"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 42,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "radius of curvature\n",
+ "(a**2*(-cos(t) + 1.0)**2 + a**2*sin(t)**2)/(a**2*(-cos(t) + 1.0)**2 - a**2*(-cos(t) + 1.0)*sin(t) + 2.0*a**2*sin(t)**2)\n",
+ "Which is proportional to rˆ0.5\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy,sympy,math\n",
+ "\n",
+ "print \"radius of curvature\"\n",
+ "a = sympy.Symbol('a')\n",
+ "t = sympy.Symbol('t')\n",
+ "r = a*(1-sympy.cos(t))\n",
+ "r1 = sympy.diff(r,t,1) \n",
+ "l = (r**2+r1**2)**(3/2)/(r**2+2*r1**2-r*r1)\n",
+ "r = sympy.Symbol('r')\n",
+ "t = sympy.acos(1-r/a)\n",
+ "l = l.evalf()\n",
+ "print l\n",
+ "print \"Which is proportional to rˆ0.5\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.47, page no. 177"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 21,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The centre of curvature\n",
+ "the coordinates x,y are resp : \n",
+ "2.0*x*(1 + 1.0*(a*x)**0.5/x)**2 + x\n",
+ "-2.0*x**2*(a*x)**(-0.5)*(1 + 1.0*(a*x)**1.0/x**2) + 2*(a*x)**0.5\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy,sympy,math\n",
+ "\n",
+ "print \"The centre of curvature\"\n",
+ "x = sympy.Symbol('x')\n",
+ "a = sympy.Symbol('a')\n",
+ "y = sympy.Symbol('y')\n",
+ "y = 2*(a*x)**0.5\n",
+ "y1 = sympy.diff(y,x,1)\n",
+ "y2 = sympy.diff(y,x,2)\n",
+ "xx = x-y1*(1+y1)**2/y2\n",
+ "yy = y+(1+y1**2)/y2\n",
+ "print \"the coordinates x,y are resp : \"\n",
+ "print xx\n",
+ "print yy"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Examle 4.48, page no. 177"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "centre of curvature of given cycloid\n",
+ "the coordinates x,y are resp : \n",
+ "a*(t - sin(t)) - (a*sin(t) + 1)**2*sin(t)/cos(t)\n",
+ "a*(-cos(t) + 1) + (a**2*sin(t)**2 + 1)/(a*cos(t))\n",
+ "which another parametric equation of cycloid\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy,sympy,math\n",
+ "\n",
+ "print \"centre of curvature of given cycloid\"\n",
+ "a = sympy.Symbol('a')\n",
+ "t = sympy.Symbol('t')\n",
+ "x = a*(t-sympy.sin(t))\n",
+ "y = a*(1-sympy.cos(t))\n",
+ "y1 = sympy.diff(y,t,1)\n",
+ "y2 = sympy.diff(y,t,2)\n",
+ "xx = x-y1*(1+y1)**2/y2 \n",
+ "yy = y+(1+y1**2)/y2\n",
+ "print \"the coordinates x,y are resp : \"\n",
+ "print xx\n",
+ "print yy\n",
+ "print \"which another parametric equation of cycloid\""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.52, page no. 180"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 42,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "To find the maxima and minima of given function put f1(x)=0\n",
+ "[-1, 1/2, 1]\n"
+ ]
+ }
+ ],
+ "source": [
+ "import sympy\n",
+ "print 'To find the maxima and minima of given function put f1(x)=0'\n",
+ "x = sympy.Symbol('x')\n",
+ "f=3*x**4-2*x**3-6*x**2+6*x+1\n",
+ "k = sympy.diff(f,x)\n",
+ "x = sympy.poly(0,x)\n",
+ "k = sympy.solve(k)\n",
+ "print k"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 4.61, page no. 188"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 49,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "to find the assymptote of given curve\n",
+ "assymptotes parallel to x−axis is given by f1=0 where f1 is : \n",
+ "[1, -1, -1, 1, 1, 1]\n",
+ "assymptotes parallel to y−axis is given by f 2=0 and f2 is : \n",
+ "x**2*y**2 - x**2*y - x*y**2 + x + y + 1\n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy,sympy,math\n",
+ "\n",
+ "print \"to find the assymptote of given curve\"\n",
+ "x = sympy.Symbol('x')\n",
+ "y = sympy.Symbol('y')\n",
+ "f = x**2*y**2-x**2*y-x*y**2+x+y+1\n",
+ "f1 = sympy.poly(f,y,x)\n",
+ "f1 = f1.coeffs()\n",
+ "print \"assymptotes parallel to x−axis is given by f1=0 where f1 is : \"\n",
+ "print sympy.factor(f1)\n",
+ "f2 = sympy.poly(f,y,x)\n",
+ "print \"assymptotes parallel to y−axis is given by f 2=0 and f2 is : \"\n",
+ "print sympy.factor(f2)"
+ ]
+ }
+ ],
+ "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.10"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}