Ask Your Question

petkus's profile - activity

2016-07-20 02:06:30 -0500 commented answer Unable to create a contour_plot of a system of inequalities

Thanks! It turns out the problem wasn't with what the function returned but with the inequalities. I set f1 < -1e-3, f2 < -1e-3, f3 < -1e-3 and it works how I wanted. This is a very strange bug that really makes sage a black box to me :(

2016-07-18 06:08:15 -0500 received badge  Student (source)
2016-07-16 14:50:18 -0500 asked a question Unable to create a contour_plot of a system of inequalities

I am trying to plot a system of inequalities, dependent on a matrix H. Here is my function I am planning to contour_plot:

def reg(x, y):
    f1 = H[0,0] * H[0,0] * x + H[1,0] * H[1,0] * y
    f2 = H[0,0] * H[0,1] * x + H[1,0] * H[1,1] * y
    f3 = H[0,1] * H[0,1] * x + H[1,1] * H[1,1] * y
    if f1 < 0 or f2 < 0 or f3 < 0:
        return 0
    else:
        return 1

I then have H be

> H
>  [2.220446049250313e-16   -0.9999999999999998]
>  [  -0.9999999999999998 2.220446049250313e-16]

However

contour_plot(reg, (x,-Integer(5),Integer(5)), (y,-Integer(5),Integer(5)))

yields an error. It says

zero-size array to reduction operation minimum which has no identity

The strange part is that when

> H
>  [-1 0]
>  [ 0 1]

the same contour_plot yields exactly what I want without any errors
Help would be much appreciated, I have just picked up SAGE this week and have much to learn