Taking the numerator and the denominatorHow to convert a notebook cell to a string retaining all formatting, colorization of identifiers etc?How to convert an image to a compressed string representation equivalent to one copied to clipboard by `CopyToClipboard[image]`?Decompose Expression into SegmentsReturning all branches of a multiple-valued functionCan Mathematica reliably determine the equality of any two constructible numbers?CoefficientList for exponentials termsHow to represent $f(x) = (y-x)^k log(y-x)$ as a summation of the form $f(x) = sumlimits_j=0^infty cdots$?Solving an equation for x when terms innvolving x are symbolic (non-algebraic) expressionsTurn single fraction into multiple fraction expressionSplit expression into nested list of summands, times and dot products
How to preserve electronics (computers, ipads, phones) for hundreds of years?
Do I have to take mana from my deck or hand when tapping this card?
Not hide and seek
How can I, as DM, avoid the Conga Line of Death occurring when implementing some form of flanking rule?
Why would five hundred and five same as one?
What is this high flying aircraft over Pennsylvania?
What properties make a magic weapon befit a Rogue more than a DEX-based Fighter?
Derivative of an interpolated function
"Marked down as someone wanting to sell shares." What does that mean?
Travelling in US for more than 90 days
Capacitor electron flow
C++ lambda syntax
Pre-Employment Background Check With Consent For Future Checks
How can a new country break out from a developed country without war?
What is the meaning of "You've never met a graph you didn't like?"
What is the period/term used describe Giuseppe Arcimboldo's style of painting?
What is the tangent at a sharp point on a curve?
How would a solely written language work mechanically
Toggle window scroll bar
Reasons for having MCU pin-states default to pull-up/down out of reset
Should a narrator ever describe things based on a character's view instead of facts?
Offset in split text content
Friend wants my recommendation but I don't want to give it to him
Air travel with refrigerated insulin
Taking the numerator and the denominator
How to convert a notebook cell to a string retaining all formatting, colorization of identifiers etc?How to convert an image to a compressed string representation equivalent to one copied to clipboard by `CopyToClipboard[image]`?Decompose Expression into SegmentsReturning all branches of a multiple-valued functionCan Mathematica reliably determine the equality of any two constructible numbers?CoefficientList for exponentials termsHow to represent $f(x) = (y-x)^k log(y-x)$ as a summation of the form $f(x) = sumlimits_j=0^infty cdots$?Solving an equation for x when terms innvolving x are symbolic (non-algebraic) expressionsTurn single fraction into multiple fraction expressionSplit expression into nested list of summands, times and dot products
$begingroup$
Is there any way to get the Numerator and the Denominator of an expression split in the same way that Mathematica graphically represents it.
Say I have an expression:
(a^(p1 + p2 - p3) b^(p1 - p2 + p3))/(c d)
When plugged into mathematica it gets represented with the $c$ and $d$ in the denominator but if I were to try to extract the numerator and denominator with respectively Numerator and Denominator I would not get the same split. I understand that a different (probably more sensible) choice of representation is made in Numerator and Denominator. However, is it possible to (automatically and reliably) take the denominator and numerator parts as split in the graphical representation? Mathematica must be able to determine this split since it has to decide how to graphically represent the output.
expression-manipulation
$endgroup$
add a comment |
$begingroup$
Is there any way to get the Numerator and the Denominator of an expression split in the same way that Mathematica graphically represents it.
Say I have an expression:
(a^(p1 + p2 - p3) b^(p1 - p2 + p3))/(c d)
When plugged into mathematica it gets represented with the $c$ and $d$ in the denominator but if I were to try to extract the numerator and denominator with respectively Numerator and Denominator I would not get the same split. I understand that a different (probably more sensible) choice of representation is made in Numerator and Denominator. However, is it possible to (automatically and reliably) take the denominator and numerator parts as split in the graphical representation? Mathematica must be able to determine this split since it has to decide how to graphically represent the output.
expression-manipulation
$endgroup$
add a comment |
$begingroup$
Is there any way to get the Numerator and the Denominator of an expression split in the same way that Mathematica graphically represents it.
Say I have an expression:
(a^(p1 + p2 - p3) b^(p1 - p2 + p3))/(c d)
When plugged into mathematica it gets represented with the $c$ and $d$ in the denominator but if I were to try to extract the numerator and denominator with respectively Numerator and Denominator I would not get the same split. I understand that a different (probably more sensible) choice of representation is made in Numerator and Denominator. However, is it possible to (automatically and reliably) take the denominator and numerator parts as split in the graphical representation? Mathematica must be able to determine this split since it has to decide how to graphically represent the output.
expression-manipulation
$endgroup$
Is there any way to get the Numerator and the Denominator of an expression split in the same way that Mathematica graphically represents it.
Say I have an expression:
(a^(p1 + p2 - p3) b^(p1 - p2 + p3))/(c d)
When plugged into mathematica it gets represented with the $c$ and $d$ in the denominator but if I were to try to extract the numerator and denominator with respectively Numerator and Denominator I would not get the same split. I understand that a different (probably more sensible) choice of representation is made in Numerator and Denominator. However, is it possible to (automatically and reliably) take the denominator and numerator parts as split in the graphical representation? Mathematica must be able to determine this split since it has to decide how to graphically represent the output.
expression-manipulation
expression-manipulation
asked 8 hours ago
KvotheKvothe
906317
906317
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
$begingroup$
The problem is that the negative terms in the exponent are being included in the denominator. A way to workaround this is to inactivate Plus, use Numerator and Denominator, and reactivate:
expr = (a^(p1+p2-p3) b^(p1-p2+p3))/(c d);
Activate @* Through @* Numerator, Denominator @* ReplaceAll[Plus->Inactive[Plus]] @ expr
a^(p1 + p2 - p3) b^(p1 - p2 + p3), c d
$endgroup$
add a comment |
$begingroup$
So, for your particular expression (which is a single fraction), the following kluge works:
expr = (a^(p1 + p2 - p3) b^(p1 - p2 + p3))/(c d);
ToExpression /@ List @@ ToBoxes@expr
(* a^(p1 + p2 - p3) b^(p1 - p2 + p3), c d *)
This is a little tricky to automat, because you have to inspect the formatting expression that you get.
This uses the visual formatting in the following way. ToBoxes converts the output to front-end formatting:
ToBoxes@expr
(* FractionBox[
RowBox[SuperscriptBox["a", RowBox["p1", "+", "p2", "-", "p3"]], " ", SuperscriptBox["b", RowBox["p1", "-", "p2", "+", "p3"]]],
RowBox["c", " ", "d"]
] *)
Then, noting that the numerator and the denominator are the first and second elements of the the FractionBox expression, we replace FractionBox with List using List@@, and then convert the remaining formatting expression to Mathematica input expressions using ToExpression.
$endgroup$
add a comment |
$begingroup$
Here is another option using TeXForm.
expr = (a^(p1 + p2 - p3) b^(p1 - p2 + p3))/(c d);
t = ToString[TeXForm[expr]]
(* fraca^textp1+textp2-textp3 b^textp1-textp2+textp3c d *)
Numerator:
ToExpression[StringCases[t, RegularExpression["frac(.+)(.+)$"] -> "$1"][[1]], TeXForm]
(* a^(p1 + p2 - p3) b^(p1 - p2 + p3) *)
Denominator:
ToExpression[StringCases[t, RegularExpression["frac(.+)(.+)$"] -> "$2"][[1]], TeXForm]
(* cd *)
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f193569%2ftaking-the-numerator-and-the-denominator%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
The problem is that the negative terms in the exponent are being included in the denominator. A way to workaround this is to inactivate Plus, use Numerator and Denominator, and reactivate:
expr = (a^(p1+p2-p3) b^(p1-p2+p3))/(c d);
Activate @* Through @* Numerator, Denominator @* ReplaceAll[Plus->Inactive[Plus]] @ expr
a^(p1 + p2 - p3) b^(p1 - p2 + p3), c d
$endgroup$
add a comment |
$begingroup$
The problem is that the negative terms in the exponent are being included in the denominator. A way to workaround this is to inactivate Plus, use Numerator and Denominator, and reactivate:
expr = (a^(p1+p2-p3) b^(p1-p2+p3))/(c d);
Activate @* Through @* Numerator, Denominator @* ReplaceAll[Plus->Inactive[Plus]] @ expr
a^(p1 + p2 - p3) b^(p1 - p2 + p3), c d
$endgroup$
add a comment |
$begingroup$
The problem is that the negative terms in the exponent are being included in the denominator. A way to workaround this is to inactivate Plus, use Numerator and Denominator, and reactivate:
expr = (a^(p1+p2-p3) b^(p1-p2+p3))/(c d);
Activate @* Through @* Numerator, Denominator @* ReplaceAll[Plus->Inactive[Plus]] @ expr
a^(p1 + p2 - p3) b^(p1 - p2 + p3), c d
$endgroup$
The problem is that the negative terms in the exponent are being included in the denominator. A way to workaround this is to inactivate Plus, use Numerator and Denominator, and reactivate:
expr = (a^(p1+p2-p3) b^(p1-p2+p3))/(c d);
Activate @* Through @* Numerator, Denominator @* ReplaceAll[Plus->Inactive[Plus]] @ expr
a^(p1 + p2 - p3) b^(p1 - p2 + p3), c d
answered 7 hours ago
Carl WollCarl Woll
70.8k394184
70.8k394184
add a comment |
add a comment |
$begingroup$
So, for your particular expression (which is a single fraction), the following kluge works:
expr = (a^(p1 + p2 - p3) b^(p1 - p2 + p3))/(c d);
ToExpression /@ List @@ ToBoxes@expr
(* a^(p1 + p2 - p3) b^(p1 - p2 + p3), c d *)
This is a little tricky to automat, because you have to inspect the formatting expression that you get.
This uses the visual formatting in the following way. ToBoxes converts the output to front-end formatting:
ToBoxes@expr
(* FractionBox[
RowBox[SuperscriptBox["a", RowBox["p1", "+", "p2", "-", "p3"]], " ", SuperscriptBox["b", RowBox["p1", "-", "p2", "+", "p3"]]],
RowBox["c", " ", "d"]
] *)
Then, noting that the numerator and the denominator are the first and second elements of the the FractionBox expression, we replace FractionBox with List using List@@, and then convert the remaining formatting expression to Mathematica input expressions using ToExpression.
$endgroup$
add a comment |
$begingroup$
So, for your particular expression (which is a single fraction), the following kluge works:
expr = (a^(p1 + p2 - p3) b^(p1 - p2 + p3))/(c d);
ToExpression /@ List @@ ToBoxes@expr
(* a^(p1 + p2 - p3) b^(p1 - p2 + p3), c d *)
This is a little tricky to automat, because you have to inspect the formatting expression that you get.
This uses the visual formatting in the following way. ToBoxes converts the output to front-end formatting:
ToBoxes@expr
(* FractionBox[
RowBox[SuperscriptBox["a", RowBox["p1", "+", "p2", "-", "p3"]], " ", SuperscriptBox["b", RowBox["p1", "-", "p2", "+", "p3"]]],
RowBox["c", " ", "d"]
] *)
Then, noting that the numerator and the denominator are the first and second elements of the the FractionBox expression, we replace FractionBox with List using List@@, and then convert the remaining formatting expression to Mathematica input expressions using ToExpression.
$endgroup$
add a comment |
$begingroup$
So, for your particular expression (which is a single fraction), the following kluge works:
expr = (a^(p1 + p2 - p3) b^(p1 - p2 + p3))/(c d);
ToExpression /@ List @@ ToBoxes@expr
(* a^(p1 + p2 - p3) b^(p1 - p2 + p3), c d *)
This is a little tricky to automat, because you have to inspect the formatting expression that you get.
This uses the visual formatting in the following way. ToBoxes converts the output to front-end formatting:
ToBoxes@expr
(* FractionBox[
RowBox[SuperscriptBox["a", RowBox["p1", "+", "p2", "-", "p3"]], " ", SuperscriptBox["b", RowBox["p1", "-", "p2", "+", "p3"]]],
RowBox["c", " ", "d"]
] *)
Then, noting that the numerator and the denominator are the first and second elements of the the FractionBox expression, we replace FractionBox with List using List@@, and then convert the remaining formatting expression to Mathematica input expressions using ToExpression.
$endgroup$
So, for your particular expression (which is a single fraction), the following kluge works:
expr = (a^(p1 + p2 - p3) b^(p1 - p2 + p3))/(c d);
ToExpression /@ List @@ ToBoxes@expr
(* a^(p1 + p2 - p3) b^(p1 - p2 + p3), c d *)
This is a little tricky to automat, because you have to inspect the formatting expression that you get.
This uses the visual formatting in the following way. ToBoxes converts the output to front-end formatting:
ToBoxes@expr
(* FractionBox[
RowBox[SuperscriptBox["a", RowBox["p1", "+", "p2", "-", "p3"]], " ", SuperscriptBox["b", RowBox["p1", "-", "p2", "+", "p3"]]],
RowBox["c", " ", "d"]
] *)
Then, noting that the numerator and the denominator are the first and second elements of the the FractionBox expression, we replace FractionBox with List using List@@, and then convert the remaining formatting expression to Mathematica input expressions using ToExpression.
answered 7 hours ago
marchmarch
17.4k22769
17.4k22769
add a comment |
add a comment |
$begingroup$
Here is another option using TeXForm.
expr = (a^(p1 + p2 - p3) b^(p1 - p2 + p3))/(c d);
t = ToString[TeXForm[expr]]
(* fraca^textp1+textp2-textp3 b^textp1-textp2+textp3c d *)
Numerator:
ToExpression[StringCases[t, RegularExpression["frac(.+)(.+)$"] -> "$1"][[1]], TeXForm]
(* a^(p1 + p2 - p3) b^(p1 - p2 + p3) *)
Denominator:
ToExpression[StringCases[t, RegularExpression["frac(.+)(.+)$"] -> "$2"][[1]], TeXForm]
(* cd *)
$endgroup$
add a comment |
$begingroup$
Here is another option using TeXForm.
expr = (a^(p1 + p2 - p3) b^(p1 - p2 + p3))/(c d);
t = ToString[TeXForm[expr]]
(* fraca^textp1+textp2-textp3 b^textp1-textp2+textp3c d *)
Numerator:
ToExpression[StringCases[t, RegularExpression["frac(.+)(.+)$"] -> "$1"][[1]], TeXForm]
(* a^(p1 + p2 - p3) b^(p1 - p2 + p3) *)
Denominator:
ToExpression[StringCases[t, RegularExpression["frac(.+)(.+)$"] -> "$2"][[1]], TeXForm]
(* cd *)
$endgroup$
add a comment |
$begingroup$
Here is another option using TeXForm.
expr = (a^(p1 + p2 - p3) b^(p1 - p2 + p3))/(c d);
t = ToString[TeXForm[expr]]
(* fraca^textp1+textp2-textp3 b^textp1-textp2+textp3c d *)
Numerator:
ToExpression[StringCases[t, RegularExpression["frac(.+)(.+)$"] -> "$1"][[1]], TeXForm]
(* a^(p1 + p2 - p3) b^(p1 - p2 + p3) *)
Denominator:
ToExpression[StringCases[t, RegularExpression["frac(.+)(.+)$"] -> "$2"][[1]], TeXForm]
(* cd *)
$endgroup$
Here is another option using TeXForm.
expr = (a^(p1 + p2 - p3) b^(p1 - p2 + p3))/(c d);
t = ToString[TeXForm[expr]]
(* fraca^textp1+textp2-textp3 b^textp1-textp2+textp3c d *)
Numerator:
ToExpression[StringCases[t, RegularExpression["frac(.+)(.+)$"] -> "$1"][[1]], TeXForm]
(* a^(p1 + p2 - p3) b^(p1 - p2 + p3) *)
Denominator:
ToExpression[StringCases[t, RegularExpression["frac(.+)(.+)$"] -> "$2"][[1]], TeXForm]
(* cd *)
answered 34 mins ago
MelaGoMelaGo
1763
1763
add a comment |
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f193569%2ftaking-the-numerator-and-the-denominator%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown