在这篇文章中,我们将详细讨论拉格朗日四方形定理,并举例说明和验证它的算法。
目录:
- 什么是自然数?
- 你知道吗?
- 证明
- 算法
- 时间复杂度
- 现实生活中的应用
- 问题
在我们深入研究细节之前。这里有一些你可能不知道的有趣的数学事实,这将有助于你更好地理解拉格朗日四平定理。
什么是自然数?
自然数是正整数(整数),如1,2,3,等等。
你知道吗?
1.不是每个自然数都可以写成两个平方的和。例如,9=0²+3²。但是,我们不能用这种方式来写6
**。**2.不是每个自然数都可以写成三个平方的总和。例如,11 = 3² + 1² + 1²。但是,我们不能以这种方式来写数字7
。有趣的是,每个自然数都可以写成四个整数的平方之和。继续阅读,你很快就会发现是怎样的!
拉格朗日的四次方定理
根据拉格朗日的四次方定理,每个自然数无论多大,都可以写成最多四个非负整数的平方之和。
下面是几个例子:
**1 = 1² + 0² + 0² + 0²
2 = 1² + 1
² + 0²
+ 0²
3 = 1² + 1² + 1² + 0
²
4 = 1² +
1² + 1² + 1²
5 = 2² + 1² + 0² + 0²
331 = 17² + 5² + 4² + 1
²
967 = 31² + 2² + 1
²
+ 1²
23159 = 151² + 18² + 5² + 3²
23160 = 152² + 6² + 4² + 2²
97,995,689 = 9876² + 678² + 25² + 2²
835,411,385,623 = 913469² + 31397² + 7² + 2
²
**
以下是Python中提供的代码,它可以找到满足拉格朗日四次方定理条件的4个数字,对于给定的数字n。
证明
(1) 设G是一个有限群,设H是G的一个子群,则H除以G。H的顺序除以G的顺序。H和G的顺序是指H和G中有多少个元素。
(2) 设a∈G(让a是g的一个元素)
让∅是一个函数,使∅:
假设x,y∈H,∅(x)=∅(y)
那么,通过左旋取消,ax=ay,x=y
所以,∅是一对一的。
假设z∈aH,
那么,z=ah,对于某些h∈H,
所以∅(h)=ah=z
,∅是
一个双射
。
(3) 由于H和aH之间存在双射关系,它们的元素数必须相同。
因此,|H| = |aH|。
这意味着H在G中的每一个左coset的元素数都与H相同。
由于H在G中的coset对G进行分割,因此|G| = r|H|,其中r是H在G中的左coset数
。
拉格朗日四边形定理的实现
算法
# a is the number whose 4 squares we are trying to find.
def fourSqaureAlgorithm(a):
# Step 1: i will start at 0. In the first while loop, the first i will be 0 and the second i will be 0.
# 0 * 0 will give us 0 which is less than the value of variable a which is 25.
i = 0
while (i * i <= a
# Step 2: j will start at 0. In the second while loop, the first j will start at 0. The second j will start at 0.
# 0 * 0 will give us 0 which is less than the value of variable a which is 25.
j = i
while (j * j <= a) :
# Step 3: k will start at 0. In the second while loop, the first k will start at 0. The second k will start at 0.
# 0 * 0 will give us 0 which is less than the value of variable a which is 25.
k = j
while (k * k <= a) :
# Step 4: l will start at 0. In the second while loop, the first l will start at 0. The second l will start at 0.
# 0 * 0 will give us 0 which is less than the value of variable a which is 25.
l = k
while (l * l <= a) :
# Step 5: check if sum of four squares equals
# the given number 25. Here we get 0 == 25, which is false.
if (i * i + j * j + k * k + l * l == a) :
# printing the numbers
print ("{} = {}*{} + {}*{} +".
format(a,i,i,j,j), end = " ")
print ("{}*{} + {}*{}".
# Step 6: We increment l by 1 to get 1. l = 1. Go back up the while loops. 1 * 1 <= 25.
# We recheck the addition of the value and if they equal 25 through the if statement. They do
# not so we increment l by 1 again and try again.
l = l + 1
k = k + 1
j = j + 1
i = i + 1
时间复杂度
上述算法的时间复杂度将是O(N^2),因为有4个O(N^0.5)的嵌套循环。
拉格朗日四舍五入定理的现实应用
拉格朗日四次方定理在现实生活中应用的一个例子是警察设备。有一种被称为 "安全导师 "的设备,可以通过拍下相隔几英里的过往车辆的两个独立图像来检测是否违反速度限制。如果这两辆车之间经过的时间比你走完这段路程所需的时间短,你就会被开出罚单。因为这将意味着你的平均速度高于规定的限制。拉格朗日定理指出,在安全导师检查的道路距离中,有一个点,你的瞬时速度等于平均速度,而这个速度被确定为超过规定的限制。