c vectors finds the Sum , substraction, dot product and cross product
dimension a(1,3), b(1,3) , c(1,3) , d(1,3) ,prodvec(1,3)
pi=2.*asin(1.)
print*,'input, ax,ay,az '
read*,a(1,1),a(1,2),a(1,3)
print*,'input, bx,by,bz '
read*,b(1,1),b(1,2),b(1,3)
c sum and substraction
do 10 i=1,3
c(1,i)=a(1,i)+ b(1,i)
d(1,i)=a(1,i)- b(1,i)
10 continue
c dot product and angle , magnitudes
sumdot=0.
suma=0.
sumb=0.
do 20 i=1,3
sumdot=sumdot+a(1,i)*b(1,i)
suma=suma + a(1,i)**2
sumb=sumb + b(1,i)**2
if(i.eq.1)prodvec(1,i)=a(1,2)*b(1,3)-a(1,3)*b(1,2)
if(i.eq.2)prodvec(1,i)=a(1,3)*b(1,1)-a(1,1)*b(1,3)
if(i.eq.3)prodvec(1,i)=a(1,1)*b(1,2)-a(1,2)*b(1,1)
20 continue
amaga=sqrt(suma)
amagb=sqrt(sumb)
arg=sumdot/(amaga*amagb)
angle=acos(arg)
print*,'magnitude of a , magn of b ,angle(deg)=',amaga,amagb,
$ angle*180./pi
print*,'Comp of the Sum cx,cy,cz=',c(1,1),c(1,2),c(1,3)
print*,'Comp of substraction dx,dy,dz=',d(1,1),d(1,2),d(1,3)
print*,' '
print*,'Comp. of vector product '
print *,(prodvec(1,i),i=1,3)
stop
end
RUN
input, ax,ay,az
2.,0.,0.
input, bx,by,bz
0.,3.,0.
magnitude of a , magn of b ,angle(deg)= 2. 3. 90.
Comp of the Sum cx,cy,cz= 2. 3. 0.
Comp of substraction dx,dy,dz= 2. -3. 0.
Comp. of vector product
0. 0. 6.