wolfram-mathematica

What generates the In/Out CellLabels in Mathematica and how can I add automatic Timing to them?

筅森魡賤 提交于 2019-12-05 23:29:30
问题 When Mathematica evaluates a cell, it gives the Input cell and Output cell the CellLabels In[$Line]:= and Out[$Line]= where $Line is a counter that gets incremented on each evaluated input. If you input something like TraditionalForm[expr] or TeXForm[expr] (or any other *Form from $OutputForms ) then the name of the form also gets added to the Output cell's label. eg Out[1]//TraditionalForm= . I can't find any way of customising these labels. They can be disabled in the Preferences dialog.

Simplifying a very long symbolic expression by automatically introducing temporal variables or in any other way

末鹿安然 提交于 2019-12-05 22:47:17
问题 After attempting to solve a symbolic math problem, I got an expression with about 17000 characters. I am using the symbolic toolbox for Matlab, but I am open to any suggestion (Mathematica, whatever). For obvious reasons, I won't copy-paste the expression straight into the question. Here is a link instead. Running the Matlab commands simplify and simple , and even attempts to collect didn't improve the situation (Some got it worse). But I am wondering, I don't care if the expression is

mathematica code in email and keeping formatting the same as notebook

点点圈 提交于 2019-12-05 22:26:32
问题 As we all know, when one is to send email with some Mathematica code in it, the practice is to do the following Select the cell, Cell->ConvertTo -> INPUT FORM, then COPY AS TEXT Then paste the code into the email, or any other exchange media it is. The only problem with the above, is that when, on the other end, one copies the text from email and paste it back into a Mathematica notebook, the code will then no longer appear as it was in the original form (before the converting to INPUT FORM).

Mathematica OO System ( or alternatives )?

六眼飞鱼酱① 提交于 2019-12-05 21:47:21
OO system is a free, open source package for OOP in Mathematica. By using OO-System I hope to benefit from the best of both worlds (OOP/Functional). What are the do's and don'ts of OO System for Mathematica? Are you aware of (better) open source alternatives? Are you willing to show some of your OO-system classes? Any remarks about OOP in general with Mathematica ? A disclaimer: I have not used any of the existing OO mma extensions (and OO System in particular), so this post is based on general arguments (but I used OO heavily when worked in Java, and used some OO elements in mma, which I

Mathematica: Obtaining graphics primitives and directives

旧时模样 提交于 2019-12-05 21:31:10
How do you obtain graphic primitives and directives from a Graphics object? Leonid Shifrin showed how to remove them in the post Mathematica: Removing graphics primitives . I tried applying something similar but I can't get what I want. Consider this example: g1 = ListPlot3D[ {{0, -1, 0}, {0, 1, 0}, {-1, 0, 1}, {1, 0, 1}, {-1, 1, 1}}, Mesh -> {2, 2}, Boxed -> False, Axes -> False, ViewPoint -> {2, -2, 1}, ViewVertical -> {0, 0, 1}, MeshStyle -> RGBColor[0, 0.5, 0], BoundaryStyle -> RGBColor[1, 0.5, 0] ]; g2 = ImportString[ExportString[g1, "PDF", Background -> None], "PDF"][[1]] g2 is now a

Line Style using Graphics3D in Mathematica

谁说胖子不能爱 提交于 2019-12-05 21:06:05
Consider the following : cAxes = {{{0, 0, 0}, {0, 0, 1}}, {{0, 0, 0}, {0, 1, 0}}, {{0, 0,0}, {1, 0, 0}}}; Graphics3D[{Line /@ cAxes}, Boxed -> False] How can Style differently the 3 lines ? The answer above are good, but I want to show some alternatives. I show that it is possible to use Style for this, and that Tube is an interesting alternative to Line . cAxes = {{{0, 0, 0}, {0, 0, 1}}, {{0, 0, 0}, {0, 1, 0}}, {{0, 0, 0}, {1, 0, 0}}}; tubes = Tube@# ~Style~ #2 & ~MapThread~ {cAxes, {Red, Green, Blue}}; Graphics3D[tubes, Boxed -> False] Here's an example: colors = {Red, Green, Blue}; style =

Selecting data from a table in mathematica

百般思念 提交于 2019-12-05 20:53:18
I'm trying to write a function that will take select the first element in the table that satisfies a criteria. For example, if I am given the following table with times in the first column and number of people infected with a disease in the second, I want to write an argument that will return the time where at least 100 people are infected. 0 1 1 2 2 4 3 8 4 15 5 29 6 50 7 88 8 130 9 157 10 180 11 191 12 196 13 199 14 200 So from this table, I want the arguemnt to tell me that at 8 seconds, at least 100 people were infected. I tried using SELECT to do this, but I'm not sure how to use SELECT

May I write {x,a,b}//Do[…,#]& instead of Do[…,{x,a,b}]?

泄露秘密 提交于 2019-12-05 20:44:26
问题 I'm in love with Ruby. In this language all core functions are actually methods. That's why I prefer postfix notation – when the data, which I want to process is placed left from the body of anonymous processing function, for example: array.map{...} . I believe, that it has advantages in how easy is this code to read. But Mathetica, being functional (yeah, it can be procedural if you want) dictates a style, where Function name is placed left from the data. As we can see in its manuals, // is

Firewall settings for remote kernel to work (Mathematica)

强颜欢笑 提交于 2019-12-05 20:00:14
问题 What firewall settings must be used on the remote machine for a remote kernel connection to work? In particular I'm interested in connecting from Windows (front end) to a Linux machine (kernel). 回答1: I don't know the exact ports, but this is a generic way to solve most such firewall issues: (at least with connections using TCP) Try to use the 'netstat -n' command and see which remote ports do the connections that are being blocked by the firewall use. They should be in the SYN_SENT state or

How to define a function that commutes with D in Mathematica

﹥>﹥吖頭↗ 提交于 2019-12-05 19:31:33
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 redefining the D operator (although I'm nowhere near understanding completely my own code). PartialDerivative[x_