Tag Info

Hot answers tagged

9

You can create your own ...Form wrapper that will format Times as you want it. Let's start with ordering function that can be used in SortBy. It puts numeric coefficients in front, expressions present in par are ordered according to their position in par, all other expressions are moved to the end. ClearAll[par, order] par = {(1 - p), p, k, Subscript[k, ...


7

You're going to have to write a separate function that uses Integrate instead of NIntegrate if you want something that looks like a matrix of traditional integrals, which is what I think you want. You also need to use HoldForm to keep the integral from evaluating. You also need someway to set the values that you want in the held version of the expression. ...


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

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


6

What I think is happening is that the SetOptions statement in init.m is executed during kernel initialization as expected, however when the notebook window is opened, the front-end sets PageWidth to be WindowWidth. Furthermore, the kernel value does get changed accordingly whenever the window is resized. This being the front-end, I would not be surprised if ...


5

Collecting together the advice given in comments to the question by kirma and Guesswhoitis, the answer is expr = {0, 1/4 (Cos[(3 t)/4] - Cos[(5 t)/4] + I (-Sin[(3 t)/4] - Sin[(5 t)/4])), 1/4 (Cos[(3 t)/4] - Cos[(5 t)/4] + I (-Sin[(3 t)/4] - Sin[(5 t)/4])), 0, 1/4 (Cos[(3 t)/4] - Cos[(5 t)/4] + I (-Sin[(3 t)/4] - Sin[(5 t)/4])), 0, 0, 0, 1/4 ...


5

There will be more clever answers from people who better understand Mathematica's order of evaluation and how to use Hold and such, and so I can't answer your question in exactly the way that you've phrased it, but here's how I go about doing these types of things. First, instead of declaring the values of x, omega, and R as you've done, make a list of ...


5

The documentation could have been clearer about this, but at least it says prints with all real numbers … in engineering notation. Therefore, it is not a bug. Use N to convert to floating point before using EngineeringForm. Exact numbers such as Pi, Sqrt[2], 7/5 or even 1*^10 won't be automatically converted to inexact forms by most *Form functions. ...


5

Here is my take on this problem. errorForm[num_, err_, digits_] := Module[{exp, n, e}, exp = Floor @ Log10 @ num; n = NumberForm[num/10^exp, digits, ExponentFunction -> (Null &)]; e = NumberForm[err/10^exp, digits, ExponentFunction -> (Null &)]; Row[{ "(", n, "\[ThinSpace]\[PlusMinus]\[ThinSpace]", e, ") ...


4

Likely some duplication with existing answers but I felt like playing with this one. I'll use Format so that the underlying representation does not change. a_ ± b_ ± c_ := PlusMinus[a, b, c]; Format[b_?NumericQ ± err_?NumericQ ± acc_Integer: 6] ^:= Row[{ "(", NumberForm[Row[{b, err}*10^-#, "±"], {acc, acc}, ExponentFunction -> (Null ...


4

Instead of While[i<21,...], use Table[...,{i,20}]. The ... part can be reduced to r = k[[a[[i]]]]; Factor[Det[r]] To find the PolynomialLCM, simply replace the head ( List) of the table with PolynomialLCM using Apply, or @@ for short: PolynomialLCM @@ Table[...,{i,20}]


3

The -noprompt switch does several things: it suppresses the Mathematica ... banner and all the In/Out prompts, sets the page width to Infinity and, most relevantly, switches the kernel default print form to InputForm (being preferable, in batch mode, to the regular two-dimensional typesetting used for interactive terminal sessions). Example : What I have ...


2

Replace the Print[det] in the print with: Paste[det]


2

This method is based on Mr. Wizard's answer (updated for V10) to About the number format in ticks, which I discovered investigating another question, Change only tick labels while keeping default ticks, that in meantime was marked as a duplicate of this one. Since the method presented in the accepted answer by FDSg no longer works (currently the only other ...


2

You can use Inactivate with TraditionalForm. Inactivate[h = (R.omega + x).x] // TraditionalForm Inactivate prevents the operations from executing and TraditionalForm gives the formatted output. Hope this helps.


2

I shall adapt my code from How do I reassign canonical ordering of symbols? with the addition of a rule for the Power[_, -1] form. I assume that any Variables not in par are to be placed at the end. reorderIstván[expr_, par_List] := Module[{h, rls}, rls = MapIndexed[x : # :> h[#2, Replace[x, rls, -1]] &, DeleteDuplicates @ Join[par, ...


1

It seems that a clean yet undocumented method has existed since v5.2 or earlier that could be applied here. Please reference Undocumented fourth parameter of Collect; how long has it been there? and then observe: Collect[(1 + x + Cos[s] x^2)^3, x, # &, Defer[+##] &] 1 + 3 x + x^2 (3 + 3 Cos[s]) + x^3 (1 + 6 Cos[s]) + x^4 (3 Cos[s] + 3 Cos[s]^2) ...


1

TableForm[Table[{i, j}, {i, 4}, {j, 8}], TableDirections -> {Column, Column, Row}] or Flatten[Table[{i, j}, {i, 4}, {j, 8}], 1] // TableForm Exporting: Export["filename.csv", Flatten[Table[{i, j}, {i, 4}, {j, 8}], 1]]


1

Perhaps something as simple as Join[{something}, #] & /@ Table[{i, j}, {i, 4}, {j, 8}] {{something, {1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {1, 7}, {1, 8}}, {something, {2, 1}, {2, 2}, {2, 3}, {2, 4}, {2, 5}, {2, 6}, {2, 7}, {2, 8}}, {something, {3, 1}, {3, 2}, {3, 3}, {3, 4}, {3, 5}, {3, 6}, {3, 7}, {3, 8}}, {something, {4, 1}, {4, ...


1

What about this: Table[{" ", Table[{i, j}, {j, 1, 8, 1}]}, {i, 1, 4, 1}] which has no "something", and you might also put it in the TableFormif needed. Alternatively you might make a Gridout of it: Grid[Table[{" ", Table[{i, j}, {j, 1, 8, 1}]}, {i, 1, 4, 1}], Dividers -> All] yielding the following: As to your second question, what ...


1

Here's another idea that makes use of ArrayFlatten GridPlus[data_, headers_, opts : OptionsPattern[Grid]] := Grid[ArrayFlatten[{{{{""}}, {headers[[1]]}}, \ {Transpose[{headers[[2]]}], data}}], opts]


1

\[GothicCapitalR] = {{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, {{0, 1, 0}, {0, 0, 1}, {1, 0, 0}}, {{0, 0, 1}, {1, 0, 0}, {0, 1, 0}}, {{1, 0, 0}, {0, 0, 1}, {0, 1, 0}}, {{0, 0, 1}, {0, 1, 0}, {1, 0, 0}}, {{0, 1, 0}, {1, 0, 0}, {0, 0, 1}}}; i = 1; j = 1; det = 1; a = Subsets[Range[6], {3}]; v = {x, y, z}; k = \[GothicCapitalR].v; PolynomialLCM @@ ...


1

This seems to be close to what is wanted. a1 = 0.02112398; a2 = 0.000331; f[z1_, z2_] := Module[{t, ee = Floor[Log10[Abs[z1]]]}, t = NumberForm[z1 10^-ee, 3] ± NumberForm[z2 10^-ee, 3 + ee, ExponentFunction -> (Null &)]; t RawBoxes[SuperscriptBox[10, ee]]] f[a1, a2] $$ (2.11 \pm 0.03) 10^{-2} $$



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