Connect with users of Wolfram technologies to learn, solve problems and share ideas
Mark as an Answer
1 Total Likes
Follow this post
Share this post:
Substituting exponents in an expression with a constant
10 years ago
Hello! Given an arbitrary algebraic expression in which some of the variables are raised to various integer exponential powers, how could one automatically transform the expression so that all exponents of ANY value are globally replaced with a SINGLE new constant value? For example, if the starting expression is (u^3)(v^4)(w^5) and the desired "global replacement exponent" is 9, then the desired result would be (u^9)(v^9)(w^9). If a particular variable does not have an exponent (i.e. has an implied power of 1) then it is not to be modified, but rather left as is in the original expression. I am new to Mathematica, and I'm not sure if I need to do some kind of string manipulation on the symbolic equation, or if there are Mathematica functions to assist in this transformation. I have seen that there are functions to extract portions of symbolic expressions, but I can not find anything specific that would help with this kind of unusual substitution. Thanks in advance for any help!
Sean Clarke, Wolfram Research
10 years ago
Mathematica has a powerful system for pattern matching and replacement. This is how most operations like this would be described.
Here for example is a pattern that takes any symbol to a numeric power and replaces it with the symbol to the 9th power:
sym_Symbol^pow_?NumericQ -> sym^9
The documentation center has more information about patterns and pattern matching:
Reply to this discussion
in reply to
Community posts can be styled and formatted using the
Tag limit exceeded
Note: Only the first five people you tag will receive an email notification; the other tagged names will appear as links to their profiles.
Add a file to this post
Follow this discussion
Be respectful. Review our
to understand your role and responsibilities.
Wolfram|Alpha Notebook Edition
Volume & Site Licensing
Enterprise Private Cloud
Service Plans Benefits
Wolfram Language Documentation
Wolfram Language Introductory Book
Get Started with Wolfram
Fast Introduction for Programmers
Fast Introduction for Math Students
Webinars & Training
Connected Devices Project
Wolfram Data Drop
Wolfram + Raspberry Pi
. All rights reserved.
Learn how »