import numpy
x = numpy.poly([0])
p = 2*(x**3)+x**2-13*x+6
print "The roots of above equation are: ", numpy.roots([2,1,-13,6])
import numpy
x = numpy.poly([0])
print "The roots of the equation are: ", numpy.roots ([3, -4, 1, 88])
import numpy
x = numpy.poly([0])
p = x^3-7*(x^2)+36
print "The roots of above equation are:", numpy.roots([1, -7, 0, 36])
import numpy
x = numpy.poly ([0])
p = x**4-2*(x**3)-21*(x**2)+22*x+40
print "The roots of above equation are:", numpy.roots([1,-2,-21,22,40])
import numpy
x = numpy.poly ([0])
p = 2*(x**4)-15*(x**3)+35*(x**2)-30*x+8
print "The roots of above equation are:", numpy.roots([2,-15,35,-30,8])
import numpy
import sympy
x = numpy.poly ([0])
p = x**3-3*(x**2)+1
ans = numpy.roots([1,-3, 0, 1])
print "The roots of above equation are:", ans
x = sympy.Symbol('x')
print "let x1 = 0.6527036 x2 = -0.5320889 x3 = 2.8793852"
print "So the equation whose roots are cube of the roots of above equation is (x−x1ˆ3)∗(x−x2ˆ3)∗(x−x3ˆ3)"
p1 = (x-x1**3)*(x-x2**3)*(x-x3**3)
print p1
import numpy
import sympy
x = numpy.poly ([0])
x1 = numpy.poly ([0])
x2 = numpy.poly ([0])
x3 = numpy.poly ([0])
x4 = numpy.poly ([0])
x5 = numpy.poly ([0] )
x6 = numpy.poly ([0])
p = x**3-6*(x**2)+5*x+8
print "The roots of above equation are:"
print numpy.roots ([1, -6, 5, 8])
print "let x1 = -0.7784571 x2 = 2.2891685 x3 = 4.4892886"
x1 = -0.7784571
x2 = 2.2891685
x3 = 4.4892886
print "Now, since we want equation whose sum of roots is 0. sum of roots of above equation is 6, so we will decrease"
print "Value of each root by 2 i.e. x4 = x1-2"
x = sympy.Symbol('x')
x4 = x1-2
print "x4 = ", x4
x5=x2-2
print "x5 = ", x5
x6=x3-2
print "x6 = ", x6
print "Hence, the required equation is ( x−x4 ) ∗ ( x−x5 ) ∗ ( x−x6 ) = 0 −−>"
p1 =( x-x4 )*(x-x5)*(x-x6)
print p1
import numpy
x = numpy.poly ([0])
p = 6*(x**5)-41*(x**4)+97*(x**3)-97*(x**2)+41*x-6
print "The roots of above equation are:",numpy.roots([6,-41,97,-97,41,-6])
import numpy
x = numpy.poly([0])
p = 6*(x**6)-25*(x**5)+31*(x**4)-31*(x**2)+25*x-6
print "The roots of above equation are:", numpy.roots([6,-25,31,0,-31,25,-6])
import numpy
x = numpy.poly ([0])
p = x**3-3*(x**2)+12*x+16
print "The roots of above equation are:", numpy.roots([1,-3,12,16])
import numpy
x = numpy.poly ([0])
p = 28*(x**3)-9*(x**2)+1
print "The roots of above equation are:",numpy.roots([28,-9,0,1])
import numpy
x = numpy.poly ([0])
p = x**3+x**2-16*x+20
print "The roots of above equation are:",numpy.roots ([1,1,-16,20])
import numpy
x = numpy.poly ([0])
p = x**3-3*(x**2)+3
print "The roots of above equation are:",numpy.roots ([1,-1,0,3])
import numpy
x = numpy.poly([0])
p = x**4-12*(x**3)+41*(x**2)-18*x-72
print "The roots of above equation are:",numpy.roots ([1,-12,41,-18,-72])
import numpy
x = numpy.poly ([0])
p = x**4-2*(x**3)-5*(x**2)+10*x-3
print "The roots of above equation are:", numpy.roots ([1,-2,-5,10,-3])
import numpy
x = numpy.poly ([0])
p = x**4-8*(x**2)-24*x+7
print "The roots of above equation are:",numpy.roots ([1,0,-8,-24,7])
import numpy
x = numpy.poly ([0])
p = x**4-6*(x**3)-3*(x**2)+22*x-6
print "The roots of above equation are:",numpy.roots ([1,-6,-3,22.-6])
%matplotlib inline
import matplotlib.pyplot as plt
import numpy
import math
x = numpy.linspace(1 ,3 ,30)
y1 = 3-x
y2 = math.e**(x-1)
plt.xlabel('X axis')
plt.ylabel('Y axis')
plt.title('My Graph')
plt.plot(x, y1, "o-" )
plt.plot(x, y2, "+-" )
plt.legend(["3-x" ,"e**(x-1)"])
print "From the graph, it is clear that the point of intersection is nearly x = 1.43"
%matplotlib inline
import matplotlib.pyplot as plt
import numpy
import math
x = numpy.linspace(1 ,3 ,30)
y1 = x
y2 = numpy.sin(x)+math.pi/2
plt.xlabel('X axis')
plt.ylabel('Y axis')
plt.title('My Graph')
plt.plot(x, y1, "o-")
plt.plot(x, y2, "+-")
plt.legend(["x", "sin(x)+pi/2"])
print "From the graph, it is clear that the point of intersection is nearly x=2.3"
%matplotlib inline
import matplotlib.pyplot as plt
import numpy
import math
x = numpy.linspace(0, 3, 30)
y1 = -1/numpy.cos(x)
y2 = numpy.cosh(x)
plt.xlabel('X axis')
plt.ylabel('Y axis')
plt.title('My Graph')
plt.plot(x, y1, "o-" )
plt.plot(x, y2, "+-" )
plt.legend (["-sec(x)", "cosh(x)"])
print "From the graph, it is clear that the point of intersection is nearly x=2.3 "