Skip to main content
20 events
when toggle format what by license comment
Jun 27, 2016 at 3:50 comment added march @PetraAxolotl. I'm pretty sure the solution MatchQ[ expression , a_ b_ | a_^2] in my answer does what you want, for any number of variables.
Jun 15, 2016 at 9:37 history tweeted twitter.com/StackMma/status/743014462085603328
Jun 14, 2016 at 5:36 answer added Petra Axolotl timeline score: 1
Jun 14, 2016 at 5:31 comment added Petra Axolotl @ Kuba, yes. But your solution won't eliminate x^2 or y^2.
Jun 14, 2016 at 5:30 comment added Petra Axolotl @ march, yes it does. But suppose I have 20 possible variables instead of just x y z.
Jun 14, 2016 at 5:25 comment added Petra Axolotl What I originally had was as follows. pat = x | y | z | a | b | c; series = 1 + x + 2 y + 3 z + 4 a + 5 b + 6 c + 7 x^2 + 8 y^2 + 9 z^2 + 10 x b + 11 a b c + 12 x y b^5 /. pat pat -> 0 I expected 1 + x + 2 y + 3 z + 4 a + 5 b + 6 c. But it did not work.
Jun 13, 2016 at 20:24 answer added march timeline score: 4
Jun 13, 2016 at 19:50 comment added march @SimonWoods. I wanted to wait to answer until I get the my clarification question answered. The OP is using x and y explicitly in their attempt at a pattern but they want z^2 matched, so I'm not actually sure what they want. In addition, depending on the actual application of this, it might be that using MatchQ just isn't the way to go in the first place. I guess I did answer the original query, though, so perhaps I'll write an answer anyway.
Jun 13, 2016 at 19:33 comment added Kuba @SimonWoods I'm not sure if Verbatim isn't more apropriated, I'm often confused.
Jun 13, 2016 at 19:22 comment added Simon Woods @march, your first comment should be an answer, along with Kuba's solution using HoldPattern.
Jun 13, 2016 at 16:04 answer added Wjx timeline score: 1
Jun 13, 2016 at 9:19 comment added QuantumDot For more info, the reason Kuba 's method works is to avoid the problem @march mentioned.
Jun 13, 2016 at 9:19 comment added QuantumDot For more info, the reason @Kuba 's method works is to avoid the problem march mentioned.
Jun 13, 2016 at 8:22 comment added Kuba Btw: MatchQ[x y, HoldPattern[(x | y) (x | y)]]
Jun 13, 2016 at 4:06 comment added march Does MatchQ[#, _^2 | a_ b_] & /@ {x^2, y^2, z^2, x y, x z, y z} do what you want? Your post needs more information, because there is an inconsistency between the terms you want to eliminate and the patterns you are making. Do you want to eliminate any second-degree monomial? Or do you want to eliminate any second-order monomial that involves x or y? (or x or y and nothing else)?
Jun 13, 2016 at 4:05 history edited march CC BY-SA 3.0
added 16 characters in body
Jun 13, 2016 at 4:04 comment added xzczd What do you mean by "I want to eliminate terms like x^2, y^2, z^2, x y, x z, y z"?
Jun 13, 2016 at 4:04 comment added march I think because (x | y) (x | y) evaluates to (x | y)^2, which doesn't match your expression.
Jun 13, 2016 at 3:56 review First posts
Jun 13, 2016 at 4:37
Jun 13, 2016 at 3:55 history asked Petra Axolotl CC BY-SA 3.0