2014計算機実験1_1

Similar documents
OK (S) vncviewer UNIX EDS vncviewer : VNC server: eds.efc.sec.eng.shizuoka.ac.jp:51 OK 2

x ( ) x dx = ax

計算機シミュレーション

シミュレーション物理4

微分方程式 モデリングとシミュレーション

資料

Note.tex 2008/09/19( )

pdf

£Ã¥×¥í¥°¥é¥ß¥ó¥°(2018) - Âè11²ó – ½ÉÂꣲ¤Î²òÀ⡤±é½¬£² –

2 1 κ c(t) = (x(t), y(t)) ( ) det(c (t), c x (t)) = det (t) x (t) y (t) y = x (t)y (t) x (t)y (t), (t) c (t) = (x (t)) 2 + (y (t)) 2. c (t) =

error_g1.eps

C:/KENAR/0p1.dvi

1.1 ft t 2 ft = t 2 ft+ t = t+ t d t 2 t + t 2 t 2 = lim t 0 t = lim t 0 = lim t 0 t 2 + 2t t + t 2 t 2 t + t 2 t 2t t + t 2 t 2t + t = lim t 0

double float

6 6.1 sound_wav_files flu00.wav.wav 44.1 khz 1/44100 spwave Text with Time spwave t T = N t N 44.1 khz t = 1 sec j t f j {f 0, f 1, f 2,, f N 1

DE-resume

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

(3) (2),,. ( 20) ( s200103) 0.7 x C,, x 2 + y 2 + ax = 0 a.. D,. D, y C, C (x, y) (y 0) C m. (2) D y = y(x) (x ± y 0), (x, y) D, m, m = 1., D. (x 2 y


6. Euler x

ニュートン重力理論.pptx

S I. dy fx x fx y fx + C 3 C vt dy fx 4 x, y dy yt gt + Ct + C dt v e kt xt v e kt + C k x v k + C C xt v k 3 r r + dr e kt S Sr πr dt d v } dt k e kt

新版明解C言語 実践編

programmingII2019-v01

Microsoft Word - NumericalComputation.docx

S I. dy fx x fx y fx + C 3 C dy fx 4 x, y dy v C xt y C v e kt k > xt yt gt [ v dt dt v e kt xt v e kt + C k x v + C C k xt v k 3 r r + dr e kt S dt d

Microsoft PowerPoint - 1章 [互換モード]

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

p = 1, 2, cos 2n + p)πj = cos 2nπj 2n + p)πj, sin = sin 2nπj 7.1) f j = a ) 0 + a p + a n+p cos 2nπj p=1 p=0 1 + ) b n+p p=0 sin 2nπj 1 2 a 0 +

M3 x y f(x, y) (= x) (= y) x + y f(x, y) = x + y + *. f(x, y) π y f(x, y) x f(x + x, y) f(x, y) lim x x () f(x,y) x 3 -

sec13.dvi

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)

/* 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

2011de.dvi

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

1 4 2 EP) (EP) (EP)

: CR (0x0d) LF (0x0a) line separator CR Mac LF UNIX CR+LF MS-DOS WINDOWS Japan Advanced Institute of Science and Technology

lecture

取扱説明書 [N-03A]

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

DVIOUT

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)

v er.1/ c /(21)

08-Note2-web

[] x < T f(x), x < T f(x), < x < f(x) f(x) f(x) f(x + nt ) = f(x) x < T, n =, 1,, 1, (1.3) f(x) T x 2 f(x) T 2T x 3 f(x), f() = f(t ), f(x), f() f(t )

sim98-8.dvi

ContourPlot[{x^+y^==,(x-)^+y^==}, {x,-,}, {y,-,}, AspectRatio -> Automatic].. ContourPlot Plot AspectRatio->Automatic.. x a + y = ( ). b ContourPlot[x

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

H8.6 P

Gmech08.dvi

A

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

() (, y) E(, y) () E(, y) (3) q ( ) () E(, y) = k q q (, y) () E(, y) = k r r (3).3 [.7 ] f y = f y () f(, y) = y () f(, y) = tan y y ( ) () f y = f y


スライド 1


I 1

2 1 x 1.1: v mg x (t) = v(t) mv (t) = mg 0 x(0) = x 0 v(0) = v 0 x(t) = x 0 + v 0 t 1 2 gt2 v(t) = v 0 gt t x = x 0 + v2 0 2g v2 2g 1.1 (x, v) θ

KENZOU

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

ContourPlot[{x^+y^==,(x-)^+y^==}, {x,-,}, {y,-,}, AspectRatio -> Automatic].5. ContourPlot Plot AspectRatio->Automatic.. x a + y = ( ). b ContourPlot[

今後の予定 6/29 パターン形成第 11 回 7/6 データ解析第 12 回 7/13 群れ行動 ( 久保先生 ) 第 13 回 7/17 ( 金 ) 休講 7/20 まとめ第 14 回 7/27 休講?

C 言語第 6 回 1 数値シミュレーション :2 階の微分方程式 ( シラバス10 11 回目 ) 1 2 階の微分方程式と差分方程式微分方程式を 2 d x dx + c = f ( x, t) 2 dt dt とする これを 2 つの 1 階の微分方程式に変更する ìdx = y 2 2 d


1 I 1.1 ± e = = - = C C MKSA [m], [Kg] [s] [A] 1C 1A 1 MKSA 1C 1C +q q +q q 1

Gmech08.dvi

slide1.dvi

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,

II Karel Švadlenka * [1] 1.1* 5 23 m d2 x dt 2 = cdx kx + mg dt. c, g, k, m 1.2* u = au + bv v = cu + dv v u a, b, c, d R

関数の呼び出し ( 選択ソート ) 選択ソートのプログラム (findminvalue, findandreplace ができているとする ) #include <stdio.h> #define InFile "data.txt" #define OutFile "sorted.txt" #def

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 )

プログラミング基礎

スライド 1

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

r07.dvi

) a + b = i + 6 b c = 6i j ) a = 0 b = c = 0 ) â = i + j 0 ˆb = 4) a b = b c = j + ) cos α = cos β = 6) a ˆb = b ĉ = 0 7) a b = 6i j b c = i + 6j + 8)

ohp07.dvi

f(x,y) (x,y) x (x,y), y (x,y) f(x,y) x y f x (x,y),f y (x,y) B p.1/14

ohp_06nov_tohoku.dvi

() n C + n C + n C + + n C n n (3) n C + n C + n C 4 + n C + n C 3 + n C 5 + (5) (6 ) n C + nc + 3 nc n nc n (7 ) n C + nc + 3 nc n nc n (

TCSE4~5


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

mugensho.dvi

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

12.2 電気回路網に関するキルヒホッフの法則による解法 2 多元連立 1 次方程式の工学的応用についての例を 2 つ示す.1 つはブリッジ T 型回路, もう 1 つはホーイストンブリッジ回路である. 示された回路図と与えられた回路定数からキルヒホッフの法則を使って多元連立 1 次方程式を導出する


x A Aω ẋ ẋ 2 + ω 2 x 2 = ω 2 A 2. (ẋ, ωx) ζ ẋ + iωx ζ ζ dζ = ẍ + iωẋ = ẍ + iω(ζ iωx) dt dζ dt iωζ = ẍ + ω2 x (2.1) ζ ζ = Aωe iωt = Aω cos ωt + iaω sin

スライド 1

8.1 Fubini 8.2 Fubini 9 (0%) 10 (50%) Carathéodory 10.3 Fubini 1 Introduction 1 (1) (2) {f n (x)} n=1 [a, b] K > 0 n, x f n (x) K < ( ) x [a

gengo1-12

としてもよいし,* を省略し, その代わりにスペースを空けてもよい. In[5]:= 2 3 Out[5]= 6 数値計算 厳密な代数計算 整数および有理数については, 厳密な計算がなされます. In[6]:= Out[6]= In[7]:= Out[7]= 2^

, 3, 6 = 3, 3,,,, 3,, 9, 3, 9, 3, 3, 4, 43, 4, 3, 9, 6, 6,, 0 p, p, p 3,..., p n N = p p p 3 p n + N p n N p p p, p 3,..., p n p, p,..., p n N, 3,,,,

数値計算で学ぶ物理学 4 放物運動と惑星運動 地上のように下向きに重力がはたらいているような場においては 物体を投げると放物運動をする 一方 中心星のまわりの重力場中では 惑星は 円 だ円 放物線または双曲線を描きながら運動する ここでは 放物運動と惑星運動を 運動方程式を導出したうえで 数値シミュ

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

December 28, 2018

( ) 2.1. C. (1) x 4 dx = 1 5 x5 + C 1 (2) x dx = x 2 dx = x 1 + C = 1 2 x + C xdx (3) = x dx = 3 x C (4) (x + 1) 3 dx = (x 3 + 3x 2 + 3x +

食リ_表紙-表4.ai

Microsoft PowerPoint - guidance.ppt


Transcription:

H26 1 1 1 seto@ics.nara-wu.ac.jp

数学モデリングのプロセス 問題点の抽出 定義 仮定 数式化 万有引力の法則 m すべての物体は引き合う r mm F =G 2 r M モデルの検証 モデルによる 説明 将来予測 解釈 F: 万有引力 (kg m s-2) G: 万有引力定数 (m s kg ) 解析 数値計算 M: 地球の質量 (kg) により解を得る m: 落下する物質の質量 (kg) 3-2 -1 r: 2物質間の距離 (m) 画像引用: http://www.matumura-ringo.com/info.html

法則と微分方程式 ニュートンの運動方程式 物体の加速度 a は物体の質量 m に ma = F Fの力で質量mの物体を押したら t秒後の速度vはどれくらい変わる? 反比例し 物体に働く力 F に比例する 速度 加速度 dx v(t) = dt 2 dv d x a(t) = = 2 dt dt x(t): 位置 m m 2 d x 2 dt F =F 2階常微分方程式

? x(0) mg ma(t) = mg g: t = 0 x = x(0), υ = υ(0) d 2 x t dt = g 2 x v(t) = gt + v(0) x(t) = 1 2 gt2 + v(0)t + x(0) t x(t) ( ) t

t y = y(t) yʹ, yʹ,... n f (t,y,y,y,...,y (n) )=0 f (t,y, dy dt,..., dn y dt n )=0 n t y 2

dy :, dt = f (t,y) y(t 0 )=y 0 y = y(t) f (t,y)=ky k = 0.5 y 0 = 0.5 dy dt = ky y(t) = y 0 e kt y 2 1 0 1 2 2 1 0 1 2 t

,, dy dx = f (x)g(y) dy dx = f y x =

dx dt = f (t, x) = lim t 0 x(t + t) x(t) t t Δt = ti+1 - ti = h f (t i, x i ) x i+1 t i+1 x i t i x i+1 x i + hf(t i, x i ) x(t) = x i, x(t + t) = x i+1 x 0 t i x 1, x 2, x 3,...

オイラー法のアルゴリズム 区間 [t0, tn] を等間隔 h で分割し ステップ ti から ti+1 の x の増加率を h f(ti, xi)で与える x dx dt while (t <= tn){ ti+1 = ti + h, xi+1 = xi + h f(ti, xi) } 解析解 x2 x1 x0 f(t0,x0) t0 f(t1,x1) t1 h 数値解 t2 t

x x x2 x1 x0 x2 x1 x0 f(t0,x0) f(t 1,x1) t t t0 t1 t2 t0 t1 t2 h

オイラー法の精度 x(t)をt = ti の周りでテイラー展開すると テイラー展開による 多項式での近似 オイラー法 h2 x(ti+1 ) = x(ti + h) = x(ti ) + hx (ti ) + x (ti ) + 2 x(ti+1 ) = x(ti ) + h f (ti, xi ) 誤差 オイラー法はテイラー展開の1次の項までしか考慮しない 区間[ t0, t0 + T ]を刻み幅hで分割した 時の終端 t0 + T での誤差の累積 2 h 2 T h = x (ti ) h 2 x (ti ) 1回のステップ における誤差 全ステップ数 刻み幅 h を 1/10 にすれば累積誤差も約 1/10 になる (ただし計算量は 10倍になる)

(, 1 ) #define DT 0.01 /* */ #define STEP_MAX 1000 /* DT*STEP_MAX = 10.0 */ double fn(double, double); /* */ void euler(double, double, double*, double); /* */ main(){ long step; double t, x, x_next; x=0.1; /* */ for(i=0; i<step_max; i++){ t = i*dt; euler(t, x, &x_next, DT); x = x_next; } } void euler(double t, double x, double *x_out, double h){... } double fn(double t, double x){... } dx dt = f (t,x) t = 0 t = DT*STEP_MAX

(, 1 ) euler ti x(ti), h ti+1 = ti + h x(ti+1) ti x(ti) x(ti+1) void euler(double t, double x, double *x_out, double h){ double tmp; tmp = x + h*fn(t,x); *x_out = tmp; } x_out double fn(double t, double x){... } tmp ti x(ti) x(ti+1) h

Mathematica (1/2) Mathematica, 1) ti x(ti) 0.000 1.00 0.001 1.02 0.002 1.05... ti x(ti) 2) GNOME Mathematica $ mathematica 3) Mathematica SetDirectory SetDirectory[ ~/keisanki-1-2010/ ]

Mathematica (2/2) 4) ReadList[ file, {type, type}] file type ( {x (ti), y (x(ti))} ) ( ) data data = ReadList[ data_file, {Real, Real}] 5) ListPlot[list] ( ) PlotRange->{0, 10} 0 10 ListPlot[ data, Joined->True, PlotRange->All ]

Mathematica Mathematica C 1. 2. 3. fig1=listplot[ data, Joined->True, PlotRange- >All ] fig2=plot[exp[t], {t, 0, 10}, PlotStyle ->Red] fig3=show[fig1, fig2] 1. fig1 2. e t 0 t 10 fig2 3. fig2 fig2 fig3

fig3 dx = x(1 x) dt x(0) = 2 2.5 x 2.0 1.5 1.0 0.5 0 2 4 6 8 10 t 2.5 x 2.0 1.5 1.0 0.5 0 2 4 6 8 10 t h 0.5 h 0.05

Mathematica Mathematica C 1. 2. 3. 4. deq = { x [t] == (1 - x[t])x[t], x[0] == 0.01} sol = NDSolve[ deq, x[t], {t, 0, 10}] Plot[ Evaluate[ x[t]/.sol ], {t, 0, 10}] x[t]/.sol/.t->5 1. deq Mathematica =, == 2. deq 0 t 10 sol 3. t /. 4. x(5)

1 (1) (2) 1-3. 1. (x(0) = 1) h = 0.1 h = 0.05 ( ) h 2. Mathematica (1) dx dt = x 0 t 1 (2) dx dt = x sin (t) 0 t 50

Q1 A1 fprintf ( ) FILE *fp fp = fopen( data.txt, w ); /* */ fprintf(fp, %f %f n, t, x); fclose(fp); /* */

Q2 C sin(t) A2 2 #include <math.h> - lm Q3 Mathematica sin(t) A3 Sin[t] S

( ) 1

(, ) #define DIM 2 /* ( ) */ #define DT 0.01 /* */ #define STEP_MAX 1000 /* DT*STEP_MAX = 10.0 */ void derives(double, double[], double[], int); /* */ void euler(double, double[], double[], int, double); /* */ main(){ long step; double t, x, x_next; x=0.1; /* */ for(i=0; i<step_max; i++){ t = i*dt; euler(t, x, &x_next, DT); x = x_next; } } void euler(double t, double x, double *x_out, double h){... } double fn(double t, double x){... } t = 0 t = DT*STEP_MAX dx dt = f (t, x)

(, ) derives ti x(ti), n derivatives[] ti x(ti) dx/dt or f(t, x) void derives(double t, double x[], double derivatives[],int n){ } derivatives[] n

(, ) void euler(double t, double x[], double x_out[], int n, double h){ int i; double x_tmp[dim], derivatives[dim]; derivs(t, x, derivatives, n); /* */ } euler ti x(ti), n, h ti+1 = ti + h x(ti+1) ti x(ti) x(ti+1) n h for(i=0; i<dim; i++) /* Euler */ x_tmp[i] = x[i] + h*derivatives[i]; for(i=0; i<dim; i++) x_out[i] = x_tmp[i]; /* */

double fn(double t, double x){ } 1 fn derives f (t, x) void derives(double t, double x[], double derivatives[],int n){ derivatives[] }

...??? 2 double fn1(double t, double x1, double x2){ } double fn2(double t, double x1, double x2){ } f1(t, x1, x2) f2(t, x1, x2)

2 ε 1.0, 0.5, 0.1 1-2. 1. t, x1, x2 Mathematica 2. x1, x2 Mathematica x(0), x(1), x(2),... dx 1 dt dx 2 dt = x 1 1 = x 1 3 x3 1 x 2 Van der Pol oscillator equation

Mathematica (1/4) Mathematica, t i x1(ti) x2(ti) 1) 0.000 1.00 2.00 0.001 1.02 1.97 0.002 1.05 1.94... 2) Mathematica % /usr/local/bin/mathematica & 3) Mathematica SetDirectory SetDirectory[ ~/keisanki-1-2010/ ]

Mathematica (2/4) 4) {ti, x1(ti), x2(ti)} data data = ReadList[ data_file, {Real, Real, Real}]; 5) - data {{t 0, x 0, y 0 }, {t 1, x 1, y 1 }, {t 2, x 2, y 2 },... } Transpose( ) data datat datat = Transpose[data]; datat {{t 0, t 1, t 2,... }, {x 0, x 1, x 2,... }, {y 0, y 1, y 2,...}}

Mathematica (3/4) 4) - datat 1 2 ( t, x1(t) ) datax datax = Transpose[ {datat[[1]], datat[[2]] } ]; ( t, y(t) ) datay ( x(t), y(t) ) dataxy datay = Transpose[ {datat[[1]], datat[[3]] } ]; dataxy = Transpose[ {datat[[2]], datat[[3]] } ];

Mathematica (4/4) 5) ListPlot t x(t), y(t) gx = ListPlot[ datax, Joined->True, PlotRange->All] gy = ListPlot[ datay, Joined->True, PlotRange->All] 2 Show Show[gx, gy] x(t), y(t) ListPlot[ dataxy, Joined->True, PlotRange->All]

Mathematica 1. 2. 3. 4. deq2 = { x1 [t] == x2[t] x1[t]^2, x2 [t] == 2 x1[t] x2[t], x1[0] == x2[0] == 1} sol2 = NDSolve[ deq2, {x1[t], x2[t]}, {t, 0, 20}] Plot[ Evaluate[ x1[t]/.sol2 ], {t, 0, 20}] Plot[ Evaluate[ x2[t]/.sol2 ], {t, 0, 20}] ParametricPlot[ Evaluate[ {x1[t], x2[t]}/.sol2 ], {t, 0, 20}] 1. deq 2. deq2 0 t 20 sol2 3. t 4. ( x 1 (t), x 2 (t) )

LaTeX 1) Mathematica EPS EPS: Encapsulated PostScript Mathematica Edit ---> Save Selection As ---> EPS 2) LaTex LaTeX \usepackage{graphicx} EPS.eps \includegraphics{graph.eps} ( ) 5cm \begin{cetner} \includegraphics[width = 5cm]{graph.eps} \end{center}

Tips ( ) 2.5 x 2.0 1.5 1.0 1 dx/dt = x(1-x) ( ) h = 0.5 ( ) x(0) = 2 0.5 0 2 4 6 8 10 t

/ (2002) ( ) / (1994) / (2007)

: 1) Burghes, D. and Borrie, M. (1990), 2) (2009) H21 1 3) (2000) Mathematica 2,