1
$\begingroup$

I want to graph a sequence g[n]. I tried:

{g[n_] := FindSequenceFunction[{5, 11, 19, 29}, n]
Plot[g[n],n,1,99999]}

But it did not work.

$\endgroup$
1
  • $\begingroup$ From this post it's hard to tell whether you had trouble finding the sequence, or plotting it. Consideration of that issue might lead to a better-formulated question, if not actual working code. $\endgroup$ Commented Sep 7, 2016 at 16:47

1 Answer 1

1
$\begingroup$

You forgot parentheses in the second argument of Plot:

g[n_] = FindSequenceFunction[{5, 11, 19, 29}, n] ;
Plot[g[n], {n, 1, 99999}]

Notice that I changed := to = such that the sequence function is found once, rather than every single time that Plot wants to evaluate g at a new sample point.

In order to plot for natural numbers only, use

DiscretePlot[g[n], {n, 1, 49}]
$\endgroup$
3
  • $\begingroup$ how to restrict domain to natural numbers. $\endgroup$
    – Theodor
    Commented Sep 7, 2016 at 16:48
  • $\begingroup$ @Theodor I edited the answer $\endgroup$
    – Coolwater
    Commented Sep 7, 2016 at 16:54
  • $\begingroup$ or ListPlot[g[n] /. n -> Range[20]] $\endgroup$
    – bill s
    Commented Sep 7, 2016 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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