ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 20 Mar 2015 17:58:21 -0500Plotting f(1),f(2),f(3),...?https://ask.sagemath.org/question/26267/plotting-f1f2f3/Hi, everyone.
I am new to this, and only just beginning to use this stuff.
I want to define a function, and see how it behaves. It's a function of natural numbers. How can I plot it (say, f(1),f(2),f(3),...) on the xy-plane?
Best regards,
Fri, 20 Mar 2015 10:08:39 -0500https://ask.sagemath.org/question/26267/plotting-f1f2f3/Answer by Eugene for <p>Hi, everyone.</p>
<p>I am new to this, and only just beginning to use this stuff.
I want to define a function, and see how it behaves. It's a function of natural numbers. How can I plot it (say, f(1),f(2),f(3),...) on the xy-plane?</p>
<p>Best regards,</p>
https://ask.sagemath.org/question/26267/plotting-f1f2f3/?answer=26275#post-id-26275See [2D Plotting](http://www.sagemath.org/doc/reference/plotting/sage/plot/plot.html), consider [plot](http://www.sagemath.org/doc/reference/plotting/sage/plot/plot.html#sage.plot.plot.plot) and [line](http://www.sagemath.org/doc/reference/plotting/sage/plot/line.html#sage.plot.line.line).
It may be more comfortable to first calculate your data points (as an numpy array, or a list of tuples) and then try to visualize them using different methods from plotting examples and docs.Fri, 20 Mar 2015 17:58:21 -0500https://ask.sagemath.org/question/26267/plotting-f1f2f3/?answer=26275#post-id-26275Answer by kcrisman for <p>Hi, everyone.</p>
<p>I am new to this, and only just beginning to use this stuff.
I want to define a function, and see how it behaves. It's a function of natural numbers. How can I plot it (say, f(1),f(2),f(3),...) on the xy-plane?</p>
<p>Best regards,</p>
https://ask.sagemath.org/question/26267/plotting-f1f2f3/?answer=26268#post-id-26268Here is one example.
f(n)=n^2
list_plot([f(i) for i in range(10)])
But there are many, many ways to do this. For instance, if you are plotting a function that returns an ordered pair, then this might be appropriate.
f(n)=(n,2*n)
points([f(i) for i in range(10)],marker='^')Fri, 20 Mar 2015 10:42:52 -0500https://ask.sagemath.org/question/26267/plotting-f1f2f3/?answer=26268#post-id-26268Comment by Kim for <p>Here is one example.</p>
<pre><code>f(n)=n^2
list_plot([f(i) for i in range(10)])
</code></pre>
<p>But there are many, many ways to do this. For instance, if you are plotting a function that returns an ordered pair, then this might be appropriate.</p>
<pre><code>f(n)=(n,2*n)
points([f(i) for i in range(10)],marker='^')
</code></pre>
https://ask.sagemath.org/question/26267/plotting-f1f2f3/?comment=26269#post-id-26269Thanks. Actually my function is recursive, so I should plot (1,f(1)), then compute f(2) using f(1), and then plot (2,f(2)), and so on. But, I get the idea.Fri, 20 Mar 2015 10:59:55 -0500https://ask.sagemath.org/question/26267/plotting-f1f2f3/?comment=26269#post-id-26269