## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
• Create your own community
##### Activity
• Jul 31 23:17
oscarbenjamin commented #21776
• Jul 31 22:04
github-actions[bot] commented #21776
• Jul 31 20:35
oscarbenjamin commented #21776
• Jul 31 20:34
sympy-bot commented #21776
• Jul 31 20:34
oscarbenjamin synchronize #21776
• Jul 31 20:28
oscarbenjamin commented #21776
• Jul 31 20:23
sylee957 commented #21776
• Jul 31 20:21
oscarbenjamin commented #21776
• Jul 31 20:15
oscarbenjamin commented #21807
• Jul 31 19:48
github-actions[bot] commented #21806
• Jul 31 19:27
github-actions[bot] commented #21703
• Jul 31 18:49
proy87 commented #21807
• Jul 31 18:43
praneethratna review_requested #21806
• Jul 31 18:32
praneethratna synchronize #21806
• Jul 31 18:29
akshanshbhatt commented #21703
• Jul 31 18:06
github-actions[bot] commented #21806
• Jul 31 17:55
akshanshbhatt synchronize #21703
• Jul 31 17:49
akshanshbhatt synchronize #21703
• Jul 31 17:14
github-actions[bot] commented #21776
• Jul 31 17:07
github-actions[bot] commented #21806
ASUTOSH GHANTO
@asutoshgha
how to actually contribute to this repository?
what additional features we can add?
Akhil (#stayhome #staysafe )
@AkhilBollu_twitter
Hello everyone
Is anyone there??
Shamitha
@ShamithaReddy
YUP @AkhilBollu_twitter
hi
ASUTOSH GHANTO
@asutoshgha
please help
I want to improve
Miguel Guthridge
@MiguelGuthridge
Is there a way for me to include sympy as a module in another project so that I can import it inside an interpreter where pip installing modules isn't accessible?
2 replies
I'm trying to make an extension to a search program that uses python so that when you type eq [some equation] it'll solve it
But since I've never included a package without having it pip installed, I'm not entirely sure where to start haha
shashankks0987
@shashankks0987
My test is returning this as the expected output Complement(Integers, ConditionSet(n, Eq((n - 1)*(n + 1), 0), Integers)). I need to convert this to 'sympy' form. Need help
oponkork
@oponkork

Why does the following latex code of the function varies from the symbol?

import sympy as sp
r = sp.symbols("r")
print(sp.latex(sp.symbols("\delta\ u_t")))
print(sp.latex(sp.Function("\delta\ u_t")(r)))

gives

\delta u_{t}
\delta\ u_{t}{\left(r \right)}

Notice that the space right after \delta is escaped for the function, but not for the symbol.

Aaron Meurer
@asmeurer
The latex printer uses different code paths for Symbol and Function. They should probably be made uniform. By the way, you should always use raw strings for latex, like r"\delta\ u_t".
oponkork
@oponkork

Okay, is there a way I can use the Symbol-like expressions for functions, or define the symbol without the space? The way it gets displayed, it appears as if \delta and u_t are two different variables. Ofcourse, sp.symbols("\deltau_t"), it won't work.

Also, why raw strings for latex?

Kalevi Suominen
@jksuom

why raw strings for latex?

Otherwise double backslash will be needed like \\delta.

oponkork
@oponkork

why raw strings for latex?

Otherwise double backslash will be needed like \\delta.

But sp.symbols("\delta\ u_t") works.

Kalevi Suominen
@jksuom
It seems to work, apparently because \d is not an escape sequence in Python. However, \b is an escape sequence:
>>> "\beta\ u_t"
'\x08eta\\ u_t'
oponkork
@oponkork
Aah okay. \theta won't work either then. Thanks a lot.

Okay, is there a way I can use the Symbol-like expressions for functions, or define the symbol without the space? The way it gets displayed, it appears as if \delta and u_t are two different variables. Ofcourse, sp.symbols("\deltau_t"), it won't work.

Also, why raw strings for latex?

Any solution for this?

Arun sanganal
@ArunSanganal
Hello! I am a freshman from IIT Kharagpur, new to sympy. Hoping to get along with this awesome community. Cheers!😄
wolfgang_302
@wolfgang-302

Maybe someone can explain the following to me:
Using sympy 1.7.1 i get the following:

from sympy import *
init_printing()

a = Symbol('a')

a0, = solveset(Eq(2*a**5,0.34),domain=S.Reals)
a0 # 0.70160032942779
0.70160032942779

print(a0.round(4)) # 0.7016
print(a0.round(4).n(10)) # 0.7015991211

Thank you for any hints.
Wolfgang

Felix
@flxai:matrix.org
[m]
Hi! 👋 I have a sympy expression and want to iterate over elements of its syntax tree. Can somebody please point me to the right direction?
Nevermind. I just found it myself: docs.sympy.org/latest/tutorial/manipulation.html#recursing-through-an-expression-tree
moiseszeleny
@moiseszeleny
@flxai:matrix.org hi you can use the args method, for example if you expression is 'expr' you can iterate on its elements by '[arg for arg in expr.args]'.
Felix
@flxai:matrix.org
[m]
moiseszeleny-5dd0d487d73408ce4fd13ecb: Thanks. That's what I'm doing. Just recursively
latot
@latot:matrix.org
[m]
Hi hi, can someone help me with a little thing plis?
I'm having a very hard time trying to get the memory usage of sympy expressions, actually for example, sys.getsizeof always return 64 bytes, even if the var have 200 bytes in the name...., just the name...., how can I get the actual memoery usage of a expression?
Felix
@flxai:matrix.org
[m]
latot: You could try something like this: ix.io/3q9z
oytis
@oytis:matrix.org
[m]

Sorry, a very general question, I'm just looking around with sympy.

I was confused by sympy having two implementations of vectors, sympy.vector an sympy.physics.vector. They seem to not be sharing code and the documentation for either doesn't mention another one and the reason to have them separate. Why is that? Is there a way to make them interoperate?

Thanks!

1 reply
Miguel Guthridge
@MiguelGuthridge
I've been making a maths interpreter using sympy, and I'm trying to implement simultaneous equations, but I'm getting a cannot determine truth value of Relational error when I try to solve them
It's parsing the equations as being semicolon seperated, then recursively generating a sympy expression for them
For the = I'm using sym.Eq(a, b)
And then once I've got everything simplified as much as possible, it uses sym.solve() with a list of the expressions
Which is where the error occurs
Miguel Guthridge
@MiguelGuthridge
Ok nevermind it turns out that sympy doesn't work well with prettyprinting so I just had to stringify it first
AlphaVictorDelta
@AlphaVictorDelta
Hey guys,
My name is Adarsh V. Desai. I am an aspiring software developer. I would like to be a part of sympy and take my skills to the next level by learning new technologies while being an active contributor. I have already installed sympy (developer version) on my local system. Could you guys please point me towards what I should do next to become an active contributor and also understand the code base?
Thank you.
flxai
@flxai:matrix.org
[m]
You could help solving issues, prioritizing bugs: https://github.com/sympy/sympy/issues
Priyanshu Agarwal
@priyanshuone6
When I try sympy.vector.operators.Divergence('x') it gives me AttributeError: module 'sympy' has no attribute 'vector' but when I try from sympy.vector.operators import Divergence and Divergence('x') it works, could you please help me
Aaron Meurer
@asmeurer
The vector module is not imported by default so you have to import sympy.vector before you can access it.
nkr0
@nkr0
nkr0
@nkr0
I'm a bit confused with the Fr and Frstar outputs of Kane's method. Here I've printed them. Fr, shows Tx, which is the load/torque. Cool. Frstar has 3 terms. First one is Ixx ddeta; inertia x angular acceleration. ok. But the next 2 terms are Ixx Omega^2; inertia x angular velocity^2. why is it like that? Fr has the unit Nm, term 1 of Frstar has Nm.rad, others have Nm.rad^2. Is it because rad is an SI derived unit?
Gerardo Jose Suarez
@mcditoos
Hi. why is xconjugate(x)==abs(x)*2 false?
Kalevi Suominen
@jksuom

They are not structurally equal:

In [11]: srepr(x*conjugate(x))
Out[11]: "Mul(Symbol('x'), conjugate(Symbol('x')))"

In [12]: srepr(abs(x)**2)
Out[12]: "Pow(Abs(Symbol('x')), Integer(2))"

== denotes structural equality.

Gerardo Jose Suarez
@mcditoos
got it, is there other equality I can use for this kind of stuff?
Kalevi Suominen
@jksuom
You can use (abs(x)**2).rewrite(conjugate).
Sebastian Helm
@SebastianHelm
Just a quick question|remark: Under The Power of Symbolic Computation, where output is spread over several lines, it misaligns with most fonts. Which font is recommended for viewing this nicely? I only found it to work with Unifont, which isn't very pretty, though. Anyway, maybe the page can be rewritten to suggest such a font?
4 replies
Pieter Barendrecht
@pjbarendrecht

Hi guys, question about root finding with symbolic coefficients. Is it possible to get symbolic results for something like the following:

import sympy as sp
t = sp.Symbol('t')
P = sp.Poly(t**2 + 2*t + sp.log(2))
P.all_roots()

This does not work, as I get sympy.polys.polyerrors.PolynomialError: only univariate polynomials are allowed

Replacing the 3rd line with P = sp.Poly(t**2 + 2*t + sp.log(2), t, domain='RR') works for numerical values. Looking at the docs, I thought something like P = sp.Poly(t**2 + 2*t + sp.log(2), t, domain='QQ<log(2)>') might work, but this triggers a sympy.polys.polyerrors.NotAlgebraic: log(2) doesn't seem to be an algebraic element