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
<!DOCTYPE html> | |
<html lang="ja"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>強化学習</title> | |
</head> | |
<body> | |
<h1>強化学習で迷路を解く</h1> | |
<canvas id="canvas" width="512" height="512"></canvas> |
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
# 関の発微算法の問14の数値解を計算するPythonスクリプト | |
# 参考: | |
# https://www.youtube.com/watch?v=cHaVY-h22Dk | |
# ただし、この動画は問題の条件と途中式に誤植があるので注意(本プログラムは誤植修正済み) | |
from scipy.optimize import fsolve | |
import numpy as np | |
# 最小化したい関数 | |
def f(p): |
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
### | |
# 素数大富豪で出せるかどうかを判定する関数 | |
# | |
# 素数大富豪で出せるかどうか判定する関数 | |
# | |
# arguments: | |
# number: 判定したい数(str型) | |
# debug: デバッグモードかどうか(bool型・任意) |
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
import numpy as np | |
import math | |
# (√6+√2)/2 の共役元 | |
alpha1 = (math.sqrt(6)+math.sqrt(2))/2 | |
alpha2 = (math.sqrt(6)-math.sqrt(2))/2 | |
alpha3 = (-math.sqrt(6)+math.sqrt(2))/2 | |
alpha4 = (-math.sqrt(6)-math.sqrt(2))/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
# coding: utf-8 | |
# 2020/01/19 | |
# 平方因子を持たない0,1を除く有理整数 m について、 | |
# 2次体 Q(√m) の整数環 Z[ω] のイデアルの積を計算できるプログラム | |
# | |
# ただし、ωはmに応じて次のルールで計算される: | |
# ω = √m (m ≡ 2, 3 (mod 4)) | |
# ω = (1+√m)/2 (m ≡ 1 (mod 4)) | |
# |
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
# 多項式のクラス | |
class Polynomial(): | |
def __init__(self,array): | |
self.__zero = (array[0]-array[0]) # 任意の係数の "0" を作るためのアクロバティックな処理 | |
# 多項式の次数を確認し、次数以上の係数を取り除く前処理 | |
d = 0 | |
for i in range(len(array)): | |
if array[i] != self.__zero: | |
d = i | |
size = d+1 |
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 scipy.misc as scm | |
# パスカルの三角形を生成 | |
print("") | |
print("") | |
print("") | |
n = 10 |
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
0076335877862595419847328244274809160305343511450381679389312977099236641221374045801526717557251908396946564885496183206106870229 | |
* 1 = 0076335877862595419847328244274809160305343511450381679389312977099236641221374045801526717557251908396946564885496183206106870229 | |
* 118 = 9007633587786259541984732824427480916030534351145038167938931297709923664122137404580152671755725190839694656488549618320610687022 | |
* 38 = 2900763358778625954198473282442748091603053435114503816793893129770992366412213740458015267175572519083969465648854961832061068702 | |
* 30 = 2290076335877862595419847328244274809160305343511450381679389312977099236641221374045801526717557251908396946564885496183206106870 | |
* 3 = 0229007633587786259541984732824427480916030534351145038167938931297709923664122137404580152671755725190839694656488549618320610687 | |
* 92 = 7022900763358778625954198473282442748091603053435114503816793893129770992366412213740458015267175572519083969465648854961832061068 | |
* 114 = 870229007633587786259541984732824427480916030534351 |
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
# hasse's theorem | |
require 'prime' | |
require 'set' | |
# F_p 上の楕円曲線 y^2 = x^3 - x の有理点をカウントする | |
def count_elliptic_points_over_finite_field p | |
points = Set.new |
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
require 'prime' | |
# 平方剰余の相互法則を用いて「p が法 q の平方剰余 (quadratic residue) かどうか」を判定する | |
# | |
# input: | |
# p, q: odd prime | |
# output: | |
# p が q の 平方剰余 => +1, 平方非剰余 => -1 | |
def qr p, q | |
sgn = 1 |
NewerOlder