# Why can't I plot a recursively defined function without first expanding it? [closed]

I have a recursively-defined sequence of functions, g[t,n], that I cannot seem to plot without first evaluating and then referencing the result. What do I need to do to g to get it to plot correctly? ## closed as off-topic by zhk, Daniel Lichtblau, m_goldberg, MarcoB, garejJul 10 '17 at 9:19

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – zhk, Daniel Lichtblau, m_goldberg, MarcoB, garej
If this question can be reworded to fit the rules in the help center, please edit the question.

• Post your code not image. – zhk Jul 9 '17 at 16:21
• Try this Plot[Evaluate@g[t, 1], {t, 0, 4}] – zhk Jul 9 '17 at 16:26

## 1 Answer

g[t_, 0] := -9.8*t^2 + 10

s[n_] := u /. Solve[g[u, n - 1] == 0, u][]

v[n_] := D[g[t, n - 1], t] /. (t -> s[n])

g[t_, n_] := -9.8*(t - s[n])^2 - v[n]/2*(t - s[n])

Plot[Evaluate@g[t, 1], {t, 0, 4}]

• Great, thanks! This works. What is the underlying issue though? – libcrypt Jul 9 '17 at 16:33
• Try evaluating Block[{t = 0.1}, g[t, 1]] vs Block[{t = 0.1}, Evaluate @ g[t, 1]] – Carl Woll Jul 9 '17 at 17:09