Hot answers tagged

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

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.


8

Histogram does not support a grouped ChartLayout. Hence the workaround using BarChart: I've arranged the 'histogram' into a bar chart so that the data can be displayed side by side. An alternative to using BarChart with "Grouped" layout is to use a custom ChartElementFunction to produce the desired Histogram layout: ClearAll[groupedHistogram] ...


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


7

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


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


7

Rather than Show, you can use Prolog + Inset with Scaled: Plot[ 140 PDF[SmoothKernelDistribution[#], x] & /@ {S086, T086, X086}, {x, 0, 100}, Evaluated -> True, PlotStyle -> { {Thickness[0.01], RGBColor[0.23, 0.42, 0.63]}, {Thickness[0.01], RGBColor[0.29, 0.53, 0.80]}, {Thickness[0.01], RGBColor[0.62, 0.73, 0.88]}}, Frame -> ...


5

It doesn't seem to be available with Options so let's edit this manually. So you can inspect the output or use ToBoxes to know what needs to be changed. And change it: sound = Sound[{SoundNote["C"], SoundNote["G"]}] ToBoxes[ sound ] /. GraphicsBox[gr_, opts___, ImageSize -> _, opts2___ ] :> GraphicsBox[gr, opts, opts2, ImageSize -> 500 ] // ...


5

There are two issues here: How to write a string that contains a quotation within it, when the quotation mark is what signifies to the system when a string begins and ends. How to export strings with special characters, and have them written in their escaped form: \[Alpha] and not α For the first, you need to construct the string using \" to begin and ...


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


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

Probably you want the following: UT := 1 + x^2 VT := t*x^2 WT := t Column[{Row[{Plot3D[UT, {x, 0, 1}, {t, 0, 0.8}], Plot3D[VT, {x, 0, 1}, {t, 0, 0.8}]}], Plot3D[WT, {x, 0, 1}, {t, 0, 0.8}]}, Center, BaseStyle -> ImageSizeMultipliers -> 1]


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


2

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


1

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 generation. A basic example building on andre's code: $print = True; $PrePrint = ($print = True; #) &; $PreRead = Replace[#, row : RowBox[{__, ";"}] :> ($print = False; ...


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