In this case, as is usual, $\textbf{Z}$ represents the set of integers and $\textbf{Q}$ represents the set of rational numbers.  I'm meant to figure out if the bijection $f:\textbf{Z}\rightarrow\textbf{Q}$ exists and, while I know that this entails proving that it is both injective and surjective, I'm stuck with how to proceed.  I've been struggling with proving bijectivity for sets in general and what I'm looking for is a framework with which to work when it comes to these sorts of problems, as my attempts to research similar problems online haven't helped.  EDIT: While I do see other problems asking similar questions, the answers I read failed to show steps that proved both injectivity and surjectivity, which is how I would like to solve the question, if possible.
I remember my professor in college challenging me with this question, which I failed to answer satisfactorily: I know there exists a bijection between the rational numbers and the natural numbers, but can anyone produce an explicit formula for such a bijection?
Helpful flags not getting updated after getting 'close question' privilege Why does a passport have a place of birth field on it? Almost all passports I have seen have a place of birth field on them. For instance, on the US Passport,    Is there a specific reason to this? How do I include lines in resolv.conf that won't get lost on reboot? What is a good way to transform Cyclic Ordinal attributes? AWS S3, Paperclip missing required :bucket option Badge Notification Repeats Not sure if someone else has already raised this - I've got eleven notifications that I've received a Caucus badge on English Language Learners. Perhaps one notification for each community that I'm a member of?  I am a member of the community, and did visit the election. Also, the badge hasn't been awarded more that once (so I think it's just the notification that's at fault).  Note that this seems to happen for other badges, it has been reported for: Caucus, Nice Answer, Enthusiast. For a moderately complex query I am trying to optimize, I noticed that removing the TOP n clause changes the execution plan.  I would have guessed that when a query includes TOP n the database engine would run the query ignoring the the TOP clause, and then at the end just shrink that result set down to the n number of rows that was requested.  The graphical execution plan seems to indicate this is the case -- TOP is the "last" step.  But it appears there is more going on.  My question is, how (and why) does a TOP n clause impact the execution plan of a query?  Here is a simplified version of what is going on in my case:  The query is matching rows from two tables, A and B.    Without the TOP clause, the optimizer estimates there will be 19k rows from table A and 46k rows from table B.  The actual number of rows returned is 16k for A and 13k for B.  A hash match is used to join these two results sets for a total of 69 rows (then a sort is applied).  This query happens very quickly.  When I add TOP 1001 the optimizer does not use a hash match; instead it first sorts the results from table A (same estimate/actual of 19k/16k) and does a nested loop against table B.  The estimated number of rows for table B is now 1, and the strange thing is that the TOP n directly affects the estimated number of executions (index seek) against B -- it appears to always be 2n+1, or in my case 2003.  This estimate changes accordingly if I change TOP n.  Of course, since this is a nested join the actual number of executions is 16k (the number of rows from table A) and this slows down the query.  The actual scenario is a bit more complex but this captures the basic idea/behavior.  Both tables are searched using index seeks.  This is SQL Server 2008 R2 Enterprise edition. How to check if a number is a power of 2 Today I needed a simple algorithm for checking if a number is a power of 2.  The algorithm needs to be:   Simple Correct for any ulong value.   I came up with this simple algorithm:  private bool IsPowerOfTwo(ulong number) {     if (number == 0)         return false;      for (ulong power = 1; power &gt; 0; power = power &lt;&lt; 1)     {         // This for loop used shifting for powers of 2, meaning         // that the value will become 0 after the last shift         // (from binary 1000...0000 to 0000...0000) then, the 'for'         // loop will break out.          if (power == number)             return true;         if (power &gt; number)             return false;     }     return false; }   But then I thought, how about checking if log2 x is an exactly round number? But when I checked for 2^63+1, Math.Log returned exactly 63 because of rounding. So I checked if 2 to the power 63 is equal to the original number - and it is, because the calculation is done in doubles and not in exact numbers:  private bool IsPowerOfTwo_2(ulong number) {     double log = Math.Log(number, 2);     double pow = Math.Pow(2, Math.Round(log));     return pow == number; }   This returned true for the given wrong value: 9223372036854775809.  Is there a better algorithm? Who was flying the Y-Wing when the Death Star exploded? Near the end of Star Wars IV: A New Hope, we see four spacecraft flying from the Death Star just moments before it explodes.     As you can see, there is the Millennium Falcon crewed by Han and Chewbacca, a pair of X-Wings which has to be Luke and Wedge, and then in the bottom corner, we see a Y-Wing. Who is this pilot and did he have any screen time to justify him actually existing in this moment? For as far as I can tell during the first trench runs, they were conducted by the Y-Wings and all of them seemed to have been destroyed during their run. So as I asked, who is flying this ship and how did survive to this moment? Connecting two relative clauses in one sentence I would like to write an essay which gives information about the charts but because I am not native English speaker, when I started to write down my essay I came across the similar problems that I do sometimes.  Here my sentence:  Figure 1 and figure 2 show the percentage of people, WHOSE age is between 25-44 and over 65, WHO purchased concert, cinema and theater tickets online over the first three months of 2006 in three countries, WHICH are Australia, the UK, Malaysia.  Here is my questions:  1.How can I give the information of age and of what do people buy in one sentence?  2.Such vital and important information on the figures can be used as indefinite relative clause? Setting READ UNCOMMITTED when reading DMVs I've seen several people call SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED before reading system DMVs. Is there ever any reason to do this, assuming you aren't mixing calls to DMVs and tables in the same transaction? How to get my hover-menu back? I was trying to accomplish this through a trigger, but its not really working. Is there a way to get this done through Process Builder? If so, what is that process?  I'm trying to have ProductB being added to the opportunity automatically once ProductA is manually added to the opportunity.  Also, is there a way to have the $ amount of ProductB being 0.5% of ProductA?  Trigger that I have so far:  trigger Attempt1 on OpportunityLineItem (after insert) { List&lt;OpportunityLineItem&gt; oliList = new List&lt;OpportunityLineItem&gt;();  for( OpportunityLineItem item: [SELECT  OpportunityId,                                          Name                                  FROM    OpportunityLineItem                                 WHERE   Id = :Trigger.new AND                                          Name = 'NAME OF PRODUCTA'])  {   oliList.add(new OpportunityLineItem(     OpportunityId = item.OpportunityId,      PricebookEntryId ='01uA000000QPDldEAt',     Quantity = 1,     UnitPrice = 25)   );  }  Insert oliList; } Is this a valid partial fraction decomposition? Write $\dfrac{4x+1}{x^2 - x - 2}$ using partial fractions. $$ \frac{4x+1}{x^2 - x - 2} = \frac{4x+1}{(x+1)(x+2)} = \frac{A}{x+1} + \frac{B}{x-2} = \frac{A(x-2)+B(x+1)}{(x+1)(x-2)}$$ $$4x+1 = A(x-2)+B(x+1)$$ $$x=2 \Rightarrow 4 \cdot2 + 1 = A(0) + B(3) \Rightarrow B = 3$$ $$x = -1 \Rightarrow 4(-1) +1 = A(-3)+ B(0) \Rightarrow A = 1$$ Thus, $$\frac{4x+1}{x^2-x-2} = \frac{1}{x+1} + \frac{3}{x-2}\textrm{.}$$  The substitution of $x$ ($x = 2, -1$) is a common method to find out the coefficient of the partial fractions. However, the equation on the third line is obtained by multiplying $(x+1)(x-2)$, which is assumed to be nonzero. Here we have a contradiction. Furthermore, the original function is not defined at $x=-1,2$. How can we substitute these value for $x$? So is this method valid and rigorous? How to modify it so that it is rigorous? test fails because of TestMethod do not support getContent call My below test fails because of Run Failures: TestRangehoodObjectionSheet.RangehoodObjectionSheetTest Methods defined as TestMethod do not support getContent call. I added the Blob thinking it might resolve but it doesn't work. What could be the problem here? Have I used the Blob correctly?  @isTest public with sharing class TestRangehoodObjectionSheet {      static testMethod void RangehoodObjectionSheetTest() {             String Build                = NBATRecords.getIdFromDeveloperName('Plan_Reviews__c','Building_Plan_Review');             Account a = new Account(Name = 'Test1' ,Type = 'Lead Acct',BillingState = 'CA',Industry = 'Business Services');             insert a;              Establishment_Record__c er = new Establishment_Record__c(Account__c=a.Id ,Project_Name__c = 'TestPreet',PremiseStreet__c='Manhattan ave',PremiseBorough__c='Manhattan',PremiseState__c='NY',PremisePostalCode__c='11102',Referral_Source__c='311',Data_Source__c='CAMIS',Phase__c='Initiate',Business_Status__c='Open' );             insert er;              Application__c ap = new Application__c(Establishment_Record__c=er.Id,Job_Number__c='222222222');             insert ap;              Plan_Reviews__c pr = new Plan_Reviews__c(Application__c =ap.Id ,DOB_Job_Number__c='222222222',RecordTypeId =Build,Objections__c='Pipe size not indicated');             insert pr;             PageReference pageRef = Page.RangehoodObjectionSheet;              Test.setCurrentPage(pageRef);               Blob content = Test.isRunningTest() ? Blob.valueOf('UNIT.TEST') : pageRef.getContent();              Plan_Reviews__c              p   = new Plan_Reviews__c(id=pr.Id);                ApexPages.StandardController sc  = new ApexPages.standardController(p);             System.assertNotEquals(sc,null);             RangehoodObjectionExtention    ext = new RangehoodObjectionExtention(sc);              ext.Savecopy();       } }   Actual class for the test:  public with sharing class RangehoodObjectionExtention { private final ApexPages.StandardController controller; private final Id                           planreviewID; public String imageURL{get;set;} public List&lt;String&gt; objlist {get;set;}  public string currentdate {get; set;}    public RangehoodObjectionExtention (ApexPages.StandardController stdController) {         controller   = stdController;         planreviewID = (Id)controller.getRecord().get('Id');         Date dt = Date.today();         currentdate = dt.format();         list&lt;Plan_Reviews__c&gt; prlist = [select FDNY_Objections__c from Plan_Reviews__c where id = :planreviewID limit 1];         string obj;         for(Plan_Reviews__c pr: prlist){            obj = pr.FDNY_Objections__c;             }         if(obj!=null){            list&lt;string&gt; objections = obj.split(';');             integer i =1;            objlist = new list&lt;string&gt;();            for(string o : objections){               objlist.add(i++ +'. '+o);            }         }         imageURL='/servlet/servlet.FileDownload?file=';         List&lt; document &gt; documentList=[select name from document where Name='RangehoodObjectionLogo'];         if(documentList.size()&gt;0)         {            imageURL=imageURL+documentList[0].id;         }       }          public PageReference Savecopy(){       PageReference p = Page.RangehoodObjectionSheet;       blob b = ApexPages.currentPage().getContentAsPDF ();       Attachment a = new Attachment();       a.body = b;       a.name = 'Rangehood Objection sheet Issued '+currentdate+'.pdf';       a.parentid = planreviewID;        insert a;        PageReference pref = new PageReference('/'+planreviewID);       return pref;    } } Taking Seats on a Plane This is a neat little problem that I was discussing today with my lab group out at lunch. Not particularly difficult but interesting implications nonetheless  Imagine there are a 100 people in line to board a plane that seats 100. The first person in line realizes he lost his boarding pass so when he boards he decides to take a random seat instead. Every person that boards the plane after him will either take their "proper" seat, or if that seat is taken, a random seat instead.  Question: What is the probability that the last person that boards will end up in his/her proper seat.  Moreover, and this is the part I'm still pondering about. Can you think of a physical system that would follow this combinatorial statistics? Maybe a spin wave function in a crystal etc... Question for any programmer—and cat lover—working from his home office. So many times my keyboard is taken over violently by my two cats who think it’s the right place for a nap. And almost every time when they do this I’m was in this precious 100% concentration phases before I get interrupted.  I tried it with a burning an anti-mosquito coil under the desk but they got used to the smell pretty fast.  EDIT: And no I don’t want to keep the cats away completey from my room. Let's say I want a way to display just the the center 50x50px of an image that's 250x250px in HTML. How can I do that. Also, is there a way to do this for css:url() references?  I'm aware of clip in CSS, but that seems to only work when used with absolute positioning. Is it okay to publish my personal notes from a lecture? I have already had the same problem before. On that occasion, I found a program that could scan my entire hard drive for string pieces so I could recover it. Unfortunately I don't remember the name of the program. It had to access the hard drive data directly, normal searches won't get any data from the hard drive before formatting.