We've just introduced a function called linsolve from the GSoC work this
summer. It has the capability to do this.


Jason
moorepants.info
+01 530-601-9791

On Wed, Oct 7, 2015 at 8:25 AM, Adam Leeper <[email protected]> wrote:

> Hi all-
>
> Interested party just wondering if there is any update on this.
>
> Cheers,
> Adam
>
> On Tuesday, June 24, 2014 at 10:01:56 AM UTC-7, Aaron Meurer wrote:
>>
>> A multidimensional version of collect() would probably be the best
>> abstraction.
>>
>> Aaron Meurer
>>
>> On Sun, Jun 15, 2014 at 10:26 AM, James Crist <[email protected]> wrote:
>> > We certainly could. The question would then be what the scope of the
>> method
>> > should be. Should it only handle systems that can be expressed as Ax =
>> b? Or
>> > should it behave like `CoefficientArrays` mentioned above, and handle
>> Ax +
>> > Bx^2 + Cx^3 + D = 0? Either way, I think it should error if the form
>> can't
>> > be matched exactly (i.e. don't linearize, just express a linear, or
>> > polynomial, system as matrices).
>> >
>> >
>> > On Saturday, June 14, 2014 6:44:21 PM UTC-5, Aaron Meurer wrote:
>> >>
>> >> Oh, of course. B is on the rhs. This is probably more natural to me
>> too.
>> >>
>> >> Should we make a convenience function that does this? I think this use
>> >> of jacobian would be lost on most people.
>> >>
>> >> Aaron Meurer
>> >>
>> >> On Sat, Jun 14, 2014 at 6:29 PM, James Crist <[email protected]> wrote:
>> >> > It's just the convention I'm most used to. Systems that can be
>> expressed
>> >> > as
>> >> > A*x = B I usually solve for x, or if A isn't square, the least
>> squares
>> >> > solution x. In both cases you need A and B in this form. I suppose
>> Ax +
>> >> > B
>> >> > could seem more natural though.
>> >> >
>> >> > On Friday, June 13, 2014 6:45:48 PM UTC-5, Aaron Meurer wrote:
>> >> >>
>> >> >> That's a clever trick. I should have thought of that.
>> >> >>
>> >> >> Is there any reason you let system = A*x - B instead of A*x + B?
>> The
>> >> >> latter seems more natural.
>> >> >>
>> >> >> Aaron Meurer
>> >> >>
>> >> >> On Sat, Jun 7, 2014 at 12:28 AM, James Crist <[email protected]>
>> wrote:
>> >> >> > I just answered this on gitter earlier today, but you can just
>> take
>> >> >> > the
>> >> >> > jacobian of the system to get its matrix form. For example:
>> >> >> >
>> >> >> > In [1]: from sympy import *
>> >> >> >
>> >> >> > In [2]: a, b, c, d = symbols('a, b, c, d')
>> >> >> >
>> >> >> > In [3]: x1, x2, x3, x4 = symbols('x1:5')
>> >> >> >
>> >> >> > In [4]: x = Matrix([x1, x2, x3, x4])
>> >> >> >
>> >> >> > In [5]: system = Matrix([a*x1 + b*x2 + c,
>> >> >> >    ...: c*x1 + d*x3 + 2,
>> >> >> >    ...: c*x3 + b*x4 + a])
>> >> >> >
>> >> >> > In [6]: A = system.jacobian(x)
>> >> >> >
>> >> >> > In [7]: B = A*x - system
>> >> >> >
>> >> >> > In [8]: A
>> >> >> > Out[8]:
>> >> >> > Matrix([
>> >> >> > [a, b, 0, 0],
>> >> >> > [c, 0, d, 0],
>> >> >> > [0, 0, c, b]])
>> >> >> >
>> >> >> > In [9]: B
>> >> >> > Out[9]:
>> >> >> > Matrix([
>> >> >> > [-c],
>> >> >> > [-2],
>> >> >> > [-a]])
>> >> >> >
>> >> >> > In [10]: assert A*x - B == system
>> >> >> >
>> >> >> > The functionality I'm adding for my GSoC for linearizing a system
>> of
>> >> >> > equations will also be able to return these matrices in a
>> convenient
>> >> >> > form.
>> >> >> > But it's not terribly difficult to solve for these arrangements
>> using
>> >> >> > the
>> >> >> > current functionality.
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > On Thursday, June 5, 2014 4:22:52 PM UTC-5, Andrei Berceanu
>> wrote:
>> >> >> >>
>> >> >> >> Was this implemented into sympy at any point? It could be the
>> >> >> >> equivalent
>> >> >> >> of Mathematica's CoefficientArrays function.
>> >> >> >>
>> >> >> >> On Thursday, November 14, 2013 5:56:22 AM UTC+1, Chris Smith
>> wrote:
>> >> >> >>>
>> >> >> >>> I forgot that as_independent, without the as_Add=True flag will
>> >> >> >>> treat
>> >> >> >>> Muls differently. The following will be more robust:
>> >> >> >>>
>> >> >> >>> def eqs2matrix(eqs, syms, augment=False):
>> >> >> >>>     """
>> >> >> >>>     >>> s
>> >> >> >>>     [x + 2*y == 4, 2*c + y/2 == 0]
>> >> >> >>>     >>> eqs2matrix(s, (x, c))
>> >> >> >>>     (Matrix([
>> >> >> >>>     [1, 0],
>> >> >> >>>     [0, 2]]), Matrix([
>> >> >> >>>     [-2*y + 4],
>> >> >> >>>     [    -y/2]]))
>> >> >> >>>     >>> eqs2matrix([2*c*(x+y)-4],(x, y))
>> >> >> >>>     (Matrix([[2*c, 2*c]]), Matrix([[4]]))
>> >> >> >>>     """
>> >> >> >>>     s = Matrix([si.lhs - si.rhs if isinstance(si, Equality)
>> else si
>> >> >> >>> for
>> >> >> >>> si in eqs])
>> >> >> >>>     sym = syms
>> >> >> >>>     j = s.jacobian(sym)
>> >> >> >>>     rhs = -(s - j*Matrix(sym))
>> >> >> >>>     rhs.simplify()
>> >> >> >>>     if augment:
>> >> >> >>>         j.col_insert(0, rhs)
>> >> >> >>>     else:
>> >> >> >>>         j = (j, rhs)
>> >> >> >>>     return j
>> >> >> >>>
>> >> >> > --
>> >> >> > 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.
>> >> >> > To view this discussion on the web visit
>> >> >> >
>> >> >> >
>> >> >> >
>> https://groups.google.com/d/msgid/sympy/8fb2dae4-9f46-4c1b-b96f-83033278c27d%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 http://groups.google.com/group/sympy.
>> >> > To view this discussion on the web visit
>> >> >
>> >> >
>> https://groups.google.com/d/msgid/sympy/a9c5f7ba-1c2d-4673-a8d4-b1253c150054%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 http://groups.google.com/group/sympy.
>> > To view this discussion on the web visit
>> >
>> https://groups.google.com/d/msgid/sympy/0b486c56-8a2b-48a5-a210-f49b6d39899f%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 http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/9b453937-0394-4efc-8d7f-dc1a6a46267e%40googlegroups.com
> <https://groups.google.com/d/msgid/sympy/9b453937-0394-4efc-8d7f-dc1a6a46267e%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 http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAP7f1Ai0%2BzM5U5hQkzWNUH9iTbAaQpHAWG%2Bwr%2BJbpYxjFG%3DP7w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to