Message Boards Message Boards

0
|
2812 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Integrate piecewise-function processes forever?

Posted 3 years ago

I want to integrate the attached piecewise function over theta from 0 to 1. The single cases work fine, but integrating the function itself processes forever. I noted that cmd+. (the abortion command) takes a few seconds until Mathematica stops compiling, so I assume the problem lies in integrating the piecewise-function itself. What am I doing wrong?

POSTED BY: Lukas Berger
2 Replies

Maybe the problem is that you have too many free parameters and the piecewise conditions are complicated to unravel. Take a look at the output of this:

Reduce[0 <= (
  r1^2 - r2^2 + t1^2 \[Gamma] - t2^2 \[Gamma] - 2 r1 \[Theta]i + 
   2 r2 \[Theta]i)/(2 t1 \[Gamma] - 2 t2 \[Gamma]) <= 1,
 \[Theta]i, Reals]

Even worse if you add your assumptions:

Reduce[0 <= (
   r1^2 - r2^2 + t1^2 \[Gamma] - t2^2 \[Gamma] - 2 r1 \[Theta]i + 
    2 r2 \[Theta]i)/(2 t1 \[Gamma] - 2 t2 \[Gamma]) <= 1 &&
  0 < \[Theta]i < 1 && 
  And @@ {\[Gamma] > 0, 0 < t1 < 1, 0 < t2 < 1, 0 < r1 < 1, 
    0 < r2 < 1, t1 < t2},
 \[Theta]i, Reals]
POSTED BY: Gianluca Gorni
Posted 1 year ago

Hi Lukas,

Definite integrals are very slow because the general case is overloaded with determining all condition sets on all parameters. Especially for singular points, as infinity is in most cases, the generation of conditions for the existence of the limit of the indefinite integral easily pushes CAS to their limits.

As a receipe:

Fix the parameter conditions in the system variable $Assumptions, calculate the indefinite integral, subtract the values at the boundaries. If there are problems in evaluation of a limiting value, try to find Limit[expr, x->Infinity] under the given conditions with all known methods, preferably by the Series expansion around the complex point infinity.

Here we have

In[54]:= $Assumptions = \[Gamma] > 0 && 0 < t1 < 1 && 0 < t2 < 1 && 0 < r1 < 1 && 
  0 < r2 < 1

Out[54]= \[Gamma] > 0 && 0 < t1 < 1 && 0 < t2 < 1 && 0 < r1 < 1 && 0 < r2 < 1

In[59]:=
X = Piecewise[{{(2/3)*(\[Gamma] + 3*(-1 + t1)*t1*\[Gamma] + 3*(r1 - \[Theta]i)^2)*(-1 + \[Theta]i), 
     (t1 - t2)*\[Gamma]*(r1^2 - r2^2 + (t1^2 - t2^2)*\[Gamma] - 2*r1*\[Theta]i + 2*r2*\[Theta]i) < 0}, 
    {(-(2/3))*(-1 + \[Theta]i)*(-1 + (r1^2 - r2^2 + t1^2*\[Gamma] - t2^2*\[Gamma] - 2*r1*\[Theta]i + 2*r2*\[Theta]i)/
        (2*t1*\[Gamma] - 2*t2*\[Gamma]))*(\[Gamma] + 3*(-1 + t1)*t1*\[Gamma] + 3*(r1 - \[Theta]i)^2 + 
       (1/(4*(t1 - t2)^2*\[Gamma]))*((r1^2 - r2^2 + (t1^2 - t2^2)*\[Gamma] - 2*r1*\[Theta]i + 2*r2*\[Theta]i)*
         (r1^2 - r2^2 - (5*t1^2 + t2*(2 + t2) - 2*t1*(1 + 3*t2))*\[Gamma] - 2*r1*\[Theta]i + 2*r2*\[Theta]i))), 
     0 <= (r1^2 - r2^2 + t1^2*\[Gamma] - t2^2*\[Gamma] - 2*r1*\[Theta]i + 2*r2*\[Theta]i)/(2*t1*\[Gamma] - 2*t2*\[Gamma]) <= 1}}, 0];

(res = Subtract @@ (res /. {{\[Theta]i -> 1}, {\[Theta]i -> 0}}) // 
    FullSimplify) // TraditionalForm

Out[66]//TraditionalForm= \[Piecewise]  1/6 (-6 r1^2+4 r1+\[Gamma] (-6 (t1-1) t1-2)-1)   (t1-t2) ((r1-2) r1-(r2-2) r2+\[Gamma] (t1-t2) (t1+t2))<0
1/120 (5 (3 r1^2 (5 t1+3 t2-8)-2 r1 (5 t1+3 t2-8)-r2 (3 r2-2) (t1-t2)+2 (t1+t2-2))+((45 r1^3+15 r1^2 (3 r2-4)+5 r1 (r2 (3 r2-8)+8)+5 r2 (r2 (3 r2-4)+4)-12) (r1-r2))/(\[Gamma] (t1-t2))+((5 ((3 r1-2) r2^2+r1 (3 r1-4) r2+r1 ((r1-2) r1+2)+r2^3)+10 r2-4) (r1-r2)^3)/(\[Gamma]^2 (t1-t2)^3)+5 \[Gamma] (t1+t2-2) (7 t1^2-2 t1 (2 t2+5)+t2 (t2+2)+4))    0<=((r1-r2) (r1+r2-2))/(\[Gamma] (t1-t2))+t1+t2<=2
POSTED BY: Updating Name
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract