# How to put a conditional expression for a variable inside a function definition or outside

I need to put a condition for b inside p01, p02 definitions or just state this condition at the beginning of my problem.

p01[x_] := 2*h[2]/κ*Log[(x - b)/(-b)] + θ[2]/κ*x + 1/2;
p02[x_] := 2*h[2]/κ*Log[(x - b)/(1 - b)] + θ[2]/κ*(x - 1);
forh2[x_] = Integrate[p01[x], {x, 0, b}] + Integrate[p02[x], {x, b, 1}] - M*g;
fortheta2[x_] = Integrate[(x - b)*p01[x], {x, 0, b}] + Integrate[(x - b)*p02[x], {x, b, 1}];


When executing, for h2 and fortheta2, I get lots of conditions related to b. I know it does complain about Log[1/-b]. In my physical problem 0<b<1 . How can I add this condition so that forh2, fortheta2 make sense.

You can use Assumptions with Integrate

Integrate[p01[x], {x, 0, b}, Assumptions -> b > 0]


(4 (1 + b) h[2] Log[1 + b] + b (κ - 4 h[2] + b θ[2]))/(2 κ)

You have to set those conditions by yourself for each Integrate.

• Thanks @Sumit. So, I cannot define 0<b<1 where b is real??
– Meva
Oct 13 '16 at 14:00
• you can do that for p01. I think that would not be sufficient for integrating p02. Oct 13 '16 at 14:10
• No, I was mentioning about b being Real. I put another Assumptions, but it did not work.
– Meva
Oct 13 '16 at 14:40
• When you say 0<b<1 you are already saying that b is real as the defining region itself is real. Oct 13 '16 at 14:57
• Sorry for that question, you are right @Sumit. I still get a condition when I execute forh2, stating b<=1/2 which should not be.
– Meva
Oct 13 '16 at 15:00