1
$\begingroup$

The following code

Assuming[-1 < t < 1 && Element[a, Reals], 
 FullSimplify[
  Integrate[
   Piecewise[{{(1 + x)/(1 + t), -1 < x < t}, 
              {(1 - x)/(1 - t),  t < x < 1}, 
              {0,                True}}], 
   {x, -1, a}]]]

will result in $$ \begin{cases} 1 & a>1 \\ \frac{(a+1)^2}{2 (t+1)} & a>-1\land a<t \\ \frac{t+1}{2} & a=t \\ \frac{(a-1)^2}{2 (t-1)}+1 & a>t\land a\leq 1 \end{cases} $$

By the assumptions above, that's the same as:

$$ \begin{cases} 1 & a\ge 1 \\ \frac{(a+1)^2}{2 (t+1)} & a>-1\land a\leq t \\ \frac{(a-1)^2}{2 (t-1)}+1 & a>t\land a< 1 \end{cases} $$

which is the form I'd prefer.
Is there a way to automatically tell mathematica to do that?

The reason I want the second form is, that I'd need to integrate the output once again and in the first form, it would result in weird behavior, suddenly unnecessarily special-casing for $\frac{1}{\sqrt{2}}$ or things like that.

(Note that there is no case for $a\leq -1$. That case gets auto-handled by Mathematica as $\{0,True\}$ and doesn't show up when you use the \TeXFormat command)

$\endgroup$
3
  • $\begingroup$ How general a solution do you need? In the example, for instance, just eliminating the equality will do the trick, as in % /. {y_, x_Equal} -> {y, False}, but in more general situations this might be incorrect. $\endgroup$
    – whuber
    Commented Jan 30, 2013 at 19:27
  • $\begingroup$ @whuber What I really want is a solution that will work for the outer-most cases all the time (which will always be something<x<-1 or somethinng>x>1) which I want to turn to x<=-1 or x>=1 respectively, and additionally, I want to get rid of any single point definitions: What I'm doing is guaranteed to be continuous and won't need such things. Beyond that I might need some more but I'll have to see if anything weird happens, in which case I'll come back if it's not clear to me how to extend a solution that may be given here. $\endgroup$
    – kram1032
    Commented Jan 30, 2013 at 22:54
  • $\begingroup$ @whuber sometimes the formating of the conditions will also be messed up, having something depending on more variables in the middle, rather than just plain x, like something<2x-t<something or stuff like that. So the simplest form of pattern-matching probably won't cut it if I can't also automate a cleanup of all cases so they become something < x < something or similar... $\endgroup$
    – kram1032
    Commented Jan 30, 2013 at 23:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.