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
Greetings! A while ago I played around with the LaTeX grammar (https://github.com/sympy/sympy/blob/master/sympy/parsing/latex/LaTeX.g4) and added support for complex conjugates to my dev version of sympy. The modification was really simple and only involved adding \overline
to the grammar file, regenerating the classes via antlr
along with some other small changes to _parse_latex_antlr.py
.
Having the ability to compute arbitrary expressions with complex conjugates is really great for the application I'm building. For example, the return value of parse_expr(str(parse_latex('\overline{3 + 4I}')))
would be 3 - 4*I
, as expected.
That being said, I was thinking about submitting a PR with this change, but wanted to check with the maintainers of sympy
whether this feature makes sense or not. @asmeurer: What do you think?
hi all,
say I have a horrible expression of the form X + sqrt(Y + iZ) where X, Y, Z are some expressions. Can I give sympy this form and ask it to collect X,Y,Z in new variables. Something like
A,B,C = some_collect_function((a**2+b**2)+sqrt((a*b*c)+i(a*d))
should set A = a**2+b**2
, B = a*b*c
and C=a*d
.
I am working on reviving an Old PR, and I am facing an issue - _eval_nseries
in Function
is returning an undesirable form. Specifically, when _eval_nseries
calls _eval_aseries
(L697 in function.py), adding a print
statement says the asymptotic series being returned is-(_x - _x**3/2 + 3*_x**5/4 + O(_x**6))*exp(-1/_x**2)/sqrt(pi) + 1
which is what I am expecting, but on returning this expressions changes to1 + O(x**(-6), (x, oo))
I think the answer sympy is finally returning is wrongly simplified and the original expression is better. This conversion is happening in _eval_nseries
of Expr
(L3027 in expr.py), where collect(s1, x)
outputs the original expression but collect(s1, x) + o
is outputting the changed expression.
If anyone can help in getting sympy to output the original expression, it would be greatly appreciated. If this is indeed an undesirable simplification, is it a bug?
hi all,
say I have a horrible expression of the form X + sqrt(Y + iZ) where X, Y, Z are some expressions. Can I give sympy this form and ask it to collect X,Y,Z in new variables. Something like
A,B,C = some_collect_function((a**2+b**2)+sqrt((a*b*c)+i(a*d))
should setA = a**2+b**2
,B = a*b*c
andC=a*d
.
Anything on this?
@costica1234_twitter yes I think it would be useful. Any improvement to the LaTeX parser is good as long as it is a fairly standard way of representing something
I've just created the PR with support for \overline here: sympy/sympy#20900.
>>> from sympy.parsing.sympy_parser import (parse_expr, standard_transformations, implicit_multiplication_application, convert_xor)
>>>
>>> def parse_plain_text(e, local_dict=None):
... return parse_expr(
... e,
... local_dict=local_dict,
... transformations=(standard_transformations + (implicit_multiplication_application, convert_xor)),
... evaluate=False)
...
>>> e = parse_plain_text("(49x^2 - 42xy + 9y^2) (7x + 3y) / (7x - 3y)")
>>> e
(7*x + 3*y)*(49*x**2 - 42*x*y + 9*y**2)/(7*x - 3*y)
>>> e.subs({x: 1, y: 2})
13