First time here? Check out the FAQ!

Ask Your Question
0

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

asked 10 years ago

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,

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
0

answered 10 years ago

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='^')
Preview: (hide)
link

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 ( 10 years ago )
0

answered 10 years ago

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.

Preview: (hide)
link

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: 10 years ago

Seen: 987 times

Last updated: Mar 20 '15