## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
• 12:33
Lsacy forked
• 12:29
sympy-bot commented #22555
• 12:29
anutosh491 opened #22555
• 12:28
ThePauliPrinciple commented #22549
• 12:15
oscargus commented #22549
• 12:01
github-actions[bot] commented #22376
• 11:50
oscargus commented #22376
• 11:03
ThePauliPrinciple commented #22553
• 10:59
hanspi42 synchronize #22376
• 10:58
hanspi42 commented #22376
• 10:55
hanspi42 synchronize #22376
• 10:50
hanspi42 synchronize #22376
• 10:46
hanspi42 synchronize #22376
• 10:29
asmeurer closed #22552
• 10:29
asmeurer commented #22552
• 09:12
github-actions[bot] commented #22554
• 09:12

smichr on master

Revert "Fix benchmarks build on… Merge pull request #22554 from … (compare)

• 09:12

smichr on revert-22481-benchmarks-ci-fix

• 09:11
smichr closed #22554
• 09:02
hanspi42 synchronize #22376
Aaron Meurer
@asmeurer
This seems related sympy/sympy#19627
I guess you can do something with replace with a pattern.
>>> a, b, c = Wild('a'), Wild('b'), Wild('c')
>>> expr.replace((a**b)**c, a**(b*c))
y
thorek1
@thorek1
yeah thats probably a good way to go
I get the solution assuming alpha is an integer but that doesnt seem very safe
thorek1
@thorek1
laolux
@laolux:privacytools.io
[m]
I have some issue with integrating the Heaviside function. Usually I would expect integrate(Heaviside(x,0), (x,-1,1) =1, but instead sympy returns Integral(Heaviside(x, 0), (x, -1, 1)). Works fine if I omit the second argument of Heaviside, but I think it should work in any case, as the value at x=0 is irrelevant for the integration (set of measure zero).
Is there something I am missing, or should I report it as a bug?
Kalevi Suominen
@jksuom

@laolux:privacytools.io Many integrators like meijerint work by looking up the results in a table. The table may contain Heaviside(x) but not Heaviside(x, 0) which is a different object.

>>> Heaviside(x) == Heaviside(x, 0)
False

It may be possible to extend the matching code to handle this but that may not be easy to implement. Another entry should probably be added.

laolux
@laolux:privacytools.io
[m]
@jksuom Thanks for the explanation. I read im the documentation that “Heaviside(x)==Heaviside(x, None)”, but for integration that should not matter. But now I understand that sympy takes different ways to evaluate these functions. Anyways, “meijerint” seems to have some more issues with Heaviside, as I commented on github:
JSS95
@JSS95
@asmeurer can you take a look at #21423, please?
Richard Pausch
@PrometheusPi

I ran into the following issue/error while trying to get the extrema of a simple 4th order polynomial:

import sympy as sym

x_sym = sym.symbols("x", real=True) # single variable

pot_sym = x_sym**4 - x_sym**2 + x_sym * 1/10 # function f
pot_prime_sym = sym.diff(pot_sym, x_sym) # first derivative of function df/fx

extrema = sym.solve(pot_prime_sym) # get extrema via df/dx == 0
for extremum in extrema:
print(sym.N(extremum), " == ", sym.N(sym.simplify(extremum))) # print values

returns:

0.050253826762553 - 0.e-23*I  ==  0.050253826762553 + 3.70576914423756e-22*I
0.680639276423668 + 0.e-23*I  ==  0.680639276423668
-0.730893103186221 + 0.e-23*I  ==  -0.730893103186221

The last two results are equal, but the first entry does seem to cause an error of I simplify the result before returning its numeric value. There should be no complex contribution 3.7e-22*I, thus something goes wrong here.

Is this a know issue, did I do something wrong, or is this a not-yet know issue and I should open a issue on github?

I am using sympy 1.7.1.

Kalevi Suominen
@jksuom
It is a known issue that is hard to avoid when working with complex floating point numbers. (There is an imaginary part because solve does not know that the result should be real.) For real floating point roots, it is often better to use nroots.
Richard Pausch
@PrometheusPi
@jksuom Thanks for the fast reply. nroots worked like a charm :+1:. If it is a know issue, I will refrain from opening another issue on GitHub.
fakuivan
@fakuivan
Hello
Is there a way to programmatically convert an expression with derived units to the equivalent with base units?
fakuivan
@fakuivan
what I have now is convert_to(expr, system._base_units) and then xreplace the base units
Emil Jiří Tywoniak
@EmilJ_gitlab
Hi, is there a way of defining a PDE with curl? It seems to me like curl operates by just... trying to compute the curl immediately.
H = Function('H')(x,y,z)
# H = cross.x *
print(type(curl(H)))
this tells me the curl of this unknown function is VectorZero
fakuivan
@fakuivan
doit=False maybe?
print(type(curl(H, doit=False)))
Emil Jiří Tywoniak
@EmilJ_gitlab
Hmm, right now H is acting like a scalar field, but how do I make it not... be that... without defining it
Emil Jiří Tywoniak
@EmilJ_gitlab
Hx = Function('Hx')(x,y,z)
Hy = Function('Hy')(x,y,z)
Hz = Function('Hz')(x,y,z)
delop = Del()
T = CoordSys3D(r'\$\bot')
H = Hx*T.x + Hy*T.y + Hz*T.z
print(type(delop.cross(H)))
AttributeError: 'Add' object has no attribute 'dot'
no clue.
Kalevi Suominen
@jksuom
H is an Add object whose arguments are Mul objects, not a vector.
In [10]: srepr(H)
Out[10]: "Add(Mul(T.x, Function('Hx')(Symbol('x'), Symbol('y'), Symbol('z'))), Mul(T.y, Function('Hy')(Symbol('x'), Symbol('y'), Symbol('z'))), Mul(T.z, Function('Hz')(Symbol('x'), Symbol('y'), Symbol('z'))))"
Samuel Lelièvre
@slel
On the SymPy page at PyPI, the "SymPy Banner" image does not display properly.
Felix Hildén
@felix-hilden

Hi, I'd like to express a vector norm with indexed variables for differentation, but I don't quite know how. Every search I came up with led to matrix norms, which aren't really in question here. The variables are indeed vectors, but I don't care about the dimensionality in this case. Formulating a difference is easy enough, but I'm not sure how to continue.

# || x_a - y_b ||

x = sp.IndexedBase('x')
a = sp.Idx('a')
y = sp.IndexedBase('y')
b = sp.Idx('b')

diff = (x[a] - y[b])

How could this be achieved? I'm open for any other formulations as well! Much appreciated.

hackman01
@hackman01
i was trying to solve this issue #21463 but was not able to find source code of convert_to
Kalevi Suominen
@jksuom
sympy/physics/units/quantities.py: def convert_to(self, other, unit_system="SI")
samsja
@samsja:matrix.org
[m]
HI everybody, I am looking for a way to symbolically minimize a multivariate function. The sympy maximize function only work on monovariate function ( or at least what I understand out of the documentationI). What could I do ? I already try the approach of resolving the system where the gradient equal zero and then take the min of it however it does not include solution with unbound variable like the maximise function do by outputing things like infinity. Thanks in advance 🙂
Vishesh Mangla
@Teut2711
import sympy as sm
from sympy import I
w = sm.symbols("omega")
exp = 20/(I*w+1)/(I*w+2)/(I*w+3)
sm.simplify(exp)
how to simplify it? I want the w corresponding to which the imaginary part is 0
sm.solve(sm.arg(exp)) gives []
here too
Isuru Fernando
@isuruf
You need to add the assumption that omega is real.
Vishesh Mangla
@Teut2711
w = sm.symbols("omega", real=True ) sorry no effect
Isuru Fernando
@isuruf
try expanding
Vishesh Mangla
@Teut2711
better but not exactly what I require
this is good but
thanks @isuruf
Vishesh Mangla
@Teut2711
thanks again
Vishesh Mangla
@Teut2711