x h = (b a)/n [x i, x i+1 ] = [a+i h, a+ (i + 1) h] A(x i ) A(x i ) = h 2 {f(x i) + f(x i+1 ) = h {f(a + i h) + f(a + (i + 1) h), (2) 2 a b n A(x i )

Similar documents
x(t) + t f(t, x) = x(t) + x (t) t x t Tayler x(t + t) = x(t) + x (t) t + 1 2! x (t) t ! x (t) t 3 + (15) Eular x t Teyler 1 Eular 2 Runge-Kutta

C による数値計算法入門 ( 第 2 版 ) 新装版 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. このサンプルページの内容は, 新装版 1 刷発行時のものです.


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

A

‚æ4›ñ

(1) + b = b +, (2) b = b, (3) + 0 =, (4) 1 =, (5) ( + b) + c = + (b + c), (6) ( b) c = (b c), (7) (b + c) = b + c, (8) ( + b)c = c + bc (9

c-all.dvi

P06.ppt

() Remrk I = [0, ] [x i, x i ]. (x : ) f(x) = 0 (x : ) ξ i, (f) = f(ξ i )(x i x i ) = (x i x i ) = ξ i, (f) = f(ξ i )(x i x i ) = 0 (f) 0.

ax 2 + bx + c = n 8 (n ) a n x n + a n 1 x n a 1 x + a 0 = 0 ( a n, a n 1,, a 1, a 0 a n 0) n n ( ) ( ) ax 3 + bx 2 + cx + d = 0 4

1 4 2 EP) (EP) (EP)

d dt A B C = A B C d dt x = Ax, A 0 B 0 C 0 = mm 0 mm 0 mm AP = PΛ P AP = Λ P A = ΛP P d dt x = P Ax d dt (P x) = Λ(P x) d dt P x =

スライド 1

x () g(x) = f(t) dt f(x), F (x) 3x () g(x) g (x) f(x), F (x) (3) h(x) = x 3x tf(t) dt.9 = {(x, y) ; x, y, x + y } f(x, y) = xy( x y). h (x) f(x), F (x

2012 IA 8 I p.3, 2 p.19, 3 p.19, 4 p.22, 5 p.27, 6 p.27, 7 p

,. 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,,.

error_g1.eps

() x + y + y + x dy dx = 0 () dy + xy = x dx y + x y ( 5) ( s55906) 0.7. (). 5 (). ( 6) ( s6590) 0.8 m n. 0.9 n n A. ( 6) ( s6590) f A (λ) = det(a λi)

A

A A = a 41 a 42 a 43 a 44 A (7) 1 (3) A = M 12 = = a 41 (8) a 41 a 43 a 44 (3) n n A, B a i AB = A B ii aa


Chap11.dvi

7. y fx, z gy z gfx dz dx dz dy dy dx. g f a g bf a b fa 7., chain ule Ω, D R n, R m a Ω, f : Ω R m, g : D R l, fω D, b fa, f a g b g f a g f a g bf a

[1] #include<stdio.h> main() { printf("hello, world."); return 0; } (G1) int long int float ± ±

( ) 1 1: 1 #include <s t d i o. h> 2 #include <GL/ g l u t. h> 3 #include <math. h> 4 #include <s t d l i b. h> 5 #include <time. h>

j x j j j + 1 l j l j = x j+1 x j, n x n x 1 = n 1 l j j=1 H j j + 1 l j l j E

CALCULUS II (Hiroshi SUZUKI ) f(x, y) A(a, b) 1. P (x, y) A(a, b) A(a, b) f(x, y) c f(x, y) A(a, b) c f(x, y) c f(x, y) c (x a, y b)

v er.1/ c /(21)

joho09.ppt

2014 S hara/lectures/lectures-j.html r 1 S phone: ,

DVIOUT

y = f(x) y = f( + h) f(), x = h dy dx f () f (derivtive) (differentition) (velocity) p(t) =(x(t),y(t),z(t)) ( dp dx dt = dt, dy dt, dz ) dt f () > f x

/* do-while */ #include <stdio.h> #include <math.h> int main(void) double val1, val2, arith_mean, geo_mean; printf( \n ); do printf( ); scanf( %lf, &v

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)

sim0004.dvi

mugensho.dvi

(search: ) [1] ( ) 2 (linear search) (sequential search) 1

#define N1 N+1 double x[n1] =.5, 1., 2.; double hokan[n1] = 1.65, 2.72, 7.39 ; double xx[]=.2,.4,.6,.8,1.2,1.4,1.6,1.8; double lagrng(double xx); main

r 1 m A r/m i) t ii) m i) t B(t; m) ( B(t; m) = A 1 + r ) mt m ii) B(t; m) ( B(t; m) = A 1 + r ) mt m { ( = A 1 + r ) m } rt r m n = m r m n B

y π π O π x 9 s94.5 y dy dx. y = x + 3 y = x logx + 9 s9.6 z z x, z y. z = xy + y 3 z = sinx y 9 s x dx π x cos xdx 9 s93.8 a, fx = e x ax,. a =

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

body.dvi

PowerPoint Presentation

x i [, b], (i 0, 1, 2,, n),, [, b], [, b] [x 0, x 1 ] [x 1, x 2 ] [x n 1, x n ] ( 2 ). x 0 x 1 x 2 x 3 x n 1 x n b 2: [, b].,, (1) x 0, x 1, x 2,, x n


2017 p vs. TDGL 4 Metropolis Monte Carlo equation of continuity s( r, t) t + J( r, t) = 0 (79) J s flux (67) J (79) J( r, t) = k δf δs s( r,

$ ls -l $ ls -l -a $ ls -la $ ls -F $ ls <dirname> <dirname> $ cd <dirname> <dirname> $ cd $ pwd $ cat <filename> <filename> $ less <filename> <filena

- II

数値計算:常微分方程式

4 R f(x)dx = f(z) f(z) R f(z) = lim R f(x) p(x) q(x) f(x) = p(x) q(x) = [ q(x) [ p(x) + p(x) [ q(x) dx =πi Res(z ) + Res(z )+ + Res(z n ) Res(z k ) k

(, ) (, ) S = 2 = [, ] ( ) 2 ( ) 2 2 ( ) 3 2 ( ) 4 2 ( ) k 2,,, k =, 2, 3, 4 S 4 S 4 = ( ) 2 + ( ) ( ) (

1 return main() { main main C 1 戻り値の型 関数名 引数 関数ブロックをあらわす中括弧 main() 関数の定義 int main(void){ printf("hello World!!\n"); return 0; 戻り値 1: main() 2.2 C main

C言語によるアルゴリズムとデータ構造

18 C ( ) hello world.c 1 #include <stdio.h> 2 3 main() 4 { 5 printf("hello World\n"); 6 } [ ] [ ] #include <stdio.h> % cc hello_world.c %./a.o

4 4 4 a b c d a b A c d A a da ad bce O E O n A n O ad bc a d n A n O 5 {a n } S n a k n a n + k S n a a n+ S n n S n n log x x {xy } x, y x + y 7 fx

スライド 1

1/1 lim f(x, y) (x,y) (a,b) ( ) ( ) lim limf(x, y) lim lim f(x, y) x a y b y b x a ( ) ( ) xy x lim lim lim lim x y x y x + y y x x + y x x lim x x 1

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

I. Backus-Naur BNF S + S S * S S x S +, *, x BNF S (parse tree) : * x + x x S * S x + S S S x x (1) * x x * x (2) * + x x x (3) + x * x + x x (4) * *

スライド 1

橡CompSimmAllcpct.PDF

II (10 4 ) 1. p (x, y) (a, b) ε(x, y; a, b) 0 f (x, y) f (a, b) A, B (6.5) y = b f (x, b) f (a, b) x a = A + ε(x, b; a, b) x a 2 x a 0 A = f x (

USB ID TA DUET 24:00 DUET XXX -YY.c ( ) XXX -YY.txt() XXX ID 3 YY ID 5 () #define StudentID 231

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

:30 12:00 I. I VI II. III. IV. a d V. VI

DOPRI5.dvi

i

PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU

Morse ( ) 2014


simx simxdx, cosxdx, sixdx 6.3 px m m + pxfxdx = pxf x p xf xdx = pxf x p xf x + p xf xdx 7.4 a m.5 fx simxdx 8 fx fx simxdx = πb m 9 a fxdx = πa a =

P05.ppt

第3章 OpenGL の基礎

text.dvi

1 R n (x (k) = (x (k) 1,, x(k) n )) k 1 lim k,l x(k) x (l) = 0 (x (k) ) 1.1. (i) R n U U, r > 0, r () U (ii) R n F F F (iii) R n S S S = { R n ; r > 0

スライド 1

, x R, f (x),, df dx : R R,, f : R R, f(x) ( ).,, f (a) d f dx (a), f (a) d3 f dx 3 (a),, f (n) (a) dn f dx n (a), f d f dx, f d3 f dx 3,, f (n) dn f

第3章 OpenGL の基礎

2 : 2008/12/ /01/ G :

<4D F736F F D B B83578B6594BB2D834A836F815B82D082C88C60202E646F63>

Bessel ( 06/11/21) Bessel 1 ( ) 1.1 0, 1,..., n n J 0 (x), J 1 (x),..., J n (x) I 0 (x), I 1 (x),..., I n (x) Miller (Miller algorithm) Bess

f : R R f(x, y) = x + y axy f = 0, x + y axy = 0 y 直線 x+y+a=0 に漸近し 原点で交叉する美しい形をしている x +y axy=0 X+Y+a=0 o x t x = at 1 + t, y = at (a > 0) 1 + t f(x, y


( z = x 3 y + y ( z = cos(x y ( 8 ( s8.7 y = xe x ( 8 ( s83.8 ( ( + xdx ( cos 3 xdx t = sin x ( 8 ( s84 ( 8 ( s85. C : y = x + 4, l : y = x + a,

1 No.1 5 C 1 I III F 1 F 2 F 1 F 2 2 Φ 2 (t) = Φ 1 (t) Φ 1 (t t). = Φ 1(t) t = ( 1.5e 0.5t 2.4e 4t 2e 10t ) τ < 0 t > τ Φ 2 (t) < 0 lim t Φ 2 (t) = 0

A/B (2010/10/08) Ver kurino/2010/soft/soft.html A/B

Informatics 2010.key

<4D F736F F D B B83578B6594BB2D834A836F815B82D082C88C60202E646F63>

II

(1) (2) (3) (4) HB B ( ) (5) (6) (7) 40 (8) (9) (10)

1

x (x, ) x y (, y) iy x y z = x + iy (x, y) (r, θ) r = x + y, θ = tan ( y ), π < θ π x r = z, θ = arg z z = x + iy = r cos θ + ir sin θ = r(cos θ + i s

C ( ) C ( ) C C C C C 1 Fortran Character*72 name Integer age Real income 3 1 C mandata mandata ( ) name age income mandata ( ) mandat

z f(z) f(z) x, y, u, v, r, θ r > 0 z = x + iy, f = u + iv C γ D f(z) f(z) D f(z) f(z) z, Rm z, z 1.1 z = x + iy = re iθ = r (cos θ + i sin θ) z = x iy

関数のグラフを描こう

2.2 ( y = y(x ( (x 0, y 0 y (x 0 (y 0 = y(x 0 y = y(x ( y (x 0 = F (x 0, y(x 0 = F (x 0, y 0 (x 0, y 0 ( (x 0, y 0 F (x 0, y 0 xy (x, y (, F (x, y ( (

f(x) = x (1) f (1) (2) f (2) f(x) x = a y y = f(x) f (a) y = f(x) A(a, f(a)) f(a + h) f(x) = A f(a) A x (3, 3) O a a + h x 1 f(x) x = a

x ( ) x dx = ax

5.. z = f(x, y) y y = b f x x g(x) f(x, b) g x ( ) A = lim h 0 g(a + h) g(a) h g(x) a A = g (a) = f x (a, b)

Transcription:

1 f(x) a b f(x)dx = n A(x i ) (1) ix [a, b] n i A(x i ) x i 1 f(x) [a, b] n h = (b a)/n y h = (b-a)/n y = f (x) h h a a+h a+2h a+(n-1)h b x 1: 1

x h = (b a)/n [x i, x i+1 ] = [a+i h, a+ (i + 1) h] A(x i ) A(x i ) = h 2 {f(x i) + f(x i+1 ) = h {f(a + i h) + f(a + (i + 1) h), (2) 2 a b n A(x i ) = = h n h 2 {f(x i) + f(x i+1 ) (3) { n 1 1 2 f(a) + f(a + i h) + 1 2 f(b) (4) 1 1 #include <stdio.h> #define X_MIN 0.0 // #define X_MAX 100.0 // #define DIV_NUM 120 // //. float function (float x) { float result; result = x; // return result; int main() { double integral; // double h; // n double x, da; int i; printf ("=[%f,%f] =%d\n", X_MIN, X_MAX, DIV_NUM); // === === h = (X_MAX - X_MIN) / DIV_NUM; // integral = 0.0; // x = X_MIN; // for (i=0; i<div_num; i++) { // A da = (function(x)+function(x+h))*h/2.0; integral += da; // 2

x += h; // === === printf ("= %lf\n", integral); printf (" ( 100 100 )=%lf\n", (X_MAX-X_MIN)*function(X_MAX)/2.0); return(0); (3) f(x + h) f(x) 2 2 2 2 y h = (b-a)/n y = f (x) h/2 h/2 a a+h a+(h/2) b a+{(2n-1)/2h x 2: f(x) [a, b] n h = (b a)/n [x i, x i+1 ] = [a + i h, a + (i + 1) h] x i + h/2 h A(x i ) A(x i ) = h f (x i + 12 ) ( h = h f a + 2i 1 ) h, (5) 2 3

a b n A(x i ) = h n f (x i + 12 ) h = h n ( f a + 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, b] n A(x i ) = h 3 [f(x 0) + 4f(x 1 ) + f(x 2 )] + h 3 [f(x 2) + 4f(x 3 ) + f(x 4 )] + + h 3 [f(x 2n 2) + 4f(x 2n 1 ) + f(x 2n )] = h 3 [f(x 0) + 4f(x 1 ) + 2f(x 2 ) + 4f(x 3 ) + 2f(x 4 ) + 2f(x 2n 2 ) + 4f(x 2n 1 ) + 2f(x 2n )] = h 3 [f(x 0) + 4f(x 1 ) + f(x 3 ) + + 2f(x 2 ) + f(x 4 ) + + f(x n )] [ ] = h n n 1 f(a) + 4 fa + (2i 1)h + 2 fa + 2ih + f(b) (10) 3 2 Simpson 5 ] x2 x 0

f (x) f (x) h da 1 da 2 da n-1 da n a b x x 0 x 1 x 2 x 3 x 4 x 2n-2 x 2n-1 x 2n 4: // === Simpson ( === h = (X_MAX - X_MIN) / (2.0*DIV_NUM); // x = X_MIN; // integral = function(x); // for (; i<div_num; i++) { da = 4.0*function(x+h) + 2.0*function(x+2.0*h); integral += da; // x += 2.0*h; integral += ( 4.0*function(x+h) + function(x+2.0*h) ); integral *= h/3.0; // === Simpson ( === 4 V N x 1, x 2,, x n V f fdv V V (11) V f Monte Carlo C rand() 3 6

A f (x)dx 5: A f f A #include <stdio.h> #include <stdlib.h> // rand #define N 400 // #define D 10.0 // main() { unsigned long i; unsigned long in=0,out=0; float ratio,x,y,r,square; square=d*d; // r=d/2.0; // for(i=0; i<n; ++i) { // x x= (double)rand()/(double)rand_max*r; // y y= (double)rand()/(double)rand_max*r; // (x,y) if ((x*x+y*y)<=r*r) ++in; else ++out; printf("=%d =%d =%d x=%5.2f y=%5.2f\n", i,in,out,x,y); // (x,y) ratio=(float)in/(float)(in+out); printf("= %d = %d\n",in,out); printf("%f\n",square); printf(" %f\n",square*ratio); printf("3.14*r*r%f\n",3.14*r*r); 7

5 http://www.sm.rim.or.jp/~shishido/bibun1.html dy dx = 2x, x = 1 y = 1 (12) y = x 2 ) y dy/dx = 2x x = 1 y 1 2 x, 2 x = 1.1y x(0.1)x = 1 y x = 1 y x = 1.1 y y 2 0.1 = 0.2 y 1 1.2 (1.1)2 = 1.21 x = 1 y(x + x) = y(x) + dy dx x (13) x y x 2 1 x 1.0 6 x = 1.0 y = 1.0 h = 0.02 4 dy dx #include <stdio.h> #define XSTART 1.0 // x #define XEND 6.0 // x #define YSTART 1.0 // y #define H 0.02 // x main() { double x, y, dy; y = YSTART; x = XSTART; = 2x 8

while(x<6.0) { dy = 2.0*x*H; y += dy; x += H; printf("x=%lf y=%lf\n",x,y); return(0); x=1.020000 y=1.040000 x=1.040000 y=1.080800 x=1.060000 y=1.122400 x=1.080000 y=1.164800 x=1.100000 y=1.208000 x=5.940000 y=35.184800 x=5.960000 y=35.422400 x=5.980000 y=35.660800 x=6.000000 y=35.900000 x=6.020000 y=36.140000 8 10 5 dy dx = 2x #include <stdio.h> #include <glut.h> // OpenGL #define XSTART 1.0 // x #define XEND 6.0 // x #define YSTART 1.0 // y #define H 0.02 // x void display(void) // { double x, y, dy; glclear(gl_color_buffer_bit); // glbegin(gl_line_strip); // ( y = YSTART; x = XSTART; while(x<6.0) { // Eular dy = 2.0*x*H; y += dy; x += H; printf("x=%lf y=%lf\n",x,y); glvertex2d(x*0.2-0.9, y*0.04-0.9); // 9

glend(); // ( glbegin(gl_line_strip); // ( glvertex2d(-0.9, 0.9); glvertex2d(-0.9, -0.9); // glvertex2d( 0.9, -0.9); glend(); // ( glflush(); // 6: 1 2 2 1 1 2 6 Runge-Kutta A da dt = f(a) (14) f(a) t = 0 A A(0) t = dt A A(dT ) Euler 7 t = 0 1 f(a(0)) dt A(dT ) f(a(0))dt 10

x x(t+dt) x(t) t t+dt 7: 8 2 Runge-Kutta Euler dt A k 1 0 dt dt/2 A f(a(0)) + k 1 /2 A(dT ) k 1 = f(a(0))dt (15) A(dT ) = A(0) + f(a(0) + k 1 /2)dT (16) Taylor dt 2 Runge-Kutta 9 4 Runge- Kutta (15) (16) 4 Runge-Kutta 3 A(dT ) k 1, k 2, k 3, k 4 A(dT ) Taylor dt 4 k 1 = f(a(0))dt (17) k 2 = f(a(0) + k 1 /2)dT (18) k 3 = f(a(0) + k 2 /2)dT (19) k 4 = f(a(0) + k 3 /2)dT (20) A(dT ) = A(0) + 1 6 (k 1 + 2k 2 + 2k 3 + k 4 ) (21) Runge-Kutta 4 Runge-Kutta Runge-Kutta qx, qy, px, py RungeKutta() 6 Runge-Kutta // === Runge-Kutta === 11

x x(t+dt) t x(t) t+dt/2 t+dt k 1 8: 2 Runge-Kutta x x(t+dt) x(t) k 1 k 2 k 3 k 4 t t+dt 9: 4 Runge-Kutta void RungeKutta(double qx, double qy, double px, double py, double *qxk, double *qyk, double *pxk, double *pyk) { double q, qi3; q = hypot( qx, qy ); qi3 = 1.0/(q*q*q); *qxk = px/m*dt; *qyk = py/m*dt; *pxk = -GM*M*qx*qi3*dT; *pyk = -GM*M*qy*qi3*dT; Runge-Kutta Euler 10 Euler 12