Suppose I have defined a numerical function
F[x] that for each entry
x, it takes a long time to calculate.
Suppose that now I want to define a new function using the previous one, say,
G[x_] := F[x]^2 + 2*F[x] + 1.
My first question is, does Wolfram Mathematica calculate twice the value of
F[x] to use it in
G[x]? that is, first calculate the
F[x]^2 and then the
F[x] for the
And if this is the case, how could I improve the way I define
G[x] so that it only calculates