Clear["Global`*"]

(* 1/r の導関数 *)
f0[r_] = 1/r;
f1[r_]=D[f0[r],r];
f2[r_]=D[f1[r],r];
f3[r_]=D[f2[r],r];
f4[r_]=D[f3[r],r];
f5[r_]=D[f4[r],r];

(* spline 関数、及び、その導関数の定義 *)
(*  rd=r2-r1;    rs =r-r1;  *)
g0[rs_]=Sum[a[i]*rs^i,{i,0,8}];
g1[rs_]=D[g0[rs],rs];
g2[rs_]=D[g1[rs],rs];
g3[rs_]=D[g2[rs],rs];
g4[rs_]=D[g3[rs],rs];
g5[rs_]=D[g4[rs],rs];

(* 定数項を残さなかった場合 *)
h0[rs_]=Sum[a[i]*rs^i,{i,0,9}];
h1[rs_]=D[h0[rs],rs];
h2[rs_]=D[h1[rs],rs];
h3[rs_]=D[h2[rs],rs];
h4[rs_]=D[h3[rs],rs];
h5[rs_]=D[h4[rs],rs];

(* 関数の接続条件から spline 係数を求める。 gg?[rs_] が得られた関数。 *)
eqs={g1[0]== 0, g2[0]==0,g3[0]==0,g4[0]==0,(*g5[0]==0,*)g0[rd]==f0[r2],g1[rd]==f1[r2],g2[rd]==f2[r2], g3[rd]==f3[r2], g4[rd]==f4[r2](*,g5[rd]==f5[r2]*)};
sol=Solve[eqs,Array[a,9,0]];

gg0[rs_] = Simplify[g0[rs]/.sol][[1]];
gg1[rs_]=D[gg0[rs],rs];
gg2[rs_]=D[gg1[rs],rs];
gg3[rs_]=D[gg2[rs],rs];
U0=a[0]/.sol;

(* 定数項を残さなかった場合 *)
eqs={h0[0]==0, h1[0]== 0, h2[0]==0,h3[0]==0,h4[0]==0,h0[rd]==f0[r2],h1[rd]==f1[r2],h2[rd]==f2[r2], h3[rd]==f3[r2], h4[rd]==f4[r2]};
sol=Solve[eqs,Array[a,10,0]];

hh0[rs_] = Simplify[h0[rs]/.sol][[1]];
hh1[rs_]=D[hh0[rs],rs];
hh2[rs_]=D[hh1[rs],rs];
hh3[rs_]=D[hh2[rs],rs];

(* 関数の表示 *)
(* 赤が 1/r^mod, 青が 1/r, 黄色が定数項をなくした場合（誘起双極子を考えない系で使われるものの拡張。） *)
r1 =11.5;
r2=6;
sign=If[r2>r1,1,-1]
rd=r2-r1;
rs=r-r1;
rmargin = 0.2*Abs[r2-r1];
rmin=Min[r1,r2];
rmax=Max[r1,r2];
Plot[{f0[r],f0[r]*UnitStep[sign*(r-r2)]+gg0[rs]*UnitStep[sign*(r2-r)]*UnitStep[sign*(r-r1)]+U0*UnitStep[sign*(r1-r)],f0[r]*UnitStep[sign*(r-r2)]+hh0[rs]*UnitStep[sign*(r2-r)]*UnitStep[sign*(r-r1)]},{r,rmin-rmargin,rmax+rmargin}, BaseStyle-> {FontWeight -> "Bold", FontSize-> 14},PlotStyle->{{Thickness[0.0075],RGBColor[0,1,0]},{Thickness[0.0075],RGBColor[1,0,0]},{Thickness[0.0075],RGBColor[0,0,1]}},AxesLabel->{"r [A]","(a) 1/r [A^{-1}]"},GridLines->{{{rmax,Dashed},{rmax-rmin,Dashed}},{}}]
Plot[{f1[r],f1[r]*UnitStep[sign*(r-r2)]+gg1[rs]*UnitStep[sign*(r2-r)]*UnitStep[sign*(r-r1)],f1[r]*UnitStep[sign*(r-r2)]+hh1[rs]*UnitStep[sign*(r2-r)]*UnitStep[sign*(r-r1)]},{r,rmin-rmargin,rmax+rmargin},BaseStyle-> {FontWeight -> "Bold", FontSize-> 14},PlotStyle->{{Thickness[0.0075],RGBColor[0,1,0]},{Thickness[0.0075],RGBColor[1,0,0]},{Thickness[0.0075],RGBColor[0,0,1]}},AxesLabel->{"r [A]","(b) D(1/r) [A^{-2}]"},GridLines->{{{rmax,Dashed},{rmax-rmin,Dashed}},{}}]
Plot[{f2[r],f2[r]*UnitStep[sign*(r-r2)]+gg2[rs]*UnitStep[sign*(r2-r)]*UnitStep[sign*(r-r1)],f2[r]*UnitStep[sign*(r-r2)]+hh2[rs]*UnitStep[sign*(r2-r)]*UnitStep[sign*(r-r1)]},{r,rmin-rmargin,rmax+rmargin},BaseStyle-> {FontWeight -> "Bold", FontSize-> 14},PlotStyle->{{Thickness[0.0075],RGBColor[0,1,0]},{Thickness[0.0075],RGBColor[1,0,0]},{Thickness[0.0075],RGBColor[0,0,1]}},AxesLabel->{"r [A]","(c) D2(1/r) [A^{-3}]"},GridLines->{{{rmax,Dashed},{rmax-rmin,Dashed}},{}}]
Plot[{f3[r],f3[r]*UnitStep[sign*(r-r2)]+gg3[rs]*UnitStep[sign*(r2-r)]*UnitStep[sign*(r-r1)],f3[r]*UnitStep[sign*(r-r2)]+hh3[rs]*UnitStep[sign*(r2-r)]*UnitStep[sign*(r-r1)]},{r,rmin-rmargin,rmax+rmargin},BaseStyle-> {FontWeight -> "Bold", FontSize-> 14},PlotStyle->{{Thickness[0.0075],RGBColor[0,1,0]},{Thickness[0.0075],RGBColor[1,0,0]},{Thickness[0.0075],RGBColor[0,0,1]}},AxesLabel->{"r [A]","(d) D3(1/r) [A^{-4}]"},GridLines->{{{rmax,Dashed},{rmax-rmin,Dashed}},{}}]