class5 - PHYS 5900 Class 5 (9/04/2009Fri) Zi-Wei Lin...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
PHYS 5900 Class 5 (9/04/2009Fri) Zi-Wei Lin In[1]:= NIntegrate @ Exp @ x^2 ê 2 Sqrt @ 2 Pi D , 8 x, 2, 2 <D Out[1]= 0.9545
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Fortran program of the integral Ÿ - 2 2 e x 2 ë 2 dx í 2 π is available at http://siyu.physics.ecu.edu/zlin/Fortran/ as integral.f, download it to your Mac computer, open Terminal, then type the following command mv ~/Desktop/integral.f . ls to move it to the current directory. Note: there are 2 spaces in the above command. 1 ) The trapezoidal rule: X 0 X n f H x L Å x i = 0 n 1 B f H X i L + f H X i + 1 L 2 F H X i + 1 X i L = d i = 1 n 1 f H X i L + d 2 @ f H X 0 L + f H X n LD , if H X i + 1 X i L = d . 2 L The Simpson rule : if n is even and H X i + 1 X i L = d X 0 X n f H x L Å x d 3 @ f H X 0 L + 4f H X 1 L + 2f H X 2 L + 4f H X 3 L + ... + 2f H X n 2 L + 4f H X n 1 L + f H X n LD 2 class5-f.nb
Background image of page 2
Some basics of Fortran programming: The parameter statement: must appear before the first executable statement; parameter (pi=3.1415926) assigns a constant value to the variable pi . If statements: if (logical expression) then statements elseif (logical expression) then statements : else statements endif Note: elseif and/or else components above are optional. You can also use if (logical expression) statement mod (n,d) gives the remainder when n is divided by d; e.g. mod(nx,2)=1 means nx is odd. Logical operators: .eq. (meaning =) .ne. (meaning π ) .gt. (meaning >) .ge. (meaning ) .lt. (meaning <) .le. (meaning £ ) .and. .or. (meaning ||) .not. (meaning !) OPEN(unit#, file='filename') can be used to connect a file to a unit#; class5-f.nb 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
WRITE(unit#, format) list write list to a file associated with unit# using a format; unit# =6 or * represents the standard output; format =* means unformatted,
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 11

class5 - PHYS 5900 Class 5 (9/04/2009Fri) Zi-Wei Lin...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online