This should be a relatively simple problem but I'm looking for a clean definition for a random polynomial, $p$, that passes through the unit square. From suggestions from the comments, the order of the polynomial, $d$, can be whatever is needed and $p$ can be found by any means.
Now I've tried the obvious approach of just taking random points from the square and interpolating from them but sometimes, $p$ tends to jump out of the square.
Half of the time, it's fine and $p$ is within the bounds. The other half of the time, it isn't.
So how can I either mitigate this or redefine $p$ so that it fits these criteria?
Much obliged, Jam.




Depending on how "well-distributed" you want your polynomials to be, here's two simple things that seem worth trying:
1) Every Chebyshev polynomial maps $[-1,1]$ to itself, so taking an arbitrary convex combination of them will always stay within the square $[-1,-1]^2$, which you can easily rescale to fit inside the unit square. The basic Chebyshev polynomials have the nice property that they fit exactly inside the square, hitting the top and bottom edges a maximal number of times for their degree.
2) Bernstein polynomials should behave better than Lagrange interpolants in terms of boundedness over the entire interval. They will allow you to find a high-degree polynomial that stays within a bounded envelope of any given continuous curve that you draw in the square. I believe that by convexity they should stay within the unit square if the original curve is within the unit square; if not you could always rescale by a small amount.