Symbolics > Working with Symbolics > Using the decomp Keyword
Using the decomp Keyword
The keyword decomp is useful when you have very long symbolic results. Using this keyword, you can simplify the display of long results in a structured way. The keyword decomp decomposes the expression into parts, replacing elements like coefficients, powers, or repeated terms with generated variables.
The following expression, due to its length, can be difficult to analyze.
Click to copy this expression
Use the keyword decomp to decompose such expression and gain a better understanding of the result structure.
Click to copy this expression
In some cases, the result expression is too long to display. PTC Mathcad Prime calculates the expression; however, because it is too long to display,it is impossible to analyze it.
Click to copy this expression
Using the keyword decomp reduces the result to a length that allows PTC Mathcad Prime to display it, replacing expressions from the results with generated variables. After using decomp the structure of the expression is visible.
Click to copy this expression
Using Modifiers with decomp
The keyword decomp works with the following modifiers:
coeff — Replaces all numeric coefficients in the expression with generated variables during the decomposition.
power — Replaces all numeric powers in the expression with generated variables during the decomposition.
func — Identifies and replaces repeated expressions in the decomposition with generated variables.
parts — Displays only the generated variables and their definitions after the decomposition.
expr — Displays only the rewritten expression using the generated variables after the decomposition.
max — Performs additional steps for greater simplification or refinement.
Using decomp with the Modifiers parts and expr
To work with repeated expressions, use the modifier parts. Assign the result to a variable called substs, so you can use it later in this example.
Click to copy this expression
To work with the result expression, use the modifier expr and use the keyword assume to extract the condition that you are interested in. You can also return to the original terms by using the keyword substitute.
Click to copy this expression
You can also use the keyword substitute if you want to avoid specific substitutions. For example, to avoid the following two generated variables:
Click to copy this expression
Click to copy this expression
Use the keyword substitute.
Click to copy this expression
Using decomp with the modifiers coeff and power
Use the coeff and power modifier to customize the substitutions of numeric coefficients and powers. You can insert a number after the modifiers coeff and power indicating the number of digits on which the substitution will be performed. The default is 3.
Click to copy this expression
Click to copy this expression
Change the name of the generated variables by specifying a new name.
Click to copy this expression
Click to copy this expression
Using decomp with the func modifier
Use the func modifier to identify and replace repeated expressions in the decomposition. The name of the generated variables can be changed to a new one as shown below:
Click to copy this expression
Using decomp with the max modifier
Use the max modifier with the decomp keyword to further simplify the expression. This will replace expressions that are already assigned to a generated variable with other generated variables. The result expression is not affected by this modifier.
Click to copy this expression
Click to copy this expression
Was this helpful?