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:


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:

  • 2
    $\begingroup$ Interpolation ? $\endgroup$ – Michael E2 Apr 13 '16 at 3:18
  • $\begingroup$ FunctionsThatRememberValuesTheyHaveFound $\endgroup$ – chuy Apr 13 '16 at 13:05
  • $\begingroup$ @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. $\endgroup$ – Jerry Guern Apr 13 '16 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.