Jump to content

Wikipedia:Reference desk/Archives/Mathematics/2014 May 28

From Wikipedia, the free encyclopedia
Mathematics desk
< May 27 << Apr | May | Jun >> Current desk >
Welcome to the Wikipedia Mathematics Reference Desk Archives
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


May 28

[edit]

Smooth approximation of a hypercube

[edit]

I'm working on an optimization problem where the solution must fall on the unit hypercube. Is there a simple smooth approximation to this constraint? It must be differentiable, and being twice differentiable would give me more flexibility in solving the problem. The simplest solution I can think of is to use a sphere, then project it to the nearest face and use gradient descent along that face to fine-tune the result. However, if there is a reasonably simple approximation that is more cube-shaped it may get me a good enough result faster because it doesn't cut off the corners of the cube as much. Katie R (talk) 12:20, 28 May 2014 (UTC)[reply]

You could use a -norm for large . The unit sphere is . If you change that to , you'll get a better approximation to the hypercube as increases; indeed, the limit is the unit hypercube.--80.109.80.78 (talk) 12:35, 28 May 2014 (UTC)[reply]
[ec] approximates the surface of the cube . With higher the approximation is better but it's less smooth. -- Meni Rosenfeld (talk) 12:37, 28 May 2014 (UTC)[reply]
Thanks! That sounds perfect - quick to evaluate, simple derivatives, and it will be easy to work with analytically when I start working on analyzing the convergence of the algorithm. Katie R (talk) 13:08, 28 May 2014 (UTC)[reply]
You will have to restrict α to even integers to keep it analytic. —Quondum 17:20, 28 May 2014 (UTC)[reply]

The points on the surface of the unit hypercube satify the equation

The points on the surface of the unit hypersphere satify the equation

So the equation

is a hypercube for p=0 and a hypersphere for p=1, and for 0<p<1 it is a surface in between. Bo Jacoby (talk) 22:17, 28 May 2014 (UTC).[reply]

That's not correct. There are many more points satisfying the first equation than just the surface of the hypercube. It seems to me the last equation is only satisfied by or . -- Meni Rosenfeld (talk) 22:35, 28 May 2014 (UTC)[reply]
Right - as long as one element has an absolute value of 1, the others are unbounded and can fall anywhere on the plane that face defines. I'm very happy with the unit ball in a p-norm solution. It's very simple, and so are the Jacobian and Hessian, which is important because I may need to evaluate it several thousand times a second. It's also convex which makes it useful for global optimization. Katie R (talk) 02:31, 29 May 2014 (UTC)[reply]

We agree that the points on the surface of the unit hypersphere do satify the equation (for p=0) and that inside points do not. It is not a problem that some outside points do. Choose 0≤x22≤1 , . . . , 0≤xn2≤1 and compute x12 from the linear equation.

It is simpler than the p-norm solution for p>n. Bo Jacoby (talk) 05:35, 29 May 2014 (UTC).[reply]

It does matter that points outside the cube satisfy the equation, when you're trying to create a new equation with a convex combination of the two equations. Did you actually try to plot your last equation? I did in the 2D case and got gibberish. And as I said, it is only satisfied for or (fixed above) when . -- Meni Rosenfeld (talk) 11:41, 29 May 2014 (UTC)[reply]

Yes I did actually plot my last equation by this J program:

  'dot; pensize 4' plot(,j.)(,-)(,+)j./%:(,:-.%[:-.0.9&*)?100#0

Explanation: (?100#0) creates 100 random numbers 0≤x2≤1. (,:-.%[:-.0.9&*) appends the corresponding y2 values for p=0.1. (-.x) is 1-x. (%) is division. (%:) is square root. (j./x,:y) creates x+iy. (,+) appends x-iy. (,-) appends -(x+iy). (,j.) appends i(x+iy). The program displays 800 dots showing a square with round corners.

Probably you committed an elementary error. Bo Jacoby (talk) 22:10, 29 May 2014 (UTC).[reply]

Ok, one issue is that in your original comment you had a sign error. This was corrected in your second comment and gives a more reasonable shape. However, the point remains that there are also points outside the cube that satisfy the equation. -- Meni Rosenfeld (talk) 09:11, 30 May 2014 (UTC)[reply]
The equi-p-norm shape is called a superellipse or superellipsoid by the way (or more specifically, a squircle). --catslash (talk) 12:39, 30 May 2014 (UTC)[reply]
Looks like squircle is the special case where p=4. Too bad, because I was hoping my high-dimensional version could be called a squircloid. :-P Katie R (talk) 15:54, 30 May 2014 (UTC)[reply]

Using only one branch of, say, a hyperbola is not prohibited. It is interesting how reluctance prevented Meni Rosenfeld from catching the idea. Bo Jacoby (talk) 11:32, 1 June 2014 (UTC).[reply]

Prohibited for whom? The OP has a specific application. If he tries your equation to test for his required condition, he may end up with false positives. How much of a problem it really is depends on the application. -- Meni Rosenfeld (talk) 20:20, 1 June 2014 (UTC)[reply]
My application is to use the function as a constraint that is a good approximation to a hypercube. Using an approximation that requires a hypercube constraint doesn't get me anywhere. Katie R (talk) 12:17, 2 June 2014 (UTC)[reply]

The OP gets a parametized family of hyper-surfaces. p=0 gives a hyper-sphere. p=1 gives a hyper-cube. Values in between give hyper-surfaces in between. The hyper-surfaces are infinitely differentiable for p<1. The hyper-surfaces are algebraic of order 4. The solution is straight-forward and not dangerous at all. Bo Jacoby (talk) 21:25, 2 June 2014 (UTC).[reply]

Algebra brain-fade.

[edit]

I'm having trouble with a bit of algebra:

If:

 A = B x
 x = ???

(B is in the range 0..1 and x>1 if that helps at all). 65.111.112.94 (talk) 20:54, 28 May 2014 (UTC)[reply]

. See Logarithm. -- Meni Rosenfeld (talk) 21:13, 28 May 2014 (UTC)[reply]
Logarithm turns multiplications into additions and exponential into multiplications.
So
A = B x
becomes
Log(A) = Log(B x )
Log(A) = Log(B) * x
So you can easily solve for x. 202.177.218.59 (talk) 01:05, 30 May 2014 (UTC)[reply]