summaryrefslogtreecommitdiff
path: root/sample_notebooks/KonasaniSai Dheeraj/sample_(chapter.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'sample_notebooks/KonasaniSai Dheeraj/sample_(chapter.ipynb')
-rwxr-xr-xsample_notebooks/KonasaniSai Dheeraj/sample_(chapter.ipynb256
1 files changed, 256 insertions, 0 deletions
diff --git a/sample_notebooks/KonasaniSai Dheeraj/sample_(chapter.ipynb b/sample_notebooks/KonasaniSai Dheeraj/sample_(chapter.ipynb
new file mode 100755
index 00000000..58372eed
--- /dev/null
+++ b/sample_notebooks/KonasaniSai Dheeraj/sample_(chapter.ipynb
@@ -0,0 +1,256 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Chapter 6 : FORMULAE"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6_1 pgno:69"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "expr=8*i-5\n",
+ "the number is 16\n"
+ ]
+ }
+ ],
+ "source": [
+ " #8 times a number is decreased by 5 the result is 123\n",
+ "#let x be the number\n",
+ "\n",
+ "print'expr=8*i-5'\n",
+ "x=0;\n",
+ "for x in range(0,100):\n",
+ " if((8*x-5)==123):\n",
+ " print\"the number is \",x\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6_2 pgno:71"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "expr=(2*n+1)+(2*n+3)+(2*n+5)\n",
+ "n=%i \n",
+ "12\n",
+ "\n",
+ " the numbers are 199 201 203\n"
+ ]
+ }
+ ],
+ "source": [
+ "#sum of 3 consecutive odd no.'s is 81\n",
+ "\n",
+ "#let the 3 consecutive odd numbers be 2n+1,2n+3,2n+5\n",
+ "\n",
+ "print\"expr=(2*n+1)+(2*n+3)+(2*n+5)\"\n",
+ "n=0;\n",
+ "for n in range(0,100):\n",
+ " if((2*n+1)+(2*n+3)+(2*n+5)==81):\n",
+ " print\"n=%i \\n\",n \n",
+ "\n",
+ "n1=2*n+1;\n",
+ "n2=2*n+3;\n",
+ "n3=2*n+5;\n",
+ "print\"\\n the numbers are \",n1,n2,n3\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6_3 pgno:72"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "p1=(6*x-5)\n",
+ "p2=(2*x+9)\n",
+ "p3=p1-p2\n",
+ "satisfies the equation \n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy\n",
+ "print\"p1=(6*x-5)\"\n",
+ "p1=numpy.array([6, -5])\n",
+ "print\"p2=(2*x+9)\"\n",
+ "p2=numpy.array([2, 9])\n",
+ "print\"p3=p1-p2\"\n",
+ "p3=p1-p2\n",
+ "\n",
+ "x1=numpy.roots(p3)\n",
+ "left=6*x1-5; #check by substituion \n",
+ "right=2*x1+9;\n",
+ "if(left==right):\n",
+ "\tprint'satisfies the equation '\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6_4 pgno:73"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "x is a polynomial function\n",
+ "by the law of sighs roots are [ 3.]\n"
+ ]
+ }
+ ],
+ "source": [
+ "print\"x is a polynomial function\"\n",
+ "import numpy\n",
+ "p1=numpy.array([3/5+1/2, 0])\n",
+ "p2=numpy.array([5/4, -3])\n",
+ "#p1=3*x/5+x/2;\n",
+ "#p2=5*x/4-3;\n",
+ "p3=p1-p2;\n",
+ "x=numpy.roots(p3) #by the law of signs\n",
+ "print\"by the law of sighs roots are\",x\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Example 6_5 pgno:75"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "p1=4*x-(x-2)/3\n",
+ "p2=5+(2*x+1)/4\n",
+ "p3=p1-p2\n",
+ "satisfies the equation \n"
+ ]
+ }
+ ],
+ "source": [
+ "import numpy\n",
+ "print\"p1=4*x-(x-2)/3\"\n",
+ "p1=numpy.array([11/3, 2/3])\n",
+ "print\"p2=5+(2*x+1)/4\"\n",
+ "p2=numpy.array([1/2, 21/4])\n",
+ "print\"p3=p1-p2\"\n",
+ "p3=p1-p2\n",
+ "\n",
+ "x=numpy.roots(p3)\n",
+ "left=4*x-(x-2)/3; #check by substituion \n",
+ "right=5+(2*x+1)/4;\n",
+ "if(left != right):\n",
+ "\tprint'satisfies the equation '\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "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
+}