Hi Aron, Many thanks for your answers. I previously use say f.args[0] to access input like \nabla*f to check. But has() is more error free.
Is there any more robust way to get the specific args symbol? For instance, if the input is like (expr=x*y*z). But I want to get the x from this expression. I would say expr.arg[0]. But if I change the expression order. This doesn't work. Thanks! On Friday, September 16, 2022 at 9:27:10 PM UTC+2 [email protected] wrote: > You can name a symbol any string you want, so Symbol(r'\nabla') will > create a symbol named \nabla. > > To test if a symbol is in an expression, use .has(): > > >>> (x + 1).has(x) > True > >>> (y + 1).has(x) > False > > Aaron Meurer > > On Fri, Sep 16, 2022 at 6:26 AM Yang Liu <[email protected]> wrote: > > > > Hi, > > > > I want to represent the \nabla symbolically without calculation. Is > there a way to declare such a symbol? Also for \triangle? > > > > Moreover, I want to write a function say F(\nabla u) take \nabla*u as an > input. Is there a way to detect if I pass the "\nabla" into the function? > Pseudo code would be something like: > > > > F(expression): > > if \nabla in expression: > > do something > > else: > > > > Many Thanks! > > > > -- > > You received this message because you are subscribed to the Google > Groups "sympy" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected]. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/cab2a16d-8fa0-4875-971e-7e39a10077d2n%40googlegroups.com > . > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/4fe989e9-6104-4026-a3e1-4d112a07f3bfn%40googlegroups.com.
