Re: Integrate[Piecewise] Confusion
- To: mathgroup at smc.vnet.net
- Subject: [mg105841] Re: Integrate[Piecewise] Confusion
- From: Derek Yates <yatesd at mac.com>
- Date: Mon, 21 Dec 2009 03:32:08 -0500 (EST)
- References: <hgl39n$vb$1@smc.vnet.net>
I think I figured out what was going on (and it is embarrassing!), but here is an explanation and a hint in case others come across the same thing. Any other comments and suggestions are still however most welcome. (a) Mathematica does not return constants of integration for simple indefinite integrals. I had in my mind the definite integral from 0 and hence was expecting a result of 40x - 40. As the first part of the piecewise integrated as I expected, I did not notice that the second part was only different by a constant. (b) I really was wanting to evaluate the definite integral, but could not get it to work, hence I had switched to using an indefinite integral. The reason I could not get the definite integral to work, was that I was assuming my limits were Real, but Mathematica wasn't. So the hint for evaluating definite integrals (which to be fair is quite clearly explained in the Mathematica help) is to use something of the form: Assuming[{n \[Element] Reals, a>0}, Integrate[Piecewise[{{20, 0 < x <= a}, {40, a < x}}], {x,0,n}] ]/.a->2 which results in the expected: Piecewise[{{-20*(2 - 2*n), 2 - n < 0}, {20*n, 2 - n >= 0 && n > 0}}, 0] (* Note that the a>0 is not required in this case to evaluate the integral, but I know in my case that a will always be greater than 0 and it thus makes the result simpler *)