Hot answers tagged

9

With Frame -> All, the automatic Spacings are weird. The automatic BaselinePosition is bad either way. It seems to be a good idea to include substitutes for as many of those options which are Automatic by default as possible: pic2 = ImageResize[ImageCrop@Rasterize@Graphics@Disk[], {Automatic, 40}]; Grid[{{pic2}}, Alignment -> {Center, Center}, ...


7

From the docs: CenterDot @@ Superscript @@@ FactorInteger[7!] Though CenterDot does not work well for prime powers: CenterDot @@ Superscript @@@ FactorInteger[5] If this is a problem, you could just define your own: myCenterDot[e_] := e myCenterDot[args__] := CenterDot[args] Now it works fine: myCenterDot @@ Superscript @@@ FactorInteger[5] ...


5

Inactive[Power] @@@ FactorInteger[24] /. Inactive[Power][a_, 1] :> a Your fac[24] could be written as Flatten[ConstantArray @@@ FactorInteger[24]] To not show the ^ symbol: Superscript @@@ FactorInteger[24] /. Superscript[a_, 1] :> a


5

Maybe this will fit your needs: myPrint[args__, {style__}] := Print[Row[{args}, BaseStyle -> {style}]] myPrint["Mass of the atmosphere is: ", m, {FontSize -> 18, FontWeight -> Bold, Background -> LightRed}] myPrint["Mass of the atmosphere is: ", m, {"Section"}]


4

{ConjugateTranspose[c],ConjugateTranspose[c]^2} /. ConjugateTranspose[c]->SuperDagger[c] gives:


3

As m_goldberg and Jens could not reproduce the problem on Mathematica 10.3.1 I updated my Mathematica and it turns out that the behavior of Mathematica depends on the version. Graphics[Text[Framed[Foobar, RoundingRadius -> 7]]] yields the following. From left to right: V10.2 Notebook, V10.2 PrintOut, V10.3.1 Notebook, V10.3.1 Printout So the problem ...


3

Perhaps this example could be helpful: pts = RandomReal[1, {10, 2}]; ch = VoronoiMesh[pts]; mp = MeshPrimitives[ch, 2]; ml = MeshPrimitives[ch, 1]; mpt = MeshPrimitives[ch, 0]; Graphics[Riffle[RandomColor[Length@mp], mp]~Join~{Red, Thick, ##} & @@ ml~Join~{Blue, PointSize[0.02], ##} & @@ mpt]


2

define your styles beforehand, style1 = Style[#, 12] &; style2 = Style[#, 24, Blue, Background -> Pink] &; and then just use them quickly and easily, Print["Variable a = ", style1@a]; Print["Variable b = ", style1@b]; Print["The result: a + b = ", style2@c];


1

(Just answering the first question. Others have answered the second question thoroughly.) It's worth mentioning that you can do {x,y} // (f @@ #) & f[x,y] (No parentheses needed, but I added them for clarity.) You could even make your own function to do this (slightly) more compactly, especially if you have trouble remembering the @'s and #'s ...


1

To address the issue use some Off[NumberForm::sigz] in Manipulate[...]. It is also better to use simple Epilog with Text[Row[...] (code below): Some code picture:


1

This is as close as I could get for this expression, but I don't know what other types of expressions you would need to work with. The code is also ugly, so there has got to be something prettier, but here goes: if we set exp = (23991 x^3)/(250000 a^5) + (87271/(5000000 a^6) + 31/(600 a^2) - b/2816) x^4 then exp /. {Rational[x_, y_]*rest_ :> ...


1

Code: DY = {{Cos[ay], 0, Sin[ay]}, {0, 1, 0}, {-Sin[ay], 0, Cos[ay]}}; Output: A potential error: {{Cos[ay], 0, Sin[ay]}, {0, 1, 0}, {-Sin[ay], 0, Cos[ay], 0}}; Look at the sub-list no. 3, you've got additional 0 in there making the lists of un-equal lengths;


1

I like march's idea of automation but I think at the moment his updated code is not working. Perhaps this will serve the purpose: SetAttributes[heldDistribute, HoldFirst] heldDistribute[expr_] := Unevaluated[expr] /. Cases[Unevaluated[expr], x_Symbol :> (HoldPattern[x] :> Defer[x]), {-1}, Heads -> False] // Distribute Now with the ...



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