Tag Info

New answers tagged

2

Update: This matches the evaluated form of your desired output for each example: fn = Collect[#, x^y_ /; FreeQ[y, _Integer], Apart] &; Test: expr1 = c0 x^(a + b) + c1 x^(a + b + 1) + c2 x^(a + b + 2) + c3 x^(a + b + 2) + c4 x^(a + b + 2) + c5 x^(a) + c6 x^(a + 1) + c7 x^(a + 1); target1 = x^(a) (c5 + x (c6 + c7)) + x^(a + b) (c0 + x c1 + x^2 (c2 ...


4

Not that I'm aware of but perhaps this can work for you: x[a] Subscript[q, a] Superscript[m, a] d[a, b] /. y_ d[z_, p_] :> (y /. z -> p) d[z, p]


1

You can also set Part 0 of input list to List: ClearAll[data, a, b, c, d, e, f]; data = a + b c - d e f; data2=data; data2[[0]] = List; data2 (* {a, b c, -d e f} *) data2 = data[[2]]; data2[[0]] = List; data2 (* {b,c} *) or, define a function that Listifies the Heads: ClearAll[lF1]; lF1 = Function[{h}, h[[0]] = List; h, HoldFirst]; data2 = data; ...


1

Cases[a + b c - d e f, _] (*{a, b c, -d e f}*) Level[a + b c - d e f, 1] (*{a, b c, -d e f}*)


9

res1 = data /. Plus -> List {a, b c, -d e f} res1[[2]] /. Times -> List {b, c} As a function: explodeOp[expr_, op_] := expr /. op -> List Then: res1 = explodeOp[data, Plus]; explodeOp[res1[[2]], Times]


4

Try this: List @@ (a + b c - d e ff) Output is {a, b c, -d e ff} Likewise, to explode a product, do this: List @@ %[[2]] Output is {b, c} This works because List @@ deletes the head of (a + b c - d e ff), which is Plus, and replaces it with list, giving List[a, b c, -d e ff] (and similar for product explosion).


1

Another approach is to include a double-angle identity in the transformations tried by Simplify: doubleangle = # /. t_ArcTan :> 1/2 Simplify@ArcTan[TrigExpand@Tan[2 t]] &; Simplify[ Solve[Cos[x] - b Sin[x] == 0 && x > 0 && x < π && b > 0, x], TransformationFunctions -> {doubleangle, Automatic}] (* {{x -> ...


2

Belisarus in his comment gave one solution which can be referred to as a post-processing. Here is the pre-processing as you mentioned: eq = Cos[x] - b Sin[x] == 0; Map[Divide[#, Cos[x]] &, eq] // Expand (* 1 - b Tan[x] == 0 *) In my version 10, however, your equation is perfectly solved by itself yielding Solve[eq,x] (* {{x ...


2

I prefer Mr Wizard's answer, but here is a method using the properties of Power and Times to deal with exponent 1 and single prime factors. Specifically: Power[x, 1] gives x Times[x] gives x The prime factors are wrapped in Defer to prevent any further evaluation. So: primeFactorForm = Times @@ Power @@@ MapAt[Defer, FactorInteger@#, {All, 1}] /. ...


2

One option is to define the formatting of CenterDot for the one argument case: Format[CenterDot[a_]] := Format[a] In[13]:= CenterDot @@ Apply[Superscript, FactorInteger[9], {1}] Out[13]= $3^2$ Note that the FullForm of this output is CenterDot[Subscript[3,2]].


4

The existing answers work but I offer two improvements: terse code via pattern replacement making an actual formatting wrapper This replacement rule strips the heads of any expressions with only one argument: foo[1] /. _[x_] :> x foo[1, 2] /. _[x_] :> x 1 foo[1, 2] Format is used to describe the output format without losing the original ...



Top 50 recent answers are included