4 2010.6 1 :, HP.. HP 4 (, PGM/PPM )., python,,, 2, kadai4,.,,, ( )., ( ) N, exn.py ( 3 ex3.py ). N 3.., ( )., ( ) N, (exn.txt).. 1
( ) kadai4, kadai4.zip.,. 3 cos x [ π, π] Python. ( 100 ), x cos x ( ). (, ). def print cos(): print cos(). -3.14159265359-1.0-3.13530946828-0.999980260856-3.12902628298-0.999921044204-3.12274309767-0.999822352381 : for ( 4 10 ) print ( 4 8 ) cos ( 4 3 )., (>). python ex1.py > cos.dat,, gnuplot. gnuplot 2
gnuplot, (gnuplot>). G N U P L O T Version 4.2 patchlevel 4 Send bug reports and suggestions to <http://sourceforge.net/projects/gnuplot> Terminal type set to wxt gnuplot> (gnuplot> ), plot cos.dat. plot cos.dat with lines,. gnuplot gnuplot>, Ctrl-d (Ctrl d)., gnuplot. gnuplot, plot. gnuplot, gnuplot., ( : show.gpl) plot cos.dat pause -1, gnuplot show.gpl.. Excel., (,),.csv (print x,,, cos(x)).,,, gnuplot ( )., Excel. 3
4 n, (): u 0 = 1 u 1 = 1 u n = u n 1 + u n 2 (n 2), u n fib. u 10.. def fib(n): return print fib(10) : for ( 4 7 ),,., Excel.. i u i 2 u i 1 u i 2 1 1 3. n 5, n, u 2, u 3,, u n. i, u i. 4
:, for print, print fib print. def print fib(n): print fib(10). 2 2 3 3 4 5 5 8 6 13 7 21 8 34 9 55 10 89 6... a, b, 2 u 0, u 1 n 2, n (u n ),., a = b = 1, u 0 = u 1 = 1. u n + au n 1 + bu n 2 = 0 (n 2). def print recurrence(a, b, u0, u1, n): print recurrence( 1, 1, 1, 1, 10) 5
7, a = 1, b = 1, 3. a = 0, b = 1, 4, a = 1, b = 1, 6.., 5 a, b?, (gnuplot ). 13?, x 2 + ax + b = 0 2 α, β. α = β, α β, u n = Aα n + Bβ n (A, B u 0, u 1 ). 8 (, ). a, b, u(0), u (0), t, u(t). u (t) + au (t) + bu(t) = 0. def solve de(a, b, u0, u 0, t): solve de(0, 1, 1.0, 1.0, 10.0) t, 0 t, ( t, u(t)), gnuplot. a, b (, a, b ),, ( ). 6
: Excel. t u(t), u (t), u(t + t) t u (t), u (t), u (t + t) t u (t), u (t) u (t), t u(t), u (t), u(t + t), u (t + t). u(0), u (0) u( ). Excel,,. (1), ( ).,, u (t) + u (t) 2 + log u(t) = 0 u (t) + sin u(t) + log t = 0,., u t, u(x, y, t) ( ),.,,,,,. (2) t, u(t) t, LCR. a = 0, b > 0 (ma = kx). a > 0, a (ma = av kx) ( ). b > 0, b,,.. a > 0,,.., : x 2 + ax + b = 0 2 α, β. α = β, α β, u(t) = Ae αt + Be βt (A, B u(0), u (0) ). α, β (, e αt ).,,,, α, β. 7
250 "b.dat" 200 150 100 50 0-50 -100-150 -200 9-250 0 100 200 300 400 500 600 700 800 900 1000,.,,,. a = 0, b > 0,.,., b. t,,.,.,,,.,, 0,,.,,,,., a = 0, b > 0, ( ). 8
,,,,, ( ). :,.,, ( ), 10 PPM 2 f(x, y),. 1. HP 4 (, PGM/PPM ). 2., display. display 3. mi less.,. 4.,, PGM (Portable Grey Map), PPM (Portable Pixel Map).,. 5. PGM ( ) (mi ). P2 w h d G 0,0 G 1,0 G 2,0 G w 1,0 G 0,1 G 1,1 G 2,1 G w 1,1 G 1,h 1 G 2,h 1 G w 1,h 1 9
w, h,,. d,, 255. G i,j (i, j), 0 d. 0, 255,. (i, j), (0,0), i, j.,,. 6. PPM ( ). P3 w h d R 0,0 G 0,0 B 0,0 R 1,0 G 1,0 B 1,0 R 2,0 G 2,0 B 2,0 R w 1,0 G w 1,0 B w 1,0 R 0,1 G 0,1 B 0,1 R 1,1 G 1,1 B 1,1 R 2,1 G 2,1 B 2,1 R w 1,1 G w 1,1 B w 1,1 R 1,h 1 G 1,h 1 B 1,h 1 R 2,h 1 G 2,h 1 B 2,h 1 R w 1,h 1 G w 1,h 1 B w 1,h 1 1 P3, RGB 3. (mi ), 10 10, PPM, display (, ). : (100 ).,.,.., PPM,., 512 256 ( 512, 256) PPM., python,. display.. for for. 10
def print blue ppm(): print P3 print 512,256 print 255 for for print print blue ppm() 11 2 PPM, 2. xy [ 2.0, 2.0] [ 1.0, 1.0], f(x, y) = x2 4 + y2 PPM. PPM ( ex11.ppm) 512 256. f(x, y) 0 (0 0 0), 2.0 (255 0 0),. :.. x ( ), int(x).,. 12 (),.., n c. z 0 = c z n = z 2 n 1 + c (n 1) z n,. c. N, z 0, z 1,, z N 1 ( ) 2 11
( ). a, b, d, M, [a, a + d] [b, b + d] ((a, b) d ) ( PPM )., M, (). (). a = b = 2.0, d = 4.0,.. 2,., z 0, z 1,, z N 1 ( ) 2, n., PPM ( ex12-1.ppm, ex12-2.ppm, ) 13 1. 1,,., 12
,... random() ([0, 1] ). :. A, B., A (y), [ 1, 1]., AB, (θ), [0, 2π]. y θ.,,.,,,.,,,., y θ., Ω = [ 1, 1] [0, 2π]. Ω, (β, θ) A., A Ω., Ω, A., 2, 3 4., Ω, f A (x) = { 1 (x A) 0 (x A), Ω f A(x)dx Ω dx., x Ω, f A (x) ( ). f A (x),.. : Ω, g(x) (x Ω) : x Ω, g(x) Ω g(x)dx Ω dx 13
: x Ω (N ) (x 1,, x N ),. 1 N N g(x i ) i=1,.,,. 14 1 π, 4 3 π. N S N, x 2 1 + + x 2 N 1 N,, S N 1 dx 1 dx 2 dx N. 4. S, N. 15 1. 2, kadai4.zip. 2., MailSuite,., ------------------------------------------------------ : rktau0 : 4 gxxxxxx gxxxxxx 4 CFIVE....... ------------------------------------------------------. kadai4.zip. 14