#simplify (a+b)/(a**2-b**2)
#as, by formula,(a**2-b**2)=(a+b)(a-b)
print"\n (a+b)/((a+b)(a-b)) => 1/(a-b) \n"
x = ('x')
e1='x**2+4*x-12';
se1='(x-2)*(x+6)'
e2='x**2+x-6'
se2='(x-2)*(x+3)'
print '(x-2)*(x+6)/(x-2)*(x+3)'
#simplify 3a(a^2-4ab+4b^2)/6a(a^2+3ab-10b^2)
#the factors 3a(a-2b) are common to numerator & denominator.
print("\n the fraction is :\n")
print('(a-2b)/(2a(a+5b))')
x = ('x')
p1='x';
p2='x+1';
p='p1/p2';
q1='x**2';
q2='x**2-1';
q='q1/q2';
print '(x**2 - 1)/(x*(x + 1))'
x =('x')
p1='x**4-27*x';
p2='x**2-9';
p='p1/p2';
q1='x**2+3*x+9';
q2='x+3';
q='q1/q2';
print '(x + 3)*(x**4 - 27*x)/((x**2 - 9)*(x**2 + 3*x + 9))'
#simplify a/(a-b) - a**2/(a**2-b**2)
#as, (a**2-b**2)=(a+b)(a-b),substitute it.
print"\n the fraction is :\n"
print 'ans=(ab/((a+b)(a-b))'
#3/(a-b)-(2a+b)/(a^2-b^2)
print"\n on factorizing, the expression becomes \n"
#3/(a-b)-(2a+b)/(a+b)(a-b) => (3a+3b-2a-b)/(a+b)(a-b)
print ('(a+2b)/((a+b)(a-b))')
import numpy
x = ('x')
p1='x-1';
p2='x**2-x-2';
p='p1/p2';
q1='x+2';
q2='x**2+4*x+3';
q='q1/q2';
t='p-q';
y=numer(t) #numerator of t
z=numpy.roots(denom(t))#factors of denominator of t (more simplified form)
print ("val=(1+2x)/(1+x)(-2+x)(3+x)")
#x/(x-(1/x))
x =('x')
p1='x'
p2='1/x';
p3='p1-p2';
p='p1/p3'
print 'x/(x - 1/x)'
#1/R=1/R1-1/R2. get R
print "R=R1R2/(R2-R1)"
import numpy
x = 'x'
p1='3/(x-2)';
p2='5/(x-1)';
# given, 3/(x-2)=5/(x-1)
x=0;
for x in numpy.arange(0,10,0.1):
if(3*(x-1)==5*(x-2)):
print x
import numpy
n=('n')
p1='1./(n-2)';
p2='1./(n-3)';
p='p1+p2';
q='2./n';
#given p=q
z1=numer(p)*denom(q);
z2=numer(q)*denom(p);
#As,z1=z2. cancel the terms common on both sides
a=z1-z2;
print a
a=numpy.array([0, 5, 0-12])
n=numpy.roots(a);
print n