├── sympy ├── core │ ├── tests │ │ ├── __init__.py │ │ ├── test_rules.py │ │ ├── test_cache.py │ │ ├── test_evaluate.py │ │ └── test_truediv.py │ ├── benchmarks │ │ ├── bench_sympify.py │ │ ├── bench_assumptions.py │ │ ├── bench_basic.py │ │ ├── bench_expand.py │ │ └── bench_arit.py │ ├── alphabets.py │ └── coreerrors.py ├── sets │ ├── tests │ │ ├── __init__.py │ │ └── test_contains.py │ ├── __init__.py │ └── contains.py ├── calculus │ ├── tests │ │ ├── __init__.py │ │ └── test_singularities.py │ ├── __init__.py │ └── singularities.py ├── concrete │ ├── tests │ │ └── __init__.py │ └── __init__.py ├── crypto │ ├── tests │ │ └── __init__.py │ └── __init__.py ├── diffgeom │ ├── tests │ │ └── __init__.py │ └── __init__.py ├── external │ ├── tests │ │ └── __init__.py │ └── __init__.py ├── galgebra │ ├── tests │ │ └── __init__.py │ └── __init__.py ├── geometry │ ├── tests │ │ └── __init__.py │ ├── exceptions.py │ └── __init__.py ├── integrals │ ├── tests │ │ ├── __init__.py │ │ └── test_lineintegrals.py │ ├── benchmarks │ │ ├── bench_trigintegrate.py │ │ └── bench_integrate.py │ └── meijerint_doc.py ├── logic │ ├── tests │ │ └── __init__.py │ ├── algorithms │ │ └── __init__.py │ ├── utilities │ │ └── __init__.py │ ├── __init__.py │ └── benchmarks │ │ └── input │ │ ├── 10.cnf │ │ └── 15.cnf ├── matrices │ ├── tests │ │ ├── __init__.py │ │ ├── test_densetools.py │ │ └── test_densesolve.py │ ├── expressions │ │ ├── tests │ │ │ ├── __init__.py │ │ │ ├── test_funcmatrix.py │ │ │ ├── test_fourier.py │ │ │ ├── test_matadd.py │ │ │ ├── test_diagonal.py │ │ │ └── test_factorizations.py │ │ ├── diagonal.py │ │ ├── __init__.py │ │ ├── fourier.py │ │ └── matpow.py │ └── benchmarks │ │ └── bench_matrix.py ├── mpmath │ ├── tests │ │ ├── __init__.py │ │ ├── test_mpmath.py │ │ ├── test_pickle.py │ │ ├── test_str.py │ │ ├── test_identify.py │ │ └── test_visualization.py │ ├── matrices │ │ └── __init__.py │ ├── calculus │ │ ├── calculus.py │ │ └── __init__.py │ ├── conftest.py │ └── functions │ │ └── __init__.py ├── ntheory │ ├── tests │ │ └── __init__.py │ └── __init__.py ├── parsing │ ├── tests │ │ ├── __init__.py │ │ └── test_mathematica.py │ └── __init__.py ├── physics │ ├── hep │ │ ├── __init__.py │ │ └── tests │ │ │ └── __init__.py │ ├── tests │ │ ├── __init__.py │ │ └── test_sho.py │ ├── optics │ │ └── tests │ │ │ └── __init__.py │ ├── vector │ │ └── tests │ │ │ └── __init__.py │ ├── mechanics │ │ └── tests │ │ │ └── __init__.py │ ├── quantum │ │ └── tests │ │ │ ├── __init__.py │ │ │ ├── test_constants.py │ │ │ ├── test_shor.py │ │ │ └── test_piab.py │ ├── unitsystems │ │ ├── tests │ │ │ ├── __init__.py │ │ │ └── test_prefixes.py │ │ └── systems │ │ │ └── __init__.py │ ├── __init__.py │ └── gaussopt.py ├── plotting │ ├── tests │ │ └── __init__.py │ ├── pygletplot │ │ ├── tests │ │ │ └── __init__.py │ │ └── plot_object.py │ ├── intervalmath │ │ ├── tests │ │ │ └── __init__.py │ │ └── __init__.py │ └── __init__.py ├── polys │ ├── tests │ │ └── __init__.py │ ├── agca │ │ ├── tests │ │ │ └── __init__.py │ │ └── __init__.py │ ├── benchmarks │ │ ├── __init__.py │ │ └── bench_groebnertools.py │ └── domains │ │ ├── tests │ │ └── __init__.py │ │ ├── simpledomain.py │ │ ├── characteristiczero.py │ │ ├── domainelement.py │ │ ├── gmpyfinitefield.py │ │ ├── pythonfinitefield.py │ │ ├── compositedomain.py │ │ └── rationalfield.py ├── printing │ ├── tests │ │ ├── __init__.py │ │ └── test_gtk.py │ ├── pretty │ │ ├── tests │ │ │ └── __init__.py │ │ └── __init__.py │ ├── gtk.py │ ├── __init__.py │ └── defaults.py ├── series │ ├── tests │ │ └── __init__.py │ ├── benchmarks │ │ └── bench_limit.py │ ├── __init__.py │ └── series.py ├── simplify │ ├── tests │ │ ├── __init__.py │ │ ├── test_traversaltools.py │ │ └── test_rewrite.py │ ├── hyperexpand_doc.py │ ├── __init__.py │ └── traversaltools.py ├── solvers │ ├── tests │ │ └── __init__.py │ ├── benchmarks │ │ └── bench_solvers.py │ └── __init__.py ├── stats │ └── tests │ │ ├── __init__.py │ │ ├── test_mix.py │ │ └── test_discrete_rv.py ├── tensor │ ├── tests │ │ └── __init__.py │ └── __init__.py ├── unify │ ├── tests │ │ └── __init__.py │ └── __init__.py ├── utilities │ ├── tests │ │ ├── __init__.py │ │ ├── test_source.py │ │ └── test_timeutils.py │ ├── magic.py │ └── __init__.py ├── vector │ ├── tests │ │ └── __init__.py │ └── __init__.py ├── assumptions │ ├── tests │ │ └── __init__.py │ ├── handlers │ │ └── __init__.py │ └── __init__.py ├── categories │ ├── tests │ │ └── __init__.py │ └── __init__.py ├── combinatorics │ ├── tests │ │ ├── __init__.py │ │ └── test_group_constructs.py │ └── __init__.py ├── interactive │ ├── tests │ │ ├── __init__.py │ │ └── test_interactive.py │ └── __init__.py ├── liealgebras │ ├── tests │ │ ├── __init__.py │ │ ├── test_dynkin_diagram.py │ │ ├── test_cartan_matrix.py │ │ ├── test_cartan_type.py │ │ ├── test_type_G.py │ │ ├── test_type_B.py │ │ ├── test_type_A.py │ │ ├── test_type_D.py │ │ ├── test_type_E.py │ │ ├── test_root_system.py │ │ └── test_type_C.py │ ├── __init__.py │ ├── cartan_matrix.py │ └── dynkin_diagram.py ├── strategies │ ├── tests │ │ ├── __init__.py │ │ ├── test_strat.py │ │ └── test_tools.py │ ├── branch │ │ ├── tests │ │ │ ├── __init__.py │ │ │ └── test_tools.py │ │ ├── __init__.py │ │ ├── tools.py │ │ └── traverse.py │ └── util.py ├── functions │ ├── special │ │ ├── tests │ │ │ ├── __init__.py │ │ │ └── test_beta_functions.py │ │ ├── benchmarks │ │ │ └── bench_special.py │ │ └── __init__.py │ ├── combinatorial │ │ ├── tests │ │ │ └── __init__.py │ │ └── __init__.py │ └── elementary │ │ ├── tests │ │ └── __init__.py │ │ ├── __init__.py │ │ └── benchmarks │ │ └── bench_exp.py └── release.py ├── .gitattributes ├── release ├── .gitignore └── Vagrantfile ├── setupegg.py ├── doc ├── src │ ├── pics │ │ ├── winpdb1.png │ │ ├── winpdb2.png │ │ ├── pngview1.png │ │ ├── consoleascii.png │ │ ├── consoleunicode.png │ │ ├── ipythonnotebook.png │ │ └── ipythonqtconsole.png │ ├── _static │ │ ├── sympylogo.png │ │ └── sympylogo_big.png │ ├── modules │ │ ├── geometry │ │ │ ├── plane.rst │ │ │ ├── line3d.rst │ │ │ ├── point3d.rst │ │ │ ├── curves.rst │ │ │ ├── points.rst │ │ │ ├── entities.rst │ │ │ ├── ellipses.rst │ │ │ ├── utils.rst │ │ │ ├── polygons.rst │ │ │ └── lines.rst │ │ ├── mpmath │ │ │ ├── plot.png │ │ │ ├── cplot.png │ │ │ ├── splot.png │ │ │ ├── plots │ │ │ │ ├── ai.png │ │ │ │ ├── ai_c.py │ │ │ │ ├── ber.png │ │ │ │ ├── bi.png │ │ │ │ ├── bi_c.py │ │ │ │ ├── gi.png │ │ │ │ ├── hi.png │ │ │ │ ├── ker.png │ │ │ │ ├── ai_c.png │ │ │ │ ├── bi_c.png │ │ │ │ ├── chebyt.png │ │ │ │ ├── chebyu.png │ │ │ │ ├── ellipe.png │ │ │ │ ├── ellipf.png │ │ │ │ ├── ellipk.png │ │ │ │ ├── gi_c.png │ │ │ │ ├── gi_c.py │ │ │ │ ├── hi_c.png │ │ │ │ ├── hi_c.py │ │ │ │ ├── kleinj.png │ │ │ │ ├── pcfd.png │ │ │ │ ├── besseli.png │ │ │ │ ├── besselj.png │ │ │ │ ├── besselk.png │ │ │ │ ├── bessely.png │ │ │ │ ├── coulombf.png │ │ │ │ ├── coulombg.png │ │ │ │ ├── ellipk.py │ │ │ │ ├── ellippi.png │ │ │ │ ├── gi.py │ │ │ │ ├── hankel1.png │ │ │ │ ├── hankel2.png │ │ │ │ ├── hermite.png │ │ │ │ ├── kleinj2.png │ │ │ │ ├── laguerre.png │ │ │ │ ├── lambertw.png │ │ │ │ ├── legendre.png │ │ │ │ ├── lommels1.png │ │ │ │ ├── lommels2.png │ │ │ │ ├── besseli_c.png │ │ │ │ ├── besselj_c.png │ │ │ │ ├── besselk_c.png │ │ │ │ ├── bessely_c.png │ │ │ │ ├── coulombf_c.png │ │ │ │ ├── coulombg_c.png │ │ │ │ ├── hankel1_c.png │ │ │ │ ├── hankel2_c.png │ │ │ │ ├── hi.py │ │ │ │ ├── lambertw_c.png │ │ │ │ ├── lambertw_c.py │ │ │ │ ├── spherharm40.png │ │ │ │ ├── spherharm41.png │ │ │ │ ├── spherharm42.png │ │ │ │ ├── spherharm43.png │ │ │ │ ├── spherharm44.png │ │ │ │ ├── coulombf_c.py │ │ │ │ ├── coulombg_c.py │ │ │ │ ├── besselj_c.py │ │ │ │ ├── hankel1_c.py │ │ │ │ ├── hankel2_c.py │ │ │ │ ├── besseli_c.py │ │ │ │ ├── bessely_c.py │ │ │ │ ├── lambertw.py │ │ │ │ ├── kleinj2.py │ │ │ │ ├── besselk_c.py │ │ │ │ ├── kleinj.py │ │ │ │ ├── ai.py │ │ │ │ ├── besselj.py │ │ │ │ ├── ker.py │ │ │ │ ├── ber.py │ │ │ │ ├── bi.py │ │ │ │ ├── hankel1.py │ │ │ │ ├── hankel2.py │ │ │ │ ├── besseli.py │ │ │ │ ├── bessely.py │ │ │ │ ├── besselk.py │ │ │ │ ├── chebyt.py │ │ │ │ ├── chebyu.py │ │ │ │ ├── lommels1.py │ │ │ │ ├── ellipe.py │ │ │ │ ├── ellipf.py │ │ │ │ ├── pcfd.py │ │ │ │ ├── legendre.py │ │ │ │ ├── hermite.py │ │ │ │ ├── lommels2.py │ │ │ │ ├── laguerre.py │ │ │ │ ├── coulombf.py │ │ │ │ ├── coulombg.py │ │ │ │ ├── ellippi.py │ │ │ │ ├── spherharm41.py │ │ │ │ ├── spherharm42.py │ │ │ │ ├── spherharm43.py │ │ │ │ ├── spherharm44.py │ │ │ │ ├── spherharm40.py │ │ │ │ └── buildplots.py │ │ │ ├── calculus │ │ │ │ ├── odes.rst │ │ │ │ ├── index.rst │ │ │ │ ├── polynomials.rst │ │ │ │ ├── approximation.rst │ │ │ │ ├── differentiation.rst │ │ │ │ └── integration.rst │ │ │ ├── functions │ │ │ │ ├── qfunctions.rst │ │ │ │ └── index.rst │ │ │ └── plotting.rst │ │ ├── assumptions │ │ │ ├── ask.rst │ │ │ ├── assume.rst │ │ │ ├── refine.rst │ │ │ └── handlers │ │ │ │ ├── sets.rst │ │ │ │ ├── order.rst │ │ │ │ ├── ntheory.rst │ │ │ │ ├── calculus.rst │ │ │ │ └── index.rst │ │ ├── physics │ │ │ ├── quantum │ │ │ │ ├── qft.rst │ │ │ │ ├── spin.rst │ │ │ │ ├── gate.rst │ │ │ │ ├── qubit.rst │ │ │ │ ├── state.rst │ │ │ │ ├── dagger.rst │ │ │ │ ├── qapply.rst │ │ │ │ ├── operator.rst │ │ │ │ ├── constants.rst │ │ │ │ ├── represent.rst │ │ │ │ ├── commutator.rst │ │ │ │ ├── hilbert.rst │ │ │ │ ├── shor.rst │ │ │ │ ├── circuitplot.rst │ │ │ │ ├── piab.rst │ │ │ │ ├── grover.rst │ │ │ │ ├── innerproduct.rst │ │ │ │ ├── anticommutator.rst │ │ │ │ ├── tensorproduct.rst │ │ │ │ ├── cg.rst │ │ │ │ ├── cartesian.rst │ │ │ │ ├── operatorset.rst │ │ │ │ └── index.rst │ │ │ ├── optics │ │ │ │ ├── utils.rst │ │ │ │ ├── waves.rst │ │ │ │ ├── medium.rst │ │ │ │ ├── gaussopt.rst │ │ │ │ └── index.rst │ │ │ ├── matrices.rst │ │ │ ├── wigner.rst │ │ │ ├── paulialgebra.rst │ │ │ ├── hydrogen.rst │ │ │ ├── secondquant.rst │ │ │ ├── sho.rst │ │ │ ├── unitsystems │ │ │ │ ├── prefixes.rst │ │ │ │ ├── quantities.rst │ │ │ │ ├── dimensions.rst │ │ │ │ └── units.rst │ │ │ ├── qho_1d.rst │ │ │ ├── mechanics │ │ │ │ ├── api │ │ │ │ │ ├── linearize.rst │ │ │ │ │ ├── expr_manip.rst │ │ │ │ │ ├── kane_lagrange.rst │ │ │ │ │ └── printing.rst │ │ │ │ ├── examples.rst │ │ │ │ ├── examples │ │ │ │ │ └── rollingdisc_example.rst │ │ │ │ └── reference.rst │ │ │ ├── hep │ │ │ │ ├── gamma_matrices.rst │ │ │ │ └── index.rst │ │ │ ├── vector │ │ │ │ └── api │ │ │ │ │ ├── kinematics.rst │ │ │ │ │ ├── printing.rst │ │ │ │ │ ├── classes.rst │ │ │ │ │ └── functions.rst │ │ │ └── index.rst │ │ ├── utilities │ │ │ ├── pytest.rst │ │ │ ├── pkgdata.rst │ │ │ ├── lambdify.rst │ │ │ ├── runtests.rst │ │ │ ├── decorator.rst │ │ │ ├── misc.rst │ │ │ ├── memoization.rst │ │ │ ├── timeutils.rst │ │ │ ├── randtest.rst │ │ │ ├── source.rst │ │ │ ├── index.rst │ │ │ └── enumerative.rst │ │ ├── tensor │ │ │ ├── index_methods.rst │ │ │ ├── indexed.rst │ │ │ ├── index.rst │ │ │ └── tensor.rst │ │ ├── galgebra │ │ │ ├── manifold_testlatex.png │ │ │ ├── simple_test_latex_1.png │ │ │ ├── simple_test_latex_2.png │ │ │ ├── manifold.rst │ │ │ ├── debug.rst │ │ │ ├── vector.rst │ │ │ ├── stringarrays.rst │ │ │ ├── index.rst │ │ │ ├── precedence.rst │ │ │ ├── printing.rst │ │ │ └── ncutil.rst │ │ ├── combinatorics │ │ │ ├── prufer.rst │ │ │ ├── polyhedron.rst │ │ │ ├── group_constructs.rst │ │ │ ├── perm_groups.rst │ │ │ ├── subsets.rst │ │ │ ├── tensor_can.rst │ │ │ ├── named_groups.rst │ │ │ ├── testutil.rst │ │ │ ├── partitions.rst │ │ │ ├── index.rst │ │ │ ├── util.rst │ │ │ ├── graycode.rst │ │ │ └── permutations.rst │ │ ├── matrices │ │ │ ├── index.rst │ │ │ ├── dense.rst │ │ │ └── sparse.rst │ │ ├── calculus │ │ │ └── index.rst │ │ ├── solvers │ │ │ └── inequalities.rst │ │ ├── functions │ │ │ └── index.rst │ │ └── polys │ │ │ └── index.rst │ ├── special_topics │ │ ├── index.rst │ │ └── intro.rst │ ├── wiki.rst │ ├── logo │ │ └── info.txt │ ├── tutorial │ │ └── index.rst │ └── index.rst ├── cheatsheet │ └── combinatoric_cheatsheet.tex ├── apidoc.conf ├── api │ └── index.rst └── README.rst ├── data └── TeXmacs │ └── progs │ └── init-sympy.scm ├── bin ├── test_import.py ├── get_sympy.py ├── py.bench ├── diagnose_imports ├── ask_update.py └── test_import ├── MANIFEST.in └── examples ├── beginner ├── basic.py ├── expansion.py ├── plotting_nice_plot.py ├── series.py ├── precision.py ├── functions.py ├── substitution.py ├── differentiation.py ├── print_pretty.py └── limits_examples.py ├── intermediate ├── print_gtk.py ├── differential_equations.py └── trees.py ├── galgebra ├── matrix_latex.py ├── exp_check.py ├── simple_check.py ├── mv_setup_options.py └── prob_not_solenoidal.py └── advanced └── hydrogen.py /sympy/core/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/sets/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/calculus/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/concrete/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/crypto/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/diffgeom/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/external/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/galgebra/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/geometry/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/integrals/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/logic/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/matrices/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/mpmath/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/ntheory/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/parsing/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/physics/hep/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/physics/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/plotting/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/polys/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/printing/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/series/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/simplify/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/solvers/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/stats/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/tensor/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/unify/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/utilities/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/vector/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.py diff=python 2 | -------------------------------------------------------------------------------- /sympy/assumptions/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/categories/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/combinatorics/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/interactive/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/liealgebras/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/logic/algorithms/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/physics/hep/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/physics/optics/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/physics/vector/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/polys/agca/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/polys/benchmarks/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/polys/domains/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/strategies/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/strategies/tests/test_strat.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /release/.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | release 3 | -------------------------------------------------------------------------------- /sympy/functions/special/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/physics/mechanics/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/physics/quantum/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/plotting/pygletplot/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/printing/pretty/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/strategies/branch/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/functions/combinatorial/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/functions/elementary/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/matrices/expressions/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/plotting/intervalmath/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /sympy/release.py: -------------------------------------------------------------------------------- 1 | __version__ = "0.7.5-git" 2 | -------------------------------------------------------------------------------- /sympy/logic/utilities/__init__.py: -------------------------------------------------------------------------------- 1 | from .dimacs import load_file 2 | -------------------------------------------------------------------------------- /setupegg.py: -------------------------------------------------------------------------------- 1 | import setuptools 2 | 3 | exec(open('setup.py').read()) 4 | -------------------------------------------------------------------------------- /sympy/physics/unitsystems/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /sympy/liealgebras/__init__.py: -------------------------------------------------------------------------------- 1 | from sympy.liealgebras.cartan_type import CartanType 2 | -------------------------------------------------------------------------------- /sympy/parsing/__init__.py: -------------------------------------------------------------------------------- 1 | """Used for translating a string into a SymPy expression. """ 2 | -------------------------------------------------------------------------------- /sympy/functions/combinatorial/__init__.py: -------------------------------------------------------------------------------- 1 | from . import factorials 2 | from . import numbers 3 | -------------------------------------------------------------------------------- /doc/src/pics/winpdb1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/pics/winpdb1.png -------------------------------------------------------------------------------- /doc/src/pics/winpdb2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/pics/winpdb2.png -------------------------------------------------------------------------------- /doc/src/pics/pngview1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/pics/pngview1.png -------------------------------------------------------------------------------- /doc/src/_static/sympylogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/_static/sympylogo.png -------------------------------------------------------------------------------- /doc/src/pics/consoleascii.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/pics/consoleascii.png -------------------------------------------------------------------------------- /sympy/concrete/__init__.py: -------------------------------------------------------------------------------- 1 | from .products import product, Product 2 | from .summations import summation, Sum 3 | -------------------------------------------------------------------------------- /doc/src/modules/geometry/plane.rst: -------------------------------------------------------------------------------- 1 | Plane 2 | ----- 3 | 4 | .. automodule:: sympy.geometry.plane 5 | :members: 6 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plot.png -------------------------------------------------------------------------------- /doc/src/pics/consoleunicode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/pics/consoleunicode.png -------------------------------------------------------------------------------- /doc/src/_static/sympylogo_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/_static/sympylogo_big.png -------------------------------------------------------------------------------- /doc/src/modules/assumptions/ask.rst: -------------------------------------------------------------------------------- 1 | === 2 | Ask 3 | === 4 | 5 | .. automodule:: sympy.assumptions.ask 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/geometry/line3d.rst: -------------------------------------------------------------------------------- 1 | 3D Line 2 | ------- 3 | 4 | .. automodule:: sympy.geometry.line3d 5 | :members: 6 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/cplot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/cplot.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/splot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/splot.png -------------------------------------------------------------------------------- /doc/src/pics/ipythonnotebook.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/pics/ipythonnotebook.png -------------------------------------------------------------------------------- /doc/src/pics/ipythonqtconsole.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/pics/ipythonqtconsole.png -------------------------------------------------------------------------------- /doc/src/modules/geometry/point3d.rst: -------------------------------------------------------------------------------- 1 | 3D Point 2 | -------- 3 | 4 | .. automodule:: sympy.geometry.point3d 5 | :members: 6 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/ai.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/ai.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/ai_c.py: -------------------------------------------------------------------------------- 1 | # Airy function Ai(z) in the complex plane 2 | cplot(airyai, [-8,8], [-8,8], points=50000) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/ber.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/ber.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/bi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/bi.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/bi_c.py: -------------------------------------------------------------------------------- 1 | # Airy function Bi(z) in the complex plane 2 | cplot(airybi, [-8,8], [-8,8], points=50000) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/gi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/gi.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/hi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/hi.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/ker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/ker.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/ai_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/ai_c.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/bi_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/bi_c.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/chebyt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/chebyt.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/chebyu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/chebyu.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/ellipe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/ellipe.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/ellipf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/ellipf.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/ellipk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/ellipk.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/gi_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/gi_c.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/gi_c.py: -------------------------------------------------------------------------------- 1 | # Scorer function Gi(z) in the complex plane 2 | cplot(scorergi, [-8,8], [-8,8], points=50000) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/hi_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/hi_c.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/hi_c.py: -------------------------------------------------------------------------------- 1 | # Scorer function Hi(z) in the complex plane 2 | cplot(scorerhi, [-8,8], [-8,8], points=50000) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/kleinj.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/kleinj.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/pcfd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/pcfd.png -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/qft.rst: -------------------------------------------------------------------------------- 1 | === 2 | QFT 3 | === 4 | 5 | .. automodule:: sympy.physics.quantum.qft 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/assumptions/assume.rst: -------------------------------------------------------------------------------- 1 | ====== 2 | Assume 3 | ====== 4 | 5 | .. automodule:: sympy.assumptions.assume 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/assumptions/refine.rst: -------------------------------------------------------------------------------- 1 | ====== 2 | Refine 3 | ====== 4 | 5 | .. automodule:: sympy.assumptions.refine 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/besseli.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/besseli.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/besselj.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/besselj.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/besselk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/besselk.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/bessely.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/bessely.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/coulombf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/coulombf.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/coulombg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/coulombg.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/ellipk.py: -------------------------------------------------------------------------------- 1 | # Complete elliptic integrals K(m) and E(m) 2 | plot([ellipk, ellipe], [-2,1], [0,3], points=600) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/ellippi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/ellippi.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/gi.py: -------------------------------------------------------------------------------- 1 | # Scorer function Gi(x) and Gi'(x) on the real line 2 | plot([scorergi, diffun(scorergi)], [-10,10]) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/hankel1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/hankel1.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/hankel2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/hankel2.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/hermite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/hermite.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/kleinj2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/kleinj2.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/laguerre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/laguerre.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/lambertw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/lambertw.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/legendre.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/legendre.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/lommels1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/lommels1.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/lommels2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/lommels2.png -------------------------------------------------------------------------------- /doc/src/modules/physics/optics/utils.rst: -------------------------------------------------------------------------------- 1 | Utilities 2 | --------- 3 | 4 | .. automodule:: sympy.physics.optics.utils 5 | :members: 6 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/spin.rst: -------------------------------------------------------------------------------- 1 | ==== 2 | Spin 3 | ==== 4 | 5 | .. automodule:: sympy.physics.quantum.spin 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/utilities/pytest.rst: -------------------------------------------------------------------------------- 1 | ====== 2 | pytest 3 | ====== 4 | 5 | .. automodule:: sympy.utilities.pytest 6 | :members: 7 | -------------------------------------------------------------------------------- /sympy/mpmath/matrices/__init__.py: -------------------------------------------------------------------------------- 1 | from . import eigen # to set methods 2 | from . import eigen_symmetric # to set methods 3 | -------------------------------------------------------------------------------- /doc/cheatsheet/combinatoric_cheatsheet.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/cheatsheet/combinatoric_cheatsheet.tex -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/besseli_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/besseli_c.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/besselj_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/besselj_c.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/besselk_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/besselk_c.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/bessely_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/bessely_c.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/coulombf_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/coulombf_c.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/coulombg_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/coulombg_c.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/hankel1_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/hankel1_c.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/hankel2_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/hankel2_c.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/hi.py: -------------------------------------------------------------------------------- 1 | # Scorer function Hi(x) and Hi'(x) on the real line 2 | plot([scorerhi, diffun(scorerhi)], [-10,2], [0,2]) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/lambertw_c.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/lambertw_c.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/lambertw_c.py: -------------------------------------------------------------------------------- 1 | # Principal branch of the Lambert W function W(z) 2 | cplot(lambertw, [-1,1], [-1,1], points=50000) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/spherharm40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/spherharm40.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/spherharm41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/spherharm41.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/spherharm42.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/spherharm42.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/spherharm43.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/spherharm43.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/spherharm44.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/mpmath/plots/spherharm44.png -------------------------------------------------------------------------------- /doc/src/modules/physics/matrices.rst: -------------------------------------------------------------------------------- 1 | ======== 2 | Matrices 3 | ======== 4 | 5 | .. automodule:: sympy.physics.matrices 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/physics/optics/waves.rst: -------------------------------------------------------------------------------- 1 | ====== 2 | Waves 3 | ====== 4 | 5 | .. automodule:: sympy.physics.optics.waves 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/gate.rst: -------------------------------------------------------------------------------- 1 | ===== 2 | Gates 3 | ===== 4 | 5 | .. automodule:: sympy.physics.quantum.gate 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/qubit.rst: -------------------------------------------------------------------------------- 1 | ===== 2 | Qubit 3 | ===== 4 | 5 | .. automodule:: sympy.physics.quantum.qubit 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/state.rst: -------------------------------------------------------------------------------- 1 | ===== 2 | State 3 | ===== 4 | 5 | .. automodule:: sympy.physics.quantum.state 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/utilities/pkgdata.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | PKGDATA 3 | ======= 4 | 5 | .. automodule:: sympy.utilities.pkgdata 6 | :members: 7 | -------------------------------------------------------------------------------- /sympy/polys/agca/__init__.py: -------------------------------------------------------------------------------- 1 | """Module for algebraic geomery and commutative algebra.""" 2 | 3 | from .homomorphisms import homomorphism 4 | -------------------------------------------------------------------------------- /doc/src/modules/assumptions/handlers/sets.rst: -------------------------------------------------------------------------------- 1 | ==== 2 | Sets 3 | ==== 4 | 5 | .. automodule:: sympy.assumptions.handlers.sets 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/geometry/curves.rst: -------------------------------------------------------------------------------- 1 | Curves 2 | ------ 3 | 4 | .. module:: sympy.geometry.curve 5 | 6 | .. autoclass:: Curve 7 | :members: 8 | -------------------------------------------------------------------------------- /doc/src/modules/geometry/points.rst: -------------------------------------------------------------------------------- 1 | Points 2 | ------ 3 | 4 | .. module:: sympy.geometry.point 5 | 6 | .. autoclass:: Point 7 | :members: 8 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/coulombf_c.py: -------------------------------------------------------------------------------- 1 | # Regular Coulomb wave function in the complex plane 2 | cplot(lambda z: coulombf(1,1,z), points=50000) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/coulombg_c.py: -------------------------------------------------------------------------------- 1 | # Irregular Coulomb wave function in the complex plane 2 | cplot(lambda z: coulombg(1,1,z), points=50000) -------------------------------------------------------------------------------- /doc/src/modules/physics/optics/medium.rst: -------------------------------------------------------------------------------- 1 | ====== 2 | Medium 3 | ====== 4 | 5 | .. automodule:: sympy.physics.optics.medium 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/dagger.rst: -------------------------------------------------------------------------------- 1 | ====== 2 | Dagger 3 | ====== 4 | 5 | .. automodule:: sympy.physics.quantum.dagger 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/qapply.rst: -------------------------------------------------------------------------------- 1 | ====== 2 | Qapply 3 | ====== 4 | 5 | .. automodule:: sympy.physics.quantum.qapply 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/tensor/index_methods.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | Methods 3 | ======= 4 | 5 | .. automodule:: sympy.tensor.index_methods 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/utilities/lambdify.rst: -------------------------------------------------------------------------------- 1 | ======== 2 | Lambdify 3 | ======== 4 | 5 | .. automodule:: sympy.utilities.lambdify 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/utilities/runtests.rst: -------------------------------------------------------------------------------- 1 | ========= 2 | Run Tests 3 | ========= 4 | 5 | .. automodule:: sympy.utilities.runtests 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/assumptions/handlers/order.rst: -------------------------------------------------------------------------------- 1 | ===== 2 | Order 3 | ===== 4 | 5 | .. automodule:: sympy.assumptions.handlers.order 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/galgebra/manifold_testlatex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/galgebra/manifold_testlatex.png -------------------------------------------------------------------------------- /doc/src/modules/galgebra/simple_test_latex_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/galgebra/simple_test_latex_1.png -------------------------------------------------------------------------------- /doc/src/modules/galgebra/simple_test_latex_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jrjohansson/sympy/master/doc/src/modules/galgebra/simple_test_latex_2.png -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/besselj_c.py: -------------------------------------------------------------------------------- 1 | # Bessel function J_n(z) in the complex plane 2 | cplot(lambda z: besselj(1,z), [-8,8], [-8,8], points=50000) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/hankel1_c.py: -------------------------------------------------------------------------------- 1 | # Hankel function H1_n(z) in the complex plane 2 | cplot(lambda z: hankel1(1,z), [-8,8], [-8,8], points=50000) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/hankel2_c.py: -------------------------------------------------------------------------------- 1 | # Hankel function H2_n(z) in the complex plane 2 | cplot(lambda z: hankel2(1,z), [-8,8], [-8,8], points=50000) -------------------------------------------------------------------------------- /doc/src/modules/utilities/decorator.rst: -------------------------------------------------------------------------------- 1 | ========= 2 | Decorator 3 | ========= 4 | 5 | .. automodule:: sympy.utilities.decorator 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/utilities/misc.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | Miscellaneous 3 | ============= 4 | 5 | .. automodule:: sympy.utilities.misc 6 | :members: 7 | -------------------------------------------------------------------------------- /sympy/mpmath/calculus/calculus.py: -------------------------------------------------------------------------------- 1 | class CalculusMethods(object): 2 | pass 3 | 4 | def defun(f): 5 | setattr(CalculusMethods, f.__name__, f) 6 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/operator.rst: -------------------------------------------------------------------------------- 1 | ======== 2 | Operator 3 | ======== 4 | 5 | .. automodule:: sympy.physics.quantum.operator 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/physics/wigner.rst: -------------------------------------------------------------------------------- 1 | ============== 2 | Wigner Symbols 3 | ============== 4 | 5 | .. automodule:: sympy.physics.wigner 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/tensor/indexed.rst: -------------------------------------------------------------------------------- 1 | =============== 2 | Indexed Objects 3 | =============== 4 | 5 | .. automodule:: sympy.tensor.indexed 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/assumptions/handlers/ntheory.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | nTheory 3 | ======= 4 | 5 | .. automodule:: sympy.assumptions.handlers.ntheory 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/besseli_c.py: -------------------------------------------------------------------------------- 1 | # Modified Bessel function I_n(z) in the complex plane 2 | cplot(lambda z: besseli(1,z), [-8,8], [-8,8], points=50000) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/bessely_c.py: -------------------------------------------------------------------------------- 1 | # Bessel function of 2nd kind Y_n(z) in the complex plane 2 | cplot(lambda z: bessely(1,z), [-8,8], [-8,8], points=50000) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/lambertw.py: -------------------------------------------------------------------------------- 1 | # Branches 0 and -1 of the Lambert W function 2 | plot([lambertw, lambda x: lambertw(x,-1)], [-2,2], [-5,2], points=2000) -------------------------------------------------------------------------------- /doc/src/modules/physics/paulialgebra.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | Pauli Algebra 3 | ============= 4 | 5 | .. automodule:: sympy.physics.paulialgebra 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/constants.rst: -------------------------------------------------------------------------------- 1 | ========= 2 | Constants 3 | ========= 4 | 5 | .. automodule:: sympy.physics.quantum.constants 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/represent.rst: -------------------------------------------------------------------------------- 1 | ========= 2 | Represent 3 | ========= 4 | 5 | .. automodule:: sympy.physics.quantum.represent 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/utilities/memoization.rst: -------------------------------------------------------------------------------- 1 | =========== 2 | Memoization 3 | =========== 4 | 5 | .. automodule:: sympy.utilities.memoization 6 | :members: 7 | -------------------------------------------------------------------------------- /sympy/assumptions/handlers/__init__.py: -------------------------------------------------------------------------------- 1 | from .common import (AskHandler, CommonHandler, AskCommutativeHandler, 2 | TautologicalHandler, test_closed_group) 3 | -------------------------------------------------------------------------------- /doc/src/modules/assumptions/handlers/calculus.rst: -------------------------------------------------------------------------------- 1 | ======== 2 | Calculus 3 | ======== 4 | 5 | .. automodule:: sympy.assumptions.handlers.calculus 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/kleinj2.py: -------------------------------------------------------------------------------- 1 | # Klein J-function as function of the half-period ratio 2 | fp.cplot(lambda t: fp.kleinj(tau=t), [-1,2], [0,1.5], points=50000) -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/commutator.rst: -------------------------------------------------------------------------------- 1 | ========== 2 | Commutator 3 | ========== 4 | 5 | .. automodule:: sympy.physics.quantum.commutator 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/besselk_c.py: -------------------------------------------------------------------------------- 1 | # Modified Bessel function of 2nd kind K_n(z) in the complex plane 2 | cplot(lambda z: besselk(1,z), [-8,8], [-8,8], points=50000) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/kleinj.py: -------------------------------------------------------------------------------- 1 | # Klein J-function as function of the number-theoretic nome 2 | fp.cplot(lambda q: fp.kleinj(qbar=q), [-1,1], [-1,1], points=50000) -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/hilbert.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | Hilbert Space 3 | ============= 4 | 5 | .. automodule:: sympy.physics.quantum.hilbert 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/shor.rst: -------------------------------------------------------------------------------- 1 | ================ 2 | Shor's Algorithm 3 | ================ 4 | 5 | .. automodule:: sympy.physics.quantum.shor 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/utilities/timeutils.rst: -------------------------------------------------------------------------------- 1 | ================ 2 | Timing Utilities 3 | ================ 4 | 5 | .. automodule:: sympy.utilities.timeutils 6 | :members: 7 | -------------------------------------------------------------------------------- /data/TeXmacs/progs/init-sympy.scm: -------------------------------------------------------------------------------- 1 | (plugin-configure sympy 2 | (:require (url-exists-in-path? "tm_sympy")) 3 | (:launch "tm_sympy --texmacs") 4 | (:session "SymPy")) 5 | -------------------------------------------------------------------------------- /doc/src/modules/physics/optics/gaussopt.rst: -------------------------------------------------------------------------------- 1 | =============== 2 | Gaussian Optics 3 | =============== 4 | 5 | .. automodule:: sympy.physics.optics.gaussopt 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/circuitplot.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Circuit Plot 3 | ============ 4 | 5 | .. automodule:: sympy.physics.quantum.circuitplot 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/piab.rst: -------------------------------------------------------------------------------- 1 | ================= 2 | Particle in a Box 3 | ================= 4 | 5 | .. automodule:: sympy.physics.quantum.piab 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/utilities/randtest.rst: -------------------------------------------------------------------------------- 1 | ================== 2 | Randomised Testing 3 | ================== 4 | 5 | .. automodule:: sympy.utilities.randtest 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/physics/hydrogen.rst: -------------------------------------------------------------------------------- 1 | ====================== 2 | Hydrogen Wavefunctions 3 | ====================== 4 | 5 | .. automodule:: sympy.physics.hydrogen 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/grover.rst: -------------------------------------------------------------------------------- 1 | ================== 2 | Grover's Algorithm 3 | ================== 4 | 5 | .. automodule:: sympy.physics.quantum.grover 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/innerproduct.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | Inner Product 3 | ============= 4 | 5 | .. automodule:: sympy.physics.quantum.innerproduct 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/physics/secondquant.rst: -------------------------------------------------------------------------------- 1 | =================== 2 | Second Quantization 3 | =================== 4 | 5 | .. automodule:: sympy.physics.secondquant 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/utilities/source.rst: -------------------------------------------------------------------------------- 1 | ====================== 2 | Source Code Inspection 3 | ====================== 4 | 5 | .. automodule:: sympy.utilities.source 6 | :members: 7 | -------------------------------------------------------------------------------- /sympy/interactive/__init__.py: -------------------------------------------------------------------------------- 1 | """Helper module for setting up interactive SymPy sessions. """ 2 | 3 | from .printing import init_printing 4 | from .session import init_session 5 | -------------------------------------------------------------------------------- /doc/src/modules/geometry/entities.rst: -------------------------------------------------------------------------------- 1 | Entities 2 | -------- 3 | 4 | .. module:: sympy.geometry.entity 5 | 6 | .. autoclass:: sympy.geometry.entity.GeometryEntity 7 | :members: 8 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/anticommutator.rst: -------------------------------------------------------------------------------- 1 | ============== 2 | Anticommutator 3 | ============== 4 | 5 | .. automodule:: sympy.physics.quantum.anticommutator 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/tensorproduct.rst: -------------------------------------------------------------------------------- 1 | ============== 2 | Tensor Product 3 | ============== 4 | 5 | .. automodule:: sympy.physics.quantum.tensorproduct 6 | :members: 7 | -------------------------------------------------------------------------------- /sympy/physics/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | A module that helps solving problems in physics 3 | """ 4 | 5 | from . import units 6 | from .matrices import mgamma, msigma, minkowski_tensor, mdft 7 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/cg.rst: -------------------------------------------------------------------------------- 1 | =========================== 2 | Clebsch-Gordan Coefficients 3 | =========================== 4 | 5 | .. automodule:: sympy.physics.quantum.cg 6 | :members: 7 | -------------------------------------------------------------------------------- /doc/src/modules/physics/sho.rst: -------------------------------------------------------------------------------- 1 | ================================== 2 | Quantum Harmonic Oscillator in 3-D 3 | ================================== 4 | 5 | .. automodule:: sympy.physics.sho 6 | :members: 7 | -------------------------------------------------------------------------------- /sympy/assumptions/__init__.py: -------------------------------------------------------------------------------- 1 | from .assume import AppliedPredicate, Predicate, AssumptionsContext, assuming 2 | from .ask import Q, ask, register_handler, remove_handler 3 | from .refine import refine 4 | -------------------------------------------------------------------------------- /doc/src/modules/physics/unitsystems/prefixes.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | Unit prefixes 3 | ============= 4 | 5 | .. automodule:: sympy.physics.unitsystems.prefixes 6 | 7 | .. autoclass:: Prefix 8 | :members: 9 | -------------------------------------------------------------------------------- /doc/src/modules/geometry/ellipses.rst: -------------------------------------------------------------------------------- 1 | Ellipses 2 | -------- 3 | 4 | .. module:: sympy.geometry.ellipse 5 | 6 | .. autoclass:: Ellipse 7 | :members: 8 | 9 | .. autoclass:: Circle 10 | :members: 11 | -------------------------------------------------------------------------------- /doc/src/modules/physics/qho_1d.rst: -------------------------------------------------------------------------------- 1 | ================================== 2 | Quantum Harmonic Oscillator in 1-D 3 | ================================== 4 | 5 | .. automodule:: sympy.physics.qho_1d 6 | :members: 7 | -------------------------------------------------------------------------------- /sympy/functions/elementary/__init__.py: -------------------------------------------------------------------------------- 1 | from . import complexes 2 | from . import exponential 3 | from . import hyperbolic 4 | from . import integers 5 | from . import trigonometric 6 | from . import miscellaneous 7 | -------------------------------------------------------------------------------- /doc/src/modules/combinatorics/prufer.rst: -------------------------------------------------------------------------------- 1 | .. _combinatorics-prufer: 2 | 3 | Prufer Sequences 4 | ================ 5 | 6 | .. module:: sympy.combinatorics.prufer 7 | 8 | .. autoclass:: Prufer 9 | :members: 10 | -------------------------------------------------------------------------------- /sympy/mpmath/calculus/__init__.py: -------------------------------------------------------------------------------- 1 | from . import calculus 2 | # XXX: hack to set methods 3 | from . import approximation 4 | from . import differentiation 5 | from . import extrapolation 6 | from . import polynomials 7 | -------------------------------------------------------------------------------- /doc/src/modules/combinatorics/polyhedron.rst: -------------------------------------------------------------------------------- 1 | .. _combinatorics-polyhedron: 2 | 3 | Polyhedron 4 | ========== 5 | 6 | .. module:: sympy.combinatorics.polyhedron 7 | 8 | .. autoclass:: Polyhedron 9 | :members: 10 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/cartesian.rst: -------------------------------------------------------------------------------- 1 | ============================== 2 | Cartesian Operators and States 3 | ============================== 4 | 5 | .. automodule:: sympy.physics.quantum.cartesian 6 | :members: 7 | -------------------------------------------------------------------------------- /sympy/strategies/branch/__init__.py: -------------------------------------------------------------------------------- 1 | from . import traverse 2 | from .core import (condition, debug, multiplex, exhaust, notempty, 3 | chain, onaction, sfilter, yieldify, do_one, identity) 4 | from .tools import canon 5 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/operatorset.rst: -------------------------------------------------------------------------------- 1 | =============================== 2 | Operator/State Helper Functions 3 | =============================== 4 | 5 | .. automodule:: sympy.physics.quantum.operatorset 6 | :members: 7 | -------------------------------------------------------------------------------- /sympy/series/benchmarks/bench_limit.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from sympy import Symbol, limit, oo 4 | 5 | x = Symbol('x') 6 | 7 | 8 | def timeit_limit_1x(): 9 | limit(1/x, x, oo) 10 | -------------------------------------------------------------------------------- /doc/src/modules/physics/unitsystems/quantities.rst: -------------------------------------------------------------------------------- 1 | =================== 2 | Physical quantities 3 | =================== 4 | 5 | .. automodule:: sympy.physics.unitsystems.quantities 6 | 7 | .. autoclass:: Quantity 8 | :members: 9 | -------------------------------------------------------------------------------- /sympy/tensor/__init__.py: -------------------------------------------------------------------------------- 1 | """A module to manipulate symbolic objects with indices including tensors 2 | 3 | """ 4 | from .indexed import IndexedBase, Idx, Indexed 5 | from .index_methods import get_contraction_structure, get_indices 6 | -------------------------------------------------------------------------------- /bin/test_import.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | 3 | from timeit import default_timer as clock 4 | from get_sympy import path_hack 5 | path_hack() 6 | t = clock() 7 | import sympy 8 | t = clock() - t 9 | print(t) 10 | -------------------------------------------------------------------------------- /doc/src/modules/combinatorics/group_constructs.rst: -------------------------------------------------------------------------------- 1 | .. _combinatorics-group_constructs: 2 | 3 | Group constructors 4 | ================== 5 | 6 | .. module:: sympy.combinatorics.group_constructs 7 | 8 | .. autofunction:: DirectProduct 9 | -------------------------------------------------------------------------------- /sympy/geometry/exceptions.py: -------------------------------------------------------------------------------- 1 | """Geometry Errors.""" 2 | 3 | from __future__ import print_function, division 4 | 5 | 6 | class GeometryError(ValueError): 7 | """An exception raised by classes in the geometry module.""" 8 | pass 9 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/ai.py: -------------------------------------------------------------------------------- 1 | # Airy function Ai(x), Ai'(x) and int_0^x Ai(t) dt on the real line 2 | f = airyai 3 | f_diff = lambda z: airyai(z, derivative=1) 4 | f_int = lambda z: airyai(z, derivative=-1) 5 | plot([f, f_diff, f_int], [-10,5]) -------------------------------------------------------------------------------- /sympy/sets/__init__.py: -------------------------------------------------------------------------------- 1 | from .sets import (Set, Interval, Union, EmptySet, FiniteSet, ProductSet, 2 | Intersection, imageset, Complement) 3 | from .fancysets import TransformationSet, ImageSet, Range 4 | from .contains import Contains 5 | -------------------------------------------------------------------------------- /doc/src/modules/combinatorics/perm_groups.rst: -------------------------------------------------------------------------------- 1 | .. _combinatorics-perm_groups: 2 | 3 | Permutation Groups 4 | ================== 5 | 6 | .. module:: sympy.combinatorics.perm_groups 7 | 8 | .. autoclass:: PermutationGroup 9 | :members: 10 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/besselj.py: -------------------------------------------------------------------------------- 1 | # Bessel function J_n(x) on the real line for n=0,1,2,3 2 | j0 = lambda x: besselj(0,x) 3 | j1 = lambda x: besselj(1,x) 4 | j2 = lambda x: besselj(2,x) 5 | j3 = lambda x: besselj(3,x) 6 | plot([j0,j1,j2,j3],[0,14]) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/ker.py: -------------------------------------------------------------------------------- 1 | # Kelvin functions ker_n(x) and kei_n(x) on the real line for n=0,2 2 | f0 = lambda x: ker(0,x) 3 | f1 = lambda x: kei(0,x) 4 | f2 = lambda x: ker(2,x) 5 | f3 = lambda x: kei(2,x) 6 | plot([f0,f1,f2,f3],[0,5],[-1,4]) -------------------------------------------------------------------------------- /doc/src/special_topics/index.rst: -------------------------------------------------------------------------------- 1 | .. _special_topics: 2 | 3 | ===================== 4 | SymPy Special Topics 5 | ===================== 6 | 7 | .. toctree:: 8 | :maxdepth: 2 9 | 10 | intro.rst 11 | finite_diff_derivatives.rst 12 | -------------------------------------------------------------------------------- /sympy/logic/__init__.py: -------------------------------------------------------------------------------- 1 | from .boolalg import (to_cnf, to_dnf, to_nnf, And, Or, Not, Xor, Nand, Nor, Implies, 2 | Equivalent, ITE, POSform, SOPform, simplify_logic, 3 | bool_equal, bool_map, true, false) 4 | from .inference import satisfiable 5 | -------------------------------------------------------------------------------- /doc/src/modules/galgebra/manifold.rst: -------------------------------------------------------------------------------- 1 | Manifold for Geometric Algebra 2 | ============================== 3 | 4 | .. module:: sympy.galgebra.manifold 5 | 6 | Class Reference 7 | --------------- 8 | 9 | .. autoclass:: Manifold 10 | :members: 11 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/ber.py: -------------------------------------------------------------------------------- 1 | # Kelvin functions ber_n(x) and bei_n(x) on the real line for n=0,2 2 | f0 = lambda x: ber(0,x) 3 | f1 = lambda x: bei(0,x) 4 | f2 = lambda x: ber(2,x) 5 | f3 = lambda x: bei(2,x) 6 | plot([f0,f1,f2,f3],[0,10],[-10,10]) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/bi.py: -------------------------------------------------------------------------------- 1 | # Airy function Bi(x), Bi'(x) and int_0^x Bi(t) dt on the real line 2 | f = airybi 3 | f_diff = lambda z: airybi(z, derivative=1) 4 | f_int = lambda z: airybi(z, derivative=-1) 5 | plot([f, f_diff, f_int], [-10,2], [-1,2]) -------------------------------------------------------------------------------- /doc/src/modules/geometry/utils.rst: -------------------------------------------------------------------------------- 1 | Utils 2 | ----- 3 | 4 | .. module:: sympy.geometry.util 5 | 6 | .. autofunction:: intersection 7 | 8 | .. autofunction:: convex_hull 9 | 10 | .. autofunction:: are_similar 11 | 12 | .. autofunction:: centroid 13 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/hankel1.py: -------------------------------------------------------------------------------- 1 | # Hankel function H1_n(x) on the real line for n=0,1,2,3 2 | h0 = lambda x: hankel1(0,x) 3 | h1 = lambda x: hankel1(1,x) 4 | h2 = lambda x: hankel1(2,x) 5 | h3 = lambda x: hankel1(3,x) 6 | plot([h0,h1,h2,h3],[0,6],[-2,1]) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/hankel2.py: -------------------------------------------------------------------------------- 1 | # Hankel function H2_n(x) on the real line for n=0,1,2,3 2 | h0 = lambda x: hankel2(0,x) 3 | h1 = lambda x: hankel2(1,x) 4 | h2 = lambda x: hankel2(2,x) 5 | h3 = lambda x: hankel2(3,x) 6 | plot([h0,h1,h2,h3],[0,6],[-1,2]) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/calculus/odes.rst: -------------------------------------------------------------------------------- 1 | Ordinary differential equations 2 | ------------------------------- 3 | 4 | Solving the ODE initial value problem (``odefun``) 5 | .................................................. 6 | 7 | .. autofunction:: mpmath.odefun 8 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/besseli.py: -------------------------------------------------------------------------------- 1 | # Modified Bessel function I_n(x) on the real line for n=0,1,2,3 2 | i0 = lambda x: besseli(0,x) 3 | i1 = lambda x: besseli(1,x) 4 | i2 = lambda x: besseli(2,x) 5 | i3 = lambda x: besseli(3,x) 6 | plot([i0,i1,i2,i3],[0,5],[0,5]) -------------------------------------------------------------------------------- /doc/src/modules/physics/mechanics/api/linearize.rst: -------------------------------------------------------------------------------- 1 | ========================== 2 | Linearization (Docstrings) 3 | ========================== 4 | 5 | Linearizer 6 | ========== 7 | 8 | .. automodule:: sympy.physics.mechanics.linearize 9 | :members: 10 | -------------------------------------------------------------------------------- /sympy/calculus/__init__.py: -------------------------------------------------------------------------------- 1 | """Some calculus-related methods waiting to find a better place in the 2 | SymPy modules tree. 3 | """ 4 | 5 | from .singularities import singularities 6 | from .finite_diff import finite_diff_weights, apply_finite_diff, as_finite_diff 7 | -------------------------------------------------------------------------------- /doc/src/modules/combinatorics/subsets.rst: -------------------------------------------------------------------------------- 1 | .. _combinatorics-subsets: 2 | 3 | Subsets 4 | ======= 5 | 6 | .. module:: sympy.combinatorics.subsets 7 | 8 | .. autoclass:: Subset 9 | :members: 10 | 11 | .. automethod:: sympy.combinatorics.subsets.ksubsets 12 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/bessely.py: -------------------------------------------------------------------------------- 1 | # Bessel function of 2nd kind Y_n(x) on the real line for n=0,1,2,3 2 | y0 = lambda x: bessely(0,x) 3 | y1 = lambda x: bessely(1,x) 4 | y2 = lambda x: bessely(2,x) 5 | y3 = lambda x: bessely(3,x) 6 | plot([y0,y1,y2,y3],[0,10],[-4,1]) -------------------------------------------------------------------------------- /sympy/mpmath/tests/test_mpmath.py: -------------------------------------------------------------------------------- 1 | from sympy.mpmath.libmp import * 2 | from sympy.mpmath import * 3 | 4 | def test_newstyle_classes(): 5 | for cls in [mp, fp, iv, mpf, mpc]: 6 | for s in cls.__class__.__mro__: 7 | assert isinstance(s, type) 8 | -------------------------------------------------------------------------------- /doc/src/modules/geometry/polygons.rst: -------------------------------------------------------------------------------- 1 | Polygons 2 | -------- 3 | 4 | .. module:: sympy.geometry.polygon 5 | 6 | .. autoclass:: Polygon 7 | :members: 8 | 9 | .. autoclass:: RegularPolygon 10 | :members: 11 | 12 | .. autoclass:: Triangle 13 | :members: 14 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include data * 2 | recursive-include doc * 3 | prune doc/_build 4 | recursive-include examples *.py README 5 | 6 | include sympy/utilities/mathml/data/*.xsl 7 | 8 | include LICENSE 9 | include TODO 10 | include AUTHORS 11 | include README.rst 12 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/besselk.py: -------------------------------------------------------------------------------- 1 | # Modified Bessel function of 2nd kind K_n(x) on the real line for n=0,1,2,3 2 | k0 = lambda x: besselk(0,x) 3 | k1 = lambda x: besselk(1,x) 4 | k2 = lambda x: besselk(2,x) 5 | k3 = lambda x: besselk(3,x) 6 | plot([k0,k1,k2,k3],[0,8],[0,5]) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/chebyt.py: -------------------------------------------------------------------------------- 1 | # Chebyshev polynomials T_n(x) on [-1,1] for n=0,1,2,3,4 2 | f0 = lambda x: chebyt(0,x) 3 | f1 = lambda x: chebyt(1,x) 4 | f2 = lambda x: chebyt(2,x) 5 | f3 = lambda x: chebyt(3,x) 6 | f4 = lambda x: chebyt(4,x) 7 | plot([f0,f1,f2,f3,f4],[-1,1]) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/chebyu.py: -------------------------------------------------------------------------------- 1 | # Chebyshev polynomials U_n(x) on [-1,1] for n=0,1,2,3,4 2 | f0 = lambda x: chebyu(0,x) 3 | f1 = lambda x: chebyu(1,x) 4 | f2 = lambda x: chebyu(2,x) 5 | f3 = lambda x: chebyu(3,x) 6 | f4 = lambda x: chebyu(4,x) 7 | plot([f0,f1,f2,f3,f4],[-1,1]) -------------------------------------------------------------------------------- /sympy/functions/elementary/benchmarks/bench_exp.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from sympy import exp, symbols 4 | 5 | x, y = symbols('x,y') 6 | 7 | e = exp(2*x) 8 | q = exp(3*x) 9 | 10 | 11 | def timeit_exp_subs(): 12 | e.subs(q, y) 13 | -------------------------------------------------------------------------------- /sympy/printing/pretty/__init__.py: -------------------------------------------------------------------------------- 1 | """ASCII-ART 2D pretty-printer""" 2 | 3 | from .pretty import (pretty, pretty_print, pprint, pprint_use_unicode, 4 | pprint_try_use_unicode, pager_print) 5 | 6 | # if unicode output is available -- let's use it 7 | pprint_try_use_unicode() 8 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/lommels1.py: -------------------------------------------------------------------------------- 1 | # Lommel function s_(u,v)(x) on the real line for a few different u,v 2 | f1 = lambda x: lommels1(-1,2.5,x) 3 | f2 = lambda x: lommels1(0,0.5,x) 4 | f3 = lambda x: lommels1(0,6,x) 5 | f4 = lambda x: lommels1(0.5,3,x) 6 | plot([f1,f2,f3,f4], [0,20]) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/ellipe.py: -------------------------------------------------------------------------------- 1 | # Elliptic integral E(z,m) for some different m 2 | f1 = lambda z: ellipe(z,-2) 3 | f2 = lambda z: ellipe(z,-1) 4 | f3 = lambda z: ellipe(z,0) 5 | f4 = lambda z: ellipe(z,1) 6 | f5 = lambda z: ellipe(z,2) 7 | plot([f1,f2,f3,f4,f5], [0,pi], [0,4]) 8 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/ellipf.py: -------------------------------------------------------------------------------- 1 | # Elliptic integral F(z,m) for some different m 2 | f1 = lambda z: ellipf(z,-1) 3 | f2 = lambda z: ellipf(z,-0.5) 4 | f3 = lambda z: ellipf(z,0) 5 | f4 = lambda z: ellipf(z,0.5) 6 | f5 = lambda z: ellipf(z,1) 7 | plot([f1,f2,f3,f4,f5], [0,pi], [0,4]) 8 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/pcfd.py: -------------------------------------------------------------------------------- 1 | # Parabolic cylinder function D_n(x) on the real line for n=0,1,2,3,4 2 | d0 = lambda x: pcfd(0,x) 3 | d1 = lambda x: pcfd(1,x) 4 | d2 = lambda x: pcfd(2,x) 5 | d3 = lambda x: pcfd(3,x) 6 | d4 = lambda x: pcfd(4,x) 7 | plot([d0,d1,d2,d3,d4],[-7,7]) 8 | -------------------------------------------------------------------------------- /sympy/core/benchmarks/bench_sympify.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from sympy.core import sympify, Symbol 4 | 5 | x = Symbol('x') 6 | 7 | 8 | def timeit_sympify_1(): 9 | sympify(1) 10 | 11 | 12 | def timeit_sympify_x(): 13 | sympify(x) 14 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/legendre.py: -------------------------------------------------------------------------------- 1 | # Legendre polynomials P_n(x) on [-1,1] for n=0,1,2,3,4 2 | f0 = lambda x: legendre(0,x) 3 | f1 = lambda x: legendre(1,x) 4 | f2 = lambda x: legendre(2,x) 5 | f3 = lambda x: legendre(3,x) 6 | f4 = lambda x: legendre(4,x) 7 | plot([f0,f1,f2,f3,f4],[-1,1]) -------------------------------------------------------------------------------- /sympy/physics/unitsystems/systems/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from sympy.physics.unitsystems.systems.mks import mks_dim, mks 4 | from sympy.physics.unitsystems.systems.mksa import mksa_dim, mksa 5 | from sympy.physics.unitsystems.systems.natural import natural_dim, natural 6 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/hermite.py: -------------------------------------------------------------------------------- 1 | # Hermite polynomials H_n(x) on the real line for n=0,1,2,3,4 2 | f0 = lambda x: hermite(0,x) 3 | f1 = lambda x: hermite(1,x) 4 | f2 = lambda x: hermite(2,x) 5 | f3 = lambda x: hermite(3,x) 6 | f4 = lambda x: hermite(4,x) 7 | plot([f0,f1,f2,f3,f4],[-2,2],[-25,25]) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/lommels2.py: -------------------------------------------------------------------------------- 1 | # Lommel function S_(u,v)(x) on the real line for a few different u,v 2 | f1 = lambda x: lommels2(-1,2.5,x) 3 | f2 = lambda x: lommels2(1.5,2,x) 4 | f3 = lambda x: lommels2(2.5,1,x) 5 | f4 = lambda x: lommels2(3.5,-0.5,x) 6 | plot([f1,f2,f3,f4], [0,8], [-8,8]) -------------------------------------------------------------------------------- /sympy/functions/special/benchmarks/bench_special.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from sympy import symbols 4 | from sympy.functions.special.spherical_harmonics import Ynm 5 | 6 | x, y = symbols('x,y') 7 | 8 | 9 | def timeit_Ynm_xy(): 10 | Ynm(1, 1, x, y) 11 | -------------------------------------------------------------------------------- /sympy/unify/__init__.py: -------------------------------------------------------------------------------- 1 | """ Unification in SymPy 2 | 3 | See sympy.unify.core docstring for algorithmic details 4 | 5 | See http://matthewrocklin.com/blog/work/2012/11/01/Unification/ for discussion 6 | """ 7 | 8 | from .usympy import unify, rebuild 9 | from .rewrite import rewriterule 10 | -------------------------------------------------------------------------------- /doc/src/modules/geometry/lines.rst: -------------------------------------------------------------------------------- 1 | Lines 2 | ----- 3 | 4 | .. module:: sympy.geometry.line 5 | 6 | .. autoclass:: LinearEntity 7 | :members: 8 | 9 | .. autoclass:: Line 10 | :members: 11 | 12 | .. autoclass:: Ray 13 | :members: 14 | 15 | .. autoclass:: Segment 16 | :members: 17 | -------------------------------------------------------------------------------- /sympy/plotting/__init__.py: -------------------------------------------------------------------------------- 1 | from .plot import plot_backends 2 | from .plot_implicit import plot_implicit 3 | from .textplot import textplot 4 | from .pygletplot import PygletPlot 5 | from .plot import (plot, plot_parametric, plot3d, plot3d_parametric_surface, 6 | plot3d_parametric_line) 7 | -------------------------------------------------------------------------------- /doc/src/modules/assumptions/handlers/index.rst: -------------------------------------------------------------------------------- 1 | ======== 2 | Handlers 3 | ======== 4 | 5 | .. automodule:: sympy.assumptions.handlers 6 | 7 | Contents 8 | ======== 9 | 10 | .. toctree:: 11 | :maxdepth: 3 12 | 13 | calculus.rst 14 | ntheory.rst 15 | order.rst 16 | sets.rst 17 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/calculus/index.rst: -------------------------------------------------------------------------------- 1 | Numerical calculus 2 | ================== 3 | 4 | .. toctree:: 5 | :maxdepth: 2 6 | 7 | polynomials.rst 8 | optimization.rst 9 | sums_limits.rst 10 | differentiation.rst 11 | integration.rst 12 | odes.rst 13 | approximation.rst 14 | -------------------------------------------------------------------------------- /doc/src/modules/tensor/index.rst: -------------------------------------------------------------------------------- 1 | .. _tensor_module: 2 | 3 | ============= 4 | Tensor Module 5 | ============= 6 | 7 | .. automodule:: sympy.tensor 8 | 9 | Contents 10 | ======== 11 | 12 | .. toctree:: 13 | :maxdepth: 3 14 | 15 | indexed.rst 16 | index_methods.rst 17 | tensor.rst 18 | -------------------------------------------------------------------------------- /sympy/plotting/intervalmath/__init__.py: -------------------------------------------------------------------------------- 1 | from .interval_arithmetic import interval 2 | from .lib_interval import (Abs, exp, log, log10, atan, sin, cos, tan, sqrt, 3 | imin, imax, sinh, cosh, tanh, acosh, asinh, atanh, 4 | asin, acos, atan, ceil, floor, And, Or) 5 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/laguerre.py: -------------------------------------------------------------------------------- 1 | # Hermite polynomials L_n(x) on the real line for n=0,1,2,3,4 2 | f0 = lambda x: laguerre(0,0,x) 3 | f1 = lambda x: laguerre(1,0,x) 4 | f2 = lambda x: laguerre(2,0,x) 5 | f3 = lambda x: laguerre(3,0,x) 6 | f4 = lambda x: laguerre(4,0,x) 7 | plot([f0,f1,f2,f3,f4],[0,10],[-10,10]) -------------------------------------------------------------------------------- /sympy/functions/special/__init__.py: -------------------------------------------------------------------------------- 1 | from . import gamma_functions 2 | from . import error_functions 3 | from . import zeta_functions 4 | from . import tensor_functions 5 | from . import delta_functions 6 | from . import elliptic_integrals 7 | from . import beta_functions 8 | 9 | from . import polynomials 10 | -------------------------------------------------------------------------------- /doc/src/modules/matrices/index.rst: -------------------------------------------------------------------------------- 1 | .. _matrices-docs: 2 | 3 | ======== 4 | Matrices 5 | ======== 6 | 7 | .. automodule:: sympy.matrices 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | matrices.rst 15 | dense.rst 16 | sparse.rst 17 | immutablematrices.rst 18 | expressions.rst 19 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/coulombf.py: -------------------------------------------------------------------------------- 1 | # Regular Coulomb wave functions -- equivalent to figure 14.3 in A&S 2 | F1 = lambda x: coulombf(0,0,x) 3 | F2 = lambda x: coulombf(0,1,x) 4 | F3 = lambda x: coulombf(0,5,x) 5 | F4 = lambda x: coulombf(0,10,x) 6 | F5 = lambda x: coulombf(0,x/2,x) 7 | plot([F1,F2,F3,F4,F5], [0,25], [-1.2,1.6]) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/coulombg.py: -------------------------------------------------------------------------------- 1 | # Irregular Coulomb wave functions -- equivalent to figure 14.5 in A&S 2 | F1 = lambda x: coulombg(0,0,x) 3 | F2 = lambda x: coulombg(0,1,x) 4 | F3 = lambda x: coulombg(0,5,x) 5 | F4 = lambda x: coulombg(0,10,x) 6 | F5 = lambda x: coulombg(0,x/2,x) 7 | plot([F1,F2,F3,F4,F5], [0,30], [-2,2]) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/ellippi.py: -------------------------------------------------------------------------------- 1 | # Elliptic integral Pi(n,z,m) for some different n, m 2 | f1 = lambda z: ellippi(0.9,z,0.9) 3 | f2 = lambda z: ellippi(0.5,z,0.5) 4 | f3 = lambda z: ellippi(-2,z,-0.9) 5 | f4 = lambda z: ellippi(-0.5,z,0.5) 6 | f5 = lambda z: ellippi(-1,z,0.5) 7 | plot([f1,f2,f3,f4,f5], [0,pi], [0,4]) 8 | -------------------------------------------------------------------------------- /doc/src/modules/physics/optics/index.rst: -------------------------------------------------------------------------------- 1 | ============== 2 | Optics Module 3 | ============== 4 | 5 | .. topic:: Abstract 6 | 7 | Contains docstrings of Physics-Optics module 8 | 9 | 10 | .. toctree:: 11 | :maxdepth: 3 12 | 13 | gaussopt.rst 14 | medium.rst 15 | utils.rst 16 | waves.rst 17 | -------------------------------------------------------------------------------- /doc/src/modules/calculus/index.rst: -------------------------------------------------------------------------------- 1 | ======== 2 | Calculus 3 | ======== 4 | 5 | .. automodule:: sympy.calculus 6 | 7 | .. automodule:: sympy.calculus.euler 8 | :members: 9 | 10 | .. automodule:: sympy.calculus.singularities 11 | :members: 12 | 13 | .. automodule :: sympy.calculus.finite_diff 14 | :members: 15 | -------------------------------------------------------------------------------- /sympy/mpmath/conftest.py: -------------------------------------------------------------------------------- 1 | # The py library is part of the "py.test" testing suite (python-codespeak-lib 2 | # on Debian), see http://codespeak.net/py/ 3 | 4 | import py 5 | 6 | #this makes py.test put mpath directory into the sys.path, so that we can 7 | #"import mpmath" from tests nicely 8 | rootdir = py.magic.autopath().dirpath() 9 | -------------------------------------------------------------------------------- /doc/src/modules/physics/hep/gamma_matrices.rst: -------------------------------------------------------------------------------- 1 | High energy physics 2 | =================== 3 | 4 | .. module:: sympy.physics.hep.gamma_matrices 5 | 6 | .. autoclass:: sympy.physics.hep.gamma_matrices._LorentzContainer 7 | :members: 8 | 9 | .. autoclass:: sympy.physics.hep.gamma_matrices.GammaMatrixHead 10 | :members: 11 | -------------------------------------------------------------------------------- /doc/src/modules/physics/hep/index.rst: -------------------------------------------------------------------------------- 1 | =================== 2 | High energy physics 3 | =================== 4 | 5 | .. topic:: Abstract 6 | 7 | Contains docstrings for methods in high energy physics. 8 | 9 | Gamma matrices 10 | ============== 11 | 12 | .. toctree:: 13 | :maxdepth: 3 14 | 15 | gamma_matrices.rst 16 | -------------------------------------------------------------------------------- /doc/src/modules/physics/unitsystems/dimensions.rst: -------------------------------------------------------------------------------- 1 | ================================ 2 | Dimensions and dimension systems 3 | ================================ 4 | 5 | .. automodule:: sympy.physics.unitsystems.dimensions 6 | 7 | .. autoclass:: Dimension 8 | :members: 9 | 10 | .. autoclass:: DimensionSystem 11 | :members: 12 | -------------------------------------------------------------------------------- /sympy/core/benchmarks/bench_assumptions.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from sympy.core import Symbol, Integer 4 | 5 | x = Symbol('x') 6 | i3 = Integer(3) 7 | 8 | 9 | def timeit_x_is_integer(): 10 | x.is_integer 11 | 12 | 13 | def timeit_Integer_is_irrational(): 14 | i3.is_irrational 15 | -------------------------------------------------------------------------------- /doc/apidoc.conf: -------------------------------------------------------------------------------- 1 | [epydoc] 2 | 3 | name : SymPy 4 | url: http://code.google.com/p/sympy 5 | 6 | modules : sympy, sympy.core, sympy.modules 7 | 8 | output : html 9 | target : ../api/ 10 | 11 | dotpath : /usr/bin/dot 12 | 13 | parse: yes 14 | introspect: yes 15 | 16 | private : no 17 | frames: no 18 | 19 | docformat : epytext 20 | -------------------------------------------------------------------------------- /doc/src/modules/physics/unitsystems/units.rst: -------------------------------------------------------------------------------- 1 | ====================== 2 | Units and unit systems 3 | ====================== 4 | 5 | .. automodule:: sympy.physics.unitsystems.units 6 | 7 | .. autoclass:: Unit 8 | :members: 9 | 10 | .. autoclass:: Constant 11 | :members: 12 | 13 | .. autoclass:: UnitSystem 14 | :members: 15 | -------------------------------------------------------------------------------- /sympy/liealgebras/tests/test_dynkin_diagram.py: -------------------------------------------------------------------------------- 1 | from sympy.liealgebras.dynkin_diagram import DynkinDiagram 2 | 3 | def test_DynkinDiagram(): 4 | c = DynkinDiagram("A3") 5 | diag = "0---0---0\n1 2 3" 6 | assert c == diag 7 | ct = DynkinDiagram(["B", 3]) 8 | diag2 = "0---0=>=0\n1 2 3" 9 | assert ct == diag2 10 | -------------------------------------------------------------------------------- /doc/src/wiki.rst: -------------------------------------------------------------------------------- 1 | Wiki 2 | ==== 3 | 4 | SymPy has a public wiki located at http://wiki.sympy.org. Users should feel 5 | free to contribute to this wiki anything interesting/useful. 6 | 7 | FAQ 8 | --- 9 | 10 | `FAQ `_ is one of the most useful 11 | wiki pages. It has answers to frequently-asked questions. 12 | -------------------------------------------------------------------------------- /sympy/core/alphabets.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | greeks = ('alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 4 | 'eta', 'theta', 'iota', 'kappa', 'lambda', 'mu', 'nu', 5 | 'xi', 'omicron', 'pi', 'rho', 'sigma', 'tau', 'upsilon', 6 | 'phi', 'chi', 'psi', 'omega') 7 | -------------------------------------------------------------------------------- /sympy/solvers/benchmarks/bench_solvers.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from sympy import zeros, eye, Symbol, solve_linear_system 4 | 5 | N = 8 6 | M = zeros(N, N + 1) 7 | M[:, :N] = eye(N) 8 | S = [Symbol('A%i' % i) for i in range(N)] 9 | 10 | 11 | def timeit_linsolve_trivial(): 12 | solve_linear_system(M, *S) 13 | -------------------------------------------------------------------------------- /doc/src/modules/galgebra/debug.rst: -------------------------------------------------------------------------------- 1 | Debug code for Geometric Algebra 2 | ================================ 3 | 4 | .. module:: sympy.galgebra.debug 5 | 6 | Function Reference 7 | ------------------ 8 | 9 | .. autofunction:: ostr 10 | 11 | .. autofunction:: oprint 12 | 13 | .. autofunction:: print_product_table 14 | 15 | .. autofunction:: print_sub_table 16 | -------------------------------------------------------------------------------- /doc/api/index.rst: -------------------------------------------------------------------------------- 1 | Welcome to SymPy API reference 2 | ============================== 3 | 4 | This is an automaticaly generated API documentation from SymPy sources. 5 | 6 | Click the "modules" (:ref:`modindex`) link in the top right corner to 7 | browse the modules. 8 | 9 | Or click the "index" to see an index of all SymPy functions, methods and 10 | classes. 11 | -------------------------------------------------------------------------------- /doc/src/modules/galgebra/vector.rst: -------------------------------------------------------------------------------- 1 | Vector for Geometric Algebra 2 | ============================ 3 | 4 | .. module:: sympy.galgebra.vector 5 | 6 | Class Reference 7 | --------------- 8 | 9 | .. autoclass:: Vector 10 | :members: 11 | 12 | Function Reference 13 | ------------------ 14 | 15 | .. autofunction:: flatten 16 | 17 | .. autofunction:: TrigSimp 18 | -------------------------------------------------------------------------------- /release/Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | Vagrant::Config.run do |config| 5 | #config.vm.box = "precise64" 6 | #config.vm.box_url = "http://files.vagrantup.com/precise64.box" 7 | config.vm.box = "precise32" 8 | config.vm.box_url = "http://files.vagrantup.com/precise32.box" 9 | config.ssh.forward_agent = true 10 | end 11 | -------------------------------------------------------------------------------- /sympy/series/__init__.py: -------------------------------------------------------------------------------- 1 | """A module that handles series: find a limit, order the series etc. 2 | """ 3 | from .order import Order 4 | from .limits import limit, Limit 5 | from .gruntz import gruntz 6 | from .series import series 7 | from .residues import residue 8 | 9 | O = Order 10 | 11 | __all__ = ['gruntz', 'limit', 'series', 'O', 'Order', 'Limit', "residue"] 12 | -------------------------------------------------------------------------------- /sympy/utilities/tests/test_source.py: -------------------------------------------------------------------------------- 1 | from sympy.utilities.source import get_mod_func, get_class 2 | 3 | 4 | def test_get_mod_func(): 5 | assert get_mod_func( 6 | 'sympy.core.basic.Basic') == ('sympy.core.basic', 'Basic') 7 | 8 | 9 | def test_get_class(): 10 | _basic = get_class('sympy.core.basic.Basic') 11 | assert _basic.__name__ == 'Basic' 12 | -------------------------------------------------------------------------------- /sympy/integrals/tests/test_lineintegrals.py: -------------------------------------------------------------------------------- 1 | from sympy import (symbols, integrate, Integral, diff, sin, cos, pi, E, ln, 2 | sympify, Curve, line_integrate, sqrt) 3 | 4 | s, t, x, y, z = symbols('s,t,x,y,z') 5 | 6 | 7 | def test_lineintegral(): 8 | c = Curve([E**t + 1, E**t - 1], (t, 0, ln(2))) 9 | assert line_integrate(x + y, c, [x, y]) == 3*sqrt(2) 10 | -------------------------------------------------------------------------------- /doc/src/logo/info.txt: -------------------------------------------------------------------------------- 1 | The real source is `sympy-use-text.svg`. 2 | 3 | The `sympy.svg` is "text to path" version of `sympy-use-text.svg`. 4 | To create it from `sympy-use-text.svg` do (you have to install 5 | the Computer Modern fonts first): 6 | 7 | Inkscape 8 | 1. Run Inkscape. 9 | 2. Open `sympy-use-text.svg` 10 | 3. Ctrl-A 11 | 4. Shift-Ctrl-C 12 | 5. Save As `sympy.svg` 13 | -------------------------------------------------------------------------------- /doc/src/modules/combinatorics/tensor_can.rst: -------------------------------------------------------------------------------- 1 | .. _combinatorics-tensor_can: 2 | 3 | Tensor Canonicalization 4 | ======================= 5 | 6 | .. module:: sympy.combinatorics.tensor_can 7 | 8 | .. autofunction:: canonicalize 9 | 10 | .. autofunction:: double_coset_can_rep 11 | 12 | .. autofunction:: get_symmetric_group_sgs 13 | 14 | .. autofunction:: bsgs_direct_product 15 | -------------------------------------------------------------------------------- /doc/src/modules/combinatorics/named_groups.rst: -------------------------------------------------------------------------------- 1 | .. _combinatorics-named_groups: 2 | 3 | Named Groups 4 | ============ 5 | 6 | .. module:: sympy.combinatorics.named_groups 7 | 8 | .. autofunction:: SymmetricGroup 9 | 10 | .. autofunction:: CyclicGroup 11 | 12 | .. autofunction:: DihedralGroup 13 | 14 | .. autofunction:: AlternatingGroup 15 | 16 | .. autofunction:: AbelianGroup 17 | -------------------------------------------------------------------------------- /doc/src/modules/physics/mechanics/api/expr_manip.rst: -------------------------------------------------------------------------------- 1 | ==================================== 2 | Expression Manipulation (Docstrings) 3 | ==================================== 4 | 5 | msubs 6 | ===== 7 | 8 | .. autofunction:: sympy.physics.mechanics.msubs 9 | 10 | find_dynamicsymbols 11 | =================== 12 | 13 | .. autofunction:: sympy.physics.mechanics.find_dynamicsymbols 14 | -------------------------------------------------------------------------------- /doc/src/tutorial/index.rst: -------------------------------------------------------------------------------- 1 | .. _tutorial: 2 | 3 | ================ 4 | SymPy Tutorial 5 | ================ 6 | 7 | .. toctree:: 8 | :maxdepth: 2 9 | 10 | preliminaries.rst 11 | intro.rst 12 | gotchas.rst 13 | basic_operations.rst 14 | printing.rst 15 | simplification.rst 16 | calculus.rst 17 | solvers.rst 18 | matrices.rst 19 | manipulation.rst 20 | -------------------------------------------------------------------------------- /doc/src/special_topics/intro.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Introduction 3 | ============ 4 | 5 | The purpose of this collection of documents is to provide users of SymPy with topics which are 6 | not strictly tutorial or are longer than tutorials and tests. The documents will hopefully 7 | fill a gap as SymPy matures and users find more ways to show how SymPy can be used in more 8 | advanced topics. 9 | -------------------------------------------------------------------------------- /sympy/core/coreerrors.py: -------------------------------------------------------------------------------- 1 | """Definitions of common exceptions for :mod:`sympy.core` module. """ 2 | 3 | from __future__ import print_function, division 4 | 5 | 6 | class BaseCoreError(Exception): 7 | """Base class for core related exceptions. """ 8 | 9 | 10 | class NonCommutativeExpression(BaseCoreError): 11 | """Raised when expression didn't have commutative property. """ 12 | -------------------------------------------------------------------------------- /sympy/liealgebras/tests/test_cartan_matrix.py: -------------------------------------------------------------------------------- 1 | from sympy.liealgebras.cartan_matrix import CartanMatrix 2 | from sympy.matrices import Matrix 3 | 4 | def test_CartanMatrix(): 5 | c = CartanMatrix("A3") 6 | m = Matrix(3, 3, [2, -1, 0, -1, 2, -1, 0, -1, 2]) 7 | assert c == m 8 | a = CartanMatrix(["G",2]) 9 | mt = Matrix(2, 2, [2, -1, -3, 2]) 10 | assert a == mt 11 | -------------------------------------------------------------------------------- /doc/src/modules/matrices/dense.rst: -------------------------------------------------------------------------------- 1 | Dense Matrices 2 | ============== 3 | 4 | Matrix Class Reference 5 | ---------------------- 6 | 7 | .. autoclass:: sympy.matrices.dense.MutableDenseMatrix 8 | :members: 9 | 10 | ImmutableMatrix Class Reference 11 | ------------------------------- 12 | 13 | .. autoclass:: sympy.matrices.immutable.ImmutableMatrix 14 | :members: 15 | :noindex: 16 | -------------------------------------------------------------------------------- /sympy/mpmath/functions/__init__.py: -------------------------------------------------------------------------------- 1 | from . import functions 2 | # Hack to update methods 3 | from . import factorials 4 | from . import hypergeometric 5 | from . import expintegrals 6 | from . import bessel 7 | from . import orthogonal 8 | from . import theta 9 | from . import elliptic 10 | from . import zeta 11 | from . import rszeta 12 | from . import zetazeros 13 | from . import qfunctions 14 | -------------------------------------------------------------------------------- /doc/src/modules/galgebra/stringarrays.rst: -------------------------------------------------------------------------------- 1 | String manipulation for Geometric Algebra 2 | ========================================= 3 | 4 | .. module:: sympy.galgebra.stringarrays 5 | 6 | Function Reference 7 | ------------------ 8 | 9 | .. autofunction:: fct_sym_array 10 | 11 | .. autofunction:: str_array 12 | 13 | .. autofunction:: str_combinations 14 | 15 | .. autofunction:: symbol_array 16 | -------------------------------------------------------------------------------- /sympy/integrals/benchmarks/bench_trigintegrate.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from sympy import Symbol, sin 4 | from sympy.integrals.trigonometry import trigintegrate 5 | 6 | x = Symbol('x') 7 | 8 | 9 | def timeit_trigintegrate_sin3x(): 10 | trigintegrate(sin(x)**3, x) 11 | 12 | 13 | def timeit_trigintegrate_x2(): 14 | trigintegrate(x**2, x) # -> None 15 | -------------------------------------------------------------------------------- /doc/src/modules/combinatorics/testutil.rst: -------------------------------------------------------------------------------- 1 | .. _combinatorics-testutil: 2 | 3 | Test Utilities 4 | ============== 5 | 6 | .. module:: sympy.combinatorics.testutil 7 | 8 | .. autofunction:: _cmp_perm_lists 9 | 10 | .. autofunction:: _naive_list_centralizer 11 | 12 | .. autofunction:: _verify_bsgs 13 | 14 | .. autofunction:: _verify_centralizer 15 | 16 | .. autofunction:: _verify_normal_closure 17 | -------------------------------------------------------------------------------- /sympy/liealgebras/tests/test_cartan_type.py: -------------------------------------------------------------------------------- 1 | from sympy.liealgebras.cartan_type import CartanType, Standard_Cartan 2 | from sympy.matrices import Matrix 3 | from sympy.core import Basic 4 | 5 | def test_Standard_Cartan(): 6 | c = CartanType("A4") 7 | assert c.rank() == 4 8 | assert c.series == "A" 9 | m = Standard_Cartan("A", 2) 10 | assert m.rank() == 2 11 | assert c.series == "A" 12 | -------------------------------------------------------------------------------- /sympy/series/series.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from sympy.core.sympify import sympify 4 | 5 | 6 | def series(expr, x=None, x0=0, n=6, dir="+"): 7 | """Series expansion of expr around point `x = x0`. 8 | 9 | See the doctring of Expr.series() for complete details of this wrapper. 10 | """ 11 | expr = sympify(expr) 12 | return expr.series(x, x0, n, dir) 13 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/spherharm41.py: -------------------------------------------------------------------------------- 1 | # Real part of spherical harmonic Y_(4,1)(theta,phi) 2 | def Y(l,m): 3 | def g(theta,phi): 4 | R = abs(fp.re(fp.spherharm(l,m,theta,phi))) 5 | x = R*fp.cos(phi)*fp.sin(theta) 6 | y = R*fp.sin(phi)*fp.sin(theta) 7 | z = R*fp.cos(theta) 8 | return [x,y,z] 9 | return g 10 | 11 | fp.splot(Y(4,1), [0,fp.pi], [0,2*fp.pi], points=300) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/spherharm42.py: -------------------------------------------------------------------------------- 1 | # Real part of spherical harmonic Y_(4,2)(theta,phi) 2 | def Y(l,m): 3 | def g(theta,phi): 4 | R = abs(fp.re(fp.spherharm(l,m,theta,phi))) 5 | x = R*fp.cos(phi)*fp.sin(theta) 6 | y = R*fp.sin(phi)*fp.sin(theta) 7 | z = R*fp.cos(theta) 8 | return [x,y,z] 9 | return g 10 | 11 | fp.splot(Y(4,2), [0,fp.pi], [0,2*fp.pi], points=300) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/spherharm43.py: -------------------------------------------------------------------------------- 1 | # Real part of spherical harmonic Y_(4,3)(theta,phi) 2 | def Y(l,m): 3 | def g(theta,phi): 4 | R = abs(fp.re(fp.spherharm(l,m,theta,phi))) 5 | x = R*fp.cos(phi)*fp.sin(theta) 6 | y = R*fp.sin(phi)*fp.sin(theta) 7 | z = R*fp.cos(theta) 8 | return [x,y,z] 9 | return g 10 | 11 | fp.splot(Y(4,3), [0,fp.pi], [0,2*fp.pi], points=300) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/spherharm44.py: -------------------------------------------------------------------------------- 1 | # Real part of spherical harmonic Y_(4,4)(theta,phi) 2 | def Y(l,m): 3 | def g(theta,phi): 4 | R = abs(fp.re(fp.spherharm(l,m,theta,phi))) 5 | x = R*fp.cos(phi)*fp.sin(theta) 6 | y = R*fp.sin(phi)*fp.sin(theta) 7 | z = R*fp.cos(theta) 8 | return [x,y,z] 9 | return g 10 | 11 | fp.splot(Y(4,4), [0,fp.pi], [0,2*fp.pi], points=300) -------------------------------------------------------------------------------- /doc/src/modules/physics/vector/api/kinematics.rst: -------------------------------------------------------------------------------- 1 | ======================= 2 | Kinematics (Docstrings) 3 | ======================= 4 | 5 | Point 6 | ===== 7 | 8 | .. automodule:: sympy.physics.vector.point 9 | :members: 10 | 11 | 12 | kinematic_equations 13 | =================== 14 | 15 | .. automodule:: sympy.physics.vector.functions 16 | :members: kinematic_equations, partial_velocity, get_motion_params 17 | -------------------------------------------------------------------------------- /sympy/physics/quantum/tests/test_constants.py: -------------------------------------------------------------------------------- 1 | from sympy import Float 2 | 3 | from sympy.physics.quantum.constants import hbar 4 | 5 | 6 | def test_hbar(): 7 | assert hbar.is_commutative is True 8 | assert hbar.is_real is True 9 | assert hbar.is_positive is True 10 | assert hbar.is_negative is False 11 | assert hbar.is_irrational is True 12 | 13 | assert hbar.evalf() == Float(1.05457162e-34) 14 | -------------------------------------------------------------------------------- /sympy/utilities/tests/test_timeutils.py: -------------------------------------------------------------------------------- 1 | """Tests for simple tools for timing functions' execution. """ 2 | 3 | import sys 4 | 5 | from sympy.utilities.timeutils import timed 6 | 7 | def test_timed(): 8 | result = timed(lambda: 1 + 1, limit=100000) 9 | assert result[0] == 100000 and result[3] == "ns" 10 | 11 | result = timed("1 + 1", limit=100000) 12 | assert result[0] == 100000 and result[3] == "ns" 13 | -------------------------------------------------------------------------------- /sympy/core/benchmarks/bench_basic.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from sympy.core import symbols, S, C 4 | 5 | x, y = symbols('x,y') 6 | 7 | 8 | def timeit_Symbol_meth_lookup(): 9 | x.diff # no call, just method lookup 10 | 11 | 12 | def timeit_S_lookup(): 13 | S.Exp1 14 | 15 | 16 | def timeit_C_lookup(): 17 | C.Add 18 | 19 | 20 | def timeit_Symbol_eq_xy(): 21 | x == y 22 | -------------------------------------------------------------------------------- /doc/README.rst: -------------------------------------------------------------------------------- 1 | How to Build Documentation 2 | ========================== 3 | 4 | To make the html documentation, install the prerequisites, e.g. on 5 | Debian/Ubuntu (similarly for other distributions):: 6 | 7 | apt-get install python-sphinx texlive-latex-recommended dvipng librsvg2-bin imagemagick docbook2x 8 | 9 | and do:: 10 | 11 | make html 12 | 13 | and to view it, do:: 14 | 15 | epiphany _build/html/index.html 16 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/calculus/polynomials.rst: -------------------------------------------------------------------------------- 1 | Polynomials 2 | ----------- 3 | 4 | See also :func:`taylor` and :func:`chebyfit` for 5 | approximation of functions by polynomials. 6 | 7 | Polynomial evaluation (``polyval``) 8 | ................................... 9 | 10 | .. autofunction:: mpmath.polyval 11 | 12 | Polynomial roots (``polyroots``) 13 | ................................ 14 | 15 | .. autofunction:: mpmath.polyroots 16 | -------------------------------------------------------------------------------- /sympy/core/tests/test_rules.py: -------------------------------------------------------------------------------- 1 | from sympy.core.rules import Transform 2 | 3 | from sympy.utilities.pytest import raises 4 | 5 | 6 | def test_Transform(): 7 | add1 = Transform(lambda x: x + 1, lambda x: x % 2 == 1) 8 | assert add1[1] == 2 9 | assert (1 in add1) is True 10 | assert add1.get(1) == 2 11 | 12 | raises(KeyError, lambda: add1[2]) 13 | assert (2 in add1) is False 14 | assert add1.get(2) is None 15 | -------------------------------------------------------------------------------- /doc/src/modules/galgebra/index.rst: -------------------------------------------------------------------------------- 1 | ======================== 2 | Geometric Algebra Module 3 | ======================== 4 | 5 | .. automodule:: sympy.galgebra 6 | 7 | Documentation for Geometric Algebra module. 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | ga.rst 15 | manifold.rst 16 | vector.rst 17 | precedence.rst 18 | printing.rst 19 | ncutil.rst 20 | stringarrays.rst 21 | debug.rst 22 | -------------------------------------------------------------------------------- /doc/src/modules/physics/mechanics/api/kane_lagrange.rst: -------------------------------------------------------------------------------- 1 | ============================================== 2 | Kane's Method & Lagrange's Method (Docstrings) 3 | ============================================== 4 | 5 | KaneMethod 6 | ========== 7 | 8 | .. automodule:: sympy.physics.mechanics.kane 9 | :members: 10 | 11 | 12 | LagrangesMethod 13 | =============== 14 | 15 | .. automodule:: sympy.physics.mechanics.lagrange 16 | :members: 17 | -------------------------------------------------------------------------------- /sympy/matrices/benchmarks/bench_matrix.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from sympy import eye, zeros, Integer 4 | 5 | i3 = Integer(3) 6 | M = eye(100) 7 | 8 | 9 | def timeit_Matrix__getitem_ii(): 10 | M[3, 3] 11 | 12 | 13 | def timeit_Matrix__getitem_II(): 14 | M[i3, i3] 15 | 16 | 17 | def timeit_Matrix__getslice(): 18 | M[:, :] 19 | 20 | 21 | def timeit_Matrix_zeronm(): 22 | zeros(100, 100) 23 | -------------------------------------------------------------------------------- /doc/src/modules/matrices/sparse.rst: -------------------------------------------------------------------------------- 1 | Sparse Matrices 2 | =============== 3 | 4 | .. module:: sympy.matrices.sparse 5 | 6 | SparseMatrix Class Reference 7 | ---------------------------- 8 | .. autoclass:: SparseMatrix 9 | :members: 10 | .. autoclass:: MutableSparseMatrix 11 | :members: 12 | 13 | ImmutableSparseMatrix Class Reference 14 | ------------------------------------- 15 | .. autoclass:: sympy.matrices.immutable.ImmutableSparseMatrix 16 | :members: 17 | -------------------------------------------------------------------------------- /examples/beginner/basic.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Basic example 4 | 5 | Demonstrates how to create symbols and print some algebra operations. 6 | """ 7 | 8 | import sympy 9 | from sympy import pprint 10 | 11 | 12 | def main(): 13 | a = sympy.Symbol('a') 14 | b = sympy.Symbol('b') 15 | c = sympy.Symbol('c') 16 | e = ( a*b*b + 2*b*a*b )**c 17 | 18 | print 19 | pprint(e) 20 | print 21 | 22 | if __name__ == "__main__": 23 | main() 24 | -------------------------------------------------------------------------------- /sympy/integrals/benchmarks/bench_integrate.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from sympy import integrate, Symbol, sin 4 | 5 | x = Symbol('x') 6 | 7 | 8 | def bench_integrate_sin(): 9 | integrate(sin(x), x) 10 | 11 | 12 | def bench_integrate_x1sin(): 13 | integrate(x**1*sin(x), x) 14 | 15 | 16 | def bench_integrate_x2sin(): 17 | integrate(x**2*sin(x), x) 18 | 19 | 20 | def bench_integrate_x3sin(): 21 | integrate(x**3*sin(x), x) 22 | -------------------------------------------------------------------------------- /sympy/matrices/expressions/tests/test_funcmatrix.py: -------------------------------------------------------------------------------- 1 | from sympy import (symbols, FunctionMatrix, MatrixExpr, Lambda, Matrix) 2 | 3 | 4 | def test_funcmatrix(): 5 | i, j = symbols('i,j') 6 | X = FunctionMatrix(3, 3, Lambda((i, j), i - j)) 7 | assert X[1, 1] == 0 8 | assert X[1, 2] == -1 9 | assert X.shape == (3, 3) 10 | assert X.rows == X.cols == 3 11 | assert Matrix(X) == Matrix(3, 3, lambda i, j: i - j) 12 | assert isinstance(X*X + X, MatrixExpr) 13 | -------------------------------------------------------------------------------- /doc/src/modules/combinatorics/partitions.rst: -------------------------------------------------------------------------------- 1 | .. _combinatorics-partitions: 2 | 3 | Partitions 4 | ========== 5 | 6 | .. module:: sympy.combinatorics.partitions 7 | 8 | .. autoclass:: Partition 9 | :members: 10 | 11 | .. autoclass:: IntegerPartition 12 | :members: 13 | 14 | .. autofunction:: random_integer_partition 15 | 16 | .. autofunction:: RGS_generalized 17 | 18 | .. autofunction:: RGS_enum 19 | 20 | .. autofunction:: RGS_unrank 21 | 22 | .. autofunction:: RGS_rank 23 | -------------------------------------------------------------------------------- /sympy/strategies/util.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from sympy import Basic 4 | 5 | new = Basic.__new__ 6 | 7 | def assoc(d, k, v): 8 | d = d.copy() 9 | d[k] = v 10 | return d 11 | 12 | basic_fns = {'op': type, 13 | 'new': Basic.__new__, 14 | 'leaf': lambda x: not isinstance(x, Basic) or x.is_Atom, 15 | 'children': lambda x: x.args} 16 | 17 | expr_fns = assoc(basic_fns, 'new', lambda op, *args: op(*args)) 18 | -------------------------------------------------------------------------------- /doc/src/modules/combinatorics/index.rst: -------------------------------------------------------------------------------- 1 | .. _combinatiorics-docs: 2 | 3 | ==================== 4 | Combinatorics Module 5 | ==================== 6 | 7 | Contents 8 | ======== 9 | 10 | .. toctree:: 11 | :maxdepth: 2 12 | 13 | partitions.rst 14 | permutations.rst 15 | perm_groups.rst 16 | polyhedron.rst 17 | prufer.rst 18 | subsets.rst 19 | graycode.rst 20 | named_groups.rst 21 | util.rst 22 | group_constructs.rst 23 | testutil.rst 24 | tensor_can.rst 25 | -------------------------------------------------------------------------------- /bin/get_sympy.py: -------------------------------------------------------------------------------- 1 | """Functions to get the correct sympy version to run tests.""" 2 | 3 | from __future__ import print_function 4 | 5 | import os 6 | import sys 7 | 8 | 9 | def path_hack(): 10 | """ 11 | Hack sys.path to import correct (local) sympy. 12 | """ 13 | this_file = os.path.abspath(__file__) 14 | sympy_dir = os.path.join(os.path.dirname(this_file), "..") 15 | sympy_dir = os.path.normpath(sympy_dir) 16 | sys.path.insert(0, sympy_dir) 17 | return sympy_dir 18 | -------------------------------------------------------------------------------- /sympy/stats/tests/test_mix.py: -------------------------------------------------------------------------------- 1 | from sympy.stats import Poisson, Beta 2 | from sympy.stats.rv import pspace, ProductPSpace, density 3 | from sympy.stats.drv_types import PoissonDistribution 4 | from sympy import Symbol, Eq 5 | 6 | def test_density(): 7 | x = Symbol('x') 8 | l = Symbol('l', positive=True) 9 | rate = Beta(l, 2, 3) 10 | X = Poisson(x, rate) 11 | assert isinstance(pspace(X), ProductPSpace) 12 | assert density(X, Eq(rate, rate.symbol)) == PoissonDistribution(l) 13 | -------------------------------------------------------------------------------- /sympy/plotting/pygletplot/plot_object.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | class PlotObject(object): 4 | """ 5 | Base class for objects which can be displayed in 6 | a Plot. 7 | """ 8 | visible = True 9 | 10 | def _draw(self): 11 | if self.visible: 12 | self.draw() 13 | 14 | def draw(self): 15 | """ 16 | OpenGL rendering code for the plot object. 17 | Override in base class. 18 | """ 19 | pass 20 | -------------------------------------------------------------------------------- /examples/intermediate/print_gtk.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """print_gtk example 4 | 5 | Demonstrates printing with gtkmathview using mathml 6 | """ 7 | 8 | from sympy import Integral, Limit, print_gtk, sin, Symbol 9 | 10 | 11 | def main(): 12 | x = Symbol('x') 13 | 14 | example_limit = Limit(sin(x)/x, x, 0) 15 | print_gtk(example_limit) 16 | 17 | example_integral = Integral(x, (x, 0, 1)) 18 | print_gtk(example_integral) 19 | 20 | if __name__ == "__main__": 21 | main() 22 | -------------------------------------------------------------------------------- /examples/beginner/expansion.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Expansion Example 4 | 5 | Demonstrates how to expand expressions. 6 | """ 7 | 8 | import sympy 9 | from sympy import pprint 10 | 11 | 12 | def main(): 13 | a = sympy.Symbol('a') 14 | b = sympy.Symbol('b') 15 | e = (a + b)**5 16 | 17 | print("\nExpression:") 18 | pprint(e) 19 | print('\nExpansion of the above expression:') 20 | pprint(e.expand()) 21 | print() 22 | 23 | if __name__ == "__main__": 24 | main() 25 | -------------------------------------------------------------------------------- /sympy/diffgeom/__init__.py: -------------------------------------------------------------------------------- 1 | from .diffgeom import ( 2 | BaseCovarDerivativeOp, BaseScalarField, BaseVectorField, Commutator, 3 | contravariant_order, CoordSystem, CovarDerivativeOp, covariant_order, 4 | Differential, intcurve_diffequ, intcurve_series, LieDerivative, 5 | Manifold, metric_to_Christoffel_1st, metric_to_Christoffel_2nd, 6 | metric_to_Ricci_components, metric_to_Riemann_components, Patch, 7 | Point, TensorProduct, twoform_to_matrix, vectors_in_basis, 8 | WedgeProduct, 9 | ) 10 | -------------------------------------------------------------------------------- /sympy/matrices/expressions/tests/test_fourier.py: -------------------------------------------------------------------------------- 1 | from sympy import S, I, ask, Q, Abs, simplify, exp, sqrt 2 | from sympy.matrices.expressions.fourier import DFT, IDFT 3 | from sympy.matrices import det, Matrix, Identity 4 | from sympy.abc import n, i, j 5 | def test_dft(): 6 | assert DFT(4).shape == (4, 4) 7 | assert ask(Q.unitary(DFT(4))) 8 | assert Abs(simplify(det(Matrix(DFT(4))))) == 1 9 | assert DFT(n)*IDFT(n) == Identity(n) 10 | assert DFT(n)[i, j] == exp(-2*S.Pi*I/n)**(i*j) / sqrt(n) 11 | -------------------------------------------------------------------------------- /sympy/polys/domains/simpledomain.py: -------------------------------------------------------------------------------- 1 | """Implementation of :class:`SimpleDomain` class. """ 2 | 3 | from __future__ import print_function, division 4 | 5 | from sympy.polys.domains.domain import Domain 6 | from sympy.utilities import public 7 | 8 | @public 9 | class SimpleDomain(Domain): 10 | """Base class for simple domains, e.g. ZZ, QQ. """ 11 | 12 | is_Simple = True 13 | 14 | def inject(self, *gens): 15 | """Inject generators into this domain. """ 16 | return self.poly_ring(*gens) 17 | -------------------------------------------------------------------------------- /doc/src/modules/solvers/inequalities.rst: -------------------------------------------------------------------------------- 1 | .. _inequality-docs: 2 | 3 | Inequality Solvers 4 | ================== 5 | 6 | .. module:: sympy.solvers.inequalities 7 | 8 | .. autofunction:: solve_rational_inequalities 9 | 10 | .. autofunction:: solve_poly_inequality 11 | 12 | .. autofunction:: reduce_rational_inequalities 13 | 14 | .. autofunction:: reduce_abs_inequality 15 | 16 | .. autofunction:: reduce_abs_inequalities 17 | 18 | .. autofunction:: reduce_inequalities 19 | 20 | .. autofunction:: solve_univariate_inequality 21 | -------------------------------------------------------------------------------- /sympy/utilities/magic.py: -------------------------------------------------------------------------------- 1 | """Functions that involve magic. """ 2 | 3 | from __future__ import print_function, division 4 | 5 | def pollute(names, objects): 6 | """Pollute the global namespace with symbols -> objects mapping. """ 7 | from inspect import currentframe 8 | frame = currentframe().f_back.f_back 9 | 10 | try: 11 | for name, obj in zip(names, objects): 12 | frame.f_globals[name] = obj 13 | finally: 14 | del frame # break cyclic dependencies as stated in inspect docs 15 | -------------------------------------------------------------------------------- /doc/src/modules/combinatorics/util.rst: -------------------------------------------------------------------------------- 1 | .. _combinatorics-util: 2 | 3 | Utilities 4 | ============ 5 | 6 | .. module:: sympy.combinatorics.util 7 | 8 | .. autofunction:: _base_ordering 9 | 10 | .. autofunction:: _check_cycles_alt_sym 11 | 12 | .. autofunction:: _distribute_gens_by_base 13 | 14 | .. autofunction:: _handle_precomputed_bsgs 15 | 16 | .. autofunction:: _orbits_transversals_from_bsgs 17 | 18 | .. autofunction:: _remove_gens 19 | 20 | .. autofunction:: _strip 21 | 22 | .. autofunction:: _strong_gens_from_distr 23 | -------------------------------------------------------------------------------- /doc/src/modules/functions/index.rst: -------------------------------------------------------------------------------- 1 | .. _functions: 2 | 3 | Functions Module 4 | **************** 5 | 6 | .. module:: sympy.functions 7 | 8 | All functions support the methods documented below, inherited from 9 | :py:class:`sympy.core.function.Function`. 10 | 11 | .. autoclass:: sympy.core.function.Function 12 | :noindex: 13 | :members: 14 | 15 | .. _functions-contents: 16 | 17 | Contents 18 | ======== 19 | 20 | .. toctree:: 21 | :maxdepth: 2 22 | 23 | elementary.rst 24 | combinatorial.rst 25 | special.rst 26 | -------------------------------------------------------------------------------- /doc/src/modules/galgebra/precedence.rst: -------------------------------------------------------------------------------- 1 | Precedence for Geometric Algebra 2 | ================================ 3 | 4 | .. module:: sympy.galgebra.precedence 5 | 6 | Function Reference 7 | ------------------ 8 | 9 | .. autofunction:: add_paren 10 | 11 | .. autofunction:: contains_interval 12 | 13 | .. autofunction:: define_precedence 14 | 15 | .. autofunction:: GAeval 16 | 17 | .. autofunction:: parse_line 18 | 19 | .. autofunction:: parse_paren 20 | 21 | .. autofunction:: sub_paren 22 | 23 | .. autofunction:: unparse_paren 24 | -------------------------------------------------------------------------------- /doc/src/modules/physics/vector/api/printing.rst: -------------------------------------------------------------------------------- 1 | ===================== 2 | Printing (Docstrings) 3 | ===================== 4 | 5 | init_printing 6 | ============= 7 | 8 | .. autofunction:: sympy.physics.vector.printing.init_printing 9 | 10 | vprint 11 | ====== 12 | 13 | .. autofunction:: sympy.physics.vector.printing.vprint 14 | 15 | 16 | vpprint 17 | ======= 18 | 19 | .. autofunction:: sympy.physics.vector.printing.vpprint 20 | 21 | 22 | vlatex 23 | ====== 24 | 25 | .. autofunction:: sympy.physics.vector.printing.vlatex 26 | -------------------------------------------------------------------------------- /examples/beginner/plotting_nice_plot.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Plotting example 4 | 5 | Demonstrates simple plotting. 6 | """ 7 | 8 | from sympy import Symbol, cos, sin, log, tan 9 | from sympy.plotting import PygletPlot 10 | from sympy.abc import x, y 11 | 12 | 13 | def main(): 14 | fun1 = cos(x)*sin(y) 15 | fun2 = sin(x)*sin(y) 16 | fun3 = cos(y) + log(tan(y/2)) + 0.2*x 17 | 18 | PygletPlot(fun1, fun2, fun3, [x, -0.00, 12.4, 40], [y, 0.1, 2, 40]) 19 | 20 | if __name__ == "__main__": 21 | main() 22 | -------------------------------------------------------------------------------- /sympy/galgebra/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | A module for geometric algebra 3 | 4 | """ 5 | from sympy.galgebra.ga import MV, Com, DD, Format, Nga, ReciprocalFrame, ScalarFunction, \ 6 | cross, dual, ga_print_off, ga_print_on, inv, proj, refl, rot, rotor 7 | 8 | from sympy.galgebra.debug import oprint, ostr 9 | 10 | from sympy.galgebra.precedence import define_precedence, GAeval 11 | 12 | from sympy.galgebra.printing import enhance_print, Get_Program, Print_Function, latex, xdvi 13 | 14 | from sympy.galgebra.manifold import Manifold 15 | -------------------------------------------------------------------------------- /sympy/polys/domains/characteristiczero.py: -------------------------------------------------------------------------------- 1 | """Implementaton of :class:`CharacteristicZero` class. """ 2 | 3 | from __future__ import print_function, division 4 | 5 | from sympy.polys.domains.domain import Domain 6 | from sympy.utilities import public 7 | 8 | @public 9 | class CharacteristicZero(Domain): 10 | """Domain that has infinite number of elements. """ 11 | 12 | has_CharacteristicZero = True 13 | 14 | def characteristic(self): 15 | """Return the characteristic of this domain. """ 16 | return 0 17 | -------------------------------------------------------------------------------- /sympy/printing/tests/test_gtk.py: -------------------------------------------------------------------------------- 1 | from sympy import print_gtk, sin 2 | from sympy.utilities.pytest import XFAIL, raises 3 | 4 | # this test fails if python-lxml isn't installed. We don't want to depend on 5 | # anything with SymPy 6 | 7 | 8 | @XFAIL 9 | def test_1(): 10 | from sympy.abc import x 11 | print_gtk(x**2, start_viewer=False) 12 | print_gtk(x**2 + sin(x)/4, start_viewer=False) 13 | 14 | 15 | def test_settings(): 16 | from sympy.abc import x 17 | raises(TypeError, lambda: print_gtk(x, method="garbage")) 18 | -------------------------------------------------------------------------------- /sympy/polys/domains/domainelement.py: -------------------------------------------------------------------------------- 1 | """Trait for implementing domain elements. """ 2 | 3 | from __future__ import print_function, division 4 | 5 | from sympy.utilities import public 6 | 7 | @public 8 | class DomainElement(object): 9 | """ 10 | Represents an element of a domain. 11 | 12 | Mix in this trait into a class which instances should be recognized as 13 | elements of a domain. Method ``parent()`` gives that domain. 14 | 15 | """ 16 | 17 | def parent(self): 18 | raise NotImplementedError("abstract method") 19 | -------------------------------------------------------------------------------- /examples/beginner/series.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Series example 4 | 5 | Demonstrates series. 6 | """ 7 | 8 | from sympy import Symbol, cos, sin, pprint 9 | 10 | 11 | def main(): 12 | x = Symbol('x') 13 | 14 | e = 1/cos(x) 15 | print() 16 | print("Series for sec(x):") 17 | print() 18 | pprint(e.series(x, 0, 10)) 19 | print("\n") 20 | 21 | e = 1/sin(x) 22 | print("Series for csc(x):") 23 | print() 24 | pprint(e.series(x, 0, 4)) 25 | print() 26 | 27 | if __name__ == "__main__": 28 | main() 29 | -------------------------------------------------------------------------------- /sympy/combinatorics/tests/test_group_constructs.py: -------------------------------------------------------------------------------- 1 | from sympy.combinatorics.group_constructs import DirectProduct 2 | from sympy.combinatorics.named_groups import CyclicGroup, DihedralGroup 3 | 4 | 5 | def test_direct_product_n(): 6 | C = CyclicGroup(4) 7 | D = DihedralGroup(4) 8 | G = DirectProduct(C, C, C) 9 | assert G.order() == 64 10 | assert G.degree == 12 11 | assert len(G.orbits()) == 3 12 | assert G.is_abelian is True 13 | H = DirectProduct(D, C) 14 | assert H.order() == 32 15 | assert H.is_abelian is False 16 | -------------------------------------------------------------------------------- /sympy/mpmath/tests/test_pickle.py: -------------------------------------------------------------------------------- 1 | import os 2 | import tempfile 3 | import pickle 4 | 5 | from sympy.mpmath import * 6 | 7 | def pickler(obj): 8 | fn = tempfile.mktemp() 9 | 10 | f = open(fn, 'wb') 11 | pickle.dump(obj, f) 12 | f.close() 13 | 14 | f = open(fn, 'rb') 15 | obj2 = pickle.load(f) 16 | f.close() 17 | os.remove(fn) 18 | 19 | return obj2 20 | 21 | def test_pickle(): 22 | 23 | obj = mpf('0.5') 24 | assert obj == pickler(obj) 25 | 26 | obj = mpc('0.5','0.2') 27 | assert obj == pickler(obj) 28 | -------------------------------------------------------------------------------- /doc/src/modules/combinatorics/graycode.rst: -------------------------------------------------------------------------------- 1 | .. _combinatorics-graycode: 2 | 3 | Gray Code 4 | ========= 5 | 6 | .. module:: sympy.combinatorics.graycode 7 | 8 | .. autoclass:: GrayCode 9 | :members: 10 | 11 | .. automethod:: sympy.combinatorics.graycode.random_bitstring 12 | 13 | .. automethod:: sympy.combinatorics.graycode.gray_to_bin 14 | 15 | .. automethod:: sympy.combinatorics.graycode.bin_to_gray 16 | 17 | .. automethod:: sympy.combinatorics.graycode.get_subset_from_bitstring 18 | 19 | .. automethod:: sympy.combinatorics.graycode.graycode_subsets 20 | -------------------------------------------------------------------------------- /doc/src/modules/physics/index.rst: -------------------------------------------------------------------------------- 1 | .. _physics-docs: 2 | 3 | ============== 4 | Physics Module 5 | ============== 6 | 7 | .. automodule:: sympy.physics 8 | 9 | Contents 10 | ======== 11 | 12 | .. toctree:: 13 | :maxdepth: 3 14 | 15 | hydrogen.rst 16 | matrices.rst 17 | paulialgebra.rst 18 | qho_1d.rst 19 | sho.rst 20 | secondquant.rst 21 | wigner.rst 22 | units.rst 23 | hep/index.rst 24 | vector/index.rst 25 | mechanics/index.rst 26 | quantum/index.rst 27 | optics/index.rst 28 | unitsystems/index.rst 29 | -------------------------------------------------------------------------------- /examples/beginner/precision.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Precision Example 4 | 5 | Demonstrates SymPy's arbitrary integer precision abilities 6 | """ 7 | 8 | import sympy 9 | from sympy import Mul, Pow, S 10 | 11 | 12 | def main(): 13 | x = Pow(2, 50, evaluate=False) 14 | y = Pow(10, -50, evaluate=False) 15 | # A large, unevaluated expression 16 | m = Mul(x, y, evaluate=False) 17 | # Evaluating the expression 18 | e = S(2)**50/S(10)**50 19 | print("%s == %s" % (m, e)) 20 | 21 | if __name__ == "__main__": 22 | main() 23 | -------------------------------------------------------------------------------- /sympy/core/tests/test_cache.py: -------------------------------------------------------------------------------- 1 | from sympy.core.cache import cacheit 2 | 3 | 4 | def test_cacheit_doc(): 5 | @cacheit 6 | def testfn(): 7 | "test docstring" 8 | pass 9 | 10 | assert testfn.__doc__ == "test docstring" 11 | assert testfn.__name__ == "testfn" 12 | 13 | def test_cacheit_unhashable(): 14 | @cacheit 15 | def testit(x): 16 | return x 17 | 18 | assert testit(1) == 1 19 | assert testit(1) == 1 20 | a = {} 21 | assert testit(a) == {} 22 | a[1] = 2 23 | assert testit(a) == {1: 2} 24 | -------------------------------------------------------------------------------- /sympy/matrices/expressions/tests/test_matadd.py: -------------------------------------------------------------------------------- 1 | from sympy.matrices.expressions import MatrixSymbol, MatAdd 2 | from sympy.matrices import eye, ImmutableMatrix 3 | from sympy import Basic 4 | 5 | X = MatrixSymbol('X', 2, 2) 6 | Y = MatrixSymbol('Y', 2, 2) 7 | 8 | def test_sort_key(): 9 | assert MatAdd(Y, X).doit().args == (X, Y) 10 | 11 | 12 | def test_matadd_sympify(): 13 | assert isinstance(MatAdd(eye(1), eye(1)).args[0], Basic) 14 | 15 | 16 | def test_matadd_of_matrices(): 17 | assert MatAdd(eye(2), 4*eye(2), eye(2)).doit() == ImmutableMatrix(6*eye(2)) 18 | -------------------------------------------------------------------------------- /doc/src/modules/physics/vector/api/classes.rst: -------------------------------------------------------------------------------- 1 | ================= 2 | Essential Classes 3 | ================= 4 | 5 | CoordinateSym 6 | ============= 7 | 8 | .. autoclass:: sympy.physics.vector.frame.CoordinateSym 9 | 10 | 11 | ReferenceFrame 12 | ============== 13 | 14 | .. autoclass:: sympy.physics.vector.frame.ReferenceFrame 15 | :members: 16 | 17 | 18 | Vector 19 | ====== 20 | 21 | .. autoclass:: sympy.physics.vector.vector.Vector 22 | :members: 23 | 24 | 25 | Dyadic 26 | ====== 27 | 28 | .. autoclass:: sympy.physics.vector.dyadic.Dyadic 29 | :members: 30 | -------------------------------------------------------------------------------- /doc/src/modules/utilities/index.rst: -------------------------------------------------------------------------------- 1 | .. _utilities-docs: 2 | 3 | ========= 4 | Utilities 5 | ========= 6 | 7 | .. TODO: add compilef.rst and benchmarking.rst when they're fixed 8 | 9 | .. automodule:: sympy.utilities 10 | 11 | Contents: 12 | 13 | .. toctree:: 14 | :maxdepth: 2 15 | 16 | autowrap.rst 17 | codegen.rst 18 | decorator.rst 19 | enumerative.rst 20 | iterables.rst 21 | lambdify.rst 22 | memoization.rst 23 | misc.rst 24 | pkgdata.rst 25 | pytest.rst 26 | randtest.rst 27 | runtests.rst 28 | source.rst 29 | timeutils.rst 30 | -------------------------------------------------------------------------------- /examples/beginner/functions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Functions example 4 | 5 | Demonstrates sympy defined functions. 6 | """ 7 | 8 | import sympy 9 | from sympy import pprint 10 | 11 | 12 | def main(): 13 | a = sympy.Symbol('a') 14 | b = sympy.Symbol('b') 15 | e = sympy.log((a + b)**5) 16 | print() 17 | pprint(e) 18 | print('\n') 19 | 20 | e = sympy.exp(e) 21 | pprint(e) 22 | print('\n') 23 | 24 | e = sympy.log(sympy.exp((a + b)**5)) 25 | pprint(e) 26 | print 27 | 28 | if __name__ == "__main__": 29 | main() 30 | -------------------------------------------------------------------------------- /sympy/strategies/branch/tools.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from .core import (exhaust, multiplex, debug, notempty, condition, chain, 4 | onaction, sfilter, yieldify, do_one, identity) 5 | from .traverse import top_down 6 | 7 | def canon(*rules): 8 | """ Strategy for canonicalization 9 | 10 | Apply each branching rule in a top-down fashion through the tree. 11 | Multiplex through all branching rule traversals 12 | Keep doing this until there is no change. 13 | """ 14 | return exhaust(multiplex(*map(top_down, rules))) 15 | -------------------------------------------------------------------------------- /sympy/simplify/hyperexpand_doc.py: -------------------------------------------------------------------------------- 1 | """ This module cooks up a docstring when imported. Its only purpose is to 2 | be displayed in the sphinx documentation. """ 3 | 4 | from __future__ import print_function, division 5 | 6 | from sympy.simplify.hyperexpand import FormulaCollection 7 | from sympy import latex, Eq, hyper 8 | 9 | c = FormulaCollection() 10 | 11 | doc = "" 12 | 13 | for f in c.formulae: 14 | obj = Eq(hyper(f.func.ap, f.func.bq, f.z), 15 | f.closed_form.rewrite('nonrepsmall')) 16 | doc += ".. math::\n %s\n" % latex(obj) 17 | 18 | __doc__ = doc 19 | -------------------------------------------------------------------------------- /sympy/calculus/tests/test_singularities.py: -------------------------------------------------------------------------------- 1 | from sympy import Symbol, exp, log 2 | from sympy.calculus.singularities import singularities 3 | 4 | from sympy.utilities.pytest import raises, XFAIL 5 | 6 | 7 | def test_singularities(): 8 | x = Symbol('x', real=True) 9 | 10 | assert singularities(x**2, x) == () 11 | assert singularities(x/(x**2 + 3*x + 2), x) == (-2, -1) 12 | 13 | 14 | @XFAIL 15 | def test_singularities_non_rational(): 16 | x = Symbol('x', real=True) 17 | 18 | assert singularities(exp(1/x), x) == (0) 19 | assert singularities(log((x - 2)**2), x) == (2) 20 | -------------------------------------------------------------------------------- /bin/py.bench: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # hook in-tree SymPy into Python path, if possible 4 | # TODO this should be shared with isympy 5 | from __future__ import print_function 6 | 7 | import os 8 | import sys 9 | 10 | isympy_dir = os.path.dirname(__file__) # bin/isympy 11 | sympy_top = os.path.split(isympy_dir)[0] # ../ 12 | sympy_dir = os.path.join(sympy_top, 'sympy') # ../sympy/ 13 | 14 | if os.path.isdir(sympy_dir): 15 | sys.path.insert(0, sympy_top) 16 | 17 | 18 | from sympy.utilities import benchmarking 19 | 20 | if __name__ == '__main__': 21 | benchmarking.main() 22 | -------------------------------------------------------------------------------- /doc/src/modules/physics/mechanics/examples.rst: -------------------------------------------------------------------------------- 1 | ============================== 2 | Examples for Physics/Mechanics 3 | ============================== 4 | 5 | Here are some examples that illustrate how one typically uses this module. We 6 | have ordered the examples roughly according to increasing difficulty. If you 7 | have used this module to do something others might find useful or interesting, 8 | consider adding it here! 9 | 10 | 11 | .. toctree:: 12 | :maxdepth: 1 13 | 14 | examples/rollingdisc_example.rst 15 | examples/bicycle_example.rst 16 | examples/lin_pend_nonmin_example.rst 17 | -------------------------------------------------------------------------------- /sympy/physics/gaussopt.py: -------------------------------------------------------------------------------- 1 | from sympy.physics.optics.gaussopt import RayTransferMatrix, FreeSpace,\ 2 | FlatRefraction, CurvedRefraction, FlatMirror, CurvedMirror, ThinLens,\ 3 | GeometricRay, BeamParameter, waist2rayleigh, rayleigh2waist, geometric_conj_ab,\ 4 | geometric_conj_af, geometric_conj_bf, gaussian_conj, conjugate_gauss_beams 5 | 6 | from sympy.utilities.exceptions import SymPyDeprecationWarning 7 | 8 | 9 | SymPyDeprecationWarning(feature="Module sympy.physics.gaussopt", 10 | useinstead="sympy.physics.optics.gaussopt", 11 | deprecated_since_version="0.7.6", issue=7659).warn() 12 | -------------------------------------------------------------------------------- /sympy/polys/domains/gmpyfinitefield.py: -------------------------------------------------------------------------------- 1 | """Implementation of :class:`GMPYFiniteField` class. """ 2 | 3 | from __future__ import print_function, division 4 | 5 | from sympy.polys.domains.finitefield import FiniteField 6 | from sympy.polys.domains.gmpyintegerring import GMPYIntegerRing 7 | 8 | from sympy.utilities import public 9 | 10 | @public 11 | class GMPYFiniteField(FiniteField): 12 | """Finite field based on GMPY integers. """ 13 | 14 | alias = 'FF_gmpy' 15 | 16 | def __init__(self, mod, symmetric=True): 17 | return super(GMPYFiniteField, self).__init__(mod, GMPYIntegerRing(), symmetric) 18 | -------------------------------------------------------------------------------- /sympy/printing/gtk.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from sympy.printing.mathml import mathml 4 | import tempfile 5 | import os 6 | 7 | 8 | def print_gtk(x, start_viewer=True): 9 | """Print to Gtkmathview, a gtk widget capable of rendering MathML. 10 | 11 | Needs libgtkmathview-bin""" 12 | from sympy.utilities.mathml import c2p 13 | 14 | tmp = tempfile.mktemp() # create a temp file to store the result 15 | with open(tmp, 'wb') as file: 16 | file.write( c2p(mathml(x), simple=True) ) 17 | 18 | if start_viewer: 19 | os.system("mathmlviewer " + tmp) 20 | -------------------------------------------------------------------------------- /sympy/core/benchmarks/bench_expand.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from sympy.core import symbols, I 4 | 5 | x, y, z = symbols('x,y,z') 6 | 7 | p = 3*x**2*y*z**7 + 7*x*y*z**2 + 4*x + x*y**4 8 | e = (x + y + z + 1)**32 9 | 10 | 11 | def timeit_expand_nothing_todo(): 12 | p.expand() 13 | 14 | 15 | def bench_expand_32(): 16 | """(x+y+z+1)**32 -> expand""" 17 | e.expand() 18 | 19 | 20 | def timeit_expand_complex_number_1(): 21 | ((2 + 3*I)**1000).expand(complex=True) 22 | 23 | 24 | def timeit_expand_complex_number_2(): 25 | ((2 + 3*I/4)**1000).expand(complex=True) 26 | -------------------------------------------------------------------------------- /sympy/liealgebras/tests/test_type_G.py: -------------------------------------------------------------------------------- 1 | from sympy.liealgebras.cartan_type import CartanType 2 | from sympy.matrices import Matrix 3 | 4 | def test_type_G(): 5 | c = CartanType("G2") 6 | m = Matrix(2, 2, [2, -1, -3, 2]) 7 | assert c.cartan_matrix() == m 8 | assert c.simple_root(2) == [1, -2, 1] 9 | assert c.basis() == 14 10 | assert c.roots() == 12 11 | assert c.dimension() == 3 12 | diag = "0≡<≡0\n1 2" 13 | assert diag == c.dynkin_diagram() 14 | assert c.positive_roots() == {1: [0, 1, -1], 2: [1, -2, 1], 3: [1, -1, 0], 15 | 4: [1, 0, 1], 5: [1, 1, -2], 6: [2, -1, -1]} 16 | -------------------------------------------------------------------------------- /sympy/mpmath/tests/test_str.py: -------------------------------------------------------------------------------- 1 | from sympy.mpmath import nstr, matrix, inf 2 | 3 | def test_nstr(): 4 | m = matrix([[0.75, 0.190940654, -0.0299195971], 5 | [0.190940654, 0.65625, 0.205663228], 6 | [-0.0299195971, 0.205663228, 0.64453125e-20]]) 7 | assert nstr(m, 4, min_fixed=-inf) == \ 8 | '''[ 0.75 0.1909 -0.02992] 9 | [ 0.1909 0.6563 0.2057] 10 | [-0.02992 0.2057 0.000000000000000000006445]''' 11 | assert nstr(m, 4) == \ 12 | '''[ 0.75 0.1909 -0.02992] 13 | [ 0.1909 0.6563 0.2057] 14 | [-0.02992 0.2057 6.445e-21]''' 15 | -------------------------------------------------------------------------------- /doc/src/modules/physics/mechanics/api/printing.rst: -------------------------------------------------------------------------------- 1 | ===================== 2 | Printing (Docstrings) 3 | ===================== 4 | 5 | 6 | mechanics_printing 7 | ================== 8 | 9 | This function is the same as :mod:`physics.vector`'s 10 | :mod:`time_derivative_printing`. 11 | 12 | 13 | mprint 14 | ====== 15 | 16 | This function is the same as :mod:`physics.vector`'s 17 | :mod:`vprint`. 18 | 19 | 20 | mpprint 21 | ======= 22 | 23 | This function is the same as :mod:`physics.vector`'s 24 | :mod:`vpprint`. 25 | 26 | 27 | mlatex 28 | ====== 29 | 30 | This function is the same as :mod:`physics.vector`'s 31 | :mod:`vlatex`. 32 | -------------------------------------------------------------------------------- /sympy/polys/domains/pythonfinitefield.py: -------------------------------------------------------------------------------- 1 | """Implementation of :class:`PythonFiniteField` class. """ 2 | 3 | from __future__ import print_function, division 4 | 5 | from sympy.polys.domains.finitefield import FiniteField 6 | from sympy.polys.domains.pythonintegerring import PythonIntegerRing 7 | 8 | from sympy.utilities import public 9 | 10 | @public 11 | class PythonFiniteField(FiniteField): 12 | """Finite field based on Python's integers. """ 13 | 14 | alias = 'FF_python' 15 | 16 | def __init__(self, mod, symmetric=True): 17 | return super(PythonFiniteField, self).__init__(mod, PythonIntegerRing(), symmetric) 18 | -------------------------------------------------------------------------------- /sympy/sets/tests/test_contains.py: -------------------------------------------------------------------------------- 1 | from sympy import Symbol, Contains, S, Interval, FiniteSet 2 | 3 | 4 | def test_contains_basic(): 5 | assert Contains(2, S.Integers) is S.true 6 | assert Contains(-2, S.Naturals) is S.false 7 | 8 | i = Symbol('i', integer=True) 9 | assert Contains(i, S.Naturals) == Contains(i, S.Naturals, evaluate=False) 10 | 11 | 12 | def test_issue_6194(): 13 | x = Symbol('x') 14 | assert Contains(x, Interval(0, 1)) == (x >= 0) & (x <= 1) 15 | assert Contains(x, FiniteSet(0)) != S.false 16 | assert Contains(x, Interval(1, 1)) != S.false 17 | assert Contains(x, S.Integers) != S.false 18 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/calculus/approximation.rst: -------------------------------------------------------------------------------- 1 | Function approximation 2 | ---------------------- 3 | 4 | Taylor series (``taylor``) 5 | .......................... 6 | 7 | .. autofunction:: mpmath.taylor 8 | 9 | Pade approximation (``pade``) 10 | ............................. 11 | 12 | .. autofunction:: mpmath.pade 13 | 14 | Chebyshev approximation (``chebyfit``) 15 | ...................................... 16 | 17 | .. autofunction:: mpmath.chebyfit 18 | 19 | Fourier series (``fourier``, ``fourierval``) 20 | ............................................ 21 | 22 | .. autofunction:: mpmath.fourier 23 | .. autofunction:: mpmath.fourierval 24 | -------------------------------------------------------------------------------- /sympy/external/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Unified place for determining if external dependencies are installed or not. 3 | 4 | You should import all external modules using the import_module() function. 5 | 6 | For example 7 | 8 | >>> from sympy.external import import_module 9 | >>> numpy = import_module('numpy') 10 | 11 | If the resulting library is not installed, or if the installed version 12 | is less than a given minimum version, the function will return None. 13 | Otherwise, it will return the library. See the docstring of 14 | import_module() for more information. 15 | 16 | """ 17 | 18 | from sympy.external.importtools import import_module 19 | -------------------------------------------------------------------------------- /sympy/functions/special/tests/test_beta_functions.py: -------------------------------------------------------------------------------- 1 | from sympy import (Symbol, gamma, expand_func, beta, digamma, diff) 2 | 3 | 4 | def test_beta(): 5 | x, y = Symbol('x'), Symbol('y') 6 | 7 | assert isinstance(beta(x, y), beta) 8 | 9 | assert expand_func(beta(x, y)) == gamma(x)*gamma(y)/gamma(x + y) 10 | assert expand_func(beta(x, y) - beta(y, x)) == 0 # Symmetric 11 | assert expand_func(beta(x, y)) == expand_func(beta(x, y + 1) + beta(x + 1, y)).simplify() 12 | 13 | assert diff(beta(x, y), x) == beta(x, y)*(digamma(x) - digamma(x + y)) 14 | assert diff(beta(x, y), y) == beta(x, y)*(digamma(y) - digamma(x + y)) 15 | -------------------------------------------------------------------------------- /sympy/utilities/__init__.py: -------------------------------------------------------------------------------- 1 | """This module contains some general purpose utilities that are used across 2 | SymPy. 3 | """ 4 | from .iterables import (flatten, group, take, subsets, 5 | variations, numbered_symbols, cartes, capture, dict_merge, 6 | postorder_traversal, interactive_traversal, 7 | prefixes, postfixes, sift, topological_sort, unflatten, 8 | has_dups, has_variety, reshape, default_sort_key, ordered) 9 | 10 | from .lambdify import lambdify 11 | from .source import source 12 | 13 | from .decorator import threaded, xthreaded, public 14 | 15 | from .runtests import test, doctest 16 | 17 | from .timeutils import timed 18 | -------------------------------------------------------------------------------- /doc/src/modules/galgebra/printing.rst: -------------------------------------------------------------------------------- 1 | Printing for Geometric Algebra 2 | ============================== 3 | 4 | .. module:: sympy.galgebra.printing 5 | 6 | Class Reference 7 | --------------- 8 | 9 | .. autoclass:: enhance_print 10 | :members: 11 | 12 | .. autoclass:: GA_Printer 13 | :members: 14 | 15 | .. autoclass:: GA_LatexPrinter 16 | :members: 17 | 18 | Function Reference 19 | ------------------ 20 | 21 | .. autofunction:: find_executable 22 | 23 | .. autofunction:: Get_Program 24 | 25 | .. autofunction:: latex 26 | 27 | .. autofunction:: Print_Function 28 | 29 | .. autofunction:: print_latex 30 | 31 | .. autofunction:: xdvi 32 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/spherharm40.py: -------------------------------------------------------------------------------- 1 | # Real part of spherical harmonic Y_(4,0)(theta,phi) 2 | def Y(l,m): 3 | def g(theta,phi): 4 | R = abs(fp.re(fp.spherharm(l,m,theta,phi))) 5 | x = R*fp.cos(phi)*fp.sin(theta) 6 | y = R*fp.sin(phi)*fp.sin(theta) 7 | z = R*fp.cos(theta) 8 | return [x,y,z] 9 | return g 10 | 11 | fp.splot(Y(4,0), [0,fp.pi], [0,2*fp.pi], points=300) 12 | # fp.splot(Y(4,0), [0,fp.pi], [0,2*fp.pi], points=300) 13 | # fp.splot(Y(4,1), [0,fp.pi], [0,2*fp.pi], points=300) 14 | # fp.splot(Y(4,2), [0,fp.pi], [0,2*fp.pi], points=300) 15 | # fp.splot(Y(4,3), [0,fp.pi], [0,2*fp.pi], points=300) -------------------------------------------------------------------------------- /doc/src/modules/mpmath/calculus/differentiation.rst: -------------------------------------------------------------------------------- 1 | Differentiation 2 | --------------- 3 | 4 | Numerical derivatives (``diff``, ``diffs``) 5 | ........................................... 6 | 7 | .. autofunction:: mpmath.diff 8 | .. autofunction:: mpmath.diffs 9 | 10 | Composition of derivatives (``diffs_prod``, ``diffs_exp``) 11 | .......................................................... 12 | 13 | .. autofunction:: mpmath.diffs_prod 14 | .. autofunction:: mpmath.diffs_exp 15 | 16 | Fractional derivatives / differintegration (``differint``) 17 | ............................................................ 18 | 19 | .. autofunction:: mpmath.differint 20 | -------------------------------------------------------------------------------- /examples/galgebra/matrix_latex.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from __future__ import print_function 4 | 5 | from sympy import symbols, Matrix 6 | from sympy.galgebra import xdvi 7 | from sympy.galgebra import Format 8 | 9 | 10 | def main(): 11 | Format() 12 | a = Matrix(2, 2, (1, 2, 3, 4)) 13 | b = Matrix(2, 1, (5, 6)) 14 | c = a*b 15 | print(a, b, '=', c) 16 | 17 | x, y = symbols('x, y') 18 | 19 | d = Matrix(1, 2, (x**3, y**3)) 20 | e = Matrix(2, 2, (x**2, 2*x*y, 2*x*y, y**2)) 21 | f = d*e 22 | 23 | print('%', d, e, '=', f) 24 | 25 | xdvi() 26 | return 27 | 28 | if __name__ == "__main__": 29 | main() 30 | -------------------------------------------------------------------------------- /sympy/matrices/expressions/diagonal.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from sympy.matrices.expressions import MatrixExpr 4 | from sympy.core import S 5 | 6 | class DiagonalMatrix(MatrixExpr): 7 | arg = property(lambda self: self.args[0]) 8 | shape = property(lambda self: (self.arg.shape[0], self.arg.shape[0])) 9 | 10 | def _entry(self, i, j): 11 | return S.Zero if i != j else self.arg[i, 0] 12 | 13 | class DiagonalOf(MatrixExpr): 14 | arg = property(lambda self: self.args[0]) 15 | shape = property(lambda self: (self.arg.shape[0], S.One)) 16 | 17 | def _entry(self, i, j): 18 | return self.arg[i, i] 19 | -------------------------------------------------------------------------------- /doc/src/modules/combinatorics/permutations.rst: -------------------------------------------------------------------------------- 1 | .. _combinatorics-permutations: 2 | 3 | Permutations 4 | ============ 5 | 6 | .. module:: sympy.combinatorics.permutations 7 | 8 | .. autoclass:: Permutation 9 | :members: 10 | 11 | .. autoclass:: Cycle 12 | :members: 13 | 14 | .. _combinatorics-generators: 15 | 16 | Generators 17 | ---------- 18 | 19 | .. module:: sympy.combinatorics.generators 20 | 21 | .. automethod:: sympy.combinatorics.generators.symmetric 22 | 23 | .. automethod:: sympy.combinatorics.generators.cyclic 24 | 25 | .. automethod:: sympy.combinatorics.generators.alternating 26 | 27 | .. automethod:: sympy.combinatorics.generators.dihedral 28 | -------------------------------------------------------------------------------- /sympy/matrices/expressions/tests/test_diagonal.py: -------------------------------------------------------------------------------- 1 | from sympy.matrices.expressions import MatrixSymbol 2 | from sympy.matrices.expressions.diagonal import DiagonalMatrix, DiagonalOf 3 | from sympy import Symbol, ask, Q 4 | 5 | n = Symbol('n') 6 | x = MatrixSymbol('x', n, 1) 7 | X = MatrixSymbol('X', n, n) 8 | D = DiagonalMatrix(x) 9 | d = DiagonalOf(X) 10 | 11 | def test_DiagonalMatrix(): 12 | assert D.shape == (n, n) 13 | assert D[1, 2] == 0 14 | assert D[1, 1] == x[1, 0] 15 | 16 | def test_DiagonalMatrix_Assumptions(): 17 | assert ask(Q.diagonal(D)) 18 | 19 | def test_DiagonalOf(): 20 | assert d.shape == (n, 1) 21 | assert d[2, 0] == X[2, 2] 22 | -------------------------------------------------------------------------------- /bin/diagnose_imports: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """ 3 | Diagnostics for import statements. 4 | Run bin/diagnose_imports.py --help for details. 5 | """ 6 | 7 | from os.path import abspath, dirname, join, normpath 8 | import subprocess 9 | import sys 10 | 11 | this_file = abspath(__file__) 12 | diagnose_imports_filename = join( 13 | dirname(this_file), 14 | '..', 'sympy', 'utilities', 'tests', 'diagnose_imports.py') 15 | diagnose_imports_filename = normpath(diagnose_imports_filename) 16 | 17 | process = subprocess.Popen( 18 | [ 19 | sys.executable, 20 | diagnose_imports_filename, 21 | ] + sys.argv[1:], 22 | bufsize = -1) 23 | process.wait() 24 | -------------------------------------------------------------------------------- /doc/src/modules/physics/mechanics/examples/rollingdisc_example.rst: -------------------------------------------------------------------------------- 1 | ============== 2 | A rolling disc 3 | ============== 4 | 5 | The disc is assumed to be infinitely thin, in contact with the ground at only 1 6 | point, and it is rolling without slip on the ground. See the image below. 7 | 8 | .. image:: rollingdisc.* 9 | :height: 350 10 | :width: 350 11 | :align: center 12 | 13 | We model the rolling disc in three different ways, to show more of the 14 | functionality of this module. 15 | 16 | .. toctree:: 17 | :maxdepth: 1 18 | 19 | rollingdisc_example_kane.rst 20 | rollingdisc_example_kane_constraints.rst 21 | rollingdisc_example_lagrange.rst 22 | -------------------------------------------------------------------------------- /examples/galgebra/exp_check.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from __future__ import print_function 4 | 5 | from sympy import symbols, sin, cos 6 | from sympy.galgebra import MV 7 | from sympy.galgebra import enhance_print 8 | 9 | def main(): 10 | enhance_print() 11 | (ex, ey, ez) = MV.setup('e*x|y|z', metric='[1,1,1]') 12 | 13 | u = MV('u', 'vector') 14 | v = MV('v', 'vector') 15 | w = MV('w', 'vector') 16 | print(u) 17 | print(v) 18 | 19 | uv = u ^ v 20 | print(uv) 21 | print(uv.is_blade()) 22 | 23 | exp_uv = uv.exp() 24 | exp_uv.Fmt(2, 'exp(uv)') 25 | 26 | return 27 | 28 | if __name__ == "__main__": 29 | main() 30 | -------------------------------------------------------------------------------- /sympy/interactive/tests/test_interactive.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | from sympy.interactive.session import int_to_Integer 4 | 5 | 6 | def test_int_to_Integer(): 7 | assert int_to_Integer("1 + 2.2 + 0x3 + 40") == \ 8 | 'Integer (1 )+2.2 +Integer (0x3 )+Integer (40 )' 9 | if sys.version_info[0] == 2: 10 | assert int_to_Integer("1l") == 'Integer (1l )' 11 | assert int_to_Integer("0b101") == 'Integer (0b101 )' 12 | assert int_to_Integer("ab1 + 1 + '1 + 2'") == "ab1 +Integer (1 )+'1 + 2'" 13 | assert int_to_Integer("(2 + \n3)") == '(Integer (2 )+\nInteger (3 ))' 14 | assert int_to_Integer("2 + 2.0 + 2j + 2e-10") == 'Integer (2 )+2.0 +2j +2e-10 ' 15 | -------------------------------------------------------------------------------- /sympy/core/tests/test_evaluate.py: -------------------------------------------------------------------------------- 1 | from sympy.abc import x, y 2 | from sympy.core.evaluate import evaluate 3 | from sympy.core import Mul, Add 4 | 5 | def test_add(): 6 | with evaluate(False): 7 | expr = x + x 8 | assert isinstance(expr, Add) 9 | assert expr.args == (x, x) 10 | 11 | with evaluate(True): 12 | assert (x + x).args == (2, x) 13 | 14 | assert (x + x).args == (x, x) 15 | 16 | assert isinstance(x + x, Mul) 17 | 18 | 19 | 20 | def test_nested(): 21 | with evaluate(False): 22 | expr = (x + x) + (y + y) 23 | assert expr.args == ((x + x), (y + y)) 24 | assert expr.args[0].args == (x, x) 25 | -------------------------------------------------------------------------------- /sympy/matrices/tests/test_densetools.py: -------------------------------------------------------------------------------- 1 | from sympy.matrices.densetools import trace, transpose, conjugate 2 | from sympy.matrices.densetools import eye 3 | from sympy import ZZ, QQ 4 | 5 | def test_trace(): 6 | a = [[ZZ(3), ZZ(7), ZZ(4)], [ZZ(2), ZZ(4), ZZ(5)], [ZZ(6), ZZ(2), ZZ(3)]] 7 | b = eye(2, ZZ) 8 | 9 | assert trace(a, ZZ) == ZZ(10) 10 | assert trace(b, ZZ) == ZZ(2) 11 | 12 | 13 | def test_transpose(): 14 | a = [[ZZ(3), ZZ(7), ZZ(4)], [ZZ(2), ZZ(4), ZZ(5)], [ZZ(6), ZZ(2), ZZ(3)]] 15 | b = eye(4, ZZ) 16 | 17 | assert transpose(a, ZZ) == ([[ZZ(3), ZZ(2), ZZ(6)], [ZZ(7), ZZ(4), ZZ(2)], [ZZ(4), ZZ(5), ZZ(3)]]) 18 | assert transpose(b, ZZ) == b 19 | -------------------------------------------------------------------------------- /sympy/printing/__init__.py: -------------------------------------------------------------------------------- 1 | """Printing subsystem""" 2 | 3 | from .pretty import pager_print, pretty, pretty_print, pprint, \ 4 | pprint_use_unicode, pprint_try_use_unicode 5 | from .latex import latex, print_latex 6 | from .mathml import mathml, print_mathml 7 | from .python import python, print_python 8 | from .ccode import ccode, print_ccode 9 | from .fcode import fcode, print_fcode 10 | from .jscode import jscode, print_jscode 11 | from .mathematica import mathematica_code 12 | from .gtk import print_gtk 13 | from .preview import preview 14 | from .repr import srepr 15 | from .tree import print_tree 16 | from .str import StrPrinter, sstr, sstrrepr 17 | from .tableform import TableForm 18 | -------------------------------------------------------------------------------- /sympy/core/benchmarks/bench_arit.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from sympy.core import Add, Mul, symbols 4 | 5 | x, y, z = symbols('x,y,z') 6 | 7 | 8 | def timeit_neg(): 9 | -x 10 | 11 | 12 | def timeit_Add_x1(): 13 | x + 1 14 | 15 | 16 | def timeit_Add_1x(): 17 | 1 + x 18 | 19 | 20 | def timeit_Add_x05(): 21 | x + 0.5 22 | 23 | 24 | def timeit_Add_xy(): 25 | x + y 26 | 27 | 28 | def timeit_Add_xyz(): 29 | Add(*[x, y, z]) 30 | 31 | 32 | def timeit_Mul_xy(): 33 | x*y 34 | 35 | 36 | def timeit_Mul_xyz(): 37 | Mul(*[x, y, z]) 38 | 39 | 40 | def timeit_Div_xy(): 41 | x/y 42 | 43 | 44 | def timeit_Div_2y(): 45 | 2/y 46 | -------------------------------------------------------------------------------- /doc/src/modules/utilities/enumerative.rst: -------------------------------------------------------------------------------- 1 | =========== 2 | Enumerative 3 | =========== 4 | .. module:: sympy.utilities.enumerative 5 | 6 | This module includes functions and classes for enumerating and 7 | counting multiset partitions. 8 | 9 | .. autofunction:: multiset_partitions_taocp 10 | .. autofunction:: factoring_visitor 11 | .. autofunction:: list_visitor 12 | 13 | The approach of the function ``multiset_partitions_taocp`` is extended 14 | and generalized by the class ``MultisetPartitionTraverser``. 15 | 16 | .. autoclass:: MultisetPartitionTraverser 17 | :members: count_partitions, 18 | enum_all, 19 | enum_large, 20 | enum_range, 21 | enum_small 22 | -------------------------------------------------------------------------------- /sympy/liealgebras/cartan_matrix.py: -------------------------------------------------------------------------------- 1 | from .cartan_type import CartanType 2 | 3 | def CartanMatrix(ct): 4 | """ 5 | This is a method that allows a user to access 6 | the Cartan matrix of a specific Lie algebra. 7 | Example 8 | ======= 9 | >>> from sympy.liealgebras.cartan_matrix import CartanMatrix 10 | >>> CartanMatrix("A2") 11 | Matrix([ 12 | [ 2, -1], 13 | [-1, 2]]) 14 | 15 | >>> CartanMatrix(['C', 3]) 16 | Matrix([ 17 | [ 2, -1, 0], 18 | [-1, 2, -1], 19 | [ 0, -2, 2]]) 20 | 21 | This method works by returning the Cartan matrix 22 | which corresponds to Cartan type t. 23 | """ 24 | 25 | return CartanType(ct).cartan_matrix() 26 | -------------------------------------------------------------------------------- /examples/beginner/substitution.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Substitution example 4 | 5 | Demonstrates substitution. 6 | """ 7 | 8 | import sympy 9 | from sympy import pprint 10 | 11 | 12 | def main(): 13 | x = sympy.Symbol('x') 14 | y = sympy.Symbol('y') 15 | 16 | e = 1/sympy.cos(x) 17 | print() 18 | pprint(e) 19 | print('\n') 20 | pprint(e.subs(sympy.cos(x), y)) 21 | print('\n') 22 | pprint(e.subs(sympy.cos(x), y).subs(y, x**2)) 23 | 24 | e = 1/sympy.log(x) 25 | e = e.subs(x, sympy.Float("2.71828")) 26 | print('\n') 27 | pprint(e) 28 | print('\n') 29 | pprint(e.evalf()) 30 | print() 31 | 32 | if __name__ == "__main__": 33 | main() 34 | -------------------------------------------------------------------------------- /sympy/liealgebras/dynkin_diagram.py: -------------------------------------------------------------------------------- 1 | from .cartan_type import CartanType 2 | 3 | 4 | 5 | def DynkinDiagram(t): 6 | """ 7 | Method for displaying the Dynkin diagram 8 | of a given Lie algebra. Works by generating 9 | the CartanType for the input, t, and then 10 | returning the Dynkin diagram method from the 11 | individual classes. 12 | 13 | Examples 14 | ===== 15 | 16 | >>> from sympy.liealgebras.dynkin_diagram import DynkinDiagram 17 | >>> print(DynkinDiagram("A3")) 18 | 0---0---0 19 | 1 2 3 20 | 21 | >>> print(DynkinDiagram("B4")) 22 | 0---0---0=>=0 23 | 1 2 3 4 24 | 25 | 26 | """ 27 | 28 | return CartanType(t).dynkin_diagram() 29 | -------------------------------------------------------------------------------- /sympy/logic/benchmarks/input/10.cnf: -------------------------------------------------------------------------------- 1 | c 2 | c SAT instance in DIMACS CNF input format. 3 | c 4 | p cnf 10 42 5 | -2 8 -9 0 6 | 7 2 10 0 7 | -6 1 -8 0 8 | 3 -6 7 0 9 | -9 3 4 0 10 | -10 -8 9 0 11 | -2 -6 -9 0 12 | 8 -10 7 0 13 | -5 -4 -6 0 14 | 7 -9 5 0 15 | -8 4 5 0 16 | 3 7 10 0 17 | -5 -6 -8 0 18 | -1 8 -6 0 19 | 1 -3 4 0 20 | 1 2 -5 0 21 | 4 -10 7 0 22 | -5 2 3 0 23 | 8 7 5 0 24 | 9 -3 4 0 25 | -3 1 -10 0 26 | 8 2 -4 0 27 | 2 -8 9 0 28 | 4 -7 2 0 29 | -2 -7 10 0 30 | -6 -10 -1 0 31 | -9 5 -8 0 32 | 8 10 1 0 33 | -7 -2 -10 0 34 | -10 -5 4 0 35 | -7 5 -4 0 36 | -3 -1 -8 0 37 | -1 5 7 0 38 | 2 -4 -3 0 39 | -2 3 8 0 40 | -2 -9 -5 0 41 | -8 5 2 0 42 | 6 -10 2 0 43 | -4 6 -9 0 44 | 9 10 -7 0 45 | -4 -10 7 0 46 | -10 4 7 0 47 | -------------------------------------------------------------------------------- /examples/intermediate/differential_equations.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Differential equations example 4 | 5 | Demonstrates solving 1st and 2nd degree linear ordinary differential 6 | equations. 7 | """ 8 | 9 | from sympy import dsolve, Eq, Function, sin, Symbol 10 | 11 | 12 | def main(): 13 | x = Symbol("x") 14 | f = Function("f") 15 | 16 | eq = Eq(f(x).diff(x), f(x)) 17 | print("Solution for ", eq, " : ", dsolve(eq, f(x))) 18 | 19 | eq = Eq(f(x).diff(x, 2), -f(x)) 20 | print("Solution for ", eq, " : ", dsolve(eq, f(x))) 21 | 22 | eq = Eq(x**2*f(x).diff(x), -3*x*f(x) + sin(x)/x) 23 | print("Solution for ", eq, " : ", dsolve(eq, f(x))) 24 | 25 | 26 | if __name__ == "__main__": 27 | main() 28 | -------------------------------------------------------------------------------- /sympy/crypto/__init__.py: -------------------------------------------------------------------------------- 1 | from sympy.crypto.crypto import (alphabet_of_cipher, cycle_list, 2 | encipher_shift, encipher_affine, encipher_substitution, 3 | encipher_vigenere, decipher_vigenere, 4 | bifid5_square, bifid6_square, bifid7_square, 5 | encipher_hill, decipher_hill, encipher_bifid5, encipher_bifid6, 6 | encipher_bifid7, decipher_bifid5, decipher_bifid6, encipher_kid_rsa, 7 | decipher_kid_rsa, kid_rsa_private_key, kid_rsa_public_key, 8 | decipher_rsa, rsa_private_key, rsa_public_key, encipher_rsa, 9 | lfsr_connection_polynomial, lfsr_autocorrelation, lfsr_sequence, 10 | encode_morse, decode_morse, elgamal_private_key, elgamal_public_key, 11 | decipher_elgamal, encipher_elgamal) 12 | -------------------------------------------------------------------------------- /sympy/liealgebras/tests/test_type_B.py: -------------------------------------------------------------------------------- 1 | from sympy.liealgebras.cartan_type import CartanType 2 | from sympy.matrices import Matrix 3 | 4 | def test_type_B(): 5 | c = CartanType("B3") 6 | m = Matrix(3, 3, [2, -1, 0, -1, 2, -2, 0, -1, 2]) 7 | assert m == c.cartan_matrix() 8 | assert c.dimension() == 3 9 | assert c.roots() == 18 10 | assert c.simple_root(3) == [0, 0, 1] 11 | assert c.basis() == 3 12 | assert c.lie_algebra() == "so(6)" 13 | diag = "0---0=>=0\n1 2 3" 14 | assert c.dynkin_diagram() == diag 15 | assert c.positive_roots() == {1: [1, -1, 0], 2: [1, 1, 0], 3: [1, 0, -1], 16 | 4: [1, 0, 1], 5: [0, 1, -1], 6: [0, 1, 1], 7: [1, 0, 0], 17 | 8: [0, 1, 0], 9: [0, 0, 1]} 18 | -------------------------------------------------------------------------------- /sympy/matrices/expressions/__init__.py: -------------------------------------------------------------------------------- 1 | """ A module which handles Matrix Expressions """ 2 | 3 | from .slice import MatrixSlice 4 | from .blockmatrix import BlockMatrix, BlockDiagMatrix, block_collapse, blockcut 5 | from .funcmatrix import FunctionMatrix 6 | from .inverse import Inverse 7 | from .matadd import MatAdd 8 | from .matexpr import (Identity, MatrixExpr, MatrixSymbol, ZeroMatrix, 9 | matrix_symbols) 10 | from .matmul import MatMul 11 | from .matpow import MatPow 12 | from .trace import Trace, trace 13 | from .determinant import Determinant, det 14 | from .transpose import Transpose 15 | from .adjoint import Adjoint 16 | from .hadamard import hadamard_product, HadamardProduct 17 | from .diagonal import DiagonalMatrix, DiagonalOf 18 | -------------------------------------------------------------------------------- /sympy/liealgebras/tests/test_type_A.py: -------------------------------------------------------------------------------- 1 | from sympy.liealgebras.cartan_type import CartanType 2 | from sympy.matrices import Matrix 3 | 4 | def test_type_A(): 5 | c = CartanType("A3") 6 | m = Matrix(3, 3, [2, -1, 0, -1, 2, -1, 0, -1, 2]) 7 | assert m == c.cartan_matrix() 8 | assert c.basis() == 8 9 | assert c.roots() == 12 10 | assert c.dimension() == 4 11 | assert c.simple_root(1) == [1, -1, 0, 0] 12 | assert c.highest_root() == [1, 0, 0, -1] 13 | assert c.lie_algebra() == "su(4)" 14 | diag = "0---0---0\n1 2 3" 15 | assert c.dynkin_diagram() == diag 16 | assert c.positive_roots() == {1: [1, -1, 0, 0], 2: [1, 0, -1, 0], 17 | 3: [1, 0, 0, -1], 4: [0, 1, -1, 0], 5: [0, 1, 0, -1], 6: [0, 0, 1, -1]} 18 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/calculus/integration.rst: -------------------------------------------------------------------------------- 1 | Numerical integration (quadrature) 2 | ---------------------------------- 3 | 4 | Standard quadrature (``quad``) 5 | .............................. 6 | 7 | .. autofunction:: mpmath.quad 8 | 9 | Oscillatory quadrature (``quadosc``) 10 | .................................... 11 | 12 | .. autofunction:: mpmath.quadosc 13 | 14 | Quadrature rules 15 | ................ 16 | 17 | .. autoclass:: mpmath.calculus.quadrature.QuadratureRule 18 | :members: 19 | 20 | Tanh-sinh rule 21 | ~~~~~~~~~~~~~~ 22 | 23 | .. autoclass:: mpmath.calculus.quadrature.TanhSinh 24 | :members: 25 | 26 | 27 | Gauss-Legendre rule 28 | ~~~~~~~~~~~~~~~~~~~ 29 | 30 | .. autoclass:: mpmath.calculus.quadrature.GaussLegendre 31 | :members: 32 | -------------------------------------------------------------------------------- /examples/galgebra/simple_check.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from __future__ import print_function 4 | 5 | from sympy import symbols, sin, cos, simplify 6 | from sympy.galgebra.ga import MV 7 | from sympy.galgebra.printing import enhance_print 8 | 9 | def main(): 10 | enhance_print() 11 | 12 | (ex, ey, ez) = MV.setup('e*x|y|z', metric='[1,1,1]') 13 | 14 | u = MV('u', 'vector') 15 | v = MV('v', 'vector') 16 | w = MV('w', 'vector') 17 | print(u) 18 | print(v) 19 | print(w) 20 | 21 | uv = u ^ v 22 | print(uv) 23 | print(uv.is_blade()) 24 | uvw = u ^ v ^ w 25 | print(uvw) 26 | print(uvw.is_blade()) 27 | 28 | print(simplify((uv*uv).scalar())) 29 | return 30 | 31 | if __name__ == "__main__": 32 | main() 33 | -------------------------------------------------------------------------------- /doc/src/modules/galgebra/ncutil.rst: -------------------------------------------------------------------------------- 1 | Noncommutative utilities for Geometric Algebra 2 | ============================================== 3 | 4 | .. module:: sympy.galgebra.ncutil 5 | 6 | Function Reference 7 | ------------------ 8 | 9 | .. autofunction:: bilinear_function 10 | 11 | .. autofunction:: bilinear_product 12 | 13 | .. autofunction:: coef_function 14 | 15 | .. autofunction:: linear_derivation 16 | 17 | .. autofunction:: linear_expand 18 | 19 | .. autofunction:: linear_function 20 | 21 | .. autofunction:: linear_projection 22 | 23 | .. autofunction:: multilinear_derivation 24 | 25 | .. autofunction:: multilinear_function 26 | 27 | .. autofunction:: multilinear_product 28 | 29 | .. autofunction:: non_scalar_projection 30 | 31 | .. autofunction:: product_derivation 32 | -------------------------------------------------------------------------------- /doc/src/modules/physics/vector/api/functions.rst: -------------------------------------------------------------------------------- 1 | ================================ 2 | Essential Functions (Docstrings) 3 | ================================ 4 | 5 | dynamicsymbols 6 | -------------- 7 | 8 | .. autofunction:: sympy.physics.vector.dynamicsymbols 9 | 10 | 11 | dot 12 | --- 13 | 14 | .. autofunction:: sympy.physics.vector.functions.dot 15 | 16 | 17 | cross 18 | ----- 19 | 20 | .. autofunction:: sympy.physics.vector.functions.cross 21 | 22 | 23 | outer 24 | ----- 25 | 26 | .. autofunction:: sympy.physics.vector.functions.outer 27 | 28 | 29 | express 30 | ------- 31 | 32 | .. autofunction:: sympy.physics.vector.functions.express 33 | 34 | 35 | time_derivative 36 | --------------- 37 | 38 | .. autofunction:: sympy.physics.vector.functions.time_derivative 39 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/functions/qfunctions.rst: -------------------------------------------------------------------------------- 1 | q-functions 2 | ------------------------------------------- 3 | 4 | q-Pochhammer symbol 5 | .................................................. 6 | 7 | :func:`qp` 8 | ^^^^^^^^^^^^^^^^^ 9 | .. autofunction:: mpmath.qp(a, q=None, n=None, **kwargs) 10 | 11 | 12 | q-gamma and factorial 13 | .................................................. 14 | 15 | :func:`qgamma` 16 | ^^^^^^^^^^^^^^^^^ 17 | .. autofunction:: mpmath.qgamma(z, q, **kwargs) 18 | 19 | :func:`qfac` 20 | ^^^^^^^^^^^^^^^^^ 21 | .. autofunction:: mpmath.qfac(z, q, **kwargs) 22 | 23 | Hypergeometric q-series 24 | .................................................. 25 | 26 | :func:`qhyper` 27 | ^^^^^^^^^^^^^^^^^ 28 | .. autofunction:: mpmath.qhyper(a_s, b_s, q, z, **kwargs) 29 | 30 | -------------------------------------------------------------------------------- /sympy/physics/tests/test_sho.py: -------------------------------------------------------------------------------- 1 | from sympy.core import symbols, Rational, Function, diff 2 | from sympy.physics.sho import R_nl, E_nl 3 | from sympy import simplify 4 | 5 | 6 | def test_sho_R_nl(): 7 | omega, r = symbols('omega r') 8 | l = symbols('l', integer=True) 9 | u = Function('u') 10 | 11 | # check that it obeys the Schrodinger equation 12 | for n in range(5): 13 | schreq = ( -diff(u(r), r, 2)/2 + ((l*(l + 1))/(2*r**2) 14 | + omega**2*r**2/2 - E_nl(n, l, omega))*u(r) ) 15 | result = schreq.subs(u(r), r*R_nl(n, l, omega/2, r)) 16 | assert simplify(result.doit()) == 0 17 | 18 | 19 | def test_energy(): 20 | n, l, hw = symbols('n l hw') 21 | assert simplify(E_nl(n, l, hw) - (2*n + l + Rational(3, 2))*hw) == 0 22 | -------------------------------------------------------------------------------- /sympy/printing/defaults.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | class DefaultPrinting(object): 4 | """ 5 | The default implementation of printing for SymPy classes. 6 | 7 | This implements a hack that allows us to print elements of built-in 8 | Python containers in a readable way. Natively Python uses ``repr()`` 9 | even if ``str()`` was explicitly requested. Mix in this trait into 10 | a class to get proper default printing. 11 | 12 | """ 13 | 14 | # Note, we always use the default ordering (lex) in __str__ and __repr__, 15 | # regardless of the global setting. See issue 5487. 16 | def __str__(self): 17 | from sympy.printing.str import sstr 18 | return sstr(self, order=None) 19 | 20 | __repr__ = __str__ 21 | -------------------------------------------------------------------------------- /sympy/mpmath/tests/test_identify.py: -------------------------------------------------------------------------------- 1 | from sympy.mpmath import * 2 | 3 | def test_pslq(): 4 | mp.dps = 15 5 | assert pslq([3*pi+4*e/7, pi, e, log(2)]) == [7, -21, -4, 0] 6 | assert pslq([4.9999999999999991, 1]) == [1, -5] 7 | assert pslq([2,1]) == [1, -2] 8 | 9 | def test_identify(): 10 | mp.dps = 20 11 | assert identify(zeta(4), ['log(2)', 'pi**4']) == '((1/90)*pi**4)' 12 | mp.dps = 15 13 | assert identify(exp(5)) == 'exp(5)' 14 | assert identify(exp(4)) == 'exp(4)' 15 | assert identify(log(5)) == 'log(5)' 16 | assert identify(exp(3*pi), ['pi']) == 'exp((3*pi))' 17 | assert identify(3, full=True) == ['3', '3', '1/(1/3)', 'sqrt(9)', 18 | '1/sqrt((1/9))', '(sqrt(12)/2)**2', '1/(sqrt(12)/6)**2'] 19 | assert identify(pi+1, {'a':+pi}) == '(1 + 1*a)' 20 | -------------------------------------------------------------------------------- /sympy/matrices/expressions/fourier.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from sympy.matrices.expressions import MatrixExpr 4 | from sympy import S, I, sqrt, exp 5 | 6 | class DFT(MatrixExpr): 7 | """ Discrete Fourier Transform """ 8 | n = property(lambda self: self.args[0]) 9 | shape = property(lambda self: (self.n, self.n)) 10 | 11 | def _entry(self, i, j): 12 | w = exp(-2*S.Pi*I/self.n) 13 | return w**(i*j) / sqrt(self.n) 14 | 15 | def _eval_inverse(self): 16 | return IDFT(self.n) 17 | 18 | class IDFT(DFT): 19 | """ Inverse Discrete Fourier Transform """ 20 | def _entry(self, i, j): 21 | w = exp(-2*S.Pi*I/self.n) 22 | return w**(-i*j) / sqrt(self.n) 23 | 24 | def _eval_inverse(self): 25 | return DFT(self.n) 26 | -------------------------------------------------------------------------------- /sympy/simplify/__init__.py: -------------------------------------------------------------------------------- 1 | """The module helps converting SymPy expressions into shorter forms of them. 2 | 3 | for example: 4 | the expression E**(pi*I) will be converted into -1 5 | the expression (x+x)**2 will be converted into 4*x**2 6 | """ 7 | from .simplify import (collect, rcollect, radsimp, ratsimp, fraction, 8 | simplify, trigsimp, powsimp, combsimp, hypersimp, hypersimilar, nsimplify, 9 | logcombine, separatevars, numer, denom, powdenest, posify, polarify, 10 | unpolarify, collect_const, signsimp, besselsimp, ratsimpmodprime, 11 | exptrigsimp) 12 | 13 | from .fu import FU, fu 14 | 15 | from .sqrtdenest import sqrtdenest 16 | 17 | from .cse_main import cse 18 | 19 | from .traversaltools import use 20 | 21 | from .epathtools import epath, EPath 22 | 23 | from .hyperexpand import hyperexpand 24 | -------------------------------------------------------------------------------- /sympy/physics/quantum/tests/test_shor.py: -------------------------------------------------------------------------------- 1 | from sympy.utilities.pytest import XFAIL 2 | 3 | from sympy.physics.quantum.qapply import qapply 4 | from sympy.physics.quantum.qubit import Qubit 5 | from sympy.physics.quantum.shor import ( 6 | CMod, continued_fraction, getr 7 | ) 8 | 9 | 10 | @XFAIL 11 | def test_CMod(): 12 | assert qapply(CMod(4, 2, 2)*Qubit(0, 0, 1, 0, 0, 0, 0, 0)) == \ 13 | Qubit(0, 0, 1, 0, 0, 0, 0, 0) 14 | assert qapply(CMod(5, 5, 7)*Qubit(0, 0, 1, 0, 0, 0, 0, 0, 0, 0)) == \ 15 | Qubit(0, 0, 1, 0, 0, 0, 0, 0, 1, 0) 16 | assert qapply(CMod(3, 2, 3)*Qubit(0, 1, 0, 0, 0, 0)) == \ 17 | Qubit(0, 1, 0, 0, 0, 1) 18 | 19 | 20 | def test_continued_frac(): 21 | assert getr(513, 1024, 10) == 2 22 | assert getr(169, 1024, 11) == 6 23 | assert getr(314, 4096, 16) == 13 24 | -------------------------------------------------------------------------------- /doc/src/index.rst: -------------------------------------------------------------------------------- 1 | .. SymPy documentation master file, created by sphinx-quickstart.py on Sat Mar 22 19:34:32 2008. 2 | You can adapt this file completely to your liking, but it should at least 3 | contain the root `toctree` directive. 4 | 5 | Welcome to SymPy's documentation! 6 | ================================= 7 | 8 | `SymPy `_ is a Python library for symbolic mathematics. 9 | If you are new to SymPy, start with the :ref:`Tutorial `. 10 | 11 | This is the central page for all of SymPy's documentation. 12 | 13 | 14 | Contents: 15 | 16 | .. toctree:: 17 | :maxdepth: 2 18 | 19 | install.rst 20 | tutorial/index.rst 21 | gotchas.rst 22 | guide.rst 23 | modules/index.rst 24 | python-comparisons.rst 25 | wiki.rst 26 | outreach.rst 27 | aboutus.rst 28 | special_topics/index.rst 29 | -------------------------------------------------------------------------------- /examples/advanced/hydrogen.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | This example shows how to work with the Hydrogen radial wavefunctions. 5 | """ 6 | 7 | from sympy import Eq, Integral, oo, pprint, symbols 8 | from sympy.physics.hydrogen import R_nl 9 | 10 | 11 | def main(): 12 | print("Hydrogen radial wavefunctions:") 13 | a, r = symbols("a r") 14 | print("R_{21}:") 15 | pprint(R_nl(2, 1, a, r)) 16 | print("R_{60}:") 17 | pprint(R_nl(6, 0, a, r)) 18 | 19 | print("Normalization:") 20 | i = Integral(R_nl(1, 0, 1, r)**2 * r**2, (r, 0, oo)) 21 | pprint(Eq(i, i.doit())) 22 | i = Integral(R_nl(2, 0, 1, r)**2 * r**2, (r, 0, oo)) 23 | pprint(Eq(i, i.doit())) 24 | i = Integral(R_nl(2, 1, 1, r)**2 * r**2, (r, 0, oo)) 25 | pprint(Eq(i, i.doit())) 26 | 27 | if __name__ == '__main__': 28 | main() 29 | -------------------------------------------------------------------------------- /sympy/combinatorics/__init__.py: -------------------------------------------------------------------------------- 1 | from sympy.combinatorics.permutations import Permutation, Cycle 2 | from sympy.combinatorics.prufer import Prufer 3 | from sympy.combinatorics.generators import cyclic, alternating, symmetric, dihedral 4 | from sympy.combinatorics.subsets import Subset 5 | from sympy.combinatorics.partitions import (Partition, IntegerPartition, 6 | RGS_rank, RGS_unrank, RGS_enum) 7 | from sympy.combinatorics.polyhedron import (Polyhedron, tetrahedron, cube, 8 | octahedron, dodecahedron, icosahedron) 9 | from sympy.combinatorics.perm_groups import PermutationGroup 10 | from sympy.combinatorics.group_constructs import DirectProduct 11 | from sympy.combinatorics.graycode import GrayCode 12 | from sympy.combinatorics.named_groups import (SymmetricGroup, DihedralGroup, 13 | CyclicGroup, AlternatingGroup, AbelianGroup, RubikGroup) 14 | -------------------------------------------------------------------------------- /sympy/matrices/expressions/tests/test_factorizations.py: -------------------------------------------------------------------------------- 1 | from sympy.matrices.expressions.factorizations import lu, LofCholesky, qr, svd 2 | from sympy import Symbol, MatrixSymbol, ask, Q 3 | 4 | n = Symbol('n') 5 | X = MatrixSymbol('X', n, n) 6 | 7 | def test_LU(): 8 | L, U = lu(X) 9 | assert L.shape == U.shape == X.shape 10 | assert ask(Q.lower_triangular(L)) 11 | assert ask(Q.upper_triangular(U)) 12 | 13 | def test_Cholesky(): 14 | L = LofCholesky(X) 15 | 16 | def test_QR(): 17 | Q_, R = qr(X) 18 | assert Q_.shape == R.shape == X.shape 19 | assert ask(Q.orthogonal(Q_)) 20 | assert ask(Q.upper_triangular(R)) 21 | 22 | def test_svd(): 23 | U, S, V = svd(X) 24 | assert U.shape == S.shape == V.shape == X.shape 25 | assert ask(Q.orthogonal(U)) 26 | assert ask(Q.orthogonal(V)) 27 | assert ask(Q.diagonal(S)) 28 | -------------------------------------------------------------------------------- /bin/ask_update.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ Update the ask_generated.py file 4 | 5 | This must be run each time known_facts is changed 6 | 7 | Should be run from sympy root directory 8 | 9 | $ python bin/ask_update.py 10 | """ 11 | 12 | # hook in-tree SymPy into Python path, if possible 13 | import os 14 | import sys 15 | 16 | isympy_path = os.path.abspath(__file__) 17 | isympy_dir = os.path.dirname(isympy_path) 18 | sympy_top = os.path.split(isympy_dir)[0] 19 | sympy_dir = os.path.join(sympy_top, 'sympy') 20 | 21 | if os.path.isdir(sympy_dir): 22 | sys.path.insert(0, sympy_top) 23 | 24 | from sympy.assumptions.ask import (compute_known_facts, known_facts, 25 | known_facts_keys) 26 | 27 | with open('sympy/assumptions/ask_generated.py', 'w') as f: 28 | code = compute_known_facts(known_facts, known_facts_keys) 29 | f.write(code) 30 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plotting.rst: -------------------------------------------------------------------------------- 1 | Plotting 2 | ======== 3 | 4 | If `matplotlib `_ is available, the functions ``plot`` and ``cplot`` in mpmath can be used to plot functions respectively as x-y graphs and in the complex plane. Also, ``splot`` can be used to produce 3D surface plots. 5 | 6 | Function curve plots 7 | ----------------------- 8 | 9 | .. image:: plot.png 10 | 11 | Output of ``plot([cos, sin], [-4, 4])`` 12 | 13 | .. autofunction:: mpmath.plot 14 | 15 | Complex function plots 16 | ------------------------- 17 | 18 | .. image:: cplot.png 19 | 20 | Output of ``fp.cplot(fp.gamma, points=100000)`` 21 | 22 | .. autofunction:: mpmath.cplot 23 | 24 | 3D surface plots 25 | ---------------- 26 | 27 | .. image:: splot.png 28 | 29 | Output of ``splot`` for the donut example. 30 | 31 | .. autofunction:: mpmath.splot 32 | 33 | -------------------------------------------------------------------------------- /doc/src/modules/tensor/tensor.rst: -------------------------------------------------------------------------------- 1 | .. _tensor-tensor: 2 | 3 | Tensor 4 | ====== 5 | 6 | .. module:: sympy.tensor.tensor 7 | 8 | .. autoclass:: _TensorManager 9 | :members: 10 | 11 | .. autoclass:: TensorIndexType 12 | :members: 13 | 14 | .. autoclass:: TensorIndex 15 | :members: 16 | 17 | .. autofunction:: tensor_indices 18 | 19 | .. autoclass:: TensorSymmetry 20 | :members: 21 | 22 | .. autofunction:: tensorsymmetry 23 | 24 | .. autoclass:: TensorType 25 | :members: 26 | 27 | .. autoclass:: TensorHead 28 | :members: 29 | 30 | .. autoclass:: TensExpr 31 | :members: 32 | 33 | .. autoclass:: TensAdd 34 | :members: 35 | 36 | .. autoclass:: TensMul 37 | :members: 38 | 39 | .. autofunction:: canon_bp 40 | 41 | .. autofunction:: tensor_mul 42 | 43 | .. autofunction:: riemann_cyclic_replace 44 | 45 | .. autofunction:: riemann_cyclic 46 | -------------------------------------------------------------------------------- /sympy/liealgebras/tests/test_type_D.py: -------------------------------------------------------------------------------- 1 | from sympy.liealgebras.cartan_type import CartanType 2 | from sympy.matrices import Matrix 3 | 4 | 5 | 6 | def test_type_D(): 7 | c = CartanType("D4") 8 | m = Matrix(4, 4, [2, -1, 0, 0, -1, 2, -1, -1, 0, -1, 2, 0, 0, -1, 0 , 2]) 9 | assert c.cartan_matrix() == m 10 | assert c.basis() == 6 11 | assert c.lie_algebra() == "so(8)" 12 | assert c.roots() == 24 13 | assert c.simple_root(3) == [0, 0, 1, -1] 14 | diag = " 3\n 0\n |\n |\n0---0---0\n1 2 4" 15 | assert diag == c.dynkin_diagram() 16 | assert c.positive_roots() == {1: [1, -1, 0, 0], 2: [1, 1, 0, 0], 17 | 3: [1, 0, -1, 0], 4: [1, 0, 1, 0], 5: [1, 0, 0, -1], 6: [1, 0, 0, 1], 18 | 7: [0, 1, -1, 0], 8: [0, 1, 1, 0], 9: [0, 1, 0, -1], 10: [0, 1, 0, 1], 19 | 11: [0, 0, 1, -1], 12: [0, 0, 1, 1]} 20 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/functions/index.rst: -------------------------------------------------------------------------------- 1 | Mathematical functions 2 | ====================== 3 | 4 | Mpmath implements the standard functions from Python's ``math`` and ``cmath`` modules, for both real and complex numbers and with arbitrary precision. Many other functions are also available in mpmath, including commonly-used variants of standard functions (such as the alternative trigonometric functions sec, csc, cot), but also a large number of "special functions" such as the gamma function, the Riemann zeta function, error functions, Bessel functions, etc. 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | constants.rst 10 | powers.rst 11 | trigonometric.rst 12 | hyperbolic.rst 13 | gamma.rst 14 | expintegrals.rst 15 | bessel.rst 16 | orthogonal.rst 17 | hypergeometric.rst 18 | elliptic.rst 19 | zeta.rst 20 | numtheory.rst 21 | qfunctions.rst 22 | -------------------------------------------------------------------------------- /examples/beginner/differentiation.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Differentiation example 4 | 5 | Demonstrates some differentiation operations. 6 | """ 7 | 8 | import sympy 9 | from sympy import pprint 10 | 11 | 12 | def main(): 13 | a = sympy.Symbol('a') 14 | b = sympy.Symbol('b') 15 | e = (a + 2*b)**5 16 | 17 | print("\nExpression : ") 18 | print() 19 | pprint(e) 20 | print("\n\nDifferentiating w.r.t. a:") 21 | print() 22 | pprint(e.diff(a)) 23 | print("\n\nDifferentiating w.r.t. b:") 24 | print() 25 | pprint(e.diff(b)) 26 | print("\n\nSecond derivative of the above result w.r.t. a:") 27 | print() 28 | pprint(e.diff(b).diff(a, 2)) 29 | print("\n\nExpanding the above result:") 30 | print() 31 | pprint(e.expand().diff(b).diff(a, 2)) 32 | print() 33 | 34 | if __name__ == "__main__": 35 | main() 36 | -------------------------------------------------------------------------------- /sympy/liealgebras/tests/test_type_E.py: -------------------------------------------------------------------------------- 1 | from sympy.liealgebras.cartan_type import CartanType 2 | from sympy.matrices import Matrix 3 | 4 | def test_type_E(): 5 | c = CartanType("E6") 6 | m = Matrix(6, 6, [2, 0, -1, 0, 0, 0, 0, 2, 0, -1, 0, 0, 7 | -1, 0, 2, -1, 0, 0, 0, -1, -1, 2, -1, 0, 0, 0, 0, 8 | -1, 2, -1, 0, 0, 0, 0, -1, 2]) 9 | assert c.cartan_matrix() == m 10 | assert c.dimension() == 8 11 | assert c.simple_root(6) == [0, 0, 0, -1, 1, 0, 0, 0] 12 | assert c.roots() == 72 13 | assert c.basis() == 78 14 | diag = " "*8 + "2\n" + " "*8 + "0\n" + " "*8 + "|\n" + " "*8 + "|\n" 15 | diag += "---".join("0" for i in range(1, 6))+"\n" 16 | diag += "1 " + " ".join(str(i) for i in range(3, 7)) 17 | assert c.dynkin_diagram() == diag 18 | posroots = c.positive_roots() 19 | assert posroots[8] == [1, 0, 0, 0, 1, 0, 0, 0] 20 | -------------------------------------------------------------------------------- /bin/test_import: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | Tests the speed of "import sympy" by measuring it many times in a row and 5 | averaging the values. 6 | 7 | Usage: 8 | 9 | $ bin/test_import 10 | """ 11 | 12 | from __future__ import print_function 13 | 14 | n_tests = 50 15 | 16 | from pexpect import run 17 | from numpy import mean, std 18 | from get_sympy import path_hack 19 | 20 | def test(): 21 | t = run("python bin/test_import.py", cwd=path_hack()) 22 | t = float(t) 23 | return t 24 | 25 | 26 | tests = [test() for x in range(n_tests + 1)] 27 | print("Note: the first run (warm up) was not included in the average + std dev") 28 | print("All runs (including warm up):") 29 | print(tests) 30 | # skip the first run (warm up): 31 | tests = tests[1:] 32 | print("Number of tests: %d" % (n_tests)) 33 | print('The speed of "import sympy" is: %f +- %f' % (mean(tests), std(tests))) 34 | -------------------------------------------------------------------------------- /sympy/categories/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Category Theory module. 3 | 4 | Provides some of the fundamental category-theory-related classes, 5 | including categories, morphisms, diagrams. Functors are not 6 | implemented yet. 7 | 8 | The general reference work this module tries to follow is 9 | 10 | [JoyOfCats] J. Adamek, H. Herrlich. G. E. Strecker: Abstract and 11 | Concrete Categories. The Joy of Cats. 12 | 13 | The latest version of this book should be available for free download 14 | from 15 | 16 | katmat.math.uni-bremen.de/acc/acc.pdf 17 | 18 | """ 19 | 20 | from .baseclasses import (Object, Morphism, IdentityMorphism, 21 | NamedMorphism, CompositeMorphism, Category, 22 | Diagram) 23 | 24 | from .diagram_drawing import (DiagramGrid, XypicDiagramDrawer, 25 | xypic_draw_diagram, preview_diagram) 26 | -------------------------------------------------------------------------------- /sympy/physics/unitsystems/tests/test_prefixes.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from sympy.physics.unitsystems.prefixes import PREFIXES, prefix_unit 4 | 5 | 6 | def test_prefix_operations(): 7 | m = PREFIXES['m'] 8 | k = PREFIXES['k'] 9 | M = PREFIXES['M'] 10 | 11 | assert m * k == 1 12 | assert k * k == M 13 | assert 1 / m == k 14 | assert k / m == M 15 | 16 | 17 | def test_prefix_unit(): 18 | from sympy.physics.unitsystems import Unit, Dimension 19 | 20 | length = Dimension(length=1) 21 | m = Unit(length, abbrev="m") 22 | 23 | pref = {"m": PREFIXES["m"], "c": PREFIXES["c"], "d": PREFIXES["d"]} 24 | 25 | res = [Unit(length, abbrev="m", prefix=PREFIXES["m"]), 26 | Unit(length, abbrev="m", prefix=PREFIXES["c"]), 27 | Unit(length, abbrev="m", prefix=PREFIXES["d"])] 28 | 29 | assert set(prefix_unit(m, pref)) == set(res) 30 | -------------------------------------------------------------------------------- /examples/intermediate/trees.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | Calculates the Sloane's A000055 integer sequence, i.e. the "Number of 5 | trees with n unlabeled nodes." 6 | 7 | You can also google for "The On-Line Encyclopedia of Integer Sequences" 8 | and paste in the sequence returned by this script: 9 | 10 | 1, 1, 1, 1, 2, 3, 6, 11, 23, 47, 106 11 | 12 | and it will shows you the A000055 13 | """ 14 | 15 | from sympy import Symbol, Poly 16 | 17 | 18 | def T(x): 19 | return x + x**2 + 2*x**3 + 4*x**4 + 9*x**5 + 20*x**6 + 48 * x**7 + \ 20 | 115*x**8 + 286*x**9 + 719*x**10 21 | 22 | 23 | def A(x): 24 | return 1 + T(x) - T(x)**2/2 + T(x**2)/2 25 | 26 | 27 | def main(): 28 | x = Symbol("x") 29 | s = Poly(A(x), x) 30 | num = list(reversed(s.coeffs()))[:11] 31 | 32 | print(s.as_expr()) 33 | print(num) 34 | 35 | if __name__ == "__main__": 36 | main() 37 | -------------------------------------------------------------------------------- /examples/beginner/print_pretty.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Pretty print example 4 | 5 | Demonstrates pretty printing. 6 | """ 7 | 8 | from sympy import Symbol, pprint, sin, cos, exp, sqrt 9 | 10 | 11 | def main(): 12 | x = Symbol("x") 13 | y = Symbol("y") 14 | 15 | pprint( x**x ) 16 | print('\n') # separate with two blank likes 17 | 18 | pprint(x**2 + y + x) 19 | print('\n') 20 | 21 | pprint(sin(x)**x) 22 | print('\n') 23 | 24 | pprint( sin(x)**cos(x) ) 25 | print('\n') 26 | 27 | pprint( sin(x)/(cos(x)**2 * x**x + (2*y)) ) 28 | print('\n') 29 | 30 | pprint( sin(x**2 + exp(x)) ) 31 | print('\n') 32 | 33 | pprint( sqrt(exp(x)) ) 34 | print('\n') 35 | 36 | pprint( sqrt(sqrt(exp(x))) ) 37 | print('\n') 38 | 39 | pprint( (1/cos(x)).series(x, 0, 10) ) 40 | print('\n') 41 | 42 | if __name__ == "__main__": 43 | main() 44 | -------------------------------------------------------------------------------- /sympy/parsing/tests/test_mathematica.py: -------------------------------------------------------------------------------- 1 | from sympy.parsing.mathematica import mathematica 2 | from sympy import sympify 3 | 4 | 5 | def test_mathematica(): 6 | d = {'Sin[x]^2': 'sin(x)**2', 7 | '2(x-1)': '2*(x-1)', 8 | '3y+8': '3*y+8', 9 | 'Arcsin[2x+9(4-x)^2]/x': 'asin(2*x+9*(4-x)**2)/x', 10 | 'x+y': 'x+y', 11 | '355/113': '355/113', 12 | '2.718281828': '2.718281828', 13 | 'Sin[12]': 'sin(12)', 14 | 'Exp[Log[4]]': 'exp(log(4))', 15 | '(x+1)(x+3)': '(x+1)*(x+3)', 16 | 'Cos[Arccos[3.6]]': 'cos(acos(3.6))', 17 | 'Cos[x]==Sin[y]': 'cos(x)==sin(y)', 18 | '2*Sin[x+y]': '2*sin(x+y)', 19 | 'Sin[x]+Cos[y]': 'sin(x)+cos(y)', 20 | 'Sin[Cos[x]]': 'sin(cos(x))', 21 | '2*Sqrt[x+y]': '2*sqrt(x+y)'} # Test case from the issue 4259 22 | for e in d: 23 | assert mathematica(e) == sympify(d[e]) 24 | -------------------------------------------------------------------------------- /sympy/polys/domains/compositedomain.py: -------------------------------------------------------------------------------- 1 | """Implementation of :class:`CompositeDomain` class. """ 2 | 3 | from __future__ import print_function, division 4 | 5 | from sympy.polys.domains.domain import Domain 6 | from sympy.polys.polyerrors import GeneratorsError 7 | 8 | from sympy.utilities import public 9 | from sympy.utilities.magic import pollute 10 | 11 | @public 12 | class CompositeDomain(Domain): 13 | """Base class for composite domains, e.g. ZZ[x], ZZ(X). """ 14 | 15 | is_Composite = True 16 | 17 | gens, ngens, symbols, domain = [None]*4 18 | 19 | def inject(self, *symbols): 20 | """Inject generators into this domain. """ 21 | if not (set(self.symbols) & set(symbols)): 22 | return self.__class__(self.domain, self.symbols + symbols, self.order) 23 | else: 24 | raise GeneratorsError("common generators in %s and %s" % (self.symbols, symbols)) 25 | -------------------------------------------------------------------------------- /sympy/strategies/tests/test_tools.py: -------------------------------------------------------------------------------- 1 | from sympy.strategies.tools import subs, typed 2 | from sympy.strategies.rl import rm_id 3 | from sympy import Basic 4 | 5 | def test_subs(): 6 | from sympy import symbols 7 | a,b,c,d,e,f = symbols('a,b,c,d,e,f') 8 | mapping = {a: d, d: a, Basic(e): Basic(f)} 9 | expr = Basic(a, Basic(b, c), Basic(d, Basic(e))) 10 | result = Basic(d, Basic(b, c), Basic(a, Basic(f))) 11 | assert subs(mapping)(expr) == result 12 | 13 | def test_subs_empty(): 14 | assert subs({})(Basic(1, 2)) == Basic(1, 2) 15 | 16 | def test_typed(): 17 | class A(Basic): 18 | pass 19 | class B(Basic): 20 | pass 21 | rmzeros = rm_id(lambda x: x == 0) 22 | rmones = rm_id(lambda x: x == 1) 23 | remove_something = typed({A: rmzeros, B: rmones}) 24 | 25 | assert remove_something(A(0, 1)) == A(1) 26 | assert remove_something(B(0, 1)) == B(0) 27 | -------------------------------------------------------------------------------- /doc/src/modules/mpmath/plots/buildplots.py: -------------------------------------------------------------------------------- 1 | import os.path 2 | import glob 3 | 4 | try: 5 | import psyco 6 | psyco.full() 7 | except ImportError: 8 | pass 9 | 10 | for f in glob.glob("*.py"): 11 | if "buildplots" in f or os.path.exists(f[:-3]+".png"): 12 | continue 13 | print "Processing", f 14 | code = open(f).readlines() 15 | code = ["from mpmath import *; mp.dps=5"] + code 16 | for i in range(len(code)): 17 | l = code[i].rstrip() 18 | if "cplot(" in l: 19 | l = l[:-1] + (", dpi=45, file='%s.png', verbose=True)" % f[:-3]) 20 | code[i] = l 21 | elif "splot(" in l: 22 | l = l[:-1] + (", dpi=45, file='%s.png')" % f[:-3]) 23 | code[i] = l 24 | elif "plot(" in l: 25 | l = l[:-1] + (", dpi=45, file='%s.png')" % f[:-3]) 26 | code[i] = l 27 | code = "\n".join(code) 28 | exec code 29 | -------------------------------------------------------------------------------- /doc/src/modules/polys/index.rst: -------------------------------------------------------------------------------- 1 | .. _polys-docs: 2 | 3 | =============================== 4 | Polynomials Manipulation Module 5 | =============================== 6 | 7 | Computations with polynomials are at the core of computer algebra and 8 | having a fast and robust polynomials manipulation module is a key for 9 | building a powerful symbolic manipulation system. SymPy has a dedicated 10 | module :mod:`sympy.polys` for computing in polynomial algebras over 11 | various coefficient domains. 12 | 13 | There is a vast number of methods implemented, ranging from simple tools 14 | like polynomial division, to advanced concepts including Gröbner bases 15 | and multivariate factorization over algebraic number domains. 16 | 17 | Contents 18 | ======== 19 | 20 | .. toctree:: 21 | :maxdepth: 3 22 | 23 | basics.rst 24 | wester.rst 25 | reference.rst 26 | agca.rst 27 | internals.rst 28 | literature.rst 29 | -------------------------------------------------------------------------------- /sympy/vector/__init__.py: -------------------------------------------------------------------------------- 1 | from sympy.vector.vector import (Vector, VectorAdd, VectorMul, 2 | BaseVector, VectorZero) 3 | from sympy.vector.dyadic import (Dyadic, DyadicAdd, DyadicMul, 4 | BaseDyadic, DyadicZero) 5 | from sympy.vector.scalar import BaseScalar 6 | from sympy.vector.deloperator import Del 7 | from sympy.vector.coordsysrect import CoordSysCartesian 8 | from sympy.vector.functions import (express, matrix_to_vector, 9 | curl, divergence, gradient, 10 | is_conservative, is_solenoidal, 11 | scalar_potential, 12 | scalar_potential_difference) 13 | from sympy.vector.point import Point 14 | from sympy.vector.orienters import (AxisOrienter, BodyOrienter, 15 | SpaceOrienter, QuaternionOrienter) 16 | -------------------------------------------------------------------------------- /sympy/strategies/branch/tests/test_tools.py: -------------------------------------------------------------------------------- 1 | from sympy.strategies.branch.tools import canon 2 | from sympy import Basic 3 | 4 | 5 | def posdec(x): 6 | if isinstance(x, int) and x > 0: 7 | yield x-1 8 | else: 9 | yield x 10 | 11 | def branch5(x): 12 | if isinstance(x, int): 13 | if 0 < x < 5: 14 | yield x-1 15 | elif 5 < x < 10: 16 | yield x+1 17 | elif x == 5: 18 | yield x+1 19 | yield x-1 20 | else: 21 | yield x 22 | 23 | def test_zero_ints(): 24 | expr = Basic(2, Basic(5, 3), 8) 25 | expected = set([Basic(0, Basic(0, 0), 0)]) 26 | 27 | brl = canon(posdec) 28 | assert set(brl(expr)) == expected 29 | 30 | def test_split5(): 31 | expr = Basic(2, Basic(5, 3), 8) 32 | expected = set([Basic(0, Basic(0, 0), 10), 33 | Basic(0, Basic(10, 0), 10)]) 34 | 35 | brl = canon(branch5) 36 | assert set(brl(expr)) == expected 37 | -------------------------------------------------------------------------------- /sympy/strategies/branch/traverse.py: -------------------------------------------------------------------------------- 1 | """ Branching Strategies to Traverse a Tree """ 2 | 3 | from __future__ import print_function, division 4 | 5 | from itertools import product 6 | 7 | from sympy.strategies.util import basic_fns 8 | from .core import chain, identity, do_one 9 | 10 | def top_down(brule, fns=basic_fns): 11 | """ Apply a rule down a tree running it on the top nodes first """ 12 | return chain(do_one(brule, identity), 13 | lambda expr: sall(top_down(brule, fns), fns)(expr)) 14 | 15 | def sall(brule, fns=basic_fns): 16 | """ Strategic all - apply rule to args """ 17 | op, new, children, leaf = map(fns.get, ('op', 'new', 'children', 'leaf')) 18 | def all_rl(expr): 19 | if leaf(expr): 20 | yield expr 21 | else: 22 | myop = op(expr) 23 | argss = product(*map(brule, children(expr))) 24 | for args in argss: 25 | yield new(myop, *args) 26 | return all_rl 27 | -------------------------------------------------------------------------------- /sympy/polys/benchmarks/bench_groebnertools.py: -------------------------------------------------------------------------------- 1 | """Benchmark of the Groebner bases algorithms. """ 2 | 3 | from __future__ import print_function, division 4 | 5 | from sympy.polys.rings import ring 6 | from sympy.polys.domains import QQ 7 | from sympy.polys.groebnertools import groebner 8 | 9 | R, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12 = ring("x1:13", QQ) 10 | 11 | V = R.gens 12 | E = [(x1, x2), (x2, x3), (x1, x4), (x1, x6), (x1, x12), (x2, x5), (x2, x7), (x3, x8), 13 | (x3, x10), (x4, x11), (x4, x9), (x5, x6), (x6, x7), (x7, x8), (x8, x9), (x9, x10), 14 | (x10, x11), (x11, x12), (x5, x12), (x5, x9), (x6, x10), (x7, x11), (x8, x12)] 15 | 16 | F3 = [ x**3 - 1 for x in V ] 17 | Fg = [ x**2 + x*y + y**2 for x, y in E ] 18 | 19 | F_1 = F3 + Fg 20 | F_2 = F3 + Fg + [x3**2 + x3*x4 + x4**2] 21 | 22 | def time_vertex_color_12_vertices_23_edges(): 23 | assert groebner(F_1, R) != [1] 24 | 25 | def time_vertex_color_12_vertices_24_edges(): 26 | assert groebner(F_2, R) == [1] 27 | -------------------------------------------------------------------------------- /doc/src/modules/physics/mechanics/reference.rst: -------------------------------------------------------------------------------- 1 | ================================ 2 | References for Physics/Mechanics 3 | ================================ 4 | 5 | .. [Blajer1994] Blajer, Wojciech, Werner Schiehlen, and Walter Schirm. 6 | "A projective criterion to the coordinate partitioning method 7 | for multibody dynamics." Archive of Applied Mechanics 64: 86-98. Print. 8 | .. [Kane1983] Kane, Thomas R., Peter W. Likins, and David A. Levinson. 9 | Spacecraft Dynamics. New York: McGraw-Hill Book, 1983. Print. 10 | .. [Kane1985] Kane, Thomas R., and David A. Levinson. Dynamics, Theory and 11 | Applications. New York: McGraw-Hill, 1985. Print. 12 | .. [Meijaard2007] Meijaard, J.P., Jim M. Papadopoulos, Andy Ruina, and A.L. 13 | Schwab. "Linearized Dynamics Equations for the Balance and Steer of a Bicycle: 14 | a Benchmark and Review." Proceedings of the Royal Society A: Mathematical, 15 | Physical and Engineering Sciences 463.2084 (2007): 1955-982. Print. 16 | -------------------------------------------------------------------------------- /sympy/physics/quantum/tests/test_piab.py: -------------------------------------------------------------------------------- 1 | """Tests for piab.py""" 2 | 3 | from sympy import Interval, pi, S, sin, sqrt, symbols 4 | from sympy.functions.special.tensor_functions import KroneckerDelta 5 | from sympy.physics.quantum import L2, qapply, hbar, represent 6 | from sympy.physics.quantum.piab import PIABHamiltonian, PIABKet, PIABBra, m, L 7 | 8 | i, j, n, x = symbols('i j n x') 9 | 10 | 11 | def test_H(): 12 | assert PIABHamiltonian('H').hilbert_space == \ 13 | L2(Interval(S.NegativeInfinity, S.Infinity)) 14 | assert qapply(PIABHamiltonian('H')*PIABKet(n)) == \ 15 | (n**2*pi**2*hbar**2)/(2*m*L**2)*PIABKet(n) 16 | 17 | 18 | def test_states(): 19 | assert PIABKet(n).dual_class() == PIABBra 20 | assert PIABKet(n).hilbert_space == \ 21 | L2(Interval(S.NegativeInfinity, S.Infinity)) 22 | assert represent(PIABKet(n)) == sqrt(2/L)*sin(n*pi*x/L) 23 | assert (PIABBra(i)*PIABKet(j)).doit() == KroneckerDelta(i, j) 24 | assert PIABBra(n).dual_class() == PIABKet 25 | -------------------------------------------------------------------------------- /sympy/ntheory/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Number theory module (primes, etc) 3 | """ 4 | 5 | from .generate import nextprime, prevprime, prime, primepi, primerange, \ 6 | randprime, Sieve, sieve, primorial, cycle_length 7 | from .primetest import isprime 8 | from .factor_ import divisors, factorint, multiplicity, perfect_power, \ 9 | pollard_pm1, pollard_rho, primefactors, totient, trailing, divisor_count 10 | from .partitions_ import npartitions 11 | from .residue_ntheory import is_primitive_root, is_quad_residue, \ 12 | legendre_symbol, jacobi_symbol, n_order, sqrt_mod, quadratic_residues, \ 13 | primitive_root, nthroot_mod, is_nthpow_residue, sqrt_mod_iter, mobius 14 | from .multinomial import binomial_coefficients, binomial_coefficients_list, \ 15 | multinomial_coefficients 16 | from .continued_fraction import continued_fraction_periodic, \ 17 | continued_fraction_iterator, continued_fraction_reduce, \ 18 | continued_fraction_convergents 19 | from .egyptian_fraction import egyptian_fraction 20 | -------------------------------------------------------------------------------- /sympy/simplify/tests/test_traversaltools.py: -------------------------------------------------------------------------------- 1 | """Tools for applying functions to specified parts of expressions. """ 2 | 3 | from sympy.simplify.traversaltools import use 4 | 5 | from sympy import expand, factor, I 6 | from sympy.abc import x, y 7 | 8 | 9 | def test_use(): 10 | assert use(0, expand) == 0 11 | 12 | f = (x + y)**2*x + 1 13 | 14 | assert use(f, expand, level=0) == x**3 + 2*x**2*y + x*y**2 + + 1 15 | assert use(f, expand, level=1) == x**3 + 2*x**2*y + x*y**2 + + 1 16 | assert use(f, expand, level=2) == 1 + x*(2*x*y + x**2 + y**2) 17 | assert use(f, expand, level=3) == (x + y)**2*x + 1 18 | 19 | f = (x**2 + 1)**2 - 1 20 | kwargs = {'gaussian': True} 21 | 22 | assert use(f, factor, level=0, kwargs=kwargs) == x**2*(x**2 + 2) 23 | assert use(f, factor, level=1, kwargs=kwargs) == (x + I)**2*(x - I)**2 - 1 24 | assert use(f, factor, level=2, kwargs=kwargs) == (x + I)**2*(x - I)**2 - 1 25 | assert use(f, factor, level=3, kwargs=kwargs) == (x**2 + 1)**2 - 1 26 | -------------------------------------------------------------------------------- /examples/galgebra/mv_setup_options.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from __future__ import print_function 4 | 5 | from sympy import symbols 6 | from sympy.galgebra import MV 7 | from sympy.galgebra import enhance_print, Get_Program, Print_Function 8 | 9 | def MV_setup_options(): 10 | Print_Function() 11 | 12 | (e1, e2, e3) = MV.setup('e_1 e_2 e_3', '[1,1,1]') 13 | v = MV('v', 'vector') 14 | print(v) 15 | 16 | (e1, e2, e3) = MV.setup('e*1|2|3', '[1,1,1]') 17 | v = MV('v', 'vector') 18 | print(v) 19 | 20 | (e1, e2, e3) = MV.setup('e*x|y|z', '[1,1,1]') 21 | v = MV('v', 'vector') 22 | print(v) 23 | 24 | coords = symbols('x y z') 25 | (e1, e2, e3, grad) = MV.setup('e', '[1,1,1]', coords=coords) 26 | v = MV('v', 'vector') 27 | print(v) 28 | 29 | return 30 | 31 | def dummy(): 32 | return 33 | 34 | def main(): 35 | Get_Program(True) 36 | enhance_print() 37 | MV_setup_options() 38 | return 39 | 40 | if __name__ == "__main__": 41 | main() 42 | -------------------------------------------------------------------------------- /sympy/geometry/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | A geometry module for the SymPy library. This module contains all of the 3 | entities and functions needed to construct basic geometrical data and to 4 | perform simple informational queries. 5 | 6 | Usage: 7 | ====== 8 | 9 | 10 | Notes: 11 | ====== 12 | Currently the geometry module supports 2-dimensional 13 | and 3 -dimensional Euclidean space. 14 | 15 | Examples 16 | ======== 17 | 18 | """ 19 | from sympy.geometry.point import Point 20 | from sympy.geometry.point3d import Point3D 21 | from sympy.geometry.line import Line, Ray, Segment 22 | from sympy.geometry.line3d import Line3D, Segment3D, Ray3D 23 | from sympy.geometry.plane import Plane 24 | from sympy.geometry.ellipse import Ellipse, Circle 25 | from sympy.geometry.polygon import Polygon, RegularPolygon, Triangle, rad, deg 26 | from sympy.geometry.util import are_similar, centroid, convex_hull, idiff, \ 27 | intersection 28 | from sympy.geometry.exceptions import GeometryError 29 | from sympy.geometry.curve import Curve 30 | -------------------------------------------------------------------------------- /sympy/liealgebras/tests/test_root_system.py: -------------------------------------------------------------------------------- 1 | from sympy.liealgebras.root_system import RootSystem 2 | from sympy.liealgebras.type_a import TypeA 3 | from sympy.matrices import Matrix 4 | 5 | def test_root_system(): 6 | c = RootSystem("A3") 7 | assert c.cartan_type == TypeA(3) 8 | assert c.simple_roots() == {1: [1, -1, 0, 0], 2: [0, 1, -1, 0], 3: [0, 0, 1, -1]} 9 | assert c.root_space() == "alpha[1] + alpha[2] + alpha[3]" 10 | assert c.cartan_matrix() == Matrix([[ 2, -1, 0], [-1, 2, -1], [ 0, -1, 2]]) 11 | assert c.dynkin_diagram() == "0---0---0\n1 2 3" 12 | assert c.add_simple_roots(1, 2) == [1, 0, -1, 0] 13 | assert c.all_roots() == {1: [1, -1, 0, 0], 2: [1, 0, -1, 0], 14 | 3: [1, 0, 0, -1], 4: [0, 1, -1, 0], 5: [0, 1, 0, -1], 15 | 6: [0, 0, 1, -1], 7: [-1, 1, 0, 0], 8: [-1, 0, 1, 0], 16 | 9: [-1, 0, 0, 1], 10: [0, -1, 1, 0], 17 | 11: [0, -1, 0, 1], 12: [0, 0, -1, 1]} 18 | assert c.add_as_roots([1, 0, -1, 0], [0, 0, 1, -1]) == [1, 0, 0, -1] 19 | -------------------------------------------------------------------------------- /sympy/solvers/__init__.py: -------------------------------------------------------------------------------- 1 | """A module for solving all kinds of equations. 2 | 3 | Examples 4 | -------- 5 | >>> from sympy.solvers import solve 6 | >>> from sympy.abc import x 7 | >>> solve(x**5+5*x**4+10*x**3+10*x**2+5*x+1,x) 8 | [-1] 9 | """ 10 | from .solvers import solve, solve_linear_system, solve_linear_system_LU, \ 11 | solve_undetermined_coeffs, nsolve, solve_linear, checksol, \ 12 | det_quick, inv_quick 13 | 14 | from .recurr import rsolve, rsolve_poly, rsolve_ratio, rsolve_hyper 15 | 16 | from .ode import checkodesol, classify_ode, dsolve, \ 17 | homogeneous_order 18 | 19 | from .polysys import solve_poly_system, solve_triangulated 20 | 21 | from .pde import pde_separate, pde_separate_add, pde_separate_mul, \ 22 | pdsolve, classify_pde, checkpdesol 23 | 24 | from .deutils import ode_order 25 | 26 | from .inequalities import reduce_inequalities, reduce_abs_inequality, \ 27 | reduce_abs_inequalities, solve_poly_inequality, solve_rational_inequalities, solve_univariate_inequality 28 | -------------------------------------------------------------------------------- /sympy/matrices/tests/test_densesolve.py: -------------------------------------------------------------------------------- 1 | from sympy.matrices.densesolve import rref, LU_solve, rref_solve, cholesky_solve 2 | from sympy import Dummy 3 | from sympy import QQ 4 | 5 | def test_LU_solve(): 6 | x, y, z = Dummy('x'), Dummy('y'), Dummy('z') 7 | 8 | assert LU_solve([[QQ(2), QQ(-1), QQ(-2)], [QQ(-4), QQ(6), QQ(3)], [QQ(-4), QQ(-2), QQ(8)]], [[x], [y], [z]], [[QQ(-1)], [QQ(13)], [QQ(-6)]], QQ) == [[QQ(2,1)], [QQ(3, 1)], [QQ(1, 1)]] 9 | 10 | 11 | def test_cholesky_solve(): 12 | x, y, z = Dummy('x'), Dummy('y'), Dummy('z') 13 | assert cholesky_solve([[QQ(25), QQ(15), QQ(-5)], [QQ(15), QQ(18), QQ(0)], [QQ(-5), QQ(0), QQ(11)]], [[x], [y], [z]], [[QQ(2)], [QQ(3)], [QQ(1)]], QQ) == [[QQ(-1, 225)], [QQ(23, 135)], [QQ(4, 45)]] 14 | 15 | 16 | def test_rref_solve(): 17 | x, y, z = Dummy('x'), Dummy('y'), Dummy('z') 18 | 19 | assert rref_solve([[QQ(25), QQ(15), QQ(-5)], [QQ(15), QQ(18), QQ(0)], [QQ(-5), QQ(0), QQ(11)]], [[x], [y], [z]], [[QQ(2)], [QQ(3)], [QQ(1)]], QQ) == [[QQ(-1, 225)], [QQ(23, 135)], [QQ(4, 45)]] 20 | -------------------------------------------------------------------------------- /sympy/liealgebras/tests/test_type_C.py: -------------------------------------------------------------------------------- 1 | from sympy.liealgebras.cartan_type import CartanType 2 | from sympy.matrices import Matrix 3 | 4 | def test_type_C(): 5 | c = CartanType("C4") 6 | m = Matrix(4, 4, [2, -1, 0, 0, -1, 2, -1, 0, 0, -1, 2, -1, 0, 0, -2, 2]) 7 | assert c.cartan_matrix() == m 8 | assert c.dimension() == 4 9 | assert c.simple_root(4) == [0, 0, 0, 2] 10 | assert c.roots() == 32 11 | assert c.basis() == 36 12 | assert c.lie_algebra() == "sp(8)" 13 | t = CartanType(['C', 3]) 14 | assert t.dimension() == 3 15 | diag = "0---0---0=<=0\n1 2 3 4" 16 | assert c.dynkin_diagram() == diag 17 | assert c.positive_roots() == {1: [1, -1, 0, 0], 2: [1, 1, 0, 0], 18 | 3: [1, 0, -1, 0], 4: [1, 0, 1, 0], 5: [1, 0, 0, -1], 19 | 6: [1, 0, 0, 1], 7: [0, 1, -1, 0], 8: [0, 1, 1, 0], 20 | 9: [0, 1, 0, -1], 10: [0, 1, 0, 1], 11: [0, 0, 1, -1], 21 | 12: [0, 0, 1, 1], 13: [2, 0, 0, 0], 14: [0, 2, 0, 0], 15: [0, 0, 2, 0], 22 | 16: [0, 0, 0, 2]} 23 | -------------------------------------------------------------------------------- /sympy/matrices/expressions/matpow.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from .matexpr import MatrixExpr, ShapeError, Identity 4 | from sympy import Pow, S, Basic 5 | from sympy.core.sympify import _sympify 6 | 7 | 8 | class MatPow(MatrixExpr): 9 | 10 | def __new__(cls, base, exp): 11 | base = _sympify(base) 12 | if not base.is_Matrix: 13 | raise TypeError("Function parameter should be a matrix") 14 | exp = _sympify(exp) 15 | return super(MatPow, cls).__new__(cls, base, exp) 16 | 17 | @property 18 | def base(self): 19 | return self.args[0] 20 | 21 | @property 22 | def exp(self): 23 | return self.args[1] 24 | 25 | @property 26 | def shape(self): 27 | return self.base.shape 28 | 29 | def _entry(self, i, j): 30 | if self.exp.is_Integer: 31 | # Make an explicity MatMul out of the MatPow 32 | return MatMul(*[self.base for k in range(self.exp)])._entry(i, j) 33 | 34 | from .matmul import MatMul 35 | -------------------------------------------------------------------------------- /sympy/stats/tests/test_discrete_rv.py: -------------------------------------------------------------------------------- 1 | from sympy.stats.drv_types import (PoissonDistribution, GeometricDistribution, 2 | Poisson) 3 | from sympy.abc import x 4 | from sympy import S, Sum 5 | from sympy.stats import E, variance, density 6 | 7 | def test_PoissonDistribution(): 8 | l = 3 9 | p = PoissonDistribution(l) 10 | assert abs(p.cdf(10).evalf() - 1) < .001 11 | assert p.expectation(x, x) == l 12 | assert p.expectation(x**2, x) - p.expectation(x, x)**2 == l 13 | 14 | def test_Poisson(): 15 | l = 3 16 | x = Poisson('x', l) 17 | assert E(x) == l 18 | assert variance(x) == l 19 | assert density(x) == PoissonDistribution(l) 20 | assert isinstance(E(x, evaluate=False), Sum) 21 | assert isinstance(E(2*x, evaluate=False), Sum) 22 | 23 | def test_GeometricDistribution(): 24 | p = S.One / 5 25 | d = GeometricDistribution(p) 26 | assert d.expectation(x, x) == 1/p 27 | assert d.expectation(x**2, x) - d.expectation(x, x)**2 == (1-p)/p**2 28 | assert abs(d.cdf(20000).evalf() - 1) < .001 29 | -------------------------------------------------------------------------------- /sympy/calculus/singularities.py: -------------------------------------------------------------------------------- 1 | from sympy.solvers import solve 2 | from sympy.simplify import simplify 3 | 4 | 5 | def singularities(expr, sym): 6 | """ 7 | Finds singularities for a function. 8 | Currently supported functions are: 9 | - univariate real rational functions 10 | 11 | Examples 12 | ======== 13 | 14 | >>> from sympy.calculus.singularities import singularities 15 | >>> from sympy import Symbol 16 | >>> x = Symbol('x', real=True) 17 | >>> singularities(x**2 + x + 1, x) 18 | () 19 | >>> singularities(1/(x + 1), x) 20 | (-1,) 21 | 22 | References 23 | ========== 24 | 25 | .. [1] http://en.wikipedia.org/wiki/Mathematical_singularity 26 | 27 | """ 28 | if not expr.is_rational_function(sym): 29 | raise NotImplementedError("Algorithms finding singularities for" 30 | " non rational functions are not yet" 31 | " implemented") 32 | else: 33 | return tuple(sorted(solve(simplify(1/expr), sym))) 34 | -------------------------------------------------------------------------------- /examples/beginner/limits_examples.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Limits Example 4 | 5 | Demonstrates limits. 6 | """ 7 | 8 | from sympy import exp, log, Symbol, Rational, sin, limit, sqrt, oo 9 | 10 | 11 | def sqrt3(x): 12 | return x**Rational(1, 3) 13 | 14 | 15 | def show(computed, correct): 16 | print("computed:", computed, "correct:", correct) 17 | 18 | 19 | def main(): 20 | x = Symbol("x") 21 | a = Symbol("a") 22 | h = Symbol("h") 23 | 24 | show( limit(sqrt(x**2 - 5*x + 6) - x, x, oo), -Rational(5)/2 ) 25 | 26 | show( limit(x*(sqrt(x**2 + 1) - x), x, oo), Rational(1)/2 ) 27 | 28 | show( limit(x - sqrt3(x**3 - 1), x, oo), Rational(0) ) 29 | 30 | show( limit(log(1 + exp(x))/x, x, -oo), Rational(0) ) 31 | 32 | show( limit(log(1 + exp(x))/x, x, oo), Rational(1) ) 33 | 34 | show( limit(sin(3*x)/x, x, 0), Rational(3) ) 35 | 36 | show( limit(sin(5*x)/sin(2*x), x, 0), Rational(5)/2 ) 37 | 38 | show( limit(((x - 1)/(x + 1))**x, x, oo), exp(-2)) 39 | 40 | if __name__ == "__main__": 41 | main() 42 | -------------------------------------------------------------------------------- /doc/src/modules/physics/quantum/index.rst: -------------------------------------------------------------------------------- 1 | ================= 2 | Quantum Mechanics 3 | ================= 4 | 5 | .. topic:: Abstract 6 | 7 | Contains Docstrings of Physics-Quantum module 8 | 9 | Quantum Functions 10 | ================= 11 | 12 | .. toctree:: 13 | :maxdepth: 3 14 | 15 | anticommutator.rst 16 | cg.rst 17 | commutator.rst 18 | constants.rst 19 | dagger.rst 20 | innerproduct.rst 21 | tensorproduct.rst 22 | 23 | States and Operators 24 | ==================== 25 | 26 | .. toctree:: 27 | :maxdepth: 3 28 | 29 | cartesian.rst 30 | hilbert.rst 31 | operator.rst 32 | operatorset.rst 33 | qapply.rst 34 | represent.rst 35 | spin.rst 36 | state.rst 37 | 38 | Quantum Computation 39 | =================== 40 | 41 | .. toctree:: 42 | :maxdepth: 3 43 | 44 | circuitplot.rst 45 | gate.rst 46 | grover.rst 47 | qft.rst 48 | qubit.rst 49 | shor.rst 50 | 51 | Analytic Solutions 52 | ================== 53 | 54 | 55 | .. toctree:: 56 | :maxdepth: 3 57 | 58 | piab.rst 59 | -------------------------------------------------------------------------------- /sympy/logic/benchmarks/input/15.cnf: -------------------------------------------------------------------------------- 1 | c 2 | c SAT instance in DIMACS CNF input format. 3 | c 4 | p cnf 15 63 5 | -9 2 -14 0 6 | -11 -1 -9 0 7 | -14 1 -6 0 8 | 10 14 -8 0 9 | 3 -12 -13 0 10 | -2 5 -10 0 11 | 3 4 -11 0 12 | 5 -11 -8 0 13 | -15 -11 10 0 14 | 8 -9 -7 0 15 | -7 8 6 0 16 | -6 -2 8 0 17 | 4 2 -9 0 18 | 13 1 11 0 19 | -15 -7 -10 0 20 | -5 -12 -10 0 21 | 7 4 -5 0 22 | 11 7 -10 0 23 | -9 8 -5 0 24 | -9 -6 5 0 25 | -13 9 3 0 26 | 13 -3 10 0 27 | 15 -10 -14 0 28 | 13 1 4 0 29 | -9 12 14 0 30 | -12 -10 -13 0 31 | -6 1 13 0 32 | 5 -12 10 0 33 | 10 13 -2 0 34 | -14 6 -11 0 35 | 11 10 -12 0 36 | 12 -7 -6 0 37 | -10 8 -15 0 38 | -1 9 -2 0 39 | -13 9 -11 0 40 | -11 7 -15 0 41 | -3 14 -8 0 42 | 8 3 -15 0 43 | 3 1 7 0 44 | -8 -15 -6 0 45 | -15 5 -12 0 46 | 8 7 14 0 47 | -5 11 8 0 48 | 2 -10 -1 0 49 | -9 11 -2 0 50 | -13 15 -6 0 51 | 5 -3 -10 0 52 | -10 15 -8 0 53 | 8 14 10 0 54 | -1 -11 -14 0 55 | -11 -10 5 0 56 | -2 4 3 0 57 | 8 6 -9 0 58 | 9 -3 -7 0 59 | -7 -12 -11 0 60 | 5 -13 1 0 61 | 11 5 -4 0 62 | -9 10 -1 0 63 | -12 7 2 0 64 | 6 8 5 0 65 | 11 -7 6 0 66 | 8 -12 3 0 67 | -8 13 4 0 68 | -------------------------------------------------------------------------------- /sympy/sets/contains.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | 3 | from sympy.core import C 4 | from sympy.logic.boolalg import BooleanFunction 5 | 6 | 7 | class Contains(BooleanFunction): 8 | """ 9 | Asserts that x is an element of the set S 10 | 11 | Examples 12 | ======== 13 | 14 | >>> from sympy import Symbol, Integer, S 15 | >>> from sympy.sets.contains import Contains 16 | >>> Contains(Integer(2), S.Integers) 17 | True 18 | >>> Contains(Integer(-2), S.Naturals) 19 | False 20 | >>> i = Symbol('i', integer=True) 21 | >>> Contains(i, S.Naturals) 22 | Contains(i, Naturals()) 23 | 24 | References 25 | ========== 26 | 27 | .. [1] http://en.wikipedia.org/wiki/Element_%28mathematics%29 28 | """ 29 | @classmethod 30 | def eval(cls, x, S): 31 | if not isinstance(x, C.Basic): 32 | raise TypeError 33 | if not isinstance(S, C.Set): 34 | raise TypeError 35 | 36 | ret = S.contains(x) 37 | if not isinstance(ret, Contains): 38 | return ret 39 | -------------------------------------------------------------------------------- /examples/galgebra/prob_not_solenoidal.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from __future__ import print_function 4 | 5 | from sympy import symbols, sin, cos, factor_terms, simplify 6 | from sympy.galgebra import enhance_print 7 | from sympy.galgebra import MV 8 | 9 | def main(): 10 | enhance_print() 11 | 12 | X = (x, y, z) = symbols('x y z') 13 | (ex, ey, ez, grad) = MV.setup('e_x e_y e_z', metric='[1,1,1]', coords=(x, y, z)) 14 | 15 | A = x*(ey ^ ez) + y*(ez ^ ex) + z*(ex ^ ey) 16 | print('A =', A) 17 | print('grad^A =', (grad ^ A).simplify()) 18 | print() 19 | 20 | f = MV('f', 'scalar', fct=True) 21 | f = (x**2 + y**2 + z**2)**(-1.5) 22 | print('f =', f) 23 | print('grad*f =', (grad*f).expand()) 24 | print() 25 | 26 | B = f*A 27 | print('B =', B) 28 | print() 29 | 30 | Curl_B = grad ^ B 31 | 32 | print('grad^B =', Curl_B.simplify()) 33 | 34 | def Symplify(A): 35 | return(factor_terms(simplify(A))) 36 | 37 | print(Curl_B.func(Symplify)) 38 | return 39 | 40 | if __name__ == "__main__": 41 | main() 42 | -------------------------------------------------------------------------------- /sympy/core/tests/test_truediv.py: -------------------------------------------------------------------------------- 1 | from __future__ import division 2 | 3 | #this module tests that sympy works with true division turned on 4 | 5 | from sympy import Rational, Symbol, Float 6 | 7 | 8 | def test_truediv(): 9 | assert 1/2 != 0 10 | assert Rational(1)/2 != 0 11 | 12 | 13 | def dotest(s): 14 | x = Symbol("x") 15 | y = Symbol("y") 16 | l = [ 17 | Rational(2), 18 | Float("1.3"), 19 | x, 20 | y, 21 | pow(x, y)*y, 22 | 5, 23 | 5.5 24 | ] 25 | for x in l: 26 | for y in l: 27 | s(x, y) 28 | return True 29 | 30 | 31 | def test_basic(): 32 | def s(a, b): 33 | x = a 34 | x = +a 35 | x = -a 36 | x = a + b 37 | x = a - b 38 | x = a*b 39 | x = a/b 40 | x = a**b 41 | assert dotest(s) 42 | 43 | 44 | def test_ibasic(): 45 | def s(a, b): 46 | x = a 47 | x += b 48 | x = a 49 | x -= b 50 | x = a 51 | x *= b 52 | x = a 53 | x /= b 54 | assert dotest(s) 55 | -------------------------------------------------------------------------------- /sympy/polys/domains/rationalfield.py: -------------------------------------------------------------------------------- 1 | """Implementation of :class:`RationalField` class. """ 2 | 3 | from __future__ import print_function, division 4 | 5 | from sympy.polys.domains.field import Field 6 | from sympy.polys.domains.simpledomain import SimpleDomain 7 | from sympy.polys.domains.characteristiczero import CharacteristicZero 8 | 9 | from sympy.utilities import public 10 | 11 | @public 12 | class RationalField(Field, CharacteristicZero, SimpleDomain): 13 | """General class for rational fields. """ 14 | 15 | rep = 'QQ' 16 | 17 | is_RationalField = is_QQ = True 18 | is_Numerical = True 19 | 20 | has_assoc_Ring = True 21 | has_assoc_Field = True 22 | 23 | def algebraic_field(self, *extension): 24 | r"""Returns an algebraic field, i.e. `\mathbb{Q}(\alpha, \dots)`. """ 25 | from sympy.polys.domains import AlgebraicField 26 | return AlgebraicField(self, *extension) 27 | 28 | def from_AlgebraicField(K1, a, K0): 29 | """Convert a ``ANP`` object to ``dtype``. """ 30 | if a.is_ground: 31 | return K1.convert(a.LC(), K0.dom) 32 | -------------------------------------------------------------------------------- /sympy/simplify/tests/test_rewrite.py: -------------------------------------------------------------------------------- 1 | from sympy import (sin, cos, exp, cot, sqrt, S, I, E, pi, symbols, Function, 2 | Matrix, Eq, RootSum, Lambda) 3 | from sympy.integrals import integrate 4 | 5 | x, y, z, n = symbols('x,y,z,n') 6 | 7 | 8 | def test_has(): 9 | assert cot(x).has(x) 10 | assert cot(x).has(cot) 11 | assert not cot(x).has(sin) 12 | assert sin(x).has(x) 13 | assert sin(x).has(sin) 14 | assert not sin(x).has(cot) 15 | 16 | 17 | def test_sin_exp_rewrite(): 18 | assert sin(x).rewrite(sin, exp) == -I/2*(exp(I*x) - exp(-I*x)) 19 | assert sin(x).rewrite(sin, exp).rewrite(exp, sin) == sin(x) 20 | assert cos(x).rewrite(cos, exp).rewrite(exp, cos) == cos(x) 21 | assert (sin(5*y) - sin( 22 | 2*x)).rewrite(sin, exp).rewrite(exp, sin) == sin(5*y) - sin(2*x) 23 | assert sin(x + y).rewrite(sin, exp).rewrite(exp, sin) == sin(x + y) 24 | assert cos(x + y).rewrite(cos, exp).rewrite(exp, cos) == cos(x + y) 25 | # This next test currently passes... not clear whether it should or not? 26 | assert cos(x).rewrite(cos, exp).rewrite(exp, sin) == cos(x) 27 | -------------------------------------------------------------------------------- /sympy/mpmath/tests/test_visualization.py: -------------------------------------------------------------------------------- 1 | """ 2 | Limited tests of the visualization module. Right now it just makes 3 | sure that passing custom Axes works. 4 | 5 | """ 6 | 7 | from sympy.mpmath import mp, fp 8 | 9 | def test_axes(): 10 | try: 11 | import matplotlib 12 | version = matplotlib.__version__.split("-")[0] 13 | version = version.split(".")[:2] 14 | if [int(_) for _ in version] < [0,99]: 15 | raise ImportError 16 | import pylab 17 | except ImportError: 18 | print("\nSkipping test (pylab not available or too old version)\n") 19 | return 20 | fig = pylab.figure() 21 | axes = fig.add_subplot(111) 22 | for ctx in [mp, fp]: 23 | ctx.plot(lambda x: x**2, [0, 3], axes=axes) 24 | assert axes.get_xlabel() == 'x' 25 | assert axes.get_ylabel() == 'f(x)' 26 | 27 | fig = pylab.figure() 28 | axes = fig.add_subplot(111) 29 | for ctx in [mp, fp]: 30 | ctx.cplot(lambda z: z, [-2, 2], [-10, 10], axes=axes) 31 | assert axes.get_xlabel() == 'Re(z)' 32 | assert axes.get_ylabel() == 'Im(z)' 33 | -------------------------------------------------------------------------------- /sympy/simplify/traversaltools.py: -------------------------------------------------------------------------------- 1 | """Tools for applying functions to specified parts of expressions. """ 2 | 3 | from __future__ import print_function, division 4 | 5 | from sympy.core import sympify 6 | 7 | 8 | def use(expr, func, level=0, args=(), kwargs={}): 9 | """ 10 | Use ``func`` to transform ``expr`` at the given level. 11 | 12 | Examples 13 | ======== 14 | 15 | >>> from sympy import use, expand 16 | >>> from sympy.abc import x, y 17 | 18 | >>> f = (x + y)**2*x + 1 19 | 20 | >>> use(f, expand, level=2) 21 | x*(x**2 + 2*x*y + y**2) + 1 22 | >>> expand(f) 23 | x**3 + 2*x**2*y + x*y**2 + 1 24 | 25 | """ 26 | def _use(expr, level): 27 | if not level: 28 | return func(expr, *args, **kwargs) 29 | else: 30 | if expr.is_Atom: 31 | return expr 32 | else: 33 | level -= 1 34 | _args = [] 35 | 36 | for arg in expr.args: 37 | _args.append(_use(arg, level)) 38 | 39 | return expr.__class__(*_args) 40 | 41 | return _use(sympify(expr), level) 42 | -------------------------------------------------------------------------------- /sympy/integrals/meijerint_doc.py: -------------------------------------------------------------------------------- 1 | """ This module cooks up a docstring when imported. Its only purpose is to 2 | be displayed in the sphinx documentation. """ 3 | 4 | from __future__ import print_function, division 5 | 6 | from sympy.integrals.meijerint import _create_lookup_table 7 | from sympy import latex, Eq, meijerg, Add, Symbol 8 | 9 | t = {} 10 | _create_lookup_table(t) 11 | 12 | doc = "" 13 | 14 | for about, category in sorted(t.items()): 15 | if about == (): 16 | doc += 'Elementary functions:\n\n' 17 | else: 18 | doc += 'Functions involving ' + ', '.join('`%s`' % latex( 19 | list(category[0][0].atoms(func))[0]) for func in about) + ':\n\n' 20 | for formula, gs, cond, hint in category: 21 | if not isinstance(gs, list): 22 | g = Symbol('\\text{generated}') 23 | else: 24 | g = Add(*[fac*f for (fac, f) in gs]) 25 | obj = Eq(formula, g) 26 | if cond is True: 27 | cond = "" 28 | else: 29 | cond = ',\\text{ if } %s' % latex(cond) 30 | doc += ".. math::\n %s%s\n\n" % (latex(obj), cond) 31 | 32 | __doc__ = doc 33 | --------------------------------------------------------------------------------