pdetest - Maple Help

pdetest

test the solutions found by pdsolve for partial differential equations (PDEs) and PDE systems

 Calling Sequence pdetest(sol, PDE)

Parameters

 sol - solution for PDE PDE - partial differential equation, or a set or list of them representing a system that can also include boundary conditions

Description

 • The pdetest command returns either 0 (when the PDE is annulled by the solution sol), indicating that the solution is correct, or a remaining algebraic expression (obtained after simplifying the PDE with respect to the proposed solution), indicating that the solution might be wrong.
 • When PDE is a system, given as a set or list, possibly including boundary conditions, for each of the elements in the set/list pdetest will return a 0 or the remaining algebraic expression; the advantage of giving PDE as a list is that you can thus determine which element (if any) is not satisfied by the solution.
 • The pdetest command can also be used to reduce a PDE to a simpler problem by giving an "ansatz", instead of an explicit solution, since it will return the nonzero remaining part.

Examples

Define a PDE, solve it, and then test the solution.

 > $\mathrm{PDE}≔\mathrm{exp}\left(\mathrm{diff}\left(f\left(x,y,z,t\right),\mathrm{}\left(x,5\right)\right)\right)+\mathrm{diff}\left(f\left(x,y,z,t\right),\mathrm{}\left(y,4\right)\right)g\left(x\right)h\left(y\right)=0$
 ${\mathrm{PDE}}{≔}{{ⅇ}}^{\frac{{{\partial }}^{{5}}}{{\partial }{{x}}^{{5}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{f}{}\left({x}{,}{y}{,}{z}{,}{t}\right)}{+}\left(\frac{{{\partial }}^{{4}}}{{\partial }{{y}}^{{4}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{f}{}\left({x}{,}{y}{,}{z}{,}{t}\right)\right){}{g}{}\left({x}\right){}{h}{}\left({y}\right){=}{0}$ (1)
 > $\mathrm{ans}≔\mathrm{pdsolve}\left(\mathrm{PDE}\right)$
 ${\mathrm{ans}}{≔}\left({f}{}\left({x}{,}{y}{,}{z}{,}{t}\right){=}{\mathrm{_F1}}{}\left({x}\right){+}{\mathrm{_F2}}{}\left({y}\right){+}{\mathrm{_F5}}{}\left({z}{,}{t}\right)\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{&where}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left[\left\{\frac{{{ⅆ}}^{{4}}}{{ⅆ}{{y}}^{{4}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\mathrm{_F2}}{}\left({y}\right){=}{-}\frac{{{\mathrm{_c}}}_{{1}}}{{h}{}\left({y}\right)}{,}\frac{{{ⅆ}}^{{5}}}{{ⅆ}{{x}}^{{5}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\mathrm{_F1}}{}\left({x}\right){=}{\mathrm{ln}}{}\left({{\mathrm{_c}}}_{{1}}{}{g}{}\left({x}\right)\right)\right\}{,}\left({\mathrm{_F5}}{}\left({z}{,}{t}\right){,}{\mathrm{are arbitrary functions.}}\right)\right]$ (2)
 > $\mathrm{pdetest}\left(\mathrm{ans},\mathrm{PDE}\right)$
 ${0}$ (3)
 > $\mathrm{PDE}≔\mathrm{diff}\left(f\left(x,y\right),y\right)\mathrm{Diff}\left(\mathrm{arctan}\left({x}^{\frac{1}{2}}y\right),y\right)+\mathrm{diff}\left(f\left(x,y\right),x\right)\mathrm{Diff}\left(\mathrm{arctan}\left({x}^{\frac{1}{2}}y\right),x\right)=0$
 ${\mathrm{PDE}}{≔}\left(\frac{{\partial }}{{\partial }{y}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{f}{}\left({x}{,}{y}\right)\right){}\frac{{\partial }}{{\partial }{y}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\mathrm{arctan}}{}\left(\sqrt{{x}}{}{y}\right){+}\left(\frac{{\partial }}{{\partial }{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{f}{}\left({x}{,}{y}\right)\right){}\frac{{\partial }}{{\partial }{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\mathrm{arctan}}{}\left(\sqrt{{x}}{}{y}\right){=}{0}$ (4)
 > $\mathrm{ans}≔\mathrm{pdsolve}\left(\mathrm{PDE}\right)$
 ${\mathrm{ans}}{≔}{f}{}\left({x}{,}{y}\right){=}{\mathrm{_F1}}{}\left({-}{2}{}{{x}}^{{2}}{+}{{y}}^{{2}}\right)$ (5)
 > $\mathrm{pdetest}\left(\mathrm{ans},\mathrm{PDE}\right)$
 ${0}$ (6)
 > $\mathrm{PDE}≔x{\mathrm{diff}\left(f\left(x,y\right),y\right)}^{2}-\mathrm{diff}\left(f\left(x,y\right),x\right)=f\left(x,y\right)$
 ${\mathrm{PDE}}{≔}{x}{}{\left(\frac{{\partial }}{{\partial }{y}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{f}{}\left({x}{,}{y}\right)\right)}^{{2}}{-}\frac{{\partial }}{{\partial }{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{f}{}\left({x}{,}{y}\right){=}{f}{}\left({x}{,}{y}\right)$ (7)
 > $\mathrm{ans}≔\mathrm{pdsolve}\left(\mathrm{PDE},\mathrm{HINT}=\mathrm{strip}\right)$
 ${\mathrm{ans}}{≔}\left({x}{}{\left(\frac{{\partial }}{{\partial }{y}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{f}{}\left({x}{,}{y}\right)\right)}^{{2}}{-}\frac{{\partial }}{{\partial }{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{f}{}\left({x}{,}{y}\right){-}{f}{}\left({x}{,}{y}\right){=}{0}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{&where}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left[\left\{\left\{{f}{}\left({\mathrm{_s}}\right){=}\left({-}{{\mathrm{_C4}}}^{{2}}{}{\mathrm{_s}}{-}{{ⅇ}}^{{-}{\mathrm{_s}}}{}{\mathrm{_C2}}{+}{\mathrm{_C1}}\right){}{{ⅇ}}^{{2}{}{\mathrm{_s}}}{,}{x}{}\left({\mathrm{_s}}\right){=}{-}{\mathrm{_s}}{+}{\mathrm{_C5}}{,}{y}{}\left({\mathrm{_s}}\right){=}{2}{}\left({-}{\mathrm{_s}}{+}{\mathrm{_C5}}{+}{1}\right){}{\mathrm{_C4}}{}{{ⅇ}}^{{\mathrm{_s}}}{+}{\mathrm{_C3}}{,}{{\mathrm{_p}}}_{{1}}{}\left({\mathrm{_s}}\right){=}\left({-}{{\mathrm{_C4}}}^{{2}}{}{{ⅇ}}^{{\mathrm{_s}}}{+}{\mathrm{_C2}}\right){}{{ⅇ}}^{{\mathrm{_s}}}{,}{{\mathrm{_p}}}_{{2}}{}\left({\mathrm{_s}}\right){=}{\mathrm{_C4}}{}{{ⅇ}}^{{\mathrm{_s}}}\right\}\right\}{,}{&and}{}\left(\left\{{{\mathrm{_p}}}_{{1}}{=}\frac{{\partial }}{{\partial }{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{f}{}\left({x}{,}{y}\right){,}{{\mathrm{_p}}}_{{2}}{=}\frac{{\partial }}{{\partial }{y}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{f}{}\left({x}{,}{y}\right)\right\}\right)\right]$ (8)
 > $\mathrm{pdetest}\left(\mathrm{ans},\mathrm{PDE}\right)$
 ${0}$ (9)

You can use pdetest to solve a PDE.  First, define the PDE.

 > $\mathrm{PDE}≔x\mathrm{diff}\left(f\left(x,y\right),y\right)-\mathrm{diff}\left(f\left(x,y\right),x\right)=f\left(x,y\right)$
 ${\mathrm{PDE}}{≔}{x}{}\left(\frac{{\partial }}{{\partial }{y}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{f}{}\left({x}{,}{y}\right)\right){-}\frac{{\partial }}{{\partial }{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{f}{}\left({x}{,}{y}\right){=}{f}{}\left({x}{,}{y}\right)$ (10)

Next, give an ansatz.

 > $\mathrm{ansatz}≔f\left(x,y\right)=F\left(x\right)\mathrm{exp}\left(y\right)$
 ${\mathrm{ansatz}}{≔}{f}{}\left({x}{,}{y}\right){=}{F}{}\left({x}\right){}{{ⅇ}}^{{y}}$ (11)

Use pdetest to simplify the PDE with regard to the ansatz above.

 > $\mathrm{ans_1}≔\mathrm{pdetest}\left(\mathrm{ansatz},\mathrm{PDE}\right)$
 ${\mathrm{ans_1}}{≔}{{ⅇ}}^{{y}}{}\left({x}{}{F}{}\left({x}\right){-}{F}{}\left({x}\right){-}\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{F}{}\left({x}\right)\right)$ (12)

The ansatz above separated the variables, so the PDE can now be solved for F(x).

 > $\mathrm{factor}\left(\mathrm{ans_1}\right)$
 ${{ⅇ}}^{{y}}{}\left({x}{}{F}{}\left({x}\right){-}{F}{}\left({x}\right){-}\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{F}{}\left({x}\right)\right)$ (13)
 > $\mathrm{ans_F}≔\mathrm{dsolve}\left(\mathrm{ans_1},F\left(x\right)\right)$
 ${\mathrm{ans_F}}{≔}{F}{}\left({x}\right){=}{\mathrm{_C1}}{}{{ⅇ}}^{\frac{{x}{}\left({x}{-}{2}\right)}{{2}}}$ (14)

Now, build a (particular) solution to the PDE by substituting the result above in "ansatz".

 > $\mathrm{ans}≔\mathrm{subs}\left(\mathrm{ans_F},\mathrm{ansatz}\right)$
 ${\mathrm{ans}}{≔}{f}{}\left({x}{,}{y}\right){=}{\mathrm{_C1}}{}{{ⅇ}}^{\frac{{x}{}\left({x}{-}{2}\right)}{{2}}}{}{{ⅇ}}^{{y}}$ (15)
 > $\mathrm{pdetest}\left(\mathrm{ans},\mathrm{PDE}\right)$
 ${0}$ (16)

Test solutions for PDE systems.

 > $\mathrm{sys}≔\left[\mathrm{diff}\left(u\left(x,t\right),t\right)=\mathrm{diff}\left(u\left(x,t\right),\mathrm{}\left(x,2\right)\right)-v\left(x,t\right),\mathrm{diff}\left(v\left(x,t\right),t\right)=\mathrm{diff}\left(v\left(x,t\right),\mathrm{}\left(x,2\right)\right)-u\left(x,t\right)\right]$
 ${\mathrm{sys}}{≔}\left[\frac{{\partial }}{{\partial }{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{u}{}\left({x}{,}{t}\right){=}\frac{{{\partial }}^{{2}}}{{\partial }{{x}}^{{2}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{u}{}\left({x}{,}{t}\right){-}{v}{}\left({x}{,}{t}\right){,}\frac{{\partial }}{{\partial }{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{v}{}\left({x}{,}{t}\right){=}\frac{{{\partial }}^{{2}}}{{\partial }{{x}}^{{2}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{v}{}\left({x}{,}{t}\right){-}{u}{}\left({x}{,}{t}\right)\right]$ (17)
 > $\mathrm{sol}≔\mathrm{pdsolve}\left(\mathrm{sys},\left\{u\left(x,t\right),v\left(x,t\right)\right\}\right)$
 ${\mathrm{sol}}{≔}\left\{{u}{}\left({x}{,}{t}\right){=}{\mathrm{_C1}}{}{\mathrm{cos}}{}\left({x}\right){+}{\mathrm{_C2}}{}{{ⅇ}}^{{x}}{+}{\mathrm{_C3}}{}{\mathrm{sin}}{}\left({x}\right){+}\frac{{\mathrm{_C4}}}{{{ⅇ}}^{{x}}}{+}\frac{{\mathrm{_C6}}}{{{ⅇ}}^{{t}}}{+}{{ⅇ}}^{{t}}{}{\mathrm{_C5}}{,}{v}{}\left({x}{,}{t}\right){=}\frac{{\mathrm{_C6}}}{{{ⅇ}}^{{t}}}{-}{{ⅇ}}^{{t}}{}{\mathrm{_C5}}{-}{\mathrm{_C1}}{}{\mathrm{cos}}{}\left({x}\right){+}{\mathrm{_C2}}{}{{ⅇ}}^{{x}}{-}{\mathrm{_C3}}{}{\mathrm{sin}}{}\left({x}\right){+}\frac{{\mathrm{_C4}}}{{{ⅇ}}^{{x}}}\right\}$ (18)
 > $\mathrm{pdetest}\left(\mathrm{sol},\mathrm{sys}\right)$
 $\left[{0}{,}{0}\right]$ (19)

Consider the following PDE, boundary condition, and solution

 > $\mathrm{pde}≔\mathrm{diff}\left(u\left(x,t\right),t\right)=k\mathrm{diff}\left(\mathrm{diff}\left(u\left(x,t\right),x\right),x\right)+Q$
 ${\mathrm{pde}}{≔}\frac{{\partial }}{{\partial }{t}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{u}{}\left({x}{,}{t}\right){=}{k}{}\left(\frac{{{\partial }}^{{2}}}{{\partial }{{x}}^{{2}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{u}{}\left({x}{,}{t}\right)\right){+}{Q}$ (20)
 > $\mathrm{bc}\left[1\right]≔u\left(0,t\right)=2\mathrm{exp}\left(kt\right)-\frac{1}{k}Q$
 ${{\mathrm{bc}}}_{{1}}{≔}{u}{}\left({0}{,}{t}\right){=}{2}{}{{ⅇ}}^{{k}{}{t}}{-}\frac{{Q}}{{k}}$ (21)
 > $\mathrm{sol}≔u\left(x,t\right)={\mathrm{_C1}}^{2}\mathrm{exp}\left(x+kt\right)-\left({\mathrm{_C1}}^{2}-2\right)\mathrm{exp}\left(-x+kt\right)-\frac{1}{2k}Q{x}^{2}+\frac{1}{{\mathrm{_C1}}^{2}k}Q\left({\mathrm{_C1}}^{2}-2\right)x-\frac{1}{k}Q$
 ${\mathrm{sol}}{≔}{u}{}\left({x}{,}{t}\right){=}{{\mathrm{_C1}}}^{{2}}{}{{ⅇ}}^{{k}{}{t}{+}{x}}{-}\left({{\mathrm{_C1}}}^{{2}}{-}{2}\right){}{{ⅇ}}^{{k}{}{t}{-}{x}}{-}\frac{{Q}{}{{x}}^{{2}}}{{2}{}{k}}{+}\frac{{Q}{}\left({{\mathrm{_C1}}}^{{2}}{-}{2}\right){}{x}}{{{\mathrm{_C1}}}^{{2}}{}{k}}{-}\frac{{Q}}{{k}}$ (22)

You can test whether the sol solves pde using pdetest; the novelty is that you can now test whether it solves the boundary condition bc[1]

 > $\mathrm{pdetest}\left(\mathrm{sol},\left[\mathrm{pde},\mathrm{bc}\left[1\right]\right]\right)$
 $\left[{0}{,}{0}\right]$ (23)

The boundary conditions can involve derivatives:

 > $\mathrm{bc}\left[2\right]≔\mathrm{D}\left[1,1\right]\left(u\right)\left(0,t\right)=2\mathrm{exp}\left(kt\right)-\frac{1}{k}Q$
 ${{\mathrm{bc}}}_{{2}}{≔}{{\mathrm{D}}}_{{1}{,}{1}}{}\left({u}\right){}\left({0}{,}{t}\right){=}{2}{}{{ⅇ}}^{{k}{}{t}}{-}\frac{{Q}}{{k}}$ (24)
 > $\mathrm{pdetest}\left(\mathrm{sol},\left[\mathrm{pde},\mathrm{bc}\left[2\right]\right]\right)$
 $\left[{0}{,}{0}\right]$ (25)