I specify a function in terms of an integral and then try to evaluate it with Simplify. However, the answer is not really simplified to what it should be.

assumptions := {l > 0, Element[NN, Integers], NN > 0, b > 0, a > 0, 
    l > b, a > l, α > 0, β > 0};

Φ = Function[x, 
    If[x < l, 
       (NN*π*α*b^2 *(l^2 ArcCos[x/l] - x Sqrt[l^2 - x^2]))/(a^2 * β), 0]
Px = Function[x, If[0 <= x <= a, 1/a, 0]];
FΦ = Function[φ, Simplify[Integrate[If[Φ[x] <= φ, 1, 0] Px[x], {x, 0, a}], 
Simplify[FΦ[0], assumptions]

However, it is easy to see that it should be reduced as first

$\frac{1}{a} \int_0^a \text{If}\left[\text{If}\left[x<l,\frac{\text{NN} \pi \alpha b^2 \left(l^2 \text{ArcCos}\left[\frac{x}{l}\right]-x \sqrt{l^2-x^2}\right)}{a^2 \beta },0\right]\leq 0,1,0\right] \, dx$

and then $\frac{1}{a} \int_0^l \text{If}\left[\frac{\text{NN} \pi \alpha b^2 \left(l^2 \text{ArcCos}\left[\frac{x}{l}\right]-x \sqrt{l^2-x^2}\right)}{a^2 \beta }\leq 0,1,0\right] \, dx + \frac{1}{a} \int_l^a \text{If}\left[ 0 \leq 0,1,0\right] \, dx$

to $ \frac{1}{a} \int_0^l 0 \, dx + \frac{1}{a} \int_l^a 1 \, dx$ $=\frac{a-l}{a}$.

How can I get Mathematica to simplify it correctly?

  • $\begingroup$ I am not sure if this helps and if I am right. But I think you are wrong in your second line with the first term. The Integration is done after the If. Without any value for x you (and Mathematica) cannot decide if this term is ≤ 0 or not. E.g. if you use NN = 1; b = 2; α = 1; β = 1; l = 5; a = 6; (this should meet your assumptions), then the term ist only 0 for x=5. $\endgroup$
    – partial81
    Mar 20, 2012 at 22:04
  • $\begingroup$ P.S.: If I am right, then you are also wrong in your first line because of the same mistake (you do not have a x, so you do not know if x<l or not). $\endgroup$
    – partial81
    Mar 20, 2012 at 22:10
  • $\begingroup$ @partial81, In assumptions, we know that $a>l>0$, so the integral from $0$ to $a$ can be broken into $0$ to $l$ and $l$ to $a$. Then, $x<l$ for the first part and $x>l$ for the second part. The values you give don't satisfy $a>l$. $\endgroup$ Mar 20, 2012 at 22:24
  • $\begingroup$ $a=6$; $l=5$; $=>$ $a>l$. What is wrong with my example values? $\endgroup$
    – partial81
    Mar 21, 2012 at 17:23

1 Answer 1


Mathematica obviously cannot decide the sign of l^2*ArcCos[x/l] - x*Sqrt[l^2 - x^2]. The rest of your code is fine. For example, just replace the first function by

 If[x < l, (NN*Pi*α*b^2*(l^2 ArcCos[x/l]))/(a^2*β), 0]] 

(in other words, just get rid of -x*Sqrt[l^2 - x^2]) and everything will work as expected.


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.