c Electric Potential /and Electric field of a point charge distribution c dimension x(100), y(100), q(100) equivalence (epsi,dx,dy) real k k=8.99E9 pi=2.*asin(1.) epsi=1.e-4 50 print*,'n points charges' read * , n do 10 i=1,n print*,' enter x,y,q for point I',i read *,x(i),y(i),q(i) 10 continue print*,' coordinates of P (observation point) xp , yp ' read*,xp,yp rp=sqrt(xp**2+yp**2) v=0. vdx=0. vdy=0. do 20 i=1,n r=sqrt((xp-x(i))**2 +(yp-y(i))**2) rdx= sqrt((xp+epsi-x(i))**2 +(yp-y(i))**2) rdy=sqrt((xp-x(i))**2 +(yp+epsi-y(i))**2) v=v+k*q(i)/r vdx=vdx+k*q(i)/rdx vdy=vdy+k*q(i)/rdy 20 continue ex=-(vdx-v)/dx ey=-(vdy-v)/dy er=(ex**2+ey**2)**.5 theta= atan(ey/ex) print 110,xp,yp,rp,v print 100, er,ex,ey,theta*180./pi 100 format(1x,'er,ex,ey, theta(degrees)=',4(2x,e11.4)) 110 format(1x,'xp,yp,rp,V=',4(2x,e11.4)) print*,' ' print*,'enter 0=no or 1=yes for another calculation' read*,id if(id.eq.0)goto 200 if(id.eq.1)goto 50 200 stop end