3

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?

xzczd
  • 65,995
  • 9
  • 163
  • 468
Daniel Huber
  • 51,463
  • 1
  • 23
  • 57
  • 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? – xzczd Oct 09 '19 at 10:52
  • 1
    BTW you may want to read this: https://mathematica.stackexchange.com/a/139647/1871 – xzczd Oct 09 '19 at 12:01

1 Answers1

2

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])\)
\)
Lukas Lang
  • 33,963
  • 1
  • 51
  • 97
  • 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. – Daniel Huber Oct 10 '19 at 08:10
  • @DanielHuber Isn't that the first example in my answer? Or am I missing something? – Lukas Lang Oct 10 '19 at 08:16