wolfram-mathematica

How can I show % values on the y axis of a plot?

拟墨画扇 提交于 2019-12-13 12:06:16
问题 In any Mathematica chart or plot how can I show % values on the y axis? I may have data like this: data = {{{2010, 8, 3}, 0.}, {{2010, 8, 31}, -0.052208}, {{2010, 9, 30}, 0.008221}, {{2010, 10, 29}, 0.133203}, {{2010, 11, 30}, 0.044557}, {{2010, 12, 31}, 0.164891}, {{2011, 1, 31}, 0.055141}, {{2011, 2, 28}, 0.114801}, {{2011, 3, 31}, 0.170501}, {{2011, 4, 29}, 0.347566}, {{2011, 5, 31}, 0.461358}, {{2011, 6, 30}, 0.244649}, {{2011, 7, 29}, 0.41939}, {{2011, 8, 31}, 0.589874}, {{2011, 9, 30},

Mathematica solving differential equations

ε祈祈猫儿з 提交于 2019-12-13 04:45:03
问题 I would like to numerically find the solution to u_t - u_xx - u_yy = f on the square y ∈ [0,1], x ∈ [0,1] where f=1 if in the unit circle and f=0 otherwise. The boundary conditions are u=0 on all four edges. I have been trying to use ND-solve for ages but I keep getting error messages. I'm new to Mathematica so I don't know how to define f before ND-Solve. Thank you in advance. 回答1: The Mathematica help files are incredibly complete for stuff like this. I'm going to reference the online

How to use InterpolatingFunction generated by Mathematica 5.2 in version 8.0.1?

别等时光非礼了梦想. 提交于 2019-12-13 02:30:20
问题 Let us interpolate the same data using Mathematica 5.2, 7.0.1 and 8.0.1: Interpolation[{{0, 0}, {1, 1}, {2, 3}, {3, 4}, {4, 3}, {5, 0}}] // InputForm The outputs are: Mathematica 5.2: InterpolatingFunction[{{0, 5}}, {2, 0, True, False, {3}, {0}}, {{0, 1, 2, 3, 4, 5}}, {{0}, {1}, {3}, {4}, {3}, {0}}, {Automatic}] Mathematica 7.0.1: InterpolatingFunction[{{0, 5}}, {3, 1, 0, {6}, {4}, 0, 0, 0, 0}, {{0, 1, 2, 3, 4, 5}}, {{0}, {1}, {3}, {4}, {3}, {0}}, {Automatic}] Mathematica 8.0.1:

Fast list-product sign for PackedArray?

橙三吉。 提交于 2019-12-12 19:58:02
问题 As a continuation of my previous question, Simon's method to find the list product of a PackedArray is fast, but it does not work with negative values. This can be "fixed" by Abs with minimal time penalty, but the sign is lost, so I will need to find the product sign separately. The fastest method that I tried is EvenQ @ Total @ UnitStep[-lst] lst = RandomReal[{-2, 2}, 5000000]; Do[ EvenQ@Total@UnitStep[-lst], {30} ] // Timing Out[]= {3.062, Null} Is there a faster way? 回答1: This is a little

Mathematica's puzzling interpretation of #^2 & /@ Range[n]

冷暖自知 提交于 2019-12-12 14:55:37
问题 I'm puzzled by Mathematica's responses to the following: ClearAll[n] #^2 & /@ Range[n] #^2 & /@ Range[n] // StandardForm It seems that even Mathematica (8.0) doesn't believe what it has just said: #^2 & /@ Range[5] Range[5^2] Any thoughts about what is happening? Edit: The original context for this question was the following. I had written PrimeOmega[Range[n]] - PrimeNu[Range[n]] and since n was going to be very large (2^50), I thought I might save time by rewriting it as: PrimeOmega[#] -

Replacing Disks by Crosses using Graphics in Mathematica

放肆的年华 提交于 2019-12-12 14:36:06
问题 Consider the following list : dalist = {{47.9913, 11.127, 208}, {47.5212, 10.3002, 208}, {49.7695, 9.96838, 160}, {48.625, 12.7042, 436}} Those are coordinatees of Eye fixations on a screen where, within each sublist, #1 is the X coordinate, #2 the Y coordinate and #3 , the duration spent at that particular location I then use the following : Disk[{#[[1]], #[[2]]}, 3N[#[[3]]/Total[dalist[[All, 3]]]]] & /@ dalist to draw disk with duration weighted diameter. I would like to draw cross instead

Solving power towers

时间秒杀一切 提交于 2019-12-12 13:31:22
问题 a=2^Power[10^6, 10^9] 3^Power[4^9, 7^5] TwoTower[n_] := Nest[2^# &, 1, n] What's the smallest n such that TwoTower[n]>a ? This question had a pen-and-paper answer on Quora, is there a way to use Mathematica here? 回答1: Just some thoughts (did not carefully check). If we follow the suggestion in that link and start taking logs (base 2), first thing which seems obvious is that we can safely forget the prefactor (the power of 3), since Log[Log[a*b]] = Log[Log[a]+Log[b]] = Log[Log[a]]+Log[1+Log[b]

More efficient way of calculating this recurrence relation in Mathematica

 ̄綄美尐妖づ 提交于 2019-12-12 12:46:32
问题 Verbeia opened up a rather interesting discussion on the performance of the functional programming style in Mathematica. It can be found here: What is the most efficient way to construct large block matrices in Mathematica? ) I'm working on a problem, and after doing some timing of my code one particularly time consuming portion is where I calculate entries of a matrix through a recurrence relation: c = Table[0, {2L+1}, {2L+1}]; c[[1, 1]] = 1; Do[c[[i, i]] = e[[i - 1]] c[[i - 1, i - 1]], {i,

If doing “math foo bar”, how to get foo and bar inside Mathematica?

坚强是说给别人听的谎言 提交于 2019-12-12 12:35:50
问题 If I run Mathematica as "math foo bar", what variable(s) hold foo and bar? I'm guessing it's $Something, but haven't found it. Googling told me Mathematica accepts command-line options like -pwpath, -pwfile, but I couldn't find the right search phrase for actual command line arguments (not options). 回答1: The $CommandLine variable holds the command line arguments. $ math foo bar In[1]:= $CommandLine Out[1]= {math, foo, bar} 来源: https://stackoverflow.com/questions/7149252/if-doing-math-foo-bar

Is it possible to create MakeBoxesStop wrapper?

旧时模样 提交于 2019-12-12 12:08:59
问题 It is known that output expressions are passed through MakeBoxes to turn the graphics expressions into the box language which the front end uses to represent graphics (when $Output has default option FormatType->StandardForm ). For example, if we evaluate: HoldComplete[Graphics[Disk[]]] we get a disk wrapped by HoldComplete : This is because HoldComplete does not stop MakeBoxes from converting its contents to typeset expression: In[4]:= MakeBoxes@HoldComplete[Graphics[Disk[]]] Out[4]= RowBox[