wolfram-mathematica

Question on Definition and values of symbols

不问归期 提交于 2019-11-30 13:52:43
Definition "knows" the way how a value for a symbol was defined: using Set or SetDelayed . But how? As I understand, after a value for a symbol was assigned there is no any difference for the evaluator how it was assigned: by using Set or SetDelayed . It can be illustrated by the function OwnValues which always returns definitions with the Head RuleDelayed . How Definiton obtains this information? In[1]:= a=5;b:=5; Definition[a] Definition[b] OwnValues[a] Out[2]= a=5 Out[3]= b:=5 Out[4]= {HoldPattern[a]:>5} Alexey Popkov OwnValues[a] = {HoldPattern[a] -> 3}; OwnValues[a] gives {HoldPattern[a]

Uses for MapAll ( //@ )

被刻印的时光 ゝ 提交于 2019-11-30 13:06:55
The function MapAll was seen as important enough to warrant the short form //@ , yet I rarely use it, especially compared to others like /@ , /. and @@@ which I use almost everywhere. What applications best leverage MapAll ? Is it used mostly in certain fields or programming styles? How often can it be used compared to other operators? //@ is a "post-order tree traversal". It visits every node in a tree structure, each node's children being visited before the node itself. The supplied function is called with each node as its argument, the node's children already having been "expanded" by a

Plotting arrows at the edges of a curve

十年热恋 提交于 2019-11-30 12:57:15
问题 Inspired by this question at ask.sagemath, what is the best way of adding arrows to the end of curves produced by Plot , ContourPlot , etc...? These are the types of plots seen in high school, indicating the curve continues off the end of the page. After some searching, I could not find a built-in way or up-to-date package to do this. (There is ArrowExtended, but it's quite old). The solution given in the ask.sagemath question relies on the knowledge of the function and its endpoints and

Command completion in mathematica : suggest rules/options

别等时光非礼了梦想. 提交于 2019-11-30 12:49:24
In current version of Mathematica these keyboard shortcuts are quite handy Ctrl+K completes current command GraphPl -> press Ctrl+K -> GraphPlot Ctrl+Shift+K completes current command and adds argument placeholders which could be replaced with actual values with tab key GraphPl -> press Ctrl+Shift+K -> GraphPlot[{vi1->vj1,vi2->vj2,...}] However I couldn't find any keyboard option to show associated settings/options For instance Say If I need to plot a graph with different layouts, I know I need to set Method with one of these Possible settings "CircularEmbedding" "RandomEmbedding"

Difference between == and === in Mathematica

房东的猫 提交于 2019-11-30 12:45:22
I was under the impression that = is an assignment, == is a numeric comparison, and === is a symbolic comparison (as well as in some other languages == being equal to and === being identical to . However, looking at the following it would appear that this is not necessarily the case... In: x == x Out: True In: x === x Out: True In: 5 == 5 Out: True In: 5 === 5 Out: True In: x = 5 Out: 5 In: 5 == x Out: True In: 5 === x Out: True In: 5 5 == 5x Out: True In: 5 5 === 5x Out: True In: x == y Out: x == y In: x === y Out: False In: y = x Out: 5 In: x == y Out: True In: x === y Out: True So what

mathematica start front end and eval notebook from command line

╄→尐↘猪︶ㄣ 提交于 2019-11-30 12:38:18
Is there a way to start up a mathematica front end (GUI) from a (Windows) command prompt and have it eval a notebook without further user action? even though mathematica.exe takes the -run and -initfile options they dont work the same as they do with math.exe. (-run ''<<file.m'' wants to open a file named ''<<file.m'' for example) Thanks. The first answer looks promising, however I get FrontEndObject::notavail A front end is not available (per docs it is "UseFrontEnd" by the way.) Perhaps a path issue, however even after setting $FrontEndLaunchCommand no joy.. Re: Initialization Cell -- that

Mathematica fast 2D binning algorithm

醉酒当歌 提交于 2019-11-30 12:15:48
问题 I am having some trouble developing a suitably fast binning algorithm in Mathematica. I have a large (~100k elements) data set of the form T={{x1,y1,z1},{x2,y2,z2},....} and I want to bin it into a 2D array of around 100x100 bins, with the bin value being given by the sum of the Z values that fall into each bin. Currently I am iterating through each element of the table, using Select to pick out which bin it is supposed to be in based on lists of bin boundaries, and adding the z value to a

Keyboard shortcut to Un/Comment out code in Mathematica 7?

雨燕双飞 提交于 2019-11-30 12:13:03
问题 A keyboard shortcut to comment/uncomment out a piece of code is common in other programming IDE's for languages like Java, .Net. I find it a very useful technique when experimenting through trial and error to temporarily comment out and uncomment lines, words and parts of the code to find out what is and isn't working. I cannot find any such keyboard shortcut on the Mathematica front end in version 7. I know that it is possible to comment out code by selecting the code, right mouse click and

Mathematica Table function

主宰稳场 提交于 2019-11-30 12:12:21
I'm running a Table function which will take too much time to complete. I wanted to know if there's a way to retrieve the results computed so far. Leonid Shifrin The proposed solution Here is a version of Table that is Abort -able and will keep the intermediate results collected so far. It is a modified version of the solution posted here . ClearAll[abortableTable]; SetAttributes[abortableTable, HoldAll]; abortableTable[expr_, iter__List] := Module[{indices, indexedRes, sowTag}, SetDelayed @@ Prepend[Thread[Map[Take[#, 1] &, List @@ Hold @@@ Hold[iter]], Hold], indices]; indexedRes = If[# ===

How to Block Symbols without evaluating them?

橙三吉。 提交于 2019-11-30 12:07:43
问题 Suppose I have a list of names of Symbol s: f1 := Print["f1 is evaluated!"]; list = {"f1", "f2"}; The obvious way to Block these Symbol s leads to evaluation of them: In[19]:= With[{list=Symbol/@list},Block[list,f1//ToString]] During evaluation of In[19]:= f1 is evaluated! During evaluation of In[19]:= f1 is evaluated! Out[19]= Null But without evaluation we could Block them without any problem: In[20]:= Block[{f1, f2}, f1 // ToString] Out[20]= "f1" Is it possible to inject this list into the