I'd like to extend my comment to an answer. As mentioned above, OP's attempt fails mainly because D
calculates based on Leibniz integral rule but sadly this rule doesn't apply in this case, because the integrand is no longer continuous when $s=t$.
Still, we can verify the solution using Mathematica, with a little manual analysis. First of all, we introduce a positive $\epsilon$ to the solution:
$$u(x,t)=\int_{0}^{t-\epsilon}\int_{-\infty}^{\infty} \frac{1}{\sqrt{4\pi k(t-s)}} \exp\left(-\frac{(x-y)^2}{4k(t-s)}\right)f(y,s)\,dy\,ds$$
G[x_, t_] := Exp[-x^2/(4 k t)]/Sqrt[4 π k t]
u[x_, t_] := Integrate[G[x - y, t - s] f[y, s], {s, 0, t - ϵ}, {y, -Infinity, Infinity}]
Substitute it back to the equation:
residual = D[u[x, t], t] - k D[u[x, t], {x, 2}] - f[x, t] // Simplify // Expand
It's easy to notice the last 2 terms cancel. We can manually delete them from the output, but here I'll do it programatically to make the answer more interesting:
residual2 =
With[{int = Integrate},
residual //.
HoldPattern[
coef1_ int[expr1_, rest_] + coef2_ int[expr2_, rest_]] :>
int[coef1 expr1 + coef2 expr2, rest]]
Remark
In v9.0.1 the following is enough:
residual2 = With[{int = Integrate},
residual /.
HoldPattern[coef_ int[int[expr_,rest1_],rest2_]]:>int[coef expr, rest2, rest1]]
(*
-f[x, t] + Integrate[(k f[y, t - ϵ])/(E^((x - y)^2/(4 k ϵ)) Sqrt[k ϵ]),
{y, -Infinity, Infinity}]/(2 k Sqrt[Pi])
*)
moveconst
can
be used in v9.0.1 in the following manner but it's a bit slow:
residual2 = FullSimplify[D[u[x, t], t] - k D[u[x, t], {x, 2}] - f[x, t],
TransformationFunctions -> {moveconst, Automatic}]
We know (from e.g. the wiki) one possible defintion for Dirac delta is
$$
\delta_a(x)=\frac{1}{|a|\sqrt \pi}e^{-(x/a)^2}\ \text{as}\ a\to 0
$$
So the … Exp[-(…)^2]
can be replaced with a … DiracDelta[…]
when $\epsilon \to 0$.
It's a pity that Limit
won't help in this case, as mentioned in the Possible Issues section of document of DiracDelta
. Once again, it's not a bad idea to modify the output by hand, but I'll replace by coding to make the answer more interesting:
residual3 =
Assuming[{x ∈ Reals, ϵ > 0, k > 0},
residual2 /. Exp[coef_ a_^2] :> DiracDelta[a]/Sqrt[-coef] Sqrt[Pi]]
(* -f[x, t] + f[x, t - ϵ] *)
residual3 /. ϵ -> 0
(* 0 *)
As we can see, all terms in the equation cancel, the solution is verified. (Verification for the initial condition is trivial. )
Tested in v9.0.1, v12.0.1, v12.1.0.
k>0
if you are going to do it this way, but this does not help with the integration part there. also on V 12.1 I get noIndeterminate
in the result, just unevaluated integrals. You might want to double check the Green function you used again just in case. $\endgroup$u
should beIntegrate[G[x - y, t - s]*f[y, s], {s, 0, t}, {y, -Infinity, Infinity}]
We cannot arbitrarily interchange the order of integration in this case. (This doesn't help solving the problem, though. ) $\endgroup$Integrate
is the opposite. The documentation doesn't have a clear example for multiple integration. $\endgroup$Table
. $\endgroup$