Contents

Test if kernel matrix of the 2D case has columns with divergence zero

clear, clc
syms t x1 x2
x = [x1; x2];
h = ((4*t - 4*t^2*(x.'*x))*eye(2) + 4*t^2*(x*x.'))*exp(-t*(x.'*x));
pretty(simplify(h))
fprintf('\n')
 
  +-                                            -+ 
  |                2              2              | 
  |  - 4 t #1 (t x2  - 1),     4 t  x1 x2 #1     | 
  |                                              | 
  |         2                            2       | 
  |      4 t  x1 x2 #1,    - 4 t #1 (t x1  - 1)  | 
  +-                                            -+ 
   
  where 
   
                      2     2 
     #1 == exp(- t (x1  + x2 ))

Calculating the divergence of the first column (h1)

div_h1 = diff(h(1,1),x1) + diff(h(2,1),x2);
disp('div_h1 = ')
pretty(simplify(div_h1))
fprintf('\n')
div_h1 = 
 
       2               2     2 
  - 4 t  x1 exp(- t (x1  + x2 ))

Calculating the divergence of the first column (h2)

div_h2 = diff(h(1,2),x1) + diff(h(2,2),x2);
disp('div_h2 = ')
pretty(simplify(div_h2))
fprintf('\n')
div_h2 = 
 
       2               2     2 
  - 4 t  x2 exp(- t (x1  + x2 ))

Calculating derivative matrices $h_{x_1}^{2x2}$

h_x1 = simplify(diff(h,x1));
pretty(h_x1)
 
  +-                                                -+ 
  |     2            2                               | 
  |  8 t  x1 #2 (t x2  - 1),           #1            | 
  |                                                  | 
  |                             2            2       | 
  |            #1,           8 t  x1 #2 (t x1  - 2)  | 
  +-                                                -+ 
   
  where 
   
                2              2 
     #1 == - 4 t  x2 #2 (2 t x1  - 1) 
   
                      2     2 
     #2 == exp(- t (x1  + x2 ))

Calculating derivative matrices $h_{x_2}^{2x2}$

h_x2 = simplify(diff(h,x2));
pretty(h_x2)
 
  +-                                                -+ 
  |     2            2                               | 
  |  8 t  x2 #2 (t x2  - 2),           #1            | 
  |                                                  | 
  |                             2            2       | 
  |            #1,           8 t  x2 #2 (t x1  - 1)  | 
  +-                                                -+ 
   
  where 
   
                2              2 
     #1 == - 4 t  x1 #2 (2 t x2  - 1) 
   
                      2     2 
     #2 == exp(- t (x1  + x2 ))