How do you know your public key from a private key? In my understanding, when you create a public-private key pair, first, you create a pair of complementary keys by using cryptographic software. Then you give one key the name public key, and give the other key the name private key.  You keep the private key for yourself and give your public key to everyone else.

Then I was reading Mastering Bitcoin, I found this sentence:


  Paper wallets are bitcoin private keys printed on paper. Often the
  paper wallet also includes the corresponding bitcoin address for
  convenience, but this is not necessary because it can be derived from
  the private key.


I don’t understand how it is possible to derive the corresponding bitcoin address(the hash of a public key) from the private key. 

If the public key can really be derived from the private key, isn’t the opposite true? I mean, we can choose whichever is the private key when we generate them.
If the public key can really be derived from the private key, isn’t the opposite true?

Nope, thats the wonder of asymmetric key cryptography! You can easily derive the public key from the private key, but going the opposite direction is equivalent to brute-force guessing you way through an impossibly large set of numbers (ie, impossible). So the public key and private key are mathematically related, but this relationship is &quot;one-way&quot;, so to speak. This is why you can share your public key with other people, but you should never, ever share the private key!
Once someone has a private key, they can use it to derive the public key and bitcoin address easily. But having a public key gives them no knowledge of the private key, since the math doesn't work the same both ways.
In bitcoin, the public key is derived using the Elliptic Curve Digital Signature Algorithm (ECDSA).

Then you give one key the name public key, and give the other key the name private key
...
I mean, we can choose whichever is the private key when we generate them.

I think this is where your misunderstanding comes from, the distinction of 'public' or 'private' is not arbitrarily chosen. One is derived from the other, their relationship is mathematically defined.