# Tag Info

44

You can use custom transformation rules, for example: -11 - 2 x + x^2 - 4 y + y^2 - 6 z + z^2 //. (a : _ : 1)*s_Symbol^2 + (b : _ : 1)*s_ + rest__ :> a (s + b/(2 a))^2 - b^2/(4 a) + rest returns (* -25 + (-1 + x)^2 + (-2 + y)^2 + (-3 + z)^2 *) The above rule does not account for cases where b is zero, but those are easy to add too, if ...

36

The power of Mathematica's syntax allows us to create dice in several different ways. Here's one way that I like: dice[n_Integer] := dice[n, Black] Format[dice[n_Integer, c_]] := With[{ dots = {1 -> {5}, 2 -> {3, 7}, 3 -> {3, 5, 7}, 4 -> {1, 3, 7, 9}, 5 -> {1, 3, 5, 7, 9}, 6 -> {1, 2, 3, 7, 8, 9}} /. l : {...

29

Since a native method is not forthcoming, I shall post my file based circumvention, for Windows. You will need to have this utility in the command path (it apparently is stock with Windows 7). copyUnicode[expr_] := Run["clip <", Export["$Clipboard.temp", ToString[expr, InputForm], "Text", CharacterEncoding -> "Unicode"] ]; Usage: expr ... 29 I always use IntegerString for this (I also number my files in a similar way): In[1]:= IntegerString[#, 10, 2] & /@ Range[87] Out[1]= {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", \ "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", \ "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", \ "33", "34", "35", "36"... 28 We have unicode support so we can use the following strings: {"⚀", "⚁", "⚂", "⚃", "⚄", "⚅"}: dice = FromCharacterCode /@ Range[9856, 9856 + 5]; Grid[Partition[RandomInteger[{1, 6}, {50, 2}], 5] /. { i : {__Integer} :> Style[ Row[dice[[i]], Spacer[1]], {Large, Total[i] /. {7 -> Red, _ -> Black}}]} , Frame -> All] 28 Mathematica does it internally by using BoxFormArrangeSummaryBox, which is quite straightforward to figure out: MakeBoxes[obj_MyObject, fmt_] ^:= Module[{o = List @@ obj, shown, hidden, icon = Graphics[{Blue, Circle[]}, ImageSize -> 70]}, shown = {{ BoxFormMakeSummaryItem[{"Name: ", "Name" /. o /. "Name" -> Missing[]}, fmt], ... 27 nb2 = NotebookOpen @ FileNameJoin[ {$InstallationDirectory, "SystemFiles", "FrontEnd", "StyleSheets", "Core.nb"}]; Note that some of the named styles in the core stylesheet styles are empty, i.e. the style name is defined but no styles set: Cell[StyleData["style"]] For example (with V8): Union[Cases[NotebookGet[nb2],StyleData[x_, ___] :> x, \[...

25

An even simpler way that does not require you to figure out the tick positions, is to set the tick font opacity to 0 and the tick font size to 0 to avoid the excess margin where the ticks would have been. Here's an example: RegionPlot[Sin[x y] > 0, {x, -1, 1}, {y, -1, 1}, FrameTicksStyle -> Directive[FontOpacity -> 0, FontSize -> 0]] ...

24

If this is something you want in general, try: SetOptions[$FrontEnd, PrintPrecision-> 10] and if you just want it for a specific notebook, then do: SetOptions[InputNotebook[], PrintPrecision-> 10] 24 After importing a free dice 3D model {pd, vd} = Import["c:\\dice.stl", #] & /@ {"PolygonData", "VertexData"}; g2 = Translate[GraphicsComplex[vd, Polygon /@ pd], {-10, -37.5, -10}]; rv = {{0, 0, -1}, {0, -1, 0}, {0, 0, 1}, {0, 1, 0}, {-1, 0, 0}, {1, 0, 0}}; dice[x_List, n_Integer] := Rasterize@(Graphics3D[{EdgeForm[None], Blue, Rotate[g2,{{0, 0, 1},... 23 Perhaps this? LogPlot[Abs[BesselJ[1, x] Sin[x]^2], {x, -10, 10}, Frame -> True, FrameTicks -> {{{#, Superscript[10, Log10@#]} & /@ ({10^0, 10^-1, 10^-2, 10^-3, 10^-4, 10^-5}), None}, {None, None}}] Here's a completely different approach, manipulating the existing tick labels in the generated graph, and preserving the unlabeled ... 23 From the documentation: PlusMinus[a] displays as$\pm x$. I believe it is purely a formatting function. It is not literally interpreted as$\pm x$. However, per the documentation, you can assign values to it. You can assign a rule that mimics the behavior you want by assigning an UpValue to PlusMinus: PlusMinus /: PlusMinus[a_]^2 := a^2 Then: ... 22 This is similar to my Log question and similar methods can be used.$PrePrint = # /. { Csc[z_] :> 1 / Defer@Sin[z], Sec[z_] :> 1 / Defer@Cos[z] } &; Example: (x + y) Csc[x] Sec[y] (x + y)/(Cos[y] Sin[x])

21

You can use TrigExpand to expand all trigonometric functions to fundamental forms and then Eliminate solves the rest eq1 = Sin[x]^8 + 2 Cos[x]^8 - 1/2 Cos[2 x]^2 + 4 Sin[x]^2 == 0; eq2 = t == Cos[2 x] Eliminate[TrigExpand[{eq1, eq2}], x]

20

Declaration: This method for Windows is based on the .NET code from Todd Gayley's this wonderful answer. My .NET knowledge is absolutely ZERO, all credit goes to Todd. Code: The main idea is to extract the "Input"-style code string, convert it to the UTF-16 little endian form, which is the standard byte order in Windows, feed the bytes to system clipboard ...

20

I've had a need for such a function several times, and I found this implementation of C-style *printf functions, by Vlad Seghete. To use it, all you need to do is extract the files to $UserBaseDirectory/MathPrintF/ and you're all set. Here's an example once you've installed it: <<MathPrintF sprintf["%d %s %d %s, %s %s %s %s", Sequence @@ Riffle[... 20 Edit: Quoting from Heike´s comment: "The font families used for Greek, script, gothic, and double struck symbols are respectively "Mathematica1", "Mathematica5", "Mathematica6", and "Mathematica7" " With this knowledge, just use Styletogether with the FontFamily option: Style["Doth this help?", FontFamily -> "Mathematica6", FontSize -> 100] ... 20 PrintPrecision You can control the number of digits displayed using the PrintPrecision option. You have a number of options for its use. You can set it Globally or for the specific Notebook using the Options Inspector. You can also use it directly with Style: Style[123.189094, PrintPrecision -> 10] 123.189094 You can set it temporarily for one ... 20 If you want to order your terms this way but not perform the other formatting that TraditionalForm does, you might like to try the (undocumented) PolynomialForm[expr, TraditionalOrder -> True]. That will change output like this: Expand[(x+y-1)^3] (* -> -1+3 x-3 x^2+x^3+3 y-6 x y+3 x^2 y-3 y^2+3 x y^2+y^3 *) into this: PolynomialForm[%,... 19 If you want the minor ticks too, you can use the following function: SetAttributes[dtZahl, Listable] dtZahl[x_] := Block[{n}, If[IntegerQ[n = Rationalize[x]], n, x]] exponentForm[x_?NumberQ] := Module[{me = MantissaExponent[x], num, exp}, If[MemberQ[{0, 0., 1, 1., -1, -1.}, x], Return[IntegerPart[x]]]; exp = Superscript["\[CenterDot]10", me[[2]] -... 18 You can express any fraction/number to arbitrary decimal places by using a backtick followed by number of digits required. For example: In[1]:= 4/320 Out[1]= 1.3333333333333333333 This is the same as N[4/3, 20]. Now combine this with AccountingForm, which never uses scientific notation to get the output that you desire. AccountingForm[1/9980012994] Out[... 18 Another option is to set FormatType -> OutputForm on the$Output stream: SetOptions[ $Output, FormatType -> OutputForm ]; Print["Hello"]; Or call OutputForm on the string itself: Print[ OutputForm["Hello"] ]; 18 Not as such. The closest equivalent is StringForm, but it doesn't provide the formatting options that the printf family does. StringForm gets a lot of use in the creation of messages. Example: StringForm["The value of Pi is ", NumberForm[N[Pi], 3]] (* ==> "The value of Pi is 3.14" *) Note that StringForm does not create a string, it merely ... 17 It indeed seems that the thickness of the frame doesn't respond to any of the options in Frame. As a workaround, you could do this (although I would recommend the second approach below, instead!): SetOptions[FrameBox, BoxFrame -> 3]; Framed["AA", FrameStyle -> Red] However, the SetOptions will affect all frames drawn in your notebook (even ones ... 17 You can use PolynomialForm : Collect[(1 + x + Cos[s] x^2)^3, x] // PolynomialForm[#, TraditionalOrder -> True] & Cos[s]^3 x^6 + 3 Cos[s]^2 x^5 + (3 Cos[s]^2 + 3 Cos[s]) x^4 + (6 Cos[s] + 1) x^3 + (3 Cos[s] + 3) x^2 + 3 x + 1 17 Recall that the rendering of Graphics has nothing to do with evaluation. It is done entirely in typesetting. And therefore, a robust solution will treat this as a problem of typesetting, and not as a problem of evaluation. Once you frame the problem properly, the solution is fairly straightforward. What you want to do is to change the typesetting of Hold ... 17 The old typesetting can be restored by SetSystemOptions["TypesetOptions" -> "IconicElidedForms" -> False]; Also mentioned previously: (1), (2), (3). 16 Mathematica's Graph related functionality is pretty great. You can easily style vertexes, edges and their labels, apply interesting functions. For small increase in code sophistication you gain quite a bit of advantage. Your data: poli = {{1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {5, 2}, {4, 2}, {3, 2}, {2, 2}, {1, 2}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {5, ... 16 You could always set$Post to have this happen automatically. format[x_Real] := NumberForm[x, ExponentFunction -> (Null &)]; format[x_] := x; $Post = format; Now, N[1/998001, 50] returns 0.0000010020030040050060070080090100110120130140150160170 Even better,$Post is applied at display time, thus Head[%] returns Real.

16

My preferred solution is playing with FontColor or FontOpacity as in R.M.s answer, or define your own ticks as in David's answer. Another alternative is to change the labels to blank in FrameTicks. Since FrameTicks->Automatic saves a lot manual effort (and it uses the built-in FindDivisions for selecting ticks), sometimes it may be more convenient to ...

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