Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 09:19
    johannesflake opened #22133
  • 08:11
    pnpolcher starred sympy/sympy
  • 06:41
    joeyskeys opened #22132
  • 06:15
    jonike starred sympy/sympy
  • 01:25
    rathmann commented #21903
  • 00:12
    rathmann commented #6662
  • Sep 21 23:00
    asmeurer commented #21945
  • Sep 21 20:29

    smichr on master

    point2D now will subclass Evalf… fixed failing tests test evalf for entities Also, … and 1 more (compare)

  • Sep 21 20:28
    smichr closed #22131
  • Sep 21 20:28
    smichr closed #22110
  • Sep 21 20:28
    smichr closed #22109
  • Sep 21 19:58
    asmeurer commented #9153
  • Sep 21 17:47
    oscarbenjamin commented #21945
  • Sep 21 17:25
    hanspi42 commented #21945
  • Sep 21 17:20
    sidhu1012 commented #21988
  • Sep 21 17:07
    sidhu1012 commented #21988
  • Sep 21 16:22
    bocklund updated the wiki
  • Sep 21 16:14
    tensorush starred sympy/sympy
  • Sep 21 16:03
    mostlyaman commented #21988
  • Sep 21 15:36
    mheidari98 starred sympy/sympy
Aaron Meurer
@asmeurer
The mathematical sets that numbers belong to is done in SymPy via the assumptions system. For example x.is_real will tell you if x is a real number. The Python classes are based on the implementation, which is why they are named after the representation. Calling Float Real would be inaccurate because it is only one possible representation of real numbers, and one that can't even represent all possible ones at that.
2 replies
Francesco
@cescofran_gitlab
I agree that Float should not be named Real, I'm not convinced should be named Float neither because of the arbitrary precsion... and so for Rational since is conflicting with is_rational (for example I find strange that Float(1.2).is_rational is None )... anyway thanks to you and @isuruf for all the clarifications!
Benoit Martin
@metabsd
Hi, There is a way to solve this with sympy ? Thx!!
image.png
image.png
Sidharth Mundhra
@0sidharth
@metabsd
>>> from sympy import *
>>> i = Symbol('i')
>>> a = 3 * i
>>> Sum(a, (i, 1, 5))
Sum(3*i, (i, 1, 5))
>>> Sum(a, (i, 1, 5)).doit()
45
>>> b = Sum(i, (i, 1, 10)) / Sum(i + 1, (i, 1, 10))
>>> b
Sum(i, (i, 1, 10))/Sum(i + 1, (i, 1, 10))
>>> b.doit()
11/13
>>> pprint(Sum(a, (i, 1, 5)))
  5      
 ___     
 ╲       
  ╲      
  ╱   3⋅i
 ╱       
 ‾‾‾     
i = 1    

>>> pprint(b)
     10      
    ___      
    ╲        
     ╲       
     ╱   i   
    ╱        
    ‾‾‾      
   i = 1     
─────────────
  10         
 ___         
 ╲           
  ╲          
  ╱   (i + 1)
 ╱           
 ‾‾‾         
i = 1
Ayush Bisht
@ayushbisht2001
hi everyone , I have been scrolling through sympy documentation and I get stuck in finding the lcm for more than 2 numbers. Is there a way to find the lcm for a set of numbers?
Sidharth Mundhra
@0sidharth
I'm not sure about sympy but python 3.9+ has math.lcm
Ayush Bisht
@ayushbisht2001
If we have a set in symbols then how can we compute LCM for that... I am seeking for sympy things... Using sympy.lcm, I compute the LCM for 2 numbers but I get errors for more numbers...
Muhammed Ali
@khabdrick
Hello everyone, to start contributing, do I clone the repo directly or fork it
almighty123789
@almighty123789
@khabdrick I think the standard procedure is to first fork and then clone from the remote on your account.
Mayank-gaur
@Mayank-gaur
HI! I am looking for some active issues for beginner so that I can start my journey with organization. I am a very hardworking guy but I am not finding any active issues and I have commented on many 'easy to fix' label issues but there also I am getting no reponse. Can someone please suggest some active and beginner friendly issues?
Ayush Bisht
@ayushbisht2001

@0sidharth , we can also do the same thing by passing a list of numbers to sympy.lcm( ) method.

import sympy
print(sympy.lcm([4,6,2]))
12

1 reply
Benoit Martin
@metabsd
Hi, there a way to pprint(simplify(e)) with explanation. Or all step to simplify ?
1 reply
Kartik Sethi
@ks147
hi there, is there some way to get a matrix with kth diagonal populated as input array, like Matlab's diag(A,k)
Ayush Bisht
@ayushbisht2001

from sympy import *
x,y,z = symbols("x y z")
exp = (x+z)&2
TypeError: unsupported operand type(s) for &: 'Add' and 'int'

how can we implement bitwise operation with sympy.

Sayandip Halder
@sayandip18
Currently, solve([x - 5], x) gives the dict {x: 5} as solution. However, solve([sin(x)], x) and solve([x**2-4],x) does not return a dict solution unless stated explicitly.
Shouldn't solve([x - 5], x) simply return [5]?
Benoit Martin
@metabsd
Normally when I divide I subtract exp but here it looks like the exp is being increased.
Benoit Martin
@metabsd
image.png
Benoit Martin
@metabsd
e25_4 = ((-4*a*b**2/-2*a**2*c**2) + (14*a**4*c/-2*a**2*c**2))
Result -7*a**6*c**3 + 2*a**3*b**2*c**2
1 reply
Ayush Bisht
@ayushbisht2001
can someone review my PR #20919
this one also , #20923
Aaron Meurer
@asmeurer
@ayushbisht2001 ilcm accepts any number of arguments
2 replies
moiseszeleny
@moiseszeleny

Hi everyone, can someone give me some recommendation to the next problem, I have a large expression lambdified, the problem is that has Nan results when I evaluate. I have found one term which causes this behavior and given by:

from sympy import init_printing,symbols,log,sqrt
init_printing()

m = symbols('m')
f = 0.5*log(1 - 3.13400648e+22/(1.56700324e+22*sqrt(1 - 1.5976993129893e-11*m)*sqrt(1.5976993129893e-11*m + 1) + 1.56700324e+22))

Then, when I substitute in $m=1e-3$

f.subs(m,1e-3)

Which give $\tilde{\infty}$. However, if I use evalf command I obtain

f.evalf(subs={m:1e-3})
-32.4607738174251 + 1.5707963267949*I

Then, I don't know what result is correct. Is this a problem of the precision of subs command?.

Aaron Meurer
@asmeurer
evalf is more accurate. The problem is that when using subs, the expression inside of the log is not evaluated to enough precision to distinguish it from 0
evalf(subs=...) handles cases like this where naive substitution leads to loss of significance
for lambdify, you are going to run into this same problem, because you are evaluating it naively. You will need to rewrite the expression somehow to avoid the massive cancellation.
Generally, you'd want to evaluate something like this using log1p.
Aaron Meurer
@asmeurer
You can use sympy.codegen.cfunctions.log1p. But I still get issues with it, so you need to make some other changes.
Maybe log1p isn't actually applicable here, since the argument is near 0, not near 1
Aaron Meurer
@asmeurer
If you are just using SymPy, you can fix this problem by converting the floats to rationals. Then subs will be able to evaluate it more accurately. But for lambdify to numpy, you will need to figure out how to rewrite the expression to be more numerically stable.
Aaron Meurer
@asmeurer
A suggestion would be to multiply and distribute a large value inside of the log then subtract the log of that value. That way the number evaluated in the log isn't so close to 0.
Ayush Bisht
@ayushbisht2001
@asmeurer , some of the test are failing in my PR's #20923 #20919, please do review.
1 reply
moiseszeleny
@moiseszeleny

@asmeurer Thanks for the suggestions and the explanation. My expression is too large because I obtained after some SymPy calculations and I do not how to rewrite the log function following your suggestions of multiply for a big number inside of log. I have tried to create a new log function like log_rewrite(x) = log(x*y) - log(y) with y a big number and after using lambdify command to the f function

from numpy import log as nplog
def log_rewritted(x):
    y = 1e30
    return nplog(x*y)-nplog(y)

fnp = lambdify([m],f,modules=[{'log':log_rewritted}])

However, I obtained the same result when I evaluate f,

fnp(1e-3) 
-inf.
Bilsteen
@Bilsteen
hey guys i am new to open source and an aspirant for gsoc 2021. i want to contribute towards sympy . can anyone guide me and help me towards what issue should be the best to start with
Aaron Meurer
@asmeurer
@moiseszeleny I think you are going to have to rewrite what is inside of the log too. It already rounds down to 0, so simply multiplying it by a larger number won't do anything.
Ayush Bisht
@ayushbisht2001
hello everyone , does use_unicode is False by default in pprint( )
1 reply
Ayush Bisht
@ayushbisht2001
I have tried to correct something in doc .Refer : #20919
Craig Russell
@ctr26
Can one use the integral transforms on numeric data?
Francesco
@cescofran_gitlab

Why

from sympy.abc import  x, k
from sympy import Sum

print(Sum(1/2**x, (x, 0, k)).evalf())

give 2.00000000000000 like it was an infinte series?

5 replies
Aaron Meurer
@asmeurer
Looks like a bug. Can you open an issue?
Francesco
@cescofran_gitlab
@asmeurer new to the project I will try to look at the reccomanded way to write a issue ..
but if someone already familiar with process do it before ...I will learn directly from it ..
Aaron Meurer
@asmeurer
It's not that complicated. Just go to https://github.com/sympy/sympy/issues/new and note the example that is wrong.
Ayush Bisht
@ayushbisht2001
#4886 I want to work on this issue , can someone suggest me how to start?? where the test file should be added . I am unable to figure out it.
Ayush Bisht
@ayushbisht2001
I have found some conflict with my PR #20935 , can someone help me ??
Francesco
@cescofran_gitlab
Sum(x**2, (x, 1, k)).evalf() and expression which derivative is not a constant raise TypeError
this should come from the euler_maclaurin when it compare a symbolic expression to a float...
why the code does not take in consideration the symbolic case?
Janmay Bhatt
@JANMAY007
Hi everyone, I am Janmay from Nirma University, India and I want to contribute into sympy library. I am CSE student, second year. I have done a research in mathematics related to prime numbers which is prime conjecture(here https://www.ijmttjournal.org/archive/ijmtt-v60p505).
This research have function for series of prime numbers and you can generate the any prime with a reference. I have read about the contribution in sympy so may someone please guide me about gsoc