# I How to word a 3D function?

Tags:
1. Mar 19, 2016

### Ben Wilson

I have, say, an ellipse in the x-y plane: (x^2/a^2) + (y^2/b^2) = 1

I want a 3d (e.g. z) function where inside the ellipse z=+1, outside z=0; the function is not continuous.

so in effect what I'm left with is a large plane where z= 0, and a small ellipse cut out raised to z=1.

How do I write what I want in terms that i can implement it in computations.

%this problem comes from describing quantum dots in 2 and 3 dimensions.

2. Mar 19, 2016

### Staff: Mentor

$$f(x, y) = \begin{cases} 1, & \frac{x^2}{a^2} + \frac{y^2}{b^2} \le 1 \\ 0, & \frac{x^2}{a^2} + \frac{y^2}{b^2} > 1\end{cases}$$

3. Mar 19, 2016

### Ben Wilson

that looks perfect tbh. Do you have any idea how i could implement that into a program?
for instance if i have two vectors representing my x and y space, how would i go about describing this function in matlab or fortran or something?

4. Mar 19, 2016

### Staff: Mentor

Your vectors are really points in the x-y plane. For a given point (x, y), calculate $b^2x^2 + a^2y^2$. If this is greater than $a^2b^2$, your function should return 0. Otherwise, it should return 0.

5. Mar 19, 2016

### Ben Wilson

thanks you have been an amazing help