A computer algebra system written in pure Python http://sympy.org/ . To get started to with contributing https://github.com/sympy/sympy/wiki/Introduction-to-contributing
anutosh491 on hyperbolic_functions
Fix errors in test_control_plot… Remove whitespace Make sure all tests pass and 59 more (compare)
anutosh491 on hyperbolic_functions
Fixed Float handling for pow._e… (compare)
anutosh491 on hyperbolic_functions
Restructured tests for nseries … (compare)
anutosh491 on hyperbolic_functions
Improved Code for Bi-directiona… (compare)
anutosh491 on hyperbolic_functions
Fixed Bi-directional limit cases (compare)
anutosh491 on hyperbolic_functions
Fixed bi-directional limit case… (compare)
anutosh491 on hyperbolic_functions
Refactored leading term methods… (compare)
anutosh491 on hyperbolic_functions
Implemented series for function… (compare)
anutosh491 on hyperbolic_functions
Implemented taylor_term method … (compare)
anutosh491 on GSOC_Pr1_Refactoring_Log_leading_term_method
anutosh491 on GSOC_Pr1_Refactoring_Log_leading_term_method
Refactored Leading Term method … Fixed leading term methods for … Fixed leading term for trigonom… and 1 more (compare)
anutosh491 on GSOC_Pr1_Refactoring_Log_leading_term_method
Added Todo (compare)
anutosh491 on GSOC_Pr1_Refactoring_Log_leading_term_method
Added expand to log rewrites (compare)
anutosh491 on GSOC_Pr1_Refactoring_Log_leading_term_method
updated test for asin,atan,acot… (compare)
anutosh491 on GSOC_Pr1_Refactoring_Log_leading_term_method
removed wrong test (compare)
anutosh491 on GSOC_Pr1_Refactoring_Log_leading_term_method
Modified test (compare)
anutosh491 on GSOC_Pr1_Refactoring_Log_leading_term_method
Fixed leading term for acos/ase… (compare)
anutosh491 on series_for_arg
Updated code (compare)
anutosh491 on GSOC_Pr1_Refactoring_Log_leading_term_method
Improved code quality (compare)
anutosh491 on GSOC_Pr1_Refactoring_Log_leading_term_method
Fixed code quality (compare)
solution_as_list
, didn't returns a list per se, but a set with a tuple, as in: {(-0.916666666666667, 0.708333333333333, 0.375, -0.208333333333333, 0.0416666666666667, 0)}
of type sympy.sets.sets.FiniteSet
.
flatten
anyway... Never mind then
Actually,
solution = np.array(*[e for e in r_tmp]).astype(float)
should flatten it as well
wow. :-( Given the matrix PI
array([[ -0.917, 0.042, 0. , 0. , -1. ],
[ 0.708, -1.125, 0.042, 0. , 5. ],
[ 0.375, 1.125, -1.125, 0.042, -10. ],
[ -0.208, -0.042, 1.125, -1.125, 10. ],
[ 0.042, 0. , -0.042, 1.125, -5. ],
[ 0. , 0. , 0. , -0.042, 1. ]])
and the vector c
array([-1. , 0. , 0. , -0.042, 1.083, -0.042])
the solution given by
linsolve(Matrix(np.c_[PI,c]))
returns an EmptySet()
while the same operation in Maple 16 returns non empty, and exactly
np.array([649/576, 143/192, 75/64, 551/576, -25/13824])
that in float is around
array([ 1.127, 0.745, 1.172, 0.957, -0.002])
Any ideas?
PI = np.array([
[-11/12, 1/24, 0, 0, -1],
[ 17/24, -9/8, 1/24, 0 ,5],
[3/8, 9/8, -9/8, 1/24, -10],
[-5/24, -1/24, 9/8, -9/8, 10],
[1/24, 0, -1/24, 9/8, -5],
[0, 0, 0, -1/24, 1]
])
It seems that your system is over-determined. It has 6 equations in 5 variables. It can have solutions only if the determinant of the extended system is 0.
>>> P = Matrix([[ -0.917, 0.042, 0. , 0. , -1. ],
... [ 0.708, -1.125, 0.042, 0. , 5. ],
... [ 0.375, 1.125, -1.125, 0.042, -10. ],
... [ -0.208, -0.042, 1.125, -1.125, 10. ],
... [ 0.042, 0. , -0.042, 1.125, -5. ],
... [ 0. , 0. , 0. , -0.042, 1. ]])
>>> c = Matrix([-1. , 0. , 0. , -0.042, 1.083, -0.042])
>>> Pc = P.row_join(c)
>>> Pc.det()
0.000998125750125132
In this example, the determinant not 0 because of the inaccuracy of floating point numbers. Hence there is no solution.
A potential solution could be to define
rationalize = lambda x: [nsimplify(e) for e in x]
(this will turn numbers from a list into rationals). And then do
PI = Matrix(map(rationalize, [
[-11/12, 1/24, 0, 0, -1],
[ 17/24, -9/8, 1/24, 0 ,5],
[3/8, 9/8, -9/8, 1/24, -10],
[-5/24, -1/24, 9/8, -9/8, 10],
[1/24, 0, -1/24, 9/8, -5],
[0, 0, 0, -1/24, 1]
]))
and similarly for c
. I've just checked and this returns the right solutions
mrationalize = lambda x: [nsimplify(e) for e in [r for r in x]]
that I do not like much the fell.
I have a problem with calculating eigenvectors for a simple 3x3 matrix in sympy. Trying to execute
q = symbols("q", positive=True)
m = Matrix([[-2, exp(-q), 1], [exp(q), -2, 1], [1, 1, -2]])
#m.eigenvects(simplify=True)
m.eigenvals()
results in very complicated expressions for the eigenvalues, trying to get the eigenvectors fails with a NotImplementedError. I expect the latter to be due to the former. However, when trying to do the same thing in Mathematica, I get much simpler expressions for everything. Is there some option / flag that I can set to have sympy compute these eigenvalues and eigenvectors? Is there currently some form of limitation within sympy that prevents me from doing this?
simplify
simplify
flag, but it doesn't work