This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/local/bin/ruby | |
#********************************************* | |
# ラグランジュ補間 | |
#********************************************* | |
# | |
class InterpolateLagrange | |
# あらかじめ与える点 | |
X = [0.0, 2.0, 3.0, 5.0, 8.0] | |
Y = [0.8, 3.2, 2.8, 4.5, 1.9] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
#********************************************* | |
# 非線形方程式の解法 ( ニュートン法 ) | |
#********************************************* | |
class NonlinearEquationNewton | |
# 各種定数 | |
EPS = 1e-08 # 打ち切り精度 | |
LIMIT = 50 # 打ち切り回数 | |
# 計算クラス |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
#********************************************* | |
# 非線形方程式の解法 ( 2分法 ) | |
#********************************************* | |
class NonlinearEquation | |
# 各種定数 | |
EPS = 1e-08 # 打ち切り精度 | |
LIMIT = 50 # 打ち切り回数 | |
# 計算クラス |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
#********************************************* | |
# テイラー展開 [ cos(x) ] | |
#********************************************* | |
class TaylorExpansionCos | |
# 各種定数 | |
EPS = 1e-08 # 精度 | |
PI = 3.1415926535 # 円周率 | |
# 計算クラス |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
#********************************************* | |
# テイラー展開 [ exp(x) ] | |
#********************************************* | |
class TaylorExpansion | |
# 各種定数 | |
EPS = 1e-08 # 精度 | |
# 計算クラス | |
class Calc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
#********************************************* | |
# シンプソン則による定積分 | |
#********************************************* | |
class DefiniteIntegralSimpson | |
# 積分区間分割数 | |
M = 100 | |
# 計算クラス | |
class Calc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
#********************************************* | |
# 台形則による定積分 | |
#********************************************* | |
class DefiniteIntegralTrapzoid | |
# 積分区間分割数 | |
M = 100 | |
# 計算クラス | |
class Calc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#********************************************* | |
# ボックス=ミューラー法法による正規乱数生成 | |
#********************************************* | |
class RndnumBoxMuller | |
# 各種定数 | |
M = 10 # 平均 | |
S = 2.5 # 標準偏差 | |
N = 10000 # 発生させる乱数の個数 | |
PI = 3.1415926535 # 円周率 | |
SCALE = N / 100.0 # ヒストグラム用スケール |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
class Chi2Rndnum | |
# 各種定数定義 | |
A = 1103515245 # 乗数 | |
C = 12345 # 加数 | |
M = 2 ** 31 # 法 | |
N = 1000 # 発生させる乱数の個数 | |
M_MAX = 10 # 整数乱数の範囲 | |
F = N / M_MAX.to_f # 期待値 | |
S = 40.0 / F # ヒストグラム用スケール |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
class RndnumLcgs | |
# 各種定数定義 | |
A = 1103515245 # 乗数 | |
C = 12345 # 加数 | |
M = 2 ** 31 # 法 | |
N = 1000 # 発生させる乱数の個数 | |
# 計算クラス | |
class Calc |