Cube Line Picking

Author

Eric W. Weisstein
May 24, 2009

This notebook downloaded from http://mathworld.wolfram.com/notebooks/ComputationalGeometry/CubeLinePicking.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/CubeLinePicking.html.

©2009 Wolfram Research, Inc. except for portions noted otherwise

Points in Interior

Delta[n_]:=Module[{x,l},
l=Array[x,{2,n}];
Integrate[Sqrt[#.#]&[Subtract@@l],Sequence@@({#,0,1}&/@Flatten[l])]
]

Numerical

NIntegrate[Sqrt[(x1-x2)^2+(y1-y2)^2+(z1-z2)^2],{x1,0,1},{x2,0,1},{y1,0,1},{y2,0,1},{z1,0,1},{z2,0,1}]

NIntegrate[Sqrt[(x1-x2)^2+(y1-y2)^2+(z1-z2)^2],{x1,0,1},{x2,0,1},{y1,0,1},{y2,0,1},{z1,0,1},{z2,0,1},Method->QuasiMonteCarlo,PrecisionGoal->6,AccuracyGoal->Infinity,MaxPoints->10^7]//Timing

Exact

N[4/105 + 17/105*Sqrt[2] - 2/35*Sqrt[3] + 1/5*Log[1 +Sqrt[2]] + 2/5*Log[2 + Sqrt[3]] - 1/15*Pi,20]

Timing[d=Integrate[Sqrt[(x1-x2)^2+(y1-y2)^2+(z1-z2)^2],{x1,0,1},{x2,0,1},{y1,0,1},{y2,0,1},{z1,0,1},{z2,0,1}]]

Set up

vars={x1,x2,y1,y2,z1,z2};

assum=And@@(0<#<1&/@vars)

assum2=Unequal@@vars

Monte Carlo

p=Table[Random[],{10^6},{3}];//Timing

dist=Sqrt[#.#]&/@Subtract@@@Partition[p,2];//Timing

<<Graphics`Graphics`

BarChart[Length/@Split[Ceiling[300Sort[dist]]],Ticks->None,BarEdges->None,BarSpacing->-.2,PlotRange->{{0,500},All},AxesLabel->TraditionalForm/@{l,P[l]}]

Analytic

Pieces

Simplify`PiecewiseIntegrate;
PiecewiseDump`$ShowIntegrals=True;
i=Integrate[Sqrt[(x1-x2)^2+(y1-y2)^2+(z1-z2)^2],{x1,0,1},{y1,0,1},{z1,0,1},{x2,0,1},{y2,0,1},{z2,0,1},{x3,0,1},{y3,0,1},{z3,0,1}];

Length[i]

8i/.HoldForm[Integrate[x__]]:>NIntegrate[Evaluate[x],Method->QuasiMonteCarlo,MaxPoints->10^6]//Timing

1st Integral

i1=Simplify[Integrate[Sqrt[(x1-x2)^2+(y1-y2)^2+(z1-z2)^2],x1]]

int1=Simplify[(i1/.x1->1)-(i1/.x1->0)]

NIntegrate[int1,{x2,0,1},{y1,0,1},{y2,0,1},{z1,0,1},{z2,0,1},Method->QuasiMonteCarlo,PrecisionGoal->3,AccuracyGoal->Infinity,MaxPoints->10^6]

2nd Integral (WRT x2)

i2=Simplify[Integrate[int1,x2]]

int2=Simplify[(i2/.x2->1)-(i2/.x2->0)]

NIntegrate[int2,{y1,0,1},{y2,0,1},{z1,0,1},{z2,0,1},Method->QuasiMonteCarlo]

int2s=Simplify[int2,0<y1<1&&0<y2<1&&0<z1<1&&0<z2<1]

NIntegrate[int2s,{y1,0,1},{y2,0,1},{z1,0,1},{z2,0,1},Method->QuasiMonteCarlo]

3rd Integral

i3=Simplify[Integrate[int2s,z1],0<y1<1&&0<y2<1&&0<z2<1]

int3=Simplify[(i3/.z1->1)-(i3/.z1->0)]

NIntegrate[int3,{y1,0,1},{y2,0,1},{z2,0,1},Method->QuasiMonteCarlo]

int3s=Simplify[int3,0<y1<1&&0<y2<1&&0<z2<1]

NIntegrate[int3s,{y1,0,1},{y2,0,1},{z2,0,1},Method->QuasiMonteCarlo]

4th Integral

i4=Simplify[Integrate[int3s,z2]]

int4=Simplify[(i4/.z2->1)-(i4/.z2->0)]

NIntegrate[int4,{y1,0,1},{y2,0,y1,1}]

5th Integral

Plot3D[int4,{y1,0,1},{y2,0,1},PlotPoints->50,Mesh->False]

Do this in v4.2

i5=Simplify[Integrate[int4,y1]]

...correct in v4.2; wrong in v5 & v6...

int5=Simplify[(i5/.y1->1)-(i5/.y1->0)]

int5=(1/120) (-(16/3) (((-1+y2))^5) (Sqrt[(((-1+y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+Log[3-2 y2+(y2^2)+2 (Sqrt[2-2 y2+(y2^2)])]-2 Log[-1+(Sqrt[3-2 y2+(y2^2)])]-Log[4-2 y2+(y2^2)+2 (Sqrt[3-2 y2+(y2^2)])]))

NIntegrate[int5,{y2,0,1}]

6th Integral

<<PSDirect`

Plot[int5,{y2,0,1}]

i6=Integrate[int5,y2]

int6=Limit[i6,y2->1,Direction->1]-Limit[i6,y2->0,Direction->-1]

FullSimplify[int6]

FullSimplify[Log[FullSimplify[ExpandAll[TrigToExp[Exp[ (56 ArcCsch[(Sqrt[2])]+98 ArcSinh[1]+21 Log[2]-28 Log[3+2 (Sqrt[2])]-42 Log[-1+(Sqrt[3])]+35 Log[2+(Sqrt[3])])]]]]]]

Solve[(3+2Sqrt[2])^n==5964153172084899+4217293152016490 (Sqrt[2]),n]//N

Solve[(2+Sqrt[3])^n==(552794861161443374798157973077388454680145589601+319156261898201133032451783177661812885799840920 (Sqrt[3])),n]//N

Log[(3+2Sqrt[2])^21 (2+Sqrt[3])^84]

(1/210) (8+34 (Sqrt[2])-12 (Sqrt[3])-14 π+Log[(((3+2 (Sqrt[2])))^21) (((2+(Sqrt[3])))^84)])//N

(1/210) (8+34 (Sqrt[2])-12 (Sqrt[3])-14 π+21Log[3+2 (Sqrt[2])]+84Log[ 2+(Sqrt[3])])//N

FullSimplify[(1/210) (8+34 (Sqrt[2])-12 (Sqrt[3])-14 π+21Log[3+2 (Sqrt[2])]+84Log[ 2+(Sqrt[3])])]

Expand[(1+Sqrt[2])^2]

FullSimplify[(1/210) (8+34 (Sqrt[2])-12 (Sqrt[3])-14 π+42Log[1+ (Sqrt[2])]+84Log[ 2+(Sqrt[3])])]

FullSimplify[ArcSinh[1]-Log[1+Sqrt[2]]]

Distribution Function

h1[v_]:=π-4(Sqrt[v])+v
h2[v_]:=-2-v+4(Sqrt[v-1])+2(ArcSin[(v^(-1/2))]-ArcCos[(v^(-1/2))])
g1[v_]:=Piecewise[{{h1[v],0<v<1},{h2[v],1<v<2}}]
g2[v_]:=(v^(-1/2))-1
g1[w1_,w_]:=-π+π(((w1-w))^(-1/2))+4(w^(1/2))-4(w^(1/2))(((w1-w))^(-1/2))-w+w(((w1-w))^(-1/2))
g2[w1_,w_]:=(*h2[w]g2[w1-w]*)2+w-2(((w1-w))^(-1/2))-w(((w1-w))^(-1/2))+4(((w-1))^(1/2))(((w1-w))^(-1/2))-4(((w-1))^(1/2))+2(((w1-w))^(-1/2))(ArcSin[(w^(-1/2))]-ArcCos[(w^(-1/2))])-2(ArcSin[(w^(-1/2))]-ArcCos[(w^(-1/2))])

f11[u_]:=-3π u+2π (Sqrt[u])+4(u^(3/2))-(1/2)(u^2)
f1221[u_]:=-(1/2)+π (3-4 (Sqrt[u]))-4 (Sqrt[-1+u])+u (3-8 (Sqrt[-1+u])+u)+12 u ArcSec[(Sqrt[u])]
f12[u_]:=(2+(π+1)u+(1/2)(u^2)-2π(Sqrt[u-1])-2u(Sqrt[u-1])-2(((u-1))^(3/2))-4u(ArcSin[(u^(-1/2))]-ArcCos[(u^(-1/2))]))
f21[u_]:=(1/2) (-5-12 (Sqrt[-1+u])+u (4-8 (Sqrt[-1+u])+u)+2 π (3+2 (Sqrt[-1+u])-4 (Sqrt[u])+u)+8 u ArcSec[(Sqrt[u])])
f22[u_]:=π-3 π u+(1/2) (-5+8 (Sqrt[-2+u])-u) (1+u)+8 ArcCot[(Sqrt[-2+u])]-8 (Sqrt[u]) ArcCsc[(Sqrt[2-(2/u)])]+4 (-1+3 u) ArcCsc[(Sqrt[-1+u])]-8 ArcTan[(Sqrt[-2+u])]+8 (Sqrt[u]) ArcTan[(Sqrt[(-2+u) u])]
f22[u_]:=(1/2) (-5+6 π+8 (Sqrt[-2+u])-u) (1+u)-8 (Sqrt[u]) ArcCsc[(Sqrt[2-(2/u)])]-12 (1+u) ArcTan[(Sqrt[-2+u])]+8 (Sqrt[u]) ArcTan[(Sqrt[(-2+u) u])]

(Subscript[f, 11])

Integrate[g1[u,w],{w,0,u},Assumptions->0<u<1]

Simplify[%-f11[u]]

(Subscript[f, 12])

Integrate[g1[u,w],{w,u-1,1},Assumptions->1<u<2]

FullSimplify[%-f12[u],Assumptions->1<u<2]

Plot[4 u (-ArcSec[(Sqrt[u])]+ArcTan[(Sqrt[-1+u])]),{u,0,2},PlotStyle->{Thick,Red}]

(Subscript[f, 21])

g2[u,w]

-π-(5/2)+(2π+2)u+(1/2)(u^2)+(2π-8)(((u-1))^(1/2))-2u(((u-1))^(1/2))-2(((u-1))^(-3/2))-2u(ArcSin[(u^(-1/2))]-ArcCos[(u^(-1/2))])-8NIntegrate[(Sqrt[u-((Sec[θ])^2)]),{θ,0,ArcCos[(u^(-1/2))]}]

Integrate[g2[u,w],{w,1,u},Assumptions->1<u<2]

Plot[(1/2) (-5-12 (Sqrt[-1+u])+u (4-8 (Sqrt[-1+u])+u)+2 π (3+2 (Sqrt[-1+u])-4 (Sqrt[u])+u)+8 u ArcSec[(Sqrt[u])]),{u,1,2}]

(Subscript[f, 12])+(Subscript[f, 21])

FullSimplify[f12[u]+f21[u],1<u<2]

(Subscript[f, 22])

(∫_((cos^(-1))((1/(Sqrt[u-1]))))^(π/4))(Sqrt[u-(sec^2)(θ)])\[DifferentialD]θ==2 (tan^(-1))((Sqrt[u-2]))+(Sqrt[u]) ((csc^(-1))((Sqrt[2-(2/u)]))-(tan^(-1))((Sqrt[(u-2) u])))-(π/2)

FullSimplify[-((1/2)π-2ArcTan[(Sqrt[-2+u])])+(Sqrt[u]) (ArcCsc[(Sqrt[2-(2/u)])]-ArcTan[(Sqrt[(-2+u) u])])]

Integrate[(Sqrt[u-((Sec[θ])^2)]),{θ,ArcCos[(((u-1))^(-1/2))],(π/4)},Assumptions->2<u<3]

With[{u=2},Integrate[(Sqrt[u-((Sec[θ])^2)]),{θ,ArcCos[(((u-1))^(-1/2))],(π/4)}]]

With[{u=2},-((1/2)π-2ArcTan[(Sqrt[-2+u])])+(Sqrt[u]) (ArcCsc[(Sqrt[2-(2/u)])]-ArcTan[(Sqrt[(-2+u) u])])]//Factor

i=Integrate[(Sqrt[u-((Sec[θ])^2)]),θ]

i1=FullSimplify[i/.θ->ArcCos[(((u-1))^(-1/2))],2<u<3]

i2=FullSimplify[i/.θ->π/4,2<u<3]

FullSimplify[i2-i1,2<u<3]

FullSimplify[-(5/2)-3u-(1/2)(u^2)+8(((u-2))^(1/2))+2(((u-2))^(3/2))+2u(((u-2))^(1/2))+6(u-1)(ArcSin[(((u-1))^(-1/2))]-ArcCos[(((u-1))^(-1/2))])+4(ArcSin[(((u-1))^(-1/2))]-ArcCos[(((u-1))^(-1/2))])-8(-ArcCot[(Sqrt[-2+u])]+ArcTan[(Sqrt[-2+u])]+(Sqrt[u]) (ArcCsc[(Sqrt[2-(2/u)])]-ArcTan[(Sqrt[(-2+u) u])])),2<u<3]

f22[u]

Plot[Subtract@@{ArcCot[(Sqrt[-2+u])]-ArcTan[(Sqrt[-2+u])],(1/2)π-2ArcTan[(Sqrt[-2+u])]},{u,2,3}]

Plot[f22[u],{u,2,3}]

Plot[π-3 π u+(1/2) (-5+8 (Sqrt[-2+u])-u) (1+u)-8 (Sqrt[u]) ArcCsc[(Sqrt[2-(2/u)])]+4 (-1+3 u) ArcCsc[(Sqrt[-1+u])]+8((1/2)π-2ArcTan[(Sqrt[-2+u])])+8 (Sqrt[u]) ArcTan[(Sqrt[(-2+u) u])],{u,2,3}]

FullSimplify[π-3 π u+(1/2) (-5+8 (Sqrt[-2+u])-u) (1+u)-8 (Sqrt[u]) ArcCsc[(Sqrt[2-(2/u)])]+4 (-1+3 u) ArcCsc[(Sqrt[-1+u])]+8((1/2)π-2ArcTan[(Sqrt[-2+u])])+8 (Sqrt[u]) ArcTan[(Sqrt[(-2+u) u])]]

Plot[expr=(1/2) (-5+6 π+8 (Sqrt[-2+u])-u) (1+u)-8 (Sqrt[u]) ArcCsc[(Sqrt[2-(2/u)])]+(4-12 u) ArcSec[(Sqrt[-1+u])]-16 ArcTan[(Sqrt[-2+u])]+8 (Sqrt[u]) ArcTan[(Sqrt[(-2+u) u])],{u,2,3}]

expr=(1/2) (-5+6 π+8 (Sqrt[-2+u])-u) (1+u)-8 (Sqrt[u]) ArcCsc[(Sqrt[2-(2/u)])]+(4-12 u) ArcSec[(Sqrt[-1+u])]-16 ArcTan[(Sqrt[-2+u])]+8 (Sqrt[u]) ArcTan[(Sqrt[(-2+u) u])]

Solve[-1+u==1+(x^2),x]

Plot[ArcSec[(Sqrt[-1+u])]-ArcTan[(Sqrt[u-2])],{u,2,3}]

expr=(1/2) (-5+6 π+8 (Sqrt[-2+u])-u) (1+u)-8 (Sqrt[u]) ArcCsc[(Sqrt[2-(2/u)])]+(4-12 u)ArcTan[(Sqrt[u-2])]-16 ArcTan[(Sqrt[-2+u])]+8 (Sqrt[u]) ArcTan[(Sqrt[(-2+u) u])]

FullSimplify[expr]

expr=(1/2) (-5+6 π+8 (Sqrt[-2+u])-u) (1+u)-8 (Sqrt[u]) ArcCsc[(Sqrt[2-(2/u)])]-12 (1+u) ArcTan[(Sqrt[-2+u])]+8 (Sqrt[u]) ArcTan[(Sqrt[(-2+u) u])]

Plot[expr,{u,2,3}]

Pieces

f[u_]:=Piecewise[{
{f11[u],0≤u≤1},
{f1221[u],1<u<2},
{f22[u],2<u<3}
}]
g[u_]:=2u f[u^2]

Plot[#[u],{u,0,3}]&/@{f11,f12,f21,f22}

FullSimplify[g[u],0<u<(Sqrt[3])]//InputForm

FullSimplify[g[l],0<l<(Sqrt[3])]//TraditionalForm

2((1/2) ((l^2)+1) (-(l^2)+8 (Sqrt[(l^2)-2])+6 π-5)-12 ((l^2)+1) (tan^(-1))((Sqrt[(l^2)-2]))+8 l (tan^(-1))(l (Sqrt[(l^2)-2]))-8 l (csc^(-1))((Sqrt[2-(2/(l^2))])))//Expand//FullSimplify

j[l_]:=Piecewise[{{2*l*
(-(1/2))*l*(l*((l - 8)*l + 6*Pi) - 4*Pi), l <= 1}, 
    {2*l*(l^4 + (3 - 8*Sqrt[l^2 - 1])*l^2 - 4*Sqrt[l^2 - 1] + 12*l^2*ArcSec[l] - 
      4*Pi*l + 3*Pi - 1/2), 1 < l^2 < 2}, 
    {2*l*((1/2)*(l^2 + 1)*(-l^2 + 8*Sqrt[l^2 - 2] + 6*Pi - 5) - 
      12*(l^2 + 1)*ArcTan[Sqrt[l^2 - 2]] + 8*l*ArcTan[l*Sqrt[l^2 - 2]] - 
      8*l*ArcCsc[Sqrt[2 - 2/l^2]]), l^2 > 2}}]

Plot[j[l],{l,0,(Sqrt[3])},Exclusions->(Sqrt[2])]

FullSimplify[j[l],0<l<(Sqrt[3])]/.l->l/a//InputForm

FullSimplify[Integrate[g[v],{v,0,u},Assumptions->0<u<(Sqrt[3])],0<u<(Sqrt[3])]

Limit[%312,u->(Sqrt[3])]//FullSimplify

%312/.u->(Sqrt[3])

Plot[%305,{u,0,(Sqrt[3])},Exclusions->None]

d[u_]:=Piecewise[{{(1/30)*(40*Pi*u^3 - 45*Pi*u^4 + 48*u^5 - 5*u^6), Inequality[0, Less, u, LessEqual, 1]}, 
   {(1/30)*(3 - 15*Pi - 15*u^2 + 90*Pi*u^2 - 80*Pi*u^3 + 45*u^4 + 10*u^6 + 24*Sqrt[-1 + u^2] - 108*u^2*Sqrt[-1 + u^2] - 
      96*u^4*Sqrt[-1 + u^2] + 180*u^4*ArcSec[u]), Inequality[1, Less, u, LessEqual, Sqrt[2]]}}, 
  (1/30)*(27 - 165*Pi - 75*u^2 + 30*Pi*u^2 - 45*u^4 - 45*Pi*u^4 - 5*u^6 + 12*Sqrt[-2 + u^2] + 108*u^2*Sqrt[-2 + u^2] + 
    48*u^4*Sqrt[-2 + u^2] + 240*u^2*ArcCot[Sqrt[-2 + u^2]] - 160*u^3*ArcCsc[Sqrt[2 - 2/u^2]] - 180*ArcCsc[Sqrt[-1 + u^2]] - 
    120*u^2*ArcCsc[Sqrt[-1 + u^2]] + 180*u^4*ArcCsc[Sqrt[-1 + u^2]] - 240*ArcTan[(-2 + u)/Sqrt[-2 + u^2]] + 
    240*ArcTan[(2 + u)/Sqrt[-2 + u^2]] + 360*ArcTan[Sqrt[-2 + u^2]] - 240*u^2*ArcTan[Sqrt[-2 + u^2]] + 160*u^3*ArcTan[u*Sqrt[-2 + u^2]])]

d[u]//TraditionalForm

FullSimplify[d[u],0<u<(Sqrt[3])]/.u->l/a//InputForm

Plot

MakeBoxes[cdf[x_],TraditionalForm]:=RowBox[{"D","(",MakeBoxes[x,TraditionalForm],")"}]

GraphicsGrid[{{Plot[j[u],{u,0,(Sqrt[3])},PlotStyle->{Red},Exclusions->None,AxesLabel->{l,P[l]}],
Plot[d[u],{u,0,(Sqrt[3])},PlotStyle->{Red},Exclusions->None,AxesLabel->{l,cdf[l]//TraditionalForm}]}},ImageSize->400,Spacings->-30]

Moments

NIntegrate[g[u],{u,0,(Sqrt[3])}]

Integrate[g[u],{u,0,(Sqrt[3])}]

NIntegrate[u g[u],{u,0,(Sqrt[3])}]

Table[Integrate[(u^(2n-1)) g[u],{u,0,(Sqrt[3])}],{n,5}]//FullSimplify//Together//Column

(s=Table[Integrate[(u^(2n)) g[u],{u,0,(Sqrt[3])}],{n,0,10}])//Timing

N[{(1/2),(11/30),(211/630),(187/525),(5899/13860),(3524083/6306300)}]

nd=Through[{Numerator,Denominator}[s]]

FindSequenceFunction[nd[[1]]]

FindSequenceFunction[nd[[2]]]

Integrate[(u^n) g[u],{u,0,(Sqrt[3])},Assumptions->n>0]

Integrate[(u^n) g[u],{u,0,1},Assumptions->n>0]

m=Integrate[(u^n) g[u],{u,1,(Sqrt[2])},Assumptions->n>0]

...wrong...

m/.n->2

PiecewiseExpand[g[u],(Sqrt[2])<u<(Sqrt[3])]

Integrate[(u^n) PiecewiseExpand[g[u],(Sqrt[2])<u<(Sqrt[3])],{u,(Sqrt[2]),(Sqrt[3])},Assumptions->n>0]

Integrate[2 (u^(1+n)) ((1/2) (1+(u^2)) 12 (1+(u^2)) ArcTan[(Sqrt[-2+(u^2)])]),u,Assumptions->n>0]

Integrate[(u^n) PiecewiseExpand[g[u],(Sqrt[2])<u<(Sqrt[3])],u]

e[n_]:=((π+(1/2)+(2-3π)(2^(n+1))+(3π-(5/2))(3^(n+1)))/(n+1))+((-3(1+2π)+3(2+π)(2^(n+2))-3(1+π)(3^(n+2)))/(n+2))+((-(3/2)+(3/2)(2^(n+3))-(1/2)(3^(n-3)))/(n+3))+((4π)/(2n+3))+((6π)/(2n+4))+(8/(2n+5))+((6 (Beta[(1/2),-(3/2)-n,(1/2)]-Beta[1,-(3/2)-n,(1/2)]))/(2+n))-4Integrate[(1/(z(Sqrt[z-1])))(u^n)(((u-z))^(1/2)),{z,1,2},{u,z,z+1}]-(16/3)Hypergeometric2F1[-n,(3/2),(5/2),-1]-(8/3)Hypergeometric2F1[-n-1,(3/2),(5/2),-1]-(8/5)Hypergeometric2F1[-n,(5/2),(7/2),-1]+(16/3)(2^n)Hypergeometric2F1[-n,(3/2),(5/2),-(1/2)]+(4/5)(2^n)Hypergeometric2F1[-n,(5/2),(7/2),-(1/2)]+(((2^(n+4))(Sqrt[2]))/(n+1))AppellF1[(1/2),n+(3/2),-n-1,(3/2),(1/2),(1/4)]+3π (2^(n-1))AppellF1[1,-n,n+3,2,(1/4),(1/2)]+((12 (2^(n+1))(Sqrt[2]))/(n+2))AppellF1[(1/2),n+(5/2),-n-2,(3/2),(1/2),(1/4)]-((12 (2^n)(Sqrt[2]))/(n+1))AppellF1[(1/2),n+(3/2),-n-1,(3/2),(1/2),(1/4)]

-(24/(2n+4))Integrate[(1/((Cos[θ])^(2n+4))),{θ,0,(π/4)}]//FullSimplify

-4Integrate[(1/(z(Sqrt[z-1])))(u^n)(((u-z))^(1/2)),{z,1,2},{u,z,z+1},Assumptions->n>0]

With[{n=0},-4Integrate[(1/(z(Sqrt[z-1])))(u^n)(((u-z))^(1/2)),{z,1,2},{u,z,z+1}]]

e[0.]

e[2.]

Comparison of 5th Integral Across Versions

int4=(1/120) (16 (Sqrt[1+(((y1-y2))^2)])+72 (y1^2) (Sqrt[1+(((y1-y2))^2)])-64 (y1^4) (Sqrt[1+(((y1-y2))^2)])+8 (Sqrt[2+(((y1-y2))^2)])-72 (y1^2) (Sqrt[2+(((y1-y2))^2)])+32 (y1^4) (Sqrt[2+(((y1-y2))^2)])+32 (y1^4) (Sqrt[(((y1-y2))^2)])-144 y1 (Sqrt[1+(((y1-y2))^2)]) y2+256 (y1^3) (Sqrt[1+(((y1-y2))^2)]) y2+144 y1 (Sqrt[2+(((y1-y2))^2)]) y2-128 (y1^3) (Sqrt[2+(((y1-y2))^2)]) y2-128 (y1^3) (Sqrt[(((y1-y2))^2)]) y2+72 (Sqrt[1+(((y1-y2))^2)]) (y2^2)-384 (y1^2) (Sqrt[1+(((y1-y2))^2)]) (y2^2)-72 (Sqrt[2+(((y1-y2))^2)]) (y2^2)+192 (y1^2) (Sqrt[2+(((y1-y2))^2)]) (y2^2)+192 (y1^2) (Sqrt[(((y1-y2))^2)]) (y2^2)+256 y1 (Sqrt[1+(((y1-y2))^2)]) (y2^3)-128 y1 (Sqrt[2+(((y1-y2))^2)]) (y2^3)-128 y1 (Sqrt[(((y1-y2))^2)]) (y2^3)-64 (Sqrt[1+(((y1-y2))^2)]) (y2^4)+32 (Sqrt[2+(((y1-y2))^2)]) (y2^4)+32 (Sqrt[(((y1-y2))^2)]) (y2^4)-80 (((y1-y2))^3) ArcTan[(1/((Sqrt[2+(((y1-y2))^2)]) (y1-y2)))]+80 (((y1-y2))^3) ArcTan[((1-(Sqrt[2+(((y1-y2))^2)])+(((y1-y2))^2))/(y1-y2))]-80 (y1^3) ArcTan[y1-y2]+240 (y1^2) y2 ArcTan[y1-y2]-240 y1 (y2^2) ArcTan[y1-y2]+80 (y2^3) ArcTan[y1-y2]-10 Log[-1+(Sqrt[1+(((y1-y2))^2)])]-60 (y1^2) Log[-1+(Sqrt[1+(((y1-y2))^2)])]-30 (y1^4) Log[-1+(Sqrt[1+(((y1-y2))^2)])]+120 y1 y2 Log[-1+(Sqrt[1+(((y1-y2))^2)])]+120 (y1^3) y2 Log[-1+(Sqrt[1+(((y1-y2))^2)])]-60 (y2^2) Log[-1+(Sqrt[1+(((y1-y2))^2)])]-180 (y1^2) (y2^2) Log[-1+(Sqrt[1+(((y1-y2))^2)])]+120 y1 (y2^3) Log[-1+(Sqrt[1+(((y1-y2))^2)])]-30 (y2^4) Log[-1+(Sqrt[1+(((y1-y2))^2)])]+30 (y1^4) Log[1+(Sqrt[1+(((y1-y2))^2)])]-120 (y1^3) y2 Log[1+(Sqrt[1+(((y1-y2))^2)])]+180 (y1^2) (y2^2) Log[1+(Sqrt[1+(((y1-y2))^2)])]-120 y1 (y2^3) Log[1+(Sqrt[1+(((y1-y2))^2)])]+30 (y2^4) Log[1+(Sqrt[1+(((y1-y2))^2)])]-30 Log[-1+(Sqrt[2+(((y1-y2))^2)])]-180 (y1^2) Log[-1+(Sqrt[2+(((y1-y2))^2)])]+60 (y1^4) Log[-1+(Sqrt[2+(((y1-y2))^2)])]+360 y1 y2 Log[-1+(Sqrt[2+(((y1-y2))^2)])]-240 (y1^3) y2 Log[-1+(Sqrt[2+(((y1-y2))^2)])]-180 (y2^2) Log[-1+(Sqrt[2+(((y1-y2))^2)])]+360 (y1^2) (y2^2) Log[-1+(Sqrt[2+(((y1-y2))^2)])]-240 y1 (y2^3) Log[-1+(Sqrt[2+(((y1-y2))^2)])]+60 (y2^4) Log[-1+(Sqrt[2+(((y1-y2))^2)])]+10 Log[1+(((y1-y2))^2)]+60 (y1^2) Log[1+(((y1-y2))^2)]-120 y1 y2 Log[1+(((y1-y2))^2)]+60 (y2^2) Log[1+(((y1-y2))^2)]-5 Log[2+2 (Sqrt[1+(((y1-y2))^2)])+(((y1-y2))^2)]-30 (y1^2) Log[2+2 (Sqrt[1+(((y1-y2))^2)])+(((y1-y2))^2)]+30 (y1^4) Log[2+2 (Sqrt[1+(((y1-y2))^2)])+(((y1-y2))^2)]+60 y1 y2 Log[2+2 (Sqrt[1+(((y1-y2))^2)])+(((y1-y2))^2)]-120 (y1^3) y2 Log[2+2 (Sqrt[1+(((y1-y2))^2)])+(((y1-y2))^2)]-30 (y2^2) Log[2+2 (Sqrt[1+(((y1-y2))^2)])+(((y1-y2))^2)]+180 (y1^2) (y2^2) Log[2+2 (Sqrt[1+(((y1-y2))^2)])+(((y1-y2))^2)]-120 y1 (y2^3) Log[2+2 (Sqrt[1+(((y1-y2))^2)])+(((y1-y2))^2)]+30 (y2^4) Log[2+2 (Sqrt[1+(((y1-y2))^2)])+(((y1-y2))^2)]+5 Log[3+2 (Sqrt[2+(((y1-y2))^2)])+(((y1-y2))^2)]+30 (y1^2) Log[3+2 (Sqrt[2+(((y1-y2))^2)])+(((y1-y2))^2)]-30 (y1^4) Log[3+2 (Sqrt[2+(((y1-y2))^2)])+(((y1-y2))^2)]-60 y1 y2 Log[3+2 (Sqrt[2+(((y1-y2))^2)])+(((y1-y2))^2)]+120 (y1^3) y2 Log[3+2 (Sqrt[2+(((y1-y2))^2)])+(((y1-y2))^2)]+30 (y2^2) Log[3+2 (Sqrt[2+(((y1-y2))^2)])+(((y1-y2))^2)]-180 (y1^2) (y2^2) Log[3+2 (Sqrt[2+(((y1-y2))^2)])+(((y1-y2))^2)]+120 y1 (y2^3) Log[3+2 (Sqrt[2+(((y1-y2))^2)])+(((y1-y2))^2)]-30 (y2^4) Log[3+2 (Sqrt[2+(((y1-y2))^2)])+(((y1-y2))^2)]+10 Log[(((y1-y2))^2)]+60 (y1^2) Log[(((y1-y2))^2)]-30 (y1^4) Log[(((y1-y2))^2)]-120 y1 y2 Log[(((y1-y2))^2)]+120 (y1^3) y2 Log[(((y1-y2))^2)]+60 (y2^2) Log[(((y1-y2))^2)]-180 (y1^2) (y2^2) Log[(((y1-y2))^2)]+120 y1 (y2^3) Log[(((y1-y2))^2)]-30 (y2^4) Log[(((y1-y2))^2)]);

v4.2

i4=Simplify[Integrate[int4,y1]]

Table[D[i4,y1]-int4/.{y1->Random[],y2->Random[]},{1000}]//Chop//Union

Plot3D[i4,{y1,0,1},{y2,0,1},PlotRange->All,PlotPoints->50,Mesh->False]

v6

i6=Simplify[Integrate[int4,y1]]

Table[D[i6,y1]-int4/.{y1->Random[Complex],y2->Random[Complex]},{50}]//Chop//Union

<<PSDirect`

Plot3D[i6,{y1,0,1},{y2,0,1},PlotRange->All,PlotPoints->50,Mesh->False]