# Tag Info

## New answers tagged output-formatting

1

For the example problem, you know 1+10^(-n) will have exactly n digits after the decimal, or n+1 digits precision, so you can do: Table[N[1 + 10^(-n), n + 1], {n, 1, 30}] 1.1 , 1.01 , 1.001 , .... 1.000000000000000000000000000001 The example in the comment is something like this: h[t_] = 58 t - 83/100 t^2; Table[With[{t = 1 + 10^(-n) }, N[ ...

3

Here's one possible way of doing this. Type some text into 2 successive text cells, then select the cell brackets, open the option inspector (Format / Option Inspector ...) and alter the values displayed at Cell Options / Display Options / CellMargins. For instance, if the 2 text items are "Hello" and "World", then the resulting Cell expressions might be ...

1

booleanTable := Module[ {var, iter}, f = Input["Enter Boolean function"]; var = BooleanVariables@f; iter = Sequence @@ ({#, {True, False}} & /@ var); Column[{Table[ Evaluate[{var, f} // Flatten], Evaluate[iter]] // Flatten[#, Length[var] - 1] & // Prepend[#, {var, f} // Flatten] & // ...

0

You seem to be trying to use Mathematica as if it were a procedural language such a Java. Sometimes that works, but it's almost always better to take a functional approach in Mathematica, especially when trying to work symbolically. One way to do what you ask is as follows. This approach supplies the boolean expression encapsulated in a pure (i.e., ...

2

You could import each frame of your movie as a separate image, then use ListAnimate on this list to generate an animation on which you would then have full control. I am going to generate a static image and a test movie to play with: staticimage = Rasterize@Plot[Sin[x], {x, -Pi, Pi}, AspectRatio -> 1, ImageSize -> Medium]; Table[Rasterize@Plot[Sin[i ...

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

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

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

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

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

0

You could do something like this: expr[i_] := Defer[dS[i] = -β[i]*S] Do[expr[i][[1]]; CellPrint@Cell[BoxData@ToBoxes@expr[i], "Output"], {i, 4}] In the Do loop I evaluate the assignment and also create a cell with the definition. You could use "Input" instead of "Output" if you prefer.

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] *)

0

Dos this work Do[dI[i] = -beta[i]*S; Print["dI", i, "= -beta", i, "*S"], {i, 4}] Any method that can print what you want has to change the expression to a kid of String. At the end, the printed expression the way you what has to be kind of String You can try Inactivate Do[dI[i] = -beta[i]*S; Print[Inactivate[dI[i] = -beta[i]*S]], {i, 4}]

0

well, I found a another solution,instead of changing the writing format, one need to convert the datas using ToExpression[data1.txt]....

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

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

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

0

Have you tried Simplify expr = 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]; expr // Simplify 1/2 (a1 (2 + 2 a0 + a3) + a2 a4) D11 Cos[n x] expr2 = 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]; expr2 // Simplify 1/2 (a1 (2 + 2 a0 + ...

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

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

1

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

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

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

Top 50 recent answers are included