Example as following
g[x_]:=NIntegate[......];
f[x_]:=g[x]^2+g[x];
I need to have define f[x] through g[x], Does mathmetica NIntegrate g[x] twice when calculating f[x]? How to rewrite it to reduce calculation? My idea is to give the value of g[x] at some x to a variable and use it in f[x].
value=g[x];
f[x_]=value^2+value;
The value giving should be done inside f[x_]. How to build up the function definition in mathematica in such way?
Update:Update:
After a bit of study myself, the new code I write is:
g[x_] := NIntegate[......];
f[x_] = #^2 + # &[g[x]]
The function definition gives correct answer. Does it calculate g[x] once or twice in this way?