Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 14:23
    oscarbenjamin closed #23547
  • 14:23
    oscarbenjamin commented #23547
  • 14:07
    linjing-lab opened #23547
  • 12:40
    hirawatt starred sympy/sympy
  • 08:09
    OMH-G commented #23375
  • 08:06
    OMH-G closed #23546
  • 07:59
    asmeurer commented #22429
  • 07:56
    sympy-bot commented #23546
  • 07:56
    OMH-G edited #23546
  • 07:55
    sympy-bot commented #23546
  • 07:55
    OMH-G edited #23546
  • 07:53
    sympy-bot commented #23546
  • 07:53
    OMH-G edited #23546
  • 07:27
    OMH-G synchronize #23546
  • 07:11
    sympy-bot commented #23546
  • 07:11
    OMH-G synchronize #23546
  • 07:04
    sympy-bot commented #23546
  • 07:04
    OMH-G edited #23546
  • 07:01
    sympy-bot commented #23546
sajen sarvajith
@sajenjeshan1222
can mentors say how should I submit proposal and apply for writing docs ?
Aaron Meurer
@asmeurer
See https://groups.google.com/g/sympy/c/PUh3g_NPy-c for instructions on applying for GSoD
Megan Ly
@meganly
Why does cancel no longer make the leading coefficients of the polynomials are positive? In Sympy 1.6 cancel((1-x)/(x**2-3)) is -(x-1)/(x**2-3) whereas in Sympy 1.7 it is (1-x)/(x**2-3)
1 reply
Also why does factor(10+5*I) no longer factor to 5*(2+I)?
sajen sarvajith
@sajenjeshan1222
See https://groups.google.com/g/sympy/c/PUh3g_NPy-c for instructions on applying for GSoD
Ok
oostben
@oostben
I'm trying to make the expand_trig function work for tanh (see #21365). I have a hacky solution that works for tanh(x+y), tanh(2x). However, I modeled my solution off of the tan, cosh, and sinh _eval_expand_trig methods and I'm running into problems, because the tan function seems to use (1+ iz)**coefficient, and then takes the real and imaginary parts of it, if the coefficient on the expression being multiplied is greater than 1. However this doesn't work for tanh. I'm assuming this is why it was never implemented for tanh. Does anyone have a better way of expanding tanh(coefficientx) for arbitrary coefficient>1?
Aaron Meurer
@asmeurer
Can you use the fact that tanhix=itanx\tanh ix = i\tan x?
Richard Pausch
@PrometheusPi

I am trying to simplify a general Taylor series of function f:

f = sym.Function('f')
x, x_0, h = sym.symbols("x x_0 h", real=True)
# works fine:
ts = sym.series(f(x),x, x_0, 4)

# but substituting x-x_0 by h
ts.subs(x-x_0,h)
# just returns 𝑂(1;𝑥→𝑥0)

Why is the (x-x0) in the Taylor series not substituted correctly?

Parseval Gramalot
@PGramalot_gitlab
I thought people answered questions here. Seems like a ghost town. Good day.
erentar2002
@erentar2002:matrix.org
[m]
yeah, happens
good luck for finding an answer
Kalevi Suominen
@jksuom

@PrometheusPi subs will replace a sum like x - x_0 (= x + (-1)*x_0) in an expression only if that is also a sum that contains the same arguments:

In [19]: (x - x_0 + 1).subs(x - x_0, h)                                         
Out[19]: h + 1

Otherwise, one must substitute x alone:

In [24]: print(ts.subs(x, x_0 + h))                                             
f(x_0) + h*Subs(Derivative(f(_xi_1), _xi_1), _xi_1, x_0) + h**2*Subs(Derivative(f(_xi_1), (_xi_1, 2)), _xi_1, x_0)/2 + h**3*Subs(Derivative(f(_xi_1), (_xi_1, 3)), _xi_1, x_0)/6 + O(h**4)
Richard Pausch
@PrometheusPi
@jksuom Thanks a lot for your fast answer. That helped tremendously. (I was not aware of the fact, that subs requires the substitution to be part of a sum. And I did not think of just replacing a single variable instead.)
Aaron Meurer
@asmeurer
@PGramalot_gitlab your question is a bit lengthy. You may be better off asking it on the mailing list.
Megan Ly
@meganly
How can I modify the latex printer the print the standard basis vectors as \mathbf{i}, \mathbf{j}, and \mathbf{k}? Currently the vectors get printed as follows
>>> C = CoordSys3D('C')
>>> i, j, k = C.base_vectors()
>>> latex(i)
'\\mathbf{\\hat{i}_{C}}'
Kalevi Suominen
@jksuom
@meganly The formatting of base vectors is hard-coded and cannot be given as a parameter. I would implement a subclass redefining the formatting. Something like this (untested):
class MyCoordSys3D(CoordSys3D):
    def __init__(self):
        self.latex_vects = [r'\mathbf{%s}' % n for n in self.vector_names]
Aaron Meurer
@asmeurer
There's a parameter in the CoordSys3D that lets you set these
Also if you use a custom printer that should take precedence over the defaults.
I don't like how the vector module defines the printers on the objects. SymPy library classes should define printing on the printer classes. I also don't like how it precomputes the latex form at construction time.
Vishesh Mangla
@Teut2711
import sympy as sm

s, Kc, tau_i = sm.symbols("s K_c tau_i")

Gc = Kc*(1+1/(tau_i*s))
Gv = 1
Gp =1/(s**2 + 2*s + 2)
Gm = 1

eq = 1 +Gc*Gv*Gp*Gm
How to get the eq's numerator with leading coefficient as 1?
Megan Ly
@meganly

Thanks for the help @jksuom and @asmeurer . I tried

C= CoordSys3D('C', vector_names = ["\mathbf{i}", "\mathbf{j}", "\mathbf{k}"])

and now the latex for the base vector i is '\mathbf{\hat{\mathbf{i}}_{C}}'.
However, implementing a subclass to do custom printing should work.

thorek1
@thorek1
under which conditions does the follwoing simplify to y? simplify((y^(1/(1-alpha)))^(1 - alpha))
Aaron Meurer
@asmeurer
Look at the docstring of powdenest.
You need assumptions on either y or alpha.
thorek1
@thorek1
@vars alpha positive = true
@vars y real = true
still doesnt work
it seems i would need sympy to understand that 0 < alpha < 1
but i dont know how
powdenest((y^(1/(alpha)))^(alpha),force=true) works finde
Aaron Meurer
@asmeurer
I don't think that is sufficient. Consider y = -1 and alpha = 1/2
thorek1
@thorek1
true, in fact y > 0 and 0<alpha<1
docstring of powdenest doesnt help much in this case it seems
Aaron Meurer
@asmeurer
SymPy doesn't currently have a way to tell powdenest that alpha is less than 1. Using force=True is the best way, after manually verifying that the simplification is mathematically correct.
thorek1
@thorek1
ok, what is the best workaround then?
Aaron Meurer
@asmeurer
force=True
thorek1
@thorek1
doesnt get me there
@vars alpha y positive = true
powdenest((y^(1/(1-alpha)))^(1 - alpha))
Aaron Meurer
@asmeurer
only other option is to do a change of variables that lets you use the assumptions that sympy supports, like positive=True
oh hmm
thorek1
@thorek1
hmm, manually catch all int +/- var cases and replace them
Aaron Meurer
@asmeurer
that's a bug I guess
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
thanks for your quick reply!
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.