Sympy 中的 conds='none' 不起作用 [英] conds='none' in Sympy does not work

查看:25
本文介绍了Sympy 中的 conds='none' 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下积分

x,x1,x2,t=symbols('x x1 x2 t')f=t*x1*x2*(x-t)**(-Rational('0.5'))整合(f,t).简化()

这个结果是一个分段函数

分段((2*sqrt(x)*x1*x2*(-I*t**2*sqrt((t - x)/x) - I*t*x*sqrt((t)- x)/x) + 2*t*x + 2*I*x**2*sqrt((t - x)/x) - 2*x**2)/(3*(t - x)), Abs(t/x) > 1), (2*sqrt(x)*x1*x2*(-t**2*sqrt((-t + x)/x) - t*x*sqrt((-t + x)/x) + 2*t*x + 2*x**2*sqrt((-t + x)/x) - 2*x**2)/(3*(t - x)), 真的))

我想忽略第一种情况,所以解决方案是这样做

integrate(f,t,conds='none').simplify()

但这并没有改变输出,它仍然是

分段((2*sqrt(x)*x1*x2*(-I*t**2*sqrt((t - x)/x) - I*t*x*sqrt((t)- x)/x) + 2*t*x + 2*I*x**2*sqrt((t - x)/x) - 2*x**2)/(3*(t - x)), Abs(t/x) > 1), (2*sqrt(x)*x1*x2*(-t**2*sqrt((-t + x)/x) - t*x*sqrt((-t + x)/x) + 2*t*x + 2*x**2*sqrt((-t + x)/x) - 2*x**2)/(3*(t - x)), 真的))

那我怎么能忽略这些条件?

解决方案

我认为 conds 不影响这个积分的原因是条件不是收敛条件,而是影响积分的条件被积函数的形式.conds 的文档特指收敛条件.

<块引用>

确定的不适当积分通常需要微妙的收敛条件.通过 conds='piecewise', 'separate' 或 'none' 分别将它们作为分段函数返回,作为单独的结果(即结果将是元组)或根本不返回(默认为分段").

您可以通过将其条件替换为 False 来摆脱您不想要的情况.

<预><代码>>>>积分(f, t).subs(Abs(t/x)>1, False).simplify()2*sqrt(x)*x1*x2*(t**2*sqrt((-t + x)/x) + t*x*sqrt((-t + x)/x) - 2*t*x- 2*x**2*sqrt((-t + x)/x) + 2*x**2)/(3*(-t + x))

I have the following integral

x,x1,x2,t=symbols('x x1 x2 t')
f=t*x1*x2*(x-t)**(-Rational('0.5'))
integrate(f,t).simplify()

The result of this is a piecewise function

Piecewise((2*sqrt(x)*x1*x2*(-I*t**2*sqrt((t - x)/x) - I*t*x*sqrt((t - x)/x) + 2*t*x + 2*I*x**2*sqrt((t - x)/x) - 2*x**2)/(3*(t - x)), Abs(t/x) > 1), (2*sqrt(x)*x1*x2*(-t**2*sqrt((-t + x)/x) - t*x*sqrt((-t + x)/x) + 2*t*x + 2*x**2*sqrt((-t + x)/x) - 2*x**2)/(3*(t - x)), True))

I want to ignore the first case, so the solution would be to do

integrate(f,t,conds='none').simplify()

But this doesn't change the output, which is still

Piecewise((2*sqrt(x)*x1*x2*(-I*t**2*sqrt((t - x)/x) - I*t*x*sqrt((t - x)/x) + 2*t*x + 2*I*x**2*sqrt((t - x)/x) - 2*x**2)/(3*(t - x)), Abs(t/x) > 1), (2*sqrt(x)*x1*x2*(-t**2*sqrt((-t + x)/x) - t*x*sqrt((-t + x)/x) + 2*t*x + 2*x**2*sqrt((-t + x)/x) - 2*x**2)/(3*(t - x)), True))

How can I ignore the conditions then?

解决方案

I think the reason that conds does not affect this integral is that the conditions are not convergence conditions, but rather conditions that affect the form of the integrand. The documentation of conds specifically refers to conditions for convergence.

Definite improper integrals often entail delicate convergence conditions. Pass conds=’piecewise’, ‘separate’ or ‘none’ to have these returned, respectively, as a Piecewise function, as a separate result (i.e. result will be a tuple), or not at all (default is ‘piecewise’).

You can get rid of the case you don't want by replacing its condition with False.

>>> integrate(f, t).subs(Abs(t/x)>1, False).simplify()
2*sqrt(x)*x1*x2*(t**2*sqrt((-t + x)/x) + t*x*sqrt((-t + x)/x) - 2*t*x - 2*x**2*sqrt((-t + x)/x) + 2*x**2)/(3*(-t + x))

这篇关于Sympy 中的 conds='none' 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆