declare - Maple Help

PDEtools[declare]

declare a function for compact display

PDEtools[undeclare]

undeclare a function for compact display

Physics[CompactDisplay]

Synonym of 'declare', declare a function for compact display

 Calling Sequence declare(f(x), g(x, y), '...') declare(expr) declare(prime = x) declare(prime) declare(copyasdisplayed = truefalse) declare(copyasdisplayed) undeclare(f(x), '...') undeclare(expr) undeclare(prime) undeclare(all) ON OFF show

Parameters

 f(x) - function to be printed with compact display expr - set, list, or sequence of expressions prime = x - equation indicating the differentiation variable to be displayed with a prime, or just the keyword prime to query about its value copyasdisplayed = .. - equation where the right-hand side is true or false (the default), or just the keyword copyasdisplayed to query about its value; when true, displayed output of declared functions and derivates is copied & pasted "as displayed", instead of the default behavior which is "as entered" quiet - (optional) perform declarations without having information displayed on the screen

Description

 • The purpose of this set of commands, declare, undeclare, show, ON, OFF, is to permit a simple, compact display of functions and derivatives on the screen. The Physics CompactDisplay command is a synonym to declare so you can use it in place of declare when working with the Physics package.
 • Typically, one declares functions by using declare(f(x, y, z)) with the result that $f\left(x,y,z\right)$ is displayed as $f$ (that is, only its name) as well as occurrences of indexed $f$, say as in ${f}_{j}\left(x,y,z\right)$ are displayed as ${f}_{j}$. This avoids a significant part of redundant information on the screen. One can declare the prime variable and many functions at once.
 • This scheme also displays all differentiation variables as indices, and permits declaring a prime variable so that, for functions of one variable, derivatives with respect to that declared prime variable are displayed with a prime.
 • Different from macro and alias, this set of commands works with 'print/foo' routines, so it does not change the output, only its typesetting on the screen.
 • When declare is called with an algebraic expression, each unknown function in the expression gets "declared".
 Note: you cannot declare for compact display known functions of the mathematical language (cos, sin, etc.).
 • Expressions involving declared functions or derivatives, that are compactly displayed on the screen, are copied and pasted as they were entered, not as they are displayed. For example declaring $f\left(x,y,z\right)$ makes it be displayed as $f$, but copying that $f$ from the output and pasting into an input line produces $f\left(x,y,z\right)$, not $f$. The same happens with derivatives displayed compactly as indexed or with primes '. However, it is sometimes convenient to copy and paste as displayed, for instance to paste formulas with format in an email, or in text in a worksheet. For that purpose, set the value of copyasdisplayed to true entering declare(copyasdisplayed = true);
 • If no arguments are given to declare, the values of the copyasdisplayed, prime, and declared variables are reported. If the arguments prime or copyasdisplayed - just the keywords - are given, the corresponding values are reported.
 • The command undeclare accepts the same types of arguments as declare does, that is, a function, a sequence of functions, or an algebraic expression. It is used to "undo" declarations previously done by using declare.
 • declare and undeclare by default print informative messages when they are called. By using the optional argument 'quiet' these messages are suppressed.
 • When declare is first called, the scheme for compact display is turned ON. However, to turn explicit the actual value of an expression being displayed compactly, you can toggle this feature OFF. Two macros ON and OFF are provided for that purpose. Also, in the ON mode, the macro show displays the last expression in OFF mode.
 • These functions are part of the PDEtools package, and so they can be used in the form declare(..) and undeclare(..) only after executing the command with(PDEtools). However, they can always be accessed through the long form of the command by using PDEtools[declare](..) or PDEtools[undeclare](..).

Examples

Declare y(x) to be displayed as y, and x to be the 'prime' differentiation variable.

 > $\mathrm{with}\left(\mathrm{PDEtools}\right):$
 > $\mathrm{declare}\left(y\left(x\right),\mathrm{prime}=x\right)$
 ${y}{}\left({x}\right){}{\mathrm{will now be displayed as}}{}{y}$
 ${\mathrm{derivatives with respect to}}{}{x}{}{\mathrm{of functions of one variable will now be displayed with \text{'}}}$ (1)

Check the declarations.

 > $\mathrm{declare}\left(\right)$
 ${\mathrm{Declared :}}$
 ${y}{}\left({x}\right){}{\mathrm{to be displayed as}}{}{y}$
 ${\mathrm{derivatives with respect to}}{}{x}{}{\mathrm{of functions of one variable are being displayed with \text{'}}}$
 ${\mathrm{Displayed derivatives and declared functions will be copied and pasted "as they were entered"}}$ (2)
 > $\mathrm{declare}\left(\mathrm{prime}\right)$
 ${\mathrm{derivatives with respect to}}{}{x}{}{\mathrm{of functions of one variable are being displayed with \text{'}}}$ (3)

Following is an ODE displayed by using the scheme for compact printing.

 > $\mathrm{ode}≔\mathrm{diff}\left(\mathrm{diff}\left(y\left(x\right),x\right),x\right)\mathrm{diff}\left(y\left(x\right),x\right)y\left(x\right)f\left(x\right)-2{\mathrm{diff}\left(y\left(x\right),x\right)}^{3}{x}^{6}+2{\mathrm{diff}\left(y\left(x\right),x\right)}^{2}y\left(x\right)\mathrm{diff}\left(g\left(x\right),x\right)+{y\left(x\right)}^{5}$
 ${\mathrm{ode}}{≔}{\mathrm{y\text{'}\text{'}}}{}{\mathrm{y\text{'}}}{}{y}{}{f}{}\left({x}\right){-}{2}{}{{\mathrm{y\text{'}}}}^{{3}}{}{{x}}^{{6}}{+}{2}{}{{\mathrm{y\text{'}}}}^{{2}}{}{y}{}{\mathrm{g\text{'}}}{+}{{y}}^{{5}}$ (4)

Turn the scheme OFF, print the ODE, and then turn the scheme ON again.  Compare the results.

 > $\mathrm{OFF}$
 > $\mathrm{ode}$
 $\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){}{y}{}\left({x}\right){}{f}{}\left({x}\right){-}{2}{}{\left(\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right)\right)}^{{3}}{}{{x}}^{{6}}{+}{2}{}{\left(\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right)\right)}^{{2}}{}{y}{}\left({x}\right){}\left(\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{g}{}\left({x}\right)\right){+}{{y}{}\left({x}\right)}^{{5}}$ (5)
 > $\mathrm{ON}$
 > $\mathrm{ode}$
 ${\mathrm{y\text{'}\text{'}}}{}{\mathrm{y\text{'}}}{}{y}{}{f}{}\left({x}\right){-}{2}{}{{\mathrm{y\text{'}}}}^{{3}}{}{{x}}^{{6}}{+}{2}{}{{\mathrm{y\text{'}}}}^{{2}}{}{y}{}{\mathrm{g\text{'}}}{+}{{y}}^{{5}}$ (6)

Use the show command to display the ODE in standard format, to copy and paste to an input line, but keep the scheme ON.

 > $\mathrm{show}$
 $\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){}{y}{}\left({x}\right){}{f}{}\left({x}\right){-}{2}{}{\left(\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right)\right)}^{{3}}{}{{x}}^{{6}}{+}{2}{}{\left(\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{y}{}\left({x}\right)\right)}^{{2}}{}{y}{}\left({x}\right){}\left(\frac{{ⅆ}}{{ⅆ}{x}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{g}{}\left({x}\right)\right){+}{{y}{}\left({x}\right)}^{{5}}$ (7)
 > $\mathrm{ode}$
 ${\mathrm{y\text{'}\text{'}}}{}{\mathrm{y\text{'}}}{}{y}{}{f}{}\left({x}\right){-}{2}{}{{\mathrm{y\text{'}}}}^{{3}}{}{{x}}^{{6}}{+}{2}{}{{\mathrm{y\text{'}}}}^{{2}}{}{y}{}{\mathrm{g\text{'}}}{+}{{y}}^{{5}}$ (8)

Now undeclare all the functions.

 > $\mathrm{undeclare}\left(\mathrm{prime}\right)$
 ${\mathrm{There is no more prime differentiation variable; all derivatives will be displayed as indexed functions}}$ (9)
 > $\mathrm{ode}$
 ${{y}}_{{x}{,}{x}}{}{{y}}_{{x}}{}{y}{}{f}{}\left({x}\right){-}{2}{}{{y}}_{{x}}^{{3}}{}{{x}}^{{6}}{+}{2}{}{{y}}_{{x}}^{{2}}{}{y}{}{{g}}_{{x}}{+}{{y}}^{{5}}$ (10)
 > $\mathrm{undeclare}\left(\mathrm{all}\right)$
 ${y}{}\left({x}\right){}{\mathrm{will now be displayed *as is*}}$ (11)
 > $\mathrm{declare}\left(\right)$
 ${\mathrm{Nothing declared}}$ (12)
 > $\mathrm{OFF}$

Here is a PDE example.

 > $\mathrm{pde}≔x\mathrm{diff}\left(f\left(x,y\right),y\right)-\mathrm{diff}\left(f\left(x,y\right),x\right)-\frac{{f\left(x,y\right)}^{2}g\left(x\right)}{h\left(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){-}\frac{{{f}{}\left({x}{,}{y}\right)}^{{2}}{}{g}{}\left({x}\right)}{{h}{}\left({y}\right)}$ (13)
 > $\mathrm{ON}$
 > $\mathrm{pde}$
 ${x}{}{{f}}_{{y}}{-}{{f}}_{{x}}{-}\frac{{{f}{}\left({x}{,}{y}\right)}^{{2}}{}{g}{}\left({x}\right)}{{h}{}\left({y}\right)}$ (14)

During a working session, declare the main function of the problem to avoid redundant information throughout the solution.

 > $\mathrm{declare}\left(f\left(x,y\right)\right)$
 ${f}{}\left({x}{,}{y}\right){}{\mathrm{will now be displayed as}}{}{f}$ (15)
 > $\mathrm{pde}$
 ${x}{}{{f}}_{{y}}{-}{{f}}_{{x}}{-}\frac{{{f}}^{{2}}{}{g}{}\left({x}\right)}{{h}{}\left({y}\right)}$ (16)

You can declare all the functions in a given DE or PDE directly.

 > $\mathrm{declare}\left(\mathrm{pde}\right)$
 ${f}{}\left({x}{,}{y}\right){}{\mathrm{will now be displayed as}}{}{f}$
 ${g}{}\left({x}\right){}{\mathrm{will now be displayed as}}{}{g}$
 ${h}{}\left({y}\right){}{\mathrm{will now be displayed as}}{}{h}$ (17)
 > $\mathrm{pde}$
 ${x}{}{{f}}_{{y}}{-}{{f}}_{{x}}{-}\frac{{{f}}^{{2}}{}{g}}{{h}}$ (18)

It is also possible to selectively undeclare one (or many) functions. When doing that, one can give the function or its name.

 > $\mathrm{undeclare}\left(g\right)$
 ${g}{}\left({x}\right){}{\mathrm{will now be displayed *as is*}}$ (19)
 > $\mathrm{pde}$
 ${x}{}{{f}}_{{y}}{-}{{f}}_{{x}}{-}\frac{{{f}}^{{2}}{}{g}{}\left({x}\right)}{{h}}$ (20)
 > $\mathrm{undeclare}\left(\mathrm{all}\right)$
 ${f}{}\left({x}{,}{y}\right){}{\mathrm{will now be displayed *as is*}}$
 ${h}{}\left({y}\right){}{\mathrm{will now be displayed *as is*}}$ (21)
 > $\mathrm{pde}$
 ${x}{}{{f}}_{{y}}{-}{{f}}_{{x}}{-}\frac{{{f}{}\left({x}{,}{y}\right)}^{{2}}{}{g}{}\left({x}\right)}{{h}{}\left({y}\right)}$ (22)
 > $\mathrm{OFF}$
 > $\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){-}\frac{{{f}{}\left({x}{,}{y}\right)}^{{2}}{}{g}{}\left({x}\right)}{{h}{}\left({y}\right)}$ (23)

Compatibility

 • The PDEtools[declare] and Physics[CompactDisplay] commands were updated in Maple 18.
 • The copyasdisplayed = .. parameter was introduced in Maple 18.