]>

Substitution and numerical evaluation

Substitution allows you to create a new mathematical expression by replacing terms in an existing mathematical expression with new values. These values can be either numerical values or they can be other mathematical expressions. This process is useful for two purposes. The first is to build up a complex expression by substituting mathematical expressions for variables in the original expression. The second is to plug in numbers to replace variables in a mathematical expression to get the answer. Either of these two purposes can be accomplished with the subs command that takes the form

    newExpression := subs(x=value1, y=value2, existingExpression)

where x and y are variables in the original expression. There can be as many variables, such as x and y as you wish. Only two were used here for simplicity.

The existing mathematical expression remains unchanged. In this way you can substitute different sets of numerical values into it many times; each time creating a new result. This is the preferred way to solve engineering problems. You first derive a mathematical expression that expresses the solution in symbolic form (i.e. expressed in terms of variable names) and then you plug in numbers to get the final numerical result.

Maple always tries to display numbers as integers or rational fractions and not as decimal numbers. Numerical evaluation to obtain a decimal result is accomplished with the evalf command

     evalf( expression )

this can also be accomplished by right-clicking the expression and selecting the Approximation option from the menu. The number of decimal places can be specified by selecting the number desired and then the decimal result will be displayed. If you want to assign a name to this decimal result, right-click it and select the Assign a name option.