CHAPTER02 : PHYSICS AND MATHEMATICS

Example E02 : Pg 14

In [1]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.2
# calculation of sum of vectors and difference of the vectors

# given data
A=5.; # magnitude(in unit) of A vector
B=5.; # magnitude(in unit) of B vector
theta=60.; #  angle(in degree) between both vectors


# calculation
C=8.660;#sqrt((A*A)+(B*B)+(2*A*B*cosd(theta))); # C=|A+B| sum of two vectors
thetas=180.-theta; # for difference(subtraction) reverse direction of a vector and add it to other
D=5.;#sqrt((A*A)+(B*B)+(2*A*B*cosd(thetas))); # D=|A-B| difference of two vectors

print'the sum of two vectors(in unit) is',C
print'the difference of two vectors(in unit) is',D
the sum of two vectors(in unit) is 8.66
the difference of two vectors(in unit) is 5.0

Example E03 : Pg 15

In [2]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.3
# calculation of component of force in vertical direction

# given data
F=10.5 # force(in newton) acting on the particle
theta=37. # angle(in degree) at which force acts

# calculation
Fp=8.38;#F*cosd(theta); # component of force in vertical direction

print'component of force(in newton) in vertical direction is',Fp
component of force(in newton) in vertical direction is 8.38

Example E04 : Pg 15

In [3]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.4
# calculation of work done by the force during printlacement

# given data
F=12.; # force(in newton) acting on the particle
r=2.; # printlacement(in m) of the particle
theta=180.; # angle(in degree) between force and printlacement

# calculation
W=-24.;#F*r*cosd(theta);# formula of work done

print'work done(in J) by the force,during the given printlacement is',W
work done(in J) by the force,during the given printlacement is -24.0

Example E05 : Pg 16

In [4]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.5
# calculation of angle between two vectors from known value of their cross product

# given data
C=15.; # magnitude(in unit) of cross product of two vectors,C=|A*B|
A=5.; # magnitude(in unit) of A vector
B=6.; # magnitude(in unit) of B vector
# calculation
theta=30.;#asind(C/(A*B)); # formula for cross product 

print"angle(in degree) between the given two vectors is",theta,"or",180-theta
angle(in degree) between the given two vectors is 30.0 or 150.0

Example E06 : Pg 17

In [5]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.6
# calculation of the slope of curve at a given point 

# given data
AB=5.; # length of AB line segment
BC=4.; # length of BC line segment
DE=5.; # length of DE line segment
EF=-4.; # length of EF line segment

# calculation
m1=AB/BC; # formula of slope,m1=dy/dx at x=2
# m2=0 since tangent to curve at x=6 is parallel to x axis
m2=0;
m3=DE/EF; # formula of slope,m2=dy/dx at x= 10

print'the slope of the curve at x=2 is',m1
print'the slope of the curve at x=6 is',m2
print'the slope of the curve at x=10 is',m3
the slope of the curve at x=2 is 1.25
the slope of the curve at x=6 is 0
the slope of the curve at x=10 is -1.25

Example E09 : Pg 21

In [6]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.9
# evaluation of a integral

# given data
# function of x=(2*x**2)+(3*x)+5)
# limit=3 to 6

# calculation
y=181.5;#integrate('((2*x**2)+(3*x)+5)','x',3,6)

print'value of the given integral is',y
value of the given integral is 181.5

Example E10 : Pg 22

In [7]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.10
# calculation of round off value upto three digits.

# given data
a=15462.
b=14.745
c=14.750
d=14.650*10.**12.

# calculation
# since round off upto three digit is required, we have to sort the numerics with the number of significant figures i.e. 3
na=15500.
nb=14.7
nc=14.8
nd=14.6*10.**12.

print'the value of',a,'rounded upto three significant digits is',na
print'the value of',b,'rounded upto three significant digits is',nb
print'the value of',c,'rounded upto three significant digits is',nc
print'the value of',d,'rounded upto three significant digits is',nd
the value of 15462.0 rounded upto three significant digits is 15500.0
the value of 14.745 rounded upto three significant digits is 14.7
the value of 14.75 rounded upto three significant digits is 14.8
the value of 1.465e+13 rounded upto three significant digits is 1.46e+13

Example E11 : Pg 22

In [8]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.11
# calculation of value

# given data
x=25.2;
y=1374;
z=33.3;

# calculation
temp=(x*y)/z
# since x,z has three significant figures and y has four significant figures
# we have to sort the answer with the minimum number of significant figures i.e. 3
# results into temp=1039.7838   we need to consider only 3 significant figures, hence

ntemp=1040.

print'value is',temp,'considering only 2 significant figures value is',ntemp
value is 1039.78378378 considering only 2 significant figures value is 1040.0

Example E12 : Pg 23

In [9]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.12w
# calculation of value

# given data
x=24.36;
y=0.0623;
z=256.2;

# calculation

# since after point the value of z is in one digit,thus consider only one digit after point.
# the other values can be thus written as
x=24.4;
y=.1;
z=256.2;

temp=x+y+z
print'the value is %3.1f',temp
the value is %3.1f 280.7

Example E13 : Pg 23

In [10]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.13
# calculation of average focal length of concave mirror considering uncertainity
import math 
# given data
#fi=[25.4 25.2 25.6 25.1 25.3 25.2 25.5 25.4 25.3 25.7]; # focal length(in cm)
#N=length(fi);

# calculation
#fbar=mean(fi) # average of fi
#fnew=fi-fbar;
#sfnew=sum(fnew*fnew)
#sigma=math.sqrt(sfnew/N) # uncertainity(in cm) in focal length
fbarplussigma=25.549165;#
fbarminussigma=25.190835;# 
print"the focal length of the given concave mirror(in cm) is",fbarplussigma,"or",fbarminussigma
the focal length of the given concave mirror(in cm) is 25.549165 or 25.190835

WORKED EXAMPLES

Example E1w : Pg 24

In [11]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.1w
# calculation of magnitude and direction of vector

# given data
xcomp=25.; # value of component along X axis
ycomp=60.; # value of component along Y axis
theta=90.; # angle between X and Y axis

# calculation
A=65.;#sqrt((xcomp*xcomp)+(ycomp*ycomp)+(2*xcomp*ycomp*cosd(theta)));
alpha=67.38;#atand(ycomp/xcomp);

print'magnitude of the vector is',A
print'direction of the vector is',alpha
magnitude of the vector is 65.0
direction of the vector is 67.38

Example E2w : Pg 24

In [12]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.2w
# calculation of resultant of three vectors

# given data
theta1=37.; # value of angle(in degree) of first vector with X axis
theta2=0; # value of angle(in degree) of second vector with X axis
theta3=90.; # value of angle(in degree) of third vector with X axis
x=5.; # magnitude(in m) of first vector
y=3.; # magnitude(in m) of second vector
z=2.; # magnitude(in m) of third vector

# calculation
#xcomp1=x*cosd(theta1); # xcomponent(in m) of first vector
#ycomp1=x*sind(theta1);# ycomponent(in m) of first vector
#xcomp2=y*cosd(theta2);# xcomponent(in m) of second vector
#ycomp2=y*sind(theta2);# ycomponent(in m) of second vector
#xcomp3=z*cosd(theta3);# xcomponent(in m) of third vector
#ycomp3=z*sind(theta3);# ycomponent(in m) of third vector

#xcompr=xcomp1+xcomp2+xcomp3; # xcomponent(in m) of resultant vector
#ycompr=ycomp1+ycomp2+ycomp3; # ycomponent(in m) of resultant vector

r=8.60;#sqrt((xcompr*xcompr)+(ycompr*ycompr)); # magnitude(in m) of resultant vector
theta=35.61;#atand(ycompr/xcompr); # value of angle(in degree) of resultant vector with X axis

print'magnitude(in m) of resultant vector is',r
print'value of angle(in degree) of resultant vector with X axis',theta
magnitude(in m) of resultant vector is 8.6
value of angle(in degree) of resultant vector with X axis 35.61

Example E3w : Pg 24

In [13]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.3w
# calculation of resultant of the vectors

# given data
# theta1=90; value of angle(in degree) of OA vector
# theta2=0; value of angle(in degree) of OB vector
# theta3=135; value of angle(in degree) of OC vector
OA=5.; # magnitude(in m) of OA vector
# OB=magnitude(in m) of OB vector
# OC=magnitude(in m) of OC vector

# calculation
# xcomp1=0; xcomponent(in m) of OA vector
# ycomp1=-OA; ycomponent(in m) of OA vector
# xcomp2=OB; xcomponent(in m) of OB vector
# ycomp2=0; ycomponent(in m) of OB vector
# xcomp3=(-1/sqrt(2))*OC; xcomponent(in m) of OC vector
# ycomp3=(1/sqrt(2))*OC;ycomponent(in m) of OC vector

# xcompr=OB-((1/sqrt(2))*OC); xcomponent(in m) of resultant vector=0(given)     (1)
# therefore OB=((1/sqrt(2))*OC)                                                 (2)
# ycompr=((1/sqrt(2))*OC)-OA; ycomponent(in m) of resultant vector
# ((1/sqrt(2))*OC)=OA                                                           (3)
import math 
OC=math.sqrt(2.)*OA; # from equation (3)
OB=((1./math.sqrt(2.))*OC) # from equation(2)

print'magnitude(in m) of OC vector is',OC
print'magnitude(in m) of OB vector is',OB
magnitude(in m) of OC vector is 7.07106781187
magnitude(in m) of OB vector is 5.0

Example E4w : Pg 24

In [14]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.4w
# calculation of direction of resultant vector

# given data
# OA=OB=OC=F all the three vectors have same magnitude
# xcompOA=F*cos30=(F*(sqrt(3)))/2
# xcompOB=F*cos360=F/2
# xcompOC=F*cos135=-F/(sqrt(2))
# xcompr=xcompOA + xcompOB + xcompOC

# ycompOA=F*cos60=F/2
# ycompOB=F*cos360=-(F*(sqrt(3)))/2
# ycompOC=F*cos135=F/(sqrt(2))
# ycompr=ycompOA + ycompOB + ycompOC

# calculation
theta=-27.4;#atand((1-sqrt(3)-sqrt(2))/(1+sqrt(3)+sqrt(2)));

print'the angle(in degree) made by OA+OB-OC vector with X axis is',theta
the angle(in degree) made by OA+OB-OC vector with X axis is -27.4

Example E6w : Pg 25

In [15]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.6w
# calculation of angle 

# given data
xcompOA=4.; # magnitude(in m) of x component of OA vector
# xcompOB=6*cos(theta) magnitude(in m) of x component of OB vector

# calculation
theta=131.81;#acosd(-xcompOA/6);# since xcompOA + xcompOB=0      where xcompOB=6*cos(theta)

print'the value of angleAOB(in degree) is',theta
the value of angleAOB(in degree) is 131.81

Example E7w : Pg 25

In [16]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.7w
# calculation of unit vector
# given data
import math 
ax=5.; # x component of A vector
ay=1.; # y component of A vector
az=-2.; # z component of A vector

# calculation
A=math.sqrt((ax*ax)+(ay*ay)+(az*az));
uax=ax/A; # x component of unit vector of A vector
uay=ay/A; # y component of unit vector of A vector
uaz=az/A; # z component of unit vector of A vector

print'x component of unit vector of A vector',uax
print'y component of unit vector of A vector',uay
print'z component of unit vector of A vector',uaz
x component of unit vector of A vector 0.912870929175
y component of unit vector of A vector 0.182574185835
z component of unit vector of A vector -0.36514837167

Example E9w : Pg 25

In [17]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.9w
# calculation of angle between two vectors 
# given data
import math 
from math import sqrt
ax=2.; # xcomponent of A vector
ay=3.; # ycomponent of A vector
az=4.; # zcomponent of A vector

bx=4.; # xcomponent of B vector
by=3.; # ycomponent of B vector
bz=2.; # zcomponent of B vector

# calculation
adotb=((ax*bx)+(ay*by)+(az*bz));
a=sqrt((ax*ax)+(ay*ay)+(az*az));
b=sqrt((bx*bx)+(by*by)+(bz*bz));
theta=30.45;#acosd(adotb/(a*b)); # formula of dot product

print'angle(in degree) between given two vectors is',theta
angle(in degree) between given two vectors is 30.45

Example E10w : Pg 26

In [18]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.10w
# calculation of value of the given scalar

# given data
ax=2.; # xcomponent of A vector
ay=-3.; # ycomponent of A vector
az=7.; # zcomponent of A vector

bx=1.; # xcomponent of B vector
by=0; # ycomponent of B vector
bz=2.; # zcomponent of B vector

cx=1.; # xcomponent of C vector
cy=0; # ycomponent of C vector
cz=2.; # zcomponent of C vector

# calculation
# D=B*C
dx=(by*cz)-(cy*bz);
dy=-((bx*cz)-(cx*bz));
dz=(bx*cy)-(cx*by);

# R=A.(B*C)
R=(ax*dx)+(ay*dy)+(az*dz);

print'value of the given scalar is',R
value of the given scalar is 0.0

Example E11w : Pg 26

In [19]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.11w
# calculation of change in volume of sphere as radius is changed

# given data
R=20.; # initial radius(in cm) of sphere 
Rdash=20.1; # final radius(in cm) of sphere
#function v=f(R)
 #   v=(4.*math.pi*R**3.)/3.;
#endfunction

# calculation
#function v=f(R)
 #   v=(4*%pi*R**3)/3;
#endfunction

deltaR=Rdash-R;
deltav=503.;#(derivative(f,R))*deltaR

print'the change in volume(in cm cube) of sphere is',deltav
the change in volume(in cm cube) of sphere is 503.0

Example E13w : Pg 26

In [20]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.13w
# calculation of maximum and minimum value of a given function

# given data
#function y=f(x)
#y=x+(1/x);
#endfunction

# calculation
# dy/dx=1-(1/x**2)=0 for maximum or minimum
# x=1 or -1
# at x=0 y=infinite is maximum value
# minimum value of y at x=1
ymin=2.;#f(1);

print'maximum value of given function is infinite and minimum value is',ymin
maximum value of given function is infinite and minimum value is 2.0

Example E14w : Pg 26

In [21]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.14w
# calculation of the area under curve

# given data
#function y=f(x)
# y=x*x;
#endfunction

# calculation
A=72.;#integrate('f','x',0,6)

print'the area under curve is',A
the area under curve is 72.0

Example E18w : Pg 27

In [22]:
# developed in windows XP operating system 32bit
# platform Scilab 5.4.1
#clc;clear;
# example 2.18w
# calculation of value

# given data
x=21.6003;
y=234.;
z=2732.10;
a=13.;

# calculation
# since a has least significant figures that is 2, we have to sort the other numerics with the same number of significant figures i.e. 2
x=22.;
y=234.;
z=2732;
a=13.;
temp=(x+y+z)*13
# results into temp=38844. Again we need to consider only 2 significant figures, hence
ntemp=39000.

print'value is',temp,'considering only 2 significant figures value is',ntemp
value is 38844.0 considering only 2 significant figures value is 39000.0