Advertisement
MatsGranvik

Relation to square roots times a constant greater than 1

Jul 6th, 2019
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. "Relation to square roots times a constant greater than 1"
  2. (*start*)
  3. a = 1/10;(*"a" is a fraction of the form 1/positiveInteger*)
  4. b = 0;
  5. nn = 64;
  6. TableForm[
  7. L2 = Table[
  8. LinearProgramming[
  9. Table[1/n, {n, 1, k}], {Table[If[n == 1, k, 1], {n, 1, k}]}, {{1,
  10. 0}}, Table[
  11. If[n == 1, {-1, 1}, {-a*(n - 1), b*(n - 1)}], {n, 1, k}]], {k,
  12. 1, nn}]];
  13. t1 = Table[Sum[If[L2[[n, k]] <= -1, 1, 0], {k, 2, n}], {n, 2, nn}]
  14.  
  15. t2 = Table[
  16. Round[-(a^(-1) - 1) + Sqrt[2/a*(n - 1 - (1 - a))]], {n, 2, nn}]
  17. Show[ListLinePlot[t1],
  18. ListLinePlot[t2]]
  19. (*end*)
  20.  
  21.  
  22. "Relation to square roots times a constant a = 1 upperbound + 1"
  23. (*start*)
  24. a = 1/1;(*"a" is a fraction of the form 1/positiveInteger*)
  25. b = 0;
  26. c = 1;
  27. nn = 20;
  28.  
  29. TableForm[
  30. L2 = Table[
  31. LinearProgramming[
  32. Table[1/n, {n, 1, k}], {Table[If[n == 1, k, 1], {n, 1, k}]}, {{1,
  33. 0}}, Table[
  34. If[n == 1, {-1, 1}, {-a*(n - 1), 1 + b*(n - 1)}], {n, 1,
  35. k}]], {k, 1, nn}]];
  36. t1 = Table[Sum[If[L2[[n, k]] <= -1, 1, 0], {k, 2, n}], {n, 2, nn}]
  37.  
  38. t2 = Table[
  39. Round[-(a^(-1) - 1) - 1 +
  40. Sqrt[-1/1 + 2*2/a*((n - 1 + 1) - 1 - (1 - a))]], {n, 2, nn}]
  41. Show[ListLinePlot[t1], ListLinePlot[t2]]
  42. Clear[a, n]
  43. Expand[-(a^(-1) - 1) - 1 +
  44. Sqrt[-1/1 + 2*2/a*((n - 1 + 1) - 1 - (1 - a))]]
  45. (*end*)
  46.  
  47.  
  48.  
  49. "Relation to square roots times a constant a = 2 upperbound + 2"
  50. (*start*)
  51. a = 2/1;(*"a" is a fraction of the form 1/positiveInteger*)b = 0;
  52. nn = 20;
  53. TableForm[
  54. L2 = Table[
  55. LinearProgramming[
  56. Table[1/n, {n, 1, k}], {Table[If[n == 1, k, 1], {n, 1, k}]}, {{1,
  57. 0}},
  58. Table[If[n == 1, {-1, 1}, {-a*(n - 1), 2 + b*(n - 1)}], {n, 1,
  59. k}]], {k, 1, nn}]];
  60. t1 = Table[Sum[If[L2[[n, k]] <= -1, 1, 0], {k, 2, n}], {n, 2, nn}]
  61.  
  62. t2 = Table[
  63. Round[-(a^(-1) - 1) - 1 - 1/2 +
  64. Sqrt[-1/2 + 3*2/a*((n - 1) - 1 - (1 - a))]], {n, 2, nn}]
  65. Show[ListLinePlot[t1], ListLinePlot[t2]]
  66. Clear[a, n]
  67. Expand[-(a^(-1) - 1) - 1 - 1/2 +
  68. Sqrt[-1/2 + 3*2/a*((n - 1) - 1 - (1 - a))]]
  69. (*end*)
  70.  
  71.  
  72. "Relation to square roots times a constant a = 3 upperbound + 3"
  73. (*start*)
  74. a = 3/1;(*"a" is a fraction of the form 1/positiveInteger*)b = 0;
  75. c = 3;
  76. nn = 80;
  77. TableForm[
  78. L2 = Table[
  79. LinearProgramming[
  80. Table[1/n, {n, 1, k}], {Table[If[n == 1, k, 1], {n, 1, k}]}, {{1,
  81. 0}}, Table[
  82. If[n == 1, {-1, 1}, {-a*(n - 1), c + b*(n - 1)}], {n, 1,
  83. k}]], {k, 1, nn}]];
  84. t1 = Table[Sum[If[L2[[n, k]] <= -1, 1, 0], {k, 2, n}], {n, 2, nn}]
  85.  
  86. t2 = Table[
  87. Round[-(1/a - 1) - (-1 + c - 1/c) +
  88. Sqrt[-1/c + (c + 1)*2/a*((n - 1 - 1) - 1 - (1 - a))]], {n, 2, nn}]
  89. Show[ListLinePlot[t1, PlotStyle -> Red], ListLinePlot[t2]]
  90. Clear[a, n];
  91. Expand[-(1/a - 1) - (-1 + c - 1/c) +
  92. Sqrt[-1/c + (c + 1)*2/a*((n - 1 - 1) - 1 - (1 - a))]]
  93. (*end*)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement