: Shift-Return evaluate 2.3 Sage? Shift-Return abs 2 abs? 2: abs 3: fac

Similar documents
2.2 Sage I 11 factor Sage Sage exit quit 1 sage : exit 2 Exiting Sage ( CPU time 0m0.06s, Wall time 2m8.71 s). 2.2 Sage Python Sage 1. Sage.sage 2. sa

v8 Mathematica ( ) [ ], { } Expand[(a+b)^2] Plot[Sin[x], {x, 0, 2Pi}] Windows Mathematica Mathematica 2.2 v8 Mathematica = ( ) = s

sin x

or a 3-1a (0 b ) : max: a b a > b result a result b ( ) result Python : def max(a, b): if a > b: result = a else: result = b ret

listings-ext

SHOBI_Portal_Manual

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


2 1 Mathematica Mathematica Mathematica Mathematica Windows Mac * Mathematica 9-1 Expand[(x + y)^7] (x + y) 7 x y Shift *1 Mathematica 1.12

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

1 P2 P P3P4 P5P8 P9P10 P11 P12

コンピュータ概論

Visual Python, Numpy, Matplotlib

untitled

2

1 matplotlib matplotlib Python matplotlib numpy matplotlib Installing A 2 pyplot matplotlib 1 matplotlib.pyplot matplotlib.pyplot plt import import nu

OpenCV IS Report No Report Medical Information System Labratry

春期講座 ~ 極限 1 1, 1 2, 1 3, 1 4,, 1 n, n n {a n } n a n α {a n } α {a n } α lim n an = α n a n α α {a n } {a n } {a n } 1. a n = 2 n {a n } 2, 4, 8, 16,

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

13 Student Software TI-Nspire CX CAS TI Web TI-Nspire CX CAS Student Software ( ) 1 Student Software 37 Student Software Nspire Nspire Nspir

Python Speed Learning

Visual Python, Numpy, Matplotlib

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

Python Speed Learning


, : GUI Web Java 2.1 GUI GUI GUI 2 y = x y = x y = x

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

J.JSSAC Vol. 7, No. 2, Mathematica Maple,., Open asir Open xxx asir. Open xxx Open asir, asir., Open xxx, Linux Open asir Open sm1 (kan/sm1). C

研修コーナー

num2.dvi

tnbp59-21_Web:P2/ky132379509610002944

Sage for Mathematics : a Primer ‚æ1Łfl - Sage ‡ð™m‡é

untitled

30

パーキンソン病治療ガイドライン2002

日本内科学会雑誌第97巻第7号

R による統計解析入門


たのしいプログラミング Pythonではじめよう!

Appendix A BASIC BASIC Beginner s All-purpose Symbolic Instruction Code FORTRAN COBOL C JAVA PASCAL (NEC N88-BASIC Windows BASIC (1) (2) ( ) BASIC BAS

日本内科学会雑誌第98巻第4号

JavaScript 1.! DOM Ajax Shelley Powers,, JavaScript David Flanagan, JavaScript 2

_0212_68<5A66><4EBA><79D1>_<6821><4E86><FF08><30C8><30F3><30DC><306A><3057><FF09>.pdf

1 R Windows R 1.1 R The R project web R web Download [CRAN] CRAN Mirrors Japan Download and Install R [Windows 9

Chap9.dvi

2 / 5 Auction: Theory and Practice 3 / 5 (WTO) 1 SDR 27 1,6 Auction: Theory and Practice 4 / 5 2

10 (1) s 10.2 rails c Rails 7 > item = PlanItem.new => #<PlanItem id nil, name nil,...> > item.name = "" => "" > item.valid? => true valid? true false

( ) kadai4, kadai4.zip.,. 3 cos x [ π, π] Python. ( 100 ), x cos x ( ). (, ). def print cos(): print cos()

日本内科学会雑誌第98巻第3号

(4) P θ P 3 P O O = θ OP = a n P n OP n = a n {a n } a = θ, a n = a n (n ) {a n } θ a n = ( ) n θ P n O = a a + a 3 + ( ) n a n a a + a 3 + ( ) n a n

PowerPoint プレゼンテーション

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

Python ( ) Anaconda 2 3 Python Python IDLE Python NumPy 6 5 matpl


公図閲覧操作マニュアル

ohp.mgp

snkp-14-2/ky347084220200019175

RL_tutorial

<4D F736F F D B B83578B6594BB2D834A836F815B82D082C88C60202E646F63>


Windows (L): D:\jyugyou\ D:\jyugyou\ D:\jyugyou\ (N): en2 OK 2

Mac OS X Windows...15 Mac OS X...16 Windows /...24 /...24 / Windows...2

16soukatsu_p1_40.ai

FX ) 2

FX自己アフリエイトマニュアル

: (EQS) /EQUATIONS V1 = 30*V F1 + E1; V2 = 25*V *F1 + E2; V3 = 16*V *F1 + E3; V4 = 10*V F2 + E4; V5 = 19*V99

Python (Anaconda ) Anaconda 2 3 Python Python IDLE Python NumPy 6

Microsoft Word - C.....u.K...doc

チュートリアル:ノンパラメトリックベイズ

Transcription:

Bulletin of JSSAC(2012) Vol. 18, No. 2, pp. 161-171 : Sage 1 Sage Mathematica Sage (William Stein) 2005 2 2006 2 UCSD Sage Days 1 Sage 1.0 4.7.2 1) Sage Maxima, R 2 Sage Firefox Internet Explorer Sage Notebook Server 2) Sage 2.1 Sage Sage 3) 1 2.2 New Worksheet take@pwv.co.jp 1) William Stein 2007 UW CSE 2) Linux, Mac OSX, Windows 3) Sage URL http://www.sagenb.org/ http://www.pwv.co.jp:8000/ c 2012 Japan Society for Symbolic and Algebraic Computation

162 18 2 2012 1: Shift-Return evaluate 2.3 Sage? Shift-Return abs 2 abs? 2: abs 3: fac

Bulletin of JSSACVol. 18, No. 2, 2012 163 2.4 Python fac factor factor factorial 2 3 2.5 4 L A TEX 4: 2.6 Python Sage Python Python Python (#) (;) 1 Sage 5 1 Sage 5 2 N 5 3 5: Sage

164 18 2 2012 2.7 Sage var var 6 1 Sage 3 Python lambda f(x) = Python def Python lambda 3 Python lamba 6 3 6: Sage 2.8 Sage 1 π e i Sage pi e I ( i) oo (o 2 ) 1: Sage 2.9 Sage Sin + Sin 7 1

Bulletin of JSSACVol. 18, No. 2, 2012 165 1. Sin sin_plt 2. data_plt 3. sin_plt data_plt show 7: Sin + 100 Sin 2.10 @interact @interact def_( ) slider( ) selector( ) 8 Sin M 0 9 2.11 [1] 4) 4) http://www.pwv.co.jp:8000/home/pub/16/

166 18 2 2012 8: Sin M Download Upload 3 Sage Sage Python 2 2 f (x) = 3 2 x2 1 + x 1x 2 + x2 2 6x 1 7x 2 (1) x 0 f t

Bulletin of JSSACVol. 18, No. 2, 2012 167 d n d d 0 = f (x 0 ) d n = f (x n ) + β n d n 1, β n = ( f (x n)) T f (x n ) ( f (x n 1 )) T f (x n 1 ) (2) x n+1 α n H f (x) 3.1 Sage x n+1 = x n + α n d n, α n = dt n f (x n ) d T n Hd n (3) Sage v x1, x2 v f # vars = var( x1 x2 ) v = vector([x1, x2]) # f def f(v): return 3/2 * v[0]^2 + v[0]*v[1] + v[1]^2-6*v[0] - 7*v[1] f nabla_f f dfs vx # f dfs = [diff(f(v), x_i) for x_i in v] # f (dfs vx ) def nabla_f(vx): # vx v s = dict(zip(v, vx)) # s return vector([df.subs(s) for df in dfs]) Sage Python diff f(v) x_i, x_j 2 matrix jsmath(h) # H = matrix([[diff(diff(f(v),x_i), x_j) for x_i in v] for x_j in v]) print jsmath(h) 3 1 1 2 α n 3

168 18 2 2012 # _n def alpha_n(x, d): return -d.dot_product(nabla_f(x)) / (d * H * d) eps = 0.001 x0 = vector([2, 1]) d = - nabla_f(vx=x0) x = x0 k = 1 while (true): o_nabla_f_sqr = nabla_f(x).dot_product(nabla_f(x)) o_x = x x += alpha_n(x, d)*d if ((x - o_x).norm() < eps): break beta = nabla_f(x).dot_product(nabla_f(x)) / o_nabla_f_sqr d = -nabla_f(x) + beta*d if (d.norm() == 0): # 0 break k += 1 print "x=", x print "k=", k x= (1, 3) k= 2 Sage # Sage g = 3/2*x1^2 + x1*x2 + x2^2-6*x1-7*x2 minimize(g, [2, 1], algorithm="cg") Optimization terminated successfully. Current function value: -13.500000 Iterations: 2 Function evaluations: 5 Gradient evaluations: 5 (1.0, 3.0) 9

Bulletin of JSSACVol. 18, No. 2, 2012 169 # p3d = plot3d(g, [x1, -1, 4], [x2, -1, 4]) pt = point([1, 3, f(x)], color= red ) (p3d+pt).show() Sage 9: f 4 Sage Sage R Sage 5) Oil Flow DataTrn.txt DataTrnLbls.txt DATA Sage R R r R result 5) http://www.pwv.co.jp:8000/home/pub/14/

170 18 2 2012 # R PCA filename = DATA + DataTrn.txt oilflow = r("oilflow <- read.table( %s )" %filename) result = r("result <- prcomp(oilflow)") R Sage 10 html pca.pdf HTML # filename = DATA + DataTrnLbls.txt labels = r("oilflow.labels <- read.table( %s )" %filename) # filename = DATA+ pca.pdf r.pdf(file= "%s" %filename) # r("col <- colsums(t(oilflow.labels) * c(4,3,2))") r("pch <- colsums(t(oilflow.labels) * c(3,1,4))") r("plot(result$x[,1:2], col=col, pch=pch, xlim=c(-3,3), ylim=c(-3,3))") r.dev_off() # html( <img src="pca.pdf"> ) 10: Sage 11: R Sage

Bulletin of JSSACVol. 18, No. 2, 2012 171 4.1 R Sage R Sage Sageobj _save_ R Sage 3 11 #R Sage # DATA V1, V2 lb = Sageobj(labels) # zip lbs = zip(lb[ DATA ][ V1 ],lb[ DATA ][ V2 ],lb[ DATA ][ V3 ]) # point3d N = len(lbs) plt = Graphics() for n in range(n): [x, y, z] = rs[n] if lbs[n][0] == 1: plt += point3d([x, y, z], rgbcolor= blue ) elif lbs[n][1] == 1: plt += point3d([x, y, z], rgbcolor= green ) else: plt += point3d([x, y, z], rgbcolor= red ) plt.show() 5 Sage Sage Sage Sage 6) ( ) L A TEX [1] : OSS Sage Software Design 2010 6 pp. 89 94 6) http://www.stat.t.u-tokyo.ac.jp/~numata/nora/sage-doc/