3
$\begingroup$

If we use Mathematica notation the following works:

Div[Grad[u[x, y], {x, y}], {x, y}]

also if we multiply the gradient with a scalar:

Div[scal[x,y] Grad[u[x, y], {x, y}], {x, y}]

But when I use graphical mathematical notation with the Del operator (EscdelEsc), the first still works, but the second screws up (sorry, I can not paste the input here, because if I paste the graphical input it gets translated into: Subscript[\[Del], x, y] what is interpreted differently in Mathematica ). I denote therefore the operator symbolically by: delxy:

delxy.(scal[x,y] delxy u[x,y])

This gives an error message, complaining that one can not take the divergence of a scalar. Obviously scal[x,y] delxy u[x,y] is considered a scalar.

Does anybody have an explanation and possibly a way around for this?

$\endgroup$
  • $\begingroup$ Interesting, didn't know can be used in this way, but "because if I paste the graphical input it gets translated into: Subscript[\[Del], x, y]" seems to suggest that you're not making it correct in 1st case, either. Perhaps you can create a GIF to illustrate what you've done? $\endgroup$ – xzczd Oct 9 at 10:52
  • 1
    $\begingroup$ BTW you may want to read this: mathematica.stackexchange.com/a/139647/1871 $\endgroup$ – xzczd Oct 9 at 12:01
2
$\begingroup$

Note that you have to use Subscript[∇, {x,y}] instead of Subscript[∇, x, y] to make it work. If you do that, I don't get any problems:

enter image description here

Copyable input for the left side:

\!\(
  \*SubscriptBox[\(∇\), \({x, y}\)] . 
  \((scal[x, y] \*SubscriptBox[\(∇\), \({x, y}\)]\ u[x, y])\)
\)

If you don't want to type the braces around the subscripts, you can use the notation package (see below for copyable version of the Notation[...] inputs):

enter image description here

Copyable inputs

Copy the following, and select "Yes" when it asks you whether the text should be interpreted:

Cell[BoxData[{
 RowBox[{"Notation", "[", 
  RowBox[{
   TemplateBox[{RowBox[{
       SubscriptBox["\[Del]", 
        RowBox[{"x_", ",", "y__"}]], "f_"}]},
    "NotationTemplateTag"], " ", "\[DoubleLongLeftRightArrow]", " ", 
   TemplateBox[{RowBox[{"Grad", "[", 
       RowBox[{"f_", ",", 
         RowBox[{"{", 
           RowBox[{"x_", ",", "y__"}], "}"}]}], "]"}]},
    "NotationTemplateTag"]}], "]"}], "\[IndentingNewLine]", 
 RowBox[{"Notation", "[", 
  RowBox[{
   TemplateBox[{RowBox[{
       SubscriptBox["\[Del]", 
        RowBox[{"x_", ",", "y__"}]], ".", "f_"}]},
    "NotationTemplateTag"], " ", "\[DoubleLongLeftRightArrow]", " ", 
   TemplateBox[{RowBox[{"Div", "[", 
       RowBox[{"f_", ",", 
         RowBox[{"{", 
           RowBox[{"x_", ",", "y__"}], "}"}]}], "]"}]},
    "NotationTemplateTag"]}], "]"}]}], "Input"]

Example input:

\!\(
  \*SubscriptBox[\(∇\), \(x, y\)] . 
  \((scal[x, y] \*SubscriptBox[\(∇\), \(x, y\)]u[x, y])\)
\)
$\endgroup$
  • $\begingroup$ Thanks a lot for your answer. The braces do the job. Playing around with the braces, I found, that there is even an easier way, without using the notation package. One can type: Esc,d,e,l,Esc,Ctrl-,{,x,y,},Ctrl Space. $\endgroup$ – Daniel Huber Oct 10 at 8:10
  • $\begingroup$ @DanielHuber Isn't that the first example in my answer? Or am I missing something? $\endgroup$ – Lukas Lang Oct 10 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.