Comments (3)
The call to cancel
here fails:
Lines 371 to 382 in 7dc74d8
It is assumed that since
f = P/Q
and b**n
is a factor of Q
then cancel(f*b**n)
will cancel the factor of b**n
out of the denominator of f
. This fails with floats though since b**n
might not exactly divide Q
.
We know that it is supposed to divide Q
so we can just compute the quotient and discard the remainder:
diff --git a/sympy/polys/partfrac.py b/sympy/polys/partfrac.py
index 000c5d7354..b9a5d32609 100644
--- a/sympy/polys/partfrac.py
+++ b/sympy/polys/partfrac.py
@@ -379,7 +379,7 @@ def apart_list_full_decomposition(P, Q, dummygen):
b = d.as_expr()
U += [ u.diff(x, n - 1) ]
- h = cancel(f*b**n) / u**n
+ h = cancel(P/Q.quo(d**n)) / u**n
H, subs = [h], []
That gives the correct answer albeit with some nontrivial rounding error:
In [1]: e = (6.43369157032015e-9*x**3 + 1.35203404799555e-5*x**2 + 0.00357538393743079*x + 0.085)/(4.
...: 74334912634438e-11*x**4 + 4.09576274286244e-6*x**3 + 0.00334241812250921*x**2 + 0.15406018058
...: 983*x + 1.0)
In [2]: apart(nsimplify(e), full=True).evalf()
Out[2]:
133.599202650992 1.07757928431867 0.395006955518971 0.564264854137341
──────────────────── + ─────────────────── + ──────────────────── + ────────────────────
x + 85524.0054884464 x + 774.88576677949 x + 40.7977016133126 x + 7.79746609204661
In [3]: apart(e, full=True).evalf()
Out[3]:
133.594113472755 1.07757928431773 0.395006955518863 0.564264854137269
──────────────────── + ─────────────────── + ──────────────────── + ────────────────────
x + 85524.0054884464 x + 774.88576677949 x + 40.7977016133126 x + 7.79746609204661
from sympy.
A little more is needed:
diff --git a/sympy/polys/partfrac.py b/sympy/polys/partfrac.py
index 000c5d7354..1ee1f653e0 100644
--- a/sympy/polys/partfrac.py
+++ b/sympy/polys/partfrac.py
@@ -368,6 +368,8 @@ def apart_list_full_decomposition(P, Q, dummygen):
.. [1] [Bronstein93]_
"""
+ P_orig, Q_orig = P, Q
+
f, x, U = P/Q, P.gen, []
u = Function('u')(x)
@@ -379,7 +381,7 @@ def apart_list_full_decomposition(P, Q, dummygen):
b = d.as_expr()
U += [ u.diff(x, n - 1) ]
- h = cancel(f*b**n) / u**n
+ h = cancel(P_orig/Q_orig.quo(d**n)) / u**n
H, subs = [h], []
from sympy.
I've opened gh-26649 with a fix.
from sympy.
Related Issues (20)
- sympy.Float and sympy.Integer compare equal but have different hashes HOT 1
- Duffing Spring Simulation HOT 5
- Formal Power Series with even or odd terms shouldn't return Piecewise formula for coefficients HOT 3
- The `join` method is unable to create beams with discontinuous values of elastic modulus.
- `lambdify()` and `lambdastr()` can't unpack `sympy.Matrix` typed parameter symbols properly
- RecursionError in sympy.solvers.inequalities.reduce_inequalities with custom function HOT 1
- The `point_cflexure` method doesn't return points when a region of the bending moment line is 0.
- variable of differentiation returns True from `has_free` HOT 4
- Symbolic specifying of locations that are "just" before or "just" after another location. HOT 8
- parse_mathematica cannot handle greek letters HOT 1
- FiniteField.__call__ returns different types depending on whether flint is installed or not HOT 6
- Sphinx build failing regularly HOT 1
- calling `latex` on `Array` with less rows than columns, and at least 10 columns, emit bad latex
- Does solve(...) respects symbol(..., real=True) assumption?
- Sympy results are int, not Integer HOT 1
- Regression: lambdify of Derivative instance now throws PrintMethodNotImplementedError HOT 24
- sp.solve: expected an integer, got rational HOT 2
- Cannot determine truth value of Relational HOT 1
- plot error after a "clean" simpify check up HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sympy.