wolfram-mathematica

Trouble redefining Protected symbols and system functions [duplicate]

China☆狼群 提交于 2019-12-06 03:05:47
问题 This question already has an answer here : Why do I have to evaluate this twice? (1 answer) Closed 2 years ago . Found trying to use the usual trick to redefine GaussianFilter[ ]: out[x_]:=Print["(*"<>ToString@x<>"*)"]; (* Redefining Circle[ ] works as expected*) Unprotect[Circle]; Circle[a_,args__]:= Block[{$i=True},{"Circle",a}]/;!TrueQ[$i]; Protect[Circle]; out@Circle[{0,1},1,{0,2Pi}] (*{Circle, {0, 1}}*) (* Redefining GaussianFilter[ ] does not*) Unprotect[GaussianFilter]; GaussianFilter

how does mathematica determine which rule to use first in substitution

喜欢而已 提交于 2019-12-06 02:34:57
问题 I am wondering if given multiple substitution rules, how does mma determine which to apply first in case of collision. An example is: x^3 + x^2*s + x^3*s^2 + s x /. {x -> 0, x^_?OddQ -> 2} Thanks. 回答1: Mathematica has a mechanism which is able to determine the relative generality of the rules in simple cases, for example it understands that ___ (BlankNullSequence) is more general than __ (BlankSequence). So, when it can, it reorders global definitions according to it. It is important to

How to format two separate lists in columns, rather than rows in Mathematica?

偶尔善良 提交于 2019-12-06 02:31:36
问题 This seems like it should be a piece of cake, but I haven't found the answer in Mathematica's documentation. Say I have two separate lists, for example x={1,2,3,4,5} and y={1,4,9,16,25}. I want to format these lists as a table with each list as a column, like this: x y 1 1 2 4 3 9 4 16 5 25 But if I do TableForm[x,y], I get only the first column, like this: 1 2 3 4 5 If I do Grid[{x,y}], I get a table, but formatted as rows instead of columns, like this: 1 2 3 4 5 1 4 9 16 25 Now, if I have

Converting graphics with ExportString

倖福魔咒の 提交于 2019-12-06 01:57:22
问题 Can ExportString export an EMF or GIF? In this demo streamoutput.emf somehow gets mangled: Quiet[DeleteFile["C:\\Temp\\thisworks.emf"]]; Quiet[DeleteFile["C:\\Temp\\streamoutput.emf"]]; graphic = Graphics[{Thick, Red, Circle[{#, 0}] & /@ Range[4], Black, Dashed, Line[{{0, 0}, {5, 0}}]}]; Export["C:\\Temp\\thisworks.emf", graphic, "EMF"]; file = ExportString[graphic, "EMF"]; stream = OpenWrite["C:\\Temp\\streamoutput.emf", BinaryFormat -> True]; Write[stream, file]; Close[stream]; If

How to subtract specific elements in a list using functional programming in Mathematica?

僤鯓⒐⒋嵵緔 提交于 2019-12-06 00:35:23
问题 I have a list of dates and values in the format: {{{dateInfo1},value1},{{dateInfo2},value2},...,{{dateInfoN},valueN}} With some actual dates and values: {{{1971, 1, 31, 0, 0, 0.}, 1.0118}, {{1971, 2, 28, 0, 0, 0}, 1.0075}, ..., {{2010, 5, 31, 0, 0, 0.}, 1.0403}} For those curious, it's a list of US versus CAD $ values pulled from the FRED database. I would like to simply subtract value1 from value 2, and then create a new list with data in the form of: {{{dateInfo1},0},{{dateInfo2},change1},.

Getting data out of CDF-player

百般思念 提交于 2019-12-06 00:20:51
问题 For my Skeptics working group I wrote a program in Mathematica to test a dowser's ability to assess the status of persons shown to them by means of photographs. For a null measurement I distributed this document to my group's members in CDF form (the new v8 Computable Document Format, meant to be run with the CDF-player). On my computer (using mma) it all works fine, but the others can't export the data (the program does an export to an Excel file). On reading the fine print I see that the

NIntegrate fails to converge near a point that is not inside my definite integral?

断了今生、忘了曾经 提交于 2019-12-06 00:05:53
问题 This question was migrated from Cross Validated because it can be answered on Stack Overflow. Migrated 8 years ago . I am trying to calculate a definite integral. I write: NIntegrate[expression, {x, 0, 1}, WorkingPrecision -> 100] "expression" is described below. The WorkingPrecision was added in to help with another error. I get an error: "NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in x near {x} = {<<156>>}. NIntegrate obtained <<157>>

.NETLink Graphics producing PNG instead of EMF

北城以北 提交于 2019-12-06 00:02:29
The C# code below should produce an EMF, but viewing the output (in Vim) shows it to be a PNG. Perhaps someone on S.O. knows a good work-around or solution. MathKernel k = new MathKernel(); k.CaptureGraphics = true; k.GraphicsFormat = "Metafile"; k.Compute("Show[Graphics[{Thick, Blue, Circle[{#, 0}] & /@ Range[4], Black, Dashed, Line[{{0, 0}, {5, 0}}]}]]"); k.Graphics[0].Save("C:\\Temp\\file.emf", System.Drawing.Imaging.ImageFormat.Emf); So far I'm considering wrapping Show[Graphics...] in ExportString[... , "EMF"] and collecting the result using the MathKernel Result property. Addendum The

Building Application Packages with multple packages and references in Mathematica

久未见 提交于 2019-12-05 23:54:02
I am building an application package in Mathematica. The application contains multiple packages and refers to other application packages To set everything up, I have used and followed the application packages instructions of the help section of workbench which is also available at: http://reference.wolfram.com/workbench/index.jsp?topic=/com.wolfram.eclipse.help/html/tasks/applications/introduction.html under the Packages and Applications subsection but... I have implemented and tested single package application packages and the all seem to work fine. My Multiple packages and application is not

Instability while NDSolving a wave equation

流过昼夜 提交于 2019-12-05 23:46:20
问题 I'm trying to use NDSolve to solve a wave equations to check if it is easier and/or faster to use it instead of my old characteristics eq. method implementation. I'm getting a lot of instability that I don't get with the characteristics method, and since these are simple equations, I wonder what is wrong... (hopefully, not the physical aspect of the problem...) ans = Flatten@NDSolve[{ u[t, x]*D[d[t, x], x] + d[t, x]*D[u[t, x], x] + D[d[t, x], t] == 0, D[d[t, x], x] + u[t, x]/9.8*D[u[t, x], x]