1 | initial version |

I can't reproduce the error (4.7.1), but I can see at least one problem.

The way the scoping works, f(g1, g2) is evaluated *before* the plot is made, so your plot will be zero everywhere. Stick a "print g1,g2" inside the function to convince yourself this is true. You probably want "f" instead of "f(g1,g2)".

The following seems to work for me. Note that I've also changed it so that it returns 0 instead of None sometimes like your original code did-- if that's what you want, switch back.

```
var("g1 g2")
def f(g1, g2):
if g1*g2 > 0.0:
if abs(g2) < 1/abs(g1):
return sqrt(0.5*((1+g1*g2)*abs(g1+g2))/(sqrt((1.0-g1*g2)^3)*g1*g2))
return 0
z=contour_plot(f, (g1,-4,4), (g2,-4,4),plot_points=500, cmap='afmhot_r', colorbar=True, contours=srange(1,6,0.5))
show(z)
```

2 | No.2 Revision |

I can't reproduce the error (4.7.1), but I can see at least one problem.

The way the scoping works, f(g1, g2) is evaluated *before* the plot is made, so your plot will be zero (or maybe None) everywhere. Stick a "print g1,g2" inside the function to convince yourself this is true. You probably want "f" instead of "f(g1,g2)".

The following seems to work for me. Note that I've also changed it so that it returns 0 instead of None sometimes like your original code did-- if that's what you want, switch back.

```
var("g1 g2")
def f(g1, g2):
if g1*g2 > 0.0:
if abs(g2) < 1/abs(g1):
return sqrt(0.5*((1+g1*g2)*abs(g1+g2))/(sqrt((1.0-g1*g2)^3)*g1*g2))
return 0
z=contour_plot(f, (g1,-4,4), (g2,-4,4),plot_points=500, cmap='afmhot_r', colorbar=True, contours=srange(1,6,0.5))
show(z)
```

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.