I am struggling to solve an extension problem of smooth functions, and I would like someone to help me. The setting is as follows:

Let $X_1$, $X_2$, and $T$ be either the real lines $\mathbb R$ or the half lines $\mathbb R_+$. Suppose we have two smooth functions $f_1:X_1\times T\to\mathbb R$ and $f_2:X_2\times T\to\mathbb R$ which agree with each other on the common submanifold $0\times T$. Furthermore, we require $f_1$ and $f_2$ to be non-negative around the origin.

Problem: Find a smooth function $f:X_1\times X_2\times T\to\mathbb R$ which restricts to $f_1$ and $f_2$ on $X_1\times0\times T$ and $0\times X_2\times T$ respectively. In addition, can one require $f$ to be non-negative around the origin ?

Note that, without non-negative requirement, we have a naive extension $$f(x_1,x_2,t) = f_1(x_1,t) + f_2(x_2,t) - f_1(0,t).\tag{1}$$ This extension, however, fails to be non-negative in general. For example consider the functions $$f_1(x_1,t) = (x_1-t)^2,\ f_2(x_2,t) = (x_2-t)^2.\tag{2}$$ Then (1) is negative on the subspace $\{x_1=x_2=t\neq 0\}$. But, of course, we can take a "right" solution $$f(x_1,x_2,t)=(x_1+x_2-t)^2$$ so (2) is not a counterexample of the problem itself.

I do not know even whether the solution exists or not. Does anyone have ideas ?

Thank you.

**P.S.**I am also interested in higher dimensional cases; i.e. $X_1$, $X_2$, and $T$ are products of copies of $\mathbb R$ and $\mathbb R_+$.