Skip to content

Commit 146b2fb

Browse files
committed
Update
1 parent e04cd68 commit 146b2fb

File tree

167 files changed

+1380
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+1380
-2
lines changed

README.md

+1-1

utils/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
[![Forks](https://img.shields.io/github/forks/mbinary/USTC-CS-Courses-Resource.svg?label=Fork&style=social)](https://github.com/mbinary/USTC-CS-Courses-Resource/network/members)
6363
[![repo-size](https://img.shields.io/github/repo-size/mbinary/USTC-CS-Courses-Resource.svg)]()
6464
[![Contributors](https://img.shields.io/github/contributors/mbinary/USTC-CS-Courses-Resource.svg)](https://github.com/mbinary/USTC-CS-Courses-Resource/graphs/contributors)
65-
[![License](https://i.creativecommons.org/l/by-nc-sa/4.0/80x22.png)](http://creativecommons.org/licenses/by-nc-sa/4.0/)
65+
[![License](https://i.creativecommons.org/l/by-nc-sa/4.0/80x15.png)](http://creativecommons.org/licenses/by-nc-sa/4.0/)
6666
6767
>本仓库收录中国科学技术大学众多课程资源,包括电子版教材、参考书、讲义、试卷、学习心得、习题解答等。以计算机学院课程为主,也包含公选课、自由选修等其他课程。
6868

其他/README.md

+6

数学类/README.md

+1
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

数学类/数理方程/README.md

+1
4.14 MB
Binary file not shown.
1.38 MB
Binary file not shown.
439 KB
Binary file not shown.
1.41 MB
Binary file not shown.
769 KB
Binary file not shown.
2.34 MB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6.22 MB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#########################################################################
2+
# File : linear_equation.py
3+
# Author: mbinary
4+
5+
# Blog: https://mbinary.xyz
6+
# Github: https://github.com/mbinary
7+
# Created Time: 2018-05-20 08:36
8+
# Description: 书上p186 附录1 程序11
9+
#########################################################################
10+
11+
import numpy as np
12+
13+
def gauss_prior_elimination(A,b=None):
14+
'''using guass elimination,get up_trianglge form of A'''
15+
m,n = A.shape
16+
res = [0]*m if b is None else b
17+
if m!=n:raise Exception("[Error]: matrix is not inversable")
18+
B = np.matrix(A,dtype=float) # necessary,otherwise when the dtype of A is int, then it will be wrong
19+
for i in range(m-1):
20+
col = abs(B[i:,i]) # note using abs value, return a matrix in (m-i)x1 form
21+
mx = col.max()
22+
if mx==0: raise Exception("[Error]: matrix is not inversable")
23+
pos = i+col.argmax()
24+
if pos != i : B[[pos,i],:] = B[[i,pos],:] # note how to swap cols/rows
25+
#B[i,:] = B[i,:]/mx
26+
#res[i]/=mx
27+
for j in range(i+1,m):
28+
if B[j,i]!=0:
29+
B[j,:] -= B[j,i]/B[i,i] * B[i,:]
30+
res[j] -= res[i]/B[i,i]*res[j]
31+
if b is None:return B
32+
return B,res
33+
34+
def det(A):
35+
m,n = A.shape
36+
ret=1
37+
B = gauss_prior_elimination(A)
38+
for i in range(m):ret *= B[i,i]
39+
return ret
40+
41+
def test(A):
42+
print()
43+
print('计算行列式')
44+
print(A)
45+
print('我的结果: det(A) = ',det(A))
46+
print('函数调用: det(A) = ',np.linalg.det(A))
47+
if __name__ == '__main__':
48+
A = np.matrix([[10,5,0,0],
49+
[2,2,1,0],
50+
[0,10,0,5],
51+
[0,0,2,1]])
52+
test(A)
53+
54+
A = np.matrix([[-6,3,2],
55+
[3,5,1],
56+
[2,1,6]])
57+
test(A)
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
2+
#########################################################################
3+
# File : numerical integration.py
4+
# Author: mbinary
5+
6+
# Blog: https://mbinary.xyz
7+
# Github: https://github.com/mbinary
8+
# Created Time: 2018-05-11 08:58
9+
# Description:
10+
# numerical intergration: using Newton-Cotes integration, and Simpson
11+
# 数值积分, 使用 牛顿-科特斯积分, 辛普森
12+
#########################################################################
13+
14+
from math import sin
15+
16+
import numpy as np
17+
18+
def mypprint(lst):
19+
for i in lst:
20+
print(('%.4f'%i).ljust(10),end='')
21+
print()
22+
23+
def trapezoidal(a,b,h,fs):
24+
'''梯形积分公式'''
25+
xs = [i for i in np.arange(a,b+h,h)]
26+
print('x'.ljust(10),end='')
27+
mypprint(xs)
28+
print('fx'.ljust(10),end='')
29+
mypprint(fs)
30+
ret = h*(sum(fs)-fs[0]/2 - fs[-1]/2)
31+
print(ret)
32+
return ret
33+
34+
35+
def simpson(a,b,h,fs):
36+
'''辛普森积分公式'''
37+
xs = [i for i in np.arange(a,b+h,h)]
38+
print('x'.ljust(10),end='')
39+
mypprint(xs)
40+
print('fx'.ljust(10),end='')
41+
mypprint(fs)
42+
ret = h/3*(4* sum(fs[1::2])+ 2*sum(fs[2:-1:2]) + fs[0]+fs[-1])
43+
print(ret)
44+
return ret
45+
46+
47+
def romberg(a,b,f,epcilon):
48+
'''romberg(龙贝格) 数值积分'''
49+
h = b-a
50+
lst1=[h*(f(a)+f(b))/2]
51+
mypprint(lst1)
52+
delta = epcilon
53+
k=1
54+
while delta >= epcilon:
55+
h/=2
56+
k+=1
57+
lst2=[]
58+
lst2.append((lst1[0]+h*2*sum(f(a+(2*i-1)*h) for i in range(1,2**(k-2)+1)))/2)
59+
for j in range(0,k-1):
60+
lst2.append(lst2[j]+(lst2[j]-lst1[j])/(4**(j+1)-1))
61+
delta = abs(lst2[-1]-lst1[-1])
62+
lst1=lst2
63+
mypprint(lst1)
64+
65+
if __name__=='__main__':
66+
print("数值积分")
67+
a,b,h = 0.6,1.8,0.2
68+
fs=[5.7,4.6,3.5,3.7,4.9,5.2,5.5]
69+
print("\n梯形公式")
70+
trapezoidal(a,b,h,fs)
71+
72+
print("\n辛普森公式")
73+
simpson(a,b,h,fs)
74+
75+
print('\n龙贝格公式')
76+
print("函数:{}, 区间:{} 精度:{}".format('sin(x^4)','[1,2]',1e-4))
77+
romberg(1,2,lambda x:sin(x**4),1e-4)
Binary file not shown.

0 commit comments

Comments
 (0)