Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. a=10^6
  2.  
  3. While[a > 0,
  4.  
  5. y=(something complicated related with x and xfinal)
  6.  
  7. sol = FindRoot[RandomReal[] - (1 - Assuming[x > 0, Exp[y]^(-a)]) == 0, {x, 0,300}];
  8.  
  9. x1 = (x /. sol);
  10.  
  11. If[a1>0, x2=(something),x2=(something else)]
  12.  
  13. Which[x1 < x2, (a=a-1; a1=a1+1; xtrue=x1)
  14. ,x1 > x2, (a1=a1-1; xtrue=x2;)];
  15.  
  16. xfinal = xfinal + xtrue;
  17.  
  18. AppendTo[alist, {xfinal, a1*(a1 + a)}];
  19.  
  20. ];//AbsoluteTiming
  21.  
  22. SetDirectory[NotebookDirectory[]];
  23. Export["alist.dat",alist];
  24.  
  25. a=10^6
  26.  
  27. While[a > 0,
  28.  
  29. y=(something complicated related with x and xfinal)
  30.  
  31. sol = FindRoot[RandomReal[] - (1 - Assuming[x > 0, Exp[y]^(-a)]) == 0, {x, 0,300}];
  32.  
  33. x1 = (x /. sol);
  34.  
  35. If[a1>0, x2=(something),x2=(something else)]
  36.  
  37. Which[x1 < x2, (a=a-1; a1=a1+1; xtrue=x1)
  38. ,x1 > x2, (a1=a1-1; xtrue=x2;)];
  39.  
  40. xfinal = xfinal + xtrue;
  41.  
  42. alist = {alist, {xfinal, a1(a1+a)}};
  43.  
  44. ];//AbsoluteTiming
  45.  
  46. alist = Cases[alist, {__}, {-2}];//AbsoluteTiming
  47.  
  48. SetDirectory[NotebookDirectory[]];
  49. Export["alist.dat",alist];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement