1 | initial version |

I would also like to know true-sage approach, just in case here is a clumsy approach with loops and matplotlib:

```
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.pyplot import figure
from mpl_toolkits.mplot3d import axes3d
# Define
def f(x, y):
if not (-y <= x <= y):
return 0
else:
return x ** 2 + y ** 2
# Calculate
N = 512
y = np.linspace(0, 3, N)
x = np.linspace(-3, 3, N)
z = np.zeros((N, N))
for i, _x in enumerate(x):
for j, _y in enumerate(y):
z[i, j] = f(_x, _y)
# Plot
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.view_init(azim=140)
X, Y = np.meshgrid(x, y)
ax.plot_surface(X, Y, z)
plt.tight_layout()
plt.savefig('sage0.png')
plt.close()
```

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.