# Finding a 2-dimensional smooth function

I am designing an autonomous agent whose behaviour depends on a function of two variables, say $f(x,y)$. The variables $x$, $y$ and $f$ are all in $[0,1]$, and I know that:

$$f(0,y)=f(x,0)=0$$ $$f(1,y)=f(x,1)=1$$

(The values $f(0,1)$ and $f(1,0)$ are not defined).

I am looking for $f$ that is smooth in $(0,1)\times(0,1)$.

After some playing around, I found the following function:

$$f(x,y)=\frac{(x+y)-|x-y|}{2-2|x-y|}$$

If am not mistaken, this function is continuous in $(0,1)\times(0,1)$, but it is not smooth because of the absolute-value function.

My questions are:

• Are there smooth functions that satisfy the above conditions?
• Is there a more systematic way to find such functions, other than just guessing and checking?

To answer your general question, there is a way to find such functions without just guessing and checking...sort of. One way is to say "I'd like to find a function that satisfies some differential equation, like Laplace's equation, on the interior of this square, but takes on these values on the boundary." That's a classic problem in heat-transfer, electrostatics, and many other fields, and is much studied.

One of the great ways to solve such a problem is to find a map from your domain to some other domain, solve the problem there, and then map back. If your map happens to be complex-analytic (the complex variables analog of "differentiable"), then it will carry solutions of Laplace's equation from one domain back to the other.

So if we can find a map that takes two sides of your square to the $v = 0$ line in the $u+ i v$ plane, and the other two side to the $v = 1$ line, then transforming the function "$v$" back to your square will give a solution.

The only problem is that building the analytic transform from your problem to an easier problem is not always easy. On the good side, many smart people have catalogued a bunch of approaches -- search for "conformal mapping" to get an idea of how they're done.

I don't have my complex variables book handy here, so I can't find a good map doing what I suggested for the square, but perhaps I can look it up tomorrow. If you look in Churchill's Complex Analysis, solving problems like this is in one of the last sections of the book.

There's one more approach: Letting $C$ denote the contour that's the boundary of the square, you can define $$f(z) = \int_C \frac{h(u)}{z-u} du$$ where $h$ is your function (the $+1/0$ function you described). (Warning: I might be off by a minus-sign, or have simply mis-remembered the formula entirely!). The function $f$ will then be a solution of Laplace's equation subject to the given boundary conditions. It's just possible that the integral I've written down is evaluatable by mere mortals, which gives you a solution.

$$f(x,y) ~:=~ \frac{xy}{xy+ (1-x)(1-y)}.$$