DEtools - Maple Programming Help

DEtools

 firint
 calculate first integrals for exact ODEs

 Calling Sequence firint(ODE, y(x), _mu = .., basis = [.., ...], method = formal)

Parameters

 ODE - an ODE that is either linear, or exact, or otherwise an integrating factor for it shall also be indicated using the _mu = ... option y(x) - (optional) required if the exact_ODE contains derivatives of more than one function _mu = .. - (optional) to indicate an integrating factor for ODE when it is not exact method = formal - (optional) only for linear ODEs, to request the computation of a complete set of first integrals basis = [...] - (optional) only for linear ODEs, a basis of solutions for ODE, to be used to compute a complete set of first integrals

Description

 • The firint command receives an nth order ODE, that could be: 1) linear or nonlinear but in exact form, that is, satisfying $\mathrm{ODE}=\frac{\mathrm{dR}}{\mathrm{dx}}$, 2) not in exact form but an integrating factor for it is indicated using the option _mu = ..., 3) the ODE is linear together with the option method = formal. The output of firint for these problems consists of a related first integral (the ODE $R$, of order $n-1$, in $\mathrm{ODE}=\frac{\mathrm{dR}}{\mathrm{dx}}$), or a complete set of them in case 3). The dependent variable y(x), is required only when the ODE contains derivatives of more than one function. Typically, the given ODE is exact; for calculating integrating factors to use with the option _mu = ... see intfactor.
 • The optional arguments can be given alone or in conjunction, and in any order.
 • When a linear ODE is given and the option method = formal is indicated, firint attempts computing a complete basis of solutions for the ODE, or uses a given one if passed with the optional argument basis = [...], and from it computes a complete set of first integrals, that is as many as the differential order and all independent from each other.
 • This function is part of the DEtools package, and so it can be used in the form firint(..) only after executing the command with(DEtools). However, it can always be accessed through the long form of the command by using DEtools[firint](..).

Examples

Nonlinear and linear ODEs

 The general first order linear ODE and its integrating factor
 > $\mathrm{with}\left(\mathrm{DEtools}\right):$
 > $\mathrm{L_ODE}≔\frac{ⅆ}{ⅆx}y\left(x\right)=A\left(x\right)y\left(x\right)+B\left(x\right)$
 ${\mathrm{L_ODE}}{≔}\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right){=}{A}{}\left({x}\right){}{y}{}\left({x}\right){+}{B}{}\left({x}\right)$ (1)
 > $\mathrm{Μ}≔\mathrm{intfactor}\left(\mathrm{L_ODE}\right)$
 ${\mathrm{Μ}}{≔}{{ⅇ}}^{{\int }{-}{A}{}\left({x}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{x}}$ (2)
 A related first integral can now be obtained either using the option $\mathrm{_μ}=\mathrm{Μ}$, as in: firint(L_ODE, _mu = Mu), or multiplying directly L_ODE by Mu (by construction, Mu*L_ODE is exact)
 > $\mathrm{firint}\left(\mathrm{Μ}\mathrm{L_ODE}\right)$
 ${{ⅇ}}^{{\int }{-}{A}{}\left({x}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{x}}{}{y}{}\left({x}\right){-}\left({\int }{{ⅇ}}^{{-}\left({\int }{A}{}\left({x}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{x}\right)}{}{B}{}\left({x}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{x}\right){+}{\mathrm{_C1}}{=}{0}$ (3)
 The most general first order ODE reducible by an integrating factor depending only on $x$ is a Linear ODE (see redode):
 > $\mathrm{reducible_ODE}≔\mathrm{redode}\left(\mathrm{μ}\left(x\right),y\left(x\right)\right)$
 ${\mathrm{reducible_ODE}}{≔}\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right){=}{-}\frac{\left(\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\mathrm{\mu }}{}\left({x}\right)\right){}{y}{}\left({x}\right){+}{\mathrm{_F1}}{}\left({x}\right)}{{\mathrm{\mu }}{}\left({x}\right)}$ (4)
 An exact nonlinear ODE which also has integrating factors of the form $\mathrm{\mu }\left(x,y\right)$
 > $\mathrm{ode2}≔xy\left(x\right)\left(\frac{{ⅆ}^{2}}{ⅆ{x}^{2}}y\left(x\right)\right)+x{\left(\frac{ⅆ}{ⅆx}y\left(x\right)\right)}^{2}+ay\left(x\right)\left(\frac{ⅆ}{ⅆx}y\left(x\right)\right)+f\left(x\right)$
 ${\mathrm{ode2}}{≔}{x}{}{y}{}\left({x}\right){}\left(\frac{{{ⅆ}}^{{2}}}{{ⅆ}{{x}}^{{2}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right)\right){+}{x}{}{\left(\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right)\right)}^{{2}}{+}{a}{}{y}{}\left({x}\right){}\left(\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right)\right){+}{f}{}\left({x}\right)$ (5)
 > $\mathrm{odeadvisor}\left(\mathrm{ode2}\right)$
 $\left[\left[{\mathrm{_2nd_order}}{,}{\mathrm{_exact}}{,}{\mathrm{_nonlinear}}\right]{,}\left[{\mathrm{_2nd_order}}{,}{\mathrm{_reducible}}{,}{\mathrm{_mu_xy}}\right]\right]$ (6)
 Two integrating factors and the related first integrals
 > $\mathrm{μ}≔\mathrm{intfactor}\left(\mathrm{ode2}\right)$
 ${\mathrm{\mu }}{≔}{1}{,}\frac{{{x}}^{{a}}}{{x}}$ (7)
 > $\mathrm{firint}\left(\mathrm{ode2}\right)$
 $\frac{{{y}{}\left({x}\right)}^{{2}}{}{a}}{{2}}{-}\frac{{{y}{}\left({x}\right)}^{{2}}}{{2}}{+}\left(\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right)\right){}{x}{}{y}{}\left({x}\right){+}{\int }{f}{}\left({x}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{x}{+}{\mathrm{_C1}}{=}{0}$ (8)
 > $\mathrm{firint}\left({\mathrm{μ}}_{2}\mathrm{ode2}\right)$
 ${{x}}^{{a}}{}{y}{}\left({x}\right){}\left(\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right)\right){+}{\int }\frac{{{x}}^{{a}}{}{f}{}\left({x}\right)}{{x}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{x}{+}{\mathrm{_C1}}{=}{0}$ (9)
 The answer to ode2 can be built from these two first integrals interactively, or by calling dsolve with extra arguments, indicating the use of the integrating factor scheme $\mathrm{mu_xy}$:
 > $\mathrm{dsolve}\left(\mathrm{ode2},\left['\mathrm{mu_xy}'\right]\right)$
 ${y}{}\left({x}\right){=}\frac{\sqrt{{2}}{}\sqrt{\left({a}{-}{1}\right){}\left({{x}}^{{1}{-}{a}}{}\left({\int }\frac{{{x}}^{{a}}{}{f}{}\left({x}\right)}{{x}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{x}\right){+}{{x}}^{{1}{-}{a}}{}{\mathrm{_C1}}{-}\left({\int }{f}{}\left({x}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{x}\right){-}{\mathrm{_C2}}\right)}}{{a}{-}{1}}{,}{y}{}\left({x}\right){=}{-}\frac{\sqrt{{2}}{}\sqrt{\left({a}{-}{1}\right){}\left({{x}}^{{1}{-}{a}}{}\left({\int }\frac{{{x}}^{{a}}{}{f}{}\left({x}\right)}{{x}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{x}\right){+}{{x}}^{{1}{-}{a}}{}{\mathrm{_C1}}{-}\left({\int }{f}{}\left({x}\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}{x}\right){-}{\mathrm{_C2}}\right)}}{{a}{-}{1}}$ (10)
 A third order ODE, an integrating factor for it, and the related first integral.
 > $\mathrm{ode3}≔\frac{{ⅆ}^{3}}{ⅆ{x}^{3}}y\left(x\right)=-\frac{2{\left(\frac{ⅆ}{ⅆx}y\left(x\right)\right)}^{2}-y\left(x\right)\left(\frac{{ⅆ}^{2}}{ⅆ{x}^{2}}y\left(x\right)\right)}{{\left(\frac{ⅆ}{ⅆx}y\left(x\right)\right)}^{2}{ⅇ}^{\frac{{ⅆ}^{2}}{ⅆ{x}^{2}}y\left(x\right)}}$
 ${\mathrm{ode3}}{≔}\frac{{{ⅆ}}^{{3}}}{{ⅆ}{{x}}^{{3}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right){=}{-}\frac{{2}{}{\left(\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right)\right)}^{{2}}{-}{y}{}\left({x}\right){}\left(\frac{{{ⅆ}}^{{2}}}{{ⅆ}{{x}}^{{2}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right)\right)}{{\left(\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right)\right)}^{{2}}{}{{ⅇ}}^{\frac{{{ⅆ}}^{{2}}}{{ⅆ}{{x}}^{{2}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right)}}$ (11)
 > $\mathrm{Μ}≔\mathrm{intfactor}\left(\mathrm{ode3}\right)$
 ${\mathrm{Μ}}{≔}{{ⅇ}}^{\frac{{{ⅆ}}^{{2}}}{{ⅆ}{{x}}^{{2}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right)}$ (12)
 > $\mathrm{firint}\left(\mathrm{Μ}\mathrm{ode3}\right)$
 $\frac{{y}{}\left({x}\right)}{\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right)}{+}{{ⅇ}}^{\frac{{{ⅆ}}^{{2}}}{{ⅆ}{{x}}^{{2}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right)}{+}{x}{+}{\mathrm{_C1}}{=}{0}$ (13)

Linear ODEs and method = formal

 The firint command treats linear and nonlinear ODEs in equal footing, unless the optional method = formal, valid only for linear equations, is indicated. Consider
 > $\mathrm{ode4}≔\frac{{ⅆ}^{2}}{ⅆ{x}^{2}}y\left(x\right)=\frac{\left(-6x-6\right)\left(\frac{ⅆ}{ⅆx}y\left(x\right)\right)}{x\left(3x+2\right)}+\frac{6y\left(x\right)}{x\left(3x+2\right)}-\frac{6}{x\left(3x+2\right)}$
 ${\mathrm{ode4}}{≔}\frac{{{ⅆ}}^{{2}}}{{ⅆ}{{x}}^{{2}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right){=}\frac{\left({-}{6}{}{x}{-}{6}\right){}\left(\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right)\right)}{{x}{}\left({3}{}{x}{+}{2}\right)}{+}\frac{{6}{}{y}{}\left({x}\right)}{{x}{}\left({3}{}{x}{+}{2}\right)}{-}\frac{{6}}{{x}{}\left({3}{}{x}{+}{2}\right)}$ (14)
 Calling firint without optional arguments will result in an error message telling ode4 is not exact. Passing method = formal, you instead get a complete set of independent first integrals obtained by first computing a basis of the solution space
 > $\mathrm{firint}\left(\mathrm{ode4},\mathrm{method}=\mathrm{formal}\right)$
 ${-}\frac{\left(\left({x}{+}{1}\right){}\left(\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right)\right){-}{y}{}\left({x}\right){+}{1}\right){}{{x}}^{{3}}}{{3}{}{x}{+}{2}}{,}\frac{\left(\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right)\right){}{x}{+}{2}{}{y}{}\left({x}\right){-}{2}}{{3}{}{x}{+}{2}}$ (15)
 A textbook example: the most general 2nd order non-homogeneous linear ODE having for solution basis ${g}_{1}\left(x\right)$ and ${g}_{2}\left(x\right)$, for the homogeneous part, and ${g}_{0}\left(x\right)$ as particular solution of the whole non-homogeneous equation, so the basis of solutions is $\left[\left[{g}_{1}\left(x\right),{g}_{2}\left(x\right)\right],{g}_{0}\left(x\right)\right]$
 > ${\mathrm{PDEtools}}_{\mathrm{declare}}\left(y\left(x\right),g\left(x\right),\mathrm{prime}=x\right)$
 ${y}{}\left({x}\right){}{\mathrm{will now be displayed as}}{}{y}$
 ${g}{}\left({x}\right){}{\mathrm{will now be displayed as}}{}{g}$
 ${\mathrm{derivatives with respect to}}{}{x}{}{\mathrm{of functions of one variable will now be displayed with \text{'}}}$ (16)
 > $\mathrm{Basis}≔\left[\left[{g}_{1}\left(x\right),{g}_{2}\left(x\right)\right],{g}_{0}\left(x\right)\right]$
 ${\mathrm{Basis}}{≔}\left[\left[{{g}}_{{1}}{,}{{g}}_{{2}}\right]{,}{{g}}_{{0}}\right]$ (17)
 > $\mathrm{ode5}≔\frac{{ⅆ}^{2}}{ⅆ{x}^{2}}y\left(x\right)=\frac{\left(\left(\frac{{ⅆ}^{2}}{ⅆ{x}^{2}}{g}_{1}\left(x\right)\right){g}_{2}\left(x\right)-{g}_{1}\left(x\right)\left(\frac{{ⅆ}^{2}}{ⅆ{x}^{2}}{g}_{2}\left(x\right)\right)\right)\left(\frac{ⅆ}{ⅆx}y\left(x\right)\right)}{{g}_{2}\left(x\right)\left(\frac{ⅆ}{ⅆx}{g}_{1}\left(x\right)\right)-{g}_{1}\left(x\right)\left(\frac{ⅆ}{ⅆx}{g}_{2}\left(x\right)\right)}+\frac{\left(\left(\frac{ⅆ}{ⅆx}{g}_{1}\left(x\right)\right)\left(\frac{{ⅆ}^{2}}{ⅆ{x}^{2}}{g}_{2}\left(x\right)\right)-\left(\frac{{ⅆ}^{2}}{ⅆ{x}^{2}}{g}_{1}\left(x\right)\right)\left(\frac{ⅆ}{ⅆx}{g}_{2}\left(x\right)\right)\right)y\left(x\right)}{{g}_{2}\left(x\right)\left(\frac{ⅆ}{ⅆx}{g}_{1}\left(x\right)\right)-{g}_{1}\left(x\right)\left(\frac{ⅆ}{ⅆx}{g}_{2}\left(x\right)\right)}+\frac{-\left(\frac{{ⅆ}^{2}}{ⅆ{x}^{2}}{g}_{2}\left(x\right)\right){g}_{0}\left(x\right)\left(\frac{ⅆ}{ⅆx}{g}_{1}\left(x\right)\right)+{g}_{2}\left(x\right)\left(\frac{{ⅆ}^{2}}{ⅆ{x}^{2}}{g}_{0}\left(x\right)\right)\left(\frac{ⅆ}{ⅆx}{g}_{1}\left(x\right)\right)-\left(\frac{{ⅆ}^{2}}{ⅆ{x}^{2}}{g}_{0}\left(x\right)\right){g}_{1}\left(x\right)\left(\frac{ⅆ}{ⅆx}{g}_{2}\left(x\right)\right)+\left(\frac{ⅆ}{ⅆx}{g}_{2}\left(x\right)\right){g}_{0}\left(x\right)\left(\frac{{ⅆ}^{2}}{ⅆ{x}^{2}}{g}_{1}\left(x\right)\right)-{g}_{2}\left(x\right)\left(\frac{ⅆ}{ⅆx}{g}_{0}\left(x\right)\right)\left(\frac{{ⅆ}^{2}}{ⅆ{x}^{2}}{g}_{1}\left(x\right)\right)+\left(\frac{ⅆ}{ⅆx}{g}_{0}\left(x\right)\right){g}_{1}\left(x\right)\left(\frac{{ⅆ}^{2}}{ⅆ{x}^{2}}{g}_{2}\left(x\right)\right)}{{g}_{2}\left(x\right)\left(\frac{ⅆ}{ⅆx}{g}_{1}\left(x\right)\right)-{g}_{1}\left(x\right)\left(\frac{ⅆ}{ⅆx}{g}_{2}\left(x\right)\right)}$
 ${\mathrm{ode5}}{≔}{\mathrm{y\text{'}\text{'}}}{=}\frac{\left({{g}}_{{1}}^{{\mathrm{\text{'}\text{'}}}}{}{{g}}_{{2}}{-}{{g}}_{{1}}{}{{g}}_{{2}}^{{\mathrm{\text{'}\text{'}}}}\right){}{\mathrm{y\text{'}}}}{{{g}}_{{2}}{}{{g}}_{{1}}^{{\mathrm{\text{'}}}}{-}{{g}}_{{1}}{}{{g}}_{{2}}^{{\mathrm{\text{'}}}}}{+}\frac{\left({{g}}_{{1}}^{{\mathrm{\text{'}}}}{}{{g}}_{{2}}^{{\mathrm{\text{'}\text{'}}}}{-}{{g}}_{{1}}^{{\mathrm{\text{'}\text{'}}}}{}{{g}}_{{2}}^{{\mathrm{\text{'}}}}\right){}{y}}{{{g}}_{{2}}{}{{g}}_{{1}}^{{\mathrm{\text{'}}}}{-}{{g}}_{{1}}{}{{g}}_{{2}}^{{\mathrm{\text{'}}}}}{+}\frac{{-}{{g}}_{{2}}^{{\mathrm{\text{'}\text{'}}}}{}{{g}}_{{0}}{}{{g}}_{{1}}^{{\mathrm{\text{'}}}}{+}{{g}}_{{2}}{}{{g}}_{{0}}^{{\mathrm{\text{'}\text{'}}}}{}{{g}}_{{1}}^{{\mathrm{\text{'}}}}{-}{{g}}_{{0}}^{{\mathrm{\text{'}\text{'}}}}{}{{g}}_{{1}}{}{{g}}_{{2}}^{{\mathrm{\text{'}}}}{+}{{g}}_{{2}}^{{\mathrm{\text{'}}}}{}{{g}}_{{0}}{}{{g}}_{{1}}^{{\mathrm{\text{'}\text{'}}}}{-}{{g}}_{{2}}{}{{g}}_{{0}}^{{\mathrm{\text{'}}}}{}{{g}}_{{1}}^{{\mathrm{\text{'}\text{'}}}}{+}{{g}}_{{0}}^{{\mathrm{\text{'}}}}{}{{g}}_{{1}}{}{{g}}_{{2}}^{{\mathrm{\text{'}\text{'}}}}}{{{g}}_{{2}}{}{{g}}_{{1}}^{{\mathrm{\text{'}}}}{-}{{g}}_{{1}}{}{{g}}_{{2}}^{{\mathrm{\text{'}}}}}$ (18)
 Verify that Basis is a complete basis for the solutions of ode5: from Basis construct the general solution then test it using odetest
 > $\mathrm{sol5}≔y\left(x\right)=\mathrm{_C1}{g}_{1}\left(x\right)+\mathrm{_C1}{g}_{2}\left(x\right)+{g}_{0}\left(x\right)$
 ${\mathrm{sol5}}{≔}{y}{=}{\mathrm{_C1}}{}{{g}}_{{1}}{+}{\mathrm{_C1}}{}{{g}}_{{2}}{+}{{g}}_{{0}}$ (19)
 > $\mathrm{odetest}\left(\mathrm{sol5},\mathrm{ode5}\right)$
 ${0}$ (20)
 A complete set of first integrals for ode5 computed from Basis
 > $\mathrm{firint}\left(\mathrm{ode5},y\left(x\right),\mathrm{basis}=\mathrm{Basis}\right)$
 $\frac{\left({y}{-}{{g}}_{{0}}\right){}{{g}}_{{2}}^{{\mathrm{\text{'}}}}{-}{{g}}_{{2}}{}\left({\mathrm{y\text{'}}}{-}{{g}}_{{0}}^{{\mathrm{\text{'}}}}\right)}{{{g}}_{{1}}{}{{g}}_{{2}}^{{\mathrm{\text{'}}}}{-}{{g}}_{{2}}{}{{g}}_{{1}}^{{\mathrm{\text{'}}}}}{,}\frac{\left({-}{y}{+}{{g}}_{{0}}\right){}{{g}}_{{1}}^{{\mathrm{\text{'}}}}{+}{{g}}_{{1}}{}\left({\mathrm{y\text{'}}}{-}{{g}}_{{0}}^{{\mathrm{\text{'}}}}\right)}{{{g}}_{{1}}{}{{g}}_{{2}}^{{\mathrm{\text{'}}}}{-}{{g}}_{{2}}{}{{g}}_{{1}}^{{\mathrm{\text{'}}}}}$ (21)
 Verify this result
 > $\mathrm{map}\left(\mathrm{firtest},\left[\right],\mathrm{ode5},y\left(x\right)\right)$
 $\left[{0}{,}{0}\right]$ (22)