本文整理汇总了Python中sympy.expand_mul函数的典型用法代码示例。如果您正苦于以下问题:Python expand_mul函数的具体用法?Python expand_mul怎么用?Python expand_mul使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了expand_mul函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_issue841
def test_issue841():
from sympy import expand_mul
from sympy.abc import k
assert expand_mul(integrate(exp(-x ** 2) * exp(I * k * x), (x, -oo, oo))) == sqrt(pi) * exp(-k ** 2 / 4)
a, d = symbols("a d", positive=True)
assert expand_mul(integrate(exp(-a * x ** 2 + 2 * d * x), (x, -oo, oo))) == sqrt(pi) * exp(d ** 2 / a) / sqrt(a)
开发者ID:arunenigma,项目名称:sympy,代码行数:7,代码来源:test_integrals.py
示例2: E
def E(expr):
res1 = integrate(expr*exponential(x, rate)*normal(y, mu1, sigma1),
(x, 0, oo), (y, -oo, oo), meijerg=True)
res2 = integrate(expr*exponential(x, rate)*normal(y, mu1, sigma1),
(y, -oo, oo), (x, 0, oo), meijerg=True)
assert expand_mul(res1) == expand_mul(res2)
return res1
开发者ID:chaffra,项目名称:sympy,代码行数:7,代码来源:test_meijerint.py
示例3: eval
def eval(cls, arg):
from sympy.simplify.simplify import signsimp
if hasattr(arg, '_eval_Abs'):
obj = arg._eval_Abs()
if obj is not None:
return obj
# handle what we can
arg = signsimp(arg, evaluate=False)
if arg.is_Mul:
known = []
unk = []
for t in arg.args:
tnew = cls(t)
if tnew.func is cls:
unk.append(tnew.args[0])
else:
known.append(tnew)
known = Mul(*known)
unk = cls(Mul(*unk), evaluate=False) if unk else S.One
return known*unk
if arg is S.NaN:
return S.NaN
if arg.is_Pow:
base, exponent = arg.as_base_exp()
if base.is_real:
if exponent.is_integer:
if exponent.is_even:
return arg
if base is S.NegativeOne:
return S.One
if base.func is cls and exponent is S.NegativeOne:
return arg
return Abs(base)**exponent
if base.is_positive == True:
return base**re(exponent)
return (-base)**re(exponent)*C.exp(-S.Pi*im(exponent))
if isinstance(arg, C.exp):
return C.exp(re(arg.args[0]))
if arg.is_zero: # it may be an Expr that is zero
return S.Zero
if arg.is_nonnegative:
return arg
if arg.is_nonpositive:
return -arg
if arg.is_imaginary:
arg2 = -S.ImaginaryUnit * arg
if arg2.is_nonnegative:
return arg2
if arg.is_Add:
if arg.has(S.Infinity, S.NegativeInfinity):
if any(a.is_infinite for a in arg.as_real_imag()):
return S.Infinity
if arg.is_real is None and arg.is_imaginary is None:
if all(a.is_real or a.is_imaginary or (S.ImaginaryUnit*a).is_real for a in arg.args):
from sympy import expand_mul
return sqrt(expand_mul(arg*arg.conjugate()))
if arg.is_real is False and arg.is_imaginary is False:
from sympy import expand_mul
return sqrt(expand_mul(arg*arg.conjugate()))
开发者ID:fetrocinol,项目名称:sympy,代码行数:59,代码来源:complexes.py
示例4: test_acsch
def test_acsch():
x = Symbol('x')
assert acsch(-x) == acsch(-x)
assert acsch(x) == -acsch(-x)
# values at fixed points
assert acsch(1) == log(1 + sqrt(2))
assert acsch(-1) == - log(1 + sqrt(2))
assert acsch(0) == zoo
assert acsch(2) == log((1+sqrt(5))/2)
assert acsch(-2) == - log((1+sqrt(5))/2)
assert acsch(I) == - I*pi/2
assert acsch(-I) == I*pi/2
assert acsch(-I*(sqrt(6) + sqrt(2))) == I*pi / 12
assert acsch(I*(sqrt(2) + sqrt(6))) == -I*pi / 12
assert acsch(-I*(1 + sqrt(5))) == I*pi / 10
assert acsch(I*(1 + sqrt(5))) == -I*pi / 10
assert acsch(-I*2 / sqrt(2 - sqrt(2))) == I*pi / 8
assert acsch(I*2 / sqrt(2 - sqrt(2))) == -I*pi / 8
assert acsch(-I*2) == I*pi / 6
assert acsch(I*2) == -I*pi / 6
assert acsch(-I*sqrt(2 + 2/sqrt(5))) == I*pi / 5
assert acsch(I*sqrt(2 + 2/sqrt(5))) == -I*pi / 5
assert acsch(-I*sqrt(2)) == I*pi / 4
assert acsch(I*sqrt(2)) == -I*pi / 4
assert acsch(-I*(sqrt(5)-1)) == 3*I*pi / 10
assert acsch(I*(sqrt(5)-1)) == -3*I*pi / 10
assert acsch(-I*2 / sqrt(3)) == I*pi / 3
assert acsch(I*2 / sqrt(3)) == -I*pi / 3
assert acsch(-I*2 / sqrt(2 + sqrt(2))) == 3*I*pi / 8
assert acsch(I*2 / sqrt(2 + sqrt(2))) == -3*I*pi / 8
assert acsch(-I*sqrt(2 - 2/sqrt(5))) == 2*I*pi / 5
assert acsch(I*sqrt(2 - 2/sqrt(5))) == -2*I*pi / 5
assert acsch(-I*(sqrt(6) - sqrt(2))) == 5*I*pi / 12
assert acsch(I*(sqrt(6) - sqrt(2))) == -5*I*pi / 12
# properties
# acsch(x) == asinh(1/x)
assert acsch(-I*sqrt(2)) == asinh(I/sqrt(2))
assert acsch(-I*2 / sqrt(3)) == asinh(I*sqrt(3) / 2)
# acsch(x) == -I*asin(I/x)
assert acsch(-I*sqrt(2)) == -I*asin(-1/sqrt(2))
assert acsch(-I*2 / sqrt(3)) == -I*asin(-sqrt(3)/2)
# csch(acsch(x)) / x == 1
assert expand_mul(csch(acsch(-I*(sqrt(6) + sqrt(2)))) / (-I*(sqrt(6) + sqrt(2)))) == 1
assert expand_mul(csch(acsch(I*(1 + sqrt(5)))) / ((I*(1 + sqrt(5))))) == 1
assert (csch(acsch(I*sqrt(2 - 2/sqrt(5)))) / (I*sqrt(2 - 2/sqrt(5)))).simplify() == 1
assert (csch(acsch(-I*sqrt(2 - 2/sqrt(5)))) / (-I*sqrt(2 - 2/sqrt(5)))).simplify() == 1
# numerical evaluation
assert str(acsch(5*I+1).n(6)) == '0.0391819 - 0.193363*I'
assert str(acsch(-5*I+1).n(6)) == '0.0391819 + 0.193363*I'
开发者ID:certik,项目名称:sympy,代码行数:56,代码来源:test_hyperbolic.py
示例5: test_asech
def test_asech():
x = Symbol('x')
assert asech(-x) == asech(-x)
# values at fixed points
assert asech(1) == 0
assert asech(-1) == pi*I
assert asech(0) == oo
assert asech(2) == I*pi/3
assert asech(-2) == 2*I*pi / 3
# at infinites
assert asech(oo) == I*pi/2
assert asech(-oo) == I*pi/2
assert asech(zoo) == nan
assert asech(I) == log(1 + sqrt(2)) - I*pi/2
assert asech(-I) == log(1 + sqrt(2)) + I*pi/2
assert asech(sqrt(2) - sqrt(6)) == 11*I*pi / 12
assert asech(sqrt(2 - 2/sqrt(5))) == I*pi / 10
assert asech(-sqrt(2 - 2/sqrt(5))) == 9*I*pi / 10
assert asech(2 / sqrt(2 + sqrt(2))) == I*pi / 8
assert asech(-2 / sqrt(2 + sqrt(2))) == 7*I*pi / 8
assert asech(sqrt(5) - 1) == I*pi / 5
assert asech(1 - sqrt(5)) == 4*I*pi / 5
assert asech(-sqrt(2*(2 + sqrt(2)))) == 5*I*pi / 8
# properties
# asech(x) == acosh(1/x)
assert asech(sqrt(2)) == acosh(1/sqrt(2))
assert asech(2/sqrt(3)) == acosh(sqrt(3)/2)
assert asech(2/sqrt(2 + sqrt(2))) == acosh(sqrt(2 + sqrt(2))/2)
assert asech(S(2)) == acosh(1/S(2))
# asech(x) == I*acos(1/x)
# (Note: the exact formula is asech(x) == +/- I*acos(1/x))
assert asech(-sqrt(2)) == I*acos(-1/sqrt(2))
assert asech(-2/sqrt(3)) == I*acos(-sqrt(3)/2)
assert asech(-S(2)) == I*acos(-S.Half)
assert asech(-2/sqrt(2)) == I*acos(-sqrt(2)/2)
# sech(asech(x)) / x == 1
assert expand_mul(sech(asech(sqrt(6) - sqrt(2))) / (sqrt(6) - sqrt(2))) == 1
assert expand_mul(sech(asech(sqrt(6) + sqrt(2))) / (sqrt(6) + sqrt(2))) == 1
assert (sech(asech(sqrt(2 + 2/sqrt(5)))) / (sqrt(2 + 2/sqrt(5)))).simplify() == 1
assert (sech(asech(-sqrt(2 + 2/sqrt(5)))) / (-sqrt(2 + 2/sqrt(5)))).simplify() == 1
assert (sech(asech(sqrt(2*(2 + sqrt(2))))) / (sqrt(2*(2 + sqrt(2))))).simplify() == 1
assert expand_mul(sech(asech((1 + sqrt(5)))) / ((1 + sqrt(5)))) == 1
assert expand_mul(sech(asech((-1 - sqrt(5)))) / ((-1 - sqrt(5)))) == 1
assert expand_mul(sech(asech((-sqrt(6) - sqrt(2)))) / ((-sqrt(6) - sqrt(2)))) == 1
# numerical evaluation
assert str(asech(5*I).n(6)) == '0.19869 - 1.5708*I'
assert str(asech(-5*I).n(6)) == '0.19869 + 1.5708*I'
开发者ID:certik,项目名称:sympy,代码行数:55,代码来源:test_hyperbolic.py
示例6: test_issue_3940
def test_issue_3940():
a, b, c, d = symbols('a:d', positive=True, finite=True)
assert integrate(exp(-x**2 + I*c*x), x) == \
-sqrt(pi)*exp(-c**2/4)*erf(I*c/2 - x)/2
assert integrate(exp(a*x**2 + b*x + c), x) == \
sqrt(pi)*exp(c)*exp(-b**2/(4*a))*erfi(sqrt(a)*x + b/(2*sqrt(a)))/(2*sqrt(a))
from sympy import expand_mul
from sympy.abc import k
assert expand_mul(integrate(exp(-x**2)*exp(I*k*x), (x, -oo, oo))) == \
sqrt(pi)*exp(-k**2/4)
a, d = symbols('a d', positive=True)
assert expand_mul(integrate(exp(-a*x**2 + 2*d*x), (x, -oo, oo))) == \
sqrt(pi)*exp(d**2/a)/sqrt(a)
开发者ID:baoqchau,项目名称:sympy,代码行数:14,代码来源:test_integrals.py
示例7: eval
def eval(cls, arg):
from sympy.simplify.simplify import signsimp
if hasattr(arg, "_eval_Abs"):
obj = arg._eval_Abs()
if obj is not None:
return obj
# handle what we can
arg = signsimp(arg, evaluate=False)
if arg.is_Mul:
known = []
unk = []
for t in arg.args:
tnew = cls(t)
if tnew.func is cls:
unk.append(tnew.args[0])
else:
known.append(tnew)
known = Mul(*known)
unk = cls(Mul(*unk), evaluate=False) if unk else S.One
return known * unk
if arg is S.NaN:
return S.NaN
if arg.is_zero: # it may be an Expr that is zero
return S.Zero
if arg.is_nonnegative:
return arg
if arg.is_nonpositive:
return -arg
if arg.is_imaginary:
arg2 = -S.ImaginaryUnit * arg
if arg2.is_nonnegative:
return arg2
if arg.is_real is False and arg.is_imaginary is False:
from sympy import expand_mul
return sqrt(expand_mul(arg * arg.conjugate()))
if arg.is_real is None and arg.is_imaginary is None and arg.is_Add:
if all(a.is_real or a.is_imaginary or (S.ImaginaryUnit * a).is_real for a in arg.args):
from sympy import expand_mul
return sqrt(expand_mul(arg * arg.conjugate()))
if arg.is_Pow:
base, exponent = arg.as_base_exp()
if exponent.is_even and base.is_real:
return arg
if exponent.is_integer and base is S.NegativeOne:
return S.One
开发者ID:Bercio,项目名称:sympy,代码行数:48,代码来源:complexes.py
示例8: eval
def eval(cls, arg):
if arg.is_Mul:
known = []
unk = []
for t in arg.args:
tnew = cls(t)
if tnew.func is cls:
unk.append(tnew.args[0])
else:
known.append(tnew)
known = Mul(*known)
unk = cls(Mul(*unk), evaluate=False) if unk else S.One
return known*unk
if arg is S.NaN:
return S.NaN
if arg.is_zero:
return arg
if arg.is_positive:
return arg
if arg.is_negative:
return -arg
if arg.is_real is False:
from sympy import expand_mul
return sqrt( expand_mul(arg * arg.conjugate()) )
if arg.is_Pow:
base, exponent = arg.as_base_exp()
if exponent.is_even and base.is_real:
return arg
开发者ID:MichaelMayorov,项目名称:sympy,代码行数:28,代码来源:complexes.py
示例9: _eval_as_leading_term
def _eval_as_leading_term(self, x):
from sympy import expand_mul, factor_terms
old = self
self = expand_mul(self)
if not self.is_Add:
return self.as_leading_term(x)
unbounded = [t for t in self.args if t.is_unbounded]
self = self.func(*[t.as_leading_term(x) for t in self.args]).removeO()
if not self:
# simple leading term analysis gave us 0 but we have to send
# back a term, so compute the leading term (via series)
return old.compute_leading_term(x)
elif self is S.NaN:
return old.func._from_args(unbounded)
elif not self.is_Add:
return self
else:
plain = self.func(*[s for s, _ in self.extract_leading_order(x)])
rv = factor_terms(plain, fraction=False)
rv_simplify = rv.simplify()
# if it simplifies to an x-free expression, return that;
# tests don't fail if we don't but it seems nicer to do this
if x not in rv_simplify.free_symbols:
if rv_simplify.is_zero and plain.is_zero is not True:
return (self - plain)._eval_as_leading_term(x)
return rv_simplify
return rv
开发者ID:Jeyatharsini,项目名称:sympy,代码行数:31,代码来源:add.py
示例10: _eval_as_leading_term
def _eval_as_leading_term(self, x):
from sympy import expand_mul, factor_terms
old = self
self = expand_mul(self)
if not self.is_Add:
return self.as_leading_term(x)
unbounded = [t for t in self.args if t.is_unbounded]
if unbounded:
return Add._from_args(unbounded)
self = Add(*[t.as_leading_term(x) for t in self.args]).removeO()
if not self:
# simple leading term analysis gave us 0 but we have to send
# back a term, so compute the leading term (via series)
return old.compute_leading_term(x)
elif not self.is_Add:
return self
else:
plain = Add(*[s for s, _ in self.extract_leading_order(x)])
rv = factor_terms(plain, fraction=False)
rv_fraction = factor_terms(rv, fraction=True)
# if it simplifies to an x-free expression, return that;
# tests don't fail if we don't but it seems nicer to do this
if x not in rv_fraction.free_symbols:
return rv_fraction
return rv
开发者ID:StefenYin,项目名称:sympy,代码行数:29,代码来源:add.py
示例11: _eval_expand_trig
def _eval_expand_trig(self, **hints):
from sympy import expand_mul
arg = self.args[0]
x = None
if arg.is_Add: # TODO, implement more if deep stuff here
# TODO: Do this more efficiently for more than two terms
x, y = arg.as_two_terms()
sx = sin(x, evaluate=False)._eval_expand_trig()
sy = sin(y, evaluate=False)._eval_expand_trig()
cx = cos(x, evaluate=False)._eval_expand_trig()
cy = cos(y, evaluate=False)._eval_expand_trig()
return sx*cy + sy*cx
else:
n, x = arg.as_coeff_Mul(rational=True)
if n.is_Integer: # n will be positive because of .eval
# canonicalization
# See http://mathworld.wolfram.com/Multiple-AngleFormulas.html
if n.is_odd:
return (-1)**((n - 1)/2)*C.chebyshevt(n, sin(x))
else:
return expand_mul((-1)**(n/2 - 1)*cos(x)*C.chebyshevu(n -
1, sin(x)), deep=False)
pi_coeff = _pi_coeff(arg)
if pi_coeff is not None:
if pi_coeff.is_Rational:
return self.rewrite(sqrt)
return sin(arg)
开发者ID:bhlegm,项目名称:sympy,代码行数:28,代码来源:trigonometric.py
示例12: _bell_poly
def _bell_poly(n, prev):
s = 1
a = 1
for k in xrange(2, n+1):
a = a * (n-k+1) // (k-1)
s += a * prev[k-1]
return expand_mul(_sym * s)
开发者ID:BDGLunde,项目名称:sympy,代码行数:7,代码来源:numbers.py
示例13: _bell_incomplete_poly
def _bell_incomplete_poly(n, k, symbols):
r"""
The second kind of Bell polynomials (incomplete Bell polynomials).
Calculated by recurrence formula:
.. math:: B_{n,k}(x_1, x_2, \dotsc, x_{n-k+1}) =
\sum_{m=1}^{n-k+1}
\x_m \binom{n-1}{m-1} B_{n-m,k-1}(x_1, x_2, \dotsc, x_{n-m-k})
where
B_{0,0} = 1;
B_{n,0} = 0; for n>=1
B_{0,k} = 0; for k>=1
"""
if (n==0) and (k==0):
return S.One
elif (n==0) or (k==0):
return S.Zero
s = S.Zero
a = S.One
for m in xrange(1, n-k+2):
s += a*bell._bell_incomplete_poly(n-m, k-1, symbols)*symbols[m-1]
a = a*(n-m)/m
return expand_mul(s)
开发者ID:BDGLunde,项目名称:sympy,代码行数:26,代码来源:numbers.py
示例14: test_sqrtdenest
def test_sqrtdenest():
d = {sqrt(5 + 2 * sqrt(6)): sqrt(2) + sqrt(3),
sqrt(sqrt(2)): sqrt(sqrt(2)),
sqrt(5+sqrt(7)): sqrt(5+sqrt(7)),
sqrt(3+sqrt(5+2*sqrt(7))):
sqrt(6+3*sqrt(7))/(sqrt(2)*(5+2*sqrt(7))**Rational(1,4)) +
3*(5+2*sqrt(7))**Rational(1,4)/(sqrt(2)*sqrt(6+3*sqrt(7))),
sqrt(3+2*sqrt(3)): 3**Rational(1,4)/sqrt(2)+3/(sqrt(2)*3**Rational(1,4))}
for i in d:
assert sqrtdenest(i) == d[i] or denester([i])[0] == d[i]
# this test caused a pattern recognition failure in sqrtdenest
# nest = sqrt(2) + sqrt(5) - sqrt(7)
nest = symbols('nest')
x0, x1, x2, x3, x4, x5, x6 = symbols('x:7')
l = sqrt(2) + sqrt(5)
r = sqrt(7) + nest
s = (l**2 - r**2).expand() + nest**2 # == nest**2
ok = solve(nest**4 - s**2, nest)[1] # this will change if results order changes
assert abs((l - r).subs(nest, ok).n()) < 1e-12
x0 = sqrt(3)
x2 = root(45*I*x0 - 28, 3)
x3 = 19/x2
x4 = x2 + x3
x5 = -x4 - 14
x6 = sqrt(-x5)
ans = -x0*x6/3 + x0*sqrt(-x4 + 28 - 6*sqrt(210)*x6/x5)/3
assert expand_mul(radsimp(ok) - ans) == 0
# issue 2554
eq = sqrt(sqrt(sqrt(2) + 2) + 2)
assert sqrtdenest(eq) == eq
开发者ID:AlexandruFlorescu,项目名称:sympy,代码行数:31,代码来源:test_sqrtdenest.py
示例15: _combine_inverse
def _combine_inverse(lhs, rhs):
"""
Returns lhs - rhs, but treats arguments like symbols, so things like
oo - oo return 0, instead of a nan.
"""
from sympy import oo, I, expand_mul
if lhs == oo and rhs == oo or lhs == oo*I and rhs == oo*I:
return S.Zero
return expand_mul(lhs - rhs)
开发者ID:ENuge,项目名称:sympy,代码行数:9,代码来源:add.py
示例16: _eval_expand_func
def _eval_expand_func(self, **hints):
from sympy import log, expand_mul, Dummy, exp_polar, I
s, z = self.args
if s == 1:
return -log(1 + exp_polar(-I*pi)*z)
if s.is_Integer and s <= 0:
u = Dummy('u')
start = u/(1 - u)
for _ in range(-s):
start = u*start.diff(u)
return expand_mul(start).subs(u, z)
return polylog(s, z)
开发者ID:abhishekkumawat23,项目名称:sympy,代码行数:12,代码来源:zeta_functions.py
示例17: _inverse_mellin_transform
def _inverse_mellin_transform(F, s, x_, strip, as_meijerg=False):
""" A helper for the real inverse_mellin_transform function, this one here
assumes x to be real and positive. """
from sympy import (expand, expand_mul, hyperexpand, meijerg, And, Or,
arg, pi, re, factor, Heaviside, gamma, Add)
x = _dummy('t', 'inverse-mellin-transform', F, positive=True)
# Actually, we won't try integration at all. Instead we use the definition
# of the Meijer G function as a fairly general inverse mellin transform.
F = F.rewrite(gamma)
for g in [factor(F), expand_mul(F), expand(F)]:
if g.is_Add:
# do all terms separately
ress = [_inverse_mellin_transform(G, s, x, strip, as_meijerg,
noconds=False) \
for G in g.args]
conds = [p[1] for p in ress]
ress = [p[0] for p in ress]
res = Add(*ress)
if not as_meijerg:
res = factor(res, gens=res.atoms(Heaviside))
return res.subs(x, x_), And(*conds)
try:
a, b, C, e, fac = _rewrite_gamma(g, s, strip[0], strip[1])
except IntegralTransformError:
continue
G = meijerg(a, b, C/x**e)
if as_meijerg:
h = G
else:
h = hyperexpand(G)
if h.is_Piecewise and len(h.args) == 3:
# XXX we break modularity here!
h = Heaviside(x - abs(C))*h.args[0].args[0] \
+ Heaviside(abs(C) - x)*h.args[1].args[0]
# We must ensure that the intgral along the line we want converges,
# and return that value.
# See [L], 5.2
cond = [abs(arg(G.argument)) < G.delta*pi]
# Note: we allow ">=" here, this corresponds to convergence if we let
# limits go to oo symetrically. ">" corresponds to absolute convergence.
cond += [And(Or(len(G.ap) != len(G.bq), 0 >= re(G.nu) + 1),
abs(arg(G.argument)) == G.delta*pi)]
cond = Or(*cond)
if cond is False:
raise IntegralTransformError('Inverse Mellin', F, 'does not converge')
return (h*fac).subs(x, x_), cond
raise IntegralTransformError('Inverse Mellin', F, '')
开发者ID:ALGHeArT,项目名称:sympy,代码行数:49,代码来源:transforms.py
示例18: _eval_expand_func
def _eval_expand_func(self, **hints):
from sympy import log, expand_mul, Dummy, exp_polar, I
if hints.get('deep', False):
s, z = map(lambda x: x._eval_expand_func(**hints), self.args)
else:
s, z = self.args
if s == 1:
return -log(1 + exp_polar(-I*pi)*z)
if s.is_Integer and s <= 0:
u = Dummy('u')
start = u/(1 - u)
for _ in range(-s):
start = u*start.diff(u)
return expand_mul(start).subs(u, z)
return polylog(s, z)
开发者ID:ALGHeArT,项目名称:sympy,代码行数:15,代码来源:zeta_functions.py
示例19: solution
def solution(pars):
(a2,a1,a0),(t1,t2),(k1,k2),(y0,yd0)=pars
a2,a1,a0 = map(int,[a2,a1,a0])
den = a2*s**2+a1*s+a0
V1 = apart(1/s/den).as_ordered_terms() # const.
V2 = apart(1/s**2/den).as_ordered_terms() # lin.
Iv1,Iv2 = ilt_pfe(V1),ilt_pfe(V2)
LIC = (a2*(s*y0+yd0) + a1*y0)/den
y1 = ILT(LIC, s,t)
y2 = k1*Iv2 # k1, t
y3 = (k2-k1)*Iv2.subs(t,t-t1)*H(t-t1) # k2-k1,(t-t1)*H(t-t1)
y4 = (t1*(k2-k1)-k2*t2)*Iv1.subs(t,t-t1)*H(t-t1) # t1*(k2-k1)-k2*t2,H(t-t1), nulove pre spojite
y5 = -k2*Iv2.subs(t,t-t2)*H(t-t2) # -k2, (t-t2)*H(t-t2)
y = expand_mul(simplify(y1+y2+y3+y4+y5))
return y
开发者ID:misolietavec,项目名称:notebooks_MA2,代码行数:15,代码来源:ode_lap_discont.py
示例20: eval
def eval(cls, nu, z):
from sympy import unpolarify, expand_mul, uppergamma, exp, gamma, factorial
nu2 = unpolarify(nu)
if nu != nu2:
return expint(nu2, z)
if nu.is_Integer and nu <= 0 or (not nu.is_Integer and (2 * nu).is_Integer):
return unpolarify(expand_mul(z ** (nu - 1) * uppergamma(1 - nu, z)))
# Extract branching information. This can be deduced from what is
# explained in lowergamma.eval().
z, n = z.extract_branch_factor()
if n == 0:
return
if nu.is_integer:
if (nu > 0) is not True:
return
return expint(nu, z) - 2 * pi * I * n * (-1) ** (nu - 1) / factorial(nu - 1) * unpolarify(z) ** (nu - 1)
else:
return (exp(2 * I * pi * nu * n) - 1) * z ** (nu - 1) * gamma(1 - nu) + expint(nu, z)
开发者ID:ness01,项目名称:sympy,代码行数:20,代码来源:error_functions.py
注:本文中的sympy.expand_mul函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论