Tag Info

Hot answers tagged

7

Add this to your notebook or init file $PrePrint = If[MatrixQ[#], MatrixForm[#], #] &; Then all matrices will automatically display as MatrixForm and If you want to format lists as column vectors also, try $PrePrint = Which[MatrixQ[#], MatrixForm[#], VectorQ[#], ColumnForm[#], True, #] &; Now also


5

Since TreeForm produces a GraphPlot and takes the same options as GraphPlot, it can be done by using a custom vertex rendering function. encoding = {{{w, d}, {o, s}}, {{{e, q}, a}, {i, j}}}; TreeForm[encoding, VertexRenderingFunction -> (If[#2 === List, Inset[Text["\[FilledCircle]"], #], Inset[Framed[Text[Style[#2, 18]], Background ...


5

Mathematica will perform an exact calculation if possible. "E" means exactly e, rather than a numerical approximation i.e. 2.718 (with a few more decimal places). When you calculate f[1/10] it gives the exact value because all of the inputs are exact. If you want a numerical approximation, you can make any of the inputs approximate, or you can use N to ...


3

Let me through a first version into the room: SetAttributes[echo, HoldAll]; echo[x___] := StringRiffle[{##}, ", "] & @@ Function[arg, ToString[Unevaluated[arg], InputForm], {HoldFirst}] /@ Hold[x]; Now you get Print[TemplateApply[">``<", echo[2^2, "foo", 2 + 2, None]]] (* >2^2, "foo", 2 + 2, None< *) Be aware that you might ...


3

Just to add some diversity, although I think m_goldbergs answer is very convenient and should be used in most cases. Nevertheless, always remember that you can easily de-structure Mathematica expressions, even the box-expressions that are used for displaying things in the front end. One possible way to start is to look at the box-expressions of a very ...


3

You could try something like the following: Table[dS[i] = -β[i]*S[i], {i, 4}]; To see the definitions for dS use the function Definition. Definition[dS] (* dS[1]=-S[1] β[1] dS[2]=-S[2] β[2] dS[3]=-S[3] β[3] dS[4]=-S[4] β[4] *) See that you can perform operations on dS. dS[1] + dS[2] (* -S[1] β[1] - S[2] β[2] *)


3

Slightly more handy approach (unless you want to work with negative integers): Grid[ {#, "+", #2, "=", Item["", ItemSize -> 3]} & @@@ RandomInteger[20, {10, 2}] , Alignment -> {{Right, Center, Right, Center, Center}}, BaseStyle -> {Italic, 20}, Frame -> True, Background -> {{}, {{GrayLevel@.9, GrayLevel@.95}}} ] A simplistic ...


3

Rough approach: Tooltip resources are stored in FileNameJoin[{ $InstallationDirectory, "SystemFiles", "FrontEnd", "TextResources", "ToolTip.tr"}] In order to not mess with installation directory you can copy this file to $UserBaseDirectory/SystemFiles... and replace labels you want. For example: @@resource ToolTipCut Cut (replace this line ...


2

You can use UnderBar instead of Style[...,Underlined]: Hyperlink[UnderBar[#], #] &@ "http://www.wolfram.com/Sine.html" Note: The issue you observe is mentioned in the docs Underlined >> Possible Issues: Underlined will recursively affect all elements of an expression


2

The purpose of using HoldForm and Plus is to allow automatic formatting rules for Plus to apply while preventing evaluation. Since you want custom formatting rules that method may be inapplicable. To get alignment we can either use a tabular format like Grid (as Kuba did) or we can pad the numbers themselves. One automatic approach to the latter is ...


2

Since you did not include your data, I am generating some fake data to play with: fakedata = Transpose@ Insert[ Transpose@ Insert[ RandomReal[{0, 1}, {6, 50}], Array["y lbl " <> ToString@# &, 50], 1 ], {""}~Join~Array["x lbl " <> ToString@# &, 6], 1 ]; The code first generates a 6-row by ...


2

As @kattern pointed out, MatrixForm will pretty print your lists to look like matrices. {{0}, {1}, {0}, {-1}} // MatrixForm A word of caution, however: MatrixForm can get in the way of your calculations if you are not careful. See this question and the related answers: Why does MatrixForm affect calculations?. For instance, you could get bitten by ...


1

I know I have answered a very similar question before but I can't find it now. Of what I can find my own question How can I get the unchanged Box form of an arbitrary expression? is probably closest, though more recently Why aren't parentheses ( ) an expression in Mathematica? maybe closer in application to what you need. For pursuing your goal it is ...


1

I'm running V10.1 on OS X 10.10.2 (Yosemite). There may be a problem on OS X. On all versions of OS X prior to Yosemite the system font was Lucida Grande. On Yosemite it is Helvetica Neue. So I tried both. ButtonLabelStyle[x_] := Style[x, 9, FontFamily -> "Helvetica Neue"] Button["//ContractBasis" // ButtonLabelStyle, Null, ImageSize -> 85] ...


1

Using the function SparseArray`ExpressionToTree: ClearAll[trF] trF[s_: {0.01, .05}][e_, opts : OptionsPattern[Options[Graph]]] := Module[{saett = SparseArray`ExpressionToTree[e], edges, vertices, vsizes, labels, vlabels}, edges = saett[[All, All, 2]]; vertices = DeleteDuplicates[Join @@ List @@@ edges]; labels = ArrayPad[Replace[saett[[All, ...


1

Second update (2015-05-11): Amandeep, you recently left a comment with the following expression: xpr = a1*D11*Cos[n*x] + a0*a1*D11*Cos[n*x] + 1/2*a1*a3*D11*Cos[n*x] + 1/2*a2*a4*D11*Cos[n*x] + a2*a3*a4*Sin[n*x] I believe that you may have left out a multiplication sign on the argument of the last Sin function. Once we add that back in, the approach using ...


1

I think you want Row: Subscript[a, Row@{b, b}] abb Consider also Indexed but beware that it is not an inert (formatting) function. Indexed[a, {b, b}] abb


1

list = {"b", "c", "d"}; Subscript[a, list[[1]] <> list[[1]]] // TraditionalForm or list = {b, c, d}; Subscript[a, ToString[list[[1]]] <> ToString[list[[1]]]] // TraditionalForm



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