Chapter 13 Graphs of Quardratic Functions

Example 13_1 pgno:148

In [1]:
#circumference of circle
print ('C=2*pi*r')
#C-length of circumference.r-the length of radius
#2 (2,pi) of these 4 symbols represent constants .
print ("the variation of C depends on changes in r")
C=2*pi*r
the variation of C depends on changes in r

Example 13_2 pgno:148

In [2]:
#let a-the avg. amount paid. x-no. of customers.  b-the expenses
#net profit is y=ax-b
x=320.;y=4.50;
x=250.;y=1.00;


import numpy
import matplotlib
from matplotlib import pyplot
%matplotlib inline

#substitute in above equation
#4.5=320*a-b-equ.1;1=250*a-b-equ.2.subbstract equ.2 from 1.
a=0.05;#we get
b=250*a-1;
x = ('x')
y='a*x-b';#equation to straight line
#if there is no profit i.e., y=0
x=0;
for x in range(1,500):
	if(0.05*x-11.5==0):
		print"x= \n",x
	break

cust=numpy.array([230, 240, 270, 300, 350, 380])
profit=[0, 0.5, 2.0, 3.5, 6.0, 7.5];
pyplot.plot(cust,profit);
pyplot.plot(230,0,'o');
#profit(y) depends on varying no. of customers(x). the no.'s 0.05 & 11.5 remained constant
pyplot.title("the straight line graph")
pyplot.xlabel("no. of customers")
pyplot.ylabel("profit");
pyplot.legend("y=0.05*x-11.5");
pyplot.grid()
pyplot.show()

Example 13_3 pgno:149

In [12]:
#y=mx+b
import numpy
import matplotlib
from matplotlib import pyplot
%matplotlib inline
x=numpy.linspace(0,3);
y=x;
pyplot.plot(x,y);
y=x+2;
pyplot.plot(x,y);
y=x-3;
pyplot.plot(x,y);
pyplot.title("Equations of the form y=mx+b")
pyplot.xlabel("x axis")
pyplot.ylabel("y axis");
#pyplot.legend("y=x","y=x+2","y=x-3");
print ('y=mx+b');
#m is constant, b is fixed distance. (x,y) vary for different points on the line 
pyplot.grid()
pyplot.show()
y=mx+b

Example 13_4 pgno:151

In [4]:
import numpy
import matplotlib
from matplotlib import pyplot
%matplotlib inline
x=numpy.linspace(-3,3,11);
y=x**2;
pyplot.plot(x,y);
pyplot.title("Parabola curve")
pyplot.xlabel("x axis")
pyplot.ylabel("y axis")
pyplot.legend("y=x^2");
pyplot.grid()
pyplot.show()

Example 13_5 pgno:152

In [5]:
import numpy
import matplotlib
from matplotlib import pyplot
%matplotlib inline
x=numpy.linspace(-3,3,11);
y=-x**2;
pyplot.plot(x,y);

pyplot.title("curve of y=-x^2")
pyplot.xlabel("x axis")
pyplot.ylabel("y axis")
pyplot.legend("y=x^2");
print("this curve is parabola");
pyplot.grid()
pyplot.show()
this curve is parabola

Example 13_6 pgno:154

In [6]:
#y=ax**2
import numpy
import matplotlib
from matplotlib import pyplot
%matplotlib inline
x=numpy.linspace(-3,3,11);
y=2*x**2;
pyplot.plot(x,y);
y=x**2;
pyplot.plot(x,y);
y=x**2/2;
pyplot.plot(x,y);

pyplot.title("curve of y=ax**2")
pyplot.xlabel("x axis")
pyplot.ylabel("y axis")
#pyplot.legend("y=2*x**2","y=x**2","y=x**2/2");
#if a is negative, we get corresponding curves similar to y=-x**2
pyplot.grid()
pyplot.show()

Example 13_7 pgno:155

In [7]:
#y=x**2+a or y=x**2-a
import numpy
import matplotlib
from matplotlib import pyplot
%matplotlib inline
x=numpy.linspace(-3,3,11);
y=x**2+2;
pyplot.plot(x,y);
y=x**2;
pyplot.plot(x,y);
y=x**2-3;
pyplot.plot(x,y);
pyplot.title("Curves of y=x**2 +/- a")
pyplot.xlabel("x axis")
pyplot.ylabel("y axis")
#pyplot.legend("y=x**2+2","y=x**2","y=x**2-3");
pyplot.grid()
pyplot.show()

Example 13_8 pgno:156

In [8]:
#y=x^2+a or y=x^2-a
import numpy
import matplotlib
from matplotlib import pyplot
%matplotlib inline
x=numpy.linspace(-3,3,11);
y=x**2;
pyplot.plot(x,y);
pyplot.plot(y=1)
pyplot.legend("y=x^2");

pyplot.title("Change of axis")
pyplot.xlabel("x axis")
pyplot.ylabel("y axis")
pyplot.grid()
pyplot.show()
print"axis for y=x^2 becomes axis for y=x^2-3 by drawing new x axis 3 units above the original"
axis for y=x^2 becomes axis for y=x^2-3 by drawing new x axis 3 units above the original

Example 13_9 pgno:157

In [9]:
import numpy
import matplotlib
from matplotlib import pyplot
%matplotlib inline
x=numpy.linspace(-3,4,8);
y=(x-1)**2;
pyplot.plot(x,y);
pyplot.legend("y=(x-1)^2");
pyplot.title("Curve of y=(x-1)^2")
pyplot.xlabel("x axis")
pyplot.ylabel("y axis")
pyplot.grid()
pyplot.show()

Example 13_10 pgno:158

In [3]:
#129,130,131 examples


import numpy
import matplotlib
from matplotlib import pyplot
%matplotlib inline
x=numpy.linspace(-3,4,8);
y=(x-1)**2-4;
pyplot.plot(x,y);
pyplot.legend("y=(x-1)^2-4");
pyplot.title("Graph of y=(x-1)^2-4")
pyplot.xlabel("x axis")
pyplot.ylabel("y axis")


x =('x')
y='(x-1)**2-4';

#131 concept
print ('At these points  curve cuts the axis of x')
x=3
pyplot.grid()
pyplot.show()	
At these points  curve cuts the axis of x