Hi Henrik!

On Fri, Oct 17, 2008 at 5:37 PM, henjo <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have been using Sympy for quite some time now in a symbolic electric
> circuit solver (which I will release soon).
>
> To the problem, I have a matrix that gives an incorrect inverse:
>
>>>> A = Matrix([[x+y, -x, 0], [-x-y, x, 1], [0,1,0]])
>>>> Ainv = A.inv()
>>>> Ainv.simplify()
>>>> print Ainv
> ⎡0  0  0⎤
> ⎢       ⎥
> ⎢0  0  1⎥
> ⎢       ⎥
> ⎣0  1  0⎦
>>>> print A*Ainv
> ⎡  0     0  0⎤
> ⎢            ⎥
> ⎢  0     1  0⎥
> ⎢            ⎥
> ⎣-x - y  x  1⎦

Thanks for the bug report. I made it:

http://code.google.com/p/sympy/issues/detail?id=1168

In the meantime, use a different method for calculating the inverse, e.g.:

In [1]: A = Matrix([[x+y, -x, 0], [-x-y, x, 1], [0,1,0]])

In [2]: Ainv = A.inv("ADJ")

In [3]: Ainv
Out[3]:
⎡  -1         -x  ⎤
⎢──────  0  ──────⎥
⎢-x - y     -x - y⎥
⎢                 ⎥
⎢  0     0    1   ⎥
⎢                 ⎥
⎣  1     1    0   ⎦

In [4]: Ainv*A
Out[4]:
⎡    x        y         ⎤
⎢- ────── - ──────  0  0⎥
⎢  -x - y   -x - y      ⎥
⎢                       ⎥
⎢        0          1  0⎥
⎢                       ⎥
⎣        0          0  1⎦

In [6]: (Ainv*A).applyfunc(simplify)
Out[6]:
⎡1  0  0⎤
⎢       ⎥
⎢0  1  0⎥
⎢       ⎥
⎣0  0  1⎦


If you have time, it'd be cool if you could figure out where the
problem is exactly, see the issue. Looking forward for your symbolic
electric
circuit solver. When you release it, please send also an email to this
list, I am sure people will like to play with it. Well, to speak for
myself, I will. :)

Ondrej

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to