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
> <https://groups.google.com/d/msgid/sympy/470f6d1b-534e-47ad-87a3-acdab0362b3e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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%2B4WL6GqP1CLhbzXtzbYcsZs02778u2JV5itBLyfZgsJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to