In this question I want to specify a domain of $0<=x<=1$ and $0<=y<=1$ in the Z Math Surface (object menu Add > Math Function > Z Math Surface) for the equation. I also need it to exclude the imaginary result.

(y-x+1-((y-x+1)**2 -4*y if 4*y < (y-x+1)**2 else 0 )**(1/2) ) / 2

enter image description here

I tried ((y-x+1-((y-x+1)**2 -4*y if 4*y < (y-x+1)**2 else 0 )**(1/2) ) / (2)) if x >= 0 and x <= 1 and y >= 0 and y <= 1 else 0

And also tried (((y if y >= 0 and y <= 1 else 0)-(x if x >= 0 and x <= 1 else 0)+1-(((y if y >= 0 and y <= 1 else 0)-(x if x >= 0 and x <= 1 else 0)+1)**2 -4*(y if y >= 0 and y <= 1 else 0) if 4*(y if y >= 0 and y <= 1 else 0) < ((y if y >= 0 and y <= 1 else 0)-(x if x >= 0 and x <= 1 else 0)+1)**2 else 0 )**(1/2) ) / (2))

But nothing can get me the correct result as when I plot it with python which should look like this:

enter image description here

How do I tell Z Math Surface to use a range of values within $0<=x<=1$ and $0<=y<=1$ that automatically exclude the imaginary results? Is that even possible? It probably is not possible with the math surface functions? Perhaps possible with geometry nodes?

EDIT: Also tried XYZ Math Surface which will still necessitate an if/else statement to exclude the imaginary part and will also give a squarish result:

(v-u+1-((v-u+1)**2 -4*v if 4*v < (v-u+1)**2 else 0 )**(1/2)) / 2

enter image description here

If there is a Geometry Nodes solution please feel free to post it.


1 Answer 1


Unfortunately, Z Math Surface uses the X Size and Y Size parameters to set a symmetric range of $-X Size \le X \le X Size$ and $-Y Size \le Y \le Y Size$. See below for an ugly way to make this work, but here's a simpler way using XYZ Function surfaces:

Simple solution

You can accomplish what you want using an X, Y, Z Surface, by setting $X = U$, $Y = V$, and using the U Min, U Max, V Min and V Max parameters. You also need to write the $Z$ equation using $U$ and $V$. Here's a simple example:

X,Y,Z Function surface example

Here's your equation in parametric form: $$(v-u+1-((v-u+1)**2 -4*v if 4*v < (v-u+1)**2 else 0 )**(1/2) ) / 2$$

swapping domain solution

To do this with Z Math Surface you need to change your equation. Consider using a math surface with the domain $-.5 \le X \le .5$ by setting X Size to .5. In the original equation replace $X$ with $X+.5$ everywhere. This will give you a resulting domain of $0 \le X \le 1$. The problem is that the surface will be displayed offset by .5. You can remedy this, of course, by moving the surface once it is created to compensate, but now you have fudged both the surface and the domain. (Obviously this will work just as well for $Y$.)

  • $\begingroup$ Hi Marty thank you for your answer! Unfortunately this will still produce a squarish result and we would still require the if/else statement to filter out the imaginary part. I updated my post with a screenshot. It looks like python is the only solution? $\endgroup$ Aug 12, 2022 at 23:22
  • $\begingroup$ @HarryMcKenzie if you specify X and Y to have the same range you'll get a squarish result no matter what you try. $\endgroup$ Aug 12, 2022 at 23:42
  • $\begingroup$ yeah that's the problem XD but +1 for your answer :) $\endgroup$ Aug 12, 2022 at 23:46
  • $\begingroup$ @HarryMcKenzie The underlying problem is that the original question is too vague. OP didn't specify ranges for X and Y nor what to do with the imaginary part nor what sort of surface they wanted. $\endgroup$ Aug 12, 2022 at 23:48
  • 1
    $\begingroup$ @HarryMcKenzie Not your problem in this question, but the OP's original problem that led to this question. Sorry I wasn't clearer. With x and y independent there's no way to solve the problem unless the OP specifies what to do with complex numbers. $\endgroup$ Aug 13, 2022 at 0:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .