## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Repo info
• • • • • • • • • • • • • • • • • • • • • • • • • ##### Activity
• Oct 19 23:10
smichr commented #22328
• Oct 19 23:07
asmeurer commented #22324
• Oct 19 23:03
smichr commented #22324
• Oct 19 23:00
smichr commented #22324
• Oct 19 22:51
sympy-bot commented #22327
• Oct 19 22:51
smichr synchronize #22327
• Oct 19 22:45
asmeurer commented #22324
• Oct 19 22:43
sympy-bot commented #22324
• Oct 19 22:43
asmeurer edited #22324
• Oct 19 22:07
github-actions[bot] commented #22286
• Oct 19 21:31
eagleoflqj opened #22328
• Oct 19 21:03
bjodah commented #22326
• Oct 19 21:03
bjodah commented #22326
• Oct 19 20:55
smichr synchronize #22327
• Oct 19 20:36
smichr synchronize #22286
• Oct 19 20:03

oscarbenjamin on master

add strict/weak to Relational simplify Or(x?=y,And(x?y, z)) a… Merge pull request #22317 from … (compare)

• Oct 19 20:03
oscarbenjamin closed #22317
• Oct 19 20:03
oscarbenjamin closed #22300
• Oct 19 19:54
smichr synchronize #22286
• Oct 19 19:48
MarkCBell commented #21016 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 : srepr(H)
Out: "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. 1 reply 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 better but not exactly what I require
this is good but
thanks @isuruf Vishesh Mangla
@Teut2711
thanks again abs gives whats expected but sm.arg doesn't , what else can be done to get the argument?
some function which does this is required I m trying to make a table like this, where each many cells of the matrix should contain unevaluated determinants
gives Vishesh Mangla
@Teut2711
row += [sm.Mul(sm.Matrix([
[row1, row2[k] ],
[row2, row2[k]]
]), -1/row2, evaluate=False)]
so I did get a Matrix in matrix as expected but the evaluate=False didnt work. What is that am I doing wrong? Aaron Meurer
@asmeurer
you probably need to use MatMul Gaurav Dhingra
@gxyd

Hey guys, I'm trying to use parse_latex function as below:

In : from sympy.parsing.latex import parse_latex

In : r = "5^0 - 4^0"

In : parse_latex(r)
ANTLR runtime and generated code versions disagree: 4.9.2!=4.7.2
ANTLR runtime and generated code versions disagree: 4.9.2!=4.7.2
Out: -1 + 5**0

Is there anyway, I can stop parse_latex to render it as 5^ 0 - 4^0 and now evaluate 4^0 as 1? Vishesh Mangla
@Teut2711

you probably need to use MatMul

yes , that was it. thanks