I see! I also noticed that I can use `DeferredVector`s instead of `MatrixSymbol`s to get avoid those dict shenanigans. This ``` import numpy import sympy
a = sympy.DeferredVector('a') b = sympy.DeferredVector('b') x = sympy.Symbol('x') P = (a[0] + a[1]*x) / (1 + b[0]*x + b[1]*x**2 + b[2]*x**3) val_a = numpy.random.rand(2) val_b = numpy.random.rand(3) Pa = sympy.lambdify((a, b), P)(val_a, val_b) print(P) print(Pa) ``` works. It's a bit weird to create a lambdify only to call it straight away though. Also, I'm reading [1] that `DeferredVector` were once scheduled for removal? Probably outdated. [1] https://github.com/sympy/sympy/issues/6788 On Monday, March 19, 2018 at 11:24:59 PM UTC+1, Leonid Kovalev wrote: > > P_a = P.subs(dict(zip(a, val_a))) > > returns > > (0.450033195586719*x + 0.829322314411828)/(x**3*b[2, 0] + x**2*b[1, 0] + x > *b[0, 0] + 1) > > You need to substitute individual MatrixElement objects like a[0], not the > MatrixSymbol itself (which isn't even present in the expression P). > > > -- 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 sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at https://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/1cdc96e2-6dd7-4540-9c55-44814d9a01b3%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.