wolfram-mathematica

Plotting phase portraits in Python using polar coordinates

末鹿安然 提交于 2021-02-10 14:26:48
问题 I need a phase portrait of the following nonlinear system given in polar form... \dot{r} = 0.5*(r - r^3) \dot{\theta} = 1 I know how to do it in Mathematica... field1 = {0.5*(r - r^3), 1}; p1 = StreamPlot[Evaluate@TransformedField["Polar" -> "Cartesian", field1, {r, \[Theta]} -> {x, y}], {x, -3, 3}, {y, -3, 3}, Axes -> True, StreamStyle -> Gray, ImageSize -> Large]; Show[p1, AxesLabel->{x,y}, ImageSize -> Large] How can I do the same using pyplot.quiver in Python? 回答1: Just very naive

detecting arc and circle shapes in vector array with a range

谁说胖子不能爱 提交于 2021-02-07 19:22:10
问题 I have an array of 2d vertices and I want to detect if there are any arch or circle shapes in a array. Sometimes the values are not that precise and I need a small range. Here are the values. The 3rd verticle value value remains 0: verticle: -0.014848, -13.2684, 0 angle : 0.141274 verticle: -0.0174556, -4.84519, 0 angle : 90 verticle: 0, 0, 0 angle : 90 verticle: -9.53674e-07, 14.14, 0 angle : 40.7168 verticle: -12.1101, 14.0709, 0 angle : 7.94458 verticle: -12.0996, 10.6442, 0 angle : 0

Java JBoss Fatal error: cannot find the required native library named JLinkNativeLibrary

帅比萌擦擦* 提交于 2021-01-29 02:30:46
问题 I'm trying to work with Wolfram Mathematica Kernel from Java Web Application using JBoss. Here is a Main Class. public class Main { static KernelLink ml; static KernelLink ml2; public Main(){ String path = "-linkmode launch -linkname 'C:/Program Files/Wolfram Research/Mathematica/9.0/MathKernel.exe'"; try { ml = MathLinkFactory.createKernelLink(path);// подключаем ядро ml.setComplexClass(MyComplex.class); System.out.println(ml.getComplexClass()); ml.discardAnswer(); ml.evaluate("<<hexagon.m")

Sorting lists inside nested lists

我们两清 提交于 2020-08-06 15:13:28
问题 I have a nested list: {{9, 8, 7}, {8, 7, 6}, {7, 6, 5}, {6, 5, 4}, {5, 4, 3}, {4, 3, 2}, {3, 2, 1}} I need to sort the lists within the list to create: {{7, 8, 9}, {6, 7, 8}, {5, 6, 7}, {4, 5, 6}, {3, 4, 5}, {2, 3, 4}, (1, 2, 3}} How do I do this? 回答1: You want the Map function, which applies a function to each element of a list. That is, Map[f, {1, 2, 3}] gives {f[1], f[2], f[3]} . In this case, you can use Map[Sort, list] . Map also has an infix operator, /@ : In[1]:= Map[Sort, {{9, 8, 7},

How does a system like Wolfram Alpha or Mathematica solve equations?

岁酱吖の 提交于 2020-05-22 16:09:13
问题 I'm building a web-based programming language partially inspired by Prolog and Haskell (don't laugh). It already has quite a bit of functionality, you can check out the prototype at http://www.lastcalc.com/. You can see the source here and read about the architecture here. Remember it's a prototype. Currently LastCalc cannot simplify expressions or solve equations. Rather than hard-coding this in Java, I would like to enhance the fundamental language such that it can be extended to do these

How to order points anti clockwise

久未见 提交于 2020-02-27 05:15:49
问题 Lets take thess points. pt={{-4.65371,0.1},{-4.68489,0.103169},{-4.78341,0.104834},{-4.83897,0.100757}, {-4.92102,0.0949725},{-4.93456,0.100181},{-4.89166,0.122666},{-4.78298,0.129514}, {-4.72723,0.121442},{-4.68355,0.11023},{-4.65371,0.1},{-4.66924,0.10173}, {-4.93059,0.0966989},{-4.93259,0.105094},{-4.91074,0.116966},{-4.90635,0.094878}, {-4.66846,0.105327},{-4.92647,0.0956182},{-4.93433,0.102498},{-4.9333,0.0982262}, {-4.66257,0.10102}}; Now they are in certain order (for me is a disorder!

How to order points anti clockwise

生来就可爱ヽ(ⅴ<●) 提交于 2020-02-27 05:15:29
问题 Lets take thess points. pt={{-4.65371,0.1},{-4.68489,0.103169},{-4.78341,0.104834},{-4.83897,0.100757}, {-4.92102,0.0949725},{-4.93456,0.100181},{-4.89166,0.122666},{-4.78298,0.129514}, {-4.72723,0.121442},{-4.68355,0.11023},{-4.65371,0.1},{-4.66924,0.10173}, {-4.93059,0.0966989},{-4.93259,0.105094},{-4.91074,0.116966},{-4.90635,0.094878}, {-4.66846,0.105327},{-4.92647,0.0956182},{-4.93433,0.102498},{-4.9333,0.0982262}, {-4.66257,0.10102}}; Now they are in certain order (for me is a disorder!

In Mathematica, what does @@@ mean?

社会主义新天地 提交于 2020-02-10 01:39:45
问题 I've been working through problems on Project Euler, and some of the solutions that other people have posted use a triple-at-sign, i.e. '@@@'. In the help browser for v7, I find an entry for @@ (which says it's the infix version of 'Apply') but none for @@@. What does it mean? EDIT: Here's an example, which I think I can post without violating the spirit of Project Euler: bloc[n_, f_][t_] := {f @@@ #, #~Tr~f} & /@ Join @@ Partition[t, {n, n}, 1]; 回答1: As others have noted, @@@ is, technically

Debugging a working program on Mathematica 5 with Mathematica 7

前提是你 提交于 2020-02-02 11:24:24
问题 I'm currently reading the Mathematica Guidebooks for Programming and I was trying to work out one of the very first program of the book. Basically, when I run the following program: Plot3D[{Re[Exp[1/(x + I y)]]}, {x, -0.02, 0.022}, {y, -0.04, 0.042}, PlotRange -> {-1, 8}, PlotPoints -> 120, Mesh -> False, ColorFunction -> Function[{x1, x2, x3}, Hue[Arg[Exp[1/(x1 + I x2)]]]]] either I get a 1/0 error and e^\infinity error or, if I lower the PlotPoints options to, say, 60, an overflow error. I

How to form submatrices with some non-consecutive rows and columns of a matrix

泄露秘密 提交于 2020-02-02 04:10:35
问题 I have a 10 by 10 matrix. I want to form a sub-matrix from this main matrix, using all the rows and columns except the 1st, 2nd and 8th columns and rows. I know Part can be used to form the sub-matrix, but the examples are mostly about forming the sub-matrix using consecutive rows and columns only. 回答1: If this is your matrix: tst = RandomInteger[10, {10, 10}]; This will do the trick for the case at hand: tst[[{3, 4, 5, 6, 7, 9, 10}, {3, 4, 5, 6, 7, 9, 10}]] Instead of explicit list, you