wolfram-mathematica

Manipulate Custom Tabular representation in Mathematica

白昼怎懂夜的黑 提交于 2019-12-22 13:33:08
问题 Considering the following data example : data ={ {"a", "b", "c", "d", "e"}, {1, 2, 3, 4, 5}, {11, 12, 13, 14, 15}, {21, 22, 23, 24, 25} }; And the following Function to generate customized Tabular representation : (and you can refer to Mr.Wizard extensive solution for customizable tabular representations. Ultimatly I would also manipulate the options he offered, for now ) DataSampleX[data_, linesNumber_, range1_, range2_, color1_, color2_, color3_] := Grid[ Join[ {Range[range1, range2]}, {Map

How to define a function that commutes with D in Mathematica

寵の児 提交于 2019-12-22 10:49:47
问题 I'd like to implement an operator f that commutes with differentiation D . Unprotect[D]; D[f[y___], x] := f[D[y, x]]; Protect[D]; D[f[Sin[x]], x] D[f[Sin[x]] + 1, x] Unfortunately this code produces two different results f[Cos[x]] (* as expected *) Cos[x] f´[Sin[x]] (* cannot explain *) I'd like to know, what's going on, and how to fix the replacement rule such that the second expression evaluates to f[Cos[x]] as well. Update. Solution 1 The following solution seems to do the job of

When does Mathematica create a new Symbol?

你说的曾经没有我的故事 提交于 2019-12-22 08:10:05
问题 Good day, I thought earlier that Mathematica creates new symbols in the current $Context at the stage of converting of the input string (that is assigned to InString ) to input expression (that is assigned to In ). But one simple example has broken this explanation: In[1]:= ?f During evaluation of In[1]:= Information::notfound: Symbol f not found. >> In[2]:= Names["`*"] Out[2]= {} In[3]:= DownValues[In]//First InString[1] Names["`*"] Out[3]= HoldPattern[In[1]]:>Information[f,LongForm->False]

When does Mathematica create a new Symbol?

有些话、适合烂在心里 提交于 2019-12-22 08:09:29
问题 Good day, I thought earlier that Mathematica creates new symbols in the current $Context at the stage of converting of the input string (that is assigned to InString ) to input expression (that is assigned to In ). But one simple example has broken this explanation: In[1]:= ?f During evaluation of In[1]:= Information::notfound: Symbol f not found. >> In[2]:= Names["`*"] Out[2]= {} In[3]:= DownValues[In]//First InString[1] Names["`*"] Out[3]= HoldPattern[In[1]]:>Information[f,LongForm->False]

Part and Span: is there a reason this *should* not work?

我们两清 提交于 2019-12-22 08:09:23
问题 This is a question of design, not of existing functionality. I would like to use: {1, 2, 3, 4, 5}[[{1 ;; 3, 2 ;; 5}]] I expect: {{1, 2, 3}, {2, 3, 4, 5}} But it is not valid: During evaluation of In[1]:= Part::pspec: Part specification {1;;3,2;;5} is neither an integer nor a list of integers. >> I am not asking why this does not work (simple: it's not supported). Rather, is there a reason it should not work? That is, is there a logical reason this is not supported? By the way, I specifically

Tweaking style/attributes of existing Graphics objects in Mathematica

ⅰ亾dé卋堺 提交于 2019-12-22 07:22:59
问题 One of Mathematica's strengths is its consistent underlying representation of objects. Thus, to change attributes of a plot without redoing the computation used to generate it, I could do something like Replace[myplot, {Graphics[x_List, y_List] :> Graphics[x,Flatten[{y, BaseStyle -> {FontFamily -> Helvetica, FontSize -> 20}}]]}] Unfortunately, every time I want to use this approach to modify a plot in order to change the style/color of lines, points, fonts, etc. I have to figure out what the

Tweaking style/attributes of existing Graphics objects in Mathematica

余生长醉 提交于 2019-12-22 07:22:23
问题 One of Mathematica's strengths is its consistent underlying representation of objects. Thus, to change attributes of a plot without redoing the computation used to generate it, I could do something like Replace[myplot, {Graphics[x_List, y_List] :> Graphics[x,Flatten[{y, BaseStyle -> {FontFamily -> Helvetica, FontSize -> 20}}]]}] Unfortunately, every time I want to use this approach to modify a plot in order to change the style/color of lines, points, fonts, etc. I have to figure out what the

How to redefine FrontEndEventActions?

戏子无情 提交于 2019-12-22 06:56:23
问题 Good day, This question comes from the question on aborting evaluation of the full sequence of inputs. I think it is probably possible to achieve the desired behavior by redefining FrontEndEventActions for two events: "EvaluateCells" (or pressing Shift + Enter ) and for pressing Alt + . . It should be something like: SetOptions[$FrontEndSession, FrontEndEventActions -> {"EvaluateCells" :> Last$PreRead, {{"Alt", "."} :> AbortAllNextInputs}}] or SetOptions[$FrontEndSession, FrontEndEventActions

Weird behaviour with GroebnerBasis in v7

只愿长相守 提交于 2019-12-22 06:36:51
问题 I came across some weird behaviour when using GroebnerBasis . In m1 below, I used a Greek letter as my variable and in m2 , I used a Latin letter. Both of them have no rules associated with them. Why do I get vastly different answers depending on what variable I choose? Image: Copyable code: Clear["Global`*"] g = Module[{x}, x /. Solve[ z - x (1 - b - b x ( (a (3 - 2 a (1 + x)))/(1 - 3 a x + 2 a^2 x^2))) == 0, x]][[3]]; m1 = First@GroebnerBasis[\[Kappa] - g, z] m2 = First@GroebnerBasis[k - g,

Using Mathematica Gather/Collect properly

限于喜欢 提交于 2019-12-22 06:23:25
问题 How do I use Mathematica's Gather/Collect/Transpose functions to convert: { { {1, foo1}, {2, foo2}, {3, foo3} }, { {1, bar1}, {2, bar2}, {3, bar3} } } to { {1, foo1, bar1}, {2, foo2, bar2}, {3, foo3, bar3} } EDIT: Thanks! I was hoping there was a simple way, but I guess not! 回答1: Here is your list: tst = {{{1, foo1}, {2, foo2}, {3, foo3}}, {{1, bar1}, {2, bar2}, {3, bar3}}} Here is one way: In[84]:= Flatten/@Transpose[{#[[All,1,1]],#[[All,All,2]]}]&@ GatherBy[Flatten[tst,1],First] Out[84]= {