We'd like to make it so that you can pass a block of statements to lambdify and it will generate one function that runs them all. Once we have that, you will be able to pass in your expressions as you have them directly. We already have a way to represent a block of statements (CodeBlock in sympy.codegen.ast), but we need to add support to lambdify.
Aaron Meurer On Fri, Apr 21, 2017 at 4:32 PM, Will <[email protected]> wrote: > Hi Aaron, > > Thanks for helping! > > In this case I'll probably implement a wrapper parser to roll out the > indexes first and then feed the generated equations to sympy. > > Any plan on automating this in future release? > > Best, > Will > > On Thursday, April 20, 2017 at 12:28:25 PM UTC-7, Aaron Meurer wrote: >> >> The code generation functionality needed to make this sort of thing >> automatic isn't implemented yet. Ideally, you'd be able to lambdify the two >> statements as a single block of code. Also, for solve(), elimination is not >> implemented yet (https://github.com/sympy/sympy/issues/2720). For now, your >> best bet is to simply substitute the one expression in the other >> (m.subs(y[i], sqrt(x[i]))). >> >> Aaron Meurer >> >> On Wed, Apr 19, 2017 at 7:08 PM, Will <[email protected]> wrote: >>> >>> Dear all, >>> >>> So I'm trying to use Sympy to solve a simple system with indexed symbols, >>> something like this: >>> >>> Eq 1. y[i] = sqrt(x[i]) >>> Eq 2. m = Sum(z[i] * y[i], (i, 0, n)) / Sum(x[i], (i, 0, >>> n)) >>> >>> where, x, y, z, i, n and m are symbols (x, y and z are IndexedBase and i >>> is Idx, n and m are Symbol). >>> >>> Now given each x[i], n and z[i], I'd like to lambdify a callable function >>> to evaluate m, how can I achieve this? >>> >>> Issue with my attempt: I tried using solve([Eq1, Eq2]) to generate a >>> symbolic solution for m first, but it seems that y[i] is not resolved as >>> sqrt(x[i]) but kept in its original form y[i]. >>> >>> Any help is appreciated! >>> >>> -- >>> 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 post to this group, send email to [email protected]. >>> 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/470f6d1b-534e-47ad-87a3-acdab0362b3e%40googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. >> >> > -- > 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 post to this group, send email to [email protected]. > 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/422ff8d1-83a7-472b-9556-e5da4c74168c%40googlegroups.com. > > For more options, visit https://groups.google.com/d/optout. -- 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 post to this group, send email to [email protected]. 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/CAKgW%3D6%2BJRoFxUfTEZ%3DNbJH1o8jpBxgPzJovR_yER25_UE5e%3DUA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
