0

I want to plot a definite integral

myIntegral[x_] := NIntegrate[Sqrt[(a - b)^2 + (c - d)^2]/ (a - b), {a, 0, x}, {b, x, 1}, {c, 0, 1}, {d, 0, 1}]
Plot[myIntegral[x], {x, 0, 1}]

I am using Mathematica 11.3. When I evaluate the code, Mathematica immediately gives some warnings about numerical integration converging too slowly, then it seems stuck in computation. I have tried some options of NIntegrate, for example as suggested here, but have had no success. Is there a way to obtain the result of Plot in an acceptable time (e.g. some minutes)?

renato
  • 3
  • 3
  • 2
    You'll get better help if you post your question on the [Mathematica Stack Exchange](https://mathematica.stackexchange.com/) – Code Different Jun 19 '18 at 14:04
  • Thank you, I copied my question [here](https://mathematica.stackexchange.com/questions/175622/how-can-i-speed-up-nintegrate-computation) – renato Jun 19 '18 at 14:46

1 Answers1

0

It is within reach of Integrate.

Assuming[0<x<1,
 Simplify[
   Integrate[Sqrt[(a-b)^2 + (c-d)^2]/(a-b), {a,0,x}, {b,x,1}, {c,0,1}, {d,0,1}]]]

which gives you

(-11*Sqrt[2] + 11*Sqrt[2+(-2+x)*x] + x*(-8-7*Sqrt[2+(-2+x)*x] + 13*Sqrt[1+x^2] +
 2*x*(6-3*Sqrt[2+(-2+x)*x] + x*(-4+2*x + Sqrt[2+(-2+x)*x] - Sqrt[1+x^2]))) +
 18*x^2*ArcCoth[Sqrt[2+(-2+x)*x]] + 9*ArcSinh[1] - 3*ArcSinh[1-x] - 3*ArcSinh[x] +
 6*Log[1-x] + 9*x*Log[-1+Sqrt[2+(-2+x)*x]] + 3*((-2+x)*Log[1+Sqrt[2+(-2+x)*x]] -
 4*x*Log[-(((-1+x)*(1 + Sqrt[1+x^2]))/x)] + x^3*(Log[2+x^2+2*Sqrt[1+x^2]] +
 2*Log[(1-x)/(x+x*Sqrt[2-2*x+x^2])])))/36

And that should be much faster to plot than doing thousands on individual NIntegrate

Bill
  • 3,664
  • 1
  • 12
  • 9