Chapter 12 Fractions

Example 12_1 pgno:141

In [14]:
#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"
                                                                                                                                                                                                                                                                                                                                                                                
 (a+b)/((a+b)(a-b)) => 1/(a-b) 

Example 12_2 pgno:141

In [3]:
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)'
(x-2)*(x+6)/(x-2)*(x+3)

Example 12_3 pgno:141

In [16]:
#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))')
 the fraction is :

(a-2b)/(2a(a+5b))

Example 12_4 pgno:142

In [6]:
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**2 - 1)/(x*(x + 1))

Example 12_5 pgno:142

In [7]:
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))'
(x + 3)*(x**4 - 27*x)/((x**2 - 9)*(x**2 + 3*x + 9))

Example 12_6 pgno:143

In [19]:
#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))'
 the fraction is :

ans=(ab/((a+b)(a-b))

Example 12_7 pgno:143

In [20]:
#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))')
 on factorizing, the expression becomes 

(a+2b)/((a+b)(a-b))

Example 12_8 pgno:144

In [10]:
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)")
val=(1+2x)/(1+x)(-2+x)(3+x)

Example 12_9 pgno:144

In [22]:
#x/(x-(1/x))

x =('x')
p1='x'
p2='1/x';
p3='p1-p2';
p='p1/p3'
print 'x/(x - 1/x)'
x/(x - 1/x)

Example 12_10 pgno:145

In [23]:
#1/R=1/R1-1/R2. get R

print "R=R1R2/(R2-R1)"
R=R1R2/(R2-R1)

Example 12_11 pgno:146

In [11]:
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
3.5

Example 12_12 pgno:146

In [12]:
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    
n*(p1 + p2) - 2.0
[ 2.4]