Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Gagandeep Singh
@czgdp1807
@imnitishng Feel free to make a PR.
oponkork
@oponkork

Polynomial methods do not work well with floating point coefficients. The coefficients of a polynomial f can be made rational by F = nsimplify(f, rational=True). Then the roots of F can be found by roots(F, extension=I). (The flag tells that the coefficient domain is the rational field QQ extended by I.)

Aah, Alright thanks for the clarification. I fed the coefficients to numpy.roots to get the solutions!

rghers
@rghers
after making a change to the code, how do I compile it so that when i run isympy my change is visible. For example, I put a silly print statement in a function to test its execution, but when i run it in the isympy console, my print statement doesn't show up
Chris
@ChrisPattison

I have a pretty complicated expression as an integrand, and I want to integrate it numerically although I have to wrap some of the inner parts in UnevaluatedExpr to avoid choking the expression manipulation routines.

What sort of transformations does autowrap apply? .doit() or simplify? Can I get it to evaluate a definite integral numerically or am I stuck with autowrap'ing the integrand and applying scipy.quad?

Chris
@ChrisPattison
Also autowrap with the cython backend doesn't seem to properly handle complex valued expressions (attempts to assign complex to double, doesn't include complex.h) and sometimes attempts to use ** for pow
should I just be using Theano?
coldino
@coldino
Anyone help a total noob fix their understanding? Why can't I substitute a value for an integer symbol?
>>> I = Symbol('I') ; (2*I).subs({'I':4})
8
>>> I = Symbol('I', integer=True) ; (2*I).subs({'I':4})
2*I
Kalevi Suominen
@jksuom
The substitution (2*I).subs({'I':4}) will create a new symbol I with integer=None. It is different from the one defined before. To get the same symbol, you should write (2*I).subs({I:4}).
coldino
@coldino
Thanks! ...that easy...
Megan Ly
@meganly

I just synced my local fork of sympy with the master branch. When I run bin/test I get the following error:

MacBook-Pro:sympy meganly$ bin/test
Traceback (most recent call last):
  File "bin/test", line 105, in <module>
    import sympy
  File "/Users/meganly/sympy/sympy/__init__.py", line 64, in <module>
    from .concrete import *
  File "/Users/meganly/sympy/sympy/concrete/__init__.py", line 2, in <module>
    from .summations import summation, Sum
  File "/Users/meganly/sympy/sympy/concrete/summations.py", line 3, in <module>
    from sympy.calculus.singularities import is_decreasing
  File "/Users/meganly/sympy/sympy/calculus/__init__.py", line 4, in <module>
    from .singularities import (singularities, is_increasing,
  File "/Users/meganly/sympy/sympy/calculus/singularities.py", line 21, in <module>
    from sympy.solvers.solveset import solveset
  File "/Users/meganly/sympy/sympy/solvers/__init__.py", line 11, in <module>
    from .solvers import solve, solve_linear_system, solve_linear_system_LU, \
  File "/Users/meganly/sympy/sympy/solvers/solvers.py", line 542
SyntaxError: Non-ASCII character '\xe2' in file /Users/meganly/sympy/sympy/solvers/solvers.py on line 543, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Any ideas what's wrong for me locally?

Aaron Meurer
@asmeurer
I get the same error in Python 2. It looks like a bug was introduced somehow
can you open an issue for it
the problem will go away if you use Python 3, which is recommended as we will be dropping Python 2 support in a month or so
Megan Ly
@meganly
How do I use Python 3? I thought I was using Python 3 not Python 2
Aaron Meurer
@asmeurer
what is your python --version?
Megan Ly
@meganly
python --version is Python 2.7.10, python3 --version is Python 3.7.2
Aaron Meurer
@asmeurer
bin/test uses python
you can use python3 bin/test
either way this is a bug that should be fixed. it looks like there is a unicode dash in a docstring.
what is concerning is that the test suite didn't fail on Travis
Megan Ly
@meganly
Ok thanks @asmeurer! I'll open an issue for it if you like. I'm also still wondering if you have answer to my question about creating a subclass for Rational that I posted on Nov 27?
Aaron Meurer
@asmeurer
this pull request is relevant. I just checked, and it would have caught the error sympy/sympy#16272
Regarding the earlier question, it looks like the Rational constructor returns Half or Integer as relevant
at the end of Rational.__new__
I think you would need to override __new__ in your class and have it not do that
something along the lines of
obj = super(DecimalRational, self).__new__(p, q)
if not isinstance(obj, DecimalRational):
    obj = Expr.__new__(cls)
    obj.p = p
    obj.q = q
return obj
Aaron Meurer
@asmeurer
although I'm not sure if it would break things to have a Rational with a denominator 1
or Rational(1, 2) that isn't equal to S.Half.
Megan Ly
@meganly
Cool I'll give it a try. I really appreciate your help... I'm not the best programmer but am enjoying learning.
Aaron Meurer
@asmeurer
well __new__ is a somewhat advanced Python thing
but you have to use it when extending sympy like this
it's possible that you'd be better off defining a printer just for Rational to print it as a decimal
the issue is if there are cases where you don't want to print it as a decimal
or if you want to mix and match Rational and Decimal then that won't work
Megan Ly
@meganly
exactly, I want to mix and match Rationals and Decimals
but don't want floating point arithmetic errors
Aaron Meurer
@asmeurer
actually maybe you don't care about integers
just 1/2
so you really only need to check for that
Megan Ly
@meganly
Correct since integers will print the same, but I'd like 1/2 to print as .5
Aaron Meurer
@asmeurer
so test if obj is S.Half
it's possible some things might break with 1/2 because if code checks for if x is S.Half and x is DecimalRational(0.5) then it won't match
but there don't seem to be too many places in the code that do that, so maybe it won't be a problem
I guess the same code would need to work with Float(0.5) too.
Megan Ly
@meganly
Agreed. Currently DecimalRational('.5') has type S.Half, but I'm not sure we need to worry about Float(0.5) or other instances of 1/2
Aaron Meurer
@asmeurer
I opened an issue about the Python 2 error sympy/sympy#17999
Ashutosh Sharma
@spider0061
Hi, This is Ashutosh Sharma. I would like to work on issue #17739 as no one has made a PR on it. As a newbie to open source its a bit difficult for me to get started, can someone please help me on it so that I may start contributing.
Dhruv Jain
@Feetly
Hello, I am Dhruv Jain. I am a second-year undergraduate in Electrical Engineering. Studying at the Indian Institute of Technology, Dharwad, Karnataka, India (IIT-DH). I am proficient in git, Python, C/C++, Java, Latex, Differential Equations, and Complex Algebra. I am also eager to start contributing to this community as I love mathematics a lot and sympy deals with it the most. I have a lot of knowledge that can be implemented in sympy. After knowing sympy, I thought it lacks many functions as interactive plots (visualization), Matlab Convolution, shortcuts to solve ODE and PDE (like Legendre and Bessel, etc. ), Transformations: (like Trigonometric, Complex, Laplace, Fourier methods to implement), boundary problems and many more. I'm new to open source development. I'm really interested in contributing to the sympy. I'm also looking forward to GSOC-2020. Can anyone guide me on how to start expressing and contributing to the sympy?
Thank you.
Gagandeep Singh
@czgdp1807
Hi, Please read the contributing guide. In addition, also take a look at README. Take a look at this list for stalled PRs. Feel free to open a new one for continuing one of these.