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[3]/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[3]/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?
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:21ValueQwill do the trick? – mfvonh Aug 13 '15 at 14:42ValueQdoes not work because its argument is first evaluated. ( I suspect you need to parse the results ofDownValues) – george2079 Aug 13 '15 at 15:33isDefinedQ[f_, args_] := MemberQ[(First@Cases[#[[1]], f[x__] :> {x}]) & /@ DownValues[f] , args](Obviously you would not use this for the present problem) – george2079 Aug 13 '15 at 15:38