# How to calculate a continuous function once and access values later?

I have a function that involves a numerical calculation:

h[v_]:=NIntegrate[f[x]*Log[p[x, v]], {x, -Infinity, Infinity}]


I need to visualize how well a bunch of other functions of v match h[v], so I'm doing a lot of this:

Plot[g1[v]-h[v],{v,0,2}]
Plot[g2[v]-h[v],{v,0,2}]
Plot[g3[v]-h[v],{v,0,2}]


Is there a good way to somehow record h[v] so that I'm not calculating it over and over and over for all those v's?

And I need to make plots on-the-fly as new functions get generated, so I can't put them all in a list together and do this:

{g1[v],g2[v],g3[v]}-h[v]

• Interpolation ? – Michael E2 Apr 13 '16 at 3:18
• FunctionsThatRememberValuesTheyHaveFound – chuy Apr 13 '16 at 13:05
• @MichaelE2 Yes, I could code up an interpolation scheme, but I was hoping something a little more elegant and accurate was possible, perhaps even built in. – Jerry Guern Apr 13 '16 at 19:17