Ask Your Question
0

Plotting f(1),f(2),f(3),...?

asked 2015-03-20 16:08:39 +0100

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

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,

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-03-20 16:42:52 +0100

kcrisman gravatar image

Here 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='^')
edit flag offensive delete link more

Comments

Thanks. 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.

Kim gravatar imageKim ( 2015-03-20 16:59:55 +0100 )edit
0

answered 2015-03-20 23:58:21 +0100

Eugene gravatar image

See 2D Plotting, consider plot and 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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2015-03-20 16:08:39 +0100

Seen: 736 times

Last updated: Mar 20 '15