# Help for double parametrized integration: algebraic vs Mathematica solutions

I have to solve a double integral with parametrized functions, that is (written as a latex equation) $$\int_{-\infty}^\infty \int_0^\infty u(t)u(t-\Delta)\frac{1+e^{-2\int_{t-\tau-\Delta}^{t-\tau} y(s)^2 ds }}{2} d\Delta dt$$ that depends upon: - the function u(t), that in my case is a squared pulse between 0 and 1, defined in Mathematica as

u[t_] = Piecewise[{{1, 0 <= t <= 1}}, 0];

• the function y(s), that in my case is a piecewise constant function between 0 and 1 with a discontinuity in t1, defined in Mathematica as

y[t_, y1_, y2_, t1_] = Piecewise[{{y1, 0 <= t <= t1}, {y2, t1 < t <= 1}}, 0];

• the parameter $\tau$.

Consider the assumptions

$Assumptions = 1 > \[Tau] > 0 && y1 \[Element] Reals && y2 \[Element] Reals && 1 > t1 > 0  and also t1 + \[Tau] < 1. I'd like to solve the integral to have a function of$\tau, y1, y2, t1$. Now, if I just substitute the definition of$u(t)$and$y(s)$and use Mathematica, I get I can't get the integral solved, as you can check with Assuming[t1 + \[Tau] < 1, Integrate[ Integrate[ u[t] u[t - \[CapitalDelta]] (1 + Exp[-2 Integrate[ y[s, y1, y2, t1]^2, {s, t - \[CapitalDelta] - \[Tau], t - \[Tau]}]])/2, {\[CapitalDelta], 0, +Infinity}], {t, -Infinity, +Infinity}]] // Simplify  So, I have done "by hand" part of the integral, in particular the integral at the exponential argument, defining the funtion IntY2[a_, b_, y1_, y2_, t1_] = Piecewise[{ {y1^2 b, a < 0 && 0 <= b < t1}, {y1^2 t1 + y2^2 (b - t1), a < 0 && t1 <= b <= 1}, {y1^2 t1 + y2^2 (1 - t1), a < 0 && 1 < b}, {y1^2 (b - a), 0 <= a < t1 && 0 <= b < t1}, {y1^2 (t1 - a) + y2^2 (b - t1), 0 <= a < t1 && t1 <= b <= 1}, {y1^2 (t1 - a) + y2^2 (1 - t1), 0 <= a < t1 && 1 < b}, {y2^2 (b - a), t1 <= a <= 1 && t1 <= b <= 1}, {y2^2 (1 - a), t1 <= a <= 1 && 1 < b}}, 0]  and calculating Assuming[t1 + \[Tau] < 1, Integrate[ Integrate[ u[t] u[t - \[CapitalDelta]] (1 + Exp[-2 IntY2[t - \[CapitalDelta] - \[Tau], t - \[Tau], y1, y2, t1]])/2, {\[CapitalDelta], 0, +Infinity}], {t, -Infinity, +Infinity}]] // Simplify  This elaboration works, and I get a solution. But doing by hand the substitution of u(t) and y(t) with some algebra I get Integrate[(1 + Exp[-2 y1^2 \[CapitalDelta]])/2, {\[CapitalDelta], 0, t - \[Tau]}, {t, \[Tau], t1 + \[Tau]}] + Integrate[(1 + Exp[-2 y1^2 (t - \[Tau])])/2, {\[CapitalDelta], t - \[Tau], t}, {t, \[Tau], t1 + \[Tau]}] + Integrate[(1 + Exp[-2 y2^2 (t - \[Tau] - t1) - 2 y1^2 t1])/ 2, {\[CapitalDelta], t - \[Tau], t}, {t, t1 + \[Tau], 1}] + Integrate[(1 + Exp[-2 y2^2 (t - \[Tau] - t1) - 2 y1^2 (t1 - (t - \[Tau] - \[CapitalDelta]))])/ 2, {\[CapitalDelta], t - t1 - \[Tau], t - \[Tau]}, {t, t1 + \[Tau], 1}] + Integrate[(1 + Exp[-2 y2^2 \[CapitalDelta]])/2, {\[CapitalDelta], 0, t - t1 - \[Tau]}, {t, t1 + \[Tau], 1}] // Simplify  that is different from the one calculated by Mathematica. Of course, probably I made a mistake somewhere that I cannot find. Anyway, I tried to substitute some parts of the original integral to get my formula, for example sustituting the constraint given by u(t), then$u(t-\Delta)$, ecc checking each step of Mathematica. For example, with Assuming[t1 + \[Tau] < 1, Integrate[ Integrate[u[t] u[t - \[CapitalDelta]] (1 + Exp[-2 IntY2[t - \[CapitalDelta] - \[Tau], t - \[Tau], y1, y2, t1]])/2, {\[CapitalDelta], 0, +Infinity}], {t, 0, 1}]] // Simplify  I get the same (Mathematica's, not mine) solution. When I get to Assuming[t1 + \[Tau] < 1, Integrate[ Integrate[ u[t - \[CapitalDelta]] (1 + Exp[-2 IntY2[t - \[CapitalDelta] - \[Tau], t - \[Tau], y1, y2, t1]])/2, {\[CapitalDelta], 0, +Infinity}], {t, 0, 1}]] // Simplify  and I tried to make that solved, Mathematica cannot solve it (or at least it takes a lot of time, the previous integral it takes 20 s but in this one after 5 minutes it's not solved). Note that I just delete u[t] in the integral argument, but from the mathematical point of view it should be indifferent since t is integrated between 0 and 1. I'd like to understand why Mathematica cannot solve this last formulation of the integral (and how can I fix it), because I want to check my solutions and also I have some more complex integrals that Mathematica cannot solve and I think the problem is the same. Sorry for the long post, Nicola - PiecewiseExpand might be helpful. – b.gatessucks Jan 15 at 16:18 Your integral is much simpler than it appears, so consider re-expressing it.$y$is piecewise constant, whence so are$y(s)^2ds$, whence its integral, whence its exponential, whence the entire integrand, because$u$also is piecewise constant. Therefore, what you are trying to integrate is a sum of constants! This suggests you change your approach into characterizing the regions at which the value of the integrand changes; within each region, the value is trivial to compute. MMA is struggling with managing all possible orderings of$t_1$relative to$t,\delta,0,1\$, etc. –  whuber Jan 15 at 16:33