wolfram-mathematica

How to expand the arithmetics of differential operators in mathematica

扶醉桌前 提交于 2019-12-11 01:39:43
问题 For example, I want mma to expand out the following differential operator (1+d/dx+x*d2/dy2)^2*(1+y*d/dy)^2 I found Nest is not good enough to do this sort of things. 回答1: A bit dated, but see http://library.wolfram.com/infocenter/Conferences/325/ The section "Some noncommutative algebraic manipulation" gives a few ways to go about this. The first example, defining a function called differentialOperate, is probably best suited for your purposes. ---edit, reedited--- Here is the code I use.

User defined Function coloring in Mathematica

十年热恋 提交于 2019-12-11 00:32:47
问题 Merged with Syntax Coloring In Mathematica. Is there a trick to assign a specific color to "user-defined" function such as "function" below : function[x_]:=x^3 Thanks to Mr.Wizard we are able to color all user defined symbols ( Syntax Coloring In Mathematica) Would there be a way to refine the solution to have different colors for Functions symbols, Variables symbols & Options symbols ? EDIT : Image for Simon 来源: https://stackoverflow.com/questions/6165977/user-defined-function-coloring-in

why is there significant double precision difference between Matlab and Mathematica?

我与影子孤独终老i 提交于 2019-12-11 00:07:30
问题 I created a random double precision value in Matlab by x = rand(1,1); then display all possible digits of x by vpa(x,100) and obtain: 0.2238119394911369 7971853298440692014992237091064453125 I save x to a .mat file, and import it into Mathematica, and then convert it: y = N[FromDigits[RealDigits[x]],100] and obtain: 0.2238119394911369 0000 Then go back to Matlab and use (copy and paste all the Mathematica digits to Matlab): vpa(0.22381193949113690000,100) and obtain: 0.22381193949113689

How to specify x-axis in List when using Mathematicia and ListPlot?

Deadly 提交于 2019-12-10 23:46:37
问题 I have imported a csv file into a list with this stmt: data1 = Take[Import["D:\\_reports\\optim_5_60_b_2.csv", "CSV"], 5] Which gives: {{178, 8, 9, 1}, {152, 2, 8, 1}, {378, 8, 9, 2}, {343, 3, 7.5`, 2}, {143, 3, 7.5`, 1}} I would like to create a plot where the x-axis is based on the first field: 178,152,378,343,143,373,743,352 And the plot creates a line for each subsequent field, so the 2nd field is: 8,2,8,3,3,3,3,2 This would be the first line on the y-axis, the other y-axis values would

Distance to a MultivariateStatistics median

烈酒焚心 提交于 2019-12-10 23:38:47
问题 I have a population of objects (each of which is described by a sequence of real numbers), and I'd like to find the "distance" between a single test object and the median of the population. I believe that I can use the MultivariateStatistics package to characterize my population, and then either SpatialMedian[] or SimplexMedian[] to find the "center." My goal is to find the distance between a test object and this median. I gather that a simple Euclidean distance would be incorrect, because I

how to apply a rule involving a hundred variables in mathematica

橙三吉。 提交于 2019-12-10 22:45:44
问题 I have an expression which involves x1,x2,...,x100, I also have a list lst with 100 elements, how to apply the rule to this expression to achieve something like the following: exp/.{x1->lst[[1]],x2->lst[[2]],...,x100->lst[[100]]} Thanks! 回答1: exp /. Table[Symbol["x" <> ToString[i]] -> lst[[i]], {i, 1, 100}] So you don't need to write X1,X2, ... X100 回答2: You can use Thread to apply the rules to each pair of expressions: Thread[{a, b, c} -> {1, 2, 3}] 回答3: It is much simpler and more

Mathematica: Removing graphics primitives

試著忘記壹切 提交于 2019-12-10 22:38:14
问题 Given that g is a graphics object with primitives such as Line s and Polygon s, how do you remove some of them? To add more primitives to an existing graphics object we can use Show , for instance: Show[g, g2] where g2 is another graphics object with other primitives. But how do you remove unwanted primitive objects? Take a look at the following ListPlot3D[{{0, 0, 1}, {1, 0, 0}, {0, 1, 0}, {1, 1, 0}}, Mesh -> {1, 1}] Now, for the input form: InputForm[ ListPlot3D[{{0, 0, 1}, {1, 0, 0}, {0, 1,

Possible to put equation's expression near its graphic representation?

三世轮回 提交于 2019-12-10 21:47:52
问题 Is it possible that when I Plot a function in Mathematica, it will automatically put near it it's equation(i.e. y = 2x) or even some other text? At first glance I don't find any option for it, but if there is one I'd like to know. Thanks 回答1: Using Mathematica 6 or higher, I often use Tooltip to help me identify plot curves: Plot[Tooltip[Sin[x]], {x, 0, 8 Pi}] Alas, this is only useful when using the graph interactively since you must hover the mouse cursor over the curve. It doesn't work so

What is the idiomatic way of counting the number of elements matching predicate?

廉价感情. 提交于 2019-12-10 21:33:32
问题 Is there a better way to count the number of elements for which the predicate function is true, other than this: PredCount[lst_, pred_] := Length@Select[lst, pred]; I'm asking because it seems inefficient to construct a subset of lst with Select[] , and because Count[] only works with patterns. In my use case, the function PredCount is called many times with a large lst . 回答1: You can often do this by turning your predicate into a pattern with a condition. For example: Count[list, x_/;x>5]

Detailed Calculation of RGB to Graylevel by Mathematica

青春壹個敷衍的年華 提交于 2019-12-10 19:59:01
问题 I tried ColorConvert[img, "Grayscale"] to convert the RGB to Graylevel . I am wondering the detailed calculation by mathematica.. Gray level= square(R^2+G^2+B^2)? or something else? 回答1: We can obtain the exact values used by mathematica by making up a 3 pixel image with pure red,green,blue and converting it: lvec = First@ ImageData[ ColorConvert[Image[{{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}}], "GrayScale"]] {0.299, 0.587, 0.114} Note these are the "Rec. 601 luna coefficients" per http://en