Contents
- Test if kernel matrix of the 3D case has columns with divergence zero
- Calculating the divergence of the first column (h1)
- Calculating the divergence of the first column (h2)
- Calculating the divergence of the first column (h3)
- Calculating derivative matrices $h_{x_1}^{3x3}$
- Calculating derivative matrices $h_{x_2}^{3x3}$
- Calculating derivative matrices $h_{x_3}^{3x3}$
Test if kernel matrix of the 3D case has columns with divergence zero
syms t x1 x2 x3 y1 y2 y3 rbf = @(e,x) exp(-e * (x(:).'*x(:))); x = [x1; x2; x3]; y = [y1; y2; y3]*0; h = ((4*t - 4*t^2*(x.'*x))*eye(3) + 4*t^2*(x*x.'))*exp(-t*(x.'*x)); Axx = diff(diff(rbf(t,x-y),x1),x1); Axy = diff(diff(rbf(t,x-y),x1),x2); Axz = diff(diff(rbf(t,x-y),x1),x3); Ayx = diff(diff(rbf(t,x-y),x2),x1); Ayy = diff(diff(rbf(t,x-y),x2),x2); Ayz = diff(diff(rbf(t,x-y),x2),x3); Azx = diff(diff(rbf(t,x-y),x3),x1); Azy = diff(diff(rbf(t,x-y),x3),x2); Azz = diff(diff(rbf(t,x-y),x3),x3); A = [Axx Ayx Azx; ... Axy Ayy Azy; ... Axz Ayz Azz]; K = simplify( -(diff(rbf(t,x-y),x1,2) + diff(rbf(t,x-y),x2,2) + ... diff(rbf(t,x-y),x3,2))*eye(3) + A); pretty(simplify(h)) fprintf('\n') pretty(K) fprintf('\n') pretty(simplify(K-h)) fprintf('\n')
+- -+
| 2 2 |
| - 4 t #4 (t x2 + t x3 - 1), #3, #2 |
| |
| 2 2 |
| #3, - 4 t #4 (t x1 + t x3 - 1), #1 |
| |
| 2 2 |
| #2, #1, - 4 t #4 (t x1 + t x2 - 1) |
+- -+
where
2
#1 == 4 t x2 x3 #4
2
#2 == 4 t x1 x3 #4
2
#3 == 4 t x1 x2 #4
2 2 2
#4 == exp(- t (x1 + x2 + x3 ))
+- -+
| 2 2 |
| - 4 t #4 (t x2 + t x3 - 1), #3, #2 |
| |
| 2 2 |
| #3, - 4 t #4 (t x1 + t x3 - 1), #1 |
| |
| 2 2 |
| #2, #1, - 4 t #4 (t x1 + t x2 - 1) |
+- -+
where
2
#1 == 4 t x2 x3 #4
2
#2 == 4 t x1 x3 #4
2
#3 == 4 t x1 x2 #4
2 2 2
#4 == exp(- t (x1 + x2 + x3 ))
+- -+
| 0, 0, 0 |
| |
| 0, 0, 0 |
| |
| 0, 0, 0 |
+- -+
Note that from the code above we have that if $\phi(r) = \exp(-t r^2)$, then the kernel $$ K(\mathbf{x},\mathbf{y}) = \left( -\Delta I + \nabla\nabla^T \right) \phi(\|\mathbf{x} - \mathbf{y}\|) = h_t^{3x3}(\mathbf{x} - \mathbf{y}) $$
Calculating the divergence of the first column (h1)
div_h1 = diff(h(1,1),x1) + diff(h(2,1),x2) + diff(h(3,1),x3); disp('div_h1 = ') pretty(simplify(div_h1)) fprintf('\n')
div_h1 = 0
Calculating the divergence of the first column (h2)
div_h2 = diff(h(1,2),x1) + diff(h(2,2),x2) + diff(h(3,2),x3); disp('div_h2 = ') pretty(simplify(div_h2)) fprintf('\n')
div_h2 = 0
Calculating the divergence of the first column (h3)
div_h3 = diff(h(1,3),x1) + diff(h(2,3),x2) + diff(h(3,3),x3); disp('div_h3 = ') pretty(simplify(div_h3)) fprintf('\n')
div_h3 = 0
Calculating derivative matrices $h_{x_1}^{3x3}$
h_x1 = simplify(diff(h,x1)); pretty(h_x1)
+- -+
| 2 2 2 |
| 8 t x1 #4 (t x2 + t x3 - 1), #2, #1 |
| |
| 2 2 2 |
| #2, 8 t x1 #4 (t x1 + t x3 - 2), #3 |
| |
| 2 2 2 |
| #1, #3, 8 t x1 #4 (t x1 + t x2 - 2) |
+- -+
where
2 2
#1 == - 4 t x3 #4 (2 t x1 - 1)
2 2
#2 == - 4 t x2 #4 (2 t x1 - 1)
3
#3 == - 8 t x1 x2 x3 #4
2 2 2
#4 == exp(- t (x1 + x2 + x3 ))
Calculating derivative matrices $h_{x_2}^{3x3}$
h_x2 = simplify(diff(h,x2)); pretty(h_x2)
+- -+
| 2 2 2 |
| 8 t x2 #4 (t x2 + t x3 - 2), #2, #3 |
| |
| 2 2 2 |
| #2, 8 t x2 #4 (t x1 + t x3 - 1), #1 |
| |
| 2 2 2 |
| #3, #1, 8 t x2 #4 (t x1 + t x2 - 2) |
+- -+
where
2 2
#1 == - 4 t x3 #4 (2 t x2 - 1)
2 2
#2 == - 4 t x1 #4 (2 t x2 - 1)
3
#3 == - 8 t x1 x2 x3 #4
2 2 2
#4 == exp(- t (x1 + x2 + x3 ))
Calculating derivative matrices $h_{x_3}^{3x3}$
h_x3 = simplify(diff(h,x3)); pretty(h_x3)
+- -+
| 2 2 2 |
| 8 t x3 #4 (t x2 + t x3 - 2), #3, #2 |
| |
| 2 2 2 |
| #3, 8 t x3 #4 (t x1 + t x3 - 2), #1 |
| |
| 2 2 2 |
| #2, #1, 8 t x3 #4 (t x1 + t x2 - 1) |
+- -+
where
2 2
#1 == - 4 t x2 #4 (2 t x3 - 1)
2 2
#2 == - 4 t x1 #4 (2 t x3 - 1)
3
#3 == - 8 t x1 x2 x3 #4
2 2 2
#4 == exp(- t (x1 + x2 + x3 ))