Tag Info

Hot answers tagged

11

Version 10 introduced some undocumented functionality that makes it easier to explore the style hierarchy. As usual, "undocumented" === "buyer beware". We start by evaluating: StyleManager`OpenStyleManager This does nothing other than trigger the auto-loading of certain symbols. We'll come back to a more interesting use of this symbol later. Now, we ...


10

The following works in both v9 and v10: style = Directive[Thick, Black]; ContourPlot[y - x^2, {x, 0, 1}, {y, 0, 1}, ContourStyle -> Directive[Thick, Black, Opacity[1]], FrameStyle -> style, PlotLegends -> BarLegend[Automatic, Method -> {FrameStyle -> style}]] The idea to use the (undocumented) Method option comes from inspecting the ...


10

Mathematica 10 introduces IntegerName: IntegerName[n] gives a string containing the full English name of the integer n. IntegerName[n,"type"] gives a string of the specified type. Possible types include: "DigitsWords" a combination of three-digit numbers and words "Words" using only words "Approximate" the first few digits ...


9

Part a response, Because you do not show additional information and do not describe the problem with the code, I show one approach. First we construct some helpers : ClearAll["Global`*"] SetDirectory@NotebookDirectory[]; siz1 = 250; siz2 = 500; tex1 = "What a long and interesting and certainly necessary title for \ a panel of functions."; title = ...


9

The reason is that you have empty history because you set $HistoryLength = 0 (as you confirm in the comments). I recommend setting $HistoryLength to be at least 3 in order to get the [Show Full Output] button working in the most practical cases.


9

From very old documentation (I think Mathematica 4): Parentheses within a single RowBox by default grow to span whatever other objects appear in the RowBox. Some expandable characters, however, grow by default only to a limited extent. The latter seems to apply to square brackets. But we can overcome that by using a StyleBox: StyleBox [RowBox[{"[", ...


8

The following works in Version 9.0.1.0 and Version 10.0.1.0 BoxForm`$UseTemplateSlotSequenceForRow = False; {x^a, Sqrt@b, ArcSin[c]} // Row // TeXForm (* x^a\sqrt{b}\sin^{-1}(c) *)


8

The following may be useful as starters: WolframAlpha["femme from french to german",{{"Translation:TranslationData", 1}, "ComputableData"}] (* {" Frau | Ehefrau", " Frau"} *)


8

You can also use MapAt with Invisible or Style[#,White]&: f1 = MatrixForm[MapAt[Invisible, #, Position[#, Except[#2], {2}, Heads->False]]] &; (* or f1 = MatrixForm[MapAt[Style[#,White]&, #, Position[#, Except[#2], {2}, Heads->False]]] &; *) Example: m = RandomInteger[5, {5, 5}]; Row[Prepend[f1[m, #] & /@ {1, 2, 1 | 2}, ...


8

The dimming is controlled by the option PrivateCellOptions->{"EvaluationUnmatchedStyle"}. It must be applied at the cell level, but this is easy to do in your example by using CellPrint with the "Print" style to match what Print does. CellPrint@ ExpressionCell[g, "Print", PrivateCellOptions -> {"EvaluationUnmatchedStyle" -> {}}]


7

x = E^-n (2 E^-1 + E^2) + E^n (2 E^-2 + E); x /. Times[a_, b_] :> Times[a, ExpToTrig@b] E^n (E + 2 Cosh[2] - 2 Sinh[2]) + E^-n (2 Cosh[1] + Cosh[2] - 2 Sinh[1] + Sinh[2])


7

Because Inactivate acts on Heads of expressions, replaces them with Inactive[h] where h is the Head of the expression and prevents them from evaluating. And in your case the Head of x y is Times: FullForm[x y] Times[x, y] So Inactivate[x y] Gives: Where the Times did not evaluate. Hence, the result you get when you apply TraditionalForm.


7

It sounds like you're merely looking for Row: Cp = 1.5; deltastar = 0.123; Row[{ "The value for ", HoldForm[Subscript[C, p]], " is ", Cp, " and the value for ", HoldForm[Superscript[\[Delta], "*"]], " is ", deltastar, "." }] If this does not work for you please clearly state how it fails so that those issues can be directly addressed.


7

Looks like StringForm can achieve this: Cp = 1.5; deltastar = 0.123; Then: StringForm["The value for `1` is `2` and the value for `3` is `4`.", HoldForm @ Subscript[C, p], Cp, HoldForm @ Superscript[\[Delta], "*"], deltastar]


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


7

Since python has pretty close syntax as Fortran, converting the expression to FortranForm is what I usually do in this case. testing2 = ExpandAll[ D[(x - A)^2 + (y - B)^2 + (v - C)^2 + (x + y - (S + v) - D)^2 - \[Lambda]1*x - \[Lambda]2*y - \[Lambda]3* v - \[Lambda]4*(x + y - (S + v)), {{x, y, v}}]] sols = {x, y, v, x, y, v, \[Lambda]1, ...


7

PlusMinus[{x_, err_}] := Module[{errE = Last@MantissaExponent[err], xE = Last@MantissaExponent[x]}, Row[{"(", NumberForm[N@Round[x, 10^(errE - 1)]*10^(-xE + 1), {xE - errE + 1, xE - errE}], " \[PlusMinus] ", NumberForm[N@Round[err, 10^(errE - 1)]*10^(-xE + 1), {1, xE - errE}, ExponentFunction -> (Null &)], ")", " ...


6

Consider this: Inactivate[3*5 - 2 - 3] // FullForm Inactive[Plus][Inactive[Times][3, 5], -2, -3] RunnyKine is correct regarding the cause but he did not really explain the mechanism involved. Formatting rules typically apply to (sub)expressions with certain heads. This has nothing to do with evaluation per se, but rather the patterns in the ...


6

Here is a function that copies a Unicode string to the clipboard using JLink: Needs["JLink`"]; InstallJava[]; LoadJavaClass["java.awt.Toolkit", AllowShortContext -> False]; uniclip[s_String] := JavaBlock[ java`awt`Toolkit`getDefaultToolkit[]@getSystemClipboard[]@setContents[#, #]& @ JavaNew["java.awt.datatransfer.StringSelection", s] ...


6

I am not familiar with the specific output format you need but I think I can show you how to proceed. dat = Import["ExampleData/caffeine.xyz", {{"VertexTypes", "VertexCoordinates"}}]; dat2 = {#[[1, 1]], #[[All, 2]]} & /@ GatherBy[dat\[Transpose], First]; dat3 = {#, Length@#2, #2} & @@@ dat2; dat3 has this format: dat3 // TableForm $\left( ...


6

Something like heldint = HoldForm[Integrate[r^3, {t, 0, 2 Pi}, {r, 0, 2}, {z, r^2, 4}]]; int = ReleaseHold[heldint]; Row[{heldint, " \[LongEqual] ", int, " \[TildeTilde] ", N[int]}] // TraditionalForm


6

TraditionalForm looks nice but it also incurs additional complexity in handling expressions. If you attempt to evaluate a TraditionalForm cell you will be asked if you wish to interpret it as input, and the equivalence is not always complete. Fortunately Mathematica is quite cabable of displaying formatted integrals in StandardForm. If you merely wrap ...


6

You people with your fancy version 10 have it too easy. StringJoin@Reverse@MapIndexed[ToString[#] <> {"", " thousand ", " million ", " billion ", " trillion" }[[First@#2]] &, Reverse@(FromDigits /@ Partition[PadLeft[#, 3 - Mod[#, 3, 1] + # &@Length@#] , 3])] &@ IntegerDigits[123456789] "123 million 456 ...


6

data = Table[(i + j) i (i - j), {i, 1, 2}, {j, 1, 22}]; The first step is to define a function to break up each row in the data into lines not exceeded the specified maximum line length. prep[row_, fieldWidth_, lineLength_] := Module[{items = Floor[lineLength/fieldWidth]}, Partition[row, items, items, 1, {}]] The second step is to do the ...


6

V = (-G*Mn)/Sqrt[x^2 + y^2 + z^2 + cn^2]; Vx = D[V, x] /. {x -> x[1], y -> x[2], z -> x[3]}; StringReplace[ToString[Vx, FortranForm], " " -> ""]


5

EDITED to include Mr.Wizard's replacement for Switch EDITED to cover additional cases Roll your own: quantityWithAppropriatePrefix[quant_Quantity] := Fold[UnitConvert[#1, #2] &, quant, {"Imperial", "SI"}]; quantityWithAppropriatePrefix /@ {Quantity[0.0000011, "Meter"], Quantity[0.0000033, "Feet"]} {Quantity[1.1, "Micrometers"], ...


5

I post this for illustrative purposes. You can access values. I suggest looking at the properties of your model, e.g. if your model is nlm then nlm["Properties"]. Some data and model: wd = WeatherData["Brisbane", "Temperature", {{2004, 1, 1}, {2013, 12, 31}, "Day"}]; vl = QuantityMagnitude /@ wd["Values"]; bnl = ...


5

I don't use the command line and haven't tried this but I suspect that SetOptions["stdout", PageWidth -> Infinity] may be what you are after.


5

Defer[Quantity][Placeholder["tip"],"Meters"] or HoldForm[Quantity][Placeholder["tip"],"Meters"] The second method requires ReleaseHold to evaluate.


5

primeFactorForm[n_Integer] := Module[{fact = FactorInteger[n]}, If[Length[fact] == 1, Superscript @@ fact[[1]], CenterDot @@ Superscript @@@ fact]] primeFactorForm[9] primeFactorForm[72]



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