I have created a table Tv
where each row is of the form
{x, y, Iv[x,y]}
where Iv
is some complicated numerical integral and x
and y
iterate through some parameter space. The issue I am facing now is that for some values of x
and y
, Iv[x,y]
failed to evaluate. Since these are only a few cases, I would like to continue working with the rest of the data. Unfortunately, however, when I try to print or save Tv
, mathematica tries to re-evaluate the cells that failed before, which takes many hours (and, of course, they fail again).
So my question is: Can I remove all rows of Tv
with non-numeric entries in the third column without re-evaluating these cells?
Edit:
Here is integral that gives me troubles:
kernel[x_, xp_, p_, d_] :=
2 Sqrt[x^2 + xp^2 - 2 x xp Cos[p]] -
2 Sqrt[d^-2 + x^2 + xp^2 - 2 x xp Cos[p]] -
1/2 d^-1 (Log[x^2 + xp^2 - 2 x xp Cos[p]] +
Log[-d^-1 + Sqrt[d^-2 + x^2 + xp^2 - 2 x xp Cos[p]]] -
3 Log[d^-1 + Sqrt[d^-2 + x^2 + xp^2 - 2 x xp Cos[p]]])
rdivM[x_, x0_] :=
x (-1 + (4 Sinh[x]^2)/(Cosh[2 x] + Cosh[2 x0])) (Sech[x - x0] +
Sech[x + x0]) + 4 Cosh[x0] Sinh[x]/(Cosh[2 x] + Cosh[2 x0])
Iv[x0_, d_] :=
2 NIntegrate[
rdivM[x, x0] rdivM[xp, x0] kernel[x, xp, p, d], {x,
Max[0, x0 - 50], x0 + 50}, {xp, Max[0, x0 - 50], x}, {p, 0, Pi},
PrecisionGoal -> 6,
Method -> {"GlobalAdaptive", "MaxErrorIncreases" -> 100000}]
and the evaluation:
x0List = {0, 0.1, 0.2, 0.3, 0.5, 0.7, 1, 1.5, 2, 2.5, 3, 4, 5, 7, 10,
15, 20, 35, 50, 75, 100, 150, 200};
logdList = Range[-4, 4, 1/10];
Tdv = ConstantArray[0, {Length[x0List]*Length[logdList], 3}];
SetSharedVariable[Tdv];
n = 0;
SetSharedVariable[n];
ParallelDo[Tdv[[d + r Length[logdList] + 1, 1]] = x0List[[r + 1]];
Tdv[[d + r Length[logdList] + 1, 2]] = N[10^logdList[[d + 1]]];
Tdv[[d + r Length[logdList] + 1, 3]] =
Re[Iv[N[x0List[[r + 1]]], N[10^logdList[[d + 1]]]]]; n++;
Print[n], {r, 0, Length[x0List] - 1}, {d, 0, Length[logdList] - 1}]
The evaluation will take many hours, but you can abort after a the first error messages. Then just try to print Tdv
.
If[]
andNothing
for this. $\endgroup$Tv
has lead to a re-evaluation of failed cells. $\endgroup$