Instructions to use giancap61/AXEL-AI_Virtual_Race_Engineer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use giancap61/AXEL-AI_Virtual_Race_Engineer with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf giancap61/AXEL-AI_Virtual_Race_Engineer:Q5_K_M # Run inference directly in the terminal: llama cli -hf giancap61/AXEL-AI_Virtual_Race_Engineer:Q5_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf giancap61/AXEL-AI_Virtual_Race_Engineer:Q5_K_M # Run inference directly in the terminal: llama cli -hf giancap61/AXEL-AI_Virtual_Race_Engineer:Q5_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf giancap61/AXEL-AI_Virtual_Race_Engineer:Q5_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf giancap61/AXEL-AI_Virtual_Race_Engineer:Q5_K_M
Use Docker
docker model run hf.co/giancap61/AXEL-AI_Virtual_Race_Engineer:Q5_K_M
- Llama new
- LM Studio
- Jan
- Ollama
How to use giancap61/AXEL-AI_Virtual_Race_Engineer with Ollama:
ollama run hf.co/giancap61/AXEL-AI_Virtual_Race_Engineer:Q5_K_M
- Unsloth Desktop
- Pi
How to use giancap61/AXEL-AI_Virtual_Race_Engineer with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf giancap61/AXEL-AI_Virtual_Race_Engineer:Q5_K_M
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "giancap61/AXEL-AI_Virtual_Race_Engineer:Q5_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use giancap61/AXEL-AI_Virtual_Race_Engineer with Docker Model Runner:
docker model run hf.co/giancap61/AXEL-AI_Virtual_Race_Engineer:Q5_K_M
- Lemonade
How to use giancap61/AXEL-AI_Virtual_Race_Engineer with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull giancap61/AXEL-AI_Virtual_Race_Engineer:Q5_K_M
Run and chat with the model
lemonade run user.AXEL-AI_Virtual_Race_Engineer-Q5_K_M
List all available models
lemonade list
- Hermes Agent
How to use giancap61/AXEL-AI_Virtual_Race_Engineer with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf giancap61/AXEL-AI_Virtual_Race_Engineer:Q5_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:9931/v1 hermes config set model.default giancap61/AXEL-AI_Virtual_Race_Engineer:Q5_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use giancap61/AXEL-AI_Virtual_Race_Engineer with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf giancap61/AXEL-AI_Virtual_Race_Engineer:Q5_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:9931/v1 \ --custom-model-id "giancap61/AXEL-AI_Virtual_Race_Engineer:Q5_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/__pycache__/__init__.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/__pycache__/expr_with_limits.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/__pycache__/gosper.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/__pycache__/guess.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/__pycache__/products.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/__pycache__/summations.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/tests/__pycache__/__init__.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/tests/__pycache__/test_delta.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/tests/__pycache__/test_gosper.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/tests/__pycache__/test_guess.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/tests/__pycache__/test_products.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/tests/test_products.py +410 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/tests/test_sums_products.py +1676 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/__init__.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/_print_helpers.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/add.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/alphabets.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/assumptions.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/assumptions_generated.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/backend.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/basic.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/cache.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/compatibility.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/containers.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/core.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/coreerrors.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/decorators.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/evalf.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/exprtools.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/facts.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/intfunc.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/kind.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/logic.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/mod.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/mul.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/multidimensional.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/operations.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/parameters.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/power.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/random.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/relational.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/rules.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/singleton.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/sorting.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/symbol.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/sympify.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/trace.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/traversal.cpython-312.pyc +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/benchmarks/__init__.py +0 -0
- TTS/Kokoro/.venv/Lib/site-packages/sympy/core/benchmarks/__pycache__/__init__.cpython-312.pyc +0 -0
TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (369 Bytes). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/__pycache__/expr_with_limits.cpython-312.pyc
ADDED
|
Binary file (26.9 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/__pycache__/gosper.cpython-312.pyc
ADDED
|
Binary file (8.04 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/__pycache__/guess.cpython-312.pyc
ADDED
|
Binary file (23.5 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/__pycache__/products.cpython-312.pyc
ADDED
|
Binary file (23.1 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/__pycache__/summations.cpython-312.pyc
ADDED
|
Binary file (64.8 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/tests/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (209 Bytes). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/tests/__pycache__/test_delta.cpython-312.pyc
ADDED
|
Binary file (75.8 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/tests/__pycache__/test_gosper.cpython-312.pyc
ADDED
|
Binary file (20.1 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/tests/__pycache__/test_guess.cpython-312.pyc
ADDED
|
Binary file (6.6 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/tests/__pycache__/test_products.cpython-312.pyc
ADDED
|
Binary file (30.8 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/tests/test_products.py
ADDED
|
@@ -0,0 +1,410 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from sympy.concrete.products import (Product, product)
|
| 2 |
+
from sympy.concrete.summations import Sum
|
| 3 |
+
from sympy.core.function import (Derivative, Function, diff)
|
| 4 |
+
from sympy.core.numbers import (Rational, oo, pi)
|
| 5 |
+
from sympy.core.singleton import S
|
| 6 |
+
from sympy.core.symbol import (Dummy, Symbol, symbols)
|
| 7 |
+
from sympy.functions.combinatorial.factorials import (rf, factorial)
|
| 8 |
+
from sympy.functions.elementary.exponential import (exp, log)
|
| 9 |
+
from sympy.functions.elementary.miscellaneous import sqrt
|
| 10 |
+
from sympy.functions.elementary.trigonometric import (cos, sin)
|
| 11 |
+
from sympy.functions.special.tensor_functions import KroneckerDelta
|
| 12 |
+
from sympy.simplify.combsimp import combsimp
|
| 13 |
+
from sympy.simplify.simplify import simplify
|
| 14 |
+
from sympy.testing.pytest import raises
|
| 15 |
+
|
| 16 |
+
a, k, n, m, x = symbols('a,k,n,m,x', integer=True)
|
| 17 |
+
f = Function('f')
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def test_karr_convention():
|
| 21 |
+
# Test the Karr product convention that we want to hold.
|
| 22 |
+
# See his paper "Summation in Finite Terms" for a detailed
|
| 23 |
+
# reasoning why we really want exactly this definition.
|
| 24 |
+
# The convention is described for sums on page 309 and
|
| 25 |
+
# essentially in section 1.4, definition 3. For products
|
| 26 |
+
# we can find in analogy:
|
| 27 |
+
#
|
| 28 |
+
# \prod_{m <= i < n} f(i) 'has the obvious meaning' for m < n
|
| 29 |
+
# \prod_{m <= i < n} f(i) = 0 for m = n
|
| 30 |
+
# \prod_{m <= i < n} f(i) = 1 / \prod_{n <= i < m} f(i) for m > n
|
| 31 |
+
#
|
| 32 |
+
# It is important to note that he defines all products with
|
| 33 |
+
# the upper limit being *exclusive*.
|
| 34 |
+
# In contrast, SymPy and the usual mathematical notation has:
|
| 35 |
+
#
|
| 36 |
+
# prod_{i = a}^b f(i) = f(a) * f(a+1) * ... * f(b-1) * f(b)
|
| 37 |
+
#
|
| 38 |
+
# with the upper limit *inclusive*. So translating between
|
| 39 |
+
# the two we find that:
|
| 40 |
+
#
|
| 41 |
+
# \prod_{m <= i < n} f(i) = \prod_{i = m}^{n-1} f(i)
|
| 42 |
+
#
|
| 43 |
+
# where we intentionally used two different ways to typeset the
|
| 44 |
+
# products and its limits.
|
| 45 |
+
|
| 46 |
+
i = Symbol("i", integer=True)
|
| 47 |
+
k = Symbol("k", integer=True)
|
| 48 |
+
j = Symbol("j", integer=True, positive=True)
|
| 49 |
+
|
| 50 |
+
# A simple example with a concrete factors and symbolic limits.
|
| 51 |
+
|
| 52 |
+
# The normal product: m = k and n = k + j and therefore m < n:
|
| 53 |
+
m = k
|
| 54 |
+
n = k + j
|
| 55 |
+
|
| 56 |
+
a = m
|
| 57 |
+
b = n - 1
|
| 58 |
+
S1 = Product(i**2, (i, a, b)).doit()
|
| 59 |
+
|
| 60 |
+
# The reversed product: m = k + j and n = k and therefore m > n:
|
| 61 |
+
m = k + j
|
| 62 |
+
n = k
|
| 63 |
+
|
| 64 |
+
a = m
|
| 65 |
+
b = n - 1
|
| 66 |
+
S2 = Product(i**2, (i, a, b)).doit()
|
| 67 |
+
|
| 68 |
+
assert S1 * S2 == 1
|
| 69 |
+
|
| 70 |
+
# Test the empty product: m = k and n = k and therefore m = n:
|
| 71 |
+
m = k
|
| 72 |
+
n = k
|
| 73 |
+
|
| 74 |
+
a = m
|
| 75 |
+
b = n - 1
|
| 76 |
+
Sz = Product(i**2, (i, a, b)).doit()
|
| 77 |
+
|
| 78 |
+
assert Sz == 1
|
| 79 |
+
|
| 80 |
+
# Another example this time with an unspecified factor and
|
| 81 |
+
# numeric limits. (We can not do both tests in the same example.)
|
| 82 |
+
f = Function("f")
|
| 83 |
+
|
| 84 |
+
# The normal product with m < n:
|
| 85 |
+
m = 2
|
| 86 |
+
n = 11
|
| 87 |
+
|
| 88 |
+
a = m
|
| 89 |
+
b = n - 1
|
| 90 |
+
S1 = Product(f(i), (i, a, b)).doit()
|
| 91 |
+
|
| 92 |
+
# The reversed product with m > n:
|
| 93 |
+
m = 11
|
| 94 |
+
n = 2
|
| 95 |
+
|
| 96 |
+
a = m
|
| 97 |
+
b = n - 1
|
| 98 |
+
S2 = Product(f(i), (i, a, b)).doit()
|
| 99 |
+
|
| 100 |
+
assert simplify(S1 * S2) == 1
|
| 101 |
+
|
| 102 |
+
# Test the empty product with m = n:
|
| 103 |
+
m = 5
|
| 104 |
+
n = 5
|
| 105 |
+
|
| 106 |
+
a = m
|
| 107 |
+
b = n - 1
|
| 108 |
+
Sz = Product(f(i), (i, a, b)).doit()
|
| 109 |
+
|
| 110 |
+
assert Sz == 1
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
def test_karr_proposition_2a():
|
| 114 |
+
# Test Karr, page 309, proposition 2, part a
|
| 115 |
+
i, u, v = symbols('i u v', integer=True)
|
| 116 |
+
|
| 117 |
+
def test_the_product(m, n):
|
| 118 |
+
# g
|
| 119 |
+
g = i**3 + 2*i**2 - 3*i
|
| 120 |
+
# f = Delta g
|
| 121 |
+
f = simplify(g.subs(i, i+1) / g)
|
| 122 |
+
# The product
|
| 123 |
+
a = m
|
| 124 |
+
b = n - 1
|
| 125 |
+
P = Product(f, (i, a, b)).doit()
|
| 126 |
+
# Test if Product_{m <= i < n} f(i) = g(n) / g(m)
|
| 127 |
+
assert combsimp(P / (g.subs(i, n) / g.subs(i, m))) == 1
|
| 128 |
+
|
| 129 |
+
# m < n
|
| 130 |
+
test_the_product(u, u + v)
|
| 131 |
+
# m = n
|
| 132 |
+
test_the_product(u, u)
|
| 133 |
+
# m > n
|
| 134 |
+
test_the_product(u + v, u)
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
def test_karr_proposition_2b():
|
| 138 |
+
# Test Karr, page 309, proposition 2, part b
|
| 139 |
+
i, u, v, w = symbols('i u v w', integer=True)
|
| 140 |
+
|
| 141 |
+
def test_the_product(l, n, m):
|
| 142 |
+
# Productmand
|
| 143 |
+
s = i**3
|
| 144 |
+
# First product
|
| 145 |
+
a = l
|
| 146 |
+
b = n - 1
|
| 147 |
+
S1 = Product(s, (i, a, b)).doit()
|
| 148 |
+
# Second product
|
| 149 |
+
a = l
|
| 150 |
+
b = m - 1
|
| 151 |
+
S2 = Product(s, (i, a, b)).doit()
|
| 152 |
+
# Third product
|
| 153 |
+
a = m
|
| 154 |
+
b = n - 1
|
| 155 |
+
S3 = Product(s, (i, a, b)).doit()
|
| 156 |
+
# Test if S1 = S2 * S3 as required
|
| 157 |
+
assert combsimp(S1 / (S2 * S3)) == 1
|
| 158 |
+
|
| 159 |
+
# l < m < n
|
| 160 |
+
test_the_product(u, u + v, u + v + w)
|
| 161 |
+
# l < m = n
|
| 162 |
+
test_the_product(u, u + v, u + v)
|
| 163 |
+
# l < m > n
|
| 164 |
+
test_the_product(u, u + v + w, v)
|
| 165 |
+
# l = m < n
|
| 166 |
+
test_the_product(u, u, u + v)
|
| 167 |
+
# l = m = n
|
| 168 |
+
test_the_product(u, u, u)
|
| 169 |
+
# l = m > n
|
| 170 |
+
test_the_product(u + v, u + v, u)
|
| 171 |
+
# l > m < n
|
| 172 |
+
test_the_product(u + v, u, u + w)
|
| 173 |
+
# l > m = n
|
| 174 |
+
test_the_product(u + v, u, u)
|
| 175 |
+
# l > m > n
|
| 176 |
+
test_the_product(u + v + w, u + v, u)
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
def test_simple_products():
|
| 180 |
+
assert product(2, (k, a, n)) == 2**(n - a + 1)
|
| 181 |
+
assert product(k, (k, 1, n)) == factorial(n)
|
| 182 |
+
assert product(k**3, (k, 1, n)) == factorial(n)**3
|
| 183 |
+
|
| 184 |
+
assert product(k + 1, (k, 0, n - 1)) == factorial(n)
|
| 185 |
+
assert product(k + 1, (k, a, n - 1)) == rf(1 + a, n - a)
|
| 186 |
+
|
| 187 |
+
assert product(cos(k), (k, 0, 5)) == cos(1)*cos(2)*cos(3)*cos(4)*cos(5)
|
| 188 |
+
assert product(cos(k), (k, 3, 5)) == cos(3)*cos(4)*cos(5)
|
| 189 |
+
assert product(cos(k), (k, 1, Rational(5, 2))) != cos(1)*cos(2)
|
| 190 |
+
|
| 191 |
+
assert isinstance(product(k**k, (k, 1, n)), Product)
|
| 192 |
+
|
| 193 |
+
assert Product(x**k, (k, 1, n)).variables == [k]
|
| 194 |
+
|
| 195 |
+
raises(ValueError, lambda: Product(n))
|
| 196 |
+
raises(ValueError, lambda: Product(n, k))
|
| 197 |
+
raises(ValueError, lambda: Product(n, k, 1))
|
| 198 |
+
raises(ValueError, lambda: Product(n, k, 1, 10))
|
| 199 |
+
raises(ValueError, lambda: Product(n, (k, 1)))
|
| 200 |
+
|
| 201 |
+
assert product(1, (n, 1, oo)) == 1 # issue 8301
|
| 202 |
+
assert product(2, (n, 1, oo)) is oo
|
| 203 |
+
assert product(-1, (n, 1, oo)).func is Product
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
def test_multiple_products():
|
| 207 |
+
assert product(x, (n, 1, k), (k, 1, m)) == x**(m**2/2 + m/2)
|
| 208 |
+
assert product(f(n), (
|
| 209 |
+
n, 1, m), (m, 1, k)) == Product(f(n), (n, 1, m), (m, 1, k)).doit()
|
| 210 |
+
assert Product(f(n), (m, 1, k), (n, 1, k)).doit() == \
|
| 211 |
+
Product(Product(f(n), (m, 1, k)), (n, 1, k)).doit() == \
|
| 212 |
+
product(f(n), (m, 1, k), (n, 1, k)) == \
|
| 213 |
+
product(product(f(n), (m, 1, k)), (n, 1, k)) == \
|
| 214 |
+
Product(f(n)**k, (n, 1, k))
|
| 215 |
+
assert Product(
|
| 216 |
+
x, (x, 1, k), (k, 1, n)).doit() == Product(factorial(k), (k, 1, n))
|
| 217 |
+
|
| 218 |
+
assert Product(x**k, (n, 1, k), (k, 1, m)).variables == [n, k]
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
def test_rational_products():
|
| 222 |
+
assert product(1 + 1/k, (k, 1, n)) == rf(2, n)/factorial(n)
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
def test_special_products():
|
| 226 |
+
# Wallis product
|
| 227 |
+
assert product((4*k)**2 / (4*k**2 - 1), (k, 1, n)) == \
|
| 228 |
+
4**n*factorial(n)**2/rf(S.Half, n)/rf(Rational(3, 2), n)
|
| 229 |
+
|
| 230 |
+
# Euler's product formula for sin
|
| 231 |
+
assert product(1 + a/k**2, (k, 1, n)) == \
|
| 232 |
+
rf(1 - sqrt(-a), n)*rf(1 + sqrt(-a), n)/factorial(n)**2
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
def test__eval_product():
|
| 236 |
+
from sympy.abc import i, n
|
| 237 |
+
# issue 4809
|
| 238 |
+
a = Function('a')
|
| 239 |
+
assert product(2*a(i), (i, 1, n)) == 2**n * Product(a(i), (i, 1, n))
|
| 240 |
+
# issue 4810
|
| 241 |
+
assert product(2**i, (i, 1, n)) == 2**(n*(n + 1)/2)
|
| 242 |
+
k, m = symbols('k m', integer=True)
|
| 243 |
+
assert product(2**i, (i, k, m)) == 2**(-k**2/2 + k/2 + m**2/2 + m/2)
|
| 244 |
+
n = Symbol('n', negative=True, integer=True)
|
| 245 |
+
p = Symbol('p', positive=True, integer=True)
|
| 246 |
+
assert product(2**i, (i, n, p)) == 2**(-n**2/2 + n/2 + p**2/2 + p/2)
|
| 247 |
+
assert product(2**i, (i, p, n)) == 2**(n**2/2 + n/2 - p**2/2 + p/2)
|
| 248 |
+
|
| 249 |
+
|
| 250 |
+
def test_product_pow():
|
| 251 |
+
# issue 4817
|
| 252 |
+
assert product(2**f(k), (k, 1, n)) == 2**Sum(f(k), (k, 1, n))
|
| 253 |
+
assert product(2**(2*f(k)), (k, 1, n)) == 2**Sum(2*f(k), (k, 1, n))
|
| 254 |
+
|
| 255 |
+
|
| 256 |
+
def test_infinite_product():
|
| 257 |
+
# issue 5737
|
| 258 |
+
assert isinstance(Product(2**(1/factorial(n)), (n, 0, oo)), Product)
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
def test_conjugate_transpose():
|
| 262 |
+
p = Product(x**k, (k, 1, 3))
|
| 263 |
+
assert p.adjoint().doit() == p.doit().adjoint()
|
| 264 |
+
assert p.conjugate().doit() == p.doit().conjugate()
|
| 265 |
+
assert p.transpose().doit() == p.doit().transpose()
|
| 266 |
+
|
| 267 |
+
A, B = symbols("A B", commutative=False)
|
| 268 |
+
p = Product(A*B**k, (k, 1, 3))
|
| 269 |
+
assert p.adjoint().doit() == p.doit().adjoint()
|
| 270 |
+
assert p.conjugate().doit() == p.doit().conjugate()
|
| 271 |
+
assert p.transpose().doit() == p.doit().transpose()
|
| 272 |
+
|
| 273 |
+
p = Product(B**k*A, (k, 1, 3))
|
| 274 |
+
assert p.adjoint().doit() == p.doit().adjoint()
|
| 275 |
+
assert p.conjugate().doit() == p.doit().conjugate()
|
| 276 |
+
assert p.transpose().doit() == p.doit().transpose()
|
| 277 |
+
|
| 278 |
+
|
| 279 |
+
def test_simplify_prod():
|
| 280 |
+
y, t, b, c, v, d = symbols('y, t, b, c, v, d', integer = True)
|
| 281 |
+
|
| 282 |
+
_simplify = lambda e: simplify(e, doit=False)
|
| 283 |
+
assert _simplify(Product(x*y, (x, n, m), (y, a, k)) * \
|
| 284 |
+
Product(y, (x, n, m), (y, a, k))) == \
|
| 285 |
+
Product(x*y**2, (x, n, m), (y, a, k))
|
| 286 |
+
assert _simplify(3 * y* Product(x, (x, n, m)) * Product(x, (x, m + 1, a))) \
|
| 287 |
+
== 3 * y * Product(x, (x, n, a))
|
| 288 |
+
assert _simplify(Product(x, (x, k + 1, a)) * Product(x, (x, n, k))) == \
|
| 289 |
+
Product(x, (x, n, a))
|
| 290 |
+
assert _simplify(Product(x, (x, k + 1, a)) * Product(x + 1, (x, n, k))) == \
|
| 291 |
+
Product(x, (x, k + 1, a)) * Product(x + 1, (x, n, k))
|
| 292 |
+
assert _simplify(Product(x, (t, a, b)) * Product(y, (t, a, b)) * \
|
| 293 |
+
Product(x, (t, b+1, c))) == Product(x*y, (t, a, b)) * \
|
| 294 |
+
Product(x, (t, b+1, c))
|
| 295 |
+
assert _simplify(Product(x, (t, a, b)) * Product(x, (t, b+1, c)) * \
|
| 296 |
+
Product(y, (t, a, b))) == Product(x*y, (t, a, b)) * \
|
| 297 |
+
Product(x, (t, b+1, c))
|
| 298 |
+
assert _simplify(Product(sin(t)**2 + cos(t)**2 + 1, (t, a, b))) == \
|
| 299 |
+
Product(2, (t, a, b))
|
| 300 |
+
assert _simplify(Product(sin(t)**2 + cos(t)**2 - 1, (t, a, b))) == \
|
| 301 |
+
Product(0, (t, a, b))
|
| 302 |
+
assert _simplify(Product(v*Product(sin(t)**2 + cos(t)**2, (t, a, b)),
|
| 303 |
+
(v, c, d))) == Product(v*Product(1, (t, a, b)), (v, c, d))
|
| 304 |
+
|
| 305 |
+
|
| 306 |
+
def test_change_index():
|
| 307 |
+
b, y, c, d, z = symbols('b, y, c, d, z', integer = True)
|
| 308 |
+
|
| 309 |
+
assert Product(x, (x, a, b)).change_index(x, x + 1, y) == \
|
| 310 |
+
Product(y - 1, (y, a + 1, b + 1))
|
| 311 |
+
assert Product(x**2, (x, a, b)).change_index(x, x - 1) == \
|
| 312 |
+
Product((x + 1)**2, (x, a - 1, b - 1))
|
| 313 |
+
assert Product(x**2, (x, a, b)).change_index(x, -x, y) == \
|
| 314 |
+
Product((-y)**2, (y, -b, -a))
|
| 315 |
+
assert Product(x, (x, a, b)).change_index(x, -x - 1) == \
|
| 316 |
+
Product(-x - 1, (x, - b - 1, -a - 1))
|
| 317 |
+
assert Product(x*y, (x, a, b), (y, c, d)).change_index(x, x - 1, z) == \
|
| 318 |
+
Product((z + 1)*y, (z, a - 1, b - 1), (y, c, d))
|
| 319 |
+
|
| 320 |
+
|
| 321 |
+
def test_reorder():
|
| 322 |
+
b, y, c, d, z = symbols('b, y, c, d, z', integer = True)
|
| 323 |
+
|
| 324 |
+
assert Product(x*y, (x, a, b), (y, c, d)).reorder((0, 1)) == \
|
| 325 |
+
Product(x*y, (y, c, d), (x, a, b))
|
| 326 |
+
assert Product(x, (x, a, b), (x, c, d)).reorder((0, 1)) == \
|
| 327 |
+
Product(x, (x, c, d), (x, a, b))
|
| 328 |
+
assert Product(x*y + z, (x, a, b), (z, m, n), (y, c, d)).reorder(\
|
| 329 |
+
(2, 0), (0, 1)) == Product(x*y + z, (z, m, n), (y, c, d), (x, a, b))
|
| 330 |
+
assert Product(x*y*z, (x, a, b), (y, c, d), (z, m, n)).reorder(\
|
| 331 |
+
(0, 1), (1, 2), (0, 2)) == \
|
| 332 |
+
Product(x*y*z, (x, a, b), (z, m, n), (y, c, d))
|
| 333 |
+
assert Product(x*y*z, (x, a, b), (y, c, d), (z, m, n)).reorder(\
|
| 334 |
+
(x, y), (y, z), (x, z)) == \
|
| 335 |
+
Product(x*y*z, (x, a, b), (z, m, n), (y, c, d))
|
| 336 |
+
assert Product(x*y, (x, a, b), (y, c, d)).reorder((x, 1)) == \
|
| 337 |
+
Product(x*y, (y, c, d), (x, a, b))
|
| 338 |
+
assert Product(x*y, (x, a, b), (y, c, d)).reorder((y, x)) == \
|
| 339 |
+
Product(x*y, (y, c, d), (x, a, b))
|
| 340 |
+
|
| 341 |
+
|
| 342 |
+
def test_Product_is_convergent():
|
| 343 |
+
assert Product(1/n**2, (n, 1, oo)).is_convergent() is S.false
|
| 344 |
+
assert Product(exp(1/n**2), (n, 1, oo)).is_convergent() is S.true
|
| 345 |
+
assert Product(1/n, (n, 1, oo)).is_convergent() is S.false
|
| 346 |
+
assert Product(1 + 1/n, (n, 1, oo)).is_convergent() is S.false
|
| 347 |
+
assert Product(1 + 1/n**2, (n, 1, oo)).is_convergent() is S.true
|
| 348 |
+
|
| 349 |
+
|
| 350 |
+
def test_reverse_order():
|
| 351 |
+
x, y, a, b, c, d= symbols('x, y, a, b, c, d', integer = True)
|
| 352 |
+
|
| 353 |
+
assert Product(x, (x, 0, 3)).reverse_order(0) == Product(1/x, (x, 4, -1))
|
| 354 |
+
assert Product(x*y, (x, 1, 5), (y, 0, 6)).reverse_order(0, 1) == \
|
| 355 |
+
Product(x*y, (x, 6, 0), (y, 7, -1))
|
| 356 |
+
assert Product(x, (x, 1, 2)).reverse_order(0) == Product(1/x, (x, 3, 0))
|
| 357 |
+
assert Product(x, (x, 1, 3)).reverse_order(0) == Product(1/x, (x, 4, 0))
|
| 358 |
+
assert Product(x, (x, 1, a)).reverse_order(0) == Product(1/x, (x, a + 1, 0))
|
| 359 |
+
assert Product(x, (x, a, 5)).reverse_order(0) == Product(1/x, (x, 6, a - 1))
|
| 360 |
+
assert Product(x, (x, a + 1, a + 5)).reverse_order(0) == \
|
| 361 |
+
Product(1/x, (x, a + 6, a))
|
| 362 |
+
assert Product(x, (x, a + 1, a + 2)).reverse_order(0) == \
|
| 363 |
+
Product(1/x, (x, a + 3, a))
|
| 364 |
+
assert Product(x, (x, a + 1, a + 1)).reverse_order(0) == \
|
| 365 |
+
Product(1/x, (x, a + 2, a))
|
| 366 |
+
assert Product(x, (x, a, b)).reverse_order(0) == Product(1/x, (x, b + 1, a - 1))
|
| 367 |
+
assert Product(x, (x, a, b)).reverse_order(x) == Product(1/x, (x, b + 1, a - 1))
|
| 368 |
+
assert Product(x*y, (x, a, b), (y, 2, 5)).reverse_order(x, 1) == \
|
| 369 |
+
Product(x*y, (x, b + 1, a - 1), (y, 6, 1))
|
| 370 |
+
assert Product(x*y, (x, a, b), (y, 2, 5)).reverse_order(y, x) == \
|
| 371 |
+
Product(x*y, (x, b + 1, a - 1), (y, 6, 1))
|
| 372 |
+
|
| 373 |
+
|
| 374 |
+
def test_issue_9983():
|
| 375 |
+
n = Symbol('n', integer=True, positive=True)
|
| 376 |
+
p = Product(1 + 1/n**Rational(2, 3), (n, 1, oo))
|
| 377 |
+
assert p.is_convergent() is S.false
|
| 378 |
+
assert product(1 + 1/n**Rational(2, 3), (n, 1, oo)) == p.doit()
|
| 379 |
+
|
| 380 |
+
|
| 381 |
+
def test_issue_13546():
|
| 382 |
+
n = Symbol('n')
|
| 383 |
+
k = Symbol('k')
|
| 384 |
+
p = Product(n + 1 / 2**k, (k, 0, n-1)).doit()
|
| 385 |
+
assert p.subs(n, 2).doit() == Rational(15, 2)
|
| 386 |
+
|
| 387 |
+
|
| 388 |
+
def test_issue_14036():
|
| 389 |
+
a, n = symbols('a n')
|
| 390 |
+
assert product(1 - a**2 / (n*pi)**2, [n, 1, oo]) != 0
|
| 391 |
+
|
| 392 |
+
|
| 393 |
+
def test_rewrite_Sum():
|
| 394 |
+
assert Product(1 - S.Half**2/k**2, (k, 1, oo)).rewrite(Sum) == \
|
| 395 |
+
exp(Sum(log(1 - 1/(4*k**2)), (k, 1, oo)))
|
| 396 |
+
|
| 397 |
+
|
| 398 |
+
def test_KroneckerDelta_Product():
|
| 399 |
+
y = Symbol('y')
|
| 400 |
+
assert Product(x*KroneckerDelta(x, y), (x, 0, 1)).doit() == 0
|
| 401 |
+
|
| 402 |
+
|
| 403 |
+
def test_issue_20848():
|
| 404 |
+
_i = Dummy('i')
|
| 405 |
+
t, y, z = symbols('t y z')
|
| 406 |
+
assert diff(Product(x, (y, 1, z)), x).as_dummy() == Sum(Product(x, (y, 1, _i - 1))*Product(x, (y, _i + 1, z)), (_i, 1, z)).as_dummy()
|
| 407 |
+
assert diff(Product(x, (y, 1, z)), x).doit() == x**(z - 1)*z
|
| 408 |
+
assert diff(Product(x, (y, x, z)), x) == Derivative(Product(x, (y, x, z)), x)
|
| 409 |
+
assert diff(Product(t, (x, 1, z)), x) == S(0)
|
| 410 |
+
assert Product(sin(n*x), (n, -1, 1)).diff(x).doit() == S(0)
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/concrete/tests/test_sums_products.py
ADDED
|
@@ -0,0 +1,1676 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from math import prod
|
| 2 |
+
|
| 3 |
+
from sympy.concrete.expr_with_intlimits import ReorderError
|
| 4 |
+
from sympy.concrete.products import (Product, product)
|
| 5 |
+
from sympy.concrete.summations import (Sum, summation, telescopic,
|
| 6 |
+
eval_sum_residue, _dummy_with_inherited_properties_concrete)
|
| 7 |
+
from sympy.core.function import (Derivative, Function)
|
| 8 |
+
from sympy.core import (Catalan, EulerGamma)
|
| 9 |
+
from sympy.core.facts import InconsistentAssumptions
|
| 10 |
+
from sympy.core.mod import Mod
|
| 11 |
+
from sympy.core.numbers import (E, I, Rational, nan, oo, pi)
|
| 12 |
+
from sympy.core.relational import Eq, Ne
|
| 13 |
+
from sympy.core.numbers import Float
|
| 14 |
+
from sympy.core.singleton import S
|
| 15 |
+
from sympy.core.symbol import (Dummy, Symbol, symbols)
|
| 16 |
+
from sympy.core.sympify import sympify
|
| 17 |
+
from sympy.functions.combinatorial.factorials import (rf, binomial, factorial)
|
| 18 |
+
from sympy.functions.combinatorial.numbers import harmonic
|
| 19 |
+
from sympy.functions.elementary.complexes import Abs, re
|
| 20 |
+
from sympy.functions.elementary.exponential import (exp, log)
|
| 21 |
+
from sympy.functions.elementary.hyperbolic import (sinh, tanh)
|
| 22 |
+
from sympy.functions.elementary.integers import floor
|
| 23 |
+
from sympy.functions.elementary.miscellaneous import sqrt
|
| 24 |
+
from sympy.functions.elementary.piecewise import Piecewise
|
| 25 |
+
from sympy.functions.elementary.trigonometric import (cos, sin, atan)
|
| 26 |
+
from sympy.functions.special.gamma_functions import (gamma, lowergamma)
|
| 27 |
+
from sympy.functions.special.tensor_functions import KroneckerDelta
|
| 28 |
+
from sympy.functions.special.zeta_functions import zeta
|
| 29 |
+
from sympy.integrals.integrals import Integral
|
| 30 |
+
from sympy.logic.boolalg import And, Or
|
| 31 |
+
from sympy.matrices.expressions.matexpr import MatrixSymbol
|
| 32 |
+
from sympy.matrices.expressions.special import Identity
|
| 33 |
+
from sympy.matrices import (Matrix, SparseMatrix,
|
| 34 |
+
ImmutableDenseMatrix, ImmutableSparseMatrix, diag)
|
| 35 |
+
from sympy.sets.contains import Contains
|
| 36 |
+
from sympy.sets.fancysets import Range
|
| 37 |
+
from sympy.sets.sets import Interval
|
| 38 |
+
from sympy.simplify.combsimp import combsimp
|
| 39 |
+
from sympy.simplify.simplify import simplify
|
| 40 |
+
from sympy.tensor.indexed import (Idx, Indexed, IndexedBase)
|
| 41 |
+
from sympy.testing.pytest import XFAIL, raises, slow
|
| 42 |
+
from sympy.abc import a, b, c, d, k, m, x, y, z
|
| 43 |
+
|
| 44 |
+
n = Symbol('n', integer=True)
|
| 45 |
+
f, g = symbols('f g', cls=Function)
|
| 46 |
+
|
| 47 |
+
def test_karr_convention():
|
| 48 |
+
# Test the Karr summation convention that we want to hold.
|
| 49 |
+
# See his paper "Summation in Finite Terms" for a detailed
|
| 50 |
+
# reasoning why we really want exactly this definition.
|
| 51 |
+
# The convention is described on page 309 and essentially
|
| 52 |
+
# in section 1.4, definition 3:
|
| 53 |
+
#
|
| 54 |
+
# \sum_{m <= i < n} f(i) 'has the obvious meaning' for m < n
|
| 55 |
+
# \sum_{m <= i < n} f(i) = 0 for m = n
|
| 56 |
+
# \sum_{m <= i < n} f(i) = - \sum_{n <= i < m} f(i) for m > n
|
| 57 |
+
#
|
| 58 |
+
# It is important to note that he defines all sums with
|
| 59 |
+
# the upper limit being *exclusive*.
|
| 60 |
+
# In contrast, SymPy and the usual mathematical notation has:
|
| 61 |
+
#
|
| 62 |
+
# sum_{i = a}^b f(i) = f(a) + f(a+1) + ... + f(b-1) + f(b)
|
| 63 |
+
#
|
| 64 |
+
# with the upper limit *inclusive*. So translating between
|
| 65 |
+
# the two we find that:
|
| 66 |
+
#
|
| 67 |
+
# \sum_{m <= i < n} f(i) = \sum_{i = m}^{n-1} f(i)
|
| 68 |
+
#
|
| 69 |
+
# where we intentionally used two different ways to typeset the
|
| 70 |
+
# sum and its limits.
|
| 71 |
+
|
| 72 |
+
i = Symbol("i", integer=True)
|
| 73 |
+
k = Symbol("k", integer=True)
|
| 74 |
+
j = Symbol("j", integer=True)
|
| 75 |
+
|
| 76 |
+
# A simple example with a concrete summand and symbolic limits.
|
| 77 |
+
|
| 78 |
+
# The normal sum: m = k and n = k + j and therefore m < n:
|
| 79 |
+
m = k
|
| 80 |
+
n = k + j
|
| 81 |
+
|
| 82 |
+
a = m
|
| 83 |
+
b = n - 1
|
| 84 |
+
S1 = Sum(i**2, (i, a, b)).doit()
|
| 85 |
+
|
| 86 |
+
# The reversed sum: m = k + j and n = k and therefore m > n:
|
| 87 |
+
m = k + j
|
| 88 |
+
n = k
|
| 89 |
+
|
| 90 |
+
a = m
|
| 91 |
+
b = n - 1
|
| 92 |
+
S2 = Sum(i**2, (i, a, b)).doit()
|
| 93 |
+
|
| 94 |
+
assert simplify(S1 + S2) == 0
|
| 95 |
+
|
| 96 |
+
# Test the empty sum: m = k and n = k and therefore m = n:
|
| 97 |
+
m = k
|
| 98 |
+
n = k
|
| 99 |
+
|
| 100 |
+
a = m
|
| 101 |
+
b = n - 1
|
| 102 |
+
Sz = Sum(i**2, (i, a, b)).doit()
|
| 103 |
+
|
| 104 |
+
assert Sz == 0
|
| 105 |
+
|
| 106 |
+
# Another example this time with an unspecified summand and
|
| 107 |
+
# numeric limits. (We can not do both tests in the same example.)
|
| 108 |
+
|
| 109 |
+
# The normal sum with m < n:
|
| 110 |
+
m = 2
|
| 111 |
+
n = 11
|
| 112 |
+
|
| 113 |
+
a = m
|
| 114 |
+
b = n - 1
|
| 115 |
+
S1 = Sum(f(i), (i, a, b)).doit()
|
| 116 |
+
|
| 117 |
+
# The reversed sum with m > n:
|
| 118 |
+
m = 11
|
| 119 |
+
n = 2
|
| 120 |
+
|
| 121 |
+
a = m
|
| 122 |
+
b = n - 1
|
| 123 |
+
S2 = Sum(f(i), (i, a, b)).doit()
|
| 124 |
+
|
| 125 |
+
assert simplify(S1 + S2) == 0
|
| 126 |
+
|
| 127 |
+
# Test the empty sum with m = n:
|
| 128 |
+
m = 5
|
| 129 |
+
n = 5
|
| 130 |
+
|
| 131 |
+
a = m
|
| 132 |
+
b = n - 1
|
| 133 |
+
Sz = Sum(f(i), (i, a, b)).doit()
|
| 134 |
+
|
| 135 |
+
assert Sz == 0
|
| 136 |
+
|
| 137 |
+
e = Piecewise((exp(-i), Mod(i, 2) > 0), (0, True))
|
| 138 |
+
s = Sum(e, (i, 0, 11))
|
| 139 |
+
assert s.n(3) == s.doit().n(3)
|
| 140 |
+
|
| 141 |
+
# issue #27893
|
| 142 |
+
n = Symbol('n', integer=True)
|
| 143 |
+
assert Sum(1/(x**2 + 1), (x, oo, 0)).doit(deep=False) == Rational(-1, 2) + pi / (2 * tanh(pi))
|
| 144 |
+
assert Sum(c**x/factorial(x), (x, oo, 0)).doit(deep=False).simplify() == exp(c) - 1 # exponential series
|
| 145 |
+
assert Sum((-1)**x/x, (x, oo,0)).doit() == -log(2) # alternating harmnic series
|
| 146 |
+
assert Sum((1/2)**x,(x, oo, -1)).doit() == S(2) # geometric series
|
| 147 |
+
assert Sum(1/x, (x, oo, 0)).doit() == oo # harmonic series, divergent
|
| 148 |
+
assert Sum((-1)**x/(2*x+1), (x, oo, -1)).doit() == pi/4 # leibniz series
|
| 149 |
+
assert Sum((((-1)**x) * c**(2*x+1)) / factorial(2*x+1), (x, oo, -1)).doit() == sin(c) # sinusoidal series
|
| 150 |
+
assert Sum((((-1)**x) * c**(2*x+1)) / (2*x+1), (x, 0, oo)).doit() \
|
| 151 |
+
== Piecewise((atan(c), Ne(c**2, -1) & (Abs(c**2) <= 1)), \
|
| 152 |
+
(Sum((-1)**x*c**(2*x + 1)/(2*x + 1), (x, 0, oo)), True)) # arctangent series
|
| 153 |
+
assert Sum(binomial(n, x) * c**x, (x, 0, oo)).doit() \
|
| 154 |
+
== Piecewise(((c + 1)**n, \
|
| 155 |
+
((n <= -1) & (Abs(c) < 1)) \
|
| 156 |
+
| ((n > 0) & (Abs(c) <= 1)) \
|
| 157 |
+
| ((n <= 0) & (n > -1) & Ne(c, -1) & (Abs(c) <= 1))), \
|
| 158 |
+
(Sum(c**x*binomial(n, x), (x, 0, oo)), True)) # binomial series
|
| 159 |
+
assert Sum(1/x**n, (x, oo, 0)).doit() \
|
| 160 |
+
== Piecewise((zeta(n), n > 1), (Sum(x**(-n), (x, oo, 0)), True)) # Euler's zeta function
|
| 161 |
+
|
| 162 |
+
def test_karr_proposition_2a():
|
| 163 |
+
# Test Karr, page 309, proposition 2, part a
|
| 164 |
+
i = Symbol("i", integer=True)
|
| 165 |
+
u = Symbol("u", integer=True)
|
| 166 |
+
v = Symbol("v", integer=True)
|
| 167 |
+
|
| 168 |
+
def test_the_sum(m, n):
|
| 169 |
+
# g
|
| 170 |
+
g = i**3 + 2*i**2 - 3*i
|
| 171 |
+
# f = Delta g
|
| 172 |
+
f = simplify(g.subs(i, i+1) - g)
|
| 173 |
+
# The sum
|
| 174 |
+
a = m
|
| 175 |
+
b = n - 1
|
| 176 |
+
S = Sum(f, (i, a, b)).doit()
|
| 177 |
+
# Test if Sum_{m <= i < n} f(i) = g(n) - g(m)
|
| 178 |
+
assert simplify(S - (g.subs(i, n) - g.subs(i, m))) == 0
|
| 179 |
+
|
| 180 |
+
# m < n
|
| 181 |
+
test_the_sum(u, u+v)
|
| 182 |
+
# m = n
|
| 183 |
+
test_the_sum(u, u )
|
| 184 |
+
# m > n
|
| 185 |
+
test_the_sum(u+v, u )
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
def test_karr_proposition_2b():
|
| 189 |
+
# Test Karr, page 309, proposition 2, part b
|
| 190 |
+
i = Symbol("i", integer=True)
|
| 191 |
+
u = Symbol("u", integer=True)
|
| 192 |
+
v = Symbol("v", integer=True)
|
| 193 |
+
w = Symbol("w", integer=True)
|
| 194 |
+
|
| 195 |
+
def test_the_sum(l, n, m):
|
| 196 |
+
# Summand
|
| 197 |
+
s = i**3
|
| 198 |
+
# First sum
|
| 199 |
+
a = l
|
| 200 |
+
b = n - 1
|
| 201 |
+
S1 = Sum(s, (i, a, b)).doit()
|
| 202 |
+
# Second sum
|
| 203 |
+
a = l
|
| 204 |
+
b = m - 1
|
| 205 |
+
S2 = Sum(s, (i, a, b)).doit()
|
| 206 |
+
# Third sum
|
| 207 |
+
a = m
|
| 208 |
+
b = n - 1
|
| 209 |
+
S3 = Sum(s, (i, a, b)).doit()
|
| 210 |
+
# Test if S1 = S2 + S3 as required
|
| 211 |
+
assert S1 - (S2 + S3) == 0
|
| 212 |
+
|
| 213 |
+
# l < m < n
|
| 214 |
+
test_the_sum(u, u+v, u+v+w)
|
| 215 |
+
# l < m = n
|
| 216 |
+
test_the_sum(u, u+v, u+v )
|
| 217 |
+
# l < m > n
|
| 218 |
+
test_the_sum(u, u+v+w, v )
|
| 219 |
+
# l = m < n
|
| 220 |
+
test_the_sum(u, u, u+v )
|
| 221 |
+
# l = m = n
|
| 222 |
+
test_the_sum(u, u, u )
|
| 223 |
+
# l = m > n
|
| 224 |
+
test_the_sum(u+v, u+v, u )
|
| 225 |
+
# l > m < n
|
| 226 |
+
test_the_sum(u+v, u, u+w )
|
| 227 |
+
# l > m = n
|
| 228 |
+
test_the_sum(u+v, u, u )
|
| 229 |
+
# l > m > n
|
| 230 |
+
test_the_sum(u+v+w, u+v, u )
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
def test_arithmetic_sums():
|
| 234 |
+
assert summation(1, (n, a, b)) == b - a + 1
|
| 235 |
+
assert Sum(S.NaN, (n, a, b)) is S.NaN
|
| 236 |
+
assert Sum(x, (n, a, a)).doit() == x
|
| 237 |
+
assert Sum(x, (x, a, a)).doit() == a
|
| 238 |
+
assert Sum(x, (n, 1, a)).doit() == a*x
|
| 239 |
+
assert Sum(x, (x, Range(1, 11))).doit() == 55
|
| 240 |
+
assert Sum(x, (x, Range(1, 11, 2))).doit() == 25
|
| 241 |
+
assert Sum(x, (x, Range(1, 10, 2))) == Sum(x, (x, Range(9, 0, -2)))
|
| 242 |
+
lo, hi = 1, 2
|
| 243 |
+
s1 = Sum(n, (n, lo, hi))
|
| 244 |
+
s2 = Sum(n, (n, hi, lo))
|
| 245 |
+
assert s1 != s2
|
| 246 |
+
assert s1.doit() == 3 and s2.doit() == 0
|
| 247 |
+
lo, hi = x, x + 1
|
| 248 |
+
s1 = Sum(n, (n, lo, hi))
|
| 249 |
+
s2 = Sum(n, (n, hi, lo))
|
| 250 |
+
assert s1 != s2
|
| 251 |
+
assert s1.doit() == 2*x + 1 and s2.doit() == 0
|
| 252 |
+
assert Sum(Integral(x, (x, 1, y)) + x, (x, 1, 2)).doit() == \
|
| 253 |
+
y**2 + 2
|
| 254 |
+
assert summation(1, (n, 1, 10)) == 10
|
| 255 |
+
assert summation(2*n, (n, 0, 10**10)) == 100000000010000000000
|
| 256 |
+
assert summation(4*n*m, (n, a, 1), (m, 1, d)).expand() == \
|
| 257 |
+
2*d + 2*d**2 + a*d + a*d**2 - d*a**2 - a**2*d**2
|
| 258 |
+
assert summation(cos(n), (n, -2, 1)) == cos(-2) + cos(-1) + cos(0) + cos(1)
|
| 259 |
+
assert summation(cos(n), (n, x, x + 2)) == cos(x) + cos(x + 1) + cos(x + 2)
|
| 260 |
+
assert isinstance(summation(cos(n), (n, x, x + S.Half)), Sum)
|
| 261 |
+
assert summation(k, (k, 0, oo)) is oo
|
| 262 |
+
assert summation(k, (k, Range(1, 11))) == 55
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
def test_polynomial_sums():
|
| 266 |
+
assert summation(n**2, (n, 3, 8)) == 199
|
| 267 |
+
assert summation(n, (n, a, b)) == \
|
| 268 |
+
((a + b)*(b - a + 1)/2).expand()
|
| 269 |
+
assert summation(n**2, (n, 1, b)) == \
|
| 270 |
+
((2*b**3 + 3*b**2 + b)/6).expand()
|
| 271 |
+
assert summation(n**3, (n, 1, b)) == \
|
| 272 |
+
((b**4 + 2*b**3 + b**2)/4).expand()
|
| 273 |
+
assert summation(n**6, (n, 1, b)) == \
|
| 274 |
+
((6*b**7 + 21*b**6 + 21*b**5 - 7*b**3 + b)/42).expand()
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
def test_geometric_sums():
|
| 278 |
+
assert summation(pi**n, (n, 0, b)) == (1 - pi**(b + 1)) / (1 - pi)
|
| 279 |
+
assert summation(2 * 3**n, (n, 0, b)) == 3**(b + 1) - 1
|
| 280 |
+
assert summation(S.Half**n, (n, 1, oo)) == 1
|
| 281 |
+
assert summation(2**n, (n, 0, b)) == 2**(b + 1) - 1
|
| 282 |
+
assert summation(2**n, (n, 1, oo)) is oo
|
| 283 |
+
assert summation(2**(-n), (n, 1, oo)) == 1
|
| 284 |
+
assert summation(3**(-n), (n, 4, oo)) == Rational(1, 54)
|
| 285 |
+
assert summation(2**(-4*n + 3), (n, 1, oo)) == Rational(8, 15)
|
| 286 |
+
assert summation(2**(n + 1), (n, 1, b)).expand() == 4*(2**b - 1)
|
| 287 |
+
|
| 288 |
+
# issue 6664:
|
| 289 |
+
assert summation(x**n, (n, 0, oo)) == \
|
| 290 |
+
Piecewise((1/(-x + 1), Abs(x) < 1), (Sum(x**n, (n, 0, oo)), True))
|
| 291 |
+
|
| 292 |
+
assert summation(-2**n, (n, 0, oo)) is -oo
|
| 293 |
+
assert summation(I**n, (n, 0, oo)) == Sum(I**n, (n, 0, oo))
|
| 294 |
+
|
| 295 |
+
# issue 6802:
|
| 296 |
+
assert summation((-1)**(2*x + 2), (x, 0, n)) == n + 1
|
| 297 |
+
assert summation((-2)**(2*x + 2), (x, 0, n)) == 4*4**(n + 1)/S(3) - Rational(4, 3)
|
| 298 |
+
assert summation((-1)**x, (x, 0, n)) == -(-1)**(n + 1)/S(2) + S.Half
|
| 299 |
+
assert summation(y**x, (x, a, b)) == \
|
| 300 |
+
Piecewise((-a + b + 1, Eq(y, 1)), ((y**a - y**(b + 1))/(-y + 1), True))
|
| 301 |
+
assert summation((-2)**(y*x + 2), (x, 0, n)) == \
|
| 302 |
+
4*Piecewise((n + 1, Eq((-2)**y, 1)),
|
| 303 |
+
((-(-2)**(y*(n + 1)) + 1)/(-(-2)**y + 1), True))
|
| 304 |
+
|
| 305 |
+
# issue 8251:
|
| 306 |
+
assert summation((1/(n + 1)**2)*n**2, (n, 0, oo)) is oo
|
| 307 |
+
|
| 308 |
+
#issue 9908:
|
| 309 |
+
assert Sum(1/(n**3 - 1), (n, -oo, -2)).doit() == summation(1/(n**3 - 1), (n, -oo, -2))
|
| 310 |
+
|
| 311 |
+
#issue 11642:
|
| 312 |
+
result = Sum(0.5**n, (n, 1, oo)).doit()
|
| 313 |
+
assert result == 1.0
|
| 314 |
+
assert result.is_Float
|
| 315 |
+
|
| 316 |
+
result = Sum(0.25**n, (n, 1, oo)).doit()
|
| 317 |
+
assert result == 1/3.
|
| 318 |
+
assert result.is_Float
|
| 319 |
+
|
| 320 |
+
result = Sum(0.99999**n, (n, 1, oo)).doit()
|
| 321 |
+
assert result == 99999.0
|
| 322 |
+
assert result.is_Float
|
| 323 |
+
|
| 324 |
+
result = Sum(S.Half**n, (n, 1, oo)).doit()
|
| 325 |
+
assert result == 1
|
| 326 |
+
assert not result.is_Float
|
| 327 |
+
|
| 328 |
+
result = Sum(Rational(3, 5)**n, (n, 1, oo)).doit()
|
| 329 |
+
assert result == Rational(3, 2)
|
| 330 |
+
assert not result.is_Float
|
| 331 |
+
|
| 332 |
+
assert Sum(1.0**n, (n, 1, oo)).doit() is oo
|
| 333 |
+
assert Sum(2.43**n, (n, 1, oo)).doit() is oo
|
| 334 |
+
|
| 335 |
+
# Issue 13979
|
| 336 |
+
i, k, q = symbols('i k q', integer=True)
|
| 337 |
+
result = summation(
|
| 338 |
+
exp(-2*I*pi*k*i/n) * exp(2*I*pi*q*i/n) / n, (i, 0, n - 1)
|
| 339 |
+
)
|
| 340 |
+
assert result.simplify() == Piecewise(
|
| 341 |
+
(1, Eq(exp(-2*I*pi*(k - q)/n), 1)), (0, True)
|
| 342 |
+
)
|
| 343 |
+
|
| 344 |
+
#Issue 23491
|
| 345 |
+
assert Sum(1/(n**2 + 1), (n, 1, oo)).doit() == S(-1)/2 + pi/(2*tanh(pi))
|
| 346 |
+
|
| 347 |
+
def test_harmonic_sums():
|
| 348 |
+
assert summation(1/k, (k, 0, n)) == Sum(1/k, (k, 0, n))
|
| 349 |
+
assert summation(1/k, (k, 1, n)) == harmonic(n)
|
| 350 |
+
assert summation(n/k, (k, 1, n)) == n*harmonic(n)
|
| 351 |
+
assert summation(1/k, (k, 5, n)) == harmonic(n) - harmonic(4)
|
| 352 |
+
|
| 353 |
+
|
| 354 |
+
def test_composite_sums():
|
| 355 |
+
f = S.Half*(7 - 6*n + Rational(1, 7)*n**3)
|
| 356 |
+
s = summation(f, (n, a, b))
|
| 357 |
+
assert not isinstance(s, Sum)
|
| 358 |
+
A = 0
|
| 359 |
+
for i in range(-3, 5):
|
| 360 |
+
A += f.subs(n, i)
|
| 361 |
+
B = s.subs(a, -3).subs(b, 4)
|
| 362 |
+
assert A == B
|
| 363 |
+
|
| 364 |
+
|
| 365 |
+
def test_hypergeometric_sums():
|
| 366 |
+
assert summation(
|
| 367 |
+
binomial(2*k, k)/4**k, (k, 0, n)) == (1 + 2*n)*binomial(2*n, n)/4**n
|
| 368 |
+
assert summation(binomial(2*k, k)/5**k, (k, -oo, oo)) == sqrt(5)
|
| 369 |
+
|
| 370 |
+
|
| 371 |
+
def test_other_sums():
|
| 372 |
+
f = m**2 + m*exp(m)
|
| 373 |
+
g = 3*exp(Rational(3, 2))/2 + exp(S.Half)/2 - exp(Rational(-1, 2))/2 - 3*exp(Rational(-3, 2))/2 + 5
|
| 374 |
+
|
| 375 |
+
assert summation(f, (m, Rational(-3, 2), Rational(3, 2))) == g
|
| 376 |
+
assert summation(f, (m, -1.5, 1.5)).evalf().epsilon_eq(g.evalf(), 1e-10)
|
| 377 |
+
|
| 378 |
+
fac = factorial
|
| 379 |
+
|
| 380 |
+
|
| 381 |
+
def NS(e, n=15, **options):
|
| 382 |
+
return str(sympify(e).evalf(n, **options))
|
| 383 |
+
|
| 384 |
+
|
| 385 |
+
def test_evalf_fast_series():
|
| 386 |
+
# Euler transformed series for sqrt(1+x)
|
| 387 |
+
assert NS(Sum(
|
| 388 |
+
fac(2*n + 1)/fac(n)**2/2**(3*n + 1), (n, 0, oo)), 100) == NS(sqrt(2), 100)
|
| 389 |
+
|
| 390 |
+
# Some series for exp(1)
|
| 391 |
+
estr = NS(E, 100)
|
| 392 |
+
assert NS(Sum(1/fac(n), (n, 0, oo)), 100) == estr
|
| 393 |
+
assert NS(1/Sum((1 - 2*n)/fac(2*n), (n, 0, oo)), 100) == estr
|
| 394 |
+
assert NS(Sum((2*n + 1)/fac(2*n), (n, 0, oo)), 100) == estr
|
| 395 |
+
assert NS(Sum((4*n + 3)/2**(2*n + 1)/fac(2*n + 1), (n, 0, oo))**2, 100) == estr
|
| 396 |
+
|
| 397 |
+
pistr = NS(pi, 100)
|
| 398 |
+
# Ramanujan series for pi
|
| 399 |
+
assert NS(9801/sqrt(8)/Sum(fac(
|
| 400 |
+
4*n)*(1103 + 26390*n)/fac(n)**4/396**(4*n), (n, 0, oo)), 100) == pistr
|
| 401 |
+
assert NS(1/Sum(
|
| 402 |
+
binomial(2*n, n)**3 * (42*n + 5)/2**(12*n + 4), (n, 0, oo)), 100) == pistr
|
| 403 |
+
# Machin's formula for pi
|
| 404 |
+
assert NS(16*Sum((-1)**n/(2*n + 1)/5**(2*n + 1), (n, 0, oo)) -
|
| 405 |
+
4*Sum((-1)**n/(2*n + 1)/239**(2*n + 1), (n, 0, oo)), 100) == pistr
|
| 406 |
+
|
| 407 |
+
# Apery's constant
|
| 408 |
+
astr = NS(zeta(3), 100)
|
| 409 |
+
P = 126392*n**5 + 412708*n**4 + 531578*n**3 + 336367*n**2 + 104000* \
|
| 410 |
+
n + 12463
|
| 411 |
+
assert NS(Sum((-1)**n * P / 24 * (fac(2*n + 1)*fac(2*n)*fac(
|
| 412 |
+
n))**3 / fac(3*n + 2) / fac(4*n + 3)**3, (n, 0, oo)), 100) == astr
|
| 413 |
+
assert NS(Sum((-1)**n * (205*n**2 + 250*n + 77)/64 * fac(n)**10 /
|
| 414 |
+
fac(2*n + 1)**5, (n, 0, oo)), 100) == astr
|
| 415 |
+
|
| 416 |
+
|
| 417 |
+
def test_evalf_fast_series_issue_4021():
|
| 418 |
+
# Catalan's constant
|
| 419 |
+
assert NS(Sum((-1)**(n - 1)*2**(8*n)*(40*n**2 - 24*n + 3)*fac(2*n)**3*
|
| 420 |
+
fac(n)**2/n**3/(2*n - 1)/fac(4*n)**2, (n, 1, oo))/64, 100) == \
|
| 421 |
+
NS(Catalan, 100)
|
| 422 |
+
astr = NS(zeta(3), 100)
|
| 423 |
+
assert NS(5*Sum(
|
| 424 |
+
(-1)**(n - 1)*fac(n)**2 / n**3 / fac(2*n), (n, 1, oo))/2, 100) == astr
|
| 425 |
+
assert NS(Sum((-1)**(n - 1)*(56*n**2 - 32*n + 5) / (2*n - 1)**2 * fac(n - 1)
|
| 426 |
+
**3 / fac(3*n), (n, 1, oo))/4, 100) == astr
|
| 427 |
+
|
| 428 |
+
|
| 429 |
+
def test_evalf_slow_series():
|
| 430 |
+
assert NS(Sum((-1)**n / n, (n, 1, oo)), 15) == NS(-log(2), 15)
|
| 431 |
+
assert NS(Sum((-1)**n / n, (n, 1, oo)), 50) == NS(-log(2), 50)
|
| 432 |
+
assert NS(Sum(1/n**2, (n, 1, oo)), 15) == NS(pi**2/6, 15)
|
| 433 |
+
assert NS(Sum(1/n**2, (n, 1, oo)), 100) == NS(pi**2/6, 100)
|
| 434 |
+
assert NS(Sum(1/n**2, (n, 1, oo)), 500) == NS(pi**2/6, 500)
|
| 435 |
+
assert NS(Sum((-1)**n / (2*n + 1)**3, (n, 0, oo)), 15) == NS(pi**3/32, 15)
|
| 436 |
+
assert NS(Sum((-1)**n / (2*n + 1)**3, (n, 0, oo)), 50) == NS(pi**3/32, 50)
|
| 437 |
+
|
| 438 |
+
|
| 439 |
+
def test_evalf_oo_to_oo():
|
| 440 |
+
# There used to be an error in certain cases
|
| 441 |
+
# Does not evaluate, but at least do not throw an error
|
| 442 |
+
# Evaluates symbolically to 0, which is not correct
|
| 443 |
+
assert Sum(1/(n**2+1), (n, -oo, oo)).evalf() == Sum(1/(n**2+1), (n, -oo, oo))
|
| 444 |
+
# This evaluates if from 1 to oo and symbolically
|
| 445 |
+
assert Sum(1/(factorial(abs(n))), (n, -oo, -1)).evalf() == Sum(1/(factorial(abs(n))), (n, -oo, -1))
|
| 446 |
+
|
| 447 |
+
|
| 448 |
+
def test_euler_maclaurin():
|
| 449 |
+
# Exact polynomial sums with E-M
|
| 450 |
+
def check_exact(f, a, b, m, n):
|
| 451 |
+
A = Sum(f, (k, a, b))
|
| 452 |
+
s, e = A.euler_maclaurin(m, n)
|
| 453 |
+
assert (e == 0) and (s.expand() == A.doit())
|
| 454 |
+
check_exact(k**4, a, b, 0, 2)
|
| 455 |
+
check_exact(k**4 + 2*k, a, b, 1, 2)
|
| 456 |
+
check_exact(k**4 + k**2, a, b, 1, 5)
|
| 457 |
+
check_exact(k**5, 2, 6, 1, 2)
|
| 458 |
+
check_exact(k**5, 2, 6, 1, 3)
|
| 459 |
+
assert Sum(x-1, (x, 0, 2)).euler_maclaurin(m=30, n=30, eps=2**-15) == (0, 0)
|
| 460 |
+
# Not exact
|
| 461 |
+
assert Sum(k**6, (k, a, b)).euler_maclaurin(0, 2)[1] != 0
|
| 462 |
+
# Numerical test
|
| 463 |
+
for mi, ni in [(2, 4), (2, 20), (10, 20), (18, 20)]:
|
| 464 |
+
A = Sum(1/k**3, (k, 1, oo))
|
| 465 |
+
s, e = A.euler_maclaurin(mi, ni)
|
| 466 |
+
assert abs((s - zeta(3)).evalf()) < e.evalf()
|
| 467 |
+
|
| 468 |
+
raises(ValueError, lambda: Sum(1, (x, 0, 1), (k, 0, 1)).euler_maclaurin())
|
| 469 |
+
|
| 470 |
+
|
| 471 |
+
@slow
|
| 472 |
+
def test_evalf_euler_maclaurin():
|
| 473 |
+
assert NS(Sum(1/k**k, (k, 1, oo)), 15) == '1.29128599706266'
|
| 474 |
+
assert NS(Sum(1/k**k, (k, 1, oo)),
|
| 475 |
+
50) == '1.2912859970626635404072825905956005414986193682745'
|
| 476 |
+
assert NS(Sum(1/k - log(1 + 1/k), (k, 1, oo)), 15) == NS(EulerGamma, 15)
|
| 477 |
+
assert NS(Sum(1/k - log(1 + 1/k), (k, 1, oo)), 50) == NS(EulerGamma, 50)
|
| 478 |
+
assert NS(Sum(log(k)/k**2, (k, 1, oo)), 15) == '0.937548254315844'
|
| 479 |
+
assert NS(Sum(log(k)/k**2, (k, 1, oo)),
|
| 480 |
+
50) == '0.93754825431584375370257409456786497789786028861483'
|
| 481 |
+
assert NS(Sum(1/k, (k, 1000000, 2000000)), 15) == '0.693147930560008'
|
| 482 |
+
assert NS(Sum(1/k, (k, 1000000, 2000000)),
|
| 483 |
+
50) == '0.69314793056000780941723211364567656807940638436025'
|
| 484 |
+
|
| 485 |
+
|
| 486 |
+
def test_evalf_symbolic():
|
| 487 |
+
# issue 6328
|
| 488 |
+
expr = Sum(f(x), (x, 1, 3)) + Sum(g(x), (x, 1, 3))
|
| 489 |
+
assert expr.evalf() == expr
|
| 490 |
+
|
| 491 |
+
|
| 492 |
+
def test_evalf_issue_3273():
|
| 493 |
+
assert Sum(0, (k, 1, oo)).evalf() == 0
|
| 494 |
+
|
| 495 |
+
|
| 496 |
+
def test_simple_products():
|
| 497 |
+
assert Product(S.NaN, (x, 1, 3)) is S.NaN
|
| 498 |
+
assert product(S.NaN, (x, 1, 3)) is S.NaN
|
| 499 |
+
assert Product(x, (n, a, a)).doit() == x
|
| 500 |
+
assert Product(x, (x, a, a)).doit() == a
|
| 501 |
+
assert Product(x, (y, 1, a)).doit() == x**a
|
| 502 |
+
|
| 503 |
+
lo, hi = 1, 2
|
| 504 |
+
s1 = Product(n, (n, lo, hi))
|
| 505 |
+
s2 = Product(n, (n, hi, lo))
|
| 506 |
+
assert s1 != s2
|
| 507 |
+
# This IS correct according to Karr product convention
|
| 508 |
+
assert s1.doit() == 2
|
| 509 |
+
assert s2.doit() == 1
|
| 510 |
+
|
| 511 |
+
lo, hi = x, x + 1
|
| 512 |
+
s1 = Product(n, (n, lo, hi))
|
| 513 |
+
s2 = Product(n, (n, hi, lo))
|
| 514 |
+
s3 = 1 / Product(n, (n, hi + 1, lo - 1))
|
| 515 |
+
assert s1 != s2
|
| 516 |
+
# This IS correct according to Karr product convention
|
| 517 |
+
assert s1.doit() == x*(x + 1)
|
| 518 |
+
assert s2.doit() == 1
|
| 519 |
+
assert s3.doit() == x*(x + 1)
|
| 520 |
+
|
| 521 |
+
assert Product(Integral(2*x, (x, 1, y)) + 2*x, (x, 1, 2)).doit() == \
|
| 522 |
+
(y**2 + 1)*(y**2 + 3)
|
| 523 |
+
assert product(2, (n, a, b)) == 2**(b - a + 1)
|
| 524 |
+
assert product(n, (n, 1, b)) == factorial(b)
|
| 525 |
+
assert product(n**3, (n, 1, b)) == factorial(b)**3
|
| 526 |
+
assert product(3**(2 + n), (n, a, b)) \
|
| 527 |
+
== 3**(2*(1 - a + b) + b/2 + (b**2)/2 + a/2 - (a**2)/2)
|
| 528 |
+
assert product(cos(n), (n, 3, 5)) == cos(3)*cos(4)*cos(5)
|
| 529 |
+
assert product(cos(n), (n, x, x + 2)) == cos(x)*cos(x + 1)*cos(x + 2)
|
| 530 |
+
assert isinstance(product(cos(n), (n, x, x + S.Half)), Product)
|
| 531 |
+
# If Product managed to evaluate this one, it most likely got it wrong!
|
| 532 |
+
assert isinstance(Product(n**n, (n, 1, b)), Product)
|
| 533 |
+
|
| 534 |
+
|
| 535 |
+
def test_rational_products():
|
| 536 |
+
assert combsimp(product(1 + 1/n, (n, a, b))) == (1 + b)/a
|
| 537 |
+
assert combsimp(product(n + 1, (n, a, b))) == gamma(2 + b)/gamma(1 + a)
|
| 538 |
+
assert combsimp(product((n + 1)/(n - 1), (n, a, b))) == b*(1 + b)/(a*(a - 1))
|
| 539 |
+
assert combsimp(product(n/(n + 1)/(n + 2), (n, a, b))) == \
|
| 540 |
+
a*gamma(a + 2)/(b + 1)/gamma(b + 3)
|
| 541 |
+
assert combsimp(product(n*(n + 1)/(n - 1)/(n - 2), (n, a, b))) == \
|
| 542 |
+
b**2*(b - 1)*(1 + b)/(a - 1)**2/(a*(a - 2))
|
| 543 |
+
|
| 544 |
+
|
| 545 |
+
def test_wallis_product():
|
| 546 |
+
# Wallis product, given in two different forms to ensure that Product
|
| 547 |
+
# can factor simple rational expressions
|
| 548 |
+
A = Product(4*n**2 / (4*n**2 - 1), (n, 1, b))
|
| 549 |
+
B = Product((2*n)*(2*n)/(2*n - 1)/(2*n + 1), (n, 1, b))
|
| 550 |
+
R = pi*gamma(b + 1)**2/(2*gamma(b + S.Half)*gamma(b + Rational(3, 2)))
|
| 551 |
+
assert simplify(A.doit()) == R
|
| 552 |
+
assert simplify(B.doit()) == R
|
| 553 |
+
# This one should eventually also be doable (Euler's product formula for sin)
|
| 554 |
+
# assert Product(1+x/n**2, (n, 1, b)) == ...
|
| 555 |
+
|
| 556 |
+
|
| 557 |
+
def test_telescopic_sums():
|
| 558 |
+
#checks also input 2 of comment 1 issue 4127
|
| 559 |
+
assert Sum(1/k - 1/(k + 1), (k, 1, n)).doit() == 1 - 1/(1 + n)
|
| 560 |
+
assert Sum(
|
| 561 |
+
f(k) - f(k + 2), (k, m, n)).doit() == -f(1 + n) - f(2 + n) + f(m) + f(1 + m)
|
| 562 |
+
assert Sum(cos(k) - cos(k + 3), (k, 1, n)).doit() == -cos(1 + n) - \
|
| 563 |
+
cos(2 + n) - cos(3 + n) + cos(1) + cos(2) + cos(3)
|
| 564 |
+
|
| 565 |
+
# dummy variable shouldn't matter
|
| 566 |
+
assert telescopic(1/m, -m/(1 + m), (m, n - 1, n)) == \
|
| 567 |
+
telescopic(1/k, -k/(1 + k), (k, n - 1, n))
|
| 568 |
+
|
| 569 |
+
assert Sum(1/x/(x - 1), (x, a, b)).doit() == 1/(a - 1) - 1/b
|
| 570 |
+
eq = 1/((5*n + 2)*(5*(n + 1) + 2))
|
| 571 |
+
assert Sum(eq, (n, 0, oo)).doit() == S(1)/10
|
| 572 |
+
nz = symbols('nz', nonzero=True)
|
| 573 |
+
v = Sum(eq.subs(5, nz), (n, 0, oo)).doit()
|
| 574 |
+
assert v.subs(nz, 5).simplify() == S(1)/10
|
| 575 |
+
# check that apart is being used in non-symbolic case
|
| 576 |
+
s = Sum(eq, (n, 0, k)).doit()
|
| 577 |
+
v = Sum(eq, (n, 0, 10**100)).doit()
|
| 578 |
+
assert v == s.subs(k, 10**100)
|
| 579 |
+
|
| 580 |
+
|
| 581 |
+
def test_sum_reconstruct():
|
| 582 |
+
s = Sum(n**2, (n, -1, 1))
|
| 583 |
+
assert s == Sum(*s.args)
|
| 584 |
+
raises(ValueError, lambda: Sum(x, x))
|
| 585 |
+
raises(ValueError, lambda: Sum(x, (x, 1)))
|
| 586 |
+
|
| 587 |
+
|
| 588 |
+
def test_limit_subs():
|
| 589 |
+
for F in (Sum, Product, Integral):
|
| 590 |
+
assert F(a*exp(a), (a, -2, 2)) == F(a*exp(a), (a, -b, b)).subs(b, 2)
|
| 591 |
+
assert F(a, (a, F(b, (b, 1, 2)), 4)).subs(F(b, (b, 1, 2)), c) == \
|
| 592 |
+
F(a, (a, c, 4))
|
| 593 |
+
assert F(x, (x, 1, x + y)).subs(x, 1) == F(x, (x, 1, y + 1))
|
| 594 |
+
|
| 595 |
+
|
| 596 |
+
def test_function_subs():
|
| 597 |
+
S = Sum(x*f(y),(x,0,oo),(y,0,oo))
|
| 598 |
+
assert S.subs(f(y),y) == Sum(x*y,(x,0,oo),(y,0,oo))
|
| 599 |
+
assert S.subs(f(x),x) == S
|
| 600 |
+
raises(ValueError, lambda: S.subs(f(y),x+y) )
|
| 601 |
+
S = Sum(x*log(y),(x,0,oo),(y,0,oo))
|
| 602 |
+
assert S.subs(log(y),y) == S
|
| 603 |
+
S = Sum(x*f(y),(x,0,oo),(y,0,oo))
|
| 604 |
+
assert S.subs(f(y),y) == Sum(x*y,(x,0,oo),(y,0,oo))
|
| 605 |
+
|
| 606 |
+
|
| 607 |
+
def test_equality():
|
| 608 |
+
# if this fails remove special handling below
|
| 609 |
+
raises(ValueError, lambda: Sum(x, x))
|
| 610 |
+
r = symbols('x', real=True)
|
| 611 |
+
for F in (Sum, Product, Integral):
|
| 612 |
+
try:
|
| 613 |
+
assert F(x, x) != F(y, y)
|
| 614 |
+
assert F(x, (x, 1, 2)) != F(x, x)
|
| 615 |
+
assert F(x, (x, x)) != F(x, x) # or else they print the same
|
| 616 |
+
assert F(1, x) != F(1, y)
|
| 617 |
+
except ValueError:
|
| 618 |
+
pass
|
| 619 |
+
assert F(a, (x, 1, 2)) != F(a, (x, 1, 3)) # diff limit
|
| 620 |
+
assert F(a, (x, 1, x)) != F(a, (y, 1, y))
|
| 621 |
+
assert F(a, (x, 1, 2)) != F(b, (x, 1, 2)) # diff expression
|
| 622 |
+
assert F(x, (x, 1, 2)) != F(r, (r, 1, 2)) # diff assumptions
|
| 623 |
+
assert F(1, (x, 1, x)) != F(1, (y, 1, x)) # only dummy is diff
|
| 624 |
+
assert F(1, (x, 1, x)).dummy_eq(F(1, (y, 1, x)))
|
| 625 |
+
|
| 626 |
+
# issue 5265
|
| 627 |
+
assert Sum(x, (x, 1, x)).subs(x, a) == Sum(x, (x, 1, a))
|
| 628 |
+
|
| 629 |
+
|
| 630 |
+
def test_Sum_doit():
|
| 631 |
+
assert Sum(n*Integral(a**2), (n, 0, 2)).doit() == a**3
|
| 632 |
+
assert Sum(n*Integral(a**2), (n, 0, 2)).doit(deep=False) == \
|
| 633 |
+
3*Integral(a**2)
|
| 634 |
+
assert summation(n*Integral(a**2), (n, 0, 2)) == 3*Integral(a**2)
|
| 635 |
+
|
| 636 |
+
# test nested sum evaluation
|
| 637 |
+
s = Sum( Sum( Sum(2,(z,1,n+1)), (y,x+1,n)), (x,1,n))
|
| 638 |
+
assert 0 == (s.doit() - n*(n+1)*(n-1)).factor()
|
| 639 |
+
|
| 640 |
+
# Integer assumes finite
|
| 641 |
+
assert Sum(KroneckerDelta(x, y), (x, -oo, oo)).doit() == Piecewise((1, And(-oo < y, y < oo)), (0, True))
|
| 642 |
+
assert Sum(KroneckerDelta(m, n), (m, -oo, oo)).doit() == 1
|
| 643 |
+
assert Sum(m*KroneckerDelta(x, y), (x, -oo, oo)).doit() == Piecewise((m, And(-oo < y, y < oo)), (0, True))
|
| 644 |
+
assert Sum(x*KroneckerDelta(m, n), (m, -oo, oo)).doit() == x
|
| 645 |
+
assert Sum(Sum(KroneckerDelta(m, n), (m, 1, 3)), (n, 1, 3)).doit() == 3
|
| 646 |
+
assert Sum(Sum(KroneckerDelta(k, m), (m, 1, 3)), (n, 1, 3)).doit() == \
|
| 647 |
+
3 * Piecewise((1, And(1 <= k, k <= 3)), (0, True))
|
| 648 |
+
assert Sum(f(n) * Sum(KroneckerDelta(m, n), (m, 0, oo)), (n, 1, 3)).doit() == \
|
| 649 |
+
f(1) + f(2) + f(3)
|
| 650 |
+
assert Sum(f(n) * Sum(KroneckerDelta(m, n), (m, 0, oo)), (n, 1, oo)).doit() == \
|
| 651 |
+
Sum(f(n), (n, 1, oo))
|
| 652 |
+
|
| 653 |
+
# issue 2597
|
| 654 |
+
nmax = symbols('N', integer=True, positive=True)
|
| 655 |
+
pw = Piecewise((1, And(1 <= n, n <= nmax)), (0, True))
|
| 656 |
+
assert Sum(pw, (n, 1, nmax)).doit() == Sum(Piecewise((1, nmax >= n),
|
| 657 |
+
(0, True)), (n, 1, nmax))
|
| 658 |
+
|
| 659 |
+
q, s = symbols('q, s')
|
| 660 |
+
assert summation(1/n**(2*s), (n, 1, oo)) == Piecewise((zeta(2*s), 2*re(s) > 1),
|
| 661 |
+
(Sum(n**(-2*s), (n, 1, oo)), True))
|
| 662 |
+
assert summation(1/(n+1)**s, (n, 0, oo)) == Piecewise((zeta(s), re(s) > 1),
|
| 663 |
+
(Sum((n + 1)**(-s), (n, 0, oo)), True))
|
| 664 |
+
assert summation(1/(n+q)**s, (n, 0, oo)) == Piecewise(
|
| 665 |
+
(zeta(s, q), And(~Contains(-q, S.Naturals0), re(s) > 1)),
|
| 666 |
+
(Sum((n + q)**(-s), (n, 0, oo)), True))
|
| 667 |
+
assert summation(1/(n+q)**s, (n, q, oo)) == Piecewise(
|
| 668 |
+
(zeta(s, 2*q), And(~Contains(-2*q, S.Naturals0), re(s) > 1)),
|
| 669 |
+
(Sum((n + q)**(-s), (n, q, oo)), True))
|
| 670 |
+
assert summation(1/n**2, (n, 1, oo)) == zeta(2)
|
| 671 |
+
assert summation(1/n**s, (n, 0, oo)) == Sum(n**(-s), (n, 0, oo))
|
| 672 |
+
assert summation(1/(n+1)**(2+I), (n, 0, oo)) == zeta(2+I)
|
| 673 |
+
t = symbols('t', real=True, positive=True)
|
| 674 |
+
assert summation(1/(n+I)**(t+1), (n, 0, oo)) == zeta(t+1, I)
|
| 675 |
+
|
| 676 |
+
|
| 677 |
+
def test_Product_doit():
|
| 678 |
+
assert Product(n*Integral(a**2), (n, 1, 3)).doit() == 2 * a**9 / 9
|
| 679 |
+
assert Product(n*Integral(a**2), (n, 1, 3)).doit(deep=False) == \
|
| 680 |
+
6*Integral(a**2)**3
|
| 681 |
+
assert product(n*Integral(a**2), (n, 1, 3)) == 6*Integral(a**2)**3
|
| 682 |
+
|
| 683 |
+
|
| 684 |
+
def test_Sum_interface():
|
| 685 |
+
assert isinstance(Sum(0, (n, 0, 2)), Sum)
|
| 686 |
+
assert Sum(nan, (n, 0, 2)) is nan
|
| 687 |
+
assert Sum(nan, (n, 0, oo)) is nan
|
| 688 |
+
assert Sum(0, (n, 0, 2)).doit() == 0
|
| 689 |
+
assert isinstance(Sum(0, (n, 0, oo)), Sum)
|
| 690 |
+
assert Sum(0, (n, 0, oo)).doit() == 0
|
| 691 |
+
raises(ValueError, lambda: Sum(1))
|
| 692 |
+
raises(ValueError, lambda: summation(1))
|
| 693 |
+
|
| 694 |
+
|
| 695 |
+
def test_diff():
|
| 696 |
+
assert Sum(x, (x, 1, 2)).diff(x) == 0
|
| 697 |
+
assert Sum(x*y, (x, 1, 2)).diff(x) == 0
|
| 698 |
+
assert Sum(x*y, (y, 1, 2)).diff(x) == Sum(y, (y, 1, 2))
|
| 699 |
+
e = Sum(x*y, (x, 1, a))
|
| 700 |
+
assert e.diff(a) == Derivative(e, a)
|
| 701 |
+
assert Sum(x*y, (x, 1, 3), (a, 2, 5)).diff(y).doit() == \
|
| 702 |
+
Sum(x*y, (x, 1, 3), (a, 2, 5)).doit().diff(y) == 24
|
| 703 |
+
assert Sum(x, (x, 1, 2)).diff(y) == 0
|
| 704 |
+
|
| 705 |
+
|
| 706 |
+
def test_hypersum():
|
| 707 |
+
assert simplify(summation(x**n/fac(n), (n, 1, oo))) == -1 + exp(x)
|
| 708 |
+
assert summation((-1)**n * x**(2*n) / fac(2*n), (n, 0, oo)) == cos(x)
|
| 709 |
+
assert simplify(summation((-1)**n*x**(2*n + 1) /
|
| 710 |
+
factorial(2*n + 1), (n, 3, oo))) == -x + sin(x) + x**3/6 - x**5/120
|
| 711 |
+
|
| 712 |
+
assert summation(1/(n + 2)**3, (n, 1, oo)) == Rational(-9, 8) + zeta(3)
|
| 713 |
+
assert summation(1/n**4, (n, 1, oo)) == pi**4/90
|
| 714 |
+
|
| 715 |
+
s = summation(x**n*n, (n, -oo, 0))
|
| 716 |
+
assert s.is_Piecewise
|
| 717 |
+
assert s.args[0].args[0] == -1/(x*(1 - 1/x)**2)
|
| 718 |
+
assert s.args[0].args[1] == (abs(1/x) < 1)
|
| 719 |
+
|
| 720 |
+
m = Symbol('n', integer=True, positive=True)
|
| 721 |
+
assert summation(binomial(m, k), (k, 0, m)) == 2**m
|
| 722 |
+
|
| 723 |
+
|
| 724 |
+
def test_issue_4170():
|
| 725 |
+
assert summation(1/factorial(k), (k, 0, oo)) == E
|
| 726 |
+
|
| 727 |
+
|
| 728 |
+
def test_is_commutative():
|
| 729 |
+
from sympy.physics.secondquant import NO, F, Fd
|
| 730 |
+
m = Symbol('m', commutative=False)
|
| 731 |
+
for f in (Sum, Product, Integral):
|
| 732 |
+
assert f(z, (z, 1, 1)).is_commutative is True
|
| 733 |
+
assert f(z*y, (z, 1, 6)).is_commutative is True
|
| 734 |
+
assert f(m*x, (x, 1, 2)).is_commutative is False
|
| 735 |
+
|
| 736 |
+
assert f(NO(Fd(x)*F(y))*z, (z, 1, 2)).is_commutative is False
|
| 737 |
+
|
| 738 |
+
|
| 739 |
+
def test_is_zero():
|
| 740 |
+
for func in [Sum, Product]:
|
| 741 |
+
assert func(0, (x, 1, 1)).is_zero is True
|
| 742 |
+
assert func(x, (x, 1, 1)).is_zero is None
|
| 743 |
+
|
| 744 |
+
assert Sum(0, (x, 1, 0)).is_zero is True
|
| 745 |
+
assert Product(0, (x, 1, 0)).is_zero is False
|
| 746 |
+
|
| 747 |
+
|
| 748 |
+
def test_is_number():
|
| 749 |
+
# is number should not rely on evaluation or assumptions,
|
| 750 |
+
# it should be equivalent to `not foo.free_symbols`
|
| 751 |
+
assert Sum(1, (x, 1, 1)).is_number is True
|
| 752 |
+
assert Sum(1, (x, 1, x)).is_number is False
|
| 753 |
+
assert Sum(0, (x, y, z)).is_number is False
|
| 754 |
+
assert Sum(x, (y, 1, 2)).is_number is False
|
| 755 |
+
assert Sum(x, (y, 1, 1)).is_number is False
|
| 756 |
+
assert Sum(x, (x, 1, 2)).is_number is True
|
| 757 |
+
assert Sum(x*y, (x, 1, 2), (y, 1, 3)).is_number is True
|
| 758 |
+
|
| 759 |
+
assert Product(2, (x, 1, 1)).is_number is True
|
| 760 |
+
assert Product(2, (x, 1, y)).is_number is False
|
| 761 |
+
assert Product(0, (x, y, z)).is_number is False
|
| 762 |
+
assert Product(1, (x, y, z)).is_number is False
|
| 763 |
+
assert Product(x, (y, 1, x)).is_number is False
|
| 764 |
+
assert Product(x, (y, 1, 2)).is_number is False
|
| 765 |
+
assert Product(x, (y, 1, 1)).is_number is False
|
| 766 |
+
assert Product(x, (x, 1, 2)).is_number is True
|
| 767 |
+
|
| 768 |
+
|
| 769 |
+
def test_free_symbols():
|
| 770 |
+
for func in [Sum, Product]:
|
| 771 |
+
assert func(1, (x, 1, 2)).free_symbols == set()
|
| 772 |
+
assert func(0, (x, 1, y)).free_symbols == {y}
|
| 773 |
+
assert func(2, (x, 1, y)).free_symbols == {y}
|
| 774 |
+
assert func(x, (x, 1, 2)).free_symbols == set()
|
| 775 |
+
assert func(x, (x, 1, y)).free_symbols == {y}
|
| 776 |
+
assert func(x, (y, 1, y)).free_symbols == {x, y}
|
| 777 |
+
assert func(x, (y, 1, 2)).free_symbols == {x}
|
| 778 |
+
assert func(x, (y, 1, 1)).free_symbols == {x}
|
| 779 |
+
assert func(x, (y, 1, z)).free_symbols == {x, z}
|
| 780 |
+
assert func(x, (x, 1, y), (y, 1, 2)).free_symbols == set()
|
| 781 |
+
assert func(x, (x, 1, y), (y, 1, z)).free_symbols == {z}
|
| 782 |
+
assert func(x, (x, 1, y), (y, 1, y)).free_symbols == {y}
|
| 783 |
+
assert func(x, (y, 1, y), (y, 1, z)).free_symbols == {x, z}
|
| 784 |
+
assert Sum(1, (x, 1, y)).free_symbols == {y}
|
| 785 |
+
# free_symbols answers whether the object *as written* has free symbols,
|
| 786 |
+
# not whether the evaluated expression has free symbols
|
| 787 |
+
assert Product(1, (x, 1, y)).free_symbols == {y}
|
| 788 |
+
# don't count free symbols that are not independent of integration
|
| 789 |
+
# variable(s)
|
| 790 |
+
assert func(f(x), (f(x), 1, 2)).free_symbols == set()
|
| 791 |
+
assert func(f(x), (f(x), 1, x)).free_symbols == {x}
|
| 792 |
+
assert func(f(x), (f(x), 1, y)).free_symbols == {y}
|
| 793 |
+
assert func(f(x), (z, 1, y)).free_symbols == {x, y}
|
| 794 |
+
|
| 795 |
+
|
| 796 |
+
def test_conjugate_transpose():
|
| 797 |
+
A, B = symbols("A B", commutative=False)
|
| 798 |
+
p = Sum(A*B**n, (n, 1, 3))
|
| 799 |
+
assert p.adjoint().doit() == p.doit().adjoint()
|
| 800 |
+
assert p.conjugate().doit() == p.doit().conjugate()
|
| 801 |
+
assert p.transpose().doit() == p.doit().transpose()
|
| 802 |
+
|
| 803 |
+
p = Sum(B**n*A, (n, 1, 3))
|
| 804 |
+
assert p.adjoint().doit() == p.doit().adjoint()
|
| 805 |
+
assert p.conjugate().doit() == p.doit().conjugate()
|
| 806 |
+
assert p.transpose().doit() == p.doit().transpose()
|
| 807 |
+
|
| 808 |
+
|
| 809 |
+
def test_noncommutativity_honoured():
|
| 810 |
+
A, B = symbols("A B", commutative=False)
|
| 811 |
+
M = symbols('M', integer=True, positive=True)
|
| 812 |
+
p = Sum(A*B**n, (n, 1, M))
|
| 813 |
+
assert p.doit() == A*Piecewise((M, Eq(B, 1)),
|
| 814 |
+
((B - B**(M + 1))*(1 - B)**(-1), True))
|
| 815 |
+
|
| 816 |
+
p = Sum(B**n*A, (n, 1, M))
|
| 817 |
+
assert p.doit() == Piecewise((M, Eq(B, 1)),
|
| 818 |
+
((B - B**(M + 1))*(1 - B)**(-1), True))*A
|
| 819 |
+
|
| 820 |
+
p = Sum(B**n*A*B**n, (n, 1, M))
|
| 821 |
+
assert p.doit() == p
|
| 822 |
+
|
| 823 |
+
|
| 824 |
+
def test_issue_4171():
|
| 825 |
+
assert summation(factorial(2*k + 1)/factorial(2*k), (k, 0, oo)) is oo
|
| 826 |
+
assert summation(2*k + 1, (k, 0, oo)) is oo
|
| 827 |
+
|
| 828 |
+
|
| 829 |
+
def test_issue_6273():
|
| 830 |
+
assert Sum(x, (x, 1, n)).n(2, subs={n: 1}) == Float(1, 2)
|
| 831 |
+
|
| 832 |
+
|
| 833 |
+
def test_issue_6274():
|
| 834 |
+
assert Sum(x, (x, 1, 0)).doit() == 0
|
| 835 |
+
assert NS(Sum(x, (x, 1, 0))) == '0'
|
| 836 |
+
assert Sum(n, (n, 10, 5)).doit() == -30
|
| 837 |
+
assert NS(Sum(n, (n, 10, 5))) == '-30.0000000000000'
|
| 838 |
+
|
| 839 |
+
|
| 840 |
+
def test_simplify_sum():
|
| 841 |
+
y, t, v = symbols('y, t, v')
|
| 842 |
+
|
| 843 |
+
_simplify = lambda e: simplify(e, doit=False)
|
| 844 |
+
assert _simplify(Sum(x*y, (x, n, m), (y, a, k)) + \
|
| 845 |
+
Sum(y, (x, n, m), (y, a, k))) == Sum(y * (x + 1), (x, n, m), (y, a, k))
|
| 846 |
+
assert _simplify(Sum(x, (x, n, m)) + Sum(x, (x, m + 1, a))) == \
|
| 847 |
+
Sum(x, (x, n, a))
|
| 848 |
+
assert _simplify(Sum(x, (x, k + 1, a)) + Sum(x, (x, n, k))) == \
|
| 849 |
+
Sum(x, (x, n, a))
|
| 850 |
+
assert _simplify(Sum(x, (x, k + 1, a)) + Sum(x + 1, (x, n, k))) == \
|
| 851 |
+
Sum(x, (x, n, a)) + Sum(1, (x, n, k))
|
| 852 |
+
assert _simplify(Sum(x, (x, 0, 3)) * 3 + 3 * Sum(x, (x, 4, 6)) + \
|
| 853 |
+
4 * Sum(z, (z, 0, 1))) == 4*Sum(z, (z, 0, 1)) + 3*Sum(x, (x, 0, 6))
|
| 854 |
+
assert _simplify(3*Sum(x**2, (x, a, b)) + Sum(x, (x, a, b))) == \
|
| 855 |
+
Sum(x*(3*x + 1), (x, a, b))
|
| 856 |
+
assert _simplify(Sum(x**3, (x, n, k)) * 3 + 3 * Sum(x, (x, n, k)) + \
|
| 857 |
+
4 * y * Sum(z, (z, n, k))) + 1 == \
|
| 858 |
+
4*y*Sum(z, (z, n, k)) + 3*Sum(x**3 + x, (x, n, k)) + 1
|
| 859 |
+
assert _simplify(Sum(x, (x, a, b)) + 1 + Sum(x, (x, b + 1, c))) == \
|
| 860 |
+
1 + Sum(x, (x, a, c))
|
| 861 |
+
assert _simplify(Sum(x, (t, a, b)) + Sum(y, (t, a, b)) + \
|
| 862 |
+
Sum(x, (t, b+1, c))) == x * Sum(1, (t, a, c)) + y * Sum(1, (t, a, b))
|
| 863 |
+
assert _simplify(Sum(x, (t, a, b)) + Sum(x, (t, b+1, c)) + \
|
| 864 |
+
Sum(y, (t, a, b))) == x * Sum(1, (t, a, c)) + y * Sum(1, (t, a, b))
|
| 865 |
+
assert _simplify(Sum(x, (t, a, b)) + 2 * Sum(x, (t, b+1, c))) == \
|
| 866 |
+
_simplify(Sum(x, (t, a, b)) + Sum(x, (t, b+1, c)) + Sum(x, (t, b+1, c)))
|
| 867 |
+
assert _simplify(Sum(x, (x, a, b))*Sum(x**2, (x, a, b))) == \
|
| 868 |
+
Sum(x, (x, a, b)) * Sum(x**2, (x, a, b))
|
| 869 |
+
assert _simplify(Sum(x, (t, a, b)) + Sum(y, (t, a, b)) + Sum(z, (t, a, b))) \
|
| 870 |
+
== (x + y + z) * Sum(1, (t, a, b)) # issue 8596
|
| 871 |
+
assert _simplify(Sum(x, (t, a, b)) + Sum(y, (t, a, b)) + Sum(z, (t, a, b)) + \
|
| 872 |
+
Sum(v, (t, a, b))) == (x + y + z + v) * Sum(1, (t, a, b)) # issue 8596
|
| 873 |
+
assert _simplify(Sum(x * y, (x, a, b)) / (3 * y)) == \
|
| 874 |
+
(Sum(x, (x, a, b)) / 3)
|
| 875 |
+
assert _simplify(Sum(f(x) * y * z, (x, a, b)) / (y * z)) \
|
| 876 |
+
== Sum(f(x), (x, a, b))
|
| 877 |
+
assert _simplify(Sum(c * x, (x, a, b)) - c * Sum(x, (x, a, b))) == 0
|
| 878 |
+
assert _simplify(c * (Sum(x, (x, a, b)) + y)) == c * (y + Sum(x, (x, a, b)))
|
| 879 |
+
assert _simplify(c * (Sum(x, (x, a, b)) + y * Sum(x, (x, a, b)))) == \
|
| 880 |
+
c * (y + 1) * Sum(x, (x, a, b))
|
| 881 |
+
assert _simplify(Sum(Sum(c * x, (x, a, b)), (y, a, b))) == \
|
| 882 |
+
c * Sum(x, (x, a, b), (y, a, b))
|
| 883 |
+
assert _simplify(Sum((3 + y) * Sum(c * x, (x, a, b)), (y, a, b))) == \
|
| 884 |
+
c * Sum((3 + y), (y, a, b)) * Sum(x, (x, a, b))
|
| 885 |
+
assert _simplify(Sum((3 + t) * Sum(c * t, (x, a, b)), (y, a, b))) == \
|
| 886 |
+
c*t*(t + 3)*Sum(1, (x, a, b))*Sum(1, (y, a, b))
|
| 887 |
+
assert _simplify(Sum(Sum(d * t, (x, a, b - 1)) + \
|
| 888 |
+
Sum(d * t, (x, b, c)), (t, a, b))) == \
|
| 889 |
+
d * Sum(1, (x, a, c)) * Sum(t, (t, a, b))
|
| 890 |
+
assert _simplify(Sum(sin(t)**2 + cos(t)**2 + 1, (t, a, b))) == \
|
| 891 |
+
2 * Sum(1, (t, a, b))
|
| 892 |
+
|
| 893 |
+
|
| 894 |
+
def test_change_index():
|
| 895 |
+
b, v, w = symbols('b, v, w', integer = True)
|
| 896 |
+
|
| 897 |
+
assert Sum(x, (x, a, b)).change_index(x, x + 1, y) == \
|
| 898 |
+
Sum(y - 1, (y, a + 1, b + 1))
|
| 899 |
+
assert Sum(x**2, (x, a, b)).change_index( x, x - 1) == \
|
| 900 |
+
Sum((x+1)**2, (x, a - 1, b - 1))
|
| 901 |
+
assert Sum(x**2, (x, a, b)).change_index( x, -x, y) == \
|
| 902 |
+
Sum((-y)**2, (y, -b, -a))
|
| 903 |
+
assert Sum(x, (x, a, b)).change_index( x, -x - 1) == \
|
| 904 |
+
Sum(-x - 1, (x, -b - 1, -a - 1))
|
| 905 |
+
assert Sum(x*y, (x, a, b), (y, c, d)).change_index( x, x - 1, z) == \
|
| 906 |
+
Sum((z + 1)*y, (z, a - 1, b - 1), (y, c, d))
|
| 907 |
+
assert Sum(x, (x, a, b)).change_index( x, x + v) == \
|
| 908 |
+
Sum(-v + x, (x, a + v, b + v))
|
| 909 |
+
assert Sum(x, (x, a, b)).change_index( x, -x - v) == \
|
| 910 |
+
Sum(-v - x, (x, -b - v, -a - v))
|
| 911 |
+
assert Sum(x, (x, a, b)).change_index(x, w*x, v) == \
|
| 912 |
+
Sum(v/w, (v, b*w, a*w))
|
| 913 |
+
raises(ValueError, lambda: Sum(x, (x, a, b)).change_index(x, 2*x))
|
| 914 |
+
|
| 915 |
+
|
| 916 |
+
def test_reorder():
|
| 917 |
+
b, y, c, d, z = symbols('b, y, c, d, z', integer = True)
|
| 918 |
+
|
| 919 |
+
assert Sum(x*y, (x, a, b), (y, c, d)).reorder((0, 1)) == \
|
| 920 |
+
Sum(x*y, (y, c, d), (x, a, b))
|
| 921 |
+
assert Sum(x, (x, a, b), (x, c, d)).reorder((0, 1)) == \
|
| 922 |
+
Sum(x, (x, c, d), (x, a, b))
|
| 923 |
+
assert Sum(x*y + z, (x, a, b), (z, m, n), (y, c, d)).reorder(\
|
| 924 |
+
(2, 0), (0, 1)) == Sum(x*y + z, (z, m, n), (y, c, d), (x, a, b))
|
| 925 |
+
assert Sum(x*y*z, (x, a, b), (y, c, d), (z, m, n)).reorder(\
|
| 926 |
+
(0, 1), (1, 2), (0, 2)) == Sum(x*y*z, (x, a, b), (z, m, n), (y, c, d))
|
| 927 |
+
assert Sum(x*y*z, (x, a, b), (y, c, d), (z, m, n)).reorder(\
|
| 928 |
+
(x, y), (y, z), (x, z)) == Sum(x*y*z, (x, a, b), (z, m, n), (y, c, d))
|
| 929 |
+
assert Sum(x*y, (x, a, b), (y, c, d)).reorder((x, 1)) == \
|
| 930 |
+
Sum(x*y, (y, c, d), (x, a, b))
|
| 931 |
+
assert Sum(x*y, (x, a, b), (y, c, d)).reorder((y, x)) == \
|
| 932 |
+
Sum(x*y, (y, c, d), (x, a, b))
|
| 933 |
+
|
| 934 |
+
|
| 935 |
+
def test_reverse_order():
|
| 936 |
+
assert Sum(x, (x, 0, 3)).reverse_order(0) == Sum(-x, (x, 4, -1))
|
| 937 |
+
assert Sum(x*y, (x, 1, 5), (y, 0, 6)).reverse_order(0, 1) == \
|
| 938 |
+
Sum(x*y, (x, 6, 0), (y, 7, -1))
|
| 939 |
+
assert Sum(x, (x, 1, 2)).reverse_order(0) == Sum(-x, (x, 3, 0))
|
| 940 |
+
assert Sum(x, (x, 1, 3)).reverse_order(0) == Sum(-x, (x, 4, 0))
|
| 941 |
+
assert Sum(x, (x, 1, a)).reverse_order(0) == Sum(-x, (x, a + 1, 0))
|
| 942 |
+
assert Sum(x, (x, a, 5)).reverse_order(0) == Sum(-x, (x, 6, a - 1))
|
| 943 |
+
assert Sum(x, (x, a + 1, a + 5)).reverse_order(0) == \
|
| 944 |
+
Sum(-x, (x, a + 6, a))
|
| 945 |
+
assert Sum(x, (x, a + 1, a + 2)).reverse_order(0) == \
|
| 946 |
+
Sum(-x, (x, a + 3, a))
|
| 947 |
+
assert Sum(x, (x, a + 1, a + 1)).reverse_order(0) == \
|
| 948 |
+
Sum(-x, (x, a + 2, a))
|
| 949 |
+
assert Sum(x, (x, a, b)).reverse_order(0) == Sum(-x, (x, b + 1, a - 1))
|
| 950 |
+
assert Sum(x, (x, a, b)).reverse_order(x) == Sum(-x, (x, b + 1, a - 1))
|
| 951 |
+
assert Sum(x*y, (x, a, b), (y, 2, 5)).reverse_order(x, 1) == \
|
| 952 |
+
Sum(x*y, (x, b + 1, a - 1), (y, 6, 1))
|
| 953 |
+
assert Sum(x*y, (x, a, b), (y, 2, 5)).reverse_order(y, x) == \
|
| 954 |
+
Sum(x*y, (x, b + 1, a - 1), (y, 6, 1))
|
| 955 |
+
|
| 956 |
+
|
| 957 |
+
def test_issue_7097():
|
| 958 |
+
assert sum(x**n/n for n in range(1, 401)) == summation(x**n/n, (n, 1, 400))
|
| 959 |
+
|
| 960 |
+
|
| 961 |
+
def test_factor_expand_subs():
|
| 962 |
+
# test factoring
|
| 963 |
+
assert Sum(4 * x, (x, 1, y)).factor() == 4 * Sum(x, (x, 1, y))
|
| 964 |
+
assert Sum(x * a, (x, 1, y)).factor() == a * Sum(x, (x, 1, y))
|
| 965 |
+
assert Sum(4 * x * a, (x, 1, y)).factor() == 4 * a * Sum(x, (x, 1, y))
|
| 966 |
+
assert Sum(4 * x * y, (x, 1, y)).factor() == 4 * y * Sum(x, (x, 1, y))
|
| 967 |
+
|
| 968 |
+
# test expand
|
| 969 |
+
_x = Symbol('x', zero=False)
|
| 970 |
+
assert Sum(x+1,(x,1,y)).expand() == Sum(x,(x,1,y)) + Sum(1,(x,1,y))
|
| 971 |
+
assert Sum(x+a*x**2,(x,1,y)).expand() == Sum(x,(x,1,y)) + Sum(a*x**2,(x,1,y))
|
| 972 |
+
assert Sum(_x**(n + 1)*(n + 1), (n, -1, oo)).expand() \
|
| 973 |
+
== Sum(n*_x*_x**n + _x*_x**n, (n, -1, oo))
|
| 974 |
+
assert Sum(x**(n + 1)*(n + 1), (n, -1, oo)).expand(power_exp=False) \
|
| 975 |
+
== Sum(n*x**(n + 1) + x**(n + 1), (n, -1, oo))
|
| 976 |
+
assert Sum(x**(n + 1)*(n + 1), (n, -1, oo)).expand(force=True) \
|
| 977 |
+
== Sum(x*x**n, (n, -1, oo)) + Sum(n*x*x**n, (n, -1, oo))
|
| 978 |
+
assert Sum(a*n+a*n**2,(n,0,4)).expand() \
|
| 979 |
+
== Sum(a*n,(n,0,4)) + Sum(a*n**2,(n,0,4))
|
| 980 |
+
assert Sum(_x**a*_x**n,(x,0,3)) \
|
| 981 |
+
== Sum(_x**(a+n),(x,0,3)).expand(power_exp=True)
|
| 982 |
+
_a, _n = symbols('a n', positive=True)
|
| 983 |
+
assert Sum(x**(_a+_n),(x,0,3)).expand(power_exp=True) \
|
| 984 |
+
== Sum(x**_a*x**_n, (x, 0, 3))
|
| 985 |
+
assert Sum(x**(_a-_n),(x,0,3)).expand(power_exp=True) \
|
| 986 |
+
== Sum(x**(_a-_n),(x,0,3)).expand(power_exp=False)
|
| 987 |
+
|
| 988 |
+
# test subs
|
| 989 |
+
assert Sum(1/(1+a*x**2),(x,0,3)).subs([(a,3)]) == Sum(1/(1+3*x**2),(x,0,3))
|
| 990 |
+
assert Sum(x*y,(x,0,y),(y,0,x)).subs([(x,3)]) == Sum(x*y,(x,0,y),(y,0,3))
|
| 991 |
+
assert Sum(x,(x,1,10)).subs([(x,y-2)]) == Sum(x,(x,1,10))
|
| 992 |
+
assert Sum(1/x,(x,1,10)).subs([(x,(3+n)**3)]) == Sum(1/x,(x,1,10))
|
| 993 |
+
assert Sum(1/x,(x,1,10)).subs([(x,3*x-2)]) == Sum(1/x,(x,1,10))
|
| 994 |
+
|
| 995 |
+
|
| 996 |
+
def test_distribution_over_equality():
|
| 997 |
+
assert Product(Eq(x*2, f(x)), (x, 1, 3)).doit() == Eq(48, f(1)*f(2)*f(3))
|
| 998 |
+
assert Sum(Eq(f(x), x**2), (x, 0, y)) == \
|
| 999 |
+
Eq(Sum(f(x), (x, 0, y)), Sum(x**2, (x, 0, y)))
|
| 1000 |
+
|
| 1001 |
+
|
| 1002 |
+
def test_issue_2787():
|
| 1003 |
+
n, k = symbols('n k', positive=True, integer=True)
|
| 1004 |
+
p = symbols('p', positive=True)
|
| 1005 |
+
binomial_dist = binomial(n, k)*p**k*(1 - p)**(n - k)
|
| 1006 |
+
s = Sum(binomial_dist*k, (k, 0, n))
|
| 1007 |
+
res = s.doit().simplify()
|
| 1008 |
+
ans = Piecewise(
|
| 1009 |
+
(n*p, x),
|
| 1010 |
+
(Sum(k*p**k*binomial(n, k)*(1 - p)**(n - k), (k, 0, n)),
|
| 1011 |
+
True)).subs(x, (Eq(n, 1) | (n > 1)) & (p/Abs(p - 1) <= 1))
|
| 1012 |
+
ans2 = Piecewise(
|
| 1013 |
+
(n*p, x),
|
| 1014 |
+
(factorial(n)*Sum(p**k*(1 - p)**(-k + n)/
|
| 1015 |
+
(factorial(-k + n)*factorial(k - 1)), (k, 0, n)),
|
| 1016 |
+
True)).subs(x, (Eq(n, 1) | (n > 1)) & (p/Abs(p - 1) <= 1))
|
| 1017 |
+
assert res in [ans, ans2] # XXX system dependent
|
| 1018 |
+
# Issue #17165: make sure that another simplify does not complicate
|
| 1019 |
+
# the result by much. Why didn't first simplify replace
|
| 1020 |
+
# Eq(n, 1) | (n > 1) with True?
|
| 1021 |
+
assert res.simplify().count_ops() <= res.count_ops() + 2
|
| 1022 |
+
|
| 1023 |
+
|
| 1024 |
+
def test_issue_4668():
|
| 1025 |
+
assert summation(1/n, (n, 2, oo)) is oo
|
| 1026 |
+
|
| 1027 |
+
|
| 1028 |
+
def test_matrix_sum():
|
| 1029 |
+
A = Matrix([[0, 1], [n, 0]])
|
| 1030 |
+
|
| 1031 |
+
result = Sum(A, (n, 0, 3)).doit()
|
| 1032 |
+
assert result == Matrix([[0, 4], [6, 0]])
|
| 1033 |
+
assert result.__class__ == ImmutableDenseMatrix
|
| 1034 |
+
|
| 1035 |
+
A = SparseMatrix([[0, 1], [n, 0]])
|
| 1036 |
+
|
| 1037 |
+
result = Sum(A, (n, 0, 3)).doit()
|
| 1038 |
+
assert result.__class__ == ImmutableSparseMatrix
|
| 1039 |
+
|
| 1040 |
+
|
| 1041 |
+
def test_failing_matrix_sum():
|
| 1042 |
+
n = Symbol('n')
|
| 1043 |
+
# TODO Implement matrix geometric series summation.
|
| 1044 |
+
A = Matrix([[0, 1, 0], [-1, 0, 0], [0, 0, 0]])
|
| 1045 |
+
assert Sum(A ** n, (n, 1, 4)).doit() == \
|
| 1046 |
+
Matrix([[0, 0, 0], [0, 0, 0], [0, 0, 0]])
|
| 1047 |
+
# issue sympy/sympy#16989
|
| 1048 |
+
assert summation(A**n, (n, 1, 1)) == A
|
| 1049 |
+
|
| 1050 |
+
|
| 1051 |
+
def test_indexed_idx_sum():
|
| 1052 |
+
i = symbols('i', cls=Idx)
|
| 1053 |
+
r = Indexed('r', i)
|
| 1054 |
+
assert Sum(r, (i, 0, 3)).doit() == sum(r.xreplace({i: j}) for j in range(4))
|
| 1055 |
+
assert Product(r, (i, 0, 3)).doit() == prod([r.xreplace({i: j}) for j in range(4)])
|
| 1056 |
+
|
| 1057 |
+
j = symbols('j', integer=True)
|
| 1058 |
+
assert Sum(r, (i, j, j+2)).doit() == sum(r.xreplace({i: j+k}) for k in range(3))
|
| 1059 |
+
assert Product(r, (i, j, j+2)).doit() == prod([r.xreplace({i: j+k}) for k in range(3)])
|
| 1060 |
+
|
| 1061 |
+
k = Idx('k', range=(1, 3))
|
| 1062 |
+
A = IndexedBase('A')
|
| 1063 |
+
assert Sum(A[k], k).doit() == sum(A[Idx(j, (1, 3))] for j in range(1, 4))
|
| 1064 |
+
assert Product(A[k], k).doit() == prod([A[Idx(j, (1, 3))] for j in range(1, 4)])
|
| 1065 |
+
|
| 1066 |
+
raises(ValueError, lambda: Sum(A[k], (k, 1, 4)))
|
| 1067 |
+
raises(ValueError, lambda: Sum(A[k], (k, 0, 3)))
|
| 1068 |
+
raises(ValueError, lambda: Sum(A[k], (k, 2, oo)))
|
| 1069 |
+
|
| 1070 |
+
raises(ValueError, lambda: Product(A[k], (k, 1, 4)))
|
| 1071 |
+
raises(ValueError, lambda: Product(A[k], (k, 0, 3)))
|
| 1072 |
+
raises(ValueError, lambda: Product(A[k], (k, 2, oo)))
|
| 1073 |
+
|
| 1074 |
+
|
| 1075 |
+
@slow
|
| 1076 |
+
def test_is_convergent():
|
| 1077 |
+
# divergence tests --
|
| 1078 |
+
assert Sum(n/(2*n + 1), (n, 1, oo)).is_convergent() is S.false
|
| 1079 |
+
assert Sum(factorial(n)/5**n, (n, 1, oo)).is_convergent() is S.false
|
| 1080 |
+
assert Sum(3**(-2*n - 1)*n**n, (n, 1, oo)).is_convergent() is S.false
|
| 1081 |
+
assert Sum((-1)**n*n, (n, 3, oo)).is_convergent() is S.false
|
| 1082 |
+
assert Sum((-1)**n, (n, 1, oo)).is_convergent() is S.false
|
| 1083 |
+
assert Sum(log(1/n), (n, 2, oo)).is_convergent() is S.false
|
| 1084 |
+
assert Sum(sin(n), (n, 1, oo)).is_convergent() is S.false
|
| 1085 |
+
|
| 1086 |
+
# Raabe's test --
|
| 1087 |
+
assert Sum(Product((3*m),(m,1,n))/Product((3*m+4),(m,1,n)),(n,1,oo)).is_convergent() is S.true
|
| 1088 |
+
|
| 1089 |
+
# root test --
|
| 1090 |
+
assert Sum((-12)**n/n, (n, 1, oo)).is_convergent() is S.false
|
| 1091 |
+
|
| 1092 |
+
# integral test --
|
| 1093 |
+
|
| 1094 |
+
# p-series test --
|
| 1095 |
+
assert Sum(1/(n**2 + 1), (n, 1, oo)).is_convergent() is S.true
|
| 1096 |
+
assert Sum(1/n**Rational(6, 5), (n, 1, oo)).is_convergent() is S.true
|
| 1097 |
+
assert Sum(2/(n*sqrt(n - 1)), (n, 2, oo)).is_convergent() is S.true
|
| 1098 |
+
assert Sum(1/(sqrt(n)*sqrt(n)), (n, 2, oo)).is_convergent() is S.false
|
| 1099 |
+
assert Sum(factorial(n) / factorial(n+2), (n, 1, oo)).is_convergent() is S.true
|
| 1100 |
+
assert Sum(rf(5,n)/rf(7,n),(n,1,oo)).is_convergent() is S.true
|
| 1101 |
+
assert Sum((rf(1, n)*rf(2, n))/(rf(3, n)*factorial(n)),(n,1,oo)).is_convergent() is S.false
|
| 1102 |
+
|
| 1103 |
+
# comparison test --
|
| 1104 |
+
assert Sum(1/(n + log(n)), (n, 1, oo)).is_convergent() is S.false
|
| 1105 |
+
assert Sum(1/(n**2*log(n)), (n, 2, oo)).is_convergent() is S.true
|
| 1106 |
+
assert Sum(1/(n*log(n)), (n, 2, oo)).is_convergent() is S.false
|
| 1107 |
+
assert Sum(2/(n*log(n)*log(log(n))**2), (n, 5, oo)).is_convergent() is S.true
|
| 1108 |
+
assert Sum(2/(n*log(n)**2), (n, 2, oo)).is_convergent() is S.true
|
| 1109 |
+
assert Sum((n - 1)/(n**2*log(n)**3), (n, 2, oo)).is_convergent() is S.true
|
| 1110 |
+
assert Sum(1/(n*log(n)*log(log(n))), (n, 5, oo)).is_convergent() is S.false
|
| 1111 |
+
assert Sum((n - 1)/(n*log(n)**3), (n, 3, oo)).is_convergent() is S.false
|
| 1112 |
+
assert Sum(2/(n**2*log(n)), (n, 2, oo)).is_convergent() is S.true
|
| 1113 |
+
assert Sum(1/(n*sqrt(log(n))*log(log(n))), (n, 100, oo)).is_convergent() is S.false
|
| 1114 |
+
assert Sum(log(log(n))/(n*log(n)**2), (n, 100, oo)).is_convergent() is S.true
|
| 1115 |
+
assert Sum(log(n)/n**2, (n, 5, oo)).is_convergent() is S.true
|
| 1116 |
+
|
| 1117 |
+
# alternating series tests --
|
| 1118 |
+
assert Sum((-1)**(n - 1)/(n**2 - 1), (n, 3, oo)).is_convergent() is S.true
|
| 1119 |
+
|
| 1120 |
+
# with -negativeInfinite Limits
|
| 1121 |
+
assert Sum(1/(n**2 + 1), (n, -oo, 1)).is_convergent() is S.true
|
| 1122 |
+
assert Sum(1/(n - 1), (n, -oo, -1)).is_convergent() is S.false
|
| 1123 |
+
assert Sum(1/(n**2 - 1), (n, -oo, -5)).is_convergent() is S.true
|
| 1124 |
+
assert Sum(1/(n**2 - 1), (n, -oo, 2)).is_convergent() is S.true
|
| 1125 |
+
assert Sum(1/(n**2 - 1), (n, -oo, oo)).is_convergent() is S.true
|
| 1126 |
+
|
| 1127 |
+
# piecewise functions
|
| 1128 |
+
f = Piecewise((n**(-2), n <= 1), (n**2, n > 1))
|
| 1129 |
+
assert Sum(f, (n, 1, oo)).is_convergent() is S.false
|
| 1130 |
+
assert Sum(f, (n, -oo, oo)).is_convergent() is S.false
|
| 1131 |
+
assert Sum(f, (n, 1, 100)).is_convergent() is S.true
|
| 1132 |
+
#assert Sum(f, (n, -oo, 1)).is_convergent() is S.true
|
| 1133 |
+
|
| 1134 |
+
# integral test
|
| 1135 |
+
|
| 1136 |
+
assert Sum(log(n)/n**3, (n, 1, oo)).is_convergent() is S.true
|
| 1137 |
+
assert Sum(-log(n)/n**3, (n, 1, oo)).is_convergent() is S.true
|
| 1138 |
+
# the following function has maxima located at (x, y) =
|
| 1139 |
+
# (1.2, 0.43), (3.0, -0.25) and (6.8, 0.050)
|
| 1140 |
+
eq = (x - 2)*(x**2 - 6*x + 4)*exp(-x)
|
| 1141 |
+
assert Sum(eq, (x, 1, oo)).is_convergent() is S.true
|
| 1142 |
+
assert Sum(eq, (x, 1, 2)).is_convergent() is S.true
|
| 1143 |
+
assert Sum(1/(x**3), (x, 1, oo)).is_convergent() is S.true
|
| 1144 |
+
assert Sum(1/(x**S.Half), (x, 1, oo)).is_convergent() is S.false
|
| 1145 |
+
|
| 1146 |
+
# issue 19545
|
| 1147 |
+
assert Sum(1/n - 3/(3*n +2), (n, 1, oo)).is_convergent() is S.true
|
| 1148 |
+
|
| 1149 |
+
# issue 19836
|
| 1150 |
+
assert Sum(4/(n + 2) - 5/(n + 1) + 1/n,(n, 7, oo)).is_convergent() is S.true
|
| 1151 |
+
|
| 1152 |
+
|
| 1153 |
+
def test_is_absolutely_convergent():
|
| 1154 |
+
assert Sum((-1)**n, (n, 1, oo)).is_absolutely_convergent() is S.false
|
| 1155 |
+
assert Sum((-1)**n/n**2, (n, 1, oo)).is_absolutely_convergent() is S.true
|
| 1156 |
+
|
| 1157 |
+
|
| 1158 |
+
@XFAIL
|
| 1159 |
+
def test_convergent_failing():
|
| 1160 |
+
# dirichlet tests
|
| 1161 |
+
assert Sum(sin(n)/n, (n, 1, oo)).is_convergent() is S.true
|
| 1162 |
+
assert Sum(sin(2*n)/n, (n, 1, oo)).is_convergent() is S.true
|
| 1163 |
+
|
| 1164 |
+
|
| 1165 |
+
def test_issue_6966():
|
| 1166 |
+
i, k, m = symbols('i k m', integer=True)
|
| 1167 |
+
z_i, q_i = symbols('z_i q_i')
|
| 1168 |
+
a_k = Sum(-q_i*z_i/k,(i,1,m))
|
| 1169 |
+
b_k = a_k.diff(z_i)
|
| 1170 |
+
assert isinstance(b_k, Sum)
|
| 1171 |
+
assert b_k == Sum(-q_i/k,(i,1,m))
|
| 1172 |
+
|
| 1173 |
+
|
| 1174 |
+
def test_issue_10156():
|
| 1175 |
+
cx = Sum(2*y**2*x, (x, 1,3))
|
| 1176 |
+
e = 2*y*Sum(2*cx*x**2, (x, 1, 9))
|
| 1177 |
+
assert e.factor() == \
|
| 1178 |
+
8*y**3*Sum(x, (x, 1, 3))*Sum(x**2, (x, 1, 9))
|
| 1179 |
+
|
| 1180 |
+
|
| 1181 |
+
def test_issue_10973():
|
| 1182 |
+
assert Sum((-n + (n**3 + 1)**(S(1)/3))/log(n), (n, 1, oo)).is_convergent() is S.true
|
| 1183 |
+
|
| 1184 |
+
|
| 1185 |
+
def test_issue_14103():
|
| 1186 |
+
assert Sum(sin(n)**2 + cos(n)**2 - 1, (n, 1, oo)).is_convergent() is S.true
|
| 1187 |
+
assert Sum(sin(pi*n), (n, 1, oo)).is_convergent() is S.true
|
| 1188 |
+
|
| 1189 |
+
|
| 1190 |
+
def test_issue_14129():
|
| 1191 |
+
x = Symbol('x', zero=False)
|
| 1192 |
+
assert Sum( k*x**k, (k, 0, n-1)).doit() == \
|
| 1193 |
+
Piecewise((n**2/2 - n/2, Eq(x, 1)), ((n*x*x**n -
|
| 1194 |
+
n*x**n - x*x**n + x)/(x - 1)**2, True))
|
| 1195 |
+
assert Sum( x**k, (k, 0, n-1)).doit() == \
|
| 1196 |
+
Piecewise((n, Eq(x, 1)), ((-x**n + 1)/(-x + 1), True))
|
| 1197 |
+
assert Sum( k*(x/y+x)**k, (k, 0, n-1)).doit() == \
|
| 1198 |
+
Piecewise((n*(n - 1)/2, Eq(x, y/(y + 1))),
|
| 1199 |
+
(x*(y + 1)*(n*x*y*(x + x/y)**(n - 1) +
|
| 1200 |
+
n*x*(x + x/y)**(n - 1) - n*y*(x + x/y)**(n - 1) -
|
| 1201 |
+
x*y*(x + x/y)**(n - 1) - x*(x + x/y)**(n - 1) + y)/
|
| 1202 |
+
(x*y + x - y)**2, True))
|
| 1203 |
+
|
| 1204 |
+
|
| 1205 |
+
def test_issue_14112():
|
| 1206 |
+
assert Sum((-1)**n/sqrt(n), (n, 1, oo)).is_absolutely_convergent() is S.false
|
| 1207 |
+
assert Sum((-1)**(2*n)/n, (n, 1, oo)).is_convergent() is S.false
|
| 1208 |
+
assert Sum((-2)**n + (-3)**n, (n, 1, oo)).is_convergent() is S.false
|
| 1209 |
+
|
| 1210 |
+
|
| 1211 |
+
def test_issue_14219():
|
| 1212 |
+
A = diag(0, 2, -3)
|
| 1213 |
+
res = diag(1, 15, -20)
|
| 1214 |
+
assert Sum(A**n, (n, 0, 3)).doit() == res
|
| 1215 |
+
|
| 1216 |
+
|
| 1217 |
+
def test_sin_times_absolutely_convergent():
|
| 1218 |
+
assert Sum(sin(n) / n**3, (n, 1, oo)).is_convergent() is S.true
|
| 1219 |
+
assert Sum(sin(n) * log(n) / n**3, (n, 1, oo)).is_convergent() is S.true
|
| 1220 |
+
|
| 1221 |
+
|
| 1222 |
+
def test_issue_14111():
|
| 1223 |
+
assert Sum(1/log(log(n)), (n, 22, oo)).is_convergent() is S.false
|
| 1224 |
+
|
| 1225 |
+
|
| 1226 |
+
def test_issue_14484():
|
| 1227 |
+
assert Sum(sin(n)/log(log(n)), (n, 22, oo)).is_convergent() is S.false
|
| 1228 |
+
|
| 1229 |
+
|
| 1230 |
+
def test_issue_14640():
|
| 1231 |
+
i, n = symbols("i n", integer=True)
|
| 1232 |
+
a, b, c = symbols("a b c", zero=False)
|
| 1233 |
+
|
| 1234 |
+
assert Sum(a**-i/(a - b), (i, 0, n)).doit() == Sum(
|
| 1235 |
+
1/(a*a**i - a**i*b), (i, 0, n)).doit() == Piecewise(
|
| 1236 |
+
(n + 1, Eq(1/a, 1)),
|
| 1237 |
+
((-a**(-n - 1) + 1)/(1 - 1/a), True))/(a - b)
|
| 1238 |
+
|
| 1239 |
+
assert Sum((b*a**i - c*a**i)**-2, (i, 0, n)).doit() == Piecewise(
|
| 1240 |
+
(n + 1, Eq(a**(-2), 1)),
|
| 1241 |
+
((-a**(-2*n - 2) + 1)/(1 - 1/a**2), True))/(b - c)**2
|
| 1242 |
+
|
| 1243 |
+
s = Sum(i*(a**(n - i) - b**(n - i))/(a - b), (i, 0, n)).doit()
|
| 1244 |
+
assert not s.has(Sum)
|
| 1245 |
+
assert s.subs({a: 2, b: 3, n: 5}) == 122
|
| 1246 |
+
|
| 1247 |
+
|
| 1248 |
+
def test_issue_15943():
|
| 1249 |
+
s = Sum(binomial(n, k)*factorial(n - k), (k, 0, n)).doit().rewrite(gamma)
|
| 1250 |
+
assert s == -E*(n + 1)*gamma(n + 1)*lowergamma(n + 1, 1)/gamma(n + 2
|
| 1251 |
+
) + E*gamma(n + 1)
|
| 1252 |
+
assert s.simplify() == E*(factorial(n) - lowergamma(n + 1, 1))
|
| 1253 |
+
|
| 1254 |
+
|
| 1255 |
+
def test_Sum_dummy_eq():
|
| 1256 |
+
assert not Sum(x, (x, a, b)).dummy_eq(1)
|
| 1257 |
+
assert not Sum(x, (x, a, b)).dummy_eq(Sum(x, (x, a, b), (a, 1, 2)))
|
| 1258 |
+
assert not Sum(x, (x, a, b)).dummy_eq(Sum(x, (x, a, c)))
|
| 1259 |
+
assert Sum(x, (x, a, b)).dummy_eq(Sum(x, (x, a, b)))
|
| 1260 |
+
d = Dummy()
|
| 1261 |
+
assert Sum(x, (x, a, d)).dummy_eq(Sum(x, (x, a, c)), c)
|
| 1262 |
+
assert not Sum(x, (x, a, d)).dummy_eq(Sum(x, (x, a, c)))
|
| 1263 |
+
assert Sum(x, (x, a, c)).dummy_eq(Sum(y, (y, a, c)))
|
| 1264 |
+
assert Sum(x, (x, a, d)).dummy_eq(Sum(y, (y, a, c)), c)
|
| 1265 |
+
assert not Sum(x, (x, a, d)).dummy_eq(Sum(y, (y, a, c)))
|
| 1266 |
+
|
| 1267 |
+
|
| 1268 |
+
def test_issue_15852():
|
| 1269 |
+
assert summation(x**y*y, (y, -oo, oo)).doit() == Sum(x**y*y, (y, -oo, oo))
|
| 1270 |
+
|
| 1271 |
+
|
| 1272 |
+
def test_exceptions():
|
| 1273 |
+
S = Sum(x, (x, a, b))
|
| 1274 |
+
raises(ValueError, lambda: S.change_index(x, x**2, y))
|
| 1275 |
+
S = Sum(x, (x, a, b), (x, 1, 4))
|
| 1276 |
+
raises(ValueError, lambda: S.index(x))
|
| 1277 |
+
S = Sum(x, (x, a, b), (y, 1, 4))
|
| 1278 |
+
raises(ValueError, lambda: S.reorder([x]))
|
| 1279 |
+
S = Sum(x, (x, y, b), (y, 1, 4))
|
| 1280 |
+
raises(ReorderError, lambda: S.reorder_limit(0, 1))
|
| 1281 |
+
S = Sum(x*y, (x, a, b), (y, 1, 4))
|
| 1282 |
+
raises(NotImplementedError, lambda: S.is_convergent())
|
| 1283 |
+
|
| 1284 |
+
|
| 1285 |
+
def test_sumproducts_assumptions():
|
| 1286 |
+
M = Symbol('M', integer=True, positive=True)
|
| 1287 |
+
|
| 1288 |
+
m = Symbol('m', integer=True)
|
| 1289 |
+
for func in [Sum, Product]:
|
| 1290 |
+
assert func(m, (m, -M, M)).is_positive is None
|
| 1291 |
+
assert func(m, (m, -M, M)).is_nonpositive is None
|
| 1292 |
+
assert func(m, (m, -M, M)).is_negative is None
|
| 1293 |
+
assert func(m, (m, -M, M)).is_nonnegative is None
|
| 1294 |
+
assert func(m, (m, -M, M)).is_finite is True
|
| 1295 |
+
|
| 1296 |
+
m = Symbol('m', integer=True, nonnegative=True)
|
| 1297 |
+
for func in [Sum, Product]:
|
| 1298 |
+
assert func(m, (m, 0, M)).is_positive is None
|
| 1299 |
+
assert func(m, (m, 0, M)).is_nonpositive is None
|
| 1300 |
+
assert func(m, (m, 0, M)).is_negative is False
|
| 1301 |
+
assert func(m, (m, 0, M)).is_nonnegative is True
|
| 1302 |
+
assert func(m, (m, 0, M)).is_finite is True
|
| 1303 |
+
|
| 1304 |
+
m = Symbol('m', integer=True, positive=True)
|
| 1305 |
+
for func in [Sum, Product]:
|
| 1306 |
+
assert func(m, (m, 1, M)).is_positive is True
|
| 1307 |
+
assert func(m, (m, 1, M)).is_nonpositive is False
|
| 1308 |
+
assert func(m, (m, 1, M)).is_negative is False
|
| 1309 |
+
assert func(m, (m, 1, M)).is_nonnegative is True
|
| 1310 |
+
assert func(m, (m, 1, M)).is_finite is True
|
| 1311 |
+
|
| 1312 |
+
m = Symbol('m', integer=True, negative=True)
|
| 1313 |
+
assert Sum(m, (m, -M, -1)).is_positive is False
|
| 1314 |
+
assert Sum(m, (m, -M, -1)).is_nonpositive is True
|
| 1315 |
+
assert Sum(m, (m, -M, -1)).is_negative is True
|
| 1316 |
+
assert Sum(m, (m, -M, -1)).is_nonnegative is False
|
| 1317 |
+
assert Sum(m, (m, -M, -1)).is_finite is True
|
| 1318 |
+
assert Product(m, (m, -M, -1)).is_positive is None
|
| 1319 |
+
assert Product(m, (m, -M, -1)).is_nonpositive is None
|
| 1320 |
+
assert Product(m, (m, -M, -1)).is_negative is None
|
| 1321 |
+
assert Product(m, (m, -M, -1)).is_nonnegative is None
|
| 1322 |
+
assert Product(m, (m, -M, -1)).is_finite is True
|
| 1323 |
+
|
| 1324 |
+
m = Symbol('m', integer=True, nonpositive=True)
|
| 1325 |
+
assert Sum(m, (m, -M, 0)).is_positive is False
|
| 1326 |
+
assert Sum(m, (m, -M, 0)).is_nonpositive is True
|
| 1327 |
+
assert Sum(m, (m, -M, 0)).is_negative is None
|
| 1328 |
+
assert Sum(m, (m, -M, 0)).is_nonnegative is None
|
| 1329 |
+
assert Sum(m, (m, -M, 0)).is_finite is True
|
| 1330 |
+
assert Product(m, (m, -M, 0)).is_positive is None
|
| 1331 |
+
assert Product(m, (m, -M, 0)).is_nonpositive is None
|
| 1332 |
+
assert Product(m, (m, -M, 0)).is_negative is None
|
| 1333 |
+
assert Product(m, (m, -M, 0)).is_nonnegative is None
|
| 1334 |
+
assert Product(m, (m, -M, 0)).is_finite is True
|
| 1335 |
+
|
| 1336 |
+
m = Symbol('m', integer=True)
|
| 1337 |
+
assert Sum(2, (m, 0, oo)).is_positive is None
|
| 1338 |
+
assert Sum(2, (m, 0, oo)).is_nonpositive is None
|
| 1339 |
+
assert Sum(2, (m, 0, oo)).is_negative is None
|
| 1340 |
+
assert Sum(2, (m, 0, oo)).is_nonnegative is None
|
| 1341 |
+
assert Sum(2, (m, 0, oo)).is_finite is None
|
| 1342 |
+
|
| 1343 |
+
assert Product(2, (m, 0, oo)).is_positive is None
|
| 1344 |
+
assert Product(2, (m, 0, oo)).is_nonpositive is None
|
| 1345 |
+
assert Product(2, (m, 0, oo)).is_negative is False
|
| 1346 |
+
assert Product(2, (m, 0, oo)).is_nonnegative is None
|
| 1347 |
+
assert Product(2, (m, 0, oo)).is_finite is None
|
| 1348 |
+
|
| 1349 |
+
assert Product(0, (x, M, M-1)).is_positive is True
|
| 1350 |
+
assert Product(0, (x, M, M-1)).is_finite is True
|
| 1351 |
+
|
| 1352 |
+
|
| 1353 |
+
def test_expand_with_assumptions():
|
| 1354 |
+
M = Symbol('M', integer=True, positive=True)
|
| 1355 |
+
x = Symbol('x', positive=True)
|
| 1356 |
+
m = Symbol('m', nonnegative=True)
|
| 1357 |
+
assert log(Product(x**m, (m, 0, M))).expand() == Sum(m*log(x), (m, 0, M))
|
| 1358 |
+
assert log(Product(exp(x**m), (m, 0, M))).expand() == Sum(x**m, (m, 0, M))
|
| 1359 |
+
assert log(Product(x**m, (m, 0, M))).rewrite(Sum).expand() == Sum(m*log(x), (m, 0, M))
|
| 1360 |
+
assert log(Product(exp(x**m), (m, 0, M))).rewrite(Sum).expand() == Sum(x**m, (m, 0, M))
|
| 1361 |
+
|
| 1362 |
+
n = Symbol('n', nonnegative=True)
|
| 1363 |
+
i, j = symbols('i,j', positive=True, integer=True)
|
| 1364 |
+
x, y = symbols('x,y', positive=True)
|
| 1365 |
+
assert log(Product(x**i*y**j, (i, 1, n), (j, 1, m))).expand() \
|
| 1366 |
+
== Sum(i*log(x) + j*log(y), (i, 1, n), (j, 1, m))
|
| 1367 |
+
|
| 1368 |
+
m = Symbol('m', nonnegative=True, integer=True)
|
| 1369 |
+
s = Sum(x**m, (m, 0, M))
|
| 1370 |
+
s_as_product = s.rewrite(Product)
|
| 1371 |
+
assert s_as_product.has(Product)
|
| 1372 |
+
assert s_as_product == log(Product(exp(x**m), (m, 0, M)))
|
| 1373 |
+
assert s_as_product.expand() == s
|
| 1374 |
+
s5 = s.subs(M, 5)
|
| 1375 |
+
s5_as_product = s5.rewrite(Product)
|
| 1376 |
+
assert s5_as_product.has(Product)
|
| 1377 |
+
assert s5_as_product.doit().expand() == s5.doit()
|
| 1378 |
+
|
| 1379 |
+
|
| 1380 |
+
def test_has_finite_limits():
|
| 1381 |
+
x = Symbol('x')
|
| 1382 |
+
assert Sum(1, (x, 1, 9)).has_finite_limits is True
|
| 1383 |
+
assert Sum(1, (x, 1, oo)).has_finite_limits is False
|
| 1384 |
+
M = Symbol('M')
|
| 1385 |
+
assert Sum(1, (x, 1, M)).has_finite_limits is None
|
| 1386 |
+
M = Symbol('M', positive=True)
|
| 1387 |
+
assert Sum(1, (x, 1, M)).has_finite_limits is True
|
| 1388 |
+
x = Symbol('x', positive=True)
|
| 1389 |
+
M = Symbol('M')
|
| 1390 |
+
assert Sum(1, (x, 1, M)).has_finite_limits is True
|
| 1391 |
+
|
| 1392 |
+
assert Sum(1, (x, 1, M), (y, -oo, oo)).has_finite_limits is False
|
| 1393 |
+
|
| 1394 |
+
def test_has_reversed_limits():
|
| 1395 |
+
assert Sum(1, (x, 1, 1)).has_reversed_limits is False
|
| 1396 |
+
assert Sum(1, (x, 1, 9)).has_reversed_limits is False
|
| 1397 |
+
assert Sum(1, (x, 1, -9)).has_reversed_limits is True
|
| 1398 |
+
assert Sum(1, (x, 1, 0)).has_reversed_limits is True
|
| 1399 |
+
assert Sum(1, (x, 1, oo)).has_reversed_limits is False
|
| 1400 |
+
M = Symbol('M')
|
| 1401 |
+
assert Sum(1, (x, 1, M)).has_reversed_limits is None
|
| 1402 |
+
M = Symbol('M', positive=True, integer=True)
|
| 1403 |
+
assert Sum(1, (x, 1, M)).has_reversed_limits is False
|
| 1404 |
+
assert Sum(1, (x, 1, M), (y, -oo, oo)).has_reversed_limits is False
|
| 1405 |
+
M = Symbol('M', negative=True)
|
| 1406 |
+
assert Sum(1, (x, 1, M)).has_reversed_limits is True
|
| 1407 |
+
|
| 1408 |
+
assert Sum(1, (x, 1, M), (y, -oo, oo)).has_reversed_limits is True
|
| 1409 |
+
assert Sum(1, (x, oo, oo)).has_reversed_limits is None
|
| 1410 |
+
|
| 1411 |
+
|
| 1412 |
+
def test_has_empty_sequence():
|
| 1413 |
+
assert Sum(1, (x, 1, 1)).has_empty_sequence is False
|
| 1414 |
+
assert Sum(1, (x, 1, 9)).has_empty_sequence is False
|
| 1415 |
+
assert Sum(1, (x, 1, -9)).has_empty_sequence is False
|
| 1416 |
+
assert Sum(1, (x, 1, 0)).has_empty_sequence is True
|
| 1417 |
+
assert Sum(1, (x, y, y - 1)).has_empty_sequence is True
|
| 1418 |
+
assert Sum(1, (x, 3, 2), (y, -oo, oo)).has_empty_sequence is True
|
| 1419 |
+
assert Sum(1, (y, -oo, oo), (x, 3, 2)).has_empty_sequence is True
|
| 1420 |
+
assert Sum(1, (x, oo, oo)).has_empty_sequence is False
|
| 1421 |
+
|
| 1422 |
+
|
| 1423 |
+
def test_empty_sequence():
|
| 1424 |
+
assert Product(x*y, (x, -oo, oo), (y, 1, 0)).doit() == 1
|
| 1425 |
+
assert Product(x*y, (y, 1, 0), (x, -oo, oo)).doit() == 1
|
| 1426 |
+
assert Sum(x, (x, -oo, oo), (y, 1, 0)).doit() == 0
|
| 1427 |
+
assert Sum(x, (y, 1, 0), (x, -oo, oo)).doit() == 0
|
| 1428 |
+
|
| 1429 |
+
|
| 1430 |
+
def test_issue_8016():
|
| 1431 |
+
k = Symbol('k', integer=True)
|
| 1432 |
+
n, m = symbols('n, m', integer=True, positive=True)
|
| 1433 |
+
s = Sum(binomial(m, k)*binomial(m, n - k)*(-1)**k, (k, 0, n))
|
| 1434 |
+
assert s.doit().simplify() == \
|
| 1435 |
+
cos(pi*n/2)*gamma(m + 1)/gamma(n/2 + 1)/gamma(m - n/2 + 1)
|
| 1436 |
+
|
| 1437 |
+
|
| 1438 |
+
def test_issue_14313():
|
| 1439 |
+
assert Sum(S.Half**floor(n/2), (n, 1, oo)).is_convergent()
|
| 1440 |
+
|
| 1441 |
+
|
| 1442 |
+
def test_issue_14563():
|
| 1443 |
+
# The assertion was failing due to no assumptions methods in Sums and Product
|
| 1444 |
+
assert 1 % Sum(1, (x, 0, 1)) == 1
|
| 1445 |
+
|
| 1446 |
+
|
| 1447 |
+
def test_issue_16735():
|
| 1448 |
+
assert Sum(5**n/gamma(n+1), (n, 1, oo)).is_convergent() is S.true
|
| 1449 |
+
|
| 1450 |
+
|
| 1451 |
+
def test_issue_14871():
|
| 1452 |
+
assert Sum((Rational(1, 10))**n*rf(0, n)/factorial(n), (n, 0, oo)).rewrite(factorial).doit() == 1
|
| 1453 |
+
|
| 1454 |
+
|
| 1455 |
+
def test_issue_17165():
|
| 1456 |
+
n = symbols("n", integer=True)
|
| 1457 |
+
x = symbols('x')
|
| 1458 |
+
s = (x*Sum(x**n, (n, -1, oo)))
|
| 1459 |
+
ssimp = s.doit().simplify()
|
| 1460 |
+
|
| 1461 |
+
assert ssimp == Piecewise((-1/(x - 1), (x > -1) & (x < 1)),
|
| 1462 |
+
(x*Sum(x**n, (n, -1, oo)), True)), ssimp
|
| 1463 |
+
assert ssimp.simplify() == ssimp
|
| 1464 |
+
|
| 1465 |
+
|
| 1466 |
+
def test_issue_19379():
|
| 1467 |
+
assert Sum(factorial(n)/factorial(n + 2), (n, 1, oo)).is_convergent() is S.true
|
| 1468 |
+
|
| 1469 |
+
|
| 1470 |
+
def test_issue_20777():
|
| 1471 |
+
assert Sum(exp(x*sin(n/m)), (n, 1, m)).doit() == Sum(exp(x*sin(n/m)), (n, 1, m))
|
| 1472 |
+
|
| 1473 |
+
|
| 1474 |
+
def test__dummy_with_inherited_properties_concrete():
|
| 1475 |
+
x = Symbol('x')
|
| 1476 |
+
|
| 1477 |
+
from sympy.core.containers import Tuple
|
| 1478 |
+
d = _dummy_with_inherited_properties_concrete(Tuple(x, 0, 5))
|
| 1479 |
+
assert d.is_real
|
| 1480 |
+
assert d.is_integer
|
| 1481 |
+
assert d.is_nonnegative
|
| 1482 |
+
assert d.is_extended_nonnegative
|
| 1483 |
+
|
| 1484 |
+
d = _dummy_with_inherited_properties_concrete(Tuple(x, 1, 9))
|
| 1485 |
+
assert d.is_real
|
| 1486 |
+
assert d.is_integer
|
| 1487 |
+
assert d.is_positive
|
| 1488 |
+
assert d.is_odd is None
|
| 1489 |
+
|
| 1490 |
+
d = _dummy_with_inherited_properties_concrete(Tuple(x, -5, 5))
|
| 1491 |
+
assert d.is_real
|
| 1492 |
+
assert d.is_integer
|
| 1493 |
+
assert d.is_positive is None
|
| 1494 |
+
assert d.is_extended_nonnegative is None
|
| 1495 |
+
assert d.is_odd is None
|
| 1496 |
+
|
| 1497 |
+
d = _dummy_with_inherited_properties_concrete(Tuple(x, -1.5, 1.5))
|
| 1498 |
+
assert d.is_real
|
| 1499 |
+
assert d.is_integer is None
|
| 1500 |
+
assert d.is_positive is None
|
| 1501 |
+
assert d.is_extended_nonnegative is None
|
| 1502 |
+
|
| 1503 |
+
N = Symbol('N', integer=True, positive=True)
|
| 1504 |
+
d = _dummy_with_inherited_properties_concrete(Tuple(x, 2, N))
|
| 1505 |
+
assert d.is_real
|
| 1506 |
+
assert d.is_positive
|
| 1507 |
+
assert d.is_integer
|
| 1508 |
+
|
| 1509 |
+
# Return None if no assumptions are added
|
| 1510 |
+
N = Symbol('N', integer=True, positive=True)
|
| 1511 |
+
d = _dummy_with_inherited_properties_concrete(Tuple(N, 2, 4))
|
| 1512 |
+
assert d is None
|
| 1513 |
+
|
| 1514 |
+
x = Symbol('x', negative=True)
|
| 1515 |
+
raises(InconsistentAssumptions,
|
| 1516 |
+
lambda: _dummy_with_inherited_properties_concrete(Tuple(x, 1, 5)))
|
| 1517 |
+
|
| 1518 |
+
|
| 1519 |
+
def test_matrixsymbol_summation_numerical_limits():
|
| 1520 |
+
A = MatrixSymbol('A', 3, 3)
|
| 1521 |
+
n = Symbol('n', integer=True)
|
| 1522 |
+
|
| 1523 |
+
assert Sum(A**n, (n, 0, 2)).doit() == Identity(3) + A + A**2
|
| 1524 |
+
assert Sum(A, (n, 0, 2)).doit() == 3*A
|
| 1525 |
+
assert Sum(n*A, (n, 0, 2)).doit() == 3*A
|
| 1526 |
+
|
| 1527 |
+
B = Matrix([[0, n, 0], [-1, 0, 0], [0, 0, 2]])
|
| 1528 |
+
ans = Matrix([[0, 6, 0], [-4, 0, 0], [0, 0, 8]]) + 4*A
|
| 1529 |
+
assert Sum(A+B, (n, 0, 3)).doit() == ans
|
| 1530 |
+
ans = A*Matrix([[0, 6, 0], [-4, 0, 0], [0, 0, 8]])
|
| 1531 |
+
assert Sum(A*B, (n, 0, 3)).doit() == ans
|
| 1532 |
+
|
| 1533 |
+
ans = (A**2*Matrix([[-2, 0, 0], [0,-2, 0], [0, 0, 4]]) +
|
| 1534 |
+
A**3*Matrix([[0, -9, 0], [3, 0, 0], [0, 0, 8]]) +
|
| 1535 |
+
A*Matrix([[0, 1, 0], [-1, 0, 0], [0, 0, 2]]))
|
| 1536 |
+
assert Sum(A**n*B**n, (n, 1, 3)).doit() == ans
|
| 1537 |
+
|
| 1538 |
+
|
| 1539 |
+
def test_issue_21651():
|
| 1540 |
+
i = Symbol('i')
|
| 1541 |
+
a = Sum(floor(2*2**(-i)), (i, S.One, 2))
|
| 1542 |
+
assert a.doit() == S.One
|
| 1543 |
+
|
| 1544 |
+
|
| 1545 |
+
@XFAIL
|
| 1546 |
+
def test_matrixsymbol_summation_symbolic_limits():
|
| 1547 |
+
N = Symbol('N', integer=True, positive=True)
|
| 1548 |
+
|
| 1549 |
+
A = MatrixSymbol('A', 3, 3)
|
| 1550 |
+
n = Symbol('n', integer=True)
|
| 1551 |
+
assert Sum(A, (n, 0, N)).doit() == (N+1)*A
|
| 1552 |
+
assert Sum(n*A, (n, 0, N)).doit() == (N**2/2+N/2)*A
|
| 1553 |
+
|
| 1554 |
+
|
| 1555 |
+
def test_summation_by_residues():
|
| 1556 |
+
x = Symbol('x')
|
| 1557 |
+
|
| 1558 |
+
# Examples from Nakhle H. Asmar, Loukas Grafakos,
|
| 1559 |
+
# Complex Analysis with Applications
|
| 1560 |
+
assert eval_sum_residue(1 / (x**2 + 1), (x, -oo, oo)) == pi/tanh(pi)
|
| 1561 |
+
assert eval_sum_residue(1 / x**6, (x, S(1), oo)) == pi**6/945
|
| 1562 |
+
assert eval_sum_residue(1 / (x**2 + 9), (x, -oo, oo)) == pi/(3*tanh(3*pi))
|
| 1563 |
+
assert eval_sum_residue(1 / (x**2 + 1)**2, (x, -oo, oo)).cancel() == \
|
| 1564 |
+
(-pi**2*tanh(pi)**2 + pi*tanh(pi) + pi**2)/(2*tanh(pi)**2)
|
| 1565 |
+
assert eval_sum_residue(x**2 / (x**2 + 1)**2, (x, -oo, oo)).cancel() == \
|
| 1566 |
+
(-pi**2 + pi*tanh(pi) + pi**2*tanh(pi)**2)/(2*tanh(pi)**2)
|
| 1567 |
+
assert eval_sum_residue(1 / (4*x**2 - 1), (x, -oo, oo)) == 0
|
| 1568 |
+
assert eval_sum_residue(x**2 / (x**2 - S(1)/4)**2, (x, -oo, oo)) == pi**2/2
|
| 1569 |
+
assert eval_sum_residue(1 / (4*x**2 - 1)**2, (x, -oo, oo)) == pi**2/8
|
| 1570 |
+
assert eval_sum_residue(1 / ((x - S(1)/2)**2 + 1), (x, -oo, oo)) == pi*tanh(pi)
|
| 1571 |
+
assert eval_sum_residue(1 / x**2, (x, S(1), oo)) == pi**2/6
|
| 1572 |
+
assert eval_sum_residue(1 / x**4, (x, S(1), oo)) == pi**4/90
|
| 1573 |
+
assert eval_sum_residue(1 / x**2 / (x**2 + 4), (x, S(1), oo)) == \
|
| 1574 |
+
-pi*(-pi/12 - 1/(16*pi) + 1/(8*tanh(2*pi)))/2
|
| 1575 |
+
|
| 1576 |
+
# Some examples made from 1 / (x**2 + 1)
|
| 1577 |
+
assert eval_sum_residue(1 / (x**2 + 1), (x, S(0), oo)) == \
|
| 1578 |
+
S(1)/2 + pi/(2*tanh(pi))
|
| 1579 |
+
assert eval_sum_residue(1 / (x**2 + 1), (x, S(1), oo)) == \
|
| 1580 |
+
-S(1)/2 + pi/(2*tanh(pi))
|
| 1581 |
+
assert eval_sum_residue(1 / (x**2 + 1), (x, S(-1), oo)) == \
|
| 1582 |
+
1 + pi/(2*tanh(pi))
|
| 1583 |
+
assert eval_sum_residue((-1)**x / (x**2 + 1), (x, -oo, oo)) == \
|
| 1584 |
+
pi/sinh(pi)
|
| 1585 |
+
assert eval_sum_residue((-1)**x / (x**2 + 1), (x, S(0), oo)) == \
|
| 1586 |
+
pi/(2*sinh(pi)) + S(1)/2
|
| 1587 |
+
assert eval_sum_residue((-1)**x / (x**2 + 1), (x, S(1), oo)) == \
|
| 1588 |
+
-S(1)/2 + pi/(2*sinh(pi))
|
| 1589 |
+
assert eval_sum_residue((-1)**x / (x**2 + 1), (x, S(-1), oo)) == \
|
| 1590 |
+
pi/(2*sinh(pi))
|
| 1591 |
+
|
| 1592 |
+
# Some examples made from shifting of 1 / (x**2 + 1)
|
| 1593 |
+
assert eval_sum_residue(1 / (x**2 + 2*x + 2), (x, S(-1), oo)) == S(1)/2 + pi/(2*tanh(pi))
|
| 1594 |
+
assert eval_sum_residue(1 / (x**2 + 4*x + 5), (x, S(-2), oo)) == S(1)/2 + pi/(2*tanh(pi))
|
| 1595 |
+
assert eval_sum_residue(1 / (x**2 - 2*x + 2), (x, S(1), oo)) == S(1)/2 + pi/(2*tanh(pi))
|
| 1596 |
+
assert eval_sum_residue(1 / (x**2 - 4*x + 5), (x, S(2), oo)) == S(1)/2 + pi/(2*tanh(pi))
|
| 1597 |
+
assert eval_sum_residue((-1)**x * -1 / (x**2 + 2*x + 2), (x, S(-1), oo)) == S(1)/2 + pi/(2*sinh(pi))
|
| 1598 |
+
assert eval_sum_residue((-1)**x * -1 / (x**2 -2*x + 2), (x, S(1), oo)) == S(1)/2 + pi/(2*sinh(pi))
|
| 1599 |
+
|
| 1600 |
+
# Some examples made from 1 / x**2
|
| 1601 |
+
assert eval_sum_residue(1 / x**2, (x, S(2), oo)) == -1 + pi**2/6
|
| 1602 |
+
assert eval_sum_residue(1 / x**2, (x, S(3), oo)) == -S(5)/4 + pi**2/6
|
| 1603 |
+
assert eval_sum_residue((-1)**x / x**2, (x, S(1), oo)) == -pi**2/12
|
| 1604 |
+
assert eval_sum_residue((-1)**x / x**2, (x, S(2), oo)) == 1 - pi**2/12
|
| 1605 |
+
|
| 1606 |
+
|
| 1607 |
+
@slow
|
| 1608 |
+
def test_summation_by_residues_failing():
|
| 1609 |
+
x = Symbol('x')
|
| 1610 |
+
|
| 1611 |
+
# Failing because of the bug in residue computation
|
| 1612 |
+
assert eval_sum_residue(x**2 / (x**4 + 1), (x, S(1), oo))
|
| 1613 |
+
assert eval_sum_residue(1 / ((x - 1)*(x - 2) + 1), (x, -oo, oo)) != 0
|
| 1614 |
+
|
| 1615 |
+
|
| 1616 |
+
def test_process_limits():
|
| 1617 |
+
from sympy.concrete.expr_with_limits import _process_limits
|
| 1618 |
+
|
| 1619 |
+
# these should be (x, Range(3)) not Range(3)
|
| 1620 |
+
raises(ValueError, lambda: _process_limits(
|
| 1621 |
+
Range(3), discrete=True))
|
| 1622 |
+
raises(ValueError, lambda: _process_limits(
|
| 1623 |
+
Range(3), discrete=False))
|
| 1624 |
+
# these should be (x, union) not union
|
| 1625 |
+
# (but then we would get a TypeError because we don't
|
| 1626 |
+
# handle non-contiguous sets: see below use of `union`)
|
| 1627 |
+
union = Or(x < 1, x > 3).as_set()
|
| 1628 |
+
raises(ValueError, lambda: _process_limits(
|
| 1629 |
+
union, discrete=True))
|
| 1630 |
+
raises(ValueError, lambda: _process_limits(
|
| 1631 |
+
union, discrete=False))
|
| 1632 |
+
|
| 1633 |
+
# error not triggered if not needed
|
| 1634 |
+
assert _process_limits((x, 1, 2)) == ([(x, 1, 2)], 1)
|
| 1635 |
+
|
| 1636 |
+
# this equivalence is used to detect Reals in _process_limits
|
| 1637 |
+
assert isinstance(S.Reals, Interval)
|
| 1638 |
+
|
| 1639 |
+
C = Integral # continuous limits
|
| 1640 |
+
assert C(x, x >= 5) == C(x, (x, 5, oo))
|
| 1641 |
+
assert C(x, x < 3) == C(x, (x, -oo, 3))
|
| 1642 |
+
ans = C(x, (x, 0, 3))
|
| 1643 |
+
assert C(x, And(x >= 0, x < 3)) == ans
|
| 1644 |
+
assert C(x, (x, Interval.Ropen(0, 3))) == ans
|
| 1645 |
+
raises(TypeError, lambda: C(x, (x, Range(3))))
|
| 1646 |
+
|
| 1647 |
+
# discrete limits
|
| 1648 |
+
for D in (Sum, Product):
|
| 1649 |
+
r, ans = Range(3, 10, 2), D(2*x + 3, (x, 0, 3))
|
| 1650 |
+
assert D(x, (x, r)) == ans
|
| 1651 |
+
assert D(x, (x, r.reversed)) == ans
|
| 1652 |
+
r, ans = Range(3, oo, 2), D(2*x + 3, (x, 0, oo))
|
| 1653 |
+
assert D(x, (x, r)) == ans
|
| 1654 |
+
assert D(x, (x, r.reversed)) == ans
|
| 1655 |
+
r, ans = Range(-oo, 5, 2), D(3 - 2*x, (x, 0, oo))
|
| 1656 |
+
assert D(x, (x, r)) == ans
|
| 1657 |
+
assert D(x, (x, r.reversed)) == ans
|
| 1658 |
+
raises(TypeError, lambda: D(x, x > 0))
|
| 1659 |
+
raises(ValueError, lambda: D(x, Interval(1, 3)))
|
| 1660 |
+
raises(NotImplementedError, lambda: D(x, (x, union)))
|
| 1661 |
+
|
| 1662 |
+
|
| 1663 |
+
def test_pr_22677():
|
| 1664 |
+
b = Symbol('b', integer=True, positive=True)
|
| 1665 |
+
assert Sum(1/x**2,(x, 0, b)).doit() == Sum(x**(-2), (x, 0, b))
|
| 1666 |
+
assert Sum(1/(x - b)**2,(x, 0, b-1)).doit() == Sum(
|
| 1667 |
+
(-b + x)**(-2), (x, 0, b - 1))
|
| 1668 |
+
|
| 1669 |
+
|
| 1670 |
+
def test_issue_23952():
|
| 1671 |
+
p, q = symbols("p q", real=True, nonnegative=True)
|
| 1672 |
+
k1, k2 = symbols("k1 k2", integer=True, nonnegative=True)
|
| 1673 |
+
n = Symbol("n", integer=True, positive=True)
|
| 1674 |
+
expr = Sum(abs(k1 - k2)*p**k1 *(1 - q)**(n - k2),
|
| 1675 |
+
(k1, 0, n), (k2, 0, n))
|
| 1676 |
+
assert expr.subs(p,0).subs(q,1).subs(n, 3).doit() == 3
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (3.42 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/_print_helpers.cpython-312.pyc
ADDED
|
Binary file (2.46 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/add.cpython-312.pyc
ADDED
|
Binary file (54.7 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/alphabets.cpython-312.pyc
ADDED
|
Binary file (366 Bytes). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/assumptions.cpython-312.pyc
ADDED
|
Binary file (21.8 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/assumptions_generated.cpython-312.pyc
ADDED
|
Binary file (15.5 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/backend.cpython-312.pyc
ADDED
|
Binary file (4.59 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/basic.cpython-312.pyc
ADDED
|
Binary file (84.3 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/cache.cpython-312.pyc
ADDED
|
Binary file (8.47 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/compatibility.cpython-312.pyc
ADDED
|
Binary file (1.36 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/containers.cpython-312.pyc
ADDED
|
Binary file (19.1 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/core.cpython-312.pyc
ADDED
|
Binary file (1.2 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/coreerrors.cpython-312.pyc
ADDED
|
Binary file (1.53 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/decorators.cpython-312.pyc
ADDED
|
Binary file (9.92 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/evalf.cpython-312.pyc
ADDED
|
Binary file (65.3 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/exprtools.cpython-312.pyc
ADDED
|
Binary file (62.3 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/facts.cpython-312.pyc
ADDED
|
Binary file (23.6 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/intfunc.cpython-312.pyc
ADDED
|
Binary file (14.3 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/kind.cpython-312.pyc
ADDED
|
Binary file (14.7 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/logic.cpython-312.pyc
ADDED
|
Binary file (14 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/mod.cpython-312.pyc
ADDED
|
Binary file (11.3 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/mul.cpython-312.pyc
ADDED
|
Binary file (87.5 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/multidimensional.cpython-312.pyc
ADDED
|
Binary file (4.93 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/operations.cpython-312.pyc
ADDED
|
Binary file (29.4 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/parameters.cpython-312.pyc
ADDED
|
Binary file (5.49 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/power.cpython-312.pyc
ADDED
|
Binary file (88.5 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/random.cpython-312.pyc
ADDED
|
Binary file (8.86 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/relational.cpython-312.pyc
ADDED
|
Binary file (60.2 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/rules.cpython-312.pyc
ADDED
|
Binary file (2.33 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/singleton.cpython-312.pyc
ADDED
|
Binary file (8.1 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/sorting.cpython-312.pyc
ADDED
|
Binary file (12.3 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/symbol.cpython-312.pyc
ADDED
|
Binary file (36.1 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/sympify.cpython-312.pyc
ADDED
|
Binary file (21.3 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/trace.cpython-312.pyc
ADDED
|
Binary file (554 Bytes). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/__pycache__/traversal.cpython-312.pyc
ADDED
|
Binary file (11 kB). View file
|
|
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/benchmarks/__init__.py
ADDED
|
File without changes
|
TTS/Kokoro/.venv/Lib/site-packages/sympy/core/benchmarks/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (210 Bytes). View file
|
|
|