2

I have to solve tasks computationally, where integrations increasingly play a role. This practically addressed question aims later at a general approach. However, I would first like to understand the procedure with the following concrete example.

I have two derivatives:

  • $\frac{d}{dx}=(1-2x^2)\cdot e^{-x^2-y^2}$ and
  • $\frac{d}{dy}=-2xy\cdot e^{-x^2-y^2}$

How can I arrive back to the original function $x\cdot e^{-x^2-y^2}$? I checked related posts, for example "From partial derivatives to original function", but cannot easily transfer the procedure.

While the example given here seems doable, there are certainly cases where it is not. Are there methods such for example numerical ones to solve those difficult cases even approximately? For some directions keywords or methods I have to search for, I would be already greatful.

Background:

When I for example integrate $e^{-x*y}$ numerically, I can obtain via the following algorithm the figure below:

arr_x = np.arange(-0.5,0.5,0.01)
arr_y = np.arange(-0.5,0.5,0.01)
X,Y = np.meshgrid(arr_x, arr_y)
Z = np.empty([arr_x.size, arr_y.size])
Z[:] = np.nan
f = lambda y, x: np.exp(-x*y)

def integrand(x, y): m = integrate.dblquad(f, -np.inf, x, lambda x: -np.inf, lambda x: y) return m[0]

for idx_x, x in enumerate(arr_x): if x < 0: for idx_y, y in enumerate(arr_y): if y < 0: Z[idx_x][idx_y] = integrand(x, y)

fig = plt.figure(figsize=(14,10)) ax1 = fig.add_subplot(111, projection='3d') surf1 = ax1.plot_surface(X, Y, Z) plt.show

enter image description here

This plot seems to be correct when checking it with Wolfram Alpha. But this case is an easier one, since my starting point for integration were not two partial derivatives. Is it possible to transfer this numerical procedure to the case having two PDEs?

Eldar Sultanow
  • 1,678
  • 7
  • 19
  • Can you suggest the scope of equations you are considering? What do you consider a difficult example? – Rollen S. D'Souza Jan 02 '22 at 00:59
  • A difficult example would be those functions, whose integral has no closed form or here the closed form is not known. This function in the question here might be considered as a difficult one, althought starting point are not two PDEs. Thank you by the way for your answer. – Eldar Sultanow Jan 02 '22 at 07:54
  • May I recommend looking at https://sfepy.org/doc-devel/index.html . Python finite element package. – BadAtMath Jan 03 '22 at 02:01
  • Thank you for this hint. Will definitively try it. – Eldar Sultanow Jan 03 '22 at 06:46

1 Answers1

1

The notation I'll use is $x = (x^1, \ldots, x^n)$ and $y = (y^1, \ldots, y^n).$ Suppose we are given a system,

$$\frac{\partial f}{\partial x^1} = g_1(x),\quad\ldots,\quad\frac{\partial f}{\partial x^n} = g_n(x)$$

of $n$ decoupled partial differential equations defined on some open rectangle[1] containing some point $x_0 \in \mathbb{R}^n.$ All this means is that there are no singularities inside the rectangle. The problem of finding $f$ amounts to asking whether there exists a smooth function $f$ whose differential satisfies,

$$df = g_1(x)\,dx^1 + \cdots + g_n(x)\,dx^n.$$

Viewing this object as a smooth one-form, a necessary and sufficient condition for this to be integrated to construct $f$ is that the exterior derivative vanishes identically on the open rectangle (see the Poincaré Lemma). That is,

$$0 = dg_1 \wedge dx^1 + \cdots + dg_n \wedge dx^n.$$

I will not expand this out completely in the general case (it is not anymore enlightening), but I will show what happens in the 2 variable case. If this condition holds, you can perform a line integral to compute $f.$ That is, for any fixed point $y$ the value of $f$ at $y$ is given by,

$$f(y) = f(x_0) + \int_{x_0}^{y} g_1(x)\,dx^1 + \cdots + g_n(x)\,dx^n,$$

where any path can be taken for the integral as long as it stays within the open rectangle where the condition is satisfied. Note, that if the conditions do not hold, there is no such $f$ that solves the equations.

Two Variable Example

Consider the smooth one-form

$$\omega = g_1(x^1, x^2)\,dx^1 + g_2(x^1, x^2)\,dx^2,$$

describing the PDE

$$\frac{\partial f}{\partial x^1} = g_1(x^1, x^2),\quad\frac{\partial f}{\partial x^2} = g_2(x^1, x^2),$$

over some open rectangle containing $x_0.$ For some intuition, you should see that this is equivalent to asking that the mixed partial derivatives of the function $f,$ if it exists, should be equal independent of the order they are taken.

The exterior derivative of $\omega$ is,

$$d\omega = \left[\frac{\partial g_2}{\partial x^1} - \frac{\partial g_1}{\partial x^2}\right] \,dx^1\wedge dx^2.$$

We need $d\omega = 0$ on an open rectangle containing $x_0,$ so we need

$$\frac{\partial g_2}{\partial x^1} = \frac{\partial g_1}{\partial x^2}$$

on that open rectangle. We can verify that your example does satisfy this. Let us check this. Let

$$g_1(x) = (1 - 2\,(x^1)^2)\,\exp(-((x^1)^2 + (x^2)^2)),\quad g_2(x) = -2\,x^1\,x^2\,\exp(-((x^1)^2 + (x^2)^2)).$$

The required partial derivatives are,

$$\begin{aligned}\frac{\partial g_1}{\partial x^2} &= -2\,x^2\,(1 - 2\,(x^1)^2)\,\exp(-((x^1)^2 + (x^2)^2)),\\ \frac{\partial g_2}{\partial x^1} &= -2\,x^2\,\exp(-((x^1)^2 + (x^2)^2)) + 4\,(x^1)^2\,x^2\,\exp(-((x^1)^2 + (x^2)^2)).\end{aligned}$$

Clearly $\frac{\partial g_1}{\partial x^2} - \frac{\partial g_2}{\partial x^1} = 0.$ As a result, we can directly compute the smooth function $f$ whose differential is $\omega.$ Explicitly, the value of $f$ at some arbitrary point $y$ in an open rectangle containing $x_0$ is,

$$f(y) = f(x_0) + \int_{x_0}^{y} (1 - 2\,(x^1)^2)\,\exp(-((x^1)^2 + (x^2)^2))\,dx^1 -2\,x^1\,x^2\,\exp(-((x^1)^2 + (x^2)^2))\,dx^2,$$

where $f(x_0) \in \mathbb{R}$ is an arbitrary initial value. For this integral, we can take any path from $x_0$ to $y$ that stays within the open rectangle where the condition is satisfied. As a result, let us consider taking the easiest path: first travel from $(x_0^1, x_0^2)$ to $(y^1, x_0^2)$ and then to $(y^1, y^2).$ The notation is a bit confusing here, but I mean perform a line integral in the $x^1$ direction and then along the $x^2$ direction. This becomes,

$$f(x) = f(x_0) + \left(\int_{x_0^1}^{y^1} (1 - 2\,(x^1)^2)\,\exp(-((x^1)^2 + (x_0^2)^2))\,dx^1\right) + \left(\int_{x_0^2}^{y^2} -2\,y^1\,x^2\,\exp(-((y^1)^2 + (x^2)^2))\,dx^2\right).$$

Note how the $x^2$ value is fixed in the first integral with the initial position's second coordinate $x_0^2$ while the $x^1$ value is fixed in the second integral with the final position's first coordinate $y^1.$ This is because of the order of the line integral I have decided to take. This method can be done both analytically (where tractable) and numerically as you did.

In this case, we can solve the problem analytically. Let us fix $x_0 = (0,0)$ with initial value of $f(x_0) = 0.$ Factor out the constants,

$$f(y) = f(x_0) + \exp(-(x_0^2)^2)\,\left(\int_{x_0^1}^{y^1} (1 - 2\,(x^1)^2)\,\exp(-(x^1)^2)\,dx^1\right) + y^1\,\exp(-(y^1)^2)\,\left(\int_{x_0^2}^{y^2} -2\,x^2\,\exp(-(x^2)^2)\,dx^2\right).$$

Now we have fairly easy single-variable integrals, so proceed with the integration,

$$f(y) = f(x_0) + \exp(-(x_0^2)^2)\,\left[x^1\,\exp(-(x^1)^2)\right]_{x_0^1}^{y^1} + y^1\,\exp(-(y^1)^2)\,\left[\exp(-(x^2)^2)\right]_{x_0^2}^{y^2}.$$

Substitute our values for $x_0$ and $f(x_0)$ to find,

$$f(y) = \left[x^1\,\exp(-(x^1)^2)\right]_{0}^{y^1} + y^1\,\exp(-(y^1)^2)\,\left[\exp(-(x^2)^2)\right]_{0}^{y^2}.$$

Simplify and find,

$$f(y) = y^1\,\exp(-(y^1)^2) + y^1\,\exp(-(y^1)^2)\left(\exp(-(y^2)^2) - 1\right) = y^1 \,\exp(-(y^1)^2 - (y^2)^2),$$

as required.

[1]: Any open, convex set works.