Replacement rule to display negative exponents as denominators
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
Suppose I have an expression of the form:
expr=f[t]^b + f[t]^a g[t]^-a + g[t]^-c
And I want to create a rule to convert negative exponents to denominators. In the above example, this could be achieved manually as follows:
expr /. f[t]^a* g[t]^-a -> (f[t]/g[t])^a
$left(fracf(t)g(t)right)^a+f(t)^b+g(t)^-c$
How would I achieve this with a general pattern match, independent of the identities of the bases and the exponents? In pseudocode, it would look something like this:
expr /. [some expression]^x*[some other expression]^-x ->
(some expression/some other expression)^x
I've made several attempts, without success.
Thus far, the only question I've been able to find on the subject is this, but the OP didn't specifically request a simple pattern-match replacement rule. Perhaps as a consequence, the answer is much more complicated than I'd like:
Display negative exponents always as fraction
Here's a related question, which seeks to do the opposite:
How is it possible to prevent separation of negative and positive exponents when symbolic simplifying?
pattern-matching output-formatting replacement formatting
add a comment |Â
up vote
3
down vote
favorite
Suppose I have an expression of the form:
expr=f[t]^b + f[t]^a g[t]^-a + g[t]^-c
And I want to create a rule to convert negative exponents to denominators. In the above example, this could be achieved manually as follows:
expr /. f[t]^a* g[t]^-a -> (f[t]/g[t])^a
$left(fracf(t)g(t)right)^a+f(t)^b+g(t)^-c$
How would I achieve this with a general pattern match, independent of the identities of the bases and the exponents? In pseudocode, it would look something like this:
expr /. [some expression]^x*[some other expression]^-x ->
(some expression/some other expression)^x
I've made several attempts, without success.
Thus far, the only question I've been able to find on the subject is this, but the OP didn't specifically request a simple pattern-match replacement rule. Perhaps as a consequence, the answer is much more complicated than I'd like:
Display negative exponents always as fraction
Here's a related question, which seeks to do the opposite:
How is it possible to prevent separation of negative and positive exponents when symbolic simplifying?
pattern-matching output-formatting replacement formatting
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
Suppose I have an expression of the form:
expr=f[t]^b + f[t]^a g[t]^-a + g[t]^-c
And I want to create a rule to convert negative exponents to denominators. In the above example, this could be achieved manually as follows:
expr /. f[t]^a* g[t]^-a -> (f[t]/g[t])^a
$left(fracf(t)g(t)right)^a+f(t)^b+g(t)^-c$
How would I achieve this with a general pattern match, independent of the identities of the bases and the exponents? In pseudocode, it would look something like this:
expr /. [some expression]^x*[some other expression]^-x ->
(some expression/some other expression)^x
I've made several attempts, without success.
Thus far, the only question I've been able to find on the subject is this, but the OP didn't specifically request a simple pattern-match replacement rule. Perhaps as a consequence, the answer is much more complicated than I'd like:
Display negative exponents always as fraction
Here's a related question, which seeks to do the opposite:
How is it possible to prevent separation of negative and positive exponents when symbolic simplifying?
pattern-matching output-formatting replacement formatting
Suppose I have an expression of the form:
expr=f[t]^b + f[t]^a g[t]^-a + g[t]^-c
And I want to create a rule to convert negative exponents to denominators. In the above example, this could be achieved manually as follows:
expr /. f[t]^a* g[t]^-a -> (f[t]/g[t])^a
$left(fracf(t)g(t)right)^a+f(t)^b+g(t)^-c$
How would I achieve this with a general pattern match, independent of the identities of the bases and the exponents? In pseudocode, it would look something like this:
expr /. [some expression]^x*[some other expression]^-x ->
(some expression/some other expression)^x
I've made several attempts, without success.
Thus far, the only question I've been able to find on the subject is this, but the OP didn't specifically request a simple pattern-match replacement rule. Perhaps as a consequence, the answer is much more complicated than I'd like:
Display negative exponents always as fraction
Here's a related question, which seeks to do the opposite:
How is it possible to prevent separation of negative and positive exponents when symbolic simplifying?
pattern-matching output-formatting replacement formatting
edited Aug 18 at 11:52
kglr
157k8181378
157k8181378
asked Aug 18 at 0:23
theorist
997319
997319
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
expr /. c_. p_^e_ q_^(-1 e_) :> c (p/q)^e // TeXForm
$left(fracf(t)g(t)right)^a+f(t)^b+g(t)^-c$
Yup, that's itâÂÂthanks! Since your first version, w/o thec_.
, worked fine, I assume you added it to make it more canonical. If so, when would the absence of thec_.
cause a failure? I'd be happy to accept the answer but, respecting site conventions, I'll wait the usual couple of days.
â theorist
Aug 18 at 0:45
1
@theorist, addedc_.
to cover cases likeexpr2 = f[t]^b + someCoeff f[t]^a g[t]^-a + g[t]^-c
â kglr
Aug 18 at 0:48
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
expr /. c_. p_^e_ q_^(-1 e_) :> c (p/q)^e // TeXForm
$left(fracf(t)g(t)right)^a+f(t)^b+g(t)^-c$
Yup, that's itâÂÂthanks! Since your first version, w/o thec_.
, worked fine, I assume you added it to make it more canonical. If so, when would the absence of thec_.
cause a failure? I'd be happy to accept the answer but, respecting site conventions, I'll wait the usual couple of days.
â theorist
Aug 18 at 0:45
1
@theorist, addedc_.
to cover cases likeexpr2 = f[t]^b + someCoeff f[t]^a g[t]^-a + g[t]^-c
â kglr
Aug 18 at 0:48
add a comment |Â
up vote
4
down vote
accepted
expr /. c_. p_^e_ q_^(-1 e_) :> c (p/q)^e // TeXForm
$left(fracf(t)g(t)right)^a+f(t)^b+g(t)^-c$
Yup, that's itâÂÂthanks! Since your first version, w/o thec_.
, worked fine, I assume you added it to make it more canonical. If so, when would the absence of thec_.
cause a failure? I'd be happy to accept the answer but, respecting site conventions, I'll wait the usual couple of days.
â theorist
Aug 18 at 0:45
1
@theorist, addedc_.
to cover cases likeexpr2 = f[t]^b + someCoeff f[t]^a g[t]^-a + g[t]^-c
â kglr
Aug 18 at 0:48
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
expr /. c_. p_^e_ q_^(-1 e_) :> c (p/q)^e // TeXForm
$left(fracf(t)g(t)right)^a+f(t)^b+g(t)^-c$
expr /. c_. p_^e_ q_^(-1 e_) :> c (p/q)^e // TeXForm
$left(fracf(t)g(t)right)^a+f(t)^b+g(t)^-c$
answered Aug 18 at 0:37
kglr
157k8181378
157k8181378
Yup, that's itâÂÂthanks! Since your first version, w/o thec_.
, worked fine, I assume you added it to make it more canonical. If so, when would the absence of thec_.
cause a failure? I'd be happy to accept the answer but, respecting site conventions, I'll wait the usual couple of days.
â theorist
Aug 18 at 0:45
1
@theorist, addedc_.
to cover cases likeexpr2 = f[t]^b + someCoeff f[t]^a g[t]^-a + g[t]^-c
â kglr
Aug 18 at 0:48
add a comment |Â
Yup, that's itâÂÂthanks! Since your first version, w/o thec_.
, worked fine, I assume you added it to make it more canonical. If so, when would the absence of thec_.
cause a failure? I'd be happy to accept the answer but, respecting site conventions, I'll wait the usual couple of days.
â theorist
Aug 18 at 0:45
1
@theorist, addedc_.
to cover cases likeexpr2 = f[t]^b + someCoeff f[t]^a g[t]^-a + g[t]^-c
â kglr
Aug 18 at 0:48
Yup, that's itâÂÂthanks! Since your first version, w/o the
c_.
, worked fine, I assume you added it to make it more canonical. If so, when would the absence of the c_.
cause a failure? I'd be happy to accept the answer but, respecting site conventions, I'll wait the usual couple of days.â theorist
Aug 18 at 0:45
Yup, that's itâÂÂthanks! Since your first version, w/o the
c_.
, worked fine, I assume you added it to make it more canonical. If so, when would the absence of the c_.
cause a failure? I'd be happy to accept the answer but, respecting site conventions, I'll wait the usual couple of days.â theorist
Aug 18 at 0:45
1
1
@theorist, added
c_.
to cover cases like expr2 = f[t]^b + someCoeff f[t]^a g[t]^-a + g[t]^-c
â kglr
Aug 18 at 0:48
@theorist, added
c_.
to cover cases like expr2 = f[t]^b + someCoeff f[t]^a g[t]^-a + g[t]^-c
â kglr
Aug 18 at 0:48
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f180193%2freplacement-rule-to-display-negative-exponents-as-denominators%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password