pdetest - Maple Programming 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}≔{ⅇ}^{\frac{{\partial }^{5}}{\partial {x}^{5}}f\left(x,y,z,t\right)}+\left(\frac{{\partial }^{4}}{\partial {y}^{4}}f\left(x,y,z,t\right)\right)g\left(x\right)h\left(y\right)=0$
 ${\mathrm{PDE}}{:=}{{ⅇ}}^{\frac{{{\partial }}^{{5}}}{{\partial }{{x}}^{{5}}}{}{f}{}\left({x}{,}{y}{,}{z}{,}{t}\right)}{+}\left(\frac{{{\partial }}^{{4}}}{{\partial }{{y}}^{{4}}}{}{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){&where}\left[\left\{\frac{{{ⅆ}}^{{5}}}{{ⅆ}{{x}}^{{5}}}{}{\mathrm{_F1}}{}\left({x}\right){=}{\mathrm{ln}}{}\left({{\mathrm{_c}}}_{{1}}{}{g}{}\left({x}\right)\right){,}\frac{{{ⅆ}}^{{4}}}{{ⅆ}{{y}}^{{4}}}{}{\mathrm{_F2}}{}\left({y}\right){=}{-}\frac{{{\mathrm{_c}}}_{{1}}}{{h}{}\left({y}\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}≔\left(\frac{\partial }{\partial y}f\left(x,y\right)\right)\left(\frac{{\partial }}{{\partial }y}\mathrm{arctan}\left({x}^{\frac{1}{2}}y\right)\right)+\left(\frac{\partial }{\partial x}f\left(x,y\right)\right)\left(\frac{{\partial }}{{\partial }x}\mathrm{arctan}\left({x}^{\frac{1}{2}}y\right)\right)=0$
 ${\mathrm{PDE}}{:=}\left(\frac{{\partial }}{{\partial }{y}}{}{f}{}\left({x}{,}{y}\right)\right){}\left(\frac{{\partial }}{{\partial }{y}}{}{\mathrm{arctan}}{}\left(\sqrt{{x}}{}{y}\right)\right){+}\left(\frac{{\partial }}{{\partial }{x}}{}{f}{}\left({x}{,}{y}\right)\right){}\left(\frac{{\partial }}{{\partial }{x}}{}{\mathrm{arctan}}{}\left(\sqrt{{x}}{}{y}\right)\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{\left(\frac{\partial }{\partial y}f\left(x,y\right)\right)}^{2}-\left(\frac{\partial }{\partial x}f\left(x,y\right)\right)=f\left(x,y\right)$
 ${\mathrm{PDE}}{:=}{x}{}{\left(\frac{{\partial }}{{\partial }{y}}{}{f}{}\left({x}{,}{y}\right)\right)}^{{2}}{-}\left(\frac{{\partial }}{{\partial }{x}}{}{f}{}\left({x}{,}{y}\right)\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}}{}{f}{}\left({x}{,}{y}\right)\right)}^{{2}}{-}\left(\frac{{\partial }}{{\partial }{x}}{}{f}{}\left({x}{,}{y}\right)\right){-}{f}{}\left({x}{,}{y}\right){=}{0}\right){&where}\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\}{,}\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\left(\frac{\partial }{\partial y}f\left(x,y\right)\right)-\left(\frac{\partial }{\partial x}f\left(x,y\right)\right)=f\left(x,y\right)$
 ${\mathrm{PDE}}{:=}{x}{}\left(\frac{{\partial }}{{\partial }{y}}{}{f}{}\left({x}{,}{y}\right)\right){-}\left(\frac{{\partial }}{{\partial }{x}}{}{f}{}\left({x}{,}{y}\right)\right){=}{f}{}\left({x}{,}{y}\right)$ (10)

Next, give an ansatz.

 > $\mathrm{ansatz}≔f\left(x,y\right)=F\left(x\right){ⅇ}^{y}$
 ${\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){-}\left(\frac{{ⅆ}}{{ⅆ}{x}}{}{F}{}\left({x}\right)\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){-}\left(\frac{{ⅆ}}{{ⅆ}{x}}{}{F}{}\left({x}\right)\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{{1}}{{2}}{}{x}{}\left({x}{-}{2}\right)}$ (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{{1}}{{2}}{}{x}{}\left({x}{-}{2}\right)}{}{{ⅇ}}^{{y}}$ (15)
 > $\mathrm{pdetest}\left(\mathrm{ans},\mathrm{PDE}\right)$
 ${0}$ (16)

Test solutions for PDE systems.

 > $\mathrm{sys}≔\left[\frac{\partial }{\partial t}u\left(x,t\right)=\frac{{\partial }^{2}}{\partial {x}^{2}}u\left(x,t\right)-v\left(x,t\right),\frac{\partial }{\partial t}v\left(x,t\right)=\frac{{\partial }^{2}}{\partial {x}^{2}}v\left(x,t\right)-u\left(x,t\right)\right]$
 ${\mathrm{sys}}{:=}\left[\frac{{\partial }}{{\partial }{t}}{}{u}{}\left({x}{,}{t}\right){=}\frac{{{\partial }}^{{2}}}{{\partial }{{x}}^{{2}}}{}{u}{}\left({x}{,}{t}\right){-}{v}{}\left({x}{,}{t}\right){,}\frac{{\partial }}{{\partial }{t}}{}{v}{}\left({x}{,}{t}\right){=}\frac{{{\partial }}^{{2}}}{{\partial }{{x}}^{{2}}}{}{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}}}{+}{{ⅇ}}^{{t}}{}{\mathrm{_C6}}{+}\frac{{\mathrm{_C5}}}{{{ⅇ}}^{{t}}}{,}{v}{}\left({x}{,}{t}\right){=}{-}{{ⅇ}}^{{t}}{}{\mathrm{_C6}}{+}\frac{{\mathrm{_C5}}}{{{ⅇ}}^{{t}}}{-}{\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}≔\frac{\partial }{\partial t}u\left(x,t\right)=k\left(\frac{\partial }{\partial x}\left(\frac{\partial }{\partial x}u\left(x,t\right)\right)\right)+Q$
 ${\mathrm{pde}}{:=}\frac{{\partial }}{{\partial }{t}}{}{u}{}\left({x}{,}{t}\right){=}{k}{}\left(\frac{{{\partial }}^{{2}}}{{\partial }{{x}}^{{2}}}{}{u}{}\left({x}{,}{t}\right)\right){+}{Q}$ (20)
 > ${\mathrm{bc}}_{1}≔u\left(0,t\right)=2{ⅇ}^{kt}-\frac{1Q}{k}$
 ${{\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}{ⅇ}^{x+kt}-\left({\mathrm{_C1}}^{2}-2\right){ⅇ}^{-x+kt}-\frac{1Q{x}^{2}}{2k}+\frac{1Q\left({\mathrm{_C1}}^{2}-2\right)x}{{\mathrm{_C1}}^{2}k}-\frac{1Q}{k}$
 ${\mathrm{sol}}{:=}{u}{}\left({x}{,}{t}\right){=}{{\mathrm{_C1}}}^{{2}}{}{{ⅇ}}^{{k}{}{t}{+}{x}}{-}\left({{\mathrm{_C1}}}^{{2}}{-}{2}\right){}{{ⅇ}}^{{k}{}{t}{-}{x}}{-}\frac{{1}}{{2}}{}\frac{{Q}{}{{x}}^{{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}}_{1}\right]\right)$
 $\left[{0}{,}{0}\right]$ (23)

The boundary conditions can involve derivatives:

 > ${\mathrm{bc}}_{2}≔\mathrm{D}[1,1]\left(u\right)\left(0,t\right)=2{ⅇ}^{kt}-\frac{1Q}{k}$
 ${{\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}}_{2}\right]\right)$
 $\left[{0}{,}{0}\right]$ (25)