Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. jagy@phobeusjunior:~$ ./Pell_Target_Fundamental
  2. Automorphism matrix:
  3. 3 4
  4. 2 3
  5. Automorphism backwards:
  6. 3 -4
  7. -2 3
  8.  
  9. 3^2 - 2 2^2 = 1
  10.  
  11. w^2 - 2 v^2 = 119 = 7 17
  12.  
  13. Tue May 21 12:25:13 PDT 2019
  14.  
  15. w: 11 v: 1 SEED KEEP +-
  16. w: 13 v: 5 SEED KEEP +-
  17. w: 19 v: 11 SEED BACK ONE STEP 13 , -5
  18. w: 29 v: 19 SEED BACK ONE STEP 11 , -1
  19. w: 37 v: 25
  20. w: 59 v: 41
  21. w: 101 v: 71
  22. w: 163 v: 115
  23. w: 211 v: 149
  24. w: 341 v: 241
  25. w: 587 v: 415
  26. w: 949 v: 671
  27. w: 1229 v: 869
  28. w: 1987 v: 1405
  29. w: 3421 v: 2419
  30. w: 5531 v: 3911
  31. w: 7163 v: 5065
  32. w: 11581 v: 8189
  33. w: 19939 v: 14099
  34. w: 32237 v: 22795
  35. w: 41749 v: 29521
  36. w: 67499 v: 47729
  37. w: 116213 v: 82175
  38. w: 187891 v: 132859
  39. w: 243331 v: 172061
  40. w: 393413 v: 278185
  41. w: 677339 v: 478951
  42. w: 1095109 v: 774359
  43. w: 1418237 v: 1002845
  44. w: 2292979 v: 1621381
  45. w: 3947821 v: 2791531
  46. w: 6382763 v: 4513295
  47. w: 8266091 v: 5845009
  48. w: 13364461 v: 9450101
  49.  
  50. Tue May 21 12:25:44 PDT 2019
  51.  
  52. w^2 - 2 v^2 = 119 = 7 17
  53.  
  54. jagy@phobeusjunior:~$
  55.  
  56. #include <iostream>
  57. #include <stdlib.h>
  58. #include <fstream>
  59. #include <strstream>
  60. #include <list>
  61. #include <set>
  62. #include <math.h>
  63. #include <iomanip>
  64. #include <string>
  65. #include <algorithm>
  66. #include <iterator>
  67. #include <time.h>
  68. #include <gmp.h>
  69. #include <gmpxx.h>
  70. #include "form.h"
  71.  
  72. using namespace std;
  73.  
  74. // g++ -o Pell_Target_Fundamental Pell_Target_Fundamental.cc -lgmp -lgmpxx
  75.  
  76.  
  77. // ./Pell_Target_Fundamental
  78.  
  79.  
  80. int main()
  81. {
  82.  
  83.  
  84. mpz_class target, d, t,s;
  85.  
  86. d = 2;
  87.  
  88.  
  89. t = 3 ;
  90. s = 2 ;
  91.  
  92.  
  93. cout << " Automorphism matrix: " << endl;
  94. cout << " " << t << " " << d * s << endl;
  95. cout << " " << s << " " << t << endl;
  96.  
  97.  
  98. cout << " Automorphism backwards: " << endl;
  99. cout << " " << t << " " << -d * s << endl;
  100. cout << " " << -s << " " << t << endl;
  101.  
  102. target = 119 ;
  103.  
  104. int time_limit_in_seconds = 31;
  105.  
  106. if ( t * t - d * s * s != 1 ) cout << " not 1 " << endl;
  107. else
  108. {
  109. cout << endl << " " << t << "^2 - " << d << " " << s << "^2 = " << t * t - d * s * s << endl ;
  110. cout << endl << " w^2 - " << d << " v^2 = " << target << " = " << mp_Factored(target) << endl << endl;
  111. system("date");
  112. cout << endl;
  113. int printcount = 0;
  114. for(mpz_class y = 0; printcount < 61 && clock() < time_limit_in_seconds * CLOCKS_PER_SEC && y <= 1000000000; y++){
  115. mpz_class n = target + d * y * y;
  116. if ( n > 0 && mp_SquareQ(n ) )
  117. {
  118. ++printcount;
  119. mpz_class x;
  120. x = mp_Sqrt( n);
  121.  
  122. cout << "w: " << x << " v: " << y ;
  123. if ( t * x - d * s * y <= 0 || -s * x + t * y <= 0)
  124. {
  125. cout << " SEED ";
  126. if ( target < 0 && x * s <= (t -1) * y ) cout << " KEEP +- ";
  127. else if ( target > 0 && x * s >= (t +1) * y ) cout << " KEEP +- ";
  128. else cout << " BACK ONE STEP " << t * x - d * s * y << " , " << -s * x + t * y ;
  129.  
  130. }
  131.  
  132.  
  133. cout << endl;
  134. } // square
  135.  
  136. } // for y
  137. cout << endl;
  138. system("date");
  139. cout << endl << " w^2 - " << d << " v^2 = " << target << " = " << mp_Factored(target) << endl << endl;
  140.  
  141. } // else 1
  142.  
  143.  
  144.  
  145. return 0 ;
  146. }
  147.  
  148. // g++ -o Pell_Target_Fundamental Pell_Target_Fundamental.cc -lgmp -lgmpxx
  149.  
  150.  
  151. // ./Pell_Target_Fundamental
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement