1
$\begingroup$

I know how to define a single-variable differential operator like

Clear[Op]  
Op[x_] := a D[#, {x, 1}] &

and I can do operations like

Op[x][f[x]]         (* af'[x]    *)
Op[x][Op[x][f[x]]]  (* a^2f''[x] *)

However, how about if I want to do a vectorial operator, i.e. something like

$$ \hat O = \vec a \cdot \vec \nabla_x, $$

so that when operating on some scalar function of $x = |\vec x|$, e.g. $f(x)$ we have

$$ \hat O f(x) = \vec a \cdot \vec \nabla_x f(x) = f'(x) \frac{\vec a \cdot \vec x}{x}\, ,\\ \left(\hat O\right)^2 f(x) = \left(\vec a \cdot \vec \nabla_x\right)^2 f(x) = \left( f''(x) - \frac{f'(x)}{x} \right) \frac{(\vec a \cdot \vec x)^2}{x^2} + \frac{f'(x)}{x} a^2\, . $$

How do I define an operator like this?

I would prefer operations to be done symbolically, without the need to specify a coordinate system.

$\endgroup$
1
  • 3
    $\begingroup$ You could use op[vars_]:=Array[a,Length[vars]].Grad[#,vars]&. Example: With[{xs=Array[x,2]}, op[xs][f[Sqrt[xs.xs]]]]. Your "without the need to specify a coordinate system" is confusing because it can mean a million different things, you should explain it in detail if it is an important part of your question, or drop it. $\endgroup$
    – user293787
    Aug 16, 2022 at 3:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.