Symbolics > Keywords and Modifiers > Using Keywords for Symbolic Operations
  
Using Keywords for Symbolic Operations
Using Keywords With Variables That Have Assigned Values
When you apply a keyword to an expression containing a variable that has an assigned value, PTC Mathcad first replaces the variable with its value and then applies the keyword. In the following example, if you assign the value x:=7 before applying factor, you get the following result:
In this case, PTC Mathcad substitutes 7 for x in the polynomial and evaluates it to get 20, and then it factors the integer 20 into its prime factors.
If you assign an expression of undefined variables to the variable that you are symbolically solving for, the first undefined variable in the expression gets flagged as undefined, but PTC Mathcad substitutes the expression and solves for the specified variable in the expression.
Using Multiple Keywords
Some mathematical problems require the use of more than one keyword. For example:
To expand the function ex into a Taylor series use the keywords series as follows:
This is equivalent to specifying the series default a creation point of 0.
To evaluate the series at x=2 and default creation point, use a second symbolic operator and specify the substitute keyword. Using multiple symbolic evaluation operators is known as chaining.
Another way to combine keywords is to list them vertically above a single symbolic evaluation operator. Listing keywords vertically above a single symbolic evaluation operator is known as stacking.
The above result is not the series approximation of ex at x=2. It is, however, the way to evaluate the series approximation of ex created for x=0 (default) at the evaluation point x=2.
The above expression is equivalent to specifying the creation point of x=0 after the keyword series:
The returned numerical value is a poor approximation, as shown below for e2:
The best approximation is found when the series creation point equals the evaluation point:
The farther the evaluation point from the creation point, the poorer the approximation.
Using Multiple Operators
Stacking keywords above a single symbolic evaluation operator is a visual aid that has no influence on the evaluation results and is equivalent to writing them on a single line.
However, there is a difference between writing keywords over a single symbolic evaluation operator and spreading them over multiple operators. Therefore, if you want the second keyword to control the behavior of the first keyword, you should write them above a single operator.
Evaluate this expression by stacking the keywords over a single symbolic evaluation operator.
In this example, the second keyword assume controls the behavior of the first keyword solve by requiring the variable x to be real.
Evaluate the same expression by listing the keywords in-line over a single symbolic evaluation operator.
Stacking or listing keywords above a single symbolic evaluation operator yields the same results.
Evaluate the same expression by listing each keyword over a sequence of two operators.
In this example, the second keyword assume has no control over the behavior of the first keyword solve, and consequently the evaluation returns a different result.
Additional Information
Stacking keywords over a single symbolic evaluation operator is equivalent to listing them on the same line — providing that you stack or list them in the same order. Changing the order has the potential of returning different results.
Listing or stacking keywords over a single symbolic evaluation operator has the potential of returning different results than if you spread the keywords over multiple symbolic evaluation operators — even if you used the same order. In part, that’s because some modifiers implicitly work over the entire expression, and the chain creates a break in that expression.