# plotting 3d function

Hi,

I am somehow new to matplotlib and I am trying to plot this function of x ,y ,z

F(x,y,z)= 38244.74787*Pi*(x^2+y^2+z^2)^.125+1615.975261*Pi*z^2/(x^2+y^2+z^2)^.875-1292.780210*Pi*z^2/((x^2+y^2+z^2)^.875*(1+y^2/x^2))+1292.78*Pi*(x^2+y^2+z^2)^.125/(1+y^2/x^2)

in a similar way as

http://matplotlib.org/mpl_examples/mplot3d/contour3d_demo3.hires.png

But I have no idea where to start...

some help would be appreciated...

thanks

The reason you are having difficulty coming up with a way to plot this is because you have 3 input dimensions, and 1 output dimension that you wish to plot. If you were to plot this in 3D space, it would have to be done as F(x,y,z) as a colored “mist” in the domain of (x,y,z). While a “mist” can’t be done in mplot3d, you could plot out scatter points to emulate this. One could also use contourf3d(…, zdir=‘z’, offset=…) to create slices of the filled contours, similar to this example:

http://matplotlib.org/examples/mplot3d/contourf3d_demo2.html

Now, if the domain of (x,y,z) can be parameterized as a surface (i.e., a sphere or a cylinder), then you are looking to do an image of F(x,y,z) plotted on that surface, which is a little bit difficult, but also do-able using the plot_surface() function.

Cheers!
Ben Root

···

On Mon, Jan 21, 2013 at 8:06 PM, Pau <vim.unix@…982…> wrote:

Hi,

I am somehow new to matplotlib and I am trying to plot this function of x ,y ,z

F(x,y,z)= 38244.74787Pi(x^2+y^2+z^2)^.125+1615.975261Piz^2/(x^2+y^2+z^2)^.875-1292.780210Piz^2/((x^2+y^2+z^2)^.875*(1+y^2/x^2))+1292.78Pi(x^2+y^2+z^2)^.125/(1+y^2/x^2)

in a similar way as

http://matplotlib.org/mpl_examples/mplot3d/contour3d_demo3.hires.png

The code is

http://matplotlib.org/mpl_examples/mplot3d/contour3d_demo3.py

But I have no idea where to start…

some help would be appreciated…

thanks

Hi,

that's true... I have been playing with maxima.

I define the function

F(x,y,z):=38244.74787*%pi*(x^2+y^2+z^2)^0.125
+1615.975261*%pi*z^2/(x^2+y^2+z^2)^0.875
+(-1292.78021)*%pi*z^2/((x^2+y^2+z^2)^0.875*(1+y^2/x^2))
+1292.78021*%pi*(x^2+y^2+z^2)^0.125/(1+y^2/x^2);

then I factor it

factor(F(x,y,z)=0);

Multiply it by the denominator

% * 32365900000*(z^2+y^2+x^2)^(7/8);

divide by pi

% / %pi;

So that F(x,y,z)=0 is equivalent to

1290128178785633*z^2+1237825685085633*y^2+1279667680084472*x^2=0

The only real solution is 0,0,0,

But then I try to define a cube centered at the origin which contains
at least a part of the surface:

n: 10\$
draw3d(
enhanced3d = true,
implicit(
F(x,y,z) = k,
x,-n,n,y,-n,n,z,-n,n));

Since it's taking huge values even for small x,y,z, one has to use
either very small n or very large k but even in that case I get
draw3d (implicit): non real value

How could I check the same in matplotlib?

Am I missing something? Maybe this is a bug in maxima...

Any help will be appreciated!

···

On Tue, Jan 22, 2013 at 3:29 PM, Benjamin Root <ben.root@...1304...> wrote:

On Mon, Jan 21, 2013 at 8:06 PM, Pau <vim.unix@...982...> wrote:

Hi,

I am somehow new to matplotlib and I am trying to plot this function of x
,y ,z

F(x,y,z)=
38244.74787*Pi*(x^2+y^2+z^2)^.125+1615.975261*Pi*z^2/(x^2+y^2+z^2)^.875-1292.780210*Pi*z^2/((x^2+y^2+z^2)^.875*(1+y^2/x^2))+1292.78*Pi*(x^2+y^2+z^2)^.125/(1+y^2/x^2)

in a similar way as

http://matplotlib.org/mpl_examples/mplot3d/contour3d_demo3.hires.png

But I have no idea where to start...

some help would be appreciated...

thanks

The reason you are having difficulty coming up with a way to plot this is
because you have 3 input dimensions, and 1 output dimension that you wish to
plot. If you were to plot this in 3D space, it would have to be done as
F(x,y,z) as a colored "mist" in the domain of (x,y,z). While a "mist" can't
be done in mplot3d, you could plot out scatter points to emulate this. One
could also use contourf3d(..., zdir='z', offset=...) to create slices of the
filled contours, similar to this example:

http://matplotlib.org/examples/mplot3d/contourf3d_demo2.html

Now, if the domain of (x,y,z) can be parameterized as a surface (i.e., a
sphere or a cylinder), then you are looking to do an image of F(x,y,z)
plotted on that surface, which is a little bit difficult, but also do-able
using the plot_surface() function.

Cheers!
Ben Root