Chapter 2 Elementry Operations in Algebra

Example 2_1 pgno:25

In [14]:
#simplify 5a+6b+2a-3b

#('collecting like terms \n');
x=5+2;y=6-3;
print"total=a+b",x,y
total=a+b 7 3

Example 2_2 pgno:26

In [15]:
#collecting like terms ;
x=15+7;y=6-3;
print"total=x+y-5",x,y
total=x+y-5 22 3

Example 2_3 pgno:26

In [16]:
x_coeff=6-3;y_coeff=2+4;
#"substitue given values"
x=3;y=2;
val=x_coeff*x + y_coeff*y -3
print val
18

Example 2_4 pgno:33

In [17]:
#84a**6/12a**2
import string
A=1;#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convince   poly(0,'a');
p1=84*A**6;
p2=12*A**2;
p=p1/p2;
print '84a**6/12a**2'


 
84a**6/12a**2

Example 2_5 pgno:33

In [2]:
#3x**4/6x**6

x=('x')#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convince   poly(0,'a');poly(0,'x');
p1='3*x**4';
p2='6*x**6';
#p=p1/p2
print '3x**4/6x**6'
3x**4/6x**6

Example 2_6 pgno:34

In [7]:
 #x/3 + x/5

x=('x')#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convince   poly(0,'a');poly(0,'x');poly(0,'x');
p1='x/3';
p2='x/5';
p=p1+p2;
q='8*x/15';
if(p==q):
    print"val=8*x/15 \n"
print"val=8*x/15"
val=8*x/15

Example 2_7 pgno:34

In [20]:
#given problem sum of 3/a + 4/b

print"((3b + 4a)/(ab))"
((3b + 4a)/(ab))

Example 2_8 pgno:34

In [21]:
#given problem is x/y - a/b

print'(bx-ay)/(by)'
 
(bx-ay)/(by)

Example 2_9 pgno:35

In [22]:
#2a/15 + 5b/12


d=60#"L.C.M of denominators"
k=d;
a_coeff=60/15*2;
b_coeff=60/12*5;
print'ans='
print"(a+b)/k",a_coeff,b_coeff,k
ans=
(a+b)/k 8 25 60

Example 2_10 pgno:35

In [23]:
#x/12a**2b - y/18ab**2

k=36#lcm(d);#L.C.M of denominators

#"L.C.M of a**2*b and a*b**2 is a**2*b**2"
x_coeff=36/12;
y_coeff=36/18;
print'ans='
print"(bx-ay)/a**2b**2",x_coeff,y_coeff,k
ans=
(bx-ay)/a**2b**2 3 2 36

Example 2_11 pgno:36

In [24]:
#4*x**3*y/(6*x*y**3)

gcd_d=1#GCD of 4 and 6 is 2
m=4/gcd_d
n=6/gcd_d
x=1#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convincepoly(0,'x');
y=1#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convincepoly(0,'y');
p1=x**3;p2=x;p=p1/p2;
q1=y;q2=y**3;q=q1/q2;
#val=m/n*p*q 
print'val='
print"/*x**2/y**2",m/2,n/2
val=
/*x**2/y**2 2 3

Example 2_12 pgno:36

In [10]:
#6*a*x**4*2*y**3/(14*x**2*y**2*3*a**4)


x=('x')#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convincepoly(0,'x');poly(0,'x');
y=('y')#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convincepoly(0,'x');poly(0,'y');
a=('a')#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convincepoly(0,'x');poly(0,'a');
num=6.*2./(14.*3.);
p1='x**4';p2='x**2';p='p1/p2';
q1='y**3';q2='y**2';q='q1/q2';
r1='a';r2='a**4';r='r1/r2';
#val=num*p*q*r
print'val='
print"*x**2*y/a**3",num
val=
*x**2*y/a**3 0.285714285714

Example 2_13 pgno:36

In [11]:
#(8x**3)/(5a**2y) *(3a)/(4x**2)


x=('x')#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convincepoly(0,'x');poly(0,'x');
y=('y')#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convincepoly(0,'x');poly(0,'y');
a=('a')#is polynomial function of degree zero poly(0,'x');#for this I assume it to be 1 for my convincepoly(0,'x');poly(0,'a');
p1='x**3';p2='x**2';p='p1/p2';
q='1/y';
r1='a';r2='a**2';r='r1/r2';
num=8.*3./(5.*4.);
#val=num*p*q*r
print('val=')
print"*x/(a*y)",num
val=
*x/(a*y) 1.2