Tag Info

Hot answers tagged

5

Use the Variables command: Variables[a x^2 + b x + c] (* {a,b,c,x} *) You can easily remove the x. Alternatively: CoefficientList[a x^2 + b x + c, x] (* {a, b, c} *)


3

A quite general approach is to use Cases. Cases[a^3 + b^2 + c, z_Symbol :> z, {0, Infinity}] (* {a, b, c} *) or Cases[Cos[a] b^c Gamma[d]/e, z_Symbol :> z, {0, Infinity}] (* {b, c, e, a, d} *)


2

My way for this is: eq = (x - a)^2 + (y - b)^2 + (z - c)^2 + d; eq == 0 /. Solve[ForAll[{x, y, z}, -11 - 2 x + x^2 - 4 y + y^2 - 6 z + z^2 == eq]] // TraditionalForm (* {(x-1)^2+(y-2)^2+(z-3)^2-25} *)


2

Perhaps the closest thing to what you want is to use HoldForm to prevent the sorting behavior of Times due to Orderless: str = "one Test String to see"; HoldForm @@ MakeExpression @ str one Test String to see However it is important to realize that the HoldForm head is still present, only that it is not shown in standard formatted output. Also know ...


2

Ditto what Kuba said about details. Another guess: expr /. Thread[Variables[expr] -> 1] (* 6 *) I guess it works for polynomials. It's not really clear to me what the coefficients of Exp[x] are. (It might be 1 Exp[1 x], etc.) Or (x + y)^2 vs. x^2 + 2 x y + y^2. (This answer gives the sum of the coefficients of the latter.) Another ...


1

It is quite possible that details matter. Without those, we can only guess what could be useful: Cases[expr, x_. y___ :> x, {1}] (*{1} is redundant, just wanted to stress it out *) % // Total {1, 2, 3} 6


1

expr = (a + b)/r 1/Denominator[expr]


1

I think you are looking for Replace: p4 - p5 == r45 i45 /. r45 -> 1 (* p4 - p5 == i45 *) % /. lhs_ == rhs__ -> rhs - lhs == 0 (* i45 + p5 - p4 == 0 *)



Only top voted, non community-wiki answers of a minimum length are eligible