cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

How to restrict domain and avoid 3-D graph errors of division by zero?

ChadOdgers
1-Newbie

How to restrict domain and avoid 3-D graph errors of division by zero?

As an example, plotting the 3D surface Z(x,y):=2/(x^2-y^2). What's the method for restricting the domain to {(x,y)| x =/= y}? Can I plot this without converting from rectangular?

I'm trying to take advatage of Mathcad capabilities, but I can't track this one down.

1 ACCEPTED SOLUTION

Accepted Solutions

I think that there are 2 issues causing confusion here:

the first is the discontinuity giving rise to some very large numbers which stop you seeing the finer detail as you move away from it - all that the plot shows are the peaks with values upto 10^???

The second is caused by the way that the points are sampled & I didn't (still don't) understand why some parts of the discontinuity ramped to infinity and other parts appeared to remain finite and relatively small.

Thought about changing "100 on error" to "100* sign(x^2-y^2) on error" which makes the plot more symetrical, though I think is mathematically wrong.

Debatable what the value should be as both x & y tend to 0.

Max() & Min() functions to clip the Z value to something sensible both +ve and -ve

And the plot is now set for the maximum 200 points per axis to show the most detail.

Hope this gives you a few ideas of the possibilities

Andy

View solution in original post

8 REPLIES 8
RichardJ
19-Tanzanite
(To:ChadOdgers)

If you are using the Quickplot feature you need to choose the start, end, and # of grids so that none of the calculated points falls on the singularity. In this case you can just change the number of grids for range 2 from 20 to 21.

Another option is add to the domain of the funciton all points in the plane (x,y) assigning an arbitrarie value when the function isn't continous.

Regards. Alvaro.

I adjusted the variables' Grid #'s to differ (by one), yet it did not resolve the problem for the sample problem. As far as the second suggestion, I didn't understand the meaning behind the syntax. At any rate, the plot seemed to lack usefulness in describing the general behavior of the surface through x,y,z space.

Could someone unpack for me a little how, or whether, Mathcad represents asymptotic planes? And if I have to restrict the domain manually, how I can do that?

In another sample problem (attached) I overcame the division by zero problem in a different rational function only after adjusting start, end, and # grids so that x & y were different in each regard, but again, the plot looks lets than descriptive. Can I visualize these a better way than with QuickPlot?

Thanks for your time spelling it out for a relatively new user.

RichardJ
19-Tanzanite
(To:ChadOdgers)

I adjusted the variables' Grid #'s to differ (by one), yet it did not resolve the problem for the sample problem.

You have a singularity when x=y, so you must choose the start, end, and number of grids so that cannot happen. In the plot on the left you have the starting and ending values set the same for x and y, so regardless of the number of grids chosen it's going to fail. For Range 1 change the values to 2, 6, and 21 (as one example - there are an infinite number of possible combinations that will work of course).

As far as the second suggestion, I didn't understand the meaning behind the syntax.

When it encounters an error, i.e. when x=y, the function returns the value 25. I don't know why Alvaro chose that number. Try changing 25 to some very large value, say 10^6, and then in the plot properties turn off the autoscaling for the z-axis and manually set some limits (say -1 and 1 for example)

At any rate, the plot seemed to lack usefulness in describing the general behavior of the surface through x,y,z space.

In what way? It shows the surface in x,y,x space, so I'm not sure what you are expecting.

Could someone unpack for me a little how, or whether, Mathcad represents asymptotic planes?

What do you mean? You want Mathcad to plot the plane automatically when all you give it is the function? It can't do that. You will have to solve for the equation of the plane and then explicitly plot it.

And if I have to restrict the domain manually, how I can do that?

Again, I don't know what you mean. If you set the limits on the Quickplot tab that sets the domain over which the surface is plotted.

but again, the plot looks lets than descriptive. Can I visualize these a better way than with QuickPlot?

In what way does it not show what you are looking for? You can also use the CreateMesh function to plot surfaces, but it will not give you anything fundamentally different to Quickplot (because Quickplot uses the CreateMesh function!). Without a description of what you think the problem is there is no way to tell you how to improve it.

I think that there are 2 issues causing confusion here:

the first is the discontinuity giving rise to some very large numbers which stop you seeing the finer detail as you move away from it - all that the plot shows are the peaks with values upto 10^???

The second is caused by the way that the points are sampled & I didn't (still don't) understand why some parts of the discontinuity ramped to infinity and other parts appeared to remain finite and relatively small.

Thought about changing "100 on error" to "100* sign(x^2-y^2) on error" which makes the plot more symetrical, though I think is mathematically wrong.

Debatable what the value should be as both x & y tend to 0.

Max() & Min() functions to clip the Z value to something sensible both +ve and -ve

And the plot is now set for the maximum 200 points per axis to show the most detail.

Hope this gives you a few ideas of the possibilities

Andy

The second is caused by the way that the points are sampled & I didn't (still don't) understand why some parts of the discontinuity ramped to infinity and other parts appeared to remain finite and relatively small.

I think that's just a question of exactly how close a particular point is to the discontinuity.

Thank you for returning this modified sample. That is exactly what I was looking for when I mentioned the "behavior of the surface in x,y,z". I wasn't interested in seeing the asymptotic planes themselves, just a view of the surface tending toward them in space, which I hadn't yet seen plotted.

The max & min functions appear crucial for clarity. Also, I see the program "plots" the asymptotic planes, giving the appearance of the function values where they don't exist. I suppose it's unavoidable? The actual surface is still identifiable.

I learned a lot from the example's settings. Thanks all.

Side note: I'm in MC14 and simply offsetting the start,end,& grid #'s did not avoid the division by zero singularity x=y. It still won't plot.

Study discontinuities in the plane is hard because you can approach to it from a lot of path, when with just reals you have only two: by the left or by the right.

But here the discussion also go to the concept of infinity, in the case of Westerman, he clip the values to let all of it in a limited box plot. Maybe it is not correct mathematically, but in math first question is about which infinity we are talking, because there are not only one. Thinking in the kind of a thing that is always grounding up, but isn't constructed. This infinity is more consistent with this used in engineering: a few centimeters or seconds could be enough to call it infinity.

Also, the 3D plots are only some fashion way to see something, but the technical plot is contour plot, as Valery claims.

Regards. Alvaro.

Top Tags