function [D1,H,x,h] = d1_noneq_minimal_12(N,L)

% L: Domain length
% N: Number of grid points
if(nargin < 2)
    L = 1;
end

if(N<20)
    error('Operator requires at least 20 grid points');
end

% BP: Number of boundary points
% m:  Number of nonequidistant spacings
% order: Accuracy of interior stencil
BP = 10;
m = 4;
order = 12;

%%%% Non-equidistant grid points %%%%%
x0 =  0.0000000000000e+00;
x1 =  4.6552112904489e-01;
x2 =  1.4647984306493e+00;
x3 =  2.7620429464763e+00;
x4 =  4.0000000000000e+00;
x5 =  5.0000000000000e+00;
x6 =  6.0000000000000e+00;
x7 =  7.0000000000000e+00;
x8 =  8.0000000000000e+00;
x9 =  9.0000000000000e+00;
x10 =  1.0000000000000e+01;

xb = sparse(m+1,1);
for i = 0:m
    xb(i+1) = eval(['x' num2str(i)]);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%% Compute h %%%%%%%%%%
h = L/(2*xb(end) + N-1-2*m);
%%%%%%%%%%%%%%%%%%%%%%%%%

%%%% Define grid %%%%%%%%
x = h*[xb; linspace(xb(end)+1,L/h-xb(end)-1,N-2*(m+1))'; L/h-flip(xb) ];
%%%%%%%%%%%%%%%%%%%%%%%%%

%%%% Norm matrix %%%%%%%%
P = sparse(BP,1);
%#ok<*NASGU>
P0 =  1.3013597111750e-01;
P1 =  7.6146045079020e-01;
P2 =  1.1984222247012e+00;
P3 =  1.3340123109301e+00;
P4 =  1.0951811473364e+00;
P5 =  9.7569096377130e-01;
P6 =  1.0061945410831e+00;
P7 =  9.9874339446564e-01;
P8 =  1.0001702615573e+00;
P9 =  9.9998873424721e-01;

for i = 0:BP-1
    P(i+1) = eval(['P' num2str(i)]);
end

H = ones(N,1);
H(1:BP) = P;
H(end-BP+1:end) = flip(P);
H = spdiags(h*H,0,N,N);
%%%%%%%%%%%%%%%%%%%%%%%%%

%%%% Q matrix %%%%%%%%%%%

% interior stencil
switch order
    case 2
        d = [-1/2,0,1/2];
    case 4
        d = [1/12,-2/3,0,2/3,-1/12];
    case 6
        d = [-1/60,3/20,-3/4,0,3/4,-3/20,1/60];
    case 8
        d = [1/280,-4/105,1/5,-4/5,0,4/5,-1/5,4/105,-1/280];
    case 10
        d = [-1/1260,5/504,-5/84,5/21,-5/6,0,5/6,-5/21,5/84,-5/504,1/1260];
    case 12
        d = [1/5544,-1/385,1/56,-5/63,15/56,-6/7,0,6/7,-15/56,5/63,-1/56,1/385,-1/5544];
end
d = repmat(d,N,1);
Q = spdiags(d,-order/2:order/2,N,N);

% Boundaries
Q0_0 = -5.0000000000000e-01;
Q0_1 =  6.7603132599815e-01;
Q0_2 = -2.6781065957921e-01;
Q0_3 =  1.4050310470012e-01;
Q0_4 = -5.4072653004710e-02;
Q0_5 = -1.1876984028213e-02;
Q0_6 =  2.6300694680362e-02;
Q0_7 = -9.8077210531438e-03;
Q0_8 =  4.2848959311712e-04;
Q0_9 =  3.0440269352791e-04;
Q0_10 =  0.0000000000000e+00;
Q0_11 =  0.0000000000000e+00;
Q0_12 =  0.0000000000000e+00;
Q0_13 =  0.0000000000000e+00;
Q0_14 =  0.0000000000000e+00;
Q0_15 =  0.0000000000000e+00;
Q1_0 = -6.7603132599815e-01;
Q1_1 =  0.0000000000000e+00;
Q1_2 =  9.5204118058043e-01;
Q1_3 = -4.1306598236120e-01;
Q1_4 =  1.5442577883533e-01;
Q1_5 =  2.6535212157067e-02;
Q1_6 = -6.7869317213141e-02;
Q1_7 =  2.6431850942376e-02;
Q1_8 = -1.8383496124689e-03;
Q1_9 = -6.2904733024363e-04;
Q1_10 =  0.0000000000000e+00;
Q1_11 =  0.0000000000000e+00;
Q1_12 =  0.0000000000000e+00;
Q1_13 =  0.0000000000000e+00;
Q1_14 =  0.0000000000000e+00;
Q1_15 =  0.0000000000000e+00;
Q2_0 =  2.6781065957921e-01;
Q2_1 = -9.5204118058043e-01;
Q2_2 =  0.0000000000000e+00;
Q2_3 =  9.4424869445124e-01;
Q2_4 = -3.0369922793820e-01;
Q2_5 = -1.7036409572828e-02;
Q2_6 =  9.7546158402857e-02;
Q2_7 = -4.2534720340735e-02;
Q2_8 =  5.3471186513813e-03;
Q2_9 =  3.5890734751923e-04;
Q2_10 =  0.0000000000000e+00;
Q2_11 =  0.0000000000000e+00;
Q2_12 =  0.0000000000000e+00;
Q2_13 =  0.0000000000000e+00;
Q2_14 =  0.0000000000000e+00;
Q2_15 =  0.0000000000000e+00;
Q3_0 = -1.4050310470012e-01;
Q3_1 =  4.1306598236120e-01;
Q3_2 = -9.4424869445124e-01;
Q3_3 =  0.0000000000000e+00;
Q3_4 =  8.1369662782755e-01;
Q3_5 = -8.4027084126181e-02;
Q3_6 = -1.0721180825279e-01;
Q3_7 =  6.1098180874949e-02;
Q3_8 = -1.2618762739267e-02;
Q3_9 =  7.4866320589496e-04;
Q3_10 =  0.0000000000000e+00;
Q3_11 =  0.0000000000000e+00;
Q3_12 =  0.0000000000000e+00;
Q3_13 =  0.0000000000000e+00;
Q3_14 =  0.0000000000000e+00;
Q3_15 =  0.0000000000000e+00;
Q4_0 =  5.4072653004710e-02;
Q4_1 = -1.5442577883533e-01;
Q4_2 =  3.0369922793820e-01;
Q4_3 = -8.1369662782755e-01;
Q4_4 =  0.0000000000000e+00;
Q4_5 =  6.8140317057259e-01;
Q4_6 = -5.0090848997730e-02;
Q4_7 = -3.2156238350691e-02;
Q4_8 =  1.2270208460707e-02;
Q4_9 = -8.9539078453821e-04;
Q4_10 = -1.8037518037522e-04;
Q4_11 =  0.0000000000000e+00;
Q4_12 =  0.0000000000000e+00;
Q4_13 =  0.0000000000000e+00;
Q4_14 =  0.0000000000000e+00;
Q4_15 =  0.0000000000000e+00;
Q5_0 =  1.1876984028213e-02;
Q5_1 = -2.6535212157067e-02;
Q5_2 =  1.7036409572828e-02;
Q5_3 =  8.4027084126181e-02;
Q5_4 = -6.8140317057259e-01;
Q5_5 =  0.0000000000000e+00;
Q5_6 =  7.3535220394540e-01;
Q5_7 = -1.7565390898074e-01;
Q5_8 =  4.5853976429252e-02;
Q5_9 = -1.2971393808506e-02;
Q5_10 =  2.5974025974031e-03;
Q5_11 = -1.8037518037522e-04;
Q5_12 =  0.0000000000000e+00;
Q5_13 =  0.0000000000000e+00;
Q5_14 =  0.0000000000000e+00;
Q5_15 =  0.0000000000000e+00;
Q6_0 = -2.6300694680362e-02;
Q6_1 =  6.7869317213141e-02;
Q6_2 = -9.7546158402857e-02;
Q6_3 =  1.0721180825279e-01;
Q6_4 =  5.0090848997730e-02;
Q6_5 = -7.3535220394540e-01;
Q6_6 =  0.0000000000000e+00;
Q6_7 =  8.2185236816776e-01;
Q6_8 = -2.4842386107781e-01;
Q6_9 =  7.6038690915127e-02;
Q6_10 = -1.7857142857146e-02;
Q6_11 =  2.5974025974031e-03;
Q6_12 = -1.8037518037522e-04;
Q6_13 =  0.0000000000000e+00;
Q6_14 =  0.0000000000000e+00;
Q6_15 =  0.0000000000000e+00;
Q7_0 =  9.8077210531438e-03;
Q7_1 = -2.6431850942376e-02;
Q7_2 =  4.2534720340735e-02;
Q7_3 = -6.1098180874949e-02;
Q7_4 =  3.2156238350691e-02;
Q7_5 =  1.7565390898074e-01;
Q7_6 = -8.2185236816776e-01;
Q7_7 =  0.0000000000000e+00;
Q7_8 =  8.5207110387533e-01;
Q7_9 = -2.6676625654053e-01;
Q7_10 =  7.9365079365093e-02;
Q7_11 = -1.7857142857146e-02;
Q7_12 =  2.5974025974031e-03;
Q7_13 = -1.8037518037522e-04;
Q7_14 =  0.0000000000000e+00;
Q7_15 =  0.0000000000000e+00;
Q8_0 = -4.2848959311712e-04;
Q8_1 =  1.8383496124689e-03;
Q8_2 = -5.3471186513813e-03;
Q8_3 =  1.2618762739267e-02;
Q8_4 = -1.2270208460707e-02;
Q8_5 = -4.5853976429252e-02;
Q8_6 =  2.4842386107781e-01;
Q8_7 = -8.5207110387533e-01;
Q8_8 =  0.0000000000000e+00;
Q8_9 =  8.5702210251244e-01;
Q8_10 = -2.6785714285718e-01;
Q8_11 =  7.9365079365093e-02;
Q8_12 = -1.7857142857146e-02;
Q8_13 =  2.5974025974031e-03;
Q8_14 = -1.8037518037522e-04;
Q8_15 =  0.0000000000000e+00;
Q9_0 = -3.0440269352791e-04;
Q9_1 =  6.2904733024363e-04;
Q9_2 = -3.5890734751923e-04;
Q9_3 = -7.4866320589496e-04;
Q9_4 =  8.9539078453821e-04;
Q9_5 =  1.2971393808506e-02;
Q9_6 = -7.6038690915127e-02;
Q9_7 =  2.6676625654053e-01;
Q9_8 = -8.5702210251244e-01;
Q9_9 =  0.0000000000000e+00;
Q9_10 =  8.5714285714289e-01;
Q9_11 = -2.6785714285718e-01;
Q9_12 =  7.9365079365093e-02;
Q9_13 = -1.7857142857146e-02;
Q9_14 =  2.5974025974031e-03;
Q9_15 = -1.8037518037522e-04;
for i = 1:BP
    for j = 1:BP
        Q(i,j) = eval(['Q' num2str(i-1) '_' num2str(j-1)]);
        Q(N+1-i,N+1-j) = -eval(['Q' num2str(i-1) '_' num2str(j-1)]);
    end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%% Difference operator %%
D1 = H\Q;
%%%%%%%%%%%%%%%%%%%%%%%%%%%