{ "info": { "author": "Abraham Lee", "author_email": "tisimst@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Education", "Intended Audience :: Science/Research", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Topic :: Education", "Topic :: Scientific/Engineering", "Topic :: Scientific/Engineering :: Mathematics", "Topic :: Scientific/Engineering :: Physics", "Topic :: Software Development", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "==============================================\nADiPy, Automatic Differentiation for Python\n==============================================\n\nADiPy is a fast, pure-python automatic differentiation (AD) library. This \npackage provides the following functionality:\n\n- Arbitrary order univariate differentiation\n- First-order multivariate differentiation\n- Univariate Taylor polynomial function generator\n- Jacobian matrix generator\n- Compatible linear algebra routines\n\nInstallation\n------------\n\nTo install ``adipy``, simply do one of the following in a terminal window \n(administrative priviledges may be required):\n\n- Download the tarball, unzip, then run ``python setup.py install`` in the \n unzipped directory.\n- Run ``easy_install [--upgrade] adipy``\n- Run ``pip install [--upgrade] adipy``\n\nWhere to Start\n--------------\n\nTo start, we use the simple import::\n\n from adipy import *\n\nThis imports the necessary constructors and elementary functions (sin, exp,\nsqrt, etc.) as well as ``np`` which is the root NumPy module.\n\nNow, we can construct AD objects using either ``ad(...)`` or ``adn(...)``. For\nmultivariate operations, it is recommended to construct them all at once using\nthe ``ad(...)`` function, but this is not required. The syntax is only a little\nmore complicated if they are initialized separately.\n\nUnivariate Examples\n-------------------\n\nHere are some examples of univariate operations::\n\n # A single, first-order differentiable object\n x = ad(1.5)\n \n y = x**2\n print y\n # output is: ad(2.25, array([3.0]))\n \n # What is dy/dx?\n print y.d(1) \n # output is: 3.0\n \n z = x*sin(x**2)\n print z \n # output is: ad(1.1671097953318819, array([-2.0487081053644052]))\n \n # What is dz/dx?\n print z.d(1) \n # output is: -2.0487081053644052\n \n # A single, fourth-order differentiable object\n x = adn(1.5, 4)\n \n y = x**2\n print y \n # output is: ad(2.25, array([ 3., 2., 0., -0.]))\n \n # What is the second derivative of y with respect to x?\n print y.d(2) \n # output is: 2.0\n \n z = x*sin(x**2)\n print z \n # output is: \n # ad(1.1671097953318819, array([ -2.04870811, -16.15755076, -20.34396265, 194.11618384]))\n \n # What is the fourth derivative of z with respect to x?\n print z.d(4) \n # output is: 194.116183837\n\nAs can be seen in the examples, when an AD object is printed out, you see two\nsets of numbers. The first is the nominal value, or the zero-th derivative.\nThe next set of values are the 1st through the Nth order derivatives, evaluated\nat the nominal value.\n\nMultivariate Examples\n---------------------\n\nFor multivariate sessions, things look a little bit different and can only\nhandle first derivatives (for the time being), but behave similarly::\n\n x = ad(np.array([-1, 2.1, 0.25]))\n \n y = x**2\n print y\n # output is: \n # ad(array([ 1. , 4.41 , 0.0625]), array([[[-2. , 0. , 0. ],\n # [-0. , 4.2, 0. ],\n # [-0. , 0. , 0.5]]]))\n\nThis essentially just performed the ``**2`` operator on each object individually,\nso we can see the derivatives for each array index and how they are not\ndependent on each other. Using standard indexing operations, we can access the\nindividual elements of an AD multivariate object::\n\n print x[0]\n # output is:\n # ad(-1, array([ 1., 0., 0.]))\n \nWhat if we want to use more than one AD object in calculations? Let's see what \nhappens::\n\n z = x[0]*sin(x[1]*x[2])\n print z\n # output is:\n # ad(-0.50121300467379792, array([[ 0.501213 , -0.21633099, -1.81718028]]))\n\nThe result here shows both the nominal value for z, but also the partial\nderivatives for each of the x values. Thus, dz/dx[0] = 0.501213, etc. \n\nJacobian\n--------\n\nIf we have multiple outputs, like::\n\n y = [0]*2\n y[0] = x[0]*x[1]/x[2]\n y[1] = -x[2]**x[0]\n\nwe can use the ``jacobian`` function to summarize the partial derivatives for\neach index of y::\n\n print jacobian(y)\n # output is: [[ 8.4 -4. 33.6 ]\n # [ 5.54517744 0. 16. ]]\n\nJust as before, we can extract the first partial derivatives::\n\n print z.d(1)\n # output is: [ 0.501213 -0.21633099 -1.81718028]\n \nFor the object y, we can't yet use the ``d(...)`` function yet, because it is\ntechnically a list at this point. However, we can convert it to a single,\nmultivariate AD object using the ``unite`` function, then we'll have access\nto the ``d(...)`` function. The ``jacobian`` function's result is the same in \nboth cases::\n\n y = unite(y)\n print y.d(1)\n # output is: [[ 8.4 -4. 33.6 ]\n # [ 5.54517744 0. 16. ]]\n\n print jacobian(y)\n # output is: [[ 8.4 -4. 33.6 ]\n # [ 5.54517744 0. 16. ]]\n\nLike was mentioned before, multivariate sessions can initialize individual\nindependent AD objects, though not quite as conveniently as before, using\nthe following syntax::\n\n x = ad(-1, np.array([1, 0, 0]))\n y = ad(2.1, np.array([0, 1, 0]))\n z = ad(0.25, np.array([0, 0, 1]))\n \nThis allows all the partial derivatives to be tracked, noted at the respective\nunitary index at initialization. Conversely to singular construction, we can\nbreak-out the individual elements, if desired::\n\n x, y, z = ad([np.array([-1, 2.1, 0.25]))\n \nAnd the results are the same.\n\nUnivariate Taylor Series Approximation\n--------------------------------------\n\nFor univariate functions, we can use the ``taylorfunc`` function to generate\nan callable function that allows approximation to some specifiable order::\n\n x = adn(1.5, 6) # a sixth-order AD object\n z = x*sin(x**2)\n fz = taylorfunc(z, at=x.nom) \n\nThe \"at\" keyword designates the point that the series is expanded about, which\nwill likely always be at the nominal value of the original independent AD\nobject (e.g., ``x.nom``). Now, we can use ``fz`` whenever we need to \napproximate ``x*sin(x**2)``, but know that the farther it is evaluated from\n``x.nom``, the more error there will be in the approximation.\n\nIf Matplotlib is installed, we can see the difference in the order of the\napproximating Taylor polynomials::\n\n import matplotlib.pyplot as plt\n xAD = [adn(1.5, i) for i in xrange(1, 7)] # a list of ith-order AD objects\n def z(x):\n return x*sin(x**2)\n\n x = np.linspace(0.75, 2.25)\n plt.plot(x, z(x), label='Actual Function')\n for i in xrange(len(xAD)):\n fz = taylorfunc(z(xAD[i]), at=xAD[i].nom)\n plt.plot(x, fz(x), label='Order %d Taylor'%(i+1))\n\n plt.legend(loc=0)\n plt.show()\n\n.. image:: https://raw.github.com/tisimst/adipy/master/taylorfunc_example.png\n\nNotice that at x=1.5, all the approximations are perfectly accurate (as we \nwould expect) and error increases as the approximation moves farther from that\npoint, but less so with the increase in the order of the approximation.\n\nLinear Algebra\n--------------\n\nSeveral linear algebra routines are available that are AD-compatible:\n\n- Decompositions\n\n - Cholesky (``chol``)\n - QR (``qr``)\n - LU (``lu``)\n\n- Linear System solvers\n\n - General solver, with support for multiple outputs (``solve``)\n - Least squares solver (``lstsq``)\n - Matrix inverse (``inv``)\n \n- Matrix Norms\n\n - Frobenius norm, or 2-norm (``norm``)\n\nThese require a separate import ``import adipy.linalg``, then they can be\nusing something like ``adipy.linalg.solve(...)``.\n\nSee the source code for relevant documentation and examples. If you are \nfamiliar with NumPy's versions, you will find these easy to use.\n\nSupport\n-------\n\nPlease contact the `author`_ with any questions, comments, or good examples of\nhow you've used ``adipy``!\n\nLicense\n-------\n\nThis package is distributed under the BSD License. It is free for public and\ncommercial use and may be copied royalty free, provided the author is given\ncredit.\n\n.. _author: mailto:tisimst@gmail.com", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/tisimst/adipy", "keywords": "automatic differentiation,algorithmic differentiation,arbitrary order,python,linear algebra", "license": "BSD License", "maintainer": null, "maintainer_email": null, "name": "ADiPy", "package_url": "https://pypi.org/project/ADiPy/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/ADiPy/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/tisimst/adipy" }, "release_url": "https://pypi.org/project/ADiPy/0.6.3/", "requires_dist": null, "requires_python": null, "summary": "Automatic Differentiation for Python", "version": "0.6.3" }, "last_serial": 937027, "releases": { "0.5": [ { "comment_text": "", "digests": { "md5": "f50e9395254e8daaa14445c88bcd83f4", "sha256": "f45dd8911ff1b3d7a56eeeec29fdc9fd20c8edbfaab731fae04aa8be80da4040" }, "downloads": -1, "filename": "ADiPy-0.5.tar.gz", "has_sig": false, "md5_digest": "f50e9395254e8daaa14445c88bcd83f4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8350, "upload_time": "2013-11-07T21:40:52", "url": "https://files.pythonhosted.org/packages/20/1f/ce9b708a30c6fcd1056f41f7b78feb22e37f127e10e78090f571a8547c01/ADiPy-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "177a3a7b874bd3ce7b61f9f49b3eb9fc", "sha256": "20c516d237f494bc8b4ef57dfb506332da2c29670c867f3cf473c226fcce4d79" }, "downloads": -1, "filename": "ADiPy-0.6.tar.gz", "has_sig": false, "md5_digest": "177a3a7b874bd3ce7b61f9f49b3eb9fc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8754, "upload_time": "2013-11-21T01:06:10", "url": "https://files.pythonhosted.org/packages/d6/7c/206dea40048dd9d6cbb52f4e5758845978f4295cddf533bf290e56d11e3d/ADiPy-0.6.tar.gz" } ], "0.6.1": [ { "comment_text": "", "digests": { "md5": "7d9069d2630ca8589db153cc49a3bef8", "sha256": "4f76c54a8b17b60286a6dc10b46e5fde240b3b06a922b53f15a5b2edb09444f7" }, "downloads": -1, "filename": "ADiPy-0.6.1.tar.gz", "has_sig": false, "md5_digest": "7d9069d2630ca8589db153cc49a3bef8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8898, "upload_time": "2013-11-21T21:52:22", "url": "https://files.pythonhosted.org/packages/d2/18/f49dbe4a8584ae85d5c0f858d12e9201cc95a86e129e2e82c84e4311e5db/ADiPy-0.6.1.tar.gz" } ], "0.6.2": [ { "comment_text": "", "digests": { "md5": "57ca7b3fadb114326711d0c69568a81b", "sha256": "a4c928dc67b9220694ae4f16135f6d424caf0ed8558fd0a17316e166f2c55367" }, "downloads": -1, "filename": "ADiPy-0.6.2.tar.gz", "has_sig": false, "md5_digest": "57ca7b3fadb114326711d0c69568a81b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8906, "upload_time": "2013-11-22T22:11:42", "url": "https://files.pythonhosted.org/packages/0b/15/38de43343f24d1aec6c207e2670e256ecbb84a2b59d46d0d23a71e77defd/ADiPy-0.6.2.tar.gz" } ], "0.6.3": [ { "comment_text": "", "digests": { "md5": "1b69d678681a0c3bba797f4a81cfe3ba", "sha256": "192364bc95595ce97eaa788fc8d74d0f6a16fb8f0deabe494d507082cc335b97" }, "downloads": -1, "filename": "ADiPy-0.6.3.tar.gz", "has_sig": false, "md5_digest": "1b69d678681a0c3bba797f4a81cfe3ba", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13569, "upload_time": "2013-12-05T21:38:20", "url": "https://files.pythonhosted.org/packages/11/b3/1ab4d7942434271be69a0e3846bc94993af93f9bb80d776fae8f85960ed0/ADiPy-0.6.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1b69d678681a0c3bba797f4a81cfe3ba", "sha256": "192364bc95595ce97eaa788fc8d74d0f6a16fb8f0deabe494d507082cc335b97" }, "downloads": -1, "filename": "ADiPy-0.6.3.tar.gz", "has_sig": false, "md5_digest": "1b69d678681a0c3bba797f4a81cfe3ba", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13569, "upload_time": "2013-12-05T21:38:20", "url": "https://files.pythonhosted.org/packages/11/b3/1ab4d7942434271be69a0e3846bc94993af93f9bb80d776fae8f85960ed0/ADiPy-0.6.3.tar.gz" } ] }