From: SixWingedSeraph on 24 Nov 2009 05:52 The two plot commands in the notebook below should give identical outputs, but they don't. The notebook is posted at http://abstractmath.org/MM/MmaBugQ.nb a := 9; b := 18; ff[x_, y_, z_] := x + y + z gg[x_, y_, z_] := 2*x - 2*y - z f[x_, y_] := z /. Solve[ff[x, y, z] == a, z] f[x, y] g[x_, y_] := z /. Solve[gg[x, y, z] == b, z] g[x, y] Plot3D[{-x - y + 9, 2*(x - y - 9)}, {x, 6, 10}, {y, -5, 1}, BoxRatios -> {4, 6, 24}, ViewPoint -> {4.5, 3, 20}, MeshStyle -> Gray, AxesLabel -> {x, y, z}, PlotStyle -> {{Red, Opacity[0.7]}, {Green, Opacity[0.7]}}, ColorFunction -> White] Plot3D[{f[x, y], g[x, y]}, {x, 6, 10}, {y, -5, 1}, BoxRatios -> {4, 6, 24}, ViewPoint -> {4.5, 3, 20}, MeshStyle -> Gray, AxesLabel -> {x, y, z}, PlotStyle -> {{Red, Opacity[0.7]}, {Green, Opacity[0.7]}}, ColorFunction -> White]
From: Bob Hanlon on 25 Nov 2009 02:34 Change your definitions for f and g to f[x_, y_] := z /. Solve[ff[x, y, z] == a, z][[1]] g[x_, y_] := z /. Solve[gg[x, y, z] == b, z][[1]] Bob Hanlon ---- SixWingedSeraph <wellsoberlin(a)gmail.com> wrote: ============= The two plot commands in the notebook below should give identical outputs, but they don't. The notebook is posted at http://abstractmath.org/MM/MmaBugQ.nb a := 9; b := 18; ff[x_, y_, z_] := x + y + z gg[x_, y_, z_] := 2*x - 2*y - z f[x_, y_] := z /. Solve[ff[x, y, z] == a, z] f[x, y] g[x_, y_] := z /. Solve[gg[x, y, z] == b, z] g[x, y] Plot3D[{-x - y + 9, 2*(x - y - 9)}, {x, 6, 10}, {y, -5, 1}, BoxRatios -> {4, 6, 24}, ViewPoint -> {4.5, 3, 20}, MeshStyle -> Gray, AxesLabel -> {x, y, z}, PlotStyle -> {{Red, Opacity[0.7]}, {Green, Opacity[0.7]}}, ColorFunction -> White] Plot3D[{f[x, y], g[x, y]}, {x, 6, 10}, {y, -5, 1}, BoxRatios -> {4, 6, 24}, ViewPoint -> {4.5, 3, 20}, MeshStyle -> Gray, AxesLabel -> {x, y, z}, PlotStyle -> {{Red, Opacity[0.7]}, {Green, Opacity[0.7]}}, ColorFunction -> White]
From: Bill Rowe on 25 Nov 2009 02:39 On 11/24/09 at 5:51 AM, wellsoberlin(a)gmail.com (SixWingedSeraph) wrote: >The two plot commands in the notebook below should give identical >outputs, but they don't. The notebook is posted at >http://abstractmath.org/MM/MmaBugQ.nb >a := 9; b := 18; There is no reason I can see to use SetDelayed here. >ff[x_, y_, z_] := x + y + z >gg[x_, y_, z_] := 2*x - 2*y - z >f[x_, y_] := z /. Solve[ff[x, y, z] == a, z] Given you are plotting this function, you definitely should be using Set ("=") instead of SetDelayed (":="). By using SetDelayed you are telling Mathematica to solve for z every time Plot supplies a new set of x, y points. This causes Mathematica to do more work than necessary to create the plot. >f[x, y] >g[x_, y_] := z /. Solve[gg[x, y, z] == b, z] >g[x, y] >Plot3D[{-x - y + 9, 2*(x - y - 9)}, {x, 6, 10}, {y, -5, 1}... >Plot3D[{f[x, y], g[x, y]}, {x, 6, 10}, {y, -5, 1}... You are not plotting the same thing in both cases. That is: In[14]:= {f[x, y], g[x, y]} Out[14]= {{-x - y + 9}, {2 (x - y - 9)}} which is not the same as {-x - y + 9, 2 (x - y - 9)} You can make things the same by redefining ff and gg to take the first solution returned by Solve or by taking the first solution when plotting
From: Sjoerd C. de Vries on 25 Nov 2009 02:39 As defined here, the functions f and g are a list. You should use the first part of it instead. Cheers -- Sjoerd On Nov 24, 12:52 pm, SixWingedSeraph <wellsober...(a)gmail.com> wrote: > The two plot commands in the notebook below should give identical > outputs, but they don't. The notebook is posted athttp://abstractmath.org/MM/MmaBugQ.nb > > a := 9; b := 18; > > ff[x_, y_, z_] := x + y + z > > gg[x_, y_, z_] := 2*x - 2*y - z > > f[x_, y_] := z /. Solve[ff[x, y, z] == a, z] > > f[x, y] > > g[x_, y_] := z /. Solve[gg[x, y, z] == b, z] > > g[x, y] > > Plot3D[{-x - y + 9, 2*(x - y - 9)}, {x, 6, 10}, {y, -5, 1}, > BoxRatios -> {4, 6, 24}, ViewPoint -> {4.5, 3, 20}, > MeshStyle -> Gray, > AxesLabel -> {x, y, z}, PlotStyle -> {{Red, Opacity[0.7]}, > {Green, Opacity[0.7]}}, ColorFunction -> White] > > Plot3D[{f[x, y], g[x, y]}, {x, 6, 10}, {y, -5, 1}, > BoxRatios -> {4, 6, 24}, ViewPoint -> {4.5, 3, 20}, > MeshStyle -> Gray, > AxesLabel -> {x, y, z}, PlotStyle -> {{Red, Opacity[0.7]}, > {Green, Opacity[0.7]}}, ColorFunction -> White]
|
Pages: 1 Prev: Solving systems of differential equations Next: how to find a function |