9
$\begingroup$

I need define the function with parameter so I could directly generate a power series expansion. The problem is that in some cases ConditionalExpression appears in output. Here is my code:

S[x_, l_] := 
  (C[1] + 
     Integrate[
       E^(2 Sum[t^i/i, {i, 1, l - 1}])*(1 - t)^2*
         Sum[(l - i*2)*t^i, {i, 1, l - 1}]/((t - 1)*t^l), 
       {t, 1, x}])*
   x^(l - 1)*E^(-2 Sum[x^i/i, {i, 1, l - 1}])/(1 - x)^2; 

Table[S[x, i], {i, 2, 3}] // TableForm
CoefficientList[Series[S[x, 2] , {x, 0, 3}], x]
CoefficientList[Series[S[x, 3] , {x, 0, 3}], x]
CoefficientList[Series[S[x, 3][[1]] , {x, 0, 3}], x]
$\endgroup$
  • $\begingroup$ Why not make up a rule (if you are sure of the Trueness of your conditional) rule = ConditionalExpression[a_, b__] -> a and apply it to the output? i.e. CoefficientList[Series[S[x, 3], {x, 0, 3}], x] /. rule $\endgroup$ – gpap Nov 11 '13 at 10:14
7
$\begingroup$

You can use GenerateConditions->False to eliminate conditions (assuming they do not affect your planned use):

S[x_, l_] := (C[1] + 
     Integrate[
      E^(2 Sum[t^i/i, {i, 1, l - 1}]) (1 - t)^2*
       Sum[(l - i*2) t^i, {i, 1, l - 1}]/((t - 1) t^l), {t, 1, x}, 
      GenerateConditions -> False]) x^(l - 1)*
   E^(-2 Sum[x^i/i, {i, 1, l - 1}])/(1 - x)^2;
Table[S[x, i], {i, 2, 3}] // TableForm
CoefficientList[Series[S[x, 2], {x, 0, 3}], x]
CoefficientList[Series[S[x, 3], {x, 0, 3}], x]
CoefficientList[Series[S[x, 3][[1]], {x, 0, 3}], x]
$\endgroup$
  • $\begingroup$ I would not recommend using GenerateConditions -> False as there are many cases where adding this option results in Mma either not being able to solve the integral, or returning a different answer than it otherwise would do. In my experience, a better approach is to let it do its thing, and then remove the ConditionalExpression $\endgroup$ – wolfies Apr 6 '17 at 15:48
22
$\begingroup$

A more general way, which can be used for other functions like Solve, is to use Normal.

Integrate[1/x^s, {x, 1, Infinity}]

(* ConditionalExpression[1/(-1 + s), Re[s] > 1] *)

Normal[%, ConditionalExpression]

(* 1/(-1 + s) *)

Edit

It looks like as of version 10, one can just use the one argument Normal:

Integrate[1/x^s, {x, 1, Infinity}]

(* ConditionalExpression[1/(-1 + s), Re[s] > 1] *)

Normal[%]

(* 1/(-1 + s) *)
$\endgroup$
4
$\begingroup$

It might be late to answer this, but I think it's important to add my approach.

I came to the same problem of having ConditionalExpressions in my outputs.

After googling I came about this solution, by using the Assuming[] function.

An example:

Assuming[Re[s] > 1, Integrate[1/x^s,{x,1,Infinity}]

Which gives:

1/(-1+s) 
$\endgroup$
  • 1
    $\begingroup$ What are cases where Normal didn't work? $\endgroup$ – Chip Hurst Jul 1 '15 at 12:43
  • 1
    $\begingroup$ Normal[] worked after all too. $\endgroup$ – milia Jul 2 '15 at 13:51
1
$\begingroup$

Assuming[Re[s] > 1, Integrate[1/x^s, {x, 1, Infinity}]] is the fastest way to do an integral. If you don't know the conditions for which the integral works, you can also use Integrate[1/x^s, {x, 1, Infinity}, GenerateConditions -> False]

Normal[Integrate[1/x^s, {x, 1, Infinity}]] is significatively longer because you must compute the conditions and then throw them away. It can be very long in some cases.

For example,

In[215]:= Normal[Integrate[1/x^s, {x, 1, Infinity}]] // AbsoluteTiming

Out[215]= {0.319937,1/(s-1)}

In[212]:= 
Integrate[1/x^s, {x, 1, Infinity}, 
  GenerateConditions -> False] // AbsoluteTiming

Out[212]= {0.140617,1/(s-1)}

In[214]:= 
Integrate[1/x^s, {x, 1, Infinity}, 
  Assumptions -> s > 1] // AbsoluteTiming

Out[214]= {0.148892,1/(s-1)}

In[219]:= 
Assuming[Re[s] > 1, 
  Integrate[1/x^s, {x, 1, Infinity}]] // AbsoluteTiming

Out[219]= {0.103522,1/(s-1)}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.