1
$\begingroup$

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}]
$\endgroup$
1
$\begingroup$

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]

enter image description here

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.

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Hazoor Imran Nov 15 '17 at 19:40
  • $\begingroup$ @HazoorImran Yes, I agree. Just see the data, the first point is real as seen in the plot. $\endgroup$ – José Antonio Díaz Navas Nov 15 '17 at 19:45
  • $\begingroup$ Not only B=0 is real, but all of the integral value is real for all values of B. $\endgroup$ – Hazoor Imran Nov 15 '17 at 19:51
  • $\begingroup$ @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? $\endgroup$ – José Antonio Díaz Navas Nov 15 '17 at 20:04
  • $\begingroup$ @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$. $\endgroup$ – Carl Woll Nov 15 '17 at 20:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.