Plotting numerically solved integration function with Logarithmic singularity

I am struggling to plot the following Numerically solved integral function. But my code is suffering from logarithmic singularity which it should not because xlnx is zero when x tends to zero. Any help to plot this function will be highly appreciated.

L1= 5;
a = 30*B;
Y=(8 a x^2 (a^2 - 2 x^4) - (a^2 - 4 x^4)^2 (Log[-a + 2 x^2] -
Log[a + 2 x^2]))/a^3;
A1[B_ ] :=
NIntegrate[
Y*1/4 1/Cosh[(x -L1)/2]^2, {x, -10, 20}]
Plot[{A1[B]}, {B, 0, 10}]


If your problem is at $B=0$, but your integral can be calculated at this point, I have worked this around by means of introducing the limit:

L1 = 5.;
a = 30.*B;
Y = (8. a x^2 (a^2 - 2. x^4) - (a^2 - 4 x^4)^2 (Log[-a + 2 x^2] - Log[a + 2 x^2]))/a^3;
limit = FullSimplify@Limit[Y*0.25 1/Cosh[(x - L1)/2.]^2, B -> 0];
A1[B_?NumericQ] := NIntegrate[If[B == 0, limit, Y*0.25 1/Cosh[(x - L1)/2.]^2], {x, -10, 20},
Method -> {"GlobalAdaptive", Method -> "MultipanelRule"}];
data = ParallelTable[A1[B], {B, 0., 10, 0.01}];
ListPlot[(Tooltip[{Re[#1], Im[#1]}] &) /@ data, AspectRatio -> 1]


I obtained that your function is complex. You can be more fine in the sampling.

I do not know if this what you are expecting. Further, maybe some other formal solution exists.

• Dear J.A.D. Navas, my integral is not complex at B=0. See Simplify[Series[Y, {B, 0, 5}]] gives results(4 x^2)/3 + (8 B^2)/(15 x^2) + (2 B^4)/(105 x^6)+ higer order terms. So it is real and finite at B=0. Commented Nov 15, 2017 at 19:40
• @HazoorImran Yes, I agree. Just see the data, the first point is real as seen in the plot. Commented Nov 15, 2017 at 19:45
• Not only B=0 is real, but all of the integral value is real for all values of B. Commented Nov 15, 2017 at 19:51
• @HazoorImran I have plotted your integrand for $B\in [0.001,10]$, and, at least beyond $B=0.1$ (this depends on the sampling), it is complex. Can you check this? Commented Nov 15, 2017 at 20:04
• @HazoorImran When $x=0$, the term $\ln[-a + 2 x^2]$ is complex when $a>0$ (or $30B > 0$) or the term $\ln(a + 2x^2)$ is complex when $a<0$. Commented Nov 15, 2017 at 20:44