求勾股本原数组的斜边的通项公式
勾股本原数,求斜边的通项公式前面若干项依次为:
{5, 13, 17, 25, 29, 37, 41, 53, 61, 65, 65, 73, 85, 85, 89, 97, 101, \
109, 113, 125, 137, 145, 145, 149, 157, 169, 173, 181, 185, 185, 193, \
197, 205, 205, 221, 221, 229, 233, 241, 257, 265, 265, 269, 277, 281, \
289, 293, 305, 305, 313, 317, 325, 325, 337, 349, 353, 365, 365, 373, \
377, 377, 389, 397, 401, 409, 421, 425, 425, 433, 445, 445, 449, 457, \
461, 481, 481, 485, 485, 493, 493, 505, 505, 509, 521, 533, 533, 541, \
545, 545, 557, 565, 565, 569, 577, 593, 601, 613, 617, 625, 629, 629, \
641, 653, 661, 673, 677, 685, 685, 689, 689, 697, 697, 701, 709, 725, \
725, 733, 745, 745, 757, 761, 769, 773, 785, 785, 793, 793, 797, 809, \
821, 829, 841, 845, 845, 853, 857, 865, 865, 877, 881, 901, 901, 905, \
905, 925, 925, 929, 937, 941, 949, 949, 953, 965, 965, 977, 985, 985, \
997}
绘图如下:
看起来像直线,但是又不是直线,如何找出通项公式呢?如果不是通项公式,那要求是尽可能好的拟合公式。
代码如下:
Clear["Global`*"];(*清除所有变量*)
max=1000;(*边长的最大值*)
aa=Flatten[#,1]&@Table[{i,j},{i,1,max,2},{j,1,i,2}];(*产生二元数组(都是奇数),并且第一个元素大于等于第二个*)
bb=Select]>#[])&];(*选择互质并且前者大的*)
cc={#1*#2,(#1^2-#2^2)/2,(#1^2+#2^2)/2}&@@@bb;(*产生勾股数*)
dd=Sort[#]&/@cc;(*排序,从小到大*)
ee=Select]<=max&](*最大的<=max*)
ff=Sort@(ee[])(*提取第三列,并且从小到大排列*)
ListLinePlot(*绘制曲线*)
按https://oeis.org/A020882,拟合公式是
\
observation by David W. Wilson, proved by Franklin T. Adams-Watters (cf. comments), Mar 15 2015 看看标准的线性回归得到的直线方程。Y = a*x+b
DataFit version 9.0.59
Results from project "Untitled1"
Equation ID: a*x+b
Model Definition:
Y = a*x+b
Number of observations = 158
Number of missing observations = 0
Solver type: Nonlinear
Nonlinear iteration limit = 250
Diverging nonlinear iteration limit =10
Number of nonlinear iterations performed = 1
Residual tolerance = .0000000001
Sum of Residuals = -1.98951966012828E-13
Average Residual = -1.25918965830904E-15
Residual Sum of Squares (Absolute) = 4565.67519422415
Residual Sum of Squares (Relative) = 4565.67519422415
Standard Error of the Estimate = 5.40991207700495
Coefficient of Multiple Determination (R^2) = 0.9996515166
Proportion of Variance Explained = 99.96515166%
Adjusted coefficient of multiple determination (Ra^2) = 0.9996492827
Durbin-Watson statistic = .80690849172544
Regression Variable Results
Variable Value Standard Error t-ratio Prob(t)
a 6.31247157185039 9.43634690033983E-03 668.9528944 0.0
b -2.36047730387811 .864881218456765 -2.729250276 0.00708
68% Confidence Intervals
Variable Value 68% (+/-) Lower Limit Upper Limit
a 6.31247157185039 9.41369966777902E-03 6.30305787218261 6.32188527151817
b -2.36047730387811 .862805503532469 -3.22328280741058 -1.49767180034564
90% Confidence Intervals
Variable Value 90% (+/-) Lower Limit Upper Limit
a 6.31247157185039 1.56143232159923E-02 6.2968572486344 6.32808589506638
b -2.36047730387811 1.43111895218041 -3.79159625605852 -.929358351697698
95% Confidence Intervals
Variable Value 95% (+/-) Lower Limit Upper Limit
a 6.31247157185039 1.86396160322413E-02 6.29383195581815 6.33111118788263
b -2.36047730387811 1.70839987081765 -4.06887717469575 -.65207743306046
99% Confidence Intervals
Variable Value 99% (+/-) Lower Limit Upper Limit
a 6.31247157185039 2.46071618120162E-02 6.28786441003837 6.33707873366241
b -2.36047730387811 2.25535075336971 -4.61582805724781 -.105126550508401
Variance Analysis
Source DF Sum of Squares Mean Square F Ratio Prob(F)
Regression 1 13096989.7678437 13096989.7678437 447497.975 0
Error 156 4565.67519422415 29.267148680924
Total 157 13101555.443038
原始数据
1 5
2 13
3 17
4 25
5 29
6 37
7 41
8 53
9 61
10 65
11 65
12 73
13 85
14 85
15 89
16 97
17 101
18 109
19 113
20 125
21 137
22 145
23 145
24 149
25 157
26 169
27 173
28 181
29 185
30 185
31 193
32 197
33 205
34 205
35 221
36 221
37 229
38 233
39 241
40 257
41 265
42 265
43 269
44 277
45 281
46 289
47 293
48 305
49 305
50 313
51 317
52 325
53 325
54 337
55 349
56 353
57 365
58 365
59 373
60 377
61 377
62 389
63 397
64 401
65 409
66 421
67 425
68 425
69 433
70 445
71 445
72 449
73 457
74 461
75 481
76 481
77 485
78 485
79 493
80 493
81 505
82 505
83 509
84 521
85 533
86 533
87 541
88 545
89 545
90 557
91 565
92 565
93 569
94 577
95 593
96 601
97 613
98 617
99 625
100 629
101 629
102 641
103 653
104 661
105 673
106 677
107 685
108 685
109 689
110 689
111 697
112 697
113 701
114 709
115 725
116 725
117 733
118 745
119 745
120 757
121 761
122 769
123 773
124 785
125 785
126 793
127 793
128 797
129 809
130 821
131 829
132 841
133 845
134 845
135 853
136 857
137 865
138 865
139 877
140 881
141 901
142 901
143 905
144 905
145 925
146 925
147 929
148 937
149 941
150 949
151 949
152 953
153 965
154 965
155 977
156 985
157 985
158 997
页:
[1]