11.07.2015 Views

Maple 9 Learning Guide - Maplesoft

Maple 9 Learning Guide - Maplesoft

Maple 9 Learning Guide - Maplesoft

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

30 • Chapter 2: Mathematics with <strong>Maple</strong>: The BasicsSuppose that you want to define a new array identical to pwr, butwith each occurrence of the number 2 in pwrs replaced by the number 9.To perform this substitution, use the subs command. The basic syntax issubs( x=expr1, y=expr2, ... , main_expr )Note: The subs command does not modify the value of main_expr. Itreturns an object of the same type with the specified substitutions. Forexample, to substitute x + y for z in an expression, do the following.> expr := z^2 + 3;expr := z 2 + 3> subs( {z=x+y}, expr);(x + y) 2 + 3Note that the following call to subs does not work.> subs( {2=9}, pwrs );pwrsYou must instead force <strong>Maple</strong> to fully evaluate the name of the arrayto the component level and not just to its name, using the commandevalm.> pwrs3:=subs( {2=9}, evalm(pwrs) );⎡1 1⎤1pwrs3 := ⎣ 9 4 8 ⎦3 9 27This causes the substitution to occur in the components and full evaluationdisplays the array’s elements, similar to using the print command.> evalm(pwrs3);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!