convert - Maple Programming Help

convert

convert an expression to a different form

 Calling Sequence convert(expr, form, arg3, ...)

Parameters

 expr - any expression form - name arg3, ... - (optional) other arguments

Description

 • The convert function is used to convert an expression from one form to another.  Some of the conversions are data-type conversions, for example convert([x, y], set)  Others are form or function conversions, for example convert(x^3-3*x^2+7*x+9, horner, x)  yields  9+(7+(-3+x)*x)*x and convert(a*x!, GAMMA) yields a*GAMMA(x+1).
 • For function conversions, a set of optional arguments to perform the conversion in different manners are described in convert/to_special_function.
 • The types of known conversions are (the second argument form must be one of these):

 • Further information is available under help pages convert/form where form is one of the forms from the above list.
 • A user can make custom conversions known to the convert function by defining a Maple procedure in the following way.  If the procedure convert/f is defined, then the function call convert(a, f, x, y, ...) will invoke convert/f(a, x, y, ...); Note that the procedure may be indexed, for example convert([1,2,3], Vector[row]);

Examples

Convert can be used to convert numbers between bases.  See the help pages convert/decimal, convert/base, convert/binary, convert/octal, and convert/hex for more information and examples.

 > $\mathrm{convert}\left(9,\mathrm{binary}\right)$
 ${1001}$ (1)

 > $\mathrm{convert}\left(\mathrm{Pi},\mathrm{degrees}\right)$
 ${180}{}{\mathrm{degrees}}$ (2)

Convert to rational expressions or floating-point numbers. See the help pages convert/float and convert/rational for more information.

 > $\mathrm{convert}\left(1.23456,\mathrm{rational}\right)$
 $\frac{{3858}}{{3125}}$ (3)
 > $\mathrm{convert}\left(\frac{1}{8},\mathrm{float},3\right)$
 ${0.125}$ (4)

Convert between units. See the help page convert/units for more information.  Also, see the Units package.

 > $\mathrm{convert}\left(22,\mathrm{units},\mathrm{inches},m\right)$
 $\frac{{1397}}{{2500}}$ (5)

Convert between Roman numerals and integers. See the help pages convert/arabic and convert/roman for more information.

 > $\mathrm{convert}\left("XI",\mathrm{arabic}\right)$
 ${11}$ (6)

Convert all the operands of a list, set, or expression to addition or multiplication. See the help page convert/+ for more information.

 > $\mathrm{convert}\left(\left[1,2,3,4\right],\mathrm{+}\right)$
 ${10}$ (7)
 > $f≔\mathrm{seq}\left({x}_{i}^{i},i=1..4\right)$
 ${f}{≔}{{x}}_{{1}}{,}{{x}}_{{2}}^{{2}}{,}{{x}}_{{3}}^{{3}}{,}{{x}}_{{4}}^{{4}}$ (8)
 > $\mathrm{convert}\left(\left[f\right],\mathrm{*}\right)$
 ${{x}}_{{1}}{}{{x}}_{{2}}^{{2}}{}{{x}}_{{3}}^{{3}}{}{{x}}_{{4}}^{{4}}$ (9)

Convert a given list, set, or expression to 'and', 'or', or 'xor' form.  See the help page convert/and for more information.

 > $\mathrm{convert}\left(\left[x,y\right],\mathrm{and}\right)$
 ${x}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{and}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{y}$ (10)

Convert a rational expression to partial fraction form. See the help page convert/parfrac for more information.

 > $f≔\frac{{x}^{3}+x}{{x}^{2}-1}$
 ${f}{≔}\frac{{{x}}^{{3}}{+}{x}}{{{x}}^{{2}}{-}{1}}$ (11)
 > $\mathrm{convert}\left(f,\mathrm{parfrac},x\right)$
 ${x}{+}\frac{{1}}{{x}{-}{1}}{+}\frac{{1}}{{x}{+}{1}}$ (12)

Convert a series to a polynomial by dropping the order term. See the help page convert/polynom for more information.

 > $s≔\mathrm{series}\left(f,x,4\right)$
 ${s}{≔}{-}{x}{-}{2}{}{{x}}^{{3}}{+}{O}{}\left({{x}}^{{5}}\right)$ (13)
 > $\mathrm{convert}\left(s,\mathrm{polynom}\right)$
 ${-}{2}{}{{x}}^{{3}}{-}{x}$ (14)

Convert a complex expression to polar coordinates. See the help page convert/polar for more information.

 > $\mathrm{convert}\left(\frac{1}{2}+\frac{I}{2},\mathrm{polar}\right)$
 ${\mathrm{polar}}{}\left(\frac{\sqrt{{2}}}{{2}}{,}\frac{{\mathrm{\pi }}}{{4}}\right)$ (15)

Convert an expression to trigonometric or exponential form, if possible. See the help pages convert/exp and convert/trig for more information.

 > $g≔\mathrm{sinh}\left(x\right)+\mathrm{sin}\left(x\right)$
 ${g}{≔}{\mathrm{sinh}}{}\left({x}\right){+}{\mathrm{sin}}{}\left({x}\right)$ (16)
 > $\mathrm{convert}\left(g,\mathrm{exp}\right)$
 $\frac{{{ⅇ}}^{{x}}}{{2}}{-}\frac{{{ⅇ}}^{{-}{x}}}{{2}}{-}\frac{{I}{}\left({{ⅇ}}^{{I}{}{x}}{-}{{ⅇ}}^{{-I}{}{x}}\right)}{{2}}$ (17)

Check the list above for all known types of conversions for more possibilities. Conversions to more advanced mathematical functions are shown below.

 > $h≔\mathrm{BesselJ}\left(a,z\right)$
 ${h}{≔}{\mathrm{BesselJ}}{}\left({a}{,}{z}\right)$ (18)
 > $j≔\mathrm{convert}\left(h,\mathrm{hypergeom}\right)$
 ${j}{≔}\frac{{{z}}^{{a}}{}{\mathrm{hypergeom}}{}\left(\left[\right]{,}\left[{a}{+}{1}\right]{,}{-}\frac{{{z}}^{{2}}}{{4}}\right)}{{\mathrm{\Gamma }}{}\left({a}{+}{1}\right){}{{2}}^{{a}}}$ (19)
 > $\mathrm{convert}\left(j,\mathrm{Bessel}\right)$
 ${\mathrm{BesselJ}}{}\left({a}{,}{z}\right)$ (20)