Re: 3D graph with assumptions
- To: mathgroup at smc.vnet.net
- Subject: [mg50889] Re: [mg50814] 3D graph with assumptions
- From: Garry Helzer <gah at math.umd.edu>
- Date: Sun, 26 Sep 2004 05:31:52 -0400 (EDT)
- References: <200409220411.AAA18719@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Mukhtar, Some years ago I wrote a package to address this question using Mathematica version 2. A description finally appeared in The Mathematica Journal volume 8, number 4 (Title: Clipping Polygons). A syntax change in version 5 broke the package but it can be repaired by replacing FindRoot[f[p+t(q-p)]==0,{t,{0,1}}] with FindRoot[f[p+t(q-p)]==0,{t,0,1}] throughout (one less pair of curly braces). The package handles general situations. Here is a rough and ready approach for your case. The idea is to chop your set of xy values into small polygons (triangles or quadrilaterals), map the polygons to space, and display them. Mapping the polygons is easy. Suppose that your function is f[x,y] and poly2D is a list of polygons in the plane. Define (note the braces) F[{x_,y_}]:={x,y,f[x,y]}. The list of transformed polygons is displayed by poly3D=poly2D/.Polygon[a_]:>Polygon[F/@a] Show[Graphics3D[poly3D], . . . your choice of options here. . .] Note that this code is indifferent to the nesting levels at which the polygons appear in the lists. The annoying part is producing the list poly2D. Since you are using the area under the curve h[x], start with, say, the left endpoint Riemann sum. d=(b-a)/n poly2D=Table[Polygon[{{a+k d,0},{a+(k+1)d,0},{a+(k+1)d,h[a+k d},{a+(k+1)d,h[a+k d}}],{k,0,n}] These rectangles need to be chopped up into shorter rectangles. A function that will chop each rectangle in a list into two rectangles is(we will need the segment ab horizontal) halve[L_]:=L/.Polygon[{a_,b_,c_,d_}]:>{{Polygon[{a,b,(b+c)/2,(a+d)/ 2}],Polygon[{(a+d)/2,(b+c)/2,c,d}]} To split each Riemann rectangle horizontally into 2^m rectangles use poly2D=Nest[halve,poly2D,m] The rectangles in poly2D can be made as small as you like by choosing m and n large enough. I have come to believe that, except in the simplest cases, it is better to ignore Mathematica's built in Plot functions and go directly to the primitives. On Sep 22, 2004, at 12:11 AM, Mukhtar wrote: > Suppose I have f(x,y) that I need to Plot in 3D, however, the range of > x is (0,1) while the range of y is (0,g(x)), where g(x) is some > explicit function of x, say x^1/2. Is there a way to do it since > specifying it directly the way I outlined above in Plot3D gives me the > error message that "Plot3D :: plln: Limiting value g(x) in {y,0,g(x)} > is not a machine-size real number". Perhaps I can do this indirectly > by plotting two surfaces and then consider the relevant part of > surface f(x,y), however, it would look ugly. Thanks. > > Garry Helzer gah at math.umd.edu
- References:
- 3D graph with assumptions
- From: mbekkali@gmail.com (Mukhtar)
- 3D graph with assumptions