Nugroho's blog.: The Answer of My Introduction Mathemathical for Physicist (Jawaban ujian Fismatku)

Saturday, November 29, 2008

The Answer of My Introduction Mathemathical for Physicist (Jawaban ujian Fismatku)


I use fortran to generate x n y position:

below is the code

PROGRAM Grafik
IMPLICIT NONE
REAL :: gaya,ygaya,k,ky,a,ay,m,v,vy,t,x,y,z
REAL :: sbx,sby,sbz,g,fx,fy,fz
REAL :: r,dt,dx,dy,dz,dv,dvy,theta,phi
INTEGER :: i,j,n
r =100
g =10
n =50
k =10000
ky =1000
t=0
dt=0.001
OPEN (80, FILE = 'data.dat', STATUS = 'NEW', FORM = 'FORMATTED')
WRITE(80,*) ' i t x y'
CLOSE(80)
OPEN(80, ACCESS = 'APPEND', FILE = 'data.dat', FORM = 'FORMATTED')
DO i=-n,n
x=i
x=x/10
IF (x .NE. 1) THEN
!y=(2+x-x*x)/(x-1)/(x-1)
z=2-x-x*x
vy=(x-1)*(x-1)
y=z/vy
END IF
WRITE(80,81) x,y
8¹FORMAT(e14.7,' ',e14.7)
END DO
CLOSE(80)
END PROGRAM Grafik

compile using:

$gfortran grafik.f90

that syntax has output a.out
run using:

$./a.out

It'll create file named data.dat and generate number of f(x)=(2-x-x^2)/(x-1)^2

plot using kst :
$kst -x ¹-y 2 data.dat

It means kst will plot a graph using 1st column as x-axis and 2nd column as y-axis of data.dat

to simplify that procedure, I create text file named run.sh contain:

rm *.dat
gfortran grafik.f90
./a.out
kst -x ¹-y 2 data.dat

make run.sh executable
then run:
$./run.sh



.........dan mereka hidup bahagia berdua selamanya.

Posted by ShoZu

No comments:

323f (5) amp (1) android (12) apple (7) arduino (18) art (1) assembler (21) astina (4) ATTiny (23) blackberry (4) camera (3) canon (2) cerita (2) computer (106) crazyness (11) debian (1) delphi (39) diary (286) flash (8) fortran (6) freebsd (6) google apps script (8) guitar (2) HTML5 (10) IFTTT (7) Instagram (7) internet (12) iOS (5) iPad (6) iPhone (5) java (1) javascript (1) keynote (2) LaTeX (6) lazarus (1) linux (29) lion (15) mac (28) macbook air (8) macbook pro (3) macOS (1) Math (3) mathematica (1) maverick (6) mazda (4) microcontroler (35) mountain lion (2) music (37) netbook (1) nugnux (6) os x (36) php (1) Physicist (29) Picture (3) programming (189) Python (109) S2 (13) software (7) Soliloquy (125) Ubuntu (5) unix (4) Video (8) wayang (3) yosemite (3)