找回密码
 欢迎注册
查看: 486|回复: 8

[求助] 求勾股本原数组的斜边的通项公式

[复制链接]
发表于 2023-12-7 11:53:38 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?欢迎注册

×
勾股本原数,求斜边的通项公式
前面若干项依次为:
  1. {5, 13, 17, 25, 29, 37, 41, 53, 61, 65, 65, 73, 85, 85, 89, 97, 101, \
  2. 109, 113, 125, 137, 145, 145, 149, 157, 169, 173, 181, 185, 185, 193, \
  3. 197, 205, 205, 221, 221, 229, 233, 241, 257, 265, 265, 269, 277, 281, \
  4. 289, 293, 305, 305, 313, 317, 325, 325, 337, 349, 353, 365, 365, 373, \
  5. 377, 377, 389, 397, 401, 409, 421, 425, 425, 433, 445, 445, 449, 457, \
  6. 461, 481, 481, 485, 485, 493, 493, 505, 505, 509, 521, 533, 533, 541, \
  7. 545, 545, 557, 565, 565, 569, 577, 593, 601, 613, 617, 625, 629, 629, \
  8. 641, 653, 661, 673, 677, 685, 685, 689, 689, 697, 697, 701, 709, 725, \
  9. 725, 733, 745, 745, 757, 761, 769, 773, 785, 785, 793, 793, 797, 809, \
  10. 821, 829, 841, 845, 845, 853, 857, 865, 865, 877, 881, 901, 901, 905, \
  11. 905, 925, 925, 929, 937, 941, 949, 949, 953, 965, 965, 977, 985, 985, \
  12. 997}
复制代码


绘图如下:

看起来像直线,但是又不是直线,如何找出通项公式呢?如果不是通项公式,那要求是尽可能好的拟合公式。

代码如下:

  1. Clear["Global`*"];(*清除所有变量*)
  2. max=1000;(*边长的最大值*)
  3. aa=Flatten[#,1]&@Table[{i,j},{i,1,max,2},{j,1,i,2}];(*产生二元数组(都是奇数),并且第一个元素大于等于第二个*)
  4. bb=Select[aa,GCD@@#==1&&(#[[1]]>#[[2]])&];(*选择互质并且前者大的*)
  5. cc={#1*#2,(#1^2-#2^2)/2,(#1^2+#2^2)/2}&@@@bb;(*产生勾股数*)
  6. dd=Sort[#]&/@cc;(*排序,从小到大*)
  7. ee=Select[dd,#[[3]]<=max&](*最大的<=max*)
  8. ff=Sort@(ee[[All,3]])(*提取第三列,并且从小到大排列*)
  9. ListLinePlot[ff](*绘制曲线*)
复制代码

QQ截图20231207115201.png
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2023-12-7 12:07:32 | 显示全部楼层
https://oeis.org/A020882,拟合公式是
\[a_n≈2πn\]
observation by David W. Wilson, proved by Franklin T. Adams-Watters (cf. comments), Mar 15 2015

点评

nyy
这个居然与pi有关系  发表于 2023-12-7 14:49
nyy
这个拟合的通项公式,真简洁,感觉很不错  发表于 2023-12-7 12:36
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2023-12-7 14:59:27 | 显示全部楼层
看看标准的线性回归得到的直线方程。Y = a*x+b       
  1. DataFit version 9.0.59                                       
  2. Results from project "Untitled1"                                       
  3. Equation ID: a*x+b                                       
  4. Model Definition:                                       
  5. Y = a*x+b                                       
  6.                                        
  7. Number of observations = 158                                       
  8. Number of missing observations = 0                                       
  9. Solver type: Nonlinear                                       
  10. Nonlinear iteration limit = 250                                       
  11. Diverging nonlinear iteration limit =10                                       
  12. Number of nonlinear iterations performed = 1                                       
  13. Residual tolerance = .0000000001                                       
  14. Sum of Residuals = -1.98951966012828E-13                                       
  15. Average Residual = -1.25918965830904E-15                                       
  16. Residual Sum of Squares (Absolute) = 4565.67519422415                                       
  17. Residual Sum of Squares (Relative) = 4565.67519422415                                       
  18. Standard Error of the Estimate = 5.40991207700495                                       
  19. Coefficient of Multiple Determination (R^2) = 0.9996515166                                       
  20. Proportion of Variance Explained = 99.96515166%                                       
  21. Adjusted coefficient of multiple determination (Ra^2) = 0.9996492827                                       
  22. Durbin-Watson statistic = .80690849172544                                       
  23.                                        
  24. Regression Variable Results                                       
  25. Variable        Value        Standard Error        t-ratio        Prob(t)       
  26. a        6.31247157185039        9.43634690033983E-03        668.9528944        0.0       
  27. b        -2.36047730387811        .864881218456765        -2.729250276        0.00708       
  28.                                        
  29. 68% Confidence Intervals                                       
  30. Variable        Value        68% (+/-)        Lower Limit        Upper Limit       
  31. a        6.31247157185039        9.41369966777902E-03        6.30305787218261        6.32188527151817       
  32. b        -2.36047730387811        .862805503532469        -3.22328280741058        -1.49767180034564       
  33.                                        
  34. 90% Confidence Intervals                                       
  35. Variable        Value        90% (+/-)        Lower Limit        Upper Limit       
  36. a        6.31247157185039        1.56143232159923E-02        6.2968572486344        6.32808589506638       
  37. b        -2.36047730387811        1.43111895218041        -3.79159625605852        -.929358351697698       
  38.                                        
  39. 95% Confidence Intervals                                       
  40. Variable        Value        95% (+/-)        Lower Limit        Upper Limit       
  41. a        6.31247157185039        1.86396160322413E-02        6.29383195581815        6.33111118788263       
  42. b        -2.36047730387811        1.70839987081765        -4.06887717469575        -.65207743306046       
  43.                                        
  44. 99% Confidence Intervals                                       
  45. Variable        Value        99% (+/-)        Lower Limit        Upper Limit       
  46. a        6.31247157185039        2.46071618120162E-02        6.28786441003837        6.33707873366241       
  47. b        -2.36047730387811        2.25535075336971        -4.61582805724781        -.105126550508401       
  48.                                        
  49. Variance Analysis                                       
  50. Source        DF        Sum of Squares        Mean Square        F Ratio        Prob(F)
  51. Regression        1        13096989.7678437        13096989.7678437        447497.975        0
  52. Error        156        4565.67519422415        29.267148680924               
  53. Total        157        13101555.443038                       
复制代码


原始数据
  1. 1        5
  2. 2        13
  3. 3        17
  4. 4        25
  5. 5        29
  6. 6        37
  7. 7        41
  8. 8        53
  9. 9        61
  10. 10        65
  11. 11        65
  12. 12        73
  13. 13        85
  14. 14        85
  15. 15        89
  16. 16        97
  17. 17        101
  18. 18        109
  19. 19        113
  20. 20        125
  21. 21        137
  22. 22        145
  23. 23        145
  24. 24        149
  25. 25        157
  26. 26        169
  27. 27        173
  28. 28        181
  29. 29        185
  30. 30        185
  31. 31        193
  32. 32        197
  33. 33        205
  34. 34        205
  35. 35        221
  36. 36        221
  37. 37        229
  38. 38        233
  39. 39        241
  40. 40        257
  41. 41        265
  42. 42        265
  43. 43        269
  44. 44        277
  45. 45        281
  46. 46        289
  47. 47        293
  48. 48        305
  49. 49        305
  50. 50        313
  51. 51        317
  52. 52        325
  53. 53        325
  54. 54        337
  55. 55        349
  56. 56        353
  57. 57        365
  58. 58        365
  59. 59        373
  60. 60        377
  61. 61        377
  62. 62        389
  63. 63        397
  64. 64        401
  65. 65        409
  66. 66        421
  67. 67        425
  68. 68        425
  69. 69        433
  70. 70        445
  71. 71        445
  72. 72        449
  73. 73        457
  74. 74        461
  75. 75        481
  76. 76        481
  77. 77        485
  78. 78        485
  79. 79        493
  80. 80        493
  81. 81        505
  82. 82        505
  83. 83        509
  84. 84        521
  85. 85        533
  86. 86        533
  87. 87        541
  88. 88        545
  89. 89        545
  90. 90        557
  91. 91        565
  92. 92        565
  93. 93        569
  94. 94        577
  95. 95        593
  96. 96        601
  97. 97        613
  98. 98        617
  99. 99        625
  100. 100        629
  101. 101        629
  102. 102        641
  103. 103        653
  104. 104        661
  105. 105        673
  106. 106        677
  107. 107        685
  108. 108        685
  109. 109        689
  110. 110        689
  111. 111        697
  112. 112        697
  113. 113        701
  114. 114        709
  115. 115        725
  116. 116        725
  117. 117        733
  118. 118        745
  119. 119        745
  120. 120        757
  121. 121        761
  122. 122        769
  123. 123        773
  124. 124        785
  125. 125        785
  126. 126        793
  127. 127        793
  128. 128        797
  129. 129        809
  130. 130        821
  131. 131        829
  132. 132        841
  133. 133        845
  134. 134        845
  135. 135        853
  136. 136        857
  137. 137        865
  138. 138        865
  139. 139        877
  140. 140        881
  141. 141        901
  142. 142        901
  143. 143        905
  144. 144        905
  145. 145        925
  146. 146        925
  147. 147        929
  148. 148        937
  149. 149        941
  150. 150        949
  151. 151        949
  152. 152        953
  153. 153        965
  154. 154        965
  155. 155        977
  156. 156        985
  157. 157        985
  158. 158        997
复制代码

点评

nyy
Coefficient of Multiple Determination (R^2) = 0.9996515166 这个回归结果还是很好的!  发表于 2023-12-7 15:02
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
您需要登录后才可以回帖 登录 | 欢迎注册

本版积分规则

小黑屋|手机版|数学研发网 ( 苏ICP备07505100号 )

GMT+8, 2024-5-3 20:39 , Processed in 0.048118 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表