On Wed, Aug 28, 2013 at 4:58 PM, pdknsk <[email protected]> wrote:
> I have two questions.
>
> a*x == b*y == c*z
>
> What is the shortest way to enter this? I have only figured out the solution
> below, to use Eq twice.
>
> Eq(a*x, b*y), Eq(a*x, c*z)
That's the easiest way I can think of. Also remember that you can just
write expressions and they will be assumed to equal 0, so you can just
use a*x - b*y and a*x - c*z
>
> The other question may be difficult to explain. Let me show an example.
>
>>>> var('w0 w1 w2 x0 x1 x2 y0 y1 y2 z0 z1 z2 k')
>
>>>> solve([Eq(w0*w1+x0*x1, k), Eq(w0*w2, x0*x2)], [w0, x0])
>>>> solve([Eq(w0*w1+x0*x1+y0*y1, k), Eq(w0*w2, x0*x2), Eq(w0*w2, y0*y2)],
>>>> [w0, x0, y0])
>>>> solve([Eq(w0*w1+x0*x1+y0*y1+z0*z1, k), Eq(w0*w2, x0*x2), Eq(w0*w2,
>>>> y0*y2), Eq(w0*w2, z0*z2)], [w0, x0, y0, z0])
>
> When you run this, you'll notice that the result follows a certain pattern.
> Is it possible to get a universal function out of this, that applies for n
> different n0/n1/n2 variables, so you don't need to run solve again when you
> add another variable? I don't even know if this is mathematically possible.
You could use a summation to represent the first term, but I can't
think of a way to represent the rest (and not in any way that SymPy
would likely give you a solution). You're best bet is probably to do
it by hand. You can still use SymPy to take care of the bookkeeping
for you, but you'll probably need to do things like solve part of the
problem and substitute it back into the rest manually (though still
using solve() and subs() where you can).
Aaron Meurer
>
> Thanks.
>
> --
> 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 http://groups.google.com/group/sympy.
> For more options, visit https://groups.google.com/groups/opt_out.
--
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 http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.