# Is there a IsDefinedQ function? [duplicate]

I have a function which is a bit expensive to calculate. I want to translate and integrate. I want to translate by values on a grid, store the values of the integral and refine the grid. That is, I want to run this:

 Table[
f2[{c, d}] = NIntegrate[f1[{a - c Sqrt/2, b - d}], Element[{a, b}, hex]],
{c, 0, 3, 1/2^n}, {d, 0, 3, 1/2^n}]


for increasing values of n, but without recalculating previously calculated values, ie don't recalculate f2[{c/2^m,d/2^m}] for m < n.

To do this I'd like to write

Table[
If[!IsDefinedQ[f2[{c,d}], f2[{c, d}] = NIntegrate[f1[{a - c Sqrt/2, b -       d}], Element[{a, b}, hex]]],
{c, 0, 3, 1/2^n}, {d, 0, 3, 1/2^n}]


Does a function as IsDefinedQ exist? Do I have a misunderstanding of the what f2[{0,2}] really means in mathematica? Can anybody see a better way to refine such evaluation without reevaluation?

## marked as duplicate by Mr.Wizard♦Aug 14 '15 at 1:15

• What is hex? Further, you do not need to have the part f2[{c, d}] = in your table. Last, It may be a good idea to give your function (is it f1 or f2?). If it is much too complex, invent a simple one, that shares the main properties with the real one. Then, n should be somehow defined. – Alexei Boulbitch Aug 13 '15 at 14:21
• Maybe ValueQ will do the trick? – mfvonh Aug 13 '15 at 14:42
• Note the literal question is not a duplicate. ValueQ does not work because its argument is first evaluated. ( I suspect you need to parse the results of DownValues ) – george2079 Aug 13 '15 at 15:33
• isDefinedQ[f_, args_] := MemberQ[(First@Cases[#[], f[x__] :> {x}]) & /@ DownValues[f] , args] (Obviously you would not use this for the present problem) – george2079 Aug 13 '15 at 15:38