simplify/constant - Maple Programming Help

Home : Support : Online Help : Mathematics : Algebra : Expression Manipulation : Simplifying : simplify/constant

simplify/constant

simplify constant expressions typically containing radicals and functions with exact numeric arguments

 Calling Sequence simplify(expr, constant)

Parameters

 expr - expression constant - literal name; constant

Description

 • The simplify(expr, constant) calling sequence is used to simplify expressions that are of type,constant and typically contain radicals or mathematical functions having exact numeric arguments.
 The approach used consists of applying a set of simplification procedures (SP) in two steps:
 1) The constant objects, in the form of sums, products, or function calls, are simplified using SP, starting with the inner most one and composing simplifications at each step. The routines can handle with reasonable efficiency products of fractional powers, exponentials, and various functions calls together with their multiplicative inverses.
 2) When the resulting expression still contains radicals, the simplification procedure applied to each object in the previous step is applied once more, this time to the whole expression.
 • The simplification procedures SP used in the itemization above consist of analyzing the Real and Imaginary parts of the expression in order to conclude about possible cancellations or simpler representations. In addition, if the expression or subexpression can be evaluated numerically fast, using hardware floats, this information is used as a starting point to determine an exact rational value for the object, if that value exists.
 The simplify/constant routines do take assumptions into account up to the point Re, Im, and abs take them.
 The simplification of constant subexpressions entering input for simplify is performed automatically. However, to invoke this set of simplification routines, call simplify with the extra argument constant.

Examples

 > $\mathrm{e1}≔1+2\mathrm{cos}\left(\frac{2\mathrm{Pi}}{7}\right)-2\mathrm{cos}\left(\frac{3\mathrm{Pi}}{7}\right)-2\mathrm{cos}\left(\frac{1\mathrm{Pi}}{7}\right)$
 ${\mathrm{e1}}{≔}{1}{+}{2}{}{\mathrm{cos}}{}\left(\frac{{2}{}{\mathrm{\pi }}}{{7}}\right){-}{2}{}{\mathrm{cos}}{}\left(\frac{{3}{}{\mathrm{\pi }}}{{7}}\right){-}{2}{}{\mathrm{cos}}{}\left(\frac{{\mathrm{\pi }}}{{7}}\right)$ (1)
 > $\mathrm{simplify}\left(\mathrm{e1},\mathrm{constant}\right)$
 ${0}$ (2)

How it works.

 > $\left|\mathrm{e1}\right|$
 ${0}$ (3)

The following example has a more complex step.

 > $\mathrm{e2}≔{\left(-1\right)}^{\frac{6}{7}}-{\left(-1\right)}^{\frac{1}{7}}+{\left(-1\right)}^{\frac{4}{7}}+{\left(-1\right)}^{\frac{2}{7}}-{\left(-1\right)}^{\frac{3}{7}}+1-{\left(-1\right)}^{\frac{5}{7}}$
 ${\mathrm{e2}}{≔}{\left({-1}\right)}^{{6}}{{7}}}{-}{\left({-1}\right)}^{{1}}{{7}}}{+}{\left({-1}\right)}^{{4}}{{7}}}{+}{\left({-1}\right)}^{{2}}{{7}}}{-}{\left({-1}\right)}^{{3}}{{7}}}{+}{1}{-}{\left({-1}\right)}^{{5}}{{7}}}$ (4)
 > $\left|\mathrm{e2}\right|$
 ${0}$ (5)

Manipulate the real and imaginary parts.

 > $\mathrm{simplify}\left(\mathrm{e2},\mathrm{constant}\right)$
 ${0}$ (6)

This example shows that these simple manipulations of the real and imaginary parts are not enough, but the expression is (in this case by construction) equal to a rational number.

 > $\mathrm{e3}≔\mathrm{e2}-\frac{17}{53}$
 ${\mathrm{e3}}{≔}{\left({-1}\right)}^{{6}}{{7}}}{-}{\left({-1}\right)}^{{1}}{{7}}}{+}{\left({-1}\right)}^{{4}}{{7}}}{+}{\left({-1}\right)}^{{2}}{{7}}}{-}{\left({-1}\right)}^{{3}}{{7}}}{+}\frac{{36}}{{53}}{-}{\left({-1}\right)}^{{5}}{{7}}}$ (7)
 > $\mathrm{simplify}\left(\mathrm{e3},\mathrm{constant}\right)$
 ${-}\frac{{17}}{{53}}$ (8)

The following example has nonelementary functions.

 > $\mathrm{e4}≔\frac{1\mathrm{Ψ}\left(1,\frac{1}{8}\right)\mathrm{Pi}\mathrm{csc}\left(\frac{1\mathrm{Pi}}{8}\right)}{64\mathrm{GAMMA}\left(\frac{7}{8}\right)}+\frac{1{\mathrm{Ψ}\left(\frac{1}{8}\right)}^{2}\mathrm{Pi}\mathrm{csc}\left(\frac{1\mathrm{Pi}}{8}\right)}{64\mathrm{GAMMA}\left(\frac{7}{8}\right)}-\frac{1\mathrm{Pi}\mathrm{Ψ}\left(1,\frac{1}{8}\right)}{64\mathrm{sin}\left(\frac{1\mathrm{Pi}}{8}\right)\mathrm{GAMMA}\left(\frac{7}{8}\right)}-\frac{1\mathrm{Pi}{\mathrm{Ψ}\left(\frac{1}{8}\right)}^{2}}{64\mathrm{sin}\left(\frac{1\mathrm{Pi}}{8}\right)\mathrm{GAMMA}\left(\frac{7}{8}\right)}+1$
 ${\mathrm{e4}}{≔}\frac{{\mathrm{\Psi }}{}\left({1}{,}\frac{{1}}{{8}}\right){}{\mathrm{\pi }}{}{\mathrm{csc}}{}\left(\frac{{\mathrm{\pi }}}{{8}}\right)}{{64}{}{\mathrm{\Gamma }}{}\left(\frac{{7}}{{8}}\right)}{+}\frac{{{\mathrm{\Psi }}{}\left(\frac{{1}}{{8}}\right)}^{{2}}{}{\mathrm{\pi }}{}{\mathrm{csc}}{}\left(\frac{{\mathrm{\pi }}}{{8}}\right)}{{64}{}{\mathrm{\Gamma }}{}\left(\frac{{7}}{{8}}\right)}{-}\frac{{\mathrm{\pi }}{}{\mathrm{\Psi }}{}\left({1}{,}\frac{{1}}{{8}}\right)}{{64}{}{\mathrm{sin}}{}\left(\frac{{\mathrm{\pi }}}{{8}}\right){}{\mathrm{\Gamma }}{}\left(\frac{{7}}{{8}}\right)}{-}\frac{{\mathrm{\pi }}{}{{\mathrm{\Psi }}{}\left(\frac{{1}}{{8}}\right)}^{{2}}}{{64}{}{\mathrm{sin}}{}\left(\frac{{\mathrm{\pi }}}{{8}}\right){}{\mathrm{\Gamma }}{}\left(\frac{{7}}{{8}}\right)}{+}{1}$ (9)
 > $\mathrm{simplify}\left(\mathrm{e4},\mathrm{constant}\right)$
 ${1}$ (10)

The following example has powers of trigonometric functions.

 > $\mathrm{e5}≔-\frac{1200{\mathrm{cos}\left(\frac{3\mathrm{Pi}}{7}\right)}^{2}\mathrm{cos}\left(\frac{1\mathrm{Pi}}{7}\right)}{7}+\frac{128{\mathrm{cos}\left(\frac{3\mathrm{Pi}}{7}\right)}^{6}}{7}-\frac{4\mathrm{cos}\left(\frac{3\mathrm{Pi}}{7}\right)\left(120\mathrm{cos}\left(\frac{3\mathrm{Pi}}{7}\right)\mathrm{cos}\left(\frac{1\mathrm{Pi}}{7}\right)-192{\mathrm{cos}\left(\frac{3\mathrm{Pi}}{7}\right)}^{5}\right)}{7}-\frac{1200{\mathrm{cos}\left(\frac{2\mathrm{Pi}}{7}\right)}^{2}\mathrm{cos}\left(\frac{3\mathrm{Pi}}{7}\right)}{7}+\frac{128{\mathrm{cos}\left(\frac{2\mathrm{Pi}}{7}\right)}^{6}}{7}+\frac{4\mathrm{cos}\left(\frac{2\mathrm{Pi}}{7}\right)\left(-120\mathrm{cos}\left(\frac{3\mathrm{Pi}}{7}\right)\mathrm{cos}\left(\frac{2\mathrm{Pi}}{7}\right)+192{\mathrm{cos}\left(\frac{2\mathrm{Pi}}{7}\right)}^{5}\right)}{7}+\frac{1200\mathrm{cos}\left(\frac{2\mathrm{Pi}}{7}\right){\mathrm{cos}\left(\frac{1\mathrm{Pi}}{7}\right)}^{2}}{7}+\frac{128{\mathrm{cos}\left(\frac{1\mathrm{Pi}}{7}\right)}^{6}}{7}-\frac{4\mathrm{cos}\left(\frac{1\mathrm{Pi}}{7}\right)\left(-120\mathrm{cos}\left(\frac{1\mathrm{Pi}}{7}\right)\mathrm{cos}\left(\frac{2\mathrm{Pi}}{7}\right)-192{\mathrm{cos}\left(\frac{1\mathrm{Pi}}{7}\right)}^{5}\right)}{7}$
 ${\mathrm{e5}}{≔}{-}\frac{{1200}{}{{\mathrm{cos}}{}\left(\frac{{3}{}{\mathrm{\pi }}}{{7}}\right)}^{{2}}{}{\mathrm{cos}}{}\left(\frac{{\mathrm{\pi }}}{{7}}\right)}{{7}}{+}\frac{{128}{}{{\mathrm{cos}}{}\left(\frac{{3}{}{\mathrm{\pi }}}{{7}}\right)}^{{6}}}{{7}}{-}\frac{{4}{}{\mathrm{cos}}{}\left(\frac{{3}{}{\mathrm{\pi }}}{{7}}\right){}\left({120}{}{\mathrm{cos}}{}\left(\frac{{3}{}{\mathrm{\pi }}}{{7}}\right){}{\mathrm{cos}}{}\left(\frac{{\mathrm{\pi }}}{{7}}\right){-}{192}{}{{\mathrm{cos}}{}\left(\frac{{3}{}{\mathrm{\pi }}}{{7}}\right)}^{{5}}\right)}{{7}}{-}\frac{{1200}{}{{\mathrm{cos}}{}\left(\frac{{2}{}{\mathrm{\pi }}}{{7}}\right)}^{{2}}{}{\mathrm{cos}}{}\left(\frac{{3}{}{\mathrm{\pi }}}{{7}}\right)}{{7}}{+}\frac{{128}{}{{\mathrm{cos}}{}\left(\frac{{2}{}{\mathrm{\pi }}}{{7}}\right)}^{{6}}}{{7}}{+}\frac{{4}{}{\mathrm{cos}}{}\left(\frac{{2}{}{\mathrm{\pi }}}{{7}}\right){}\left({-}{120}{}{\mathrm{cos}}{}\left(\frac{{3}{}{\mathrm{\pi }}}{{7}}\right){}{\mathrm{cos}}{}\left(\frac{{2}{}{\mathrm{\pi }}}{{7}}\right){+}{192}{}{{\mathrm{cos}}{}\left(\frac{{2}{}{\mathrm{\pi }}}{{7}}\right)}^{{5}}\right)}{{7}}{+}\frac{{1200}{}{\mathrm{cos}}{}\left(\frac{{2}{}{\mathrm{\pi }}}{{7}}\right){}{{\mathrm{cos}}{}\left(\frac{{\mathrm{\pi }}}{{7}}\right)}^{{2}}}{{7}}{+}\frac{{128}{}{{\mathrm{cos}}{}\left(\frac{{\mathrm{\pi }}}{{7}}\right)}^{{6}}}{{7}}{-}\frac{{4}{}{\mathrm{cos}}{}\left(\frac{{\mathrm{\pi }}}{{7}}\right){}\left({-}{120}{}{\mathrm{cos}}{}\left(\frac{{\mathrm{\pi }}}{{7}}\right){}{\mathrm{cos}}{}\left(\frac{{2}{}{\mathrm{\pi }}}{{7}}\right){-}{192}{}{{\mathrm{cos}}{}\left(\frac{{\mathrm{\pi }}}{{7}}\right)}^{{5}}\right)}{{7}}$ (11)
 > $\mathrm{simplify}\left(\mathrm{e5},\mathrm{constant}\right)$
 ${166}$ (12)

In cases as the following one (extracted from some integration problems):

 > $\mathrm{e6}≔-\frac{1I{ⅇ}^{I}\mathrm{Ei}\left(1,I\right)}{2}-\frac{1\mathrm{Ei}\left(1,I\right)\mathrm{sin}\left(1\right)}{2}+\frac{1I\mathrm{Ei}\left(1,I\right)\mathrm{cos}\left(1\right)}{2}-\frac{1\mathrm{Ei}\left(1,-I\right)\mathrm{sin}\left(1\right)}{2}-\frac{1I\mathrm{Ei}\left(1,-I\right)\mathrm{cos}\left(1\right)}{2}+\frac{1I{ⅇ}^{-I}\mathrm{Ei}\left(1,-I\right)}{2}$
 ${\mathrm{e6}}{≔}{-}\frac{{I}{}{{ⅇ}}^{{I}}{}{{\mathrm{Ei}}}_{{1}}{}\left({I}\right)}{{2}}{-}\frac{{{\mathrm{Ei}}}_{{1}}{}\left({I}\right){}{\mathrm{sin}}{}\left({1}\right)}{{2}}{+}\frac{{I}{}{{\mathrm{Ei}}}_{{1}}{}\left({I}\right){}{\mathrm{cos}}{}\left({1}\right)}{{2}}{-}\frac{{{\mathrm{Ei}}}_{{1}}{}\left({-I}\right){}{\mathrm{sin}}{}\left({1}\right)}{{2}}{-}\frac{{I}{}{{\mathrm{Ei}}}_{{1}}{}\left({-I}\right){}{\mathrm{cos}}{}\left({1}\right)}{{2}}{+}\frac{{I}{}{{ⅇ}}^{{-I}}{}{{\mathrm{Ei}}}_{{1}}{}\left({-I}\right)}{{2}}$ (13)

The whole expression cannot be simplified by means of Re, Im, or abs.

 > $\left|\mathrm{e6}\right|$
 $\frac{\left|{-}{I}{}{{ⅇ}}^{{I}}{}{{\mathrm{Ei}}}_{{1}}{}\left({I}\right){-}{{\mathrm{Ei}}}_{{1}}{}\left({I}\right){}{\mathrm{sin}}{}\left({1}\right){+}{I}{}{{\mathrm{Ei}}}_{{1}}{}\left({I}\right){}{\mathrm{cos}}{}\left({1}\right){-}{{\mathrm{Ei}}}_{{1}}{}\left({-I}\right){}{\mathrm{sin}}{}\left({1}\right){-}{I}{}{{\mathrm{Ei}}}_{{1}}{}\left({-I}\right){}{\mathrm{cos}}{}\left({1}\right){+}{I}{}{{ⅇ}}^{{-I}}{}{{\mathrm{Ei}}}_{{1}}{}\left({-I}\right)\right|}{{2}}$ (14)

It cannot be evaluated using hardware floats.

 > $\mathrm{evalhf}\left(\mathrm{e6}\right)$

Some subexpressions of it can be simplified by properly manipulating these procedures and that suffices to collapse the original problem into something within the scope of these simpler manipulations, here leading to the following.

 > $\mathrm{simplify}\left(\mathrm{e6},\mathrm{constant}\right)$
 ${0}$ (15)

The simplification routines for constant expressions is also used by simplify to simplify certain type of constant subexpressions found inside non-constant expressions

 > $\mathrm{e7}≔\frac{1{2}^{\frac{1}{2}}\left(-4{\left(1+{2}^{\frac{1}{2}}\right)}^{\frac{1}{2}}+2{\left(2{2}^{\frac{1}{2}}-2\right)}^{\frac{1}{2}}\mathrm{Pi}+{\left(2{2}^{\frac{1}{2}}-2\right)}^{\frac{1}{2}}\mathrm{Pi}{2}^{\frac{1}{2}}+2{\mathrm{Pi}}^{\frac{1}{2}}{\left(2{2}^{\frac{1}{2}}-2\right)}^{\frac{1}{2}}+{\mathrm{Pi}}^{\frac{1}{2}}{2}^{\frac{1}{2}}{\left(2{2}^{\frac{1}{2}}-2\right)}^{\frac{1}{2}}+2x{\left(2{2}^{\frac{1}{2}}-2\right)}^{\frac{1}{2}}+x{2}^{\frac{1}{2}}{\left(2{2}^{\frac{1}{2}}-2\right)}^{\frac{1}{2}}\right)}{2{\left(2{2}^{\frac{1}{2}}-2\right)}^{\frac{1}{2}}\left({2}^{\frac{1}{2}}-1\right){\left(1+{2}^{\frac{1}{2}}\right)}^{2}}$
 ${\mathrm{e7}}{≔}\frac{\sqrt{{2}}{}\left({-}{4}{}\sqrt{{1}{+}\sqrt{{2}}}{+}{2}{}\sqrt{{2}{}\sqrt{{2}}{-}{2}}{}{\mathrm{\pi }}{+}\sqrt{{2}{}\sqrt{{2}}{-}{2}}{}{\mathrm{\pi }}{}\sqrt{{2}}{+}{2}{}\sqrt{{\mathrm{\pi }}}{}\sqrt{{2}{}\sqrt{{2}}{-}{2}}{+}\sqrt{{\mathrm{\pi }}}{}\sqrt{{2}}{}\sqrt{{2}{}\sqrt{{2}}{-}{2}}{+}{2}{}{x}{}\sqrt{{2}{}\sqrt{{2}}{-}{2}}{+}{x}{}\sqrt{{2}}{}\sqrt{{2}{}\sqrt{{2}}{-}{2}}\right)}{{2}{}\sqrt{{2}{}\sqrt{{2}}{-}{2}}{}\left(\sqrt{{2}}{-}{1}\right){}{\left({1}{+}\sqrt{{2}}\right)}^{{2}}}$ (16)
 > $\mathrm{type}\left(\mathrm{e7},\mathrm{constant}\right)$
 ${\mathrm{false}}$ (17)
 > $\mathrm{simplify}\left(\mathrm{e7}\right)$
 $\sqrt{{\mathrm{\pi }}}{+}{\mathrm{\pi }}{+}{x}{-}{2}$ (18)