Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Klampt symbolic module capabilities #40

#1

I particularly like the possibilities introduced in the symbolic module documentation. Especially support for black-box functions inside expressions, references to arbitrary user data, user-defined functions, and vector variables.

I'm trying to understand more about what I can do with the symbolic module, or the module plus sympy. Besides using eval or evalf are there features for creating systems of equations from user expressions entered or read as strings, like Sympy's sympify and Eq? Also, an equivalent to Sympy's nsolve for solving the system of equations, ideally one which allows use of arbitrary functions/objects in expressions.

The docs are pretty good but I would love to be able to look through more examples of general application of the symbolic module.

Thanks for any insights.

  • replies 1
  • views 192
  • likes 0
#2

Yes, you can use the exprFromStr function in klampt.math.symbolic_io.

ctx = symbolic.Context()
ctx.addVar('x')
expr = symbolic_io.exprFromStr(ctx,'cos(x**2)')
print(expr.evalf({'x':3.0})  #prints -0.9111302618846769

There are no system solving functions, but you can convert an expression to sympy in symbolic_sympy.exprToSympy. Hope this helps!