Chapter 16 Logarithms

Example 16_1 pgno:196

In [22]:
import numpy
import numpy
import matplotlib
from matplotlib import pyplot
%matplotlib inline
x=numpy.linspace(0,1,7);
y=10**x;
pyplot.plot(x,y);
pyplot.title(" graph of y=10**x")
pyplot.xlabel("x axis")
pyplot.ylabel("y axis");
pyplot.legend("y=10**x");

pyplot.grid()
pyplot.show()



#ex1:1.8*2.6=? ,from graph
#1.8=10**0.26 \n 2.6=10**0.42  
x=10**0.26;y=10**0.42;
#format(4)
ex1_ans=x*y#from the graph

#ex2:9**(1/3)
#9=10**0.96
x=10**0.96;
#format(4)
ex2_ans=x**(1/3)#third law of indices

print ex1_ans,ex2_ans
4.78630092323 1.0

Example 16_2 pgno:198

In [23]:
import math
from math import log10


ans1=log10(56.2)
ans2=10
ans3=log10(1000)
ans4=log10(81)/log10(3)

print ans1,ans2,ans3,ans4
1.74973631557 10 3.0 4.0

Example 16_3 pgno:201

In [24]:
#no. whose logarithm is 2.3714

mantissa=0.3714;
print("from anti-logarithm table,corresponding no. is 2352")
# As,characteristic is 2,no. must lie between 100 & 1000.\n \n hence 3 significant figures in the intergral part
print 235.2
from anti-logarithm table,corresponding no. is 2352
235.2

Example 16_4 pgno:203

In [25]:
#value of (57.86*4.385)
from math import log10
#log(p*q)=log(p)+log(q)
p=57.86;q=4.385;
logx=log10(p)+log10(q);
format(6)
x=10**logx
print x
253.7161

Example 16_5 pgno:204

In [26]:
#value of (5.672*18.94)/1.758
from math import log10
#log(p*q)=log(p)+log(q) , log(p/q)=log(p)-log(q)
p=5.672;q=18.94;r=1.758;
logx=log10(p)+log10(q)-log10(r);

x=10**logx
print round(x,1)
61.1

Example 16_6 pgno:204

In [27]:
#5th root of 721.8
from math import log10
#log(a)^n=n*log(a)
p=721.8;n=1./5.;
logx=n*log10(p);
#format(6)
x=10**logx
print round(x,3)
3.73

Example 16_7 pgno:206

In [28]:
#logs of 0.3185,0.03185,0.003185
from math import log10
x=0.3185;y=0.03185;z=0.003185;
logx=log10(0.3185)
logy=log10(0.03185)
logz=log10(0.003185)

print round(logx,4),round(logy,4),round(logz,4)
-0.4969 -1.4969 -2.4969

Example 16_8 pgno:206

In [29]:
#no. with logarithm -3.5416

mantissa=0.5416;
print("from anti-logarithm table, corresponding no.is 3840 ")
#characteristic is -3.\n \n hence there will be 2 zeros after the decimal point
print 0.003480
from anti-logarithm table, corresponding no.is 3840 
0.00348

Example 16_9 pgno:207

In [30]:
#sum of logarithms -1.6173,-2.3415,-1.6493,-0.7374

x=.6173;y=.3415;z=.6493;a=0.7374;#mantissa's of all 4 logarithms
mantissa=x+y+z+a;
#2 which is carried forward from the addition of mantissa is +ve.
characteristic=-1-2-1-0+2;#characteristic part of all 4 logarithms
print("sum=-",mantissa)



 
('sum=-', 2.3455)

Example 16_10 pgno:207

In [31]:
#logarithm :  -1.6175-(-3.8463)

mantissa=1.6175-0.8463;
#in borrowing to subtract 8 from 6, -1(characteristic) becomes -2 
characteristic=-2-(-3);
print mantissa+characteristic
1.7712

Example 16_11 pgno:208

In [32]:
#logarithm : multiply -2.8763 by 3

num=2.8763;#given
mantissa=0.8763;
mul=mantissa*3;
#when mantissa is multiplied, 2 is carried forward. (-2)*3=-6. the characteristic becomes -6+2=-4
print -4.6289
-4.6289

Example 16_12 pgno:208

In [33]:
#logarithm: -1.8738*1.3

#multiply mantissa & characteristic seperately and add results
x=0.8738*1.3;
y=-1*1.3;
#as y=-1.3 is -ve, change it to -2.7 to make mantissa +ve
y=-2.7;
mantissa_sum=0.13594+0.7; #of x & y
characteristic_sum=2-1;
print 2*characteristic_sum-mantissa_sum
1.16406

Example 16_13 pgno:208

In [34]:
#divide -5.3716 by 3

#characteristic=-5=-6+1 or the log as -6+1.3716
characteristic=-6/3;
mantissa=1.3716/3;
print characteristic-mantissa
-2.4572

Example 16_14 pgno:211

In [35]:
#log50 to the base e 
from math import log
print round(log(50),3)#natural logarithm
# or, log50_base_e=log10(50)*2.3026
3.912