makeproc - Maple Help

codegen

 makeproc
 make a Maple procedure from formulae

 Calling Sequence makeproc(a, x) makeproc(a, x, ...)

Parameters

 a - formula, list, array of formulae, or Array of formulae x - symbol or a list of symbols

Description

 • The first argument a is a Maple formula, or a list of equations (which is understood to be a sequence of assignments), a named array of formulae, or an Array of formulae. The second argument x is a symbol or a list of symbols. The makeproc command returns a Maple procedure which evaluates a(x).  The symbols in x may include types.
 • The optional arguments $\mathrm{parameters}=P$, $\mathrm{locals}=L$, and $\mathrm{globals}=G$ specify whether symbols are to be parameters, local variables, or global variables respectively.  P, L, G must be lists of symbols, or symbols with types.

Examples

 > $\mathrm{with}\left(\mathrm{codegen},\mathrm{makeproc}\right):$
 > $f≔x{ⅇ}^{-t}-yx{ⅇ}^{-t}$
 ${f}{≔}{x}{}{{ⅇ}}^{{-}{t}}{-}{y}{}{x}{}{{ⅇ}}^{{-}{t}}$ (1)
 > makeproc(f,[x,y,t]);
 ${\mathbf{proc}}\left({x}{,}{y}{,}{t}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{x}{*}{\mathrm{exp}}{}\left({−}{t}\right){-}{y}{*}{x}{*}{\mathrm{exp}}{}\left({−}{t}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (2)
 > makeproc(f,[x,y]);
 ${\mathbf{proc}}\left({x}{,}{y}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{x}{*}{\mathrm{exp}}{}\left({−}{t}\right){-}{y}{*}{x}{*}{\mathrm{exp}}{}\left({−}{t}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (3)
 > $a≔\mathrm{series}\left(\frac{1}{1-{x}^{2}},x,10\right)$
 ${a}{≔}{1}{+}{{x}}^{{2}}{+}{{x}}^{{4}}{+}{{x}}^{{6}}{+}{{x}}^{{8}}{+}{O}{}\left({{x}}^{{10}}\right)$ (4)
 > makeproc(a,x::numeric);
 ${\mathbf{proc}}\left({x}{::}{\mathrm{numeric}}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{1}{+}\left({1}{+}\left({1}{+}\left({x}{^}{2}{+}{1}\right){*}{x}{^}{2}\right){*}{x}{^}{2}\right){*}{x}{^}{2}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (5)
 > $A≔\mathrm{array}\left(\left[3x,{x}^{3},x{y}^{2},-{x}^{2}y\right]\right)$
 ${A}{≔}\left[\begin{array}{cccc}{3}{}{x}& {{x}}^{{3}}& {x}{}{{y}}^{{2}}& {-}{{x}}^{{2}}{}{y}\end{array}\right]$ (6)
 > makeproc(A,[x,y]);
 ${\mathbf{proc}}\left({x}{,}{y}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{≔}{\mathrm{array}}{}\left({1}{..}{4}\right){;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{1}{]}{≔}{3}{*}{x}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{2}{]}{≔}{x}{^}{3}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{3}{]}{≔}{x}{*}{y}{^}{2}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{4}{]}{≔}{−}{x}{^}{2}{*}{y}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (7)
 > makeproc(A,[x,y,A]);
 ${\mathbf{proc}}\left({x}{,}{y}{,}{A}{::}\left({\mathrm{array}}{}\left({1}{..}{4}\right)\right)\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{1}{]}{≔}{3}{*}{x}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{2}{]}{≔}{x}{^}{3}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{3}{]}{≔}{x}{*}{y}{^}{2}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{A}{[}{4}{]}{≔}{−}{x}{^}{2}{*}{y}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{return}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (8)
 > $\mathrm{CS}≔\left[s=\mathrm{sin}\left(x\right),c=\mathrm{cos}\left(x\right),Y-sx-cx-{s}^{2}x+{c}^{2}x\right]:$
 > makeproc(CS,x);
 ${\mathbf{proc}}\left({x}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{c}{,}{s}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{s}{≔}{\mathrm{sin}}{}\left({x}\right){;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{c}{≔}{\mathrm{cos}}{}\left({x}\right){;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{c}{^}{2}{*}{x}{-}{s}{^}{2}{*}{x}{-}{c}{*}{x}{-}{s}{*}{x}{+}{Y}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (9)
 > makeproc(CS,parameters=[x::numeric],locals=[s,c],globals=[Y]);
 ${\mathbf{proc}}\left({x}{::}{\mathrm{numeric}}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{s}{,}{c}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{global}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{Y}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{s}{≔}{\mathrm{sin}}{}\left({x}\right){;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{c}{≔}{\mathrm{cos}}{}\left({x}\right){;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{c}{^}{2}{*}{x}{-}{s}{^}{2}{*}{x}{-}{c}{*}{x}{-}{s}{*}{x}{+}{Y}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (10)