On Mon, Feb 2, 2015 at 1:14 PM, Yuxiang Wang <[email protected]>
wrote:
> Dear all,
>
> I am currently trying to do solid mechanics (finite deformation) in SymPy.
> There are a lot of matrices that are positive definite, but I do not know
> whether there is a way to define this property in SymPy. Any help would be
> deeply appreciated!
>
> Take this code snippet for example:
>
>
> ```
> from sympy import symbols, init_printing, sqrt, simplify, Matrix
> init_printing()
>
> # Define a positive-definite real symmetric matrix
> b11, b22, b33, b12, b13, b23 = symbols('b11, b22, b33, b12, b13, b23')
> b = Matrix([[b11, b12, b13], [b12, b22, b23], [b13, b23, b33]])
>
> J = sqrt(b.det())
> lambda1sq, lambda2sq, lambda3sq = b.eigenvals()
> lambda1, lambda2, lambda3 = sqrt(lambda1sq), sqrt(lambda2sq),
> sqrt(lambda3sq)
>
> simplify(lambda1 * lambda2 * lambda3 - J)
> ```
>
> 1) Supposedly, the result of the simplify() should be zero. However it is
> not, because we are not sure whether the eigenvalues of the matrix b are
> positive! They are because the matrix should be positive definite, but I do
> not know how to define that.
>
Maybe refine(lambda1, Q.positive(lambda1sq)).
>
> 2) Also, I know that I could've used real=True in where I defined the
> symbols of b11, b22, b33.... But I didn't do that. The reason is, if I use
> real=True, then I cannot get the eigenvalues any more - it will say
>
> TypeError: cannot determine truth value of-b11*b22*b33 + b11*b23**2 +
> b12**2*b33 - 2*b12*b13*b23 + b13**2*b22 + 2*(-b11 - b22 - b33)**3/27 -
> (-b11 - b22 - b33)*(b11*b22 + b11*b33 - b12**2 - b13**2 + b22*b33 -
> b23**2)/3 < 0
>
This error almost always indicates a bug.
Aaron Meurer
>
> Any way to tighten that up as well?
>
> Thanks,
>
> Shawn
>
>
> --
> 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/02b195fa-d0ef-4523-95fb-059599803090%40googlegroups.com
> <https://groups.google.com/d/msgid/sympy/02b195fa-d0ef-4523-95fb-059599803090%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/CAKgW%3D6KWSRfW5VJEacQhq6nb1r0Xtjs1rhMUyUXR40aYGWSwcw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.