GithubHelp home page GithubHelp logo

sympy / sympy Goto Github PK

View Code? Open in Web Editor NEW
12.4K 295.0 4.3K 180.42 MB

A computer algebra system written in pure Python

Home Page: https://sympy.org/

License: Other

Python 98.50% Shell 0.01% Scheme 0.01% XSLT 1.42% ANTLR 0.04% Perl 0.03% JavaScript 0.01%
python math computer-algebra science hacktoberfest

sympy's Introduction

SymPy

pypi version Join the chat at https://gitter.im/sympy/sympy Zenodo Badge Downloads GitHub Issues Git Tutorial Powered by NumFocus Commits since last release

SymPy Banner

See the AUTHORS file for the list of authors.

And many more people helped on the SymPy mailing list, reported bugs, helped organize SymPy's participation in the Google Summer of Code, the Google Highly Open Participation Contest, Google Code-In, wrote and blogged about SymPy...

License: New BSD License (see the LICENSE file for details) covers all files in the sympy repository unless stated otherwise.

Our mailing list is at https://groups.google.com/forum/?fromgroups#!forum/sympy.

We have a community chat at Gitter. Feel free to ask us anything there. We have a very welcoming and helpful community.

Download

The recommended installation method is through Anaconda, https://www.anaconda.com/products/distribution

You can also get the latest version of SymPy from https://pypi.python.org/pypi/sympy/

To get the git version do

$ git clone https://github.com/sympy/sympy.git

For other options (tarballs, debs, etc.), see https://docs.sympy.org/dev/install.html.

Documentation and Usage

For in-depth instructions on installation and building the documentation, see the SymPy Documentation Style Guide.

Everything is at:

https://docs.sympy.org/

You can generate everything at the above site in your local copy of SymPy by:

$ cd doc
$ make html

Then the docs will be in _build/html. If you don't want to read that, here is a short usage:

From this directory, start Python and:

>>> from sympy import Symbol, cos
>>> x = Symbol('x')
>>> e = 1/cos(x)
>>> print(e.series(x, 0, 10))
1 + x**2/2 + 5*x**4/24 + 61*x**6/720 + 277*x**8/8064 + O(x**10)

SymPy also comes with a console that is a simple wrapper around the classic python console (or IPython when available) that loads the SymPy namespace and executes some common commands for you.

To start it, issue:

$ bin/isympy

from this directory, if SymPy is not installed or simply:

$ isympy

if SymPy is installed.

Installation

SymPy has a hard dependency on the mpmath library (version >= 0.19). You should install it first, please refer to the mpmath installation guide:

https://github.com/fredrik-johansson/mpmath#1-download--installation

To install SymPy using PyPI, run the following command:

$ pip install sympy

To install SymPy using Anaconda, run the following command:

$ conda install -c anaconda sympy

To install SymPy from GitHub source, first clone SymPy using git:

$ git clone https://github.com/sympy/sympy.git

Then, in the sympy repository that you cloned, simply run:

$ pip install .

See https://docs.sympy.org/dev/install.html for more information.

Contributing

We welcome contributions from anyone, even if you are new to open source. Please read our Introduction to Contributing page and the SymPy Documentation Style Guide. If you are new and looking for some way to contribute, a good place to start is to look at the issues tagged Easy to Fix.

Please note that all participants in this project are expected to follow our Code of Conduct. By participating in this project you agree to abide by its terms. See CODE_OF_CONDUCT.md.

Tests

To execute all tests, run:

$./setup.py test

in the current directory.

For the more fine-grained running of tests or doctests, use bin/test or respectively bin/doctest. The master branch is automatically tested by GitHub Actions.

To test pull requests, use sympy-bot.

Regenerate Experimental LaTeX Parser/Lexer

The parser and lexer were generated with the ANTLR4 toolchain in sympy/parsing/latex/_antlr and checked into the repo. Presently, most users should not need to regenerate these files, but if you plan to work on this feature, you will need the antlr4 command-line tool (and you must ensure that it is in your PATH). One way to get it is:

$ conda install -c conda-forge antlr=4.11.1

Alternatively, follow the instructions on the ANTLR website and download the antlr-4.11.1-complete.jar. Then export the CLASSPATH as instructed and instead of creating antlr4 as an alias, make it an executable file with the following contents:

#!/bin/bash
java -jar /usr/local/lib/antlr-4.11.1-complete.jar "$@"

After making changes to sympy/parsing/latex/LaTeX.g4, run:

$ ./setup.py antlr

Clean

To clean everything (thus getting the same tree as in the repository):

$ git clean -Xdf

which will clear everything ignored by .gitignore, and:

$ git clean -df

to clear all untracked files. You can revert the most recent changes in git with:

$ git reset --hard

WARNING: The above commands will all clear changes you may have made, and you will lose them forever. Be sure to check things with git status, git diff, git clean -Xn, and git clean -n before doing any of those.

Bugs

Our issue tracker is at https://github.com/sympy/sympy/issues. Please report any bugs that you find. Or, even better, fork the repository on GitHub and create a pull request. We welcome all changes, big or small, and we will help you make the pull request if you are new to git (just ask on our mailing list or Gitter Channel). If you further have any queries, you can find answers on Stack Overflow using the sympy tag.

Brief History

SymPy was started by Ondřej Čertík in 2005, he wrote some code during the summer, then he wrote some more code during summer 2006. In February 2007, Fabian Pedregosa joined the project and helped fix many things, contributed documentation, and made it alive again. 5 students (Mateusz Paprocki, Brian Jorgensen, Jason Gedge, Robert Schwarz, and Chris Wu) improved SymPy incredibly during summer 2007 as part of the Google Summer of Code. Pearu Peterson joined the development during the summer 2007 and he has made SymPy much more competitive by rewriting the core from scratch, which has made it from 10x to 100x faster. Jurjen N.E. Bos has contributed pretty-printing and other patches. Fredrik Johansson has written mpmath and contributed a lot of patches.

SymPy has participated in every Google Summer of Code since 2007. You can see https://github.com/sympy/sympy/wiki#google-summer-of-code for full details. Each year has improved SymPy by bounds. Most of SymPy's development has come from Google Summer of Code students.

In 2011, Ondřej Čertík stepped down as lead developer, with Aaron Meurer, who also started as a Google Summer of Code student, taking his place. Ondřej Čertík is still active in the community but is too busy with work and family to play a lead development role.

Since then, a lot more people have joined the development and some people have also left. You can see the full list in doc/src/aboutus.rst, or online at:

https://docs.sympy.org/dev/aboutus.html#sympy-development-team

The git history goes back to 2007 when development moved from svn to hg. To see the history before that point, look at https://github.com/sympy/sympy-old.

You can use git to see the biggest developers. The command:

$ git shortlog -ns

will show each developer, sorted by commits to the project. The command:

$ git shortlog -ns --since="1 year"

will show the top developers from the last year.

Citation

To cite SymPy in publications use

Meurer A, Smith CP, Paprocki M, Čertík O, Kirpichev SB, Rocklin M, Kumar A, Ivanov S, Moore JK, Singh S, Rathnayake T, Vig S, Granger BE, Muller RP, Bonazzi F, Gupta H, Vats S, Johansson F, Pedregosa F, Curry MJ, Terrel AR, Roučka Š, Saboo A, Fernando I, Kulal S, Cimrman R, Scopatz A. (2017) SymPy: symbolic computing in Python. PeerJ Computer Science 3:e103 https://doi.org/10.7717/peerj-cs.103

A BibTeX entry for LaTeX users is

@article{10.7717/peerj-cs.103,
 title = {SymPy: symbolic computing in Python},
 author = {Meurer, Aaron and Smith, Christopher P. and Paprocki, Mateusz and \v{C}ert\'{i}k, Ond\v{r}ej and Kirpichev, Sergey B. and Rocklin, Matthew and Kumar, Amit and Ivanov, Sergiu and Moore, Jason K. and Singh, Sartaj and Rathnayake, Thilina and Vig, Sean and Granger, Brian E. and Muller, Richard P. and Bonazzi, Francesco and Gupta, Harsh and Vats, Shivam and Johansson, Fredrik and Pedregosa, Fabian and Curry, Matthew J. and Terrel, Andy R. and Rou\v{c}ka, \v{S}t\v{e}p\'{a}n and Saboo, Ashutosh and Fernando, Isuru and Kulal, Sumith and Cimrman, Robert and Scopatz, Anthony},
 year = 2017,
 month = Jan,
 keywords = {Python, Computer algebra system, Symbolics},
 abstract = {
            SymPy is an open-source computer algebra system written in pure Python. It is built with a focus on extensibility and ease of use, through both interactive and programmatic applications. These characteristics have led SymPy to become a popular symbolic library for the scientific Python ecosystem. This paper presents the architecture of SymPy, a description of its features, and a discussion of select submodules. The supplementary material provides additional examples and further outlines details of the architecture and features of SymPy.
         },
 volume = 3,
 pages = {e103},
 journal = {PeerJ Computer Science},
 issn = {2376-5992},
 url = {https://doi.org/10.7717/peerj-cs.103},
 doi = {10.7717/peerj-cs.103}
}

SymPy is BSD licensed, so you are free to use it whatever you like, be it academic, commercial, creating forks or derivatives, as long as you copy the BSD statement if you redistribute it (see the LICENSE file for details). That said, although not required by the SymPy license, if it is convenient for you, please cite SymPy when using it in your work and also consider contributing all your changes back, so that we can incorporate it and all of us will benefit in the end.

sympy's People

Contributors

aktech avatar asmeurer avatar bertiewooster avatar bjodah avatar brocksam avatar cbm755 avatar certik avatar czgdp1807 avatar debugger22 avatar ethankward avatar gxyd avatar jegerjensen avatar jksuom avatar jrioux avatar jss95 avatar mattpap avatar mijo2 avatar moorepants avatar navytux avatar oscarbenjamin avatar oscargus avatar pernici avatar rlamy avatar sidhu1012 avatar skirpichev avatar smichr avatar smit-create avatar sylee957 avatar tjstienstra avatar upabjojr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sympy's Issues

pylint score

pylint is a tool for checking code quality in python code. 

I attach the log of running pylint in sympy. While sometimes he says
nonsense, in some cases he is right and we should follow what he says. 

currently our score is 0.55 / 10 mainly because of missing docstrings,
style issues and circular dependencies (this last thing will hardly be
corrected). 

I propose with this issue to achieve at least a score of 5/10

Original issue for #3148: http://code.google.com/p/sympy/issues/detail?id=49

Original author: https://code.google.com/u/103948515893177094863/

noncommutative objects (matrices)

I want to implement matrices and their multiplication using python *. the
**mul**(a,b) method should however return an NCMul(a,b).

The current NCMul implementation doesn't work:

In [4]: NCMul((x,z,x,z))
Out[4]: x^2*z^2

This is wrong. My idea is that the commutation is a feature of the objects
involved (Numbers, symbols, functions, matrices), not of the multiplication
itself. So my idea is that Basic.commutative() variable will return True by
default, and Matrix.commutative() will return False. The class Mul will
rearange the terms according to the result of commutative() method and I
will remove the NCMul. This should allow us to simplify things like:

A_b_B_3_C    --->   3_b_A_B_C

where A,B and C are (compatible) matrices, b is a symbol which commutes
with matrices and 3 is a number.

By default, the Matrix should look just like a noncommutative symbol. 

There should however also be a mode, which would allow us to calculate the
matrix multiplication directly and return a new matrix. So I think we could
have a class:

NCSymbol, which would be a noncommutative symbol, the class Mul will take
care of that. And Matrix will be a subclass of NCSymbol. 

Actually, I think we could have 2 classes just below Basic:

CommutativeObject and NoncommutativeObject.

Where subclasses of CommutativeObject are Number, Symbol, Function...
and subclasses of NoncommutativeObject are NCSymbol, Matrix, ....

But this adds another level of complexity to sympy, so I think I will just
implement the commutative() approach for the time being, and we'll see how
it goes.

Ondrej

Original issue for #3130: http://code.google.com/p/sympy/issues/detail?id=31

Original author: https://code.google.com/u/104039945248245758823/

Original owner: https://code.google.com/u/104039945248245758823/

class names do not follow the Style Guide for Python code

class names do not
follow the Style Guide for Python code ( http://www.python.org/dev/peps/ pep-0008/):

"""
Class Names

```
 Almost without exception, class names use the CapWords
```

convention.
     Classes for internal use have a leading underscore in addition.
"""

We should change that as soon as possible.

Original issue for #3102: http://code.google.com/p/sympy/issues/detail?id=3

Original author: https://code.google.com/u/104039945248245758823/

Original owner: https://code.google.com/u/104039945248245758823/

generic __str__ method

Hi. For a long time I disliked that x**y prints x^y, because that way, you
can't copy & paste code between sessions and because this like this are
somewhat confusing: 

In [1]: x**y
Out[1]: x^y
## In [2]: x^y

exceptions.TypeError                                 Traceback (most recent
call last)

/home/fabian/dev/sympy/<ipython console> 

TypeError: unsupported operand type(s) for ^: 'Symbol' and 'Symbol'

I mean: I know that in mathematics and in latex ^ is accepted as the power
operator, but in python ^ is a boolean operator and shouldn't be used for
denoting power. 

This is a very easy and low-priority issue. In case you are not convinced,
we'll just leave like it is now, and in case you find that this makes
sense, the fix is one line.

Original issue for #3145: http://code.google.com/p/sympy/issues/detail?id=46

Original author: https://code.google.com/u/103948515893177094863/

Complex numbers

Implement complex numbers. It should be able to compute with "i", maybe the
powers of negative (complex) numbers should return a complex number.
Functions like sin, cos, exp, ln, should handle complex numbers.

Rewritings like exp(ix)=cos(x)+i*sin(x) should be implemented, but probably
not into eval(). Let's get inspired by other symbolic software.

Original issue for #3110: http://code.google.com/p/sympy/issues/detail?id=11

Original author: https://code.google.com/u/104039945248245758823/

Original owner: https://code.google.com/u/104039945248245758823/

Documentation

Currently, I am generating the documentation examples http://code.google.com/p/sympy/wiki/Documentation by hand, by pasting scripts in examples dir into the python prompt. It
would be fine, if we could do it automatically, to ensure the documentation
is uptodate.

Also, just before the release, it would be fine, if we could generate a
documentation from the sources somehow. I beleive we could in principle
only have documentation in form of source comments, because this could be
managable.

Original issue for #3125: http://code.google.com/p/sympy/issues/detail?id=26

Original author: https://code.google.com/u/104039945248245758823/

Original owner: https://code.google.com/u/103948515893177094863/

printing system: mathml

Like print_pretty(), we would have print_x11, or print_pygame, and this
would open a window and print a nice formula using tex.

It shouldn't be much difficult to do so, there are codes on the web which
control tex and we can browse dozens of applications here: http://www.pygame.org To have something to start with. I like the idea pypy is using: they start
pygame and you can interactively browse the code. I thinkg this could be
very useful for CAS and for debugging: you do some complex calculation (for
example some complicated limit) and then you could browse how sympy did it
in pygame.

For the beginning, just to show a nice formula in x11 would be nice. This
would be much better than those ugly formulas in maple/mathematica.

Original issue for #3135: http://code.google.com/p/sympy/issues/detail?id=36

Original author: https://code.google.com/u/104039945248245758823/

Original owner: https://code.google.com/u/103948515893177094863/

implement relations (<, >) solving

Implement code, which would evaluate relations like:

0< ln(3)/ln(2)-1

and which decides if its true or false. This is needed in the limits code.
Currently, we use evalf() on both sides and compare the resulting floating
point number. It is heuristics, but for most purposes, it is sufficient. 
But it would be fine to have exact solution.

Also to handle symbolic relations would be fine, like 

a < a + 5

But this needs to be thought through first. Maybe also to store relations,
which can be used elsewhere, for example to remember, that 

a > 0 

in some integration routine.

Original issue for #3106: http://code.google.com/p/sympy/issues/detail?id=7

Original author: https://code.google.com/u/104039945248245758823/

objects with indices (tensors)

Let's get inspired by ginac. This code should make it easy to compute for
example einstein equations from the (symbolic) metric tensor. We can do it
already now, but it would be nice to type in equations in the index form as
found in the general relativity books and then just plug in a symbolic
matrix for the metric tensor, and it would figure all the rest by itself.

Original issue for #3115: http://code.google.com/p/sympy/issues/detail?id=16

Original author: https://code.google.com/u/104039945248245758823/

setup.py should include new modules

The setup.py file (in trunk, revision 509 ) not include
sympy.modules.printing and sympy.modules.mathml, so the "setup.py install"
don't install these modules.

A simple patch (generated on windows):
# Index: setup.py

--- setup.py    ( revision 509 )
+++ setup.py    (working copy)
@@ -150,7 +150,7 @@
       version = sympy.**version**, 
       description = 'Computer algebra system (CAS) in Python', 
       url = ' http://code.google.com/p/sympy' , 
-      packages = ['sympy', 'sympy.core', 'sympy.modules'],
-      packages = ['sympy', 'sympy.core', 'sympy.modules',
  'sympy.modules.printing', 'sympy.modules.mathml' ],
     scripts = ['bin/isym.py'],
     ext_modules = [],
     cmdclass    = {'test': test_sympy,

Original issue for #3147: http://code.google.com/p/sympy/issues/detail?id=48

Original author: https://code.google.com/u/109578314321907230070/

refactor the printing system and implement pretty printing

The printing system needs to be refactored to support several different
styles of printing expressions. 

The best idea so far is this (thanks to Jurjen N.E. Bos):

This is how prettyprinting should be implemented.
I would suggest to extend it to more general output.
Make a variable, let's say outputType:

```
#set this to "LaTeX", "pretty", "Maple", or whatever
outputType = "pretty"
```

You could put in the basic class:
    def **str**(self):
        return getattr(self, outputType)()
    def LaTeX(self):
        raise NotImplementedError, "LaTeX output not defined for
"+self.**class**.**name**
    def pretty(self):
        raise NotImplementedError, "pretty output not defined for
"+self.**class**.**name**
    def Maple(self):
        raise NotImplementedError, "Maple output not defined for
"+self.**class**.**name**

And then in the subclasses:
    def pretty(self):
        <the code as shown in one of the classes below>
    def LateX(self):
        "e.g. addition, ignoring special cases."
        return '+'.join(map(LaTeX), self)

Code for pretty printing is in examples/prettysym.py. Implement that in sympy.

Original issue for #3103: http://code.google.com/p/sympy/issues/detail?id=4

Original author: https://code.google.com/u/104039945248245758823/

unification for accessing arguments

This could be SEP1 (sympy enhacement proposal 1 ;-)
# Description of the problem

Encapsulation is fine, but sometimes we just have to access the objects
content, and currently in sympy we have a variety of ways of doing this: 
- if x is a Pair: x.args, x.getab(), 
- if x is a Pow: (x.base, x.exp), x.get_baseandexp()
- if x is a Function: x.arg  (notice the hard to remember diference arg
  vs args)
- if x is an Integral: (x.f, x.a, x.b) (?)

I think this is not fine, because this makes tree-traversing algorithms
very hard, since you have to be making distinctions depending on the
object's type every time, and we tend to substitute such algorithms with
ugly (and slow) tricks, like in Basic.isnumber(). That without counting
that you have to look at the docs for each object, since it's hard to
remember which to use in each case
# My solution

I think the most pythonic way of doing this is via the **len** and
**getitem** methods, so we could do: 

> > > f = (1+x+y*x)
> > > f[:]
> > > [1,x,y*x]

def break_to_pieces(expr): # breaks an expression into its atoms
    s = []
    for arg in f[:]:
      while len(arg) != 1:
          s += break_to_pieces(arg)
    return s
# I think this is not correct but you get the idea, it traverses the tree

until all the pieces are of lenght 1 (we'd have to overload **len** for
objects so that Symbol and number have len == 1, and others have len > 1)
# Advantages
- intuitive
- no function names to remember
- encapsulation: things like this wouldn't be possible: 

In [1]: f = x*y

In [2]: f.args[0] = x

In [3]: f
Out[3]: x*x

In [4]: f == x**2
Out[4]: False

since we would define the **setitem** to raise an exception, and make the
args a private variable. 
- So sympy's types would be more inmutable (maybe completely inmutable?).

Original issue for #3144: http://code.google.com/p/sympy/issues/detail?id=45

Original author: https://code.google.com/u/103948515893177094863/

Original owner: https://code.google.com/u/103948515893177094863/

wrong limit: limit( exp(exponent * ln(base)), x, 0)

In [1]: base=2*exp( (1-cos(x))/sin(x) ) -1

In [2]: exponent = (-exp(-x)+exp(x))/(2_arctan(x)_*2)

In [3]: limit( exponent \* ln(base), x, 0)
Out[3]: 1

In [4]: limit( exp(exponent \* ln(base)), x, 0)
Out[4]: 1

In [5]: limit( base**exponent, x, 0)
Out[5]: 1

Notes: [3] is correct, the result of [4] and [5] should be exp(1).

Original issue for #3140: http://code.google.com/p/sympy/issues/detail?id=41

Original author: https://code.google.com/u/104039945248245758823/

Binary ops of real numbers fail to work

At svn r108 :

> > > import sym
> > > a = sym.real(4.)
> > > x = a + a
> > > print x
> > > 4.0+4.0
> > > x.eval()
> > > Traceback (most recent call last):
> > >   File "<stdin>", line 1, in ?
> > >   File "sym/add.py", line 246, in eval
> > >     a=self.coerce(a,add2)
> > >   File "sym/add.py", line 58, in coerce
> > >     return reduce(action,a,[])
> > >   File "sym/add.py", line 237, in add2
> > >     e.append(mul(an.addnumber(bn),a).eval())
> > >   File "sym/add.py", line 125, in eval
> > >     a=self.coerce(a,mul2)
> > >   File "sym/add.py", line 58, in coerce
> > >     return reduce(action,a,[])
> > >   File "sym/add.py", line 114, in mul2
> > >     if (not ok) and a.isequal(b):
> > >   File "sym/basic.py", line 60, in isequal
> > >     return self.hash()==a.hash()
> > >   File "sym/numbers.py", line 59, in hash
> > >     self.mhash.addfloat(self.num)
> > >   File "sym/hashing.py", line 43, in addfloat
> > >     self.add(x+3)
> > >   File "sym/hashing.py", line 30, in add
> > >     self.value=self.trimlong(1000003*self.value)^item
> > > TypeError: unsupported operand type(s) for ^: 'int' and 'float'
> > > x.evalf()
> > > 4.0+4.0

Also, the following should probably be accepted:

> > > sym.real(4)
> > > Traceback (most recent call last):
> > >   File "<stdin>", line 1, in ?
> > >   File "sym/numbers.py", line 52, in **init**
> > >     assert isinstance(num,float)
> > > AssertionError

Original issue for #3100: http://code.google.com/p/sympy/issues/detail?id=1

Original author: https://code.google.com/u/118176110351984044711/

Original owner: https://code.google.com/u/104039945248245758823/

Series expansion needs polishing

1) go through the series expansion and make sure the correct amount of
terms are being generated, when the user wants "n" terms.

2)  limits: ln(w)=-x ..., see page 111. write a test case and implement
  make the series expansion more robust - and fix the horrible thing in
  log.series().

The limit code needs this substitution. The correct way of implementing
this is to be able to expand thing which contain logarithmic singularities
in this way (like maple does):

A(x) \* 1  + B(x) \* x   + C(x)  \* x^2  +   D(x)  \* x^3

where A(x), B(x), C(x), D(x) are either numbers, or contain some function
of ln(x). We are expanding at the point x==0, so the ln(x) contains a
singularity. So mathematically, we cannot expand into a taylor (or laurent)
series, but we can make generalization and treat ln(x) as constants in the
expansion. Try it in maple. The limit code needs this, because it later
substitutes a symbol for all ln(x) in the expansion. 

Currently, I solve this problem right at he beginning, where I substitute
for ln(x) before making the expansion, thus I can use the current code. 

Solution: think about this issue, so that the series code (which belongs to
the engine) is nicely written and doesn't depend on the limits code (as it
does now - it asks the limit code what it should substitute for ln(x)).

Original issue for #3108: http://code.google.com/p/sympy/issues/detail?id=9

Original author: https://code.google.com/u/104039945248245758823/

Original owner: https://code.google.com/u/104039945248245758823/

no decorator module

hi. I got sympy broken right now:

fabian@delta01:~/dev/sympy$ python
Python 2.4.4c1 (#2, Oct 11 2006, 21:51:02) 
[GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

> > > import sym
> > > Traceback (most recent call last):
> > >   File "<stdin>", line 1, in ?
> > >   File "./sym/**init**.py", line 22, in ?
> > >     from modules import *
> > >   File "/home/fabian/dev/sympy/sym/modules/**init**.py", line 2, in ?
> > >     from limits import limit,limitinf
> > >   File "sym/modules/limits.py", line 84, in ?
> > >     from decorator import decorator
> > > ImportError: No module named decorator

and i can't find anywhere the module decorator ...

Original issue for #3129: http://code.google.com/p/sympy/issues/detail?id=30

Original author: https://code.google.com/u/103948515893177094863/

Original owner: https://code.google.com/u/103948515893177094863/

code unification for operations on numbers

Hi Ondrej. 

Here is my patch to unify the ***** functions in number.py . So the good
news are:
- It works fine, and the code is readable, (I think)
- I solve a subs bug . Before, if you did "exp(x*x).subs(x,1)" it would
  throw an exception, now it works ok

now I have a doubt with the following code: 

In [6]: (Rational(0)**Rational(0)).eval()
Out[6]: 1

, I always thought 0**0 is mathematically undefined, but however python
happily prints 1 , so does axiom and so does google's calculator (am I
wrong and 0**0 is defined??). 

Now the problem is that if you tell sympy to raise a pole_error for In[6],
then lot's of limits begin to fail, behavior which I thought might be the
reason of some bugs in limits.py ...

Original issue for #3119: http://code.google.com/p/sympy/issues/detail?id=20

Original author: fab…@fseoane.net

setup.py test_core fails

ondra@syslik:~/sympy$ python setup.py test_core
running test_core
Traceback (most recent call last):
  File "setup.py", line 103, in ?
    cmdclass    = {'test': test_sympy,
  File "distutils/core.py", line 149, in setup
  File "distutils/dist.py", line 946, in run_commands
  File "distutils/dist.py", line 966, in run_command
  File "setup.py", line 92, in run
    py.test.cmdline.main(args=[self.tests_to_run])
  File "/usr/lib/python2.4/site-packages/py/test/cmdline.py", line 15, in main
    failures = session.main()
  File "/usr/lib/python2.4/site-packages/py/test/session.py", line 57, in main
    colitems = self.config.getcolitems()
  File "/usr/lib/python2.4/site-packages/py/test/config.py", line 65, in
getcolitems
    return [self._getcollector(path) for path in (trails or self.args)]
  File "/usr/lib/python2.4/site-packages/py/test/config.py", line 74, in
_getcollector
    assert path.check(), "%s: path does not exist" %(path,)
AssertionError: /home/ondra/sympy/['tests/test_arit.py',
'tests/test_basic.py', 'tests/test_diff.py', 'tests/test_equal.py',
'tests/test_eval.py', 'tests/test_evalf.py', 'tests/test_functions.py',
'tests/test_hashing.py', 'tests/test_numbers.py', 'tests/test_series.py',
'tests/test_str.py', 'tests/test_subs.py', 'tests/test_symbol.py',
'tests/test_util.py']: path does not exist

Original issue for #3123: http://code.google.com/p/sympy/issues/detail?id=24

Original author: https://code.google.com/u/104039945248245758823/

Original owner: https://code.google.com/u/103948515893177094863/

limit code doesn't compute some limits

It doesn't compute all the commented limits in tests. The major reason is
the problem in the series expansion, see the issue 3108 . But there still seems
to be other problems. So, first fix the problem in the series facility, and
then fix the limit code.

Original issue for #3109: http://code.google.com/p/sympy/issues/detail?id=10

Original author: https://code.google.com/u/104039945248245758823/

Referenced issues: #3108

Original owner: https://code.google.com/u/104039945248245758823/

speed of SymPy is insufficient

try to run examples/qft.py

The last line x.expand() runs forever. Well, we need some optimizations. I
don't know if it is so slow only because of the algorithm in expand(), or
because of the overall speed of SymPy is not enough. 

I believe optimization should be done after we implement basic things, so
that sympy.core is more or less finished. Maybe we will then have to
rewrite the sympy.core in C++.

Original issue for #3142: http://code.google.com/p/sympy/issues/detail?id=43

Original author: https://code.google.com/u/104039945248245758823/

basic polynomial methods

Some polynomail methods are needed for the integration algorithm. 
At least, we need: 
- ispoly(p, x) -> True if p is a polynomial in x
- gcd of polynomials 
- square_free_decomp(p, x) -> calculate the square free decomposition of 
  p (we could use http://portal.acm.org/citation.cfm? coll=GUIDE&dl=GUIDE&id=806320)

Original issue for #3139: http://code.google.com/p/sympy/issues/detail?id=40

Original author: https://code.google.com/u/103948515893177094863/

Original owner: https://code.google.com/u/104039945248245758823/

Integral syntax and basic integration

I think the arguments in Integral are not optimal since: 
- a and b should be optional (case indefinite integral),
- does not support integration over several variables

rather, I find the syntax from Mathematica's Integrate to be extremely
clever and intuitive: http://documents.wolfram.com/mathematica/functions/Integrate in python, this would be: 

• integrate(f, x) gives the indefinite integral .
• integrate(f, (x,a,b)) gives the definite integral .
• integrate(f, (x,a1,b1), (y,a2,b2)) gives the multiple integral .

it should also be extensible in the sense that new options could be
implemented without changing the api. this could maybe be implemented with
a dictionary as last argument, for example: 
- integrate(f, x, {'Evaluate' : False, 'Field' : ComplexNumbers,
  'Assumptions' : belongs(n, Integers)})

Original issue for #3124: http://code.google.com/p/sympy/issues/detail?id=25

Original author: https://code.google.com/u/103948515893177094863/

Original owner: https://code.google.com/u/103948515893177094863/

Problem with printing

x=Symbol("x")
w=Symbol("w")
e=(-2)_x.sqrt()-Rational(1)/2_w/x.sqrt()
print e
print e.print_tree()

Prints:

(-2)_x^1/2(-1/2)_x^(-1/2)*w
Add
+--Mul
|  +--(-2)
|  +--x^1/2
+--Mul
   +--(-1/2)
   +--x^(-1/2)
   +--w

There is a missing "+" sign between the two Muls. Actually, removing the
brackets around (-1/2) would solve the problem. It used to work with the
deepcopy ugly code, but doesn't work with the new clean code.

Original issue for #3126: http://code.google.com/p/sympy/issues/detail?id=27

Original author: https://code.google.com/u/104039945248245758823/

Fractions simplification

We need a method for simplification of fractions. Example:

-E-m-(E+m)^(-1)_m^2+(E+m)^(-1)_E^2

this should simplify to:

-2*m

It probably doesn't belong to eval(), but to some method similar to
expand(). This method should convert the whole expression to one fraction.
Then factor it, and cancel the same terms. 

We need the factorisation method first.

Original issue for #3134: http://code.google.com/p/sympy/issues/detail?id=35

Original author: https://code.google.com/u/104039945248245758823/

Original owner: https://code.google.com/u/104039945248245758823/

special constants

I would need an implementation of pi with the following properties:
- arbitrary precision: so that i can do pi(10) and have 10 significant
  digits, pi(100) and have 100, and so on.
- symbolic value: It should be a symbol and not a mere approximation (like
  math.pi) so that cos(pi) = 1, sin(pi) = 0 (and not 1.2246467991473532e-16
  like in math.pi) and pi != Rational(3.14.16...)
- I could evaluate it at any point by doing pi.eval(), (pi + 1).eval(), ...

This applies also to e and possibly other constants

Original issue for #3116: http://code.google.com/p/sympy/issues/detail?id=17

Original author: fab…@fseoane.net

sqrt and Limit/Derivative/Integral class, automatic evaluation

Problems with expressions like (sqrt(2)+1)/3, it is a number in fact, but
not a class "number". Look through all the assertions isinstance(rational),
and consider changing it to "not has(e,x)", or rather "not e.has(x)".

This is still not very general solution, because we don't know what kind of
variables the user uses. So maybe we could implement something like

e.isnumber()   which would traverse the expression tree and if there are no
symbols used, then its a number and the answer would be True, otherwise False.

Original issue for #3107: http://code.google.com/p/sympy/issues/detail?id=8

Original author: https://code.google.com/u/104039945248245758823/

Original owner: https://code.google.com/u/104039945248245758823/

Derivative class

I implemented back Derivative.diff() and Derivative.**str**(), right now
its a quick hack, but I need it in examples/relativity.py.

The example uses a metric tensor, that contains general (unknown) functions
and then it calculates the Ricci tensor and prints the diagonal components
(others are zero). As you can see from the output, we need some way do
differentiate an unknown function and to print it. 

This hack works, and now we should implement it correctly and also write
some tests for it (it was my fault, that I didn't write any tests for that,
so you deleted it).

As to me, it doesn't matter if it is in the core, or in modules. I was also
thinking of somehow incorporating Derivative into Function.diff(), so that
if the subclass doesn't implement diff(), it returns a general Derivative
class, otherwise it calculates the derivate.

Also I think the current implementation of Derivative.diff() only works for
functions like f(r), but not f(r**2) for example.

Original issue for #3146: http://code.google.com/p/sympy/issues/detail?id=47

Original author: https://code.google.com/u/104039945248245758823/

Original owner: https://code.google.com/u/104039945248245758823/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.