When I say the word convex maybe flashbacks of high school Physics class come to mind with convex and concave mirrors. Even if you don’t remember it here is a visual (on the left) to help jog the memory.

Now rather talking about how the physics work for a convex mirror I’m going to be talking about what convexity is itself and the properties that define a convex set. The way we will try and show this is by building a scene. Also, keep in mind that a concave set is simply the negative of a convex set so I will be just using the term convex.

I first created this Desmos scene ( <-- this is a link) and realized later that I could make an article with it.

1). Lets lay out the scene

Image for post

This scene will live on the 2d space but these concepts can apply to any nth dimension. This means that any point we pick on this space which we call the set ℝ² will look in the form (x,y). If we were to be in ℝ³ a point would look something like (x,y,z).

We are going to plot the function f(x) >x² and g(x) <-x² + 1. This is our exponential function and another one but multiplied by a negative (flipped) and translated (shifted over) but for the sake of this conversation we won’t be taking a look at the functions themselves but a set that they will be bounding _(ie the white space) _them by.

We will call the white space the set W (for white) since we can see that W is on the ℝ² plane we can say that W is a subset of ℝ².

Image for post

Now, let’s pick two points, let’s call them a and b. a and b are elements of W meaning that they will be inside the white space.

Now that we have these two points inside this white space we can make a line between them. (Like in the image)

Now we have set up the scene now we can move on to the actual definition of what a convex set is.

2). The definition of convex

Image for post

Pick any two points a and b such that they are elements of W then any point in between a and b _(ie the line) _is also contained in the set W. We can show this concisely that by saying any point

𝜃a + (1-𝜃)b 𝜀 W for 0 ≤ 𝜃 ≤ 1.

You can see what that looks like, on the left, the ball on the line is that point.

When 𝜃 = 1 we can see that the ball sits on point a.

And when 𝜃 = 0 the ball sits on point b.

That is it, that’s all it takes for a set to be convex but this concept of convexity has multiple subfields devoted to it like Convex Analysis and Convex Optimization to name two.

Now I’m sure you can visualize in your head what this looks like in a 3d space or on the set ℝ³. But this idea also applies to ℝ⁴ and beyond as well.

3). Non-convex set

Before I go it would feel wrong to not also show a non-convex set as it helps to be able to see when a set is not convex as well.

Image for post

lets look at the function

g(x) <-x² + 1 and

h(x) > 5x⁴ +x³ -x²-.5x+.5

We can see if we place the dots on the bottom right and bottom left the line goes through the black space which makes the set in that white space not convex.

Closing Comments

Hope you enjoyed learning about what a convex set is if you want to learn more about these kinds of concepts checkout Stephen Boyd’s book Convex Optimization, that’s where I learned these things myself.

#data-science #machine-learning #visualization #math #mathematics #visual studio code

Visualizing Convex Sets
1.45 GEEK