これ、ねんちょヨロ

年末調整の給与所得を算定するための『訳の分からない表』をプロットしてみた。

『訳の分からない表』はこれ↓

f:id:imakov:20211113165343p:plain

プロットした結果がこれ↓。給与収入が百万円(106)から一億円(108)までをプロットしている。赤線が控除後の所得で、黒点線は控除無しの所得(給与収入の全額が給与所得)である。したがって、給与が低い人ほど多く控除してもらっているのが分かる。あの『訳の分からない表』をプロットすると結構美しいというか、滑らかに接続していると思う。

f:id:imakov:20211113165404j:plain

これをプロットしたmatlabのコードは以下のとおり。

close all
clear variables
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x = logspace(0,8,200);

y = x - 1950000;

thres_min = 1;
thres_max = 550999;
index = thres_min <= x & x <=thres_max;
y(index) = 0;

thres_min = thres_max+1;
thre_max = 1618999;
index = thres_min <= x & x <=thres_max;
y(index) = x(index)-550000;

thres_min = thres_max+1;
thre_max = 1619999;
index = thres_min <= x & x <=thres_max;
y(index) = 1069000;

thres_min = thres_max+1;
thre_max = 1621999;
index = thres_min <= x & x <=thres_max;
y(index) = 1070000;

thres_min = thres_max+1;
thre_max = 1623999;
index = thres_min <= x & x <=thres_max;
y(index) = 1072000;

thres_min = thres_max+1;
thre_max = 1627999;
index = thres_min <= x & x <=thres_max;
y(index) = 1074000;

thres_min = thres_max+1;
thre_max = 1799999;
index = thres_min <= x & x <=thres_max;
y(index) = floor(x(index)/4/1000)*1000*2.4+100000;

thres_min = thres_max+1;
thre_max = 3599999;
index = thres_min <= x & x <=thres_max;
y(index) = floor(x(index)/4/1000)*1000*2.8 - 80000;

thres_min = thres_max+1;
thre_max = 6599999;
index = thres_min <= x & x <=thres_max;
y(index) = floor(x(index)/4/1000)*1000*3.2 - 440000;

thres_min = thres_max+1;
thre_max = 8499999;
index = thres_min <= x & x <=thres_max;
y(index) = x(index)*0.9 - 1100000;

%+++ PLOT +++
loglog(x, y, 'r-', 'LineWidth', 2)
hold all
loglog(x, x, 'k-.', 'LineWidth', 2)
xlabel('給与の収入金額(円)')
ylabel('給与所得の金額(円)')
xlim([1e6, max(x(:))])
ylim([1e6, max(x(:))])
grid on
set(gca,'ticklength', 2 * get(gca,'ticklength'))
axis square