Microsoft Word - 03-数値計算の基礎.docx

Similar documents
Microsoft Word - 資料 (テイラー級数と数値積分).docx

Microsoft Word - 資料 docx

情報活用資料

joho09.ppt

. (.8.). t + t m ü(t + t) + c u(t + t) + k u(t + t) = f(t + t) () m ü f. () c u k u t + t u Taylor t 3 u(t + t) = u(t) + t! u(t) + ( t)! = u(t) + t u(

(2-1) x, m, 2 N(m, 2 ) x REAL*8 FUNCTION NRMDST (X, M, V) X,M,V REAL*8 x, m, 2 X X N(0,1) f(x) standard-norm.txt normdist1.f x=0, 0.31, 0.5

3. :, c, ν. 4. Burgers : u t + c u x = ν 2 u x 2, (3), ν. 5. : u t + u u x = ν 2 u x 2, (4), c. 2 u t 2 = c2 2 u x 2, (5) (1) (4), (1 Navier Stokes,.,

3. :, c, ν. 4. Burgers : t + c x = ν 2 u x 2, (3), ν. 5. : t + u x = ν 2 u x 2, (4), c. 2 u t 2 = c2 2 u x 2, (5) (1) (4), (1 Navier Stokes,., ν. t +

all.dvi

情報活用資料

C 2 / 21 1 y = x 1.1 lagrange.c 1 / Laglange / 2 #include <stdio.h> 3 #include <math.h> 4 int main() 5 { 6 float x[10], y[10]; 7 float xx, pn, p; 8 in

演習2

I

数学の基礎訓練I

num3.dvi

p-sylow :


) 9 81

GraphicsWithPlotFull.nb Plot[{( 1), ( ),...}, {( ), ( ), ( )}] Plot Plot Cos x Sin x, x, 5 Π, 5 Π, AxesLabel x, y x 1 Plot AxesLabel

y = x 4 y = x 8 3 y = x 4 y = x 3. 4 f(x) = x y = f(x) 4 x =,, 3, 4, 5 5 f(x) f() = f() = 3 f(3) = 3 4 f(4) = 4 *3 S S = f() + f() + f(3) + f(4) () *4

演習1

スライド 1

微分積分 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. このサンプルページの内容は, 初版 1 刷発行時のものです.

1 α X (path) α I = [0, 1] X α(0) = α(1) = p α p (base point) loop α(1) = β(0) X α, β α β : I X (α β)(s) = ( )α β { α(2s) (0 s 1 2 ) β(2s 1) ( 1 2 s 1)

Collatzの問題 (数学/数理科学セレクト1)

ii

18 ( ) I II III A B C(100 ) 1, 2, 3, 5 I II A B (100 ) 1, 2, 3 I II A B (80 ) 6 8 I II III A B C(80 ) 1 n (1 + x) n (1) n C 1 + n C

68 A mm 1/10 A. (a) (b) A.: (a) A.3 A.4 1 1

num2.dvi

Fortran90/95 [9]! (1 ) " " 5 "Hello!"! 3. (line) Fortran Fortran 1 2 * (1 ) 132 ( ) * 2 ( Fortran ) Fortran ,6 (continuation line) 1

f(x) = f(x ) + α(x)(x x ) α(x) x = x. x = f (y), x = f (y ) y = f f (y) = f f (y ) + α(f (y))(f (y) f (y )) f (y) = f (y ) + α(f (y)) (y y ) ( (2) ) f

, 1 ( f n (x))dx d dx ( f n (x)) 1 f n (x)dx d dx f n(x) lim f n (x) = [, 1] x f n (x) = n x x 1 f n (x) = x f n (x) = x 1 x n n f n(x) = [, 1] f n (x


1. A0 A B A0 A : A1,...,A5 B : B1,...,B

情報処理概論(第二日目)

9 2 1 f(x, y) = xy sin x cos y x y cos y y x sin x d (x, y) = y cos y (x sin x) = y cos y(sin x + x cos x) x dx d (x, y) = x sin x (y cos y) = x sin x

/02/18

スライド 1

all.dvi

cpall.dvi

08 p Boltzmann I P ( ) principle of equal probability P ( ) g ( )g ( 0 ) (4 89) (4 88) eq II 0 g ( 0 ) 0 eq Taylor eq (4 90) g P ( ) g ( ) g ( 0

No δs δs = r + δr r = δr (3) δs δs = r r = δr + u(r + δr, t) u(r, t) (4) δr = (δx, δy, δz) u i (r + δr, t) u i (r, t) = u i x j δx j (5) δs 2

C 2 2.1? 3x 2 + 2x + 5 = 0 (1) 1

D xy D (x, y) z = f(x, y) f D (2 ) (x, y, z) f R z = 1 x 2 y 2 {(x, y); x 2 +y 2 1} x 2 +y 2 +z 2 = 1 1 z (x, y) R 2 z = x 2 y

x = a 1 f (a r, a + r) f(a) r a f f(a) 2 2. (a, b) 2 f (a, b) r f(a, b) r (a, b) f f(a, b)

1F90/kouhou_hf90.dvi

86 6 r (6) y y d y = y 3 (64) y r y r y r ϕ(x, y, y,, y r ) n dy = f(x, y) (6) 6 Lipschitz 6 dy = y x c R y(x) y(x) = c exp(x) x x = x y(x ) = y (init

1 4 1 ( ) ( ) ( ) ( ) () 1 4 2

Microsoft PowerPoint - NA03-09black.ppt

1 u t = au (finite difference) u t = au Von Neumann

Microsoft PowerPoint - IntroAlgDs-05-5.ppt

基礎数学I

II A A441 : October 02, 2014 Version : Kawahira, Tomoki TA (Kondo, Hirotaka )

A B P (A B) = P (A)P (B) (3) A B A B P (B A) A B A B P (A B) = P (B A)P (A) (4) P (B A) = P (A B) P (A) (5) P (A B) P (B A) P (A B) A B P

1 1.1 ( ). z = a + bi, a, b R 0 a, b 0 a 2 + b 2 0 z = a + bi = ( ) a 2 + b 2 a a 2 + b + b 2 a 2 + b i 2 r = a 2 + b 2 θ cos θ = a a 2 + b 2, sin θ =

最小二乗フィット、カイ二乗フィット、gnuplot

1 1 [1] ( 2,625 [2] ( 2, ( ) /

( 28 ) ( ) ( ) 0 This note is c 2016, 2017 by Setsuo Taniguchi. It may be used for personal or classroom purposes, but not for commercial purp

DVIOUT


9 8 7 (x-1.0)*(x-1.0) *(x-1.0) (a) f(a) (b) f(a) Figure 1: f(a) a =1.0 (1) a 1.0 f(1.0)

直交座標系の回転

05 I I / 56

スライド 1

sim0004.dvi

1 8, : 8.1 1, 2 z = ax + by + c ax by + z c = a b +1 x y z c = 0, (0, 0, c), n = ( a, b, 1). f = n i=1 a ii x 2 i + i<j 2a ij x i x j = ( x, A x), f =

I

C言語による数値計算プログラミング演習

n 第1章 章立ての部分は、書式(PC入門大見出し)を使います

2009 IA 5 I 22, 23, 24, 25, 26, (1) Arcsin 1 ( 2 (4) Arccos 1 ) 2 3 (2) Arcsin( 1) (3) Arccos 2 (5) Arctan 1 (6) Arctan ( 3 ) 3 2. n (1) ta

IA 2013 : :10722 : 2 : :2 :761 :1 (23-27) : : ( / ) (1 /, ) / e.g. (Taylar ) e x = 1 + x + x xn n! +... sin x = x x3 6 + x5 x2n+1 + (

tomocci ,. :,,,, Lie,,,, Einstein, Newton. 1 M n C. s, M p. M f, p d ds f = dxµ p ds µ f p, X p = X µ µ p = dxµ ds µ p. µ, X µ.,. p,. T M p.

Excel ではじめる数値解析 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. このサンプルページの内容は, 初版 1 刷発行時のものです.


main.dvi

untitled

1 = = = (set) (element) a A a A a A a A a A {2, 5, (0, 1)}, [ 1, 1] = {x; 1 x 1}. (proposition) A = {x; P (x)} P (x) x x a A a A Remark. (i) {2, 0, 0,

Microsoft Word - FT_2010.doc

I A A441 : April 15, 2013 Version : 1.1 I Kawahira, Tomoki TA (Shigehiro, Yoshida )

TOP URL 1

1 1 sin cos P (primary) S (secondly) 2 P S A sin(ω2πt + α) A ω 1 ω α V T m T m 1 100Hz m 2 36km 500Hz. 36km 1

2000年度『数学展望 I』講義録

i

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裱£²²ó ¡Ý½ÉÂꣲ¤Î²òÀ⡤±é½¬£²¡Ý

( )/2 hara/lectures/lectures-j.html 2, {H} {T } S = {H, T } {(H, H), (H, T )} {(H, T ), (T, T )} {(H, H), (T, T )} {1

コンピュータ概論

スライド 1

°ÌÁê¿ô³ØII

格子QCD実践入門

A S hara/lectures/lectures-j.html ϵ-n 1 ϵ-n lim n a n = α n a n α 2 lim a n = 0 1 n a k n n k= ϵ

all.dvi

17 ( ) II III A B C(100 ) 1, 2, 6, 7 II A B (100 ) 2, 5, 6 II A B (80 ) 8 10 I II III A B C(80 ) 1 a 1 = 1 2 a n+1 = a n + 2n + 1 (n = 1,

³ÎΨÏÀ

,. Black-Scholes u t t, x c u 0 t, x x u t t, x c u t, x x u t t, x + σ x u t, x + rx ut, x rux, t 0 x x,,.,. Step 3, 7,,, Step 6., Step 4,. Step 5,,.

11042 計算機言語7回目 サポートページ:

2

1 filename=mathformula tex 1 ax 2 + bx + c = 0, x = b ± b 2 4ac, (1.1) 2a x 1 + x 2 = b a, x 1x 2 = c a, (1.2) ax 2 + 2b x + c = 0, x = b ± b 2

untitled

I, II 1, A = A 4 : 6 = max{ A, } A A 10 10%

Chap11.dvi

Transcription:

δx f x 0 + δ x n=0 a n = f ( n) ( x 0 ) n δx n f x x=0 sin x = x x3 3 + x5 5 x7 7 +... x ( ) = a n δ x n ( ) = sin x ak = (-mod(k,2))**(k/2) / fact_k 10

11

I = f x dx a ΔS = f ( x)h I = f a h I = h b ( ) ( ) + f ( a + h) +...+ f ( a + ih) +... + f ( b h) N 1 i=1 ΔS = 1 2 ( ) f a + ih f ( x) + f ( x + h) h I = 1 2 f a ( ) + 2 f ( a + h ) +... + 2 f ( a + ih ) +... + 2 f ( b h) + f ( b) h 12

積分法 地球惑星内部物理学演習 B 資料3 端以外の係数が2になっている まとめると I= N 1 1 f a + 2 f ( a + ih ) + f ( b ) h ( ) 2 (16) i =1 である 台形法は2次の打ち切り誤差を持つ め足し合わせる y y=f(x) 似 積分 f(x) a f(x+h) h b x てを2次以上の多項式で近似 2.3 シンプソン法 h N /2 近接するいくつかの区間を1まとめにして より高次の次数をもつ多項式で関数を近似 する方法である 精度は補間する関数の次数で決まる 例えば 区間[a,b]を偶数個nに 等分し 2つまとめにすると 3点を用いて2次多項式を当てはめることができる こ f (b ) h 2 f ( a + 2ih ) + のとき 小区間を2つ合わせた区間の面積は =1 ΔS = 1 f ( x ) + 4 f ( x + h ) + f ( x + 2h ) h 3 (17) である このとき 区間[a, b]全体では 1 I = [ f ( a ) + 4 f ( a + h ) + 2 f ( a + 2h )... 3 + 2 f ( a + 2ih ) + 4 f ( a + {2i + 1} h ) +... + 2 f ( b 2h ) + 4 f ( b h ) + f ( b )]h (18) となる 係数が 1 4 2 4 2 2 4 1となっている 2は小区間を2つ にまとめたΔS のつなぎ目である まとめると I= N /2 1 N /2 1 f a + 4 f a + 2i + 1 h + 2 f ( a + 2ih ) + f ( b ) h ( ) { } ( ) 3 i =1 i =1 となる 2次式で近似する方法は3次の打ち切り誤差を持つ 13 (19)

f x x 2/ π ( ) ( ) = e x2 = exp x 2 erf x ( ) = 2 π 0 x ( ) exp ζ 2 dζ x= 2/ π x= ( )2 1 f (x) = 2πσ exp x µ 2 2σ 2 x 2 14

f x x = g x ( ) = 0 ( ) x n+1 = g x n ( ) n x 0 g(x) x 1 = g x 0 ( ) x n+1 = x n x = x n+1 y y=x g(x) g(x 3 ) g(x 2 ) g(x 1 ) y=g(x) x 1 x 2 x 3... x x 15

ϕ x g x ( ) 0 ( ) = x ϕ ( x) f x x = g x ( ) x ϕ ( x) = g x x = g x 1 f x ( ) x n+1 = x n f x n ( ) ( ) = x f ( x) f ( x) ( ) ( ) f ( ) x n x y y=f(x) y=f (x 1 )(x-x 2 ) x x 3 x 2 x 1 x 16

t f ( x) = x esin x 2πt = 0 T e x t T t x x e = a2 b 2 a 2 (41) ab E E E x http://www.toyama-cmt.ac.jp/~mkawai/lecture/radionav/orbit/body2/anomaly/keplerequa.html e x t 17

f95 taylor.f t_sine.f ****** Calculate sine by Talor-series expansion ****** program taylor implicit none integer i, n, ns real(8):: dx, xmax, pi real(8), allocatable:: x(:),s1(:),s2(:) real(8):: T_sine character(20):: fmt1 pi = 4.0d0 * atan(1.0d0) fmt1 = '(3f12.7)' write (6,*) 'Input number of samples for 1 period' read (5,*) ns write (6,*) 'Your input for number of samples = ',ns dx = 2.0d0 * pi / dfloat(ns) allocate ( x(0:ns),s1(0:ns),s2(0:ns) ) write (6,*) 'Input maximum order of Taylor series' 18

read (5,*) n write (6,*) 'Your input maximum order of Taylor series = ',n write (6,*) write (6,*) ' x sin(x) T_sine(x)' open (10,file='mysine.dat') do i = 0,ns x(i) = dx * dble(i) s1(i) = dsin(x(i)) s2(i) = T_sine(x(i),n) write ( 6,fmt1) x(i), s1(i), s2(i) write (10,fmt1) x(i), s1(i), s2(i) end do stop end program taylor ****** function T_sine ***************************************** function T_sine(x,n) implicit none integer:: k, n real(8):: pi real(8):: x, xp, fact_k, ak, fk real(8):: T_sine_k real(8):: T_sine real(8),parameter:: eps = 1.0d-10 19

pi = 4.0d0 * atan(1.0d0) initalize: f(x=0) = sin(0), 0 = 1, x**0 = 1.0 T_sine_k = 0.0d0 fact_k = 1.0d0 xp = 1.0d0 take summation sigma_( a(i)*x**i ) for i = 1 to n do k = 1,n fact_k = fact_k * dfloat(k) calculate factorial real(k) ak = (-mod(k,2))**(k/2) / fact_k coefficient of the series xp = xp * x fk = ak * xp calculate xp = x**k k-th order term T_sine_k = T_sine_k + fk calculate summation end do T_sine = T_sine_k return end function T_sine 20

real(8), allocatable:: x(:),s1(:),s2(:) allocate ( x(0:ns),s1(0:ns),s2(0:ns) ) real(8):: T_sine T_sine T_sine s2(i) = T_sine(x(i),n) T_sine write (10,500) x(i), s1(i), s2(i) real*8 function T_sine(x,n) T_sine = T_sine_k return 21

plot 'mysine.dat' using 1:2 plot 'mysine.dat' using 1:2, 'mysine.dat' using 1:3 plot 'mysine.dat' using 1:2 replot 'mysine.dat' using 1:3 replot 22

** Error function ** Numerical integration by trapezoid method program trapezoid_i implicit none integer, parameter:: n = 1000 integer:: i real(8):: f(0:n) real(8):: x,x1,x2,dx real(8):: s1,sall real(8):: erf real(8):: pi,rootpi write (6,*) 'x1 =' read (5,*) x1 x1 = 0.0d0 write (6,*) 'x =' read (5,*) x2 dx = ( x2-x1 ) / dfloat( n ) do i = 0,n x = x1 + dx * dfloat(i) f(i) = exp( - x**2 ) end do s1 = 0.0d0 do i = 1,n-1 s1 = s1 + 2.0d0*f(i) end do 23

sall = dx * 0.5d0 * ( f(0) + s1 + f(n) ) pi = 4.0d0 * atan( 1.0d0 ) rootpi = sqrt( pi ) erf = 2.0d0 / rootpi * sall write (6,*) 'Integral F = ',sall write (6,*) 'erf(',x2,')= ',erf stop end program trapezoid_i integer, parameter:: n = 1000n real(8):: f(0:n) f(i) = exp( - x**2 ) sall s1 = s1 + 2.0d0*f(i) s 1 = n 1 i=1 ( ) f x i s1 24

Solve 2nd-order algebraic equation ax^2+bx+c=0 by a Newton method program newton implicit none real(4), parameter:: eps=1.0e-6 real(4):: a,b,c,x,fx,dfdx,xini,corr integer:: itr,nitr write (6,*) 'input a,b,c (use space between numbers)' read (5,*) a,b,c write (6,*) 'input inital guess' read (5,*) xini write (6,*) 'input maximum iteration' read (5,*) nitr x = xini Iteration do itr = 1,nitr fx = a*x**2 + b*x + c dfdx = 2.0 * a * x + b corr = fx / dfdx write (6,*) itr,x,fx,dfdx,corr x = x - corr If ( abs(corr/x).lt. eps ) Exit Exit loop if convergent end do write (6,*) 'solution x = ',x stop 25

end program newton dfdx = 2.0 * a * x + b x = x - corr If ( abs(corr/x).lt. eps ) Exit 26