Turning arguments into exponentsWhat is -(-2,3,4)?Replace rule also matching complex numbersCollecting terms of even exponentsApplying functions repeatedly on parts of complicated expressionsSplitBy with exponentsTurning table into association for ClassifyCollect with symbolic exponentscoordinate change in a list of pointsTurning a NB into a Repeatable Script?How to Append Sequence of Numbers to List?Expression replacement with variable exponents
Get ids only where one id is null and other isn't
Comparing two limsup's
Can I play a first turn Simic Growth Chamber to have 3 mana available in the second turn?
Rhombuses, kites etc
Single word for "refusing to move to next activity unless present one is completed."
Can I call 112 to check a police officer's identity in the Czech Republic?
Why would guns not work in the dungeon?
What is this welding tool I found in my attic?
How do you create draggable points inside a graphic image?
I wrote two alternate fugue expositions for one subject do both follow good harmonic conventions?
How might the United Kingdom become a republic?
How to disable wifi in Raspberry Pi 4
Why do players in the past play much longer tournaments than today's top players?
What's the minimum number of sensors for a hobby GPS waypoint-following UAV?
Keep milk (or milk alternative) for a day without a fridge
How does a Potion of Poison work?
Why didn't Thanos kill all the Dwarves on Nidavellir?
<schwitz>, <zwinker> etc. Does German always use 2nd Person Singular Imperative verbs for emoticons? If so, why?
Cubic programming and beyond?
Why do Americans say "less than five people"?
What does "it kind of works out" mean?
Leave PhD after one year or finish it to the end?
Matchmaker, Matchmaker, make me a match
SOLVED - GFCI - should my neutral and ground have continuity?
Turning arguments into exponents
What is -(-2,3,4)?Replace rule also matching complex numbersCollecting terms of even exponentsApplying functions repeatedly on parts of complicated expressionsSplitBy with exponentsTurning table into association for ClassifyCollect with symbolic exponentscoordinate change in a list of pointsTurning a NB into a Repeatable Script?How to Append Sequence of Numbers to List?Expression replacement with variable exponents
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
I'd like to replace every instance of L[stuff],
e.g.,
L[-1,-2,-2]
in an expression with x^(-FromDigits[stuff])
, e.g.
x^122
.
But I'm running into an issue-- I'd like to do this with the code
L[-1, -2, -2] /. L[a___] -> x^(FromDigits[-a])
but this produces
2/x^6 + x^4 + x^5.
In trouble-shooting, I noticed that while
L[-1, -2, -2] /. L[a___] -> a
produces the output I expected, namely -1,-2,-2
, I found that
L[-1, -2, -2] /. L[a___] -> -a
just produces 4
rather than 1,2,2
. I must be misunderstanding how Sequence behaves when it shows up in the right side of a Rule since when I try just inputting -Sequence[-1,-2,-2]
I get the expected result 1,2,2
. Does anyone see where I'm going wrong? Thanks!
list-manipulation replacement symbolic polynomials sequence
$endgroup$
add a comment |
$begingroup$
I'd like to replace every instance of L[stuff],
e.g.,
L[-1,-2,-2]
in an expression with x^(-FromDigits[stuff])
, e.g.
x^122
.
But I'm running into an issue-- I'd like to do this with the code
L[-1, -2, -2] /. L[a___] -> x^(FromDigits[-a])
but this produces
2/x^6 + x^4 + x^5.
In trouble-shooting, I noticed that while
L[-1, -2, -2] /. L[a___] -> a
produces the output I expected, namely -1,-2,-2
, I found that
L[-1, -2, -2] /. L[a___] -> -a
just produces 4
rather than 1,2,2
. I must be misunderstanding how Sequence behaves when it shows up in the right side of a Rule since when I try just inputting -Sequence[-1,-2,-2]
I get the expected result 1,2,2
. Does anyone see where I'm going wrong? Thanks!
list-manipulation replacement symbolic polynomials sequence
$endgroup$
2
$begingroup$
funny, I asked a very similar question last week, I wonder if its the same issue. Anyway, here is a possible workaround:L[-1, -2, -2] /. L[a___] :> x^(FromDigits[-a])
.
$endgroup$
– AccidentalFourierTransform
8 hours ago
$begingroup$
@AccidentalFourierTransform yup it would appear to be exactly the same issue and my reaction toFullForm[-b]
was exactly the same as yours lol
$endgroup$
– Diffycue
8 hours ago
add a comment |
$begingroup$
I'd like to replace every instance of L[stuff],
e.g.,
L[-1,-2,-2]
in an expression with x^(-FromDigits[stuff])
, e.g.
x^122
.
But I'm running into an issue-- I'd like to do this with the code
L[-1, -2, -2] /. L[a___] -> x^(FromDigits[-a])
but this produces
2/x^6 + x^4 + x^5.
In trouble-shooting, I noticed that while
L[-1, -2, -2] /. L[a___] -> a
produces the output I expected, namely -1,-2,-2
, I found that
L[-1, -2, -2] /. L[a___] -> -a
just produces 4
rather than 1,2,2
. I must be misunderstanding how Sequence behaves when it shows up in the right side of a Rule since when I try just inputting -Sequence[-1,-2,-2]
I get the expected result 1,2,2
. Does anyone see where I'm going wrong? Thanks!
list-manipulation replacement symbolic polynomials sequence
$endgroup$
I'd like to replace every instance of L[stuff],
e.g.,
L[-1,-2,-2]
in an expression with x^(-FromDigits[stuff])
, e.g.
x^122
.
But I'm running into an issue-- I'd like to do this with the code
L[-1, -2, -2] /. L[a___] -> x^(FromDigits[-a])
but this produces
2/x^6 + x^4 + x^5.
In trouble-shooting, I noticed that while
L[-1, -2, -2] /. L[a___] -> a
produces the output I expected, namely -1,-2,-2
, I found that
L[-1, -2, -2] /. L[a___] -> -a
just produces 4
rather than 1,2,2
. I must be misunderstanding how Sequence behaves when it shows up in the right side of a Rule since when I try just inputting -Sequence[-1,-2,-2]
I get the expected result 1,2,2
. Does anyone see where I'm going wrong? Thanks!
list-manipulation replacement symbolic polynomials sequence
list-manipulation replacement symbolic polynomials sequence
asked 8 hours ago
DiffycueDiffycue
2521 silver badge6 bronze badges
2521 silver badge6 bronze badges
2
$begingroup$
funny, I asked a very similar question last week, I wonder if its the same issue. Anyway, here is a possible workaround:L[-1, -2, -2] /. L[a___] :> x^(FromDigits[-a])
.
$endgroup$
– AccidentalFourierTransform
8 hours ago
$begingroup$
@AccidentalFourierTransform yup it would appear to be exactly the same issue and my reaction toFullForm[-b]
was exactly the same as yours lol
$endgroup$
– Diffycue
8 hours ago
add a comment |
2
$begingroup$
funny, I asked a very similar question last week, I wonder if its the same issue. Anyway, here is a possible workaround:L[-1, -2, -2] /. L[a___] :> x^(FromDigits[-a])
.
$endgroup$
– AccidentalFourierTransform
8 hours ago
$begingroup$
@AccidentalFourierTransform yup it would appear to be exactly the same issue and my reaction toFullForm[-b]
was exactly the same as yours lol
$endgroup$
– Diffycue
8 hours ago
2
2
$begingroup$
funny, I asked a very similar question last week, I wonder if its the same issue. Anyway, here is a possible workaround:
L[-1, -2, -2] /. L[a___] :> x^(FromDigits[-a])
.$endgroup$
– AccidentalFourierTransform
8 hours ago
$begingroup$
funny, I asked a very similar question last week, I wonder if its the same issue. Anyway, here is a possible workaround:
L[-1, -2, -2] /. L[a___] :> x^(FromDigits[-a])
.$endgroup$
– AccidentalFourierTransform
8 hours ago
$begingroup$
@AccidentalFourierTransform yup it would appear to be exactly the same issue and my reaction to
FullForm[-b]
was exactly the same as yours lol$endgroup$
– Diffycue
8 hours ago
$begingroup$
@AccidentalFourierTransform yup it would appear to be exactly the same issue and my reaction to
FullForm[-b]
was exactly the same as yours lol$endgroup$
– Diffycue
8 hours ago
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
Here's an explanation of why you get 4
. As mentioned above, your problem is the use of Rule
instead of RuleDelayed
, which means the RHS of the rule evaluates before the rule is used. So, let's see what the RHS of the rule evaluates to:
-a //FullForm
List[Times[-1,a]]
So, when evaluated, the rule becomes:
L[a___] -> Times[-1, a]
Now, it should be clear what happens. When the rule is applied, a
gets bound to the sequence -1, -2, -2
, and so the output (before evaluation) is:
Times[-1, -1, -2, -2]
which evaluates to:
4
$endgroup$
add a comment |
$begingroup$
It's just a matter of using RuleDelayed
, or rather :>
instead of ->
.
L[-1, -2, -2] /. L[a___] :> x^(FromDigits[-a])
x^122
L[-1, -2, -2] /. L[a___] :> -a
1, 2, 2
$endgroup$
add a comment |
Your Answer
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%2f201948%2fturning-arguments-into-exponents%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Here's an explanation of why you get 4
. As mentioned above, your problem is the use of Rule
instead of RuleDelayed
, which means the RHS of the rule evaluates before the rule is used. So, let's see what the RHS of the rule evaluates to:
-a //FullForm
List[Times[-1,a]]
So, when evaluated, the rule becomes:
L[a___] -> Times[-1, a]
Now, it should be clear what happens. When the rule is applied, a
gets bound to the sequence -1, -2, -2
, and so the output (before evaluation) is:
Times[-1, -1, -2, -2]
which evaluates to:
4
$endgroup$
add a comment |
$begingroup$
Here's an explanation of why you get 4
. As mentioned above, your problem is the use of Rule
instead of RuleDelayed
, which means the RHS of the rule evaluates before the rule is used. So, let's see what the RHS of the rule evaluates to:
-a //FullForm
List[Times[-1,a]]
So, when evaluated, the rule becomes:
L[a___] -> Times[-1, a]
Now, it should be clear what happens. When the rule is applied, a
gets bound to the sequence -1, -2, -2
, and so the output (before evaluation) is:
Times[-1, -1, -2, -2]
which evaluates to:
4
$endgroup$
add a comment |
$begingroup$
Here's an explanation of why you get 4
. As mentioned above, your problem is the use of Rule
instead of RuleDelayed
, which means the RHS of the rule evaluates before the rule is used. So, let's see what the RHS of the rule evaluates to:
-a //FullForm
List[Times[-1,a]]
So, when evaluated, the rule becomes:
L[a___] -> Times[-1, a]
Now, it should be clear what happens. When the rule is applied, a
gets bound to the sequence -1, -2, -2
, and so the output (before evaluation) is:
Times[-1, -1, -2, -2]
which evaluates to:
4
$endgroup$
Here's an explanation of why you get 4
. As mentioned above, your problem is the use of Rule
instead of RuleDelayed
, which means the RHS of the rule evaluates before the rule is used. So, let's see what the RHS of the rule evaluates to:
-a //FullForm
List[Times[-1,a]]
So, when evaluated, the rule becomes:
L[a___] -> Times[-1, a]
Now, it should be clear what happens. When the rule is applied, a
gets bound to the sequence -1, -2, -2
, and so the output (before evaluation) is:
Times[-1, -1, -2, -2]
which evaluates to:
4
answered 7 hours ago
Carl WollCarl Woll
86.7k3 gold badges114 silver badges221 bronze badges
86.7k3 gold badges114 silver badges221 bronze badges
add a comment |
add a comment |
$begingroup$
It's just a matter of using RuleDelayed
, or rather :>
instead of ->
.
L[-1, -2, -2] /. L[a___] :> x^(FromDigits[-a])
x^122
L[-1, -2, -2] /. L[a___] :> -a
1, 2, 2
$endgroup$
add a comment |
$begingroup$
It's just a matter of using RuleDelayed
, or rather :>
instead of ->
.
L[-1, -2, -2] /. L[a___] :> x^(FromDigits[-a])
x^122
L[-1, -2, -2] /. L[a___] :> -a
1, 2, 2
$endgroup$
add a comment |
$begingroup$
It's just a matter of using RuleDelayed
, or rather :>
instead of ->
.
L[-1, -2, -2] /. L[a___] :> x^(FromDigits[-a])
x^122
L[-1, -2, -2] /. L[a___] :> -a
1, 2, 2
$endgroup$
It's just a matter of using RuleDelayed
, or rather :>
instead of ->
.
L[-1, -2, -2] /. L[a___] :> x^(FromDigits[-a])
x^122
L[-1, -2, -2] /. L[a___] :> -a
1, 2, 2
answered 8 hours ago
That Gravity GuyThat Gravity Guy
2,2311 gold badge6 silver badges15 bronze badges
2,2311 gold badge6 silver badges15 bronze badges
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%2f201948%2fturning-arguments-into-exponents%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
2
$begingroup$
funny, I asked a very similar question last week, I wonder if its the same issue. Anyway, here is a possible workaround:
L[-1, -2, -2] /. L[a___] :> x^(FromDigits[-a])
.$endgroup$
– AccidentalFourierTransform
8 hours ago
$begingroup$
@AccidentalFourierTransform yup it would appear to be exactly the same issue and my reaction to
FullForm[-b]
was exactly the same as yours lol$endgroup$
– Diffycue
8 hours ago