Evidently, finding a high precision approximation of the singularity curve

${\Gamma}^{*}$ is more involved than finding a high precision approximation to the singularity point

${s}^{*}$ in the univariate case. Let

${D}_{{\Gamma}^{*}}(x,y)$ be the signed-distance function corresponding to the curve

${\Gamma}^{*}$:

For a given

${D}_{\overline{b}}$ we define the approximation to

f similar to the construction in the univariate case by Equations (

7)–(

9). We look here for an approximation

S to

f which is a combination of two bivariate splines components:

such that

${(2M+1)}^{2}$ Fourier coefficients of

f and

S are matched in the least-squares sense:

We denote by

${B}_{1ij}(x,y)$ the restriction of

${B}_{d}^{[k]}(x-id){B}^{[k]}(y-jd)$ to the domain defined by

${D}_{\overline{b}}(x,y)\ge 0$, and by

${B}_{2ij}(x,y)$ the restriction of

${B}_{d}^{[k]}(x-id){B}^{[k]}(y-jd)$ to the domain defined by

${D}_{\overline{b}}(x,y)<0$. We concatenate these two sequences of basis functions,

$\left\{{B}_{1ij}\right\}$ and

$\left\{{B}_{2ij}\right\}$ into one sequence

${\left\{{B}_{ij}\right\}}_{i=1,j=1}^{{N}_{d},2{N}_{d}}$, denoting their Fourier coefficients by

${\left\{{\widehat{B}}_{ij,n}\right\}}_{n\in \mathbb{Z}}$, and rearranging them (for each

n) in vectors of length

$2{N}_{d}^{2}$,

${\left\{{\widehat{B}}_{i,n}\right\}}_{i=1,n\in \mathbb{Z}}^{2{N}_{d}^{2}}$. For a given

${D}_{\overline{\widehat{}}b}$, the normal equations for the least squares problem (

21) induce the linear system

$Aa=b$ for the splines’ coefficients

$a=({\left\{{a}_{1ij}\right\}}_{i,j=1}^{{N}_{d}},{\left\{{a}_{2ij}\right\}}_{i,j=1}^{{N}_{d}})$, where:

and

For a given choice of

$\overline{b}=\left\{{b}_{ij}\right\}$, the coefficients

${\left\{{a}_{1ij}\right\}}_{i,j=1}^{{N}_{d}},{\left\{{a}_{2ij}\right\}}_{i,j=1}^{{N}_{d}}$ are obtained by solving a linear system of equations, and properly rearranging the solution. However, finding the optimal

$\overline{b}$ is a non-linear problem that requires an iterative process and is much more expensive.

**Remark** **3.** Representing the singularity curve of the approximation S as the zero level set of the bivariate spline function ${D}_{\overline{b}}$ is the way to achieve a smooth control over the approximation. As a result, the objective function in (21) varies smoothly with respect to the spline coefficients $\left\{{b}_{ij}\right\}$. **Remark** **4.** In principle, the above framework is applicable to cases where f is combined of k functions defined on k disjoint subdomains of ${[0,1]}^{2}$. The implementation, however, is more involved. The main challenge is to find a good first approximation to the curves separating the subdomains. In this context, for our case of two subdomains, we further assume for simplicity that the separating curve ${\Gamma}^{*}$ is bijective.

Here again we choose to demonstrate the whole approximation procedure alongside a specific numerical example.

#### 3.2.1. The Approximation Procedure—A Numerical Example

Consider a piecewise smooth function on

${[0,1]}^{2}$ with a jump singularity across the curve

${\Gamma}^{*}$ which is the quarter circle defined by

${x}^{2}+{y}^{2}=0.5$. The test function is shown in

Figure 11 and is defined as

In the univariate case, in

Section 2.2.1, we use the Gibbs phenomenon in order to find an initial approximation

${s}_{0}$ to the singularity location

${s}^{*}$. The same idea, with some modifications to the 2D case, is applied here. The truncated Fourier sum

gives an approximation to

f, but the approximation suffers from a Gibbs phenomenon near the boundaries of the domain and near the singularity curve

${\Gamma}^{*}$. We evaluated

${f}_{50}$ on a

$400\times 400$ mesh on

${[0,1]}^{2}$, and enhanced the Gibbs effect by applying first order differences along the

x-direction. The results are depicted in

Figure 12. The locations of large

x-direction differences and of large

y-direction differences within

${[0,1]}^{2}$ indicate the location of

${\Gamma}^{*}$.

**Building the initial approximation ${D}_{{\overline{b}}_{0}}$**

Searching along 50 horizontal lines (

x-direction) for maximal

x-direction differences, and along 50 vertical lines (

y-direction) for maximal

y direction differences, we have found 72 such maximum points, which we denote by

${P}_{0}$. We display these points (in red) in

Figure 13, on top of the curve

${\Gamma}^{*}$ (in blue). Now we use these points to construct the spline

${D}_{{\overline{b}}_{0}}$, whose zero level curve is taken as the initial approximation to

${\Gamma}^{*}$. To construct

${D}_{{\overline{b}}_{0}}$ we first overlay on

${[0,1]}^{2}$ a net of

$11\times 11$ points,

${Q}_{0}$. These are the green points displayed in

Figure 14.

To each point in

${Q}_{0}$ we assign the value of its distance from the set

${P}_{0}$, with a plus sign for points which are on the right or above

${P}_{0}$, and a minus sign for the other points. To each point in

${P}_{0}$ we assign the value zero. The spline function

${D}_{{\overline{b}}_{0}}$ is now defined by the least-squares approximation to the values at all the points

${P}_{0}\cup {Q}_{0}$. We have used here tensor product splines of order 10, on a uniform mesh with knots’ distance

$=0.1$. We denote the level curve zero of the resulting

${D}_{{\overline{b}}_{0}}$ as

${\Gamma}_{0}$, and this curve is depicted in yellow in

Figure 14. It seems that

${\Gamma}_{0}$ is already a good approximation to

${\Gamma}^{*}$ (in blue), and thus it is a good starting point for achieving the minimization target (

21).

**Improving the approximation to ${\Gamma}^{*}$, and building the two approximants**

Starting from

${D}_{{\overline{b}}_{0}}$ we use a quasi-Newton method for iterative improvement of the approximation to

${\Gamma}^{*}$. The expensive ingredient in the computation procedure is the need to recompute the Fourier coefficients of the

B-splines for any new set of coefficients

$\overline{b}$ of

${D}_{\overline{b}}$. We recall that we need

${(2M+1)}^{2}$ of these coefficients for each

B-spline, and we have

$2{N}_{d}^{2}$B-splines. In the numerical example we have used

$M=40$ and

${N}_{d}=19$. To illustrate the issue we present in

Figure 15 one of those

B-spline whose support intersects the singularity curve. When the singularity curve is updated, the Fourier coefficients of this

B-spline are recalculated.

**Remark** **5.** **Calculating Fourier coefficients of the B-splines**Calculating the Fourier coefficients of the B-splines is the most costly step in the approximation procedure. For the univariate case the Fourier coefficients of the B-splines can be computed analytically. For a smooth d-variate function $f:{[0,1]}^{d}\to \mathbb{R}$, with no singularity within the unit cube ${[0,1]}^{d}$, piecewise Gauss quadrature may be used to compute the Fourier coefficients with high precision. The non-smooth multivariate case is more difficult, and more expensive. However, we noticed that using low precision approximations for the Fourier coefficients of the B-splines is fine. For example, in the above example, we have employed a simple numerical quadrature combined with fast Fourier transform, and we obtained the Fourier coefficients with a relative error ∼${10}^{-5}$. Yet the resulting approximation error is small ${\parallel f-S\parallel}_{\infty}<5\times {10}^{-6}$, as seen in Figure 18.

Using one quasi-Newton step we obtained new spline coefficients

${\overline{b}}_{1}$ and an improved approximation

${\Gamma}_{1}$ to

${\Gamma}^{*}$ as the zero level set of

${D}_{{\overline{b}}_{1}}$. Stopping the procedure at this point yields approximation results as shown in the figures below.

Figure 16 shows the approximation error

$f-S$ on

${[0,1]}^{2}\backslash U$, where

U is a small neighborhood of

${\Gamma}^{*}$.

Figure 17 shows, in green,

${log}_{10}$ of the magnitude of the giver Fourier coefficients

${\widehat{f}}_{mn}$ and, in blue,

${log}_{10}$ of the Fourier coefficients of the difference

$f-S$. We observe a reduction of three orders of magnitude between the two.

Applying four quasi-Newton iterations took ∼24 min execution time. The approximation of

${\Gamma}^{*}$ by the zero level set of

${D}_{{\overline{b}}_{4}}$ is now with an error of

${10}^{-9}$. The consequent approximation error to

f is reduced as shown in

Figure 18, and the Fourier coefficients of the error are reduced by 5 orders of magnitude, as shown in

Figure 19.