This file contains hidden or 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 | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| def exp(x,N): | |
| """ N:近似次数 """ | |
| x_n = np.array(x,dtype=np.float64) | |
| low = 1.0 | |
| ret = np.ones(len(x)) |
This file contains hidden or 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 | |
| import twitter | |
| api = twitter.Api( | |
| consumer_key=[consumer key], | |
| consumer_secret=[consumer secret], | |
| access_token_key=[access token] | |
| access_token_secret=[access token secret]) |
This file contains hidden or 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
| """ | |
| 球面線形補間(slerp)実装例 | |
| """ | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| from mpl_toolkits.mplot3d import Axes3D |
This file contains hidden or 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
| ! | |
| ! The simulation of Torricelli's law | |
| ! | |
| program pendulum | |
| implicit none | |
| real,parameter :: g = 9.80665 ! gravity acceleration | |
| real,parameter :: dt = 1e0 ! delta time | |
| ! initial value of theta and diff_theta |
This file contains hidden or 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
| ! | |
| ! pogosort by fortran | |
| ! | |
| program pogosort | |
| implicit none | |
| integer,parameter :: N = 5 ! the number of data | |
| integer,parameter :: SEED = 2016 ! the seed of random number | |
| integer,dimension(N) :: arr ! data |
This file contains hidden or 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
| ! | |
| ! pendulum simulation | |
| ! author: @TonyMooori | |
| ! | |
| program pendulum | |
| implicit none | |
| real,parameter :: l = 27.8 ! length of pendulum | |
| real,parameter :: g = 9.8 ! gravity acceleration | |
| real,parameter :: dt = 1e-3 ! delta time |
This file contains hidden or 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
| /* | |
| [参考] | |
| ルンゲクッタ法で様々な連立微分方程式を解く数値計算例(C言語) | |
| http://www.geocities.jp/supermisosan/rksimultaneousequation.html | |
| ほとんどこちらのコードの焼き直し | |
| */ | |
| float t; | |
| float dt = (float)(1e-2); |
This file contains hidden or 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
| /* 4次ルンゲクッタ法によるロジスティック方程式の解の計算 */ | |
| #include <stdio.h> | |
| #define K 1000.0 // 個体数のしきい値 | |
| #define r 0.9 // 1個体の増加率 | |
| #define N_LOOP 10000 // ループ回数 | |
| // 積分する関数g(t,N) | |
| double g(double t,double N_t){ | |
| return r*(K-N_t)*N_t/K; |
This file contains hidden or 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
| /* シンプソンの公式による1/(x^2+1)の計算 */ | |
| #include <stdio.h> | |
| // 被積分関数 | |
| double f(double x){ | |
| return 4.0/(x*x+1.0); | |
| } | |
| int main(void){ | |
| int k; // ループカウンタ |
This file contains hidden or 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
| /* 修正Euler法による微分方程式 f' - 2f = x の計算 */ | |
| #include <stdio.h> | |
| #include <math.h> | |
| double g(double x,double fx){ | |
| return x + 2.0 * fx; | |
| } | |
| int main(void){ | |
| int k; // ループカウンタ |