0
$\begingroup$

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?

Mathematica Example

| improve this question | | | | |
$\endgroup$
  • 2
    $\begingroup$ Post your code not image. $\endgroup$ – zhk Jul 9 '17 at 16:21
  • 3
    $\begingroup$ Try this Plot[Evaluate@g[t, 1], {t, 0, 4}] $\endgroup$ – zhk Jul 9 '17 at 16:26
1
$\begingroup$
g[t_, 0] := -9.8*t^2 + 10

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

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}]
| improve this answer | | | | |
$\endgroup$
  • $\begingroup$ Great, thanks! This works. What is the underlying issue though? $\endgroup$ – libcrypt Jul 9 '17 at 16:33
  • 3
    $\begingroup$ Try evaluating Block[{t = 0.1}, g[t, 1]] vs Block[{t = 0.1}, Evaluate @ g[t, 1]] $\endgroup$ – Carl Woll Jul 9 '17 at 17:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.