# get coordinates and function value as list

 0 I am quite new in sage as well as in programming, so please if you explain this, please do it thouroughly. Let's assume we have a simple function like F(x,y)=x+y. Is it possible to create a list, something like (x,y,F)? To make clearer a list in the form of (value_of_x_coordinate,value_of_y_coordinate,value_of_function) for instance (1,1,2) or (1,2,3). If this is possible, how can we transform the coordinates x,y by operating somehow on the list e.g adding on both x and y, a number N. asked Jul 04 '12 Cosmos 1 ● 2

 1 List comprehension is a way of constructing lists that is very readable and concise. It mimics set builder notation from mathematics: f(x,y) = x + y L = [ (a, b, f(a, b)) for (a,b) in [ (0,0), (1,1), (5.6, 7.0) ] ]  or L = [ (a, b, f(a, b)) for a in range(10) for b in range(10) ]  try these out and see what they produce. You can now modify your list or add to it any way you want. For example: f(x,y) = x + y L = [ (a, b, f(a, b)) for (a,b) in [ (0,0), (1,1), (5.6, 7.0) ] ] print L[0] # prints (0,0,0) L[0] = (1,2, f(1,2)) print L[0] # prints (1,2,3) L.append((1.1, 1.2, f(1.1, 1.2))) print L[3]  posted Jul 04 '12 benjaminfjones 2470 ● 3 ● 33 ● 66 http://bfj7.com/ Thank you for your reply. I think now i can make a more general question on the subject.When we ask sage to plot a function doesn't it replace (x,y) with values,it gets the values of the function and then plots it? Is there a way instead of asking from the program to plot the values it just calculated, to just create a list or some other construct with all the values (so that we don't have to create it ourselves each time)? Something like x_coordinates_column,y_coordinates_column,Function_value_column. Let's use this example: We have a f(x,y)=sin(x)cos(y) and we want the contours sin(x)cos(y)=k where k is a real number we can change as we like. I would like to have a consrtuct as described above with x_values,y_values,k. Cosmos (Jul 05 '12)

[hide preview]