Mathematica
is a term rewriting system, variables need not to be declared as in compiled languages. For a general view I recommend reading this post by Leonid Shifrin. In general, symbolic variables are processed as complex if not assumed otherwise. To specify assumptions there are a few ways :
$Assumptions
are recommended when you want to use global assumptions.
- for local assumptions there is
Assuming[ assum, expr]
where expr
can be a compound expression (see CompoundExpression
, a shorthand - ;
) :
Assuming[ assum, expr] evaluates expr with assum appended to $Assumptions, so that assum
is included in the default assumptions used by functions such as Refine, Simplify, and
Integrate
Many functions as Simplify
, Refine
, and Integrate
have options Assumptions
that specifies default assumptions to be made about symbolic quantities.
Here are a few examples how to specify desired assumptions and compute a given expression :
D[ Simplify[ 1/ Norm @ rhatV, {x, y, z} ∈ Reals && {x0, y0, z0} ∈ Reals], x]
and
D[ Simplify[ 1/EuclideanDistance[{x, y, z}, {x0, y0, z0}],
{x, y, z} ∈ Reals && {x0, y0, z0} ∈ Reals], x]
and
Assuming[ {x, y, z} ∈ Reals && {x0, y0, z0} ∈ Reals, D[ 1/Simplify @ Norm @ rhatV, x] ]
all these expressions return :

Assuming[]
... $\endgroup$