The Mastermage
The Mastermage

Reputation: 123

Sympy automatically create variables for Derivatives

So what i want to make is an error propagation calculator using sympy and creating partial derivatives of an expression. My main question is mainly how can I create out of a string expression like e.g. "d*x+x**v" the symbolic variables so I can use sympy.diff(expr,Variables) I know I can parse the expression from string to a sympy expression by using parse_expr("string") but is there a way for me to create all the symbols from the "String" so that i can use them in the function for calculating differentials.

Upvotes: 0

Views: 178

Answers (1)

smichr
smichr

Reputation: 18939

The free_symbols property will tell you these symbols:

>>> sympify("d*x+x**v").free_symbols
{d, v, x}

Upvotes: 1

Related Questions