# Verify solution to first order partial differential equation with If condition and ReplaceAll

I am confident the solution to the following differential equation is correct.

$$\frac{\partial u(t,x)}{\partial t}+\frac{\partial u(t,x)}{\partial x}=0$$

Two Questions: (1) Does the solution verification (pde /. sol // FullSimplify) appear to be constructed correctly? (2) If True (or if False) why does it always return Null (prints as indeterminate)?

pde := D[u[t, x], t] + D[u[t, x], x] == 0
ic := u[0, x] == Exp[-x] Sin[x]^2
bc := u[t, 0] == 0
sol := First[DSolve[{pde, ic, bc}, u[t, x], {t, x}]]
ver := If[pde /. sol // FullSimplify, Style["True", lime],
Style["False", Background -> Red],
Style["Indeterminate", Black, Background -> Yellow]]
Print[ver]


returns: Indeterminate

goal: return True or False

To verify solution of ode or pde, it is better use the form u instead of u[...] in the call. This makes it return a Function which can be used to verify the ode or the pde by direct substitution.

pde = D[u[t, x], t] + D[u[t, x], x] == 0
ic = u[0, x] == Exp[-x] Sin[x]^2
bc = u[t, 0] == 0
sol = First@DSolve[{pde, ic, bc}, u, {t, x}];
(pde /. sol) // Simplify


Verified

side points. No need to use := for assignments to variables. Simply use =

• Thank you so much. This second time you came through for me in less than 24 hours. Apr 22, 2020 at 20:15