ONLY DO WHAT ONLY YOU CAN DO

こけたら立ちなはれ 立ったら歩きなはれ

Python

Pythonで固有値・固有ベクトルを求める (反復法)

n × n の正方行列 A と n次元のベクトル x について Ax = λx (ただし x ≠ 0) が成り立つとき λを固有値, x を固有ベクトルという. 最初に適当なベクトルx0から始めて xk+1 = Axk を反復すると xk は行列 A の最大固有値に対応する固有ベクトルに収束する. 固…

Python で非線形方程式を解く (2分法)

非線形方程式の解法(2分法)を利用して2の平方根を求める 1. まず, 条件 を満たす点 を考えると, 関数 の解は, 区間 の中に存在する. 2. 次に, 区間 の中点 を考えると, であれば, 解は区間 の中に存在し, 同様に, であれば, 区間 の中に存在する. 3. この…

さまざまな言語で四則演算と数値の出力

VBScript WScript.Echo 3 + 5 WScript.Echo 3 - 5 WScript.Echo 3 * 5 WScript.Echo 3 ^ 5 WScript.Echo 5 / 3 WScript.Echo 5 \ 3 WScript.Echo 5 Mod 3 WScript.StdOut.Write 3 * 5 & vbNewLine WScript.StdOut.WriteLine 3 * 5Z:\>cscript //nologo 0101.…

Python で Project Euler Problem 1

3か5の倍数になっている1000未満の自然数を足し合わせよ 10未満の自然数のうち, 3 もしくは 5 の倍数になっているものは 3, 5, 6, 9 の4つがあり, これらの合計は 23 になる. 同じようにして, 1000 未満の 3 か 5 の倍数になっている数字の合計を求めよ. htt…

さまざまな言語で Access オートメーション

VBScript Option Explicit Const acOutputReport = 3 Const acViewPreview = 2 Const acFormatXLS = "Microsoft Excel (*.xls)" Const acFormatRTF = "Rich Text Format (*.rtf)" Const acFormatSNP = "Snapshot Format (*.snp)" Const acFormatHTML = "HTML…

さまざまな言語で Internet Explorer オートメーション

VBScript Option Explicit 'IE起動 Dim ie: Set ie = CreateObject("InternetExplorer.Application") ie.Visible = True ie.Toolbar = True ie.MenuBar = True ie.AddressBar = True ie.StatusBar = True 'ログオン画面 ie.Navigate "http://192.168.1.1/zzz…

REPL

Ruby PS S:\> irb irb(main):001:0> puts "hello world" hello world => nil irb(main):002:0> exitPS S:\>irb irb(main):001:0> x = 10 => 10 irb(main):002:0> y = 20 => 20 irb(main):003:0> z = 30 => 30 irb(main):004:0> area = (x*y + y*z + z*x) * 2…

さまざまな言語で実行時引数を表示

VBScript For Each arg In WScript.Arguments WScript.Echo arg Next For i = 0 To WScript.Arguments.Count - 1 WScript.Echo WScript.Arguments(i) Next JScript var arg = new Enumerator(WScript.Arguments); for (;!arg.atEnd(); arg.moveNext()) WScri…

さまざまな言語で Excel オートメーション (まとめ)

VBScript Dim excelApp: Set excelApp = CreateObject("Excel.Application") excelApp.Visible = True excelApp.DisplayAlerts = False '警告メッセージをOFF 'ブックを読み取り専用で開く Dim book: Set book = excelApp.Workbooks.Open(WScript.Arguments(…

Python で Excel OLE オートメーション シート名を列挙する

# coding: cp932 import win32api, win32con, win32com, win32com.client, os, time, sys xlApp=win32com.client.Dispatch("Excel.Application") xlApp.Visible=True xlApp.DisplayAlerts=False #警告メッセージをOFF #ブックを読み取り専用で開く wb = xlAp…