WOLFRAM

When do I use GenerateConditions and Assumptions with Integrate or Sum?

Integrate and Sum evaluations return generic solutions. These are usually correct for general cases, but may not apply for specific parameter values (see Generic and Non-Generic Cases).

For example, this summation is unbounded if x is greater than or equal to 1:

In[1]:= Sum[x^n, {n, 0, Infinity}]

Out[1]=  1 / (1 - x)  

The GenerateConditions->True option tells the function to state when the solution is valid.

Now we confirm that the result applies only for Abs[x]<1:

In[2]:= Sum[x^n, {n, 0, Infinity}, GenerateConditions -> True]

Out[2]=  ConditionalExpression[1/(1 - x), Abs[x] < 1]  

If any condition is known already, the Assumptions option can be used to tell Sum about it. This gives a simple output suitable for later use in the code. The explicit condition used here will need to be remembered when the result is used:

In[3]:= Sum[x^n, {n, 0, Infinity}, Assumptions -> {-1 < x && x < 1}]

Out[3]= 1/(1 - x)    

Assumptions can also be passed using the Assuming function or $Assumptions:

In[4]:= Integrate[1/(x + a), {x, 0, 1}]

Out[4]= ConditionalExpression[-Log[a] + Log[1 + a],
   Re[a] > 0 || Re[a] < -1 || NotElement[a, Reals]


In[5]:= Assuming[a > 0, Integrate[1/(x + a), {x, 0, 1}]]

Out[5]= Log[1 + 1/a]

In[6]:= $Assumptions = a > 0;
        Integrate[1/(x + a), {x, 0, 1}]

Out[7]= Log[1 + 1/a]

This resets $Assumptions to its default:

In[8]:= $Assumptions =. ;  

该文档是否有帮助?

任何建议?

非常感谢您的反馈!

提交

联系支持团队

从账单到产品激活,以及任何技术相关内容,无论您遇到任何问题,我们都在此为您提供帮助。

1-800-WOLFRAM (+1-217-398-0700 美国境外用户)

客服支持

周一至周五
8am–5pm 美国中部时区

  • 产品注册或激活
  • 预售信息和订单
  • 安装帮助和首次启动

高级技术支持 (面向特定用户)

周一至周四
8am–7pm 美国中部时区

周五
8:30–10am & 11am–5pm 美国中部时区

  • 优先技术支持
  • Wolfram 专家助理专员
  • Wolfram 语言编程帮助
  • 高级安装支持