Skip to content

Instantly share code, notes, and snippets.

@yyk458
yyk458 / euler_runge.py
Created June 14, 2019 07:12
オイラールンゲ
# coding: utf-8
# Your code here!
def f(x, y):
return x + y
def euler(dx, x, y):
return y + dx * f(x, y)
def improve_euler(dx, x, y):
return y + 0.5*dx * (f(x, y) + f(x+dx, euler(dx, x, y)))
@yyk458
yyk458 / main.py
Created May 31, 2019 06:12
【python3】掃き出し法
# coding: utf-8
#input
N = int(input())
index = [i for i in range(N)]
mat = []
for i in index:
tmp = input().split(" ")
tmp = list(map(float, tmp))
mat.append(tmp)
@yyk458
yyk458 / main.cpp
Last active May 31, 2019 06:11
c++ガウスザイデル法
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cmath>
using namespace std;
#define outVec(v) for(int i = 0; i < (v).size() - 1; ++i){ cout << (v)[i] << " "; } cout << (v)[v.size() - 1]; cout << endl
#define debug(x) cout<<#x<<": "<<x<<endl
@yyk458
yyk458 / Main.java
Created May 31, 2019 06:05
【Java】二分法ニュートン法割線法(セカント法)
import java.util.ArrayList;
import java.util.List;
public class Main {
public static double f(double x) {
return x*x + x - 6;
}
@yyk458
yyk458 / 01_basic.html
Last active February 17, 2018 10:14
【JavaScript】備忘録
<!DOCTYPE HTML>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>JSであそぼ - 基本</title>
</head>
<body>
<h1>jsであそぼ</h1>
@yyk458
yyk458 / basic.py
Created February 2, 2018 13:17
python3備忘録
# -*-coding: utf-8 -*-
#Hello world
print("Hello, python.")
#四則演算
print(1 + 1)
print(33 - 4)
print(4 * 6)
print(81 / 9)
@yyk458
yyk458 / TheFateOfTwoPeopleWhoAreAttracted.cpp
Last active January 10, 2018 07:14
セカント法挟み撃ち法
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
double f(double x){
@yyk458
yyk458 / newton.py
Last active December 13, 2017 05:06
にぶんほうにゅーとんほう
# coding: utf-8
def f(x):
return x**3 - 3*(x**2) + 9*x - 8
def df(x):
return 3*(x**2) - 6*x + 9
if __name__ == '__main__':
x = [5]
x.append(x[0] - f(x[0])/df(x[0]))
@yyk458
yyk458 / trapezoidalAndSimpsonsRule.cpp
Last active October 11, 2017 09:28
【C++】台形則と中点則である関数と指定された区間に対する定積分を計算する。
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#define output(x) cout << (x) << endl
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
@yyk458
yyk458 / outputVector.cpp
Created August 25, 2017 07:50
【C++】vectorの気の利いた出力マクロ
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define outVec(v) for(int f7bv3d72gsq = 0; f7bv3d72gsq < (v).size() - 1; ++f7bv3d72gsq){ cout << (v)[f7bv3d72gsq] << " "; } cout << (v)[v.size() - 1]; cout << endl
#define outVec2(v) for(int d366dv2s6cbz = 0; d366dv2s6cbz < (v).size(); ++d366dv2s6cbz){ outVec((v)[d366dv2s6cbz]); } bool throwingPiece
int main()