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
# 関の発微算法の問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 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 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 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 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 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 'benchmark' | |
_MAXNUM=1000 | |
#=begin | |
# 二項係数 nCk を計算する関数 ver.1 | |
def binom_v1(n,k) | |
if k==0 then | |
return 1 |
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 | |
import scipy.misc as scm | |
# パスカルの三角形を生成 | |
print("") | |
print("") | |
print("") | |
n = 10 |
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
require 'rational' | |
class AugmentedMatrix | |
def initialize a, b, mod | |
@matrix = [] | |
@i_size = a.size | |
@j_size = a[0].size |
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
#複数多項式二次ふるい法(MPQS) | |
# の作りかけ | |
# | |
# 参考: | |
# https://en.wikipedia.org/wiki/Quadratic_sieve#Example_of_basic_sieve | |
# http://www.cs.t-kougei.ac.jp/nsim/lecture/2008/ws/QS.pdf | |
# http://www.asahi-net.or.jp/~KC2H-MSM/mathland/math12/math1207.htm | |
# http://inaz2.hatenablog.com/entry/2016/01/09/032521 | |
# http://d.hatena.ne.jp/lemniscus/20130226/1361874593#special | |
# |
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
0076335877862595419847328244274809160305343511450381679389312977099236641221374045801526717557251908396946564885496183206106870229 | |
* 1 = 0076335877862595419847328244274809160305343511450381679389312977099236641221374045801526717557251908396946564885496183206106870229 | |
* 118 = 9007633587786259541984732824427480916030534351145038167938931297709923664122137404580152671755725190839694656488549618320610687022 | |
* 38 = 2900763358778625954198473282442748091603053435114503816793893129770992366412213740458015267175572519083969465648854961832061068702 | |
* 30 = 2290076335877862595419847328244274809160305343511450381679389312977099236641221374045801526717557251908396946564885496183206106870 | |
* 3 = 0229007633587786259541984732824427480916030534351145038167938931297709923664122137404580152671755725190839694656488549618320610687 | |
* 92 = 7022900763358778625954198473282442748091603053435114503816793893129770992366412213740458015267175572519083969465648854961832061068 | |
* 114 = 870229007633587786259541984732824427480916030534351 |
NewerOlder