A computer algebra system written in pure Python http://sympy.org/ . To get started to with contributing https://github.com/sympy/sympy/wiki/Introduction-to-contributing
factor(10+5*I)
no longer factor to 5*(2+I)
?
I am trying to simplify a general Taylor series of function f:
f = sym.Function('f')
x, x_0, h = sym.symbols("x x_0 h", real=True)
# works fine:
ts = sym.series(f(x),x, x_0, 4)
# but substituting x-x_0 by h
ts.subs(x-x_0,h)
# just returns 𝑂(1;𝑥→𝑥0)
Why is the (x-x0) in the Taylor series not substituted correctly?
@PrometheusPi subs
will replace a sum like x - x_0
(= x + (-1)*x_0
) in an expression only if that is also a sum that contains the same arguments:
In [19]: (x - x_0 + 1).subs(x - x_0, h)
Out[19]: h + 1
Otherwise, one must substitute x
alone:
In [24]: print(ts.subs(x, x_0 + h))
f(x_0) + h*Subs(Derivative(f(_xi_1), _xi_1), _xi_1, x_0) + h**2*Subs(Derivative(f(_xi_1), (_xi_1, 2)), _xi_1, x_0)/2 + h**3*Subs(Derivative(f(_xi_1), (_xi_1, 3)), _xi_1, x_0)/6 + O(h**4)
class MyCoordSys3D(CoordSys3D):
def __init__(self):
self.latex_vects = [r'\mathbf{%s}' % n for n in self.vector_names]
y
or alpha
.
replace
with a pattern.
>>> a, b, c = Wild('a'), Wild('b'), Wild('c')
>>> expr.replace((a**b)**c, a**(b*c))
y
integrate(Heaviside(x,0), (x,-1,1) =1
, but instead sympy returns Integral(Heaviside(x, 0), (x, -1, 1))
. Works fine if I omit the second argument of Heaviside
, but I think it should work in any case, as the value at x=0
is irrelevant for the integration (set of measure zero).
@laolux:privacytools.io Many integrators like meijerint
work by looking up the results in a table. The table may contain Heaviside(x)
but not Heaviside(x, 0)
which is a different object.
>>> Heaviside(x) == Heaviside(x, 0)
False
It may be possible to extend the matching code to handle this but that may not be easy to implement. Another entry should probably be added.