This question stems from a previous question I asked here: https://mathematica.stackexchange.com/questions/80877/multiple-integral-of-equation-including-dx-prime?noredirect=1#comment219103_80877
An equation describing a gravitational field of a cuboid is given as:
$V(X,Y,Z) = -G\rho \int_{-D}^{D} \int_{-B}^{B} \int_{-L}^{L} [ \frac{{dx}'{dy}'{dz}'}{\sqrt{(X-{x}')^2+(Y-{y}')^2+(Z-{z}')^2)}} ]$
And in Mathematica:
V[X_, Y_, Z_, Len_, Br_, Dep_] :=
-GravitationalConstant*ρ*
Integrate[
1 / Sqrt[(X - x)^2 + (Y - y)^2 + (Z - z)^2],
{x, -Len, Len},
{y, -Br, Br},
{z, -Dep, Dep}
]
My goal is to make a vector plot of the above function, but my problem is that in order to do so each vector is can represented as $\vec{g} = - \bigtriangledown V$, which is a bunch of partial derivatives. I've tried doing the following with no success:
Manipulate[
Graphics3D[
Table[
{Red, Arrowheads[Small], Arrow[{D[V, x], D[V, y], D[V, z]}]
},
{X, 0, 10}, {Y, 0, 10}, {Z, 0, 10}]
],
"Cuboid Length",
{Len, 2, 20},
"Cuboid Breadth",
{Br, 2, 4},
"Cuboid Depth",
{Dep, 2, 4},
Initialization :> (
Len = 8; Br = 2; Dep = 2; ρ = 1)
]
Where I think I'm going wrong is not properly initializing the V
function, since when I try to perform a partial derivative on it in a single input line, it returns as 0
. I also tried a StreamPlot
with no success.
What am I doing wrong, and how can I fix it? Is it even necessary to use partial derivatives to define each vector? Thanks to those who can help!
ρ
in your definition of V? $\endgroup$V[x_] := x^2;
,D[V,x]
is zero, you should writeD[V[x],x]=2x
. $\endgroup$