Lecture Note in Experimental Physics Scientific Writing & Programming

Embed Size (px)

DESCRIPTION

正體中文講義,主要介紹應用Scilab進行科學運算,重點放在如何透過電腦程式的撰寫來幫助我們模擬一些常見的物理現象,透過繪圖的方式來呈現實驗數據並加以分析。作者為林致翰先生。

Text of Lecture Note in Experimental Physics Scientific Writing & Programming

  • Lecture Note in Experimental PhysicsScientific Writing & Programming

    Chih-Han Lin clin@ltl.iams.sinica.edu.tw

    High-Field Physics and Ultrafast Technology Labotary

    Department of National Central University

    Institude of Atomic and Molecular Science, Academica Sinica, Taiwan

    September 15, 2011

  • 2009

    (trial by error)

    (Maple Mathematica)

    ( LinuxWindow ) Scilab Matlab ( Linux Octave Scilab ) Matlab Scilab Matlab Scilab

    i

  • Matlab user-friedly Scilab Scilab scilab c/c++ fortran

    Scilab matlab jpg bmp scilab 16bit datasheet C/P

    Scilab (NIF) ImageJ GUI

    Scilab Scilab matlab Youtube

    XeLateX 102

    September, 2011

  • GUI

    Scilab

    50% self-learning

    September, 2009

    iii

  • iv

  • Contents

    1 1

    1.1 OpenOffice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    1.2 LATEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

    1.2.1 Miktex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    1.2.2 TeXworks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    1.2.3 Online LATEX Math editor . . . . . . . . . . . . . . . . . . . . . . 3

    1.2.4 OOoLaTeX* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    1.2.5 LATEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    1.3 LATEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    1.3.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    1.3.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    2 Scilab 11

    2.1 Scilab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

    2.1.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

    2.1.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    2.1.3 Scilab . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

    v

  • vi CONTENTS

    2.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

    2.2.1 (console) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

    2.2.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    2.2.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    2.2.4 string . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    2.2.5 Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

    2.2.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

    2.2.7 I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

    2.2.8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

    3 29

    3.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

    3.1.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

    3.1.2 error bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

    3.1.3 Student's t-test . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

    3.1.5 which is better? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

    3.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    3.2.2 . . . . . . . . . . . . . . . . . . . . . . . . . . 36

    3.2.3 RC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

    3.3 Scilab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

    3.3.1 . . . . . . . . . . . . . . . . . . . . . . . . . . 38

    3.3.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

    3.3.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

    3.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

  • CONTENTS vii

    3.4.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

    3.4.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

    3.4.3 g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

    3.4.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

    A Runge-Kutta 51

    A.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

    A.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

    B LaTEX - RevTEX 55

  • viii CONTENTS

  • Chapter1

    Herodotus relates that Xerxes wept at the sight of hisarmy, which stretched further than the eye could reach,in the thought that of all these, after a hundred years,not one would be alive. And in looking over a hugecatalogue of new books, one might weep at thinking that,when ten years have passed, not one of them will be heardof.

    Arthur Schopenhauer

    1.1 OpenOffice

    OpenOffice http://zh.openoffice.org/new/zh_tw/ OpenOffice OpenOffice LATEX (OooLatex)OpenOffice pdf Portable Document Formatpdf MS Word pdf

    pdf

    1

  • 2 Chapter.1

    Acrobat Reader http://get.adobe.com/tw/reader/Foxit Reader http://www.foxitsoftware.com/pdf/reader/PDF-XChange Viewer http://pdf-xchange-viewer.en.softonic.com/

    Openoffice writer MS office Word! ( [F11]) ! !

    Ctrl + Enter Enter ! ! pdf ! pdf

    1.2 LATEX

    ``It has often been said that a person does not really understand something until heteaches it to someone else. Actually a person does not really understand something untilafter teaching it to a computer, i.e., express it as an algorithm.''

    Donald Knuth, in "American Mathematical Monthly," 81

    TeX Stanford Don Knuth () Knuth "The Art Of ComputerProgrammnig " ``American Scientist" Dirac Einstein Knuth Knuth literate programming plain TEX Metafont TEX TEX LATEX Lamport TEX TEX

  • 1.2. LATEX 3

    LATEX ( APS RevTeX4) LATEX LATEX LATEX LATEX LATEX macro LATEX unicode

    1.2.1 Miktex

    WINDOWS TEX distribution Miktex http://miktex.org/ 2.9 TEX TEXOpenOffice LATEX LATEX office LATEX LATEX

    1.2.2 TeXworks

    MikTeX TeXworksLATEX LATEX

    1.2.3 Online LATEX Math editor

    (png, pdf, svg, emf) LATEX online editorhttp://www.codecogs.com/latex/eqneditor.php

    LATEX LATEX Inkscape, CorelDraw svg MS powerpoint office emf

  • 4 Chapter.1

    300 dpi png pdf pdf Acrobat Reader X ! ! / ( dpi) 720 dpi pdf

    1.2.4 OOoLaTeX*

    LATEX OpenOffice OOoLaTeX LATEX compile equation compile LATEX

    OpenOffice LATEX

    OpenOffice OOoLaTeX (from http://ooolatex.sourceforge.net/) Miktex or other distribution MSYS (for OOoLaTeX , http://www.mingw.org/wiki/msys) Ghostscript (from http://pages.cs.wisc.edu/~ghost/) math fonts (from OOoLaTeX website)

    OOoLaTeX OpenOffice OOoLaTeX but-ton Config LatexGhostscript MinSYS (MSYS)

    Latex: C:\ProgramFiles\MiKTeX2.7\miktex\bin\ Ghostscript: C:\ProgramFiles\gs\gs8.60\bin\ MinSYS: \C:\msys\1.0\bin\

    1.2.5 LATEX

    cwTEX

  • 1.3. LATEX 5

    http://homepage.ntu.edu.tw/~ntut019/cwtex/cwtex.html

    TEX (unicode TEX Big5 unicode LATEX TEX CJKutf8 package XeLATEX ) FAQ

    (AMS) Short Math Guide for LATEX

    http://amath.colorado.edu/documentation/LaTeX/Symbols.pdf

    colorado's LATEX online tutorials

    http://amath.colorado.edu/documentation/LaTeX/tutorial/

    1.3 LATEX

    1.3.1

    LATEX n ( 7 ! Enter ) { } \LaTeX{} LATEX: $\sqrt{\pi}$ p \frac

    $\frac{1}{2}$ 12

  • 6 Chapter.1

    $\sqrt[3]{\frac{1}{2}}$ 3q

    12

    [] ()\sqrt []

    LATEX ( unicode ):

    \%!%, \&!&, \#!#, \$!$, \verb+~+ ! ~, \verb+^+! ^, \_{}!_ ,

    $\Omega$ $\omega$ !LaTEX \\ LaTEX

    1.3.2

    cwTEX LATEX

    (inline): $ ( Shift * + 4 ) $$ $\sqrt{\pi}$ p $\sqrt{1}{2}$ 1

    2

    \displaystyle $\displaystyle\frac{1}{2}$ 1

    2 \displaystyle

    $1/2$ 1/2

  • 1.3. LATEX 7

    (display): \begin

    \begin{displaymath}\sum_{k=0}^{n}\frac{1}{n}=1+\frac -

    {1}{2}+\frac{1}{3}+\cdots+\ -frac{1}{n}.

    \end{displaymath}

    nXk=0

    1

    n= 1 +

    1

    2+

    1

    3+ + 1

    n:

    \[ \] $$ $$ \displaystyle

    \begin{displaymath}\frac{1}{1+\frac{1}{1+\frac -

    {1}{1+\cdots}}}.\end{displaymath}

    1

    1 + 11+ 1

    1+

    :

    \begin{displaymath}\frac{1}{1+\displaystyle\frac -

    {1}{1+\displaystyle\frac -{1}{1+\cdots}}}.

    \end{displaymath}

    1

    1 +1

    1 +1

    1 +

    :

    \begin{equation} ...\end{ equation} \begin{eqnarray}...\end{eqnarray} amsmath \begin{align}... \end{align} align eqnarray LATEX

    \begin{eqnarray}a_1&=&k_1=b_1+c_1,~~~~d_1=e_1+f_1,\\a_2&=&k_2=b_2+c_2,~~~~d_1=e_1+f_1.\end{eqnarray}

  • 8 Chapter.1

    a1 = k1 = b1 + c1; d1 = e1 + f1; (1.1)a2 = k2 = b2 + c2; d1 = e1 + f1: (1.2)

    eqnarray & eqnarray align

    \begin{align}a_1&=k_1=b_1+c_1, & d_1&=e_1+f_1,\\a_2&=k_2=b_2+c_2, & d_1&=e_1+f_1.\end{align}

    a1 = k1 = b1 + c1; d1 = e1 + f1; (1.3)a2 = k2 = b2 + c2; d1 = e1 + f1: (1.4)

    & & align align* \notag \tag

    \addtocounter{equation}{+1}\begin{align}\notag a_1&=k_1=b_1+c_1, & d_1&=e_1+f_1,\\a_2&=k_2=b_2+c_2, & d_1&=e_1+f_1.\tag{\Roman{chapter}.\arabic{equation}a,b}\end{align}

    a1 = k1 = b1 + c1; d1 = e1 + f1;

    a2 = k2 = b2 + c2; d1 = e1 + f1: (I.5a,b)

    \notag \tag equation \addtocounter{equation}{+1} \tag \Roman \arabic

  • 1.3. LATEX 9

    Ex 1.3.3

    \frac

    \[\nabla^2\Phi=\frac{1}{r^2}\left[\ -frac{\partial}{\partial r}\left( -r^2\frac{\partial\Phi}{\partial -r}\right)+\cdots\right].\]

    r2 = 1r2

    @

    @r

    r2@

    @r