I have two byte arrays with the exact same content. I tried:  if (bytearray1 == bytearray2) {...} else {...}   and  if (Array.Equals(bytearray1, bytearray2)) {....} else {...}   All time it goes to the else! I don't know why! I checked both arrays manually several times!!!
How can I do this fast?  Sure I can do this:  static bool ByteArrayCompare(byte[] a1, byte[] a2) {     if (a1.Length != a2.Length)         return false;      for (int i=0; i&lt;a1.Length; i++)         if (a1[i]!=a2[i])             return false;      return true; }   But I'm looking for either a  function or some highly optimized proven way to do this.  java.util.Arrays.equals((sbyte[])(Array)a1, (sbyte[])(Array)a2);   works nicely, but it doesn't look like that would work for x64.  Note my super-fast answer .
For what values of $\theta$ does $\sum_{1}^{\infty} \frac{e^{i n\theta}}{n}$ Converge? I just came across the problem of what happens in the boundary cases of .  More concisely, for what $\theta$ will the following sum converge? $$\sum_{n=1}^{\infty} \frac{e^{ni\theta}}{n}$$ It is well known that this sum will diverge for $\theta=0$ and will converge for $\theta=\pi$. In fact, for any odd multiple of an even root of unity, since we have symmetry, for each line through the origin of the complex plane, we can use the alternating series theorem to show that they converge.  Another idea I had was to split  the sum into imaginary and real parts, and if we can prove each of these converges, then we are all set. So now we must prove that both of the following converge $$\sum_{n=1}^{\infty}\frac{\cos(n\theta)}{n}\space, \space \sum_{n=1}^{\infty}\frac{\sin(n\theta)}{n}$$ Now these can be shown to converge easily by Dirichlet's test for any rational multiple of pi, but what about irrational multiples of pi? I know it has been shown to converge with $\theta=1$, but I don't see how to generalize this. How to list files in a zip without extra information in command line In my bash command line, when I use unzip -l test.zip I get the output like this:  Archive:  test.zip   Length      Date    Time    Name ---------  ---------- -----   ----    810000  05-07-2014 15:09   file1.txt    810000  05-07-2014 15:09   file2.txt    810000  05-07-2014 15:09   file3.txt ---------                     -------   2430000                     3 files   But I am interested only by the lines containing the file details.  I tried to make filtering using grep like this:   unzip -l test.zip | grep -v Length | grep -v "\-\-\-\-" | g -v Archive | grep -v " files"  But it is long and prone to error (e.g a file name Archive in this list will be dropped)  Is there any other options with unzip -l (I checked the unzip man page and did not find any) or another tool to do so?  It is important to me to not really unzip the archive but just to look what files are inside. Prove $GL_n(\Bbb{R})/SL_n(\Bbb{R}) \cong \Bbb{R}^\times$ $$GL_n(\Bbb{R})/SL_n(\Bbb{R}) \cong \Bbb{R}^\times$$  This is trivial to prove with the first isomorphism theorem - by using the determinant as a endomorphism, then as $SL_n(\Bbb{R})$ is $1$ under the determinant, it is the kernel, and by FIT, the above is proved.  I was wondering how to prove this without the isomorphism theorem ? Searching for an equation to find the center of a sphere given 4 points, one finds that taking the determinant of the four (non-coplanar) points together with the variables $x$, $y$, and $z$ arranged like so:  $\left|\begin{array}{ccccc} x^2+y^2+z^2 &amp; x &amp; y&amp;z&amp;1\\ x_1^2 + y_1^2 + z_1^2 &amp; x_1 &amp; y_1 &amp; z_1 &amp; 1\\ x_2^2 + y_2^2 + z_2^2 &amp; x_2 &amp; y_2 &amp; z_2 &amp; 1\\ x_3^2 + y_3^2 + z_3^2 &amp; x_3 &amp; y_3 &amp; z_3 &amp; 1\\ x_4^2 + y_4^2 + z_4^2 &amp; x_4 &amp; y_4 &amp; z_4 &amp; 1\\ \end{array}\right| = 0$   yields the equation for the sphere.  Then one need only re-arrange terms into the more familiar form to find the center and radius.  This works fine.  My question is why.    This same approach also works for one or two dimensions.  I'm guessing it also works for finding hyperspheres in higher-dimensional spaces as long as you have a corresponding number of points.  But where did that determinant form come from?  Is there an intuitive meaning for what that relationship is saying? Unicode Regex; Invalid XML characters The list of valid XML characters is well known, as defined by the spec it's:  #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]   My question is whether or not it's possible to make a PCRE regular expression for this (or its inverse) without actually hard-coding the codepoints, by using Unicode general categories. An inverse might be something like [\p{Cc}\p{Cs}\p{Cn}], except that improperly covers linefeeds and tabs and misses some other invalid characters. How do I join two lists in Java? A theorem about Cesàro mean, related to Stolz-Cesàro theorem Original Title: Tauberian theorems and Cesàro sum  Theorem (Landau-Hardy, From Rudin's Principle of Mathematical Analysis Exercise 3.14)  $\newcommand\abs[1]{\left\lvert#1\right\rvert}$ If $\{s_n\}$ is a complex sequence, define its arithmetic means $\sigma_n$ by $$\sigma_n=\frac{s_0+s_1+\dotsb+s_n}{n+1}\qquad(n=0,1,2,\dotsc)$$ Put $a_n=s_n-s_{n-1}$ for $n\ge1$. Assume $M&lt;+\infty$ and $\abs{na_n}\le M$ for all $n$, and $\lim_{n\to\infty}\sigma_n=\sigma$, then $\lim_{n\to\infty}s_n=\sigma$.  The outline of the proof  If $m&lt;n$, then $$s_n-\sigma_n=\frac{m+1}{n-m}(\sigma_n-\sigma_m)+\frac1{n-m}\sum_{k=m+1}^n(s_n-s_k)\tag{*}$$ Notice that $\abs{s_n-s_k}\le(n-m-1)M\,/\,(m+2)$, fix $\epsilon&gt;0$ and associate with each $n$ the integer $m$ that satisfies $$m\le\frac{n-\epsilon}{1+\epsilon}&lt;m+1$$ Then $(m+1)\,/\,(n-m)\le1/\epsilon$ and $\abs{s_n-s_k}&lt;M\epsilon$. Hence $$\limsup_{n\to\infty}\,\abs{s_n-\sigma}\le M\epsilon$$  Questions and thoughts  It seems that the equation (*) comes out strangely. I wonder how to discover such kind of strange identities. So is there any observation, even deeper, to look through that equation?  Thanks! If a student needs a reference letter for graduate admissions or that sort of thing, some profs will ask the student to write a reference letter for themself before sending it off to the prof for minor edits and finalization. This seems to be a somewhat common practice given that some graduate schools ask for several letters of recommendation even when it is not reasonable for the student to have developed deep connections with that many professors, and that most professors are just too busy to write quality letters for all the students that ask them to.  Is it acceptable to write most of the reference letter and have the prof make minor edits? Do academic institutions frown upon this practice? Would it be considered an academic offense if a student wrote a reference letter for themselves and had a prof sign it? Disable the default app key (super+num) functionality on Ubuntu 17.10 and later I like to switch workspaces via Super+Number. But unfortunately the default behavior in Ubuntu for Super+Number is to select applications from the dock.   Is it possible to disable that functionality? I've tried overriding the keyboard shortcuts but it doesn't appear to be working. I am trying to proof the following algorithm to see if a there exists a path from u to v in a graph G = (V,E).   Reach := {u} LastCardinality := 0 while LastCardinality &lt; |Reach| do   LastCardinality := |Reach|   Next := null   foreach i &lt;- Reach do     foreach j &lt;- V do       if(i,j) exists in E then         Next := Next + {j}   Reach := Reach + Next return Reach   So far I have got that the output needs to be Reach = Goal where Goal = {r | r exists V, there is a path from u to r}. I also have three invariants that I am pretty sure will help prove this.   Reach is always a subset of Goal and Next is always a subset of Goal. After an arbitrary K times through the while loop, for every t that exsits in V, if t has a path of length k+1 from u, then t exists in Reach If Reach is a subset of Goal before the while loop then LastCardinality &lt; |Reach|   I know that to finish up the proof, I need to prove termination, the invariants, and correctness but I have no idea how. I think I need to use induction on the while loop but I am not exactly sure how.   How do I proof those three characteristics about an algorithm? How can phone companies detect tethering (incl. Wifi hotspot) $x^2-y^2=2s$, s cannot be an odd integer How can we prove that if $x^2-y^2=2s$ holds, s cannot be an odd integer. What theorem in number theory should we use? As stated above, I can't connect to my home wi-fi with natty but can with Windows 7. The strange thing is I that I have gotten it to connect to other password protected networks with natty, it's just mine that it dosn't like.   I am using a WPA2 pass-code with AES Encryption and all other devises work fine on my network. Laptop used is a Dell Latitude D430. Why should users never use normal sudo to start graphical applications? I've read  and am interested in this line:     You should never use normal sudo to start graphical applications as Root.   Why? What is the difference? Please provide a simple explanation, as I'm just a normal desktop user. In CSS what is the difference between "." and "#" when declaring a set of styles? What is the difference between # and . when declaring a set of styles for an element and what are the semantics that come into play when deciding which one to use? Can the Hubble constant be measured locally? "Agree" vs. "concur" Why did the Tethered form a line in Us? In Jordan Peele's  we see that the Tethered plan a revolt, rise above ground and start murdering everyone in sight and then they form a line by holding hand in hand.   What was the purpose of that? How do I distinguish between a command, utility, or builtin for getting documentation? Where should looking-for-resources questions go?