Ask Your Question

Cosmos's profile - activity

2021-04-28 02:16:17 +0200 received badge  Taxonomist
2017-09-04 22:26:29 +0200 received badge  Notable Question (source)
2016-07-05 16:47:46 +0200 received badge  Student (source)
2016-07-04 14:10:04 +0200 received badge  Famous Question (source)
2015-03-12 12:18:35 +0200 received badge  Popular Question (source)
2015-01-22 21:32:08 +0200 received badge  Notable Question (source)
2014-06-29 20:56:33 +0200 received badge  Famous Question (source)
2014-06-29 20:56:33 +0200 received badge  Notable Question (source)
2014-06-29 20:56:33 +0200 received badge  Popular Question (source)
2014-04-29 10:54:23 +0200 received badge  Popular Question (source)
2012-07-12 06:58:12 +0200 commented question sage crashes while interpolating

I didn't see your comment earlier. The binary version of sage was upgraded today and after this the problem i had was gone. Now however big the matrix is it doesn't crash. EDIT: It finally crashed again in sage 5.1

2012-07-11 09:29:36 +0200 asked a question sage crashes while interpolating
f_interpolation = scipy.interpolate.interp2d(*zip(*matrix(A)),kind='cubic')
               plot_interpolation = contour_plot(lambda x,y:
                   f_interpolation(x,y)[0], (22.423,22.439),(37.07,37.08) ,cmap='jet', contours=numpy.arange(0,1400,100), colorbar=True)

               plot_all = plot_interpolation

     ,axes_labels=["m", "m"])

I am running this command to interpolate the data contained in matrix(A). matrix(A) is 1800 x 3 dense matrix over Real Double Field. Sage crashes everytime i do this both in a quad core Amd with 8GB of ram(kubuntu 12.04 64bit, in both the binary and compiled from source versions) and a netbook Lenovo s9e with Intel Atom and 1GB of ram(kubuntu 12.04 32bit, binary version of sage).It returns this message:

/home/user/Sage/sage-5.0.1/local/lib/ ...
2012-07-09 20:44:52 +0200 received badge  Editor (source)
2012-07-09 14:58:42 +0200 asked a question scipy.interpolate.interp2d multivariate interpolation and list alignement

Given a set of (x[i],y[i],Value[i]) we can create a list or tuple and plot them with the command list_plot3d. In this way we take a 3d plot where in fact the z-axis corresponds to the value of an f(x,y). Instead of doing this, it appears that with scipy.interpolate.interp2d it is possible to avoid using the list_plot3d and create a contour-density kind of plot. As shown in the link it is feasible to do this but the fact is that it is too complicated to understand for a beginner like me. Is possible to explain this just to the simple point that someone takes the tuple and tries to create a contour-like plot?


It seems that the part of the code below is enough to make a contour plot:

import numpy, scipy.interpolate 
f_interpolation = scipy.interpolate.interp2d(*zip(*data))
plot_interpolation = contour_plot(lambda x,y:
                   f_interpolation(x,y)[0], (30,40), (20,30), cmap='jet', contours=numpy.arange(0.1,30,5), colorbar=True)

Notice on the second line that it refers to some data obviously given before this part of the code. I found out that for this code to work one has to have fully aligned data to feed to the code above.


           ( 37.850629,  5.421135, 22.162571637111411),
           ( 37.706629,  0.421472,  5.229876952864690),
           (  7.706629, 28.421472, 15.229876952864690),

If in any way the data that might be a tuple, or a list from what i understand, are not formatted as above, the code doesn't run. How is it possible to right align all elements as well as keep them aligned in relation to the decimal place in a list?

2012-07-07 18:07:06 +0200 received badge  Supporter (source)
2012-07-07 18:06:57 +0200 commented question Using solve() to find positive real solutions to a complex equation

Is there any kind of workaround to at least remove automatically the complex solutions from the solutions so the don't mix with real roots? For example i was trying to make a list of real solutions of an equation and half of the list finally came out to be complex numbers.

2012-07-06 14:54:10 +0200 asked a question generate_plot_points for multiple variable functions and contour_plot

Is there a default sage function to generate all (x,y,f(x,y)) values the program uses to draw a multivariable function or the contours of let's say a f(x,y)=C ? I am new to sage and could only find that generate_plot_points works only for one variable functions.

Example from documentation:

sage: from sage.plot.plot import generate_plot_points
sage: generate_plot_points(sin, (0, pi), plot_points=2, adaptive_recursion=0)

I guess one could solve symbolically let's say a contour equation and then create the values i talk about like discussed here:

sage: var('x,y')
(x, y)
sage: solve(y^2 - x^3 - x == 0, [y])
[y == -sqrt(x)*sqrt(x^2 + 1), y == sqrt(x)*sqrt(x^2 + 1)]

then just plot each of those two above and combine them. But this could become really cumbersome since one could have a terribly complicated equation. So can this be done currently or someone needs a workaround to achieve this? excuse my english :)

2012-07-05 03:39:03 +0200 commented answer get coordinates and function value as list

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.

2012-07-04 16:32:33 +0200 asked a question get coordinates and function value as list

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.