       Integrate piecewise with Assumptions

• To: mathgroup at smc.vnet.net
• Subject: [mg44072] Integrate piecewise with Assumptions
• From: "Chia-Ming" <yucalf at mail.educities.edu.tw>
• Date: Tue, 21 Oct 2003 02:07:45 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Excuse me,

First, I define a piecewise function to discribe the shortest distance
on the edge of a circle.

dis[x_, xi_] :=
Which[1/2 >= x - xi >= 0, x - xi, x - xi > 1/2, 1 - (x - xi),
0 > x - xi >= -1/2, xi - x, x - xi < -1/2, 1 - (xi - x)]

And it does works that it can automatically judge to go in a clockwise
or a conter-clockwise direction.

dis[2/3, 1/10]
13/30

Furthermore, dis[] can be applied in the Integrate[] command:

Integrate[(a - 5 dist[1/6, x])^2, {x, 0, 1}]// Simplify
25/12 - (5 a)/2 + a^2

However, it can not work with the option Assumptions:

Integrate[(a - 5 dist[y, x])^2, {x, 0, 1}, Assumptions->0<y<1/2]//Simplify

While the above calculation can be completed by hands:

Integrate[(a - 5 (y - x))^2,     {x, 0, y}] +
Integrate[(a - 5 (x - y))^2,     {x, y, y + 1/2}] +
Integrate[(a - 5 (1 - x + y))^2, {x, y + 1/2, 1}]//Simplify