{"id":836,"date":"2016-09-16T19:19:43","date_gmt":"2016-09-16T19:19:43","guid":{"rendered":"http:\/\/wordpress.rose-hulman.edu\/rickert\/?page_id=836"},"modified":"2016-09-16T19:21:38","modified_gmt":"2016-09-16T19:21:38","slug":"maple-command-summary","status":"publish","type":"page","link":"https:\/\/wordpress.rose-hulman.edu\/rickert\/maple-command-summary\/","title":{"rendered":"Maple Command Summary"},"content":{"rendered":"<h3 style=\"text-align: center\"><strong>Please <a href=\"mailto:john.rickert@rose-hulman.edu\"><u><span style=\"color: #000080\">e-mail me<\/span><\/u><\/a> if you have any useful suggestions about this page.<\/strong><\/h3>\n<p>All <i>Maple<\/i> commands must end with a semi-colon <span style=\"font-family: Courier New\"><tt>;<\/tt><br \/>\n<\/span> To define a variable, use <tt><span style=\"font-family: Courier New\">:=<\/span><\/tt>. The lone <tt><span style=\"font-family: Courier New\">=<\/span><\/tt> sets up an equation, it does not define the variable.<br \/>\n<i>Maple<\/i> may be used to do arithmetic computations. For example, <span style=\"font-family: Courier New\"><tt>2+3; 17-8; 2*5; 1001\/13; 2^20;<\/tt><br \/>\n<\/span> The <tt><span style=\"font-family: Courier New\">evalf<\/span><\/tt> command will numerically evaluate an expression (it gives a <span style=\"color: #888800\">f<\/span>loating point <span style=\"color: #888800\">eval<\/span>uation)<br \/>\n<tt><span style=\"font-family: Courier New\">evalf(Pi);<br \/>\n<span style=\"color: #0000aa\">3.141592654<\/span><br \/>\nevalf(sqrt(2));<br \/>\n<span style=\"color: #0000aa\">1.414213562<\/span><br \/>\nevalf(exp(1));<br \/>\n<span style=\"color: #0000aa\">2.718281828<\/span><\/span><\/tt><\/p>\n<p><i>Manipulating algebraic expressions<\/i><br \/>\nThe <tt>expand<\/tt> command may be used to expand an algebraic expression. For example,<br \/>\n<span style=\"font-family: Courier New\"><tt>expand((x+2)^3);<br \/>\n<span style=\"color: #0000aa\">x<sup><span style=\"font-size: small\">3<\/span><\/sup>+6x<sup><span style=\"font-size: small\">2<\/span><\/sup>+12x+8<\/span><\/tt><br \/>\nThe <tt>simplify<\/tt> command may be used to simplify complicated expressions.<br \/>\nThe <tt>subs<\/tt> commands may be used to make a substitution,<br \/>\n<\/span><tt><span style=\"font-family: Courier New\">f=x^3+2*x + 7; subs( x=x^2, f);<br \/>\n<span style=\"color: #0000aa\">x<sup><span style=\"font-size: small\">6<\/span><\/sup> + 2x<sup><span style=\"font-size: small\">2<\/span><\/sup> + 7<\/span><br \/>\nsubs( x=1, f);<br \/>\n<span style=\"color: #0000aa\">10<\/span><\/span><\/tt><\/p>\n<p><i>Graphs<\/i><br \/>\nThe <tt>plot<\/tt> command may be used to plot simple graphs,<br \/>\n<span style=\"font-family: Courier New\"><tt>plot( x^3, x=-3..3);<br \/>\nplot( 1\/x, x=-2..3, y=-5..5);<br \/>\nf:=x-x^3; g=sin(x); plot({f,g},x=-1..1);<\/tt><br \/>\nf:=x-x^3; g=sin(x); plot([f,g],x=-1..1,color=[red,blue]);<\/span><span style=\"font-family: Courier New\"> (you won&#8217;t generally have to worry about making graphs different colors)<br \/>\nTo plot parametric equations, place the parametrizations and the limits on the parameter inside <tt>[]<\/tt>:<br \/>\n<tt>plot( [cos(t),sin(t),t=0..2*Pi]);<\/tt><\/span><\/p>\n<p><i>Equations<\/i><br \/>\nThe <i>solve<\/i> command may be used to solve equations,<br \/>\n<span style=\"font-family: Courier New\"><tt>solve( 3*x+y=9, y);<br \/>\n<span style=\"color: #0000aa\">3x+9<\/span><br \/>\nsolve( x^2 + x -6 =0, x);<br \/>\n<span style=\"color: #0000aa\">-3, 2 <\/span><br \/>\nsolve( { x+y=2, 2*x+y=3},{x,y});<br \/>\n<span style=\"color: #0000aa\">{x=1,y=1}<\/span><br \/>\n<\/tt><br \/>\nThe results of these <i>Maple<\/i> evaluations may be used in later calculations<br \/>\n<\/span><tt><span style=\"font-family: Courier New\">sol:=solve( x^2 + x -6 =0, x);<br \/>\n<span style=\"color: #0000aa\"><i>sol<\/i>:=-3, 2 <\/span><br \/>\nsubs( x=sol[1], 2*x+1);<br \/>\n<span style=\"color: #0000aa\">-5<\/span><br \/>\nplugs the first solution (<i>x<\/i>=-3) into the expression 2<i>x<\/i>+1 and returns the value produced. (2(-3)+1=-5)<\/span><\/tt><\/p>\n<p>The <tt>fsolve<\/tt> command may be used to numerically determine real solutions to equations,<br \/>\n<tt><span style=\"font-family: Courier New\">fsolve( cos(x)=x,x);<br \/>\n<span style=\"color: #0000aa\">.7390851332<\/span><br \/>\nfsolve( x^3-3*x+1=0,x);<br \/>\n<span style=\"color: #0000aa\">-1.879385242, .3472963553, 1.532088886<\/span><\/span><\/tt><\/p>\n<p><i>functions<\/i> The trigonometric funcstions are defined in <i>Maple<\/i> by<br \/>\n<tt> sin(x), cos(x), tan(x), cot(x), sec(x),csc(x)<\/tt><br \/>\nThe exponential function <i>e<sup><span style=\"font-size: small\">x<\/span><\/sup><\/i> is given by <tt>exp(x)<\/tt><br \/>\nThe natural logarithm is given by <tt>log(x)<\/tt><br \/>\nThe absolute value function is given by <tt>abs(x)<\/tt><\/p>\n<p><i>vectors<\/i>: We may define a vector by<br \/>\n<tt>v:=[3,4];<\/tt><br \/>\nIf we wish to find the magnitude of the vector, we must load the <i>Maple<\/i> <tt><span style=\"font-family: Courier New\">linalg<\/span><tt><span style=\"font-family: Courier New\"> package.<br \/>\n<tt>with(linalg):<\/tt><br \/>\nand use the command<br \/>\n<\/span><span style=\"font-family: Courier New\"><tt>mag:=norm(v,2);<br \/>\n<span style=\"color: #0000aa\">mag:=5<\/span><br \/>\n<\/tt> The direction vector is given by a parallel unit vector <b>v<\/b>\/||<b>v<\/b>||;<br \/>\n<\/span><span style=\"font-family: Courier New\"><tt> dir:= v\/mag;<br \/>\n<span style=\"color: #0000aa\">dir:=[3\/5,4\/5]<\/span><\/tt><br \/>\nTo bypass the <tt>linalg<\/tt> package, you may simply compute the magnitude by finding the square root of the sum of the squares of the components;<br \/>\n<\/span><span style=\"font-family: Courier New\"><tt>mag1:= sqrt( v[1]^2+v[2]^2);<br \/>\n<span style=\"color: #0000aa\">mag1:= 5<\/span><\/tt><br \/>\nThose of you who enjoy digging more deeply into <i>Maple<\/i> could also try creating your own <i>Maple<\/i> function to compute the size of a vector;<br \/>\n<\/span><span style=\"font-family: Courier New\"><tt> siz:= v -&gt; sqrt(v[1]^2+v[2]^2);<br \/>\nsiz(v);<br \/>\n<span style=\"color: #0000aa\">5<\/span><br \/>\n<\/tt><br \/>\n<i>Help<\/i>: <i>Maple<\/i> help for functions may be called by type a <tt>?<\/tt> followed by the command. For example,<br \/>\n<\/span><tt><span style=\"font-family: Courier New\"> ?plot;<br \/>\n?log;<br \/>\n?solve;<br \/>\n?subs;<\/span><\/tt><\/tt><\/tt><\/p>\n<p><i>parentheses, braces and brackets<\/i> Braces (curly braces), <tt>{}<\/tt>, are used to make lists (or sets) of elements in <i>Maple<\/i>. The order of the terms is irrelevant, <i>Maple<\/i> will reorder according to its own &#8220;whims&#8221; and remove redundant elements. For example,<br \/>\n<tt><span style=\"font-family: Courier New\"> {1,5,3,3,2};<br \/>\n<span style=\"color: #0000aa\">{1,2,3,5}<\/span><br \/>\n{x^2,sin(x),x,cos(x)};<br \/>\n<span style=\"color: #0000aa\">{x,sin(x),cos(x),x^2}<\/span><br \/>\nBrackets (square brackets), <tt>[]<\/tt>, are used to make Ordered lists. <i>Maple<\/i> will keep elements in the same order that you listed them. This is very useful for describing points (ordered pairs) and vectors and subscripts in a list.<br \/>\n<\/span><tt><span style=\"font-family: Courier New\"> [1,5,3,3,2];<br \/>\n<span style=\"color: #0000aa\">[1,5,3,3,2]<\/span><br \/>\n[x^2,sin(x),x,cos(x)];<br \/>\n<span style=\"color: #0000aa\">[x^2,sin(x),x,cos(x)]<\/span><br \/>\nfn:=[x^2,sin(x),x,cos(x)];<br \/>\n<span style=\"color: #0000aa\">fn:=[x^2,sin(x),x,cos(x)]<\/span><br \/>\nfn[1];<br \/>\n<span style=\"color: #0000aa\">x<sup><span style=\"font-size: small\">2<\/span><\/sup><\/span><br \/>\nfn[4];<br \/>\n<span style=\"color: #0000aa\">cos(x)<\/span><br \/>\nparentheses, <tt>()<\/tt>,are used by <i>Maple<\/i> to enclose a sequence of expressions to be evaluated in a function.<br \/>\n<\/span><span style=\"font-family: Courier New\"><tt>f:=(x,y)-&gt;x^2+y^2;<br \/>\nf(3,4);<br \/>\n<span style=\"color: #0000aa\">25<\/span><br \/>\nf(1,10);<br \/>\n<span style=\"color: #0000aa\">101<\/span><\/tt><\/span><\/tt><\/tt><\/p>\n<p>&lt;!&#8211; <tt>diff(sin(x),x);<\/tt> differentiates the sine function with respect to <i>x<\/i>.<br \/>\n&#8211;&gt;<\/p>\n<hr \/>\n<p>Go to<\/p>\n<ul>\n<li>Dr. Rickert&#8217;s <a href=\"http:\/\/wordpress.rose-hulman.edu\/rickert\/maple-command-summary\/\" target=\"_blank\"><u><span style=\"color: #000080\">MA111 page<\/span><\/u><\/a><\/li>\n<li>the <a href=\"http:\/\/www.rose-hulman.edu\/math\/home.php\"><u><span style=\"color: #000080\">Mathematics Department Home Page. <\/span><\/u><\/a><\/li>\n<li>Dr. Rickert&#8217;s <a href=\"http:\/\/wordpress.rose-hulman.edu\/rickert\/jhrs-class-pages-list\/\" target=\"_blank\"><u><span style=\"color: #000080\">classes page<\/span><\/u><\/a><\/li>\n<li>Dr. Rickert&#8217;s <a href=\"http:\/\/wordpress.rose-hulman.edu\/rickert\/\" target=\"_blank\"><u><span style=\"color: #000080\">home page<\/span><\/u><\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">Please e-mail me if you have any useful suggestions about this page. All Maple commands must end with a semi-colon ; To define a variable, use :=. The lone = sets up an equation, it does not define the variable. Maple may be used to do arithmetic computations. For example, 2+3; 17-8; 2*5; 1001\/13; 2^20; The evalf command will numerically&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"btn btn-default\" href=\"https:\/\/wordpress.rose-hulman.edu\/rickert\/maple-command-summary\/\">Read more<\/a><\/p>\n","protected":false},"author":812,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-836","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/wordpress.rose-hulman.edu\/rickert\/wp-json\/wp\/v2\/pages\/836","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.rose-hulman.edu\/rickert\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/wordpress.rose-hulman.edu\/rickert\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.rose-hulman.edu\/rickert\/wp-json\/wp\/v2\/users\/812"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.rose-hulman.edu\/rickert\/wp-json\/wp\/v2\/comments?post=836"}],"version-history":[{"count":3,"href":"https:\/\/wordpress.rose-hulman.edu\/rickert\/wp-json\/wp\/v2\/pages\/836\/revisions"}],"predecessor-version":[{"id":3709,"href":"https:\/\/wordpress.rose-hulman.edu\/rickert\/wp-json\/wp\/v2\/pages\/836\/revisions\/3709"}],"wp:attachment":[{"href":"https:\/\/wordpress.rose-hulman.edu\/rickert\/wp-json\/wp\/v2\/media?parent=836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}