## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
• Create your own community
##### Activity
• 19:26
willt-pearson commented #20400
• 18:43
hyadav2k synchronize #21037
• 18:01
hyadav2k commented #21444
• 17:58
hyadav2k synchronize #21037
• 17:55
hanspi42 edited #21372
• 17:50
hanspi42 commented #21469
• 17:50
hanspi42 ready_for_review #21469
• 17:48
hanspi42 commented #21469
• 17:46
hanspi42 synchronize #21469
• 17:44
sylee957 edited #21470
• 17:44
sylee957 edited #21470
• 17:44
sylee957 opened #21470
• 17:44
sylee957 labeled #21470
• 17:38
hanspi42 converted_to_draft #21469
• 17:03
hyadav2k commented #21056
• 16:47
hyadav2k synchronize #21037
• 15:37
hanspi42 commented #21469
• 15:29
hanspi42 commented #21469
• 15:29
hanspi42 synchronize #21469
• 15:05
namannimmo10 labeled #21469
kirk86
@kirk86

Would it make sense in the following scenario:

X = sympy.symbols('x', real=True, positive=True)
stats.E(X)
x

stats.E(*) to output Integral of X dP for some probability space Ω,Σ,P instead of just x?

10 replies
Anurag-Chevendra
@Anurag-Chevendra
@suryam35 heyy, thank you! on it.
JP
@JP1128
I'm having problem with processing latex string into latex image using the preview function cause I can't get to install the latex program in Heroku. Does anyone know how to fix this problem?
Constantin Mateescu
@costica1234_twitter

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?

oponkork
@oponkork

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.

Aaron Meurer
@asmeurer
@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'm hoping we can move to Lark, which will make these kinds of improvements much easier to make. But the PR for it has stalled sympy/sympy#19825
AbhishekS78
@AbhishekS78_gitlab
Hello all,
I'm Abhishek Sontakke, a second-year UG student at IIT Bombay.
I sent a personal introduction mail on the Sympy mailing list yesterday, but it still hasn't been posted.
Can anyone please moderate it, so it can be posted?
Or should I send it one more time?
Sidharth Mundhra
@0sidharth

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 to
1 + 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?

1 reply
Master Grey
@mastergrey
@AbhishekS78_gitlab Sure i'll do that.
Sayandip Halder
@sayandip18
How do I profile sympy code?
basic-programmer-python
@basic-programmer-python
hey Everyone!
I am A Athithya Ithaya (u can simply call me Adi)
I have sent a introduction mail as well as request for guidance for GSOC in mailing list yesterday so I request to post it ...! @AbhishekS78_gitlab
oponkork
@oponkork

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.

Anything on this?

Constantin Mateescu
@costica1234_twitter

@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.

Jim Dupont
@jmikedupont2_gitlab
Howdy
Looking for a mathml xml parser in python, i found sympy has output, any parses?
Benoit Martin
@metabsd
Hi, I'm new with Sympy. Can someone assist me to sympy this. Thx!
Constantin Mateescu
@costica1234_twitter
Welcome to Sympy, @metabsd! Here's a code snippet that you can use:
>>> from sympy.abc import x, y
>>> e = (49 * x**2 - 42 * x * y + 9 * y**2) * (7 * x + 3 * y) / (7 * x - 3 * y)
>>> e.subs({x: 1, y: 2})
13
Constantin Mateescu
@costica1234_twitter
Here's something else that you can do:
>>> 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
Benoit Martin
@metabsd
@costica1234_twitter Thx a lot!!!
Benoit Martin
@metabsd
What happen when I use solve(e) ? The result == [{x: -3*y/7}]
This is the normal solving .
Constantin Mateescu
@costica1234_twitter
I'm not sure if you can end up with the intermediate form you highlighted as e.subs({x: -3 * y / 7}) will simply return 0.
Neel Gorasiya
@Neel2904
how to set up development environment for sympy in local machine??
Ayush Bisht
@ayushbisht2001
hello everyone, My name is Ayush Bisht and I would like to join this amazing community . Can please , anyone help me, from where to start first so that I get well acquainted with the software and can contribute here.
Ayush Bisht
@ayushbisht2001
can we do some changes to Sympy live shell also ?
Aaron Stiff
@AaronStiff
What is the standard syntax for subscripted variables? x1 or x_1. Either seems to work in most cases, but only underscored subscripts seem to work in all cases (#19005)
Aaron Meurer
@asmeurer
@oponkork your best bet is to substitute the expressions for dummy variables with subs, call collect, then substitute back
Muhammed Ali
@khabdrick
Hello everyone, I am new to sympy, was going through the docs and I saw a lot of maths, can someone please tell me the basic math principles I need to know before I can be comfortable contributing to the project
Francesco
@cescofran_gitlab
Hi There, I'm studying a little the source and I have some questions ..I will ask them one at the time...
1. Why Float are called Float and not Reals? Float seam to refer rather to floating point which by definitions are approximation
but sympy Float seam to have arbitrary precision..
Isuru Fernando
@isuruf
@cescofran_gitlab, they are still floating point numbers, because they have a limited number of digits in the mantissa which is determined at instantiation time.
Francesco
@cescofran_gitlab
Thanks you very much @isuruf ! I see you cannot instantiate any real number just by value ... since that will need infinite memory.
But since still you can have arbitrary precision I felt a little confused in Float nomenclature....
Isuru Fernando
@isuruf
arbitrary precision integers and arbitrary precision floats are two entirely different beasts
with integers, you only need a finite amount of memory
with integer operations, integers can get bigger and the size grows as expected
with reals, you need infinite memory at the start
otherwise you get floats
Francesco
@cescofran_gitlab
so is common to refer to floats as arbitrary precision floats?
Isuru Fernando
@isuruf
I didn't get that part
20 replies
with sympy, instead of storing 1/3 with say 1000 digits, you can store it as a Rational number and sympy will not convert it to a float in subsequent operations which means multiplying Rational(1, 3) * 3 gives you an integer 1 instead of a float 1.0
WhiteBlackGoose
@WhiteBlackGoose
Hey! I'm working on an oss computer algebra library for .NET, those, who are "fluent" in SymPy and willing to contribute to our project - please, let me know! (Oryp4ik#0120. on Discord. The project I'm working on is here: https://github.com/asc-community/AngouriMath . There's no need to know .NET to help with the project)
Aaron Meurer
@asmeurer
@cescofran_gitlab Float refers to the specific way the numbers are represented, i.e., floating-point. Not all real numbers are represented that way. For instance, Rational(1, 3), sqrt(2) and pi are real numbers but not floating point, and in fact they can't be exactly represented as floating-point. A floating point number uses a very specific representation of $man\times 2^{exp}$ (see https://mpmath.org/doc/current/technical.html#representation-of-numbers).
Floating point numbers approximate real numbers, but they are not the same as real numbers. Even numbers that are represented exactly are not the same, because they might have a sum that isn't exactly representable. For example, Float(x) + Float(y) != Float(x + y) in general.
Francesco
@cescofran_gitlab
Thanks you @asmeurer , but for example also Rational are just one representation for rational numbers
Float could be another representation for rational numbers .. but in the case of Rational
that specific representation as been assigned the name of the set...
The fact you cannot instantiate all reals with Float does not mean you could not use it as type of real...
I'm not suggesting to do so .. that is just to say from what my question was coming from ....
An approach could be that since is a symbolic math lib... you could just abstract any internal representation
and having just Rational, Reals etc..
Aaron Meurer
@asmeurer
The mathematical sets that numbers belong to is done in SymPy via the assumptions system. For example x.is_real will tell you if x is a real number. The Python classes are based on the implementation, which is why they are named after the representation. Calling Float Real would be inaccurate because it is only one possible representation of real numbers, and one that can't even represent all possible ones at that.
2 replies
Francesco
@cescofran_gitlab
I agree that Float should not be named Real, I'm not convinced should be named Float neither because of the arbitrary precsion... and so for Rational since is conflicting with is_rational (for example I find strange that Float(1.2).is_rational is None )... anyway thanks to you and @isuruf for all the clarifications!
Benoit Martin
@metabsd
Hi, There is a way to solve this with sympy ? Thx!!