New answers tagged


It's unclear what exactly is an input but here's my interpretation: ClearAll[f] f[x_, y_] := 3.23425124` x^2 + 5.8978587` y; f[2, 3] 30.6306 DownValues[f] = DownValues[f] /. n_?NumericQ :> RuleCondition@Round[n, 0.1]; f[2, 3] 30.5


3.23425124` x^2 + 5.8978587` y /. Times[a_, b_] :> Times[Round[a, 0.1], b] (*3.2 x^2 + 5.9 y*) coefficient * variable is of Times[coefficient, variable] in full form, therefore you can use this pattern to match and round only the coefficient.


This isn't an exact answer as for how to construct NCSort. However, it is the core of my approach for generating Wick contractions. I ripped out all the bells and whistles. It helps to have some background: I do lattice QCD, and so I mostly think about quark contractions. So, if you see "quark" you can parse that as "fermion". My code is designed to ...


I think one of the most important core functions is ReplaceAll(/.). I find it useful as some functions output results as rules and then you can use replaceall directly with the results.


numberListIndexed=partition[Thread[{Range[len],fileImported}],Range[100]]; numberIndexList=#[[All,1]]&/@numberListIndexed; numberListAsso=AssociationThread[Range[len],fileImported]; pickMax[trackList_]:=MaximalBy[trackList,Total[Map[numberListAsso,#, {1}]]&,1] append[x_,y_]:=Append[x,#]&/@y ...

Top 50 recent answers are included