# Tag Info

## Hot answers tagged output-formatting

15

This has nothing to do with N. You are observing the fact that by default Mathematica truncates machine precision numbers to 6 digits for displaying them. Enter 1.000001 without N and evaluate it: you'll see the same output (i.e. "1."). You can adjust this in Preferences, Appearance, Numbers, Formatting. The numbers are still stored to full precision, ...

11

Hint: try In[1]:= FullForm[N[1.000001, 10]] which returns Out[1]//FullForm= 1.000001 That tells you the 'rounding' is happening on the front end only, but that the full precision you asked for is still there. Roughly speaking, objects have an internal representation, and the front end 'interprets' this representation to produce the display in a ...

10

MeshShading Plot[Sin[x], {x, 0, 2 Pi}, MeshFunctions -> {# &}, Mesh -> {{Pi/2}}, MeshShading -> {Red, Directive[Dashed, Blue]}, PlotStyle -> Thick] Two piecewise functions Plot[{ConditionalExpression[Sin[x], x <= Pi], ConditionalExpression[Sin[x], x >= Pi]}, {x, 0, 2 Pi}, PlotStyle -> {Directive[Thick, Red], ...

8

Manipulate[ pascal = Row[Pane[#, 50, Alignment -> Center] & /@ #] & /@ Table[CoefficientList[(x + 1)^i, x], {i, 0, n - 1}]; product = Pane @ StringPadLeft[ToString[#], 40, "."] & /@ Table[(j!)^(j - 1)/BarnesG[j + 1]^2, {j, 0, n - 1}]; Grid[{{ Column[pascal, Center], Column[product, Right] }}, BaseStyle -> 15] , ...

8

Question 1: What is the typesetting in Mathematica? What procedures does it include? I think that this 2008 year MathGroup post by John Fultz completely answers this question, so I'll cite it here: In version 6, the kernel has absolutely no involvement whatsoever in generating the rendered image. The steps taken in displaying a graphic in ...

8

I'll make this brief: it's a job for a MakeBoxes rule. In this case a particularly simple one: MakeBoxes[li : LogIntegral, StandardForm] := InterpretationBox["li", li] Now LogIntegral prints as li.

7

An good explanation can be found an old mathgroup archive thread which I have reconstructed: When you create a typeset form for a function or operator, you must write a MakeBoxes definition for that function. For example, if you want Transpose[A] to have the typeset form $A^T$ then you might, erroneously, write it this way: Transpose /: ...

5

I am going to attempt to answer your questions off the cuff. I have been somewhat inactive on this site recently and also not using Mathematica much, so I am surely not at my best, so "take this with a grain of salt" as they say. Question 1 What is the typesetting in Mathematica? What procedures does it include? Typesetting is anything that is done for ...

4

One more trick is to use Show Show[Plot[Sin[x], {x, 0, Pi}, PlotStyle -> Red], Plot[Sin[x], {x, Pi, 2 Pi}], PlotRange -> {{0, 2 Pi}, Automatic}]

4

SetAttributes[hmsAbsTiming, HoldAllComplete]; hmsAbsTiming[calculation_] := MapAt[IntegerDigits[IntegerPart[#], MixedRadix[{24, 60, 60}]] &, AbsoluteTiming[ calculation ], 1] If you prefer a Quantity object: SetAttributes[hmsAbsTiming2, HoldAllComplete]; hmsAbsTiming2[calculation_] := MapAt[UnitConvert[Quantity[#, "Seconds"], ...

4

As Dynamic objects are only evaluated when they are visible, one can use them to print cells only when there is no ; at the end of the input. The following one removes the Out cell containing a DynamicWrapper as the Dynamic object itself, after the cells are printed. ClearAll@f f[x_] := Module[{evalCellObject}, DynamicWrapper["", evalCellObject = ...

3

This one checks if the input ended with ; and prints Echo cells if it didn't. f[x_] := If[ Cases[NotebookRead[EvaluationCell[]], BoxData[RowBox[{___, last_}]] :> last] == {";"}, Null, CellPrint[ExpressionCell[#, "Echo"]] & /@ Range[x]; ] For example: f[5] f[5]; This approach can be extended to also cover CompoundExpressions ...

3

The code below is currently broken but I'll leave it for reference. I'll attempt a full rewrite somewhat later. Thanks to gwr for testing my code and pointing out problems. The first possibility that comes to mind is the use of $PreRead and$PrePrint to set a global variable, then use the value of this variable within your function to control Cell ...

3

If you want to tweak the number of digits displayed in your notebook, run this: SetOptions[EvaluationNotebook[], PrintPrecision -> 10] As noted by Szabolcs, the default setting of PrintPrecision is 6, which is why you're only seeing that many digits in the output, even tho all the digits are still there.

3

You need to reorder the way definitions of Inactive are applied once you've defined your custom one. By default it was put at the bottom, so the "catch-all" rule is being attempted first. Unprotect[Inactive]; Inactive /: MakeBoxes[p : Inactive[myTimes][args___], form_] := MakeBoxes[Interpretation[HoldForm@myHead[args], p], form] FormatValues[Inactive] ...

3

You can use Row to accomplish your task. HoldForm needs to be wrapped around the first part. Copy of your code: Subscript[f, H][k_, t_] := 1/(k t + 1) Now try: Row[{ TraditionalForm[HoldForm@D[Log[Subscript[f, H][k, t]], t]], " = ", TraditionalForm[D[Log[Subscript[f, H][k, t]], t]] }] You can style it as you like. Below is a silly example ...

2

According to the documentation, Format[] seems to be done for that : Unprotect[LogIntegral] Format[LogIntegral[z_]] := li[z] Protect[LogIntegral]

2

Analysis Key step is to solve for wi1, wi2, wj1 and wj2 symbolically in terms of the input points l1, l2, p1, p2 and p3. The symbolic solution will be used in the Manipulate which will dramatically speed up the process. Below is the code, some are a direct copy, others have changes. At[X_] := 1/2 Det[({{1, X[[1, 1]], X[[1, 2]]}, {1, X[[2, 1]], X[[2, ...

2

You can use NumberFormat option in ScientificForm to do this. For example cformat[x_, numDigts_] := ToString[ ScientificForm[x, numDigts, NumberFormat -> (Row[If[#3 == "", {#1}, {#1, "E", #3}]] &)]] then cformat[1.2345678*^-10, 4] (* "1.235E-10" *) However, since your data is all in the range of 0 to 10, there would be no "E" in the ...

1

You can use an intermediate expression that can be returned by your function, not printed as side effect. Then you can use \$Post to post-process this returned expression, so that it'll result in multiple printed cells. ClearAll[multipleCellsOutput, printMultipleCellsOutput] printMultipleCellsOutput = # /. multipleCellsOutput[cells_List] :> ...

1

Here's my take, borrowing some code from here and here: ic = Function[x, With[{r = Round[x]}, r + Chop[x - r]], Listable]; SetAttributes[myTiming, HoldAllComplete]; myTiming[calculation_, tf : (Timing | AbsoluteTiming) : AbsoluteTiming] := Module[{timing = tf[calculation]}, Print[StringTemplate["h hr m min s` s", ...

1

I prefer @Karsten's approach of making a pure function that can be applied directly to format results from AbsoluteTiming, but if you're new to Mathematica this might be easier to follow: SetAttributes[myAbsoluteTiming, HoldAllComplete]; myAbsoluteTiming[calculation_] := Module[{time, result, hours, minutes, seconds, format}, {time, result} = ...

1

I'm not sure if that's what you want to achieve but if you want Mathematica to process your input while keeping the sum only as a symbol you may want to make it inactive (a new feature since version 10.0). Try: Inactive[Sum][f[OverTilde[q]], OverTilde[q] ∈ Subscript[l, i]] This way you can still use it as a part of a formula, or assign it to a variable, ...

1

As a generalization to the excellent answer by ens, Silvia's solution also can be added as a palette to the menu as follows. First, create and save the UniCodeCopy.m package, as described by ens. Then create as a separate notebook, perhaps named Unicode Copy Source.nb, CreatePalette[Button["UniCode Copy", Module[{codestr}, ...

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