wolfram-mathematica

Convert Mathematica equations into R code

我怕爱的太早我们不能终老 提交于 2019-12-12 11:19:19
问题 Is there an easy way to convert Mathematica equations into R code? I have several equations that consist of dozens of terms with subscripts, superscripts, and greek letters. For example, here's a small part of one equation in Latex format: m_2_2= 48 b_1 c_2^2 d_1 \rho ^4+48 b_2 c_1^2 d_2 \rho ^4+216 b_2 c_1 c_2 d_1 \rho ^3+216 b_1 c_1 c_2 d_2 \rho ^3+96 b_1 c_2^2 d_1 \rho ^2+96 b_2 c_1^2 d_2 \rho ^2 + ... I can copy from Mathematica as plain text, input text, Latex, or MathML, but how can I

How to set values to symbols

≡放荡痞女 提交于 2019-12-12 11:14:37
问题 I would like to set values to a list of variables, like so: list[[1]] = 2 and if list[[1]] is a , then a will now be equal to two. How can I achieve this? 回答1: Well, let's try it naively: Make a list: In[1]:= ClearAll[list, a, b, c]; list = {a, b, c}; It's as we expect it: In[3]:= list Out[3]= {a, b, c} Set the first element to 2: In[4]:= list[[1]] = 2 Out[4]= 2 In[5]:= list Out[5]= {2, b, c} That doesn't affect a: In[6]:= a Out[6]= a Start again: In[7]:= ClearAll[list, a, b, c]; list = {a, b

Color Plot by order of points in list - Mathematica

心已入冬 提交于 2019-12-12 10:53:41
问题 I've got a list of three dimensional points, ordered by time. Is there a way to plot the points so that I can get a visual representation that also includes information on where in the list the point occurred? My initial thought is to find a way to color the points by the order in which they were plotted. ListPlot3D drapes a sheet over the points, with no regard to the order which they were plotted. ListPointPlot just shows the points, but gives no indication as to the order in which they

How do I label different curves in Mathematica?

南笙酒味 提交于 2019-12-12 10:19:04
问题 How can I label each of these lines separately : Plot[{{5 + 2 x}, {6 + x}}, {x, 0, 10}] 回答1: There's some nice code that allows you to do this dynamically in an answer to How to annotate multiple datasets in ListPlots. There's also a LabelPlot command defined in the Technical Note Labeling Curves in Plots Of course, if you don't have too many images to make, then it's not hard to manually add the labels in using Epilog, for example fns[x_] := {5 + 2 x, 6 + x}; len := Length[fns[x]]; Plot

A programming challenge with Mathematica

笑着哭i 提交于 2019-12-12 10:14:39
问题 I am interfacing an external program with Mathematica. I am creating an input file for the external program. Its about converting geometry data from a Mathematica generated graphics into a predefined format. Here is an example Geometry. Figure 1 The geometry can be described in many ways in Mathematica. One laborious way is the following. dat={{1.,-1.,0.},{0.,-1.,0.5},{0.,-1.,-0.5},{1.,-0.3333,0.},{0.,-0.3333,0.5}, {0.,-0.3333,-0.5},{1.,0.3333,0.},{0.,0.3333,0.5},{0.,0.3333,-0.5},{1.,1.,0.},

Noncommutative Multiplication and Negative coeffcients at the Beginning of an Expression in Mathematica

我与影子孤独终老i 提交于 2019-12-12 09:49:40
问题 With the help of some very gracious stackoverflow contributors in this post, I have the following new definition for NonCommutativeMultiply (**) in Mathematica: Unprotect[NonCommutativeMultiply]; ClearAll[NonCommutativeMultiply] NonCommutativeMultiply[] := 1 NonCommutativeMultiply[___, 0, ___] := 0 NonCommutativeMultiply[a___, 1, b___] := a ** b NonCommutativeMultiply[a___, i_Integer, b___] := i*a ** b NonCommutativeMultiply[a_] := a c___ ** Subscript[a_, i_] ** Subscript[b_, j_] ** d___ /; i

Plotting mathematica data with python

孤人 提交于 2019-12-12 08:59:31
问题 This question is related to my previous question on "publication quality plots in python". I am trying to write a post processor (a bash script/python combo) that would comb through the thousands (literally!) of data files I have and plot data. The trouble is, my data files are from mathematica. I have interpolating function polynomials in Mathematica (mma) as a result of an NDSolve operation on a non-linear partial differential equation. I was able to deconstruct/extract discrete data out of

Create a Function for Customized Tabular Representation

混江龙づ霸主 提交于 2019-12-12 08:48:06
问题 I use the code below get an overview of parts of my data. What would be the best way to make a function out of the below code ? It would take a dataList as well as some graphical options (such as colors) as arguments and return a customized tabular representation as shown below. overviewtheData=Text@Grid[{Map[Rotate[Text[#], 90Degree]&,data[[1]]]}~Join~data[[2;;]], Background->{{{{White,Pink}},{1->White}}}, Dividers->{All,{1->True,2->True,0->True}}, ItemSize->{1->5,Automatic}, Alignment->Top,

Mathematica execution-time bug: symbol names

我的梦境 提交于 2019-12-12 08:21:59
问题 There is a strange bug that has been in Mathematica for years, at least since version 5.1, and persisting through version 7. Module[{f, L}, L = f[]; Do[L = f[L, i], {i, 10^4}]] // Timing {0.015, Null} Module[{weirdness, L}, L = weirdness[]; Do[L = weirdness[L, i], {i, 10^4}]] // Timing {2.266, Null} What causes this? Is it a hashing problem? Is it fixed in Version 8? Is there a way to know what symbol names cause a slowdown, other than testing? 回答1: What causes this? Is it a hashing problem?

Update Manipulate[]'d plots when parameters change

时光毁灭记忆、已成空白 提交于 2019-12-12 08:06:22
问题 I've been fighting with Mathematica's Manipulate function for the last few days for a project. I'm working on tweaking assumptions and boundary conditions that go into a physical model. For this, I want to be able to plot different equations and adjust the parameters and have the graphs update on the fly. Manipulate seems to be the perfect tool for the job -- except that I can't get it to work. The plots won't update when the parameters are changed. Basic example: a =.; b =.; c =.; func1[x_]