Why does the graph of $-\left(x\right)\log_{2}\left(x\right)-\left(1-x\right)\log_{2}\left(1-x\right)$ look like: $\cap$?

48 Views Asked by At

I can understand it algebraically, but I wanted some geometric-esq intuition for why the graph is this way. Like some intuition that I could've used to derive it.

This is the plot:

I eked out some explanation for what's happening (not sure how correct it is):

A log:

enter image description here

We want it to swoop back in to zero instead of going to -infinity though. So, we weight it by $x$ (which gets smaller as it goes to $- \infty$

enter image description here

Flip it

enter image description here

Now copy it, flip horizontally, and push it to 1 (since we want the graph to be from 0 to 1).

enter image description here

My brain is happy with everything above, what it isn't happy with is that when I add both of them together: the part in the middle gets added as expected but the parts at the ends just go away? What witchcraft is this?

enter image description here

1

There are 1 best solutions below

3
On BEST ANSWER

You can add them only in the part where they are both defined. The red function is not defined for $x<0$ and the blue one is not defined for $x>1$, so the common domain is $[0,1]$.

By the way, this is a rather interesting functions called the Binary entropy function.
It has many important properties, and defines the entropy (uncertainty) of a coin flip with $\mathbb{P}(\text{coin falls on head})=x$.