Re: [sympy] New to sympy: Implement Spherical Coordinates in Vector module

2014-12-06 Thread Francesco Bonazzi
I published a gist on how to get the gradient in any coordinate system, given the backward transformation to rectangular coordinates. I was also trying to write the code to get the divergence, but I ran into problems with sympy's simplify( ) function. https://gist.github.com/Upabjojr/34f75ce115

Re: [sympy] Sympy assumptions

2014-12-06 Thread Yuxiang Wang
Hi Richard, I do get your point that we don't have to make the same mistake with other systems, but I do think there is a benefit for consistency, if they have a purpose in doing that design. For most systems, sqrt() returns the principal/positive square root, so there is only one unique value.

Re: [sympy] Sympy assumptions

2014-12-06 Thread Ondřej Čertík
Hi Richard, On Fri, Dec 5, 2014 at 4:48 PM, Richard Fateman wrote: > You are heading into erroneous waters. > It doesn't matter that 3>0. sqrt(9) has two values, +3 and -3. > Just because some other systems make this mistake does not mean > sympy should do this. > > If you want to say something

Re: [sympy] Sympy assumptions

2014-12-06 Thread Aaron Meurer
Something that I'm not sure about with representing functions as multivalued is, how do you represent arbitrary Riemann surfaces. Another question is computational. How do you compute the surfaces in general (say even for a limited class of expressions, like algebraic functions), and how do you ma

Re: [sympy] New to sympy: Implement Spherical Coordinates in Vector module

2014-12-06 Thread Alan Bromborsky
This is what I do for sqrt of real expression x (I want sqrt(abs(x)) without the abs() function in the result unless it is unavoidable) def square_root_of_expr(expr): if expr.is_number: if expr > 0: return(sqrt(expr)) else: return(sqrt(-expr)) els

[sympy] Point class repeatedly returns a hardcoded Point class

2014-12-06 Thread Duane Nykamp
The Point class, for numerous functions, such as .evalf, returns a hard coded Point class. This means that for a derived class, these functions end up returning the original Point class not the derived class. I assume there must be a way to code it differently so these functions return the de

Re: [sympy] Point class repeatedly returns a hardcoded Point class

2014-12-06 Thread Aaron Meurer
This is an issue in a lot of places in SymPy (see https://github.com/sympy/sympy/issues/6751). The solution is to always reference the class indirectly via self, and make use of super(), isinstance(), and issubclass() (the exception is that the class does have to be named explicitly in the argument

[sympy] Re: Point class repeatedly returns a hardcoded Point class

2014-12-06 Thread Duane Nykamp
Well, upon closer examination, I find many uses of Point in point.py that I don't know how to fix. I think my Python knowledge isn't quite there yet. It appears many of the functions are intended be called off the class rather than an instance, such as Point.is_collinear(p1, p2, p3, p4) de

Re: [sympy] Sympy assumptions

2014-12-06 Thread Joachim Durchholz
Am 06.12.2014 um 17:03 schrieb Yuxiang Wang: Hi Richard, I do get your point that we don't have to make the same mistake with other systems, but I do think there is a benefit for consistency, if they have a purpose in doing that design. For most systems, sqrt() returns the principal/positive squ

Re: [sympy] Sympy assumptions

2014-12-06 Thread Ondřej Čertík
On Sat, Dec 6, 2014 at 1:01 PM, Aaron Meurer wrote: > Something that I'm not sure about with representing functions as > multivalued is, how do you represent arbitrary Riemann surfaces. > > Another question is computational. How do you compute the surfaces in > general (say even for a limited clas

Re: [sympy] Re: Point class repeatedly returns a hardcoded Point class

2014-12-06 Thread Aaron Meurer
This really should be a class method: @classmethod def is_collinear(cls, *points) points = [cls(a) for a in points] Note that this breaks backwards compatibility with the method being called on an instance. Previously it would work, because the instance would be the first element of points (w

Re: [sympy] Sympy assumptions

2014-12-06 Thread Yuxiang Wang
Hi Joachim, I was thinking of Mathematica and MATLAB Symbolic Toolbox, and both doing symbolic math rather than numerical systems. My experience is limited to these two though (that's the two my institution got a license for), so I'd be open to hear on more example / counter-examples. -Shawn