import sympy
import numpy
import math
print "We have to find yn for F=cosxcos2xcos3x"
x = sympy.Symbol('x')
F = sympy.cos(x)*sympy.cos(2*x)*sympy.cos(3*x)
n = int(raw_input("Enter the order of differentiation: "))
print "calculating yn.."
yn= sympy.diff(F,x,n)
print "The expression for yn is"
print yn
import sympy
print 'we have to find yn for F=cosxcos2xcos3x'
x = sympy.Symbol('x')
F = x/((x-1)*(2*x+3))
n = int(raw_input("Enter the order of differentiation: "))
print "calculating yn"
yn= sympy.diff(F,x,n)
print "The expression for yn is"
print yn
import sympy
print "We have to find yn for F=cosxcos2xcos3x"
x = sympy.Symbol('x')
a = sympy.Symbol('a')
F = x/(x**2+a**2)
n = raw_input ("Enter the orde of differentiation:")
print "calculating yn"
yn = diff(F,x,n)
print "the expression for yn is"
print yn
import sympy, math
print "we have to find yn for F=cosxcos2xcos3x"
x = sympy.Symbol('x')
a = sympy.Symbol('a')
F = math.e**(x)*(2*x+3)**3
n = raw_input ("Enter the order of differentiation: ")
print "calculating yn"
yn = diff(F,x,n)
print "the expression for yn is"
print yn
import sympy
print 'y=(sinˆ-1)x) --sign inverse x'
x = sympy.Symbol('x')
a = sympy.Symbol('a')
y = (sympy.asin(x))**2;
print 'we have to prove (1-xˆ2)y(n+2)-(2n+1)xy(n+1)-nˆ2 yn'
print 'Calculating yn for various values of n'
for n in range(1,5):
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)
print n
print 'The expression for yn is'
print F
print 'Which is equal to 0'
print 'Hence Proved'
import sympy, math
print 'y=eˆ(a(sinˆ-1)x))--sign inverse x'
x = sympy.Symbol('x')
a = sympy.Symbol('a')
y = math.e**(a*(sympy.asin(x)))
print 'We have to prove (1-xˆ2)y(n+2)-(2n+1)xy(n+1)-(nˆ2+aˆ2)yn'
print 'Calculating yn for various values of n'
for n in range(1,5):
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)
print n
print 'The expression for yn is'
print F
print 'Which is equal to 0'
print 'Hence proved'
import sympy
print 'y^(1/m)+y^-(1/m)=2x'
print 'OR y^(2/m)-2xy^(1/m)+1'
print 'OR y=[ x+(xˆ2-1)]ˆm and y=[x-(xˆ2 −1)]ˆm'
x = sympy.Symbol('x')
m = sympy.Symbol('m')
print 'For y=[x+(xˆ2−1)]ˆm'
y=(x+(x**2-1))**m
print 'We have to prove (xˆ2−1)y(n+2)+(2n+1)xy(n+1)+(nˆ2−mˆ2)yn'
print 'Calculating various values for yn'
for n in range(1,5):
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)
print n
print 'The expression for yn is'
print F
print 'Which is equal to 0'
print 'Hence Proved'
import sympy, math
print 'For roles theorem F9x should be differentiable in (a, b) and f(a)=f(b)'
print 'Here f(x)=sin(x)/e^x'
x = sympy.Symbol('x')
y = sympy.sin(x)/math.e**x
y1 = sympy.diff(y,x)
print y1
print 'Putting this to zero we get tan(x)=1 ie x=pi/4'
print 'Value pi/2 lies b/w 0 and pi. Hence roles theroem is verified'
import numpy, sympy, math
print "Maclaurin's Series"
print 'f(x)=f(0)+xf1(0)+xˆ2/2!∗f2(0)+xˆ3/3!∗f3(0)+......'
x = sympy.Symbol('x')
a = sympy.Symbol('a')
y = sympy.tan(a)
n = int(raw_input("Enter the orde of differentiation: "))
a = 1
t = sympy.solve(y)[0]
a = 0
for i in range(2,n+1):
y1 = sympy.diff (y,'a',i-1)
if sympy.solve(y1):
t = t+x**(i-1)*sympy.solve(y1)[0]/math.factorial(i-1)
print t
import numpy,sympy,math
print "Maclaurins series"
print "f(x)=f(0)+xf1(0)+xˆ2/2!∗f2(0)+xˆ3/3!∗f3(0)+......"
x = sympy.Symbol('x')
a = sympy.Symbol('a')
y = math.e**(sympy.sin(a))
n = int(raw_input('enter the number of expression in series:'))
a = 0
t = 0
a = 0
for i in range(2,n+1):
y1 = sympy.diff(y,'a',i-1)
t = t+x**(i-1)*sympy.solve(y1)[0]/math.factorial(i-1)
print t
import numpy,sympy,math
print "Maclaurins series"
print "f(x)=f(0)+xf1(0)+xˆ2/2!∗f2(0)+xˆ3/3!∗f3(0)+......"
x = sympy.Symbol('x')
a = sympy.Symbol('a')
y = sympy.log(1+(sympy.sin(a))**2)
n = int(raw_input("enter the number of differentiation involved in maclaurins series :"))
a = 0
t = 0
a = 0
for i in range(2,n+1):
y1 = sympy.diff(y,'a',i-1)
t = t+x**(i-1)*sympy.solve(y1)[0]/math.factorial(i-1)
print t
import numpy,sympy,math
print "Maclaurins series"
print "f(x)=f(0)+xf1(0)+xˆ2/2!∗f2(0)+xˆ3/3!∗f3(0)+......"
x = sympy.Symbol('x')
a = sympy.Symbol('a')
b = sympy.Symbol('b')
y = math.e**(a*sympy.asin(b))
y1 = sympy.diff(y, 'b', 1)
n = int(raw_input("enter the number of expression in series :"))
b = 0
t = 0
for i in range(2,n+1):
y1 = sympy.diff(y,'b',i-1)
t = t+x**(i-1)*y1.evalf()/math.factorial(i-1)
print t
import numpy,math,sympy
print "Use of taylor series are given in subsequent examples"
y = math.log(1.1)
print "log(1.1) = ",math.log (1.1)
import numpy,sympy,math
print "Taylor series"
print "f(x+h)=f(x)+hf1(x)+hˆ2/2!∗f2(x)+hˆ3/3!∗f3(x)+......"
print "To finf the taylor expansion of tan−1(x+h)"
x = sympy.Symbol('x')
h = sympy.Symbol('h')
y = sympy.atan ( x )
n = int(raw_input ("enter the number of expression in series : "))
t = y
for i in range (2,n+1):
y1 = sympy.diff (y,'x',i-1)
t = t+h**(i-1)*(y1)/math.factorial(i-1)
print t
import numpy,sympy,math
print "Here we need to find the limit off(x) at x=0"
x = sympy.Symbol('x')
y = (x*math.e**x-sympy.log(1+x))/x**2
f = 1
while f==1:
yn = x*math.e**x-sympy.log(1+x)
yd = x**2;
yn1 = sympy.diff(yn,'x',1)
yd1 = sympy.diff(yd,'x',1)
x = 0
a = yn1.evalf(subs=dict(x=1))
b = yd1.evalf(subs=dict(x=1))
if a == b:
yn = yn1
yd = yd1
else:
f =0
h = a / b
print h
import numpy,sympy,math
print "Equation of tangent"
x = sympy.Symbol('x')
a = sympy.Symbol('a')
y = sympy.Symbol('y')
f = (a**(2/3)-x**(2/3))**(3/2)
s = sympy.diff(f,x)
Y1 = s*(-x)+y
X1 = -y/s*x
g = x-(Y1-s*(X1-x))
print "Equation is g=0 where g is",g
import numpy,sympy,math
print "Equation of tangent"
x = sympy.Symbol('x')
a = sympy.Symbol('a')
y = sympy.Symbol('y')
t = sympy.Symbol('t')
xo = a*(sympy.cos(t)+t*sympy.sin(t))
yo = a*(sympy.sin(t)-t*sympy.cos(t))
s = sympy.diff(xo,t)/sympy.diff(yo,t)
y = yo+s*(x-xo)
print "y = ",y
import numpy,sympy,math
print "The two given curves are xˆ=4y and yˆ2=4x which intersects at (0,0) and (4,4)"
print "for (4 ,4)"
x = 4
x = sympy.Symbol('x')
y1= x**2/4
y2 = 2*x**(1/2)
m1= sympy.diff(y1,x,1)
m2= sympy.diff(y2,x,1)
x = 4
print "Angle between them is (radians):−"
t= sympy.atan((m1-m2)/(1+m1*m2))
print t
import numpy,sympy,math
a = sympy.Symbol('a')
t = sympy.Symbol('t')
x = a*(sympy.cos(t)+sympy.log(sympy.tan(t/2)))
y = a*sympy.sin(t)
s = sympy.diff(x,t,1)/sympy.diff(y,t,1)
print "length of tangent"
l = y*(1+s)**(0.5)
print l
print "checking for its dependency on t"
f = 1
t = 0
k = sympy.solve(l)
for i in range(1,11):
t = i
if(sympy.solve(l)!=k):
f = 0
if(f==1):
print "verified and equal to a"
print "subtangent"
m = y/s
print m
import numpy,sympy,math
print "Angle of intersection"
print "point of intersection of r=sint+cost and r=2 sint is t=pi/4"
print "tanu=dQ/dr∗r"
Q = sympy.Symbol('Q')
r1 = 2*sympy.sin(Q)
r2 = sympy.sin(Q)+sympy.cos(Q)
u = sympy.atan(r1*sympy.diff(r2,Q,1))
Q = math.pi/4
u = u.evalf()
print "The angle at point of intersection in radians is : "
print u
import sympy,math
print "tanu=dQ/dr∗r"
Q = sympy.Symbol('Q')
a = sympy.Symbol('a')
r = 2*a/(1-sympy.cos(Q))
u = sympy.atan(r/sympy.diff(r2,Q,1))
u = u.evalf()
print u
p = r*sympy.sin(u)
r = sympy.Symbol('r')
Q = sympy.acos(1-2*a/r)
p = p.evalf()
print p
import numpy,sympy,math
a = sympy.Symbol('a')
t = sympy.Symbol('t')
x = a*(t+sympy.sin(t))
y = a*(1-sympy.cos(t))
s2 = sympy.diff(y,t,2)/sympy.diff(x,t,2)
s1 = sympy.diff(y,t,1)/sympy.diff(x,t,1)
r = (1+s1**2)**(3/2)/s2
print "The radius of curvature is :",r
import numpy,sympy,math
print "radius of curvature"
a = sympy.Symbol('a')
t = sympy.Symbol('t')
r = a*(1-sympy.cos(t))
r1 = sympy.diff(r,t,1)
l = (r**2+r1**2)**(3/2)/(r**2+2*r1**2-r*r1)
r = sympy.Symbol('r')
t = sympy.acos(1-r/a)
l = l.evalf()
print l
print "Which is proportional to rˆ0.5"
import numpy,sympy,math
print "The centre of curvature"
x = sympy.Symbol('x')
a = sympy.Symbol('a')
y = sympy.Symbol('y')
y = 2*(a*x)**0.5
y1 = sympy.diff(y,x,1)
y2 = sympy.diff(y,x,2)
xx = x-y1*(1+y1)**2/y2
yy = y+(1+y1**2)/y2
print "the coordinates x,y are resp : "
print xx
print yy
import numpy,sympy,math
print "centre of curvature of given cycloid"
a = sympy.Symbol('a')
t = sympy.Symbol('t')
x = a*(t-sympy.sin(t))
y = a*(1-sympy.cos(t))
y1 = sympy.diff(y,t,1)
y2 = sympy.diff(y,t,2)
xx = x-y1*(1+y1)**2/y2
yy = y+(1+y1**2)/y2
print "the coordinates x,y are resp : "
print xx
print yy
print "which another parametric equation of cycloid"
import sympy
print 'To find the maxima and minima of given function put f1(x)=0'
x = sympy.Symbol('x')
f=3*x**4-2*x**3-6*x**2+6*x+1
k = sympy.diff(f,x)
x = sympy.poly(0,x)
k = sympy.solve(k)
print k
import numpy,sympy,math
print "to find the assymptote of given curve"
x = sympy.Symbol('x')
y = sympy.Symbol('y')
f = x**2*y**2-x**2*y-x*y**2+x+y+1
f1 = sympy.poly(f,y,x)
f1 = f1.coeffs()
print "assymptotes parallel to x−axis is given by f1=0 where f1 is : "
print sympy.factor(f1)
f2 = sympy.poly(f,y,x)
print "assymptotes parallel to y−axis is given by f 2=0 and f2 is : "
print sympy.factor(f2)