Tag Info

New answers tagged

3

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 ...


1

As per wxffles' comment Simplify[Sqrt[x^3] Sqrt[x - a x]/x, x > 0] Sqrt[1 - a] x


4

PaddedForm[Range[-2, -1, 0.2], {3, 2}] Plot[Sin[x], {x, -2, -1}, Frame -> True, Axes -> False, FrameTicks -> {{Automatic, Automatic},{Transpose[{#, Map[PaddedForm[#, {3, 2}] &, #]}] & [Range[-2, -1, 0.2]], Automatic}}]


2

stf[{_, 1}] := StringTemplate["`1`"]; stf[{_, _}] := StringTemplate["\!\(\*SuperscriptBox[\(`1`\), \(`2`\)]\)"]; funcn[u_] := StringJoin[ Riffle[TemplateApply[stf[#], #] & /@ FactorInteger[u], "\[CenterDot]"]] Testing: Grid[Style[#, 20] & /@ ({#, "=", funcn[#]}) & /@ Range[100]]


1

Another almost identical way: primeFactorForm[n_] := If[Length@# == 1, First@#, CenterDot @@ #] &[ Superscript @@@ FactorInteger[n]]; Example output: Column[primeFactorForm /@ RandomInteger[{0, 10000}, 10]]


4

primeFactorForm[n_Integer] := Module[{fact = FactorInteger[n]}, If[Length[fact] == 1, Superscript @@ fact[[1]], CenterDot @@ Superscript @@@ fact]] primeFactorForm[9] primeFactorForm[72]



Top 50 recent answers are included