Community RSS Feed
https://community.wolfram.com
RSS Feed for Wolfram Community showing any discussions in tag Wolfram Sciencesearch.php sorted by activePerformance of recursion code with radial polynomials
https://community.wolfram.com/groups/-/m/t/1549861
Consider the following code:
Clear[r, re, p, pmax, delta, imagesize, delta]
ClearSystemCache[]
re[0, r_] := Sqrt[8/Pi]*((1 - r)/r)^(1/4)*1;
re[1, r_] := Sqrt[8/Pi]*((1 - r)/r)^(1/4)*-1*2*(1 - 2*r);
re[p_, r_] := re[p, r] = Sqrt[8/Pi]*((1 - r)/r)^(1/4)*(-1)^p*(re[1, r]*re[p - 1, r] - re[p - 2, r]);
imagesize = 32;
pmax = 10;
delta = 2/imagesize;
Table[r = Sqrt[x^2 + y^2]; re[pmax, r], {x, -1 + delta/2, 1 - delta/2, delta}, {y, 1 - delta/2, -1 + delta/2, -delta}];
this code is to calculate the distance r from each pixel to point(0,0), then evaluate the radial polynomial as below:
![enter image description here][1]
for accuracy, I will use the recursion version:
![enter image description here][2]
when the imagesize and pmax increase, the time will become unacceptable. So, I would ask if we can use compile of other methods to speed up,like: for imagesize is 256 and pmax is 120, the time will be about 10 seconds. In my code, I also use the memoization to store the value during the evaluation which I will use in the future.
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=1.png&userId=1399878
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=2.png&userId=1399878look xu2018-11-14T00:34:36ZSolve the Nonlinear Schroedinger Equation with NDSolve?
https://community.wolfram.com/groups/-/m/t/1547257
I’m trying to solve the a special form of the Nonlinear Schroedinger Equation using NDSolve (see file attached) and run into the problem of “Warning: scaled local spatial error estimate of …”. This is presumably due to the low resolution along the tau-axis, while increasing this number leads to a massive increase in simulation time.
For instance if I set MinPoints=600, simulation time is 0.47s, while if MinPoints=2000, simulation time increases to 80s, while the warning is still present.
Does any one of you have experience in setting up NDSolve such that good solutions are obtained while maintaining a reasonable simulation speed, particular in the case of the Nonlinear Schrödinger Equation?
What is actually the meaning of “MaxStepSize”?
Thanks in advance. MarkusMarkus Schmidt2018-11-11T14:45:28ZHow to get grids on image and two slider2D in one control
https://community.wolfram.com/groups/-/m/t/1551195
Hello,
I require gridlines (x and y axis) on an imported image. However, the help shows gridlines/frametick only for Graphics and Plot functions
{image , FrameTicks-> {0,0}
In addition, on that image i need the two Slider 2D control in one panel and crop the selected region.. An idea of the final interface is show below;
![enter image description here][1]
{Slider2D[{.7, .3}, {.9, .6}]} ;
It appears but both are sliding together
{Slider2D[{.7, .3}], Slider2D[{1, .6}] ;
Appears in two different panes
Thank you for your kind usual help
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=IMAGEGRIDSLIDERFORFORUM.JPG&userId=971622Man Oj2018-11-15T01:58:19ZInterpretation of PolarPlot
https://community.wolfram.com/groups/-/m/t/1550055
Hello everyone, I tried to plot the function $r=-2t$ with $t$ in $[0,2\pi]$:
PolarPlot[-2 t, {t, 0, 2 Pi}, AxesLabel -> {x, y}]
![enter image description here][1]
When $t=\pi/4$, I have:
$$r=-\pi/2=-1.57$$
Through Get Coordinates, I saw the only point so that $r=-1.57$ is $("-"1.57, \,\, 3.9...)$. Why is the angle $3.9..=\pi+(\pi/4)$ different from $t=\pi/4$?
How can I get the above angle by using math formulas? I can't use the classic relationship $tan(t)=y/x$ because I don't know x and y (without looking the plot).
Thank you so much in advance.
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=48500.png&userId=818155Gennaro Arguzzi2018-11-14T10:52:41ZDoes anyone have a working Workbench installation?
https://community.wolfram.com/groups/-/m/t/1551183
I recently installed Workbench 2 on my laptop. I am running Win7 Pro x64. I followed the instructions on the Wolfram site:
I installed Java JDK version 8 build 192 (current)
Then Eclipse Java IDE 2018-09 version 4.9.0
I then added the Wolfram Workbench 2 from within Eclipse as called for in the Wolfram instructions.
I created a test project. The .m file contains a simple function definition:
![enter image description here][1]
You can see a set breakpoint in the image above. If I called if from a test notebook with no breakpoint it runs and returns a correct result. When called with the breakpoint I get a stream of errors, it does not break, and then gives the correct result:
x = f[1, 2, 3]
JLink`Java::excptn: A Java exception occurred: MathLinkException: 7: MathLink machine number overflow.
JLink`JavaNew::fail: Error calling constructor for class com.wolfram.eclipse.MEET.debug.MathematicaStackFrame.
JLink`Java::excptn: A Java exception occurred: MathLinkException: 7: MathLink machine number overflow.
JLink`JavaNew::fail: Error calling constructor for class com.wolfram.eclipse.MEET.debug.MathematicaStackFrame.
JLink`Java::argx: Method named handleBreakpoint defined in class com.wolfram.eclipse.MEET.debug.MathematicaBreakpointHandler was called with an incorrect number or type of arguments. The arguments, shown here in a list, were {27668229269427709719,{« JavaObject[com.wolfram.eclipse.MEET.debug.MathematicaStackFrame]»,« JavaObject[<<52>>]»,Failed,Failed,« JavaObject[<<52>>]»,« JavaObject[com.wolfram.eclipse.MEET.debug.MathematicaStackFrame]»},False}.
I do note that when I look at the Start menu items under Eclipse, I see "Eclipse Cpp 2018-09" and "Eclipse Java 2018-09" but no start entry for Wolfram. I don't know if this is expected.
All I can think is that there is some incompatibility between the versions I have installed. Does anyone know what the problem might be? Or, if this is a version issue, can anyone recommend a set of versions of Java, Eclipse, and Workbench that are known to work?
I have posted this to StackExchange also, but so far have received no replies.
Thanks and kind regards,
David
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=testf.PNG&userId=98179David Keith2018-11-14T23:55:01ZHow to get historical PE-ratios with FinancialData?
https://community.wolfram.com/groups/-/m/t/1550095
I have tried to get historical PE-ratios with FinancialData like this:
FinancialData["MSFT","PERatio",{2000,1,1}
But with this I only get one value, i.e. the latest PE-ratio. I had expected a whole list of them.
What do I do wrong?Laurens Wachters2018-11-14T13:08:49ZWhy is my implementation of a random network slower than the built-in?
https://community.wolfram.com/groups/-/m/t/1528378
Hello everybody,
I wanted for accademic purposes to implement the algorithm that generate a Random Graph of the Barabasi-Albert kind.
I know that there exsist already a built-in function that do exactly that, but for better understanding it I challenged myself to reproduce it.
I came up with this (relatively simple, but effective) code:
m0 = 2;(*How many edges to connect at each time step*)
n = 1000; \
(*How many nodes*)
g = CompleteGraph[m0, VertexLabels -> Automatic];
addBarabAlbert[g_Graph, m_Integer] :=
EdgeAdd[g,
Rule[m, #] & /@ RandomSample[VertexDegree@g -> VertexList@g, m0]]
Do[g = addBarabAlbert[g, i], {i, m0, n}]
Which I think it gives me a correct solution, in fact you can see from the code below that the degree of the vertexes follow a power-law of the same nature as the one generated with the built-in wolfram function.
The only problem is that my implementation is kind of slow (compared to the built-in) and I was wondering why.
Maybe knowing how I could set it up to make it faster will help me in the future with different problems.
Any ideas?
(In the attachment you find the brief code)Ektor Mariotti2018-10-22T23:32:50ZRe-evaluate a random generator to simulate a raquetball play?
https://community.wolfram.com/groups/-/m/t/1544882
Sorry - trying to learn the language...your playing racquetball , you only score when you serve. 60% chance of winning when you serve, 50% chance of winning when you don't serve
p5 := If[Random[] >= .5, 1, 0]
p6 := If[Random[] >= .6, 1, 0]
p := If[x < x + Evaluate[p6], x += 1, np];
np := If[Evaluate[p5] == 1, p, np];
score = Table[p, 10]
Do[Print[x]; p, 5]
the best I can do so far and it's not working, I want to see how far it will take to get to 21, I am not sure how Mathematica works as a programming language. Thanks for any help.Raymond Low2018-11-08T05:54:47ZSelect elements in my texts and count the frequency of each code "@..." ?
https://community.wolfram.com/groups/-/m/t/1550112
Good morning.
After processing a few texts, I ended up with an XML file with a lot of semantic anotation codes initiated by @ and a certain amount of numbers (7 or 8) to identify some words of my texts.
Example: It follows an incident<incident,Noun**@7307477**[incident]> at UC Berkeley when police<police,Noun**@8209687**[police,police force,constabulary,law]>
Does anyone know an efficient and (semi)automatic way to extract all these @xxxxxxx and compile them in a list so that I can count the frequency of each code?
I appreciate any help. Thank you.Eurov Stars2018-11-14T05:01:15ZPlot multi histogram in one image, where the bins are real numbers?
https://community.wolfram.com/groups/-/m/t/1550038
Hi,
I tried to plot the attached data with no success - can some one please advise?
I try with
Histogram[Flatten[Table[i, {i, Length[bincounts ]}, {j, bincounts [[i]]}]]]
, but it plot the X axis from 1-20, instead of -099-0.64
Thanks!
data = {0,0,0,0,0,0,0,0,0,0,2,0,1,2,2,5,1,3,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
data2 = {0 ,0 ,0 ,0 ,0 ,1 ,0 ,0 ,0 ,0 ,3 ,1 ,4 ,5 ,1 ,3 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 }
bins = {-0.99 ,-0.98 ,-0.97 ,-0.96 ,-0.95 ,-0.94 ,-0.93 ,-0.92 ,-0.91, -0.9 ,-0.89 ,-0.88 ,-0.87 ,-0.86 ,-0.85 ,-0.84 ,-0.83 ,-0.82 ,-0.81 ,-0.8 ,-0.79 ,-0.78 ,-0.77 ,-0.76 ,-0.75 ,-0.74 ,-0.73, -0.72 ,-0.71 ,-0.7 ,-0.69 ,-0.68, -0.67 ,-0.66 ,-0.65 ,-0.64 }Yossi Rab2018-11-14T09:46:23Z3D Design in Mathematica: Costa Rica Keychain
https://community.wolfram.com/groups/-/m/t/1549848
**[Open in Cloud][1]** | **[See Original][2]** | **Download to Desktop via Attachments Below**
Hi everyone! Welcome back to another 3D Design in Mathematica Tutorial. Last time I showed how to create a [polyhedral terrarium][3]. Today I will use Mathematica's MeshRegion command to design a keychain shaped like a country. I had the opportunity to visit Costa Rica in February 2017 and especially enjoyed my visit to the cloud forests of [Monteverde][4], so let's choose Costa Rica for our example.
![enter image description here][5]
##Step One: Import the shape of Costa Rica
We'll be relying on one of the strengths of Mathematica and the whole Wolfram suite—its vast amount of [curated data][6]. The command [CountryData][7] can access diverse information about countries such as their GDP, their population, their borders, their languages, and even their flags. For instance, we can access the shape of Costa Rica by using the following command.
CountryData["CostaRica", "Shape"]
![enter image description here][8]
What we would really like are the coordinates of the vertices of this shape, which we can acquire using the command:
vertices =
CountryData[Entity["Country", "CostaRica"], "Polygon"][[1, 1, 1]];
The first few elements of this list are:
![enter image description here][9]
which are the longitude and latitude of each of the coordinates.
##Step Two: Simplify the boundary
Keeping an eye toward printability, I realized that Costa Rica's actual land and sea borders are too complicated to be able to be printed in metal. (Shapeways has certain tolerances that must be adhered to for them to accept your file.) So I needed to find a way to smooth the border to reduce the complexity. After searching around for quite a while, I learned about a couple well-known simplification algorithms including [Mike Bostock][10]'s awesome [visualization][11] implementing the [Visvalingam-Whyatt algorithm][12].
I found this [list of implementations][13] of Mike's simplify code and was able to run the python implementation [on repl.it][14]. I needed to take the data from Mathematica and put it into the right python format to input into simplify, which would take a pair of coordinates {11.0785, -85.6911} and output them as the string {'x':11.0785, 'y':-85.6911}. So I used Mathematica's String operations.
newpoints =
StringJoin @@ Map["{'x':" <> ToString[#[[1]]] <> ", 'y':" <> ToString[#[[2]]] <> "}," &, vertices];
I input the resulting code:
> [{'x':11.0785, 'y':-85.6911}, {'x':11.2142, 'y':-85.6144}, ... ,
{'x':11.0782, 'y':-85.6907}]
into simplify with the parameter 0.05. The output was again in python format, which I needed to reconvert into Mathematica format by deleting extraneous characters:
StringDelete[StringDelete[newpoints, "'y':"], "'x':"]
We can compare the before and after of this process:
![enter image description here][15]
Notice that there are still some jagged parts of the polygon, so I decided to make a few manual adjustments too. The best way I have found to do this is to use the [ToolTip][16] command:
Graphics[{Polygon@simplified, Red, Map[Tooltip[Point@#, #] &, simplified]}]
which displays a vertex's coordinates when you hover over it so that I know I am removing the correct vertices.
![enter image description here][17]
By the end of this process, I had reduced the original polygon with over 1400 vertices to a polygon with 55 vertices that still contains the essence of the shape of Costa Rica.
simplified = {{-85.6911, 11.0785}, {-85.6144, 11.2142}, {-84.9387,
10.9541}, {-84.7104, 11.091}, {-84.4801, 10.973}, {-84.3577,
10.9965}, {-84.2041, 10.7839}, {-84.0131, 10.7908}, {-83.9293,
10.7087}, {-83.6779, 10.7938}, {-83.6978, 10.8801}, {-83.6401,
10.9096}, {-83.3902, 10.3557}, {-82.7786, 9.66272}, {-82.62,
9.57017}, {-82.6712, 9.49412}, {-82.8549, 9.57112}, {-82.9361,
9.47312}, {-82.9359, 9.07847}, {-82.7118, 8.92455}, {-82.9192,
8.76513}, {-82.83, 8.63599}, {-82.8396, 8.48029}, {-83.0517,
8.33343}, {-83.1454, 8.36625}, {-83.1207, 8.60242}, {-83.3745,
8.74827}, {-83.4645, 8.72645}, {-83.2844, 8.54143}, {-83.2774,
8.3865}, {-83.5892, 8.45915}, {-83.7345, 8.59876}, {-83.5704,
8.84997}, {-83.6403, 9.05175}, {-84.2461, 9.49397}, {-84.6181,
9.58172}, {-84.703, 9.92881}, {-84.774, 9.99558}, {-85.2166,
10.1833}, {-85.1987, 10.0272}, {-84.9217, 9.9254}, {-84.8642,
9.82857}, {-85.1111, 9.559}, {-85.2539, 9.78983}, {-85.6684,
9.90357}, {-85.8752, 10.3566}, {-85.7732, 10.4469}, {-85.811,
10.5156}, {-85.6993, 10.6107}, {-85.6584, 10.766}, {-85.9497,
10.8896}, {-85.8843, 10.9498}, {-85.7141, 10.9201}, {-85.755,
11.0254}, {-85.6907, 11.0782}};
##Step Three: Define an interior
I would like to make a raised lip around the outside of the keychain, so I will use some code I wrote last year that creates a boundary of a fixed thickness on the inside or outside of a given polygon.
Before I apply it, I'll remove some of the peninsulas from our polygon and some of the redundant vertices and visualize the difference:
minimal = {{-85.6144, 11.2142}, {-84.9387, 10.9541}, {-84.7104,
11.091}, {-84.4801, 10.973}, {-84.3577, 10.9965}, {-84.2041,
10.7839}, {-84.0131, 10.7908}, {-83.9293, 10.7087}, {-83.5979,
10.8238}, {-83.3902, 10.3557}, {-82.7786, 9.66272}, {-82.9361,
9.47312}, {-82.9359, 9.07847}, {-82.9192, 8.76513}, {-83.1207,
8.60242}, {-83.3745, 8.74827}, {-83.5704, 8.84997}, {-83.6403,
9.05175}, {-84.2461, 9.49397}, {-84.6181, 9.58172}, {-84.703,
9.92881}, {-84.774, 9.99558}, {-85.2166, 10.1833}, {-85.1987,
10.0272}, {-85.2539, 9.78983}, {-85.6684, 9.90357}, {-85.8752,
10.3566}, {-85.7732, 10.4469}, {-85.811, 10.5156}, {-85.6584,
10.766}, {-85.7141, 10.9201}}
Graphics[{Polygon@simplified, Gray, Polygon@minimal}]
![enter image description here][18]
Now let's describe the algorithm to create a polygon nested inside our bounding shape—we'll be using geometry and trigonometry! We define the vertices of the interior polygon in relation to the vertices of the exterior polygon. The interior vertex is found along the angle bisector of the edges incident with the exterior vertex. We determine its final position by ensuring that the distance to each exterior edge is the prescribed distance *ep*.
Let me give you the code and then dissect it.
ep = .15;
boundarypoints = Reverse@minimal;
interiorhalfangles =
Table[FullSimplify[
Mod[Apply[
ArcTan, (boundarypoints[[i]] -
boundarypoints[[Mod[i + 1, Length[boundarypoints], 1]]])] -
Apply[ArcTan, (boundarypoints[[Mod[i + 2,
Length[boundarypoints], 1]]] -
boundarypoints[[Mod[i + 1, Length[boundarypoints], 1]]])],
2 Pi]], {i, Length[boundarypoints]}]/2;
edgedirections =
Table[FullSimplify[
Apply[ArcTan,
boundarypoints[[Mod[i + 2, Length[boundarypoints], 1]]] -
boundarypoints[[Mod[i + 1, Length[boundarypoints], 1]]]]], {i,
Length[boundarypoints]}];
interiorvectors =
Map[AngleVector, interiorhalfangles + edgedirections];
interiorvertices =
MapThread[#1 + ep/Sin[#3] #2 &, {RotateLeft[boundarypoints],
interiorvectors, interiorhalfangles}]
We choose our thickness (*ep* for epsilon) to be .15. Notice that the following command is to invert the order of the points on the bounding polygon. If we had left the list as is, the new polygon would have been constructed on the outside of the original polygon instead of on the inside.
Then I find the interior half angles by using a special overloading of the ArcTan command. The expected functionality of ArcTan is that ArcTan applied to a single number finds the angle whose tangent is that number. More useful in this context is the two argument version of ArcTan:
**Useful Command**: ArcTan[x,y] gives the angle that the line through (x,y) makes with the positive x-axis.
I have used ArcTan to find the angles that each of the directed edges make with the positive x-axis and taking their difference modulo 2π so that the number is between 0 and 2π. Another command that seemed useful when I started programming was VectorAngle, which finds the angle between two vectors, but that gives the unsigned angle instead of the signed angle between the two vectors.
If we add the interior half angle to the angle that the corresponding edge makes with the x-axis, we get the direction of the vector leaving the exterior vertex toward the interior vertex. Applying the command AngleVector gives the unit vector in that direction. (It gives me warm fuzzy feelings to know that Mathematica has both a command VectorAngle and a command AngleVector!)
The interior vertices are finally calculated using trigonometry to calculate the distance along this unit vector from the exterior vertex.
The final result is a polygon that nests perfectly inside the original Costa Rica shape.
Graphics[{Polygon@simplified, Red, Polygon@interiorvertices}]
![enter image description here][19]
##Step Four: Create a Mesh Object
Now that we have our exterior polygon and our interior polygon, we will convert these Graphics objects into MeshRegion objects, since this seems to be the underlying structure necessary to export three dimensional objects to STL files. The first step is to use [DiscretizeGraphics][20] to convert the polygons into [MeshRegion][21] objects.
interior = DiscretizeGraphics@Graphics@Polygon@interiorvertices;
exterior = DiscretizeGraphics@Graphics@Polygon@simplified;
Then we use RegionDifference to excise the interior from the exterior.
lip = RegionDifference[exterior, interior]
![enter image description here][22]
The last pieces we need are the boundaries of these regions.
exteriorbdry = RegionBoundary@exterior;
interiorbdry = RegionBoundary@interior;
With these building blocks, we can create our three-dimensional model. We define four variables that are the heights of each of the layers, making sure that they are numerical / decimal instead of exact / infinitely precise numbers. There are errors if you use exact numbers like '0' instead of '0.'. I am not sure why.
**Pro tip**: Notice that I have defined these variables outside the subsequent code. By separating the definition of the variables, it makes it easier to modify the rest of the code later if you need to change a parameter for aesthetic or printing reasons.
extbottom = 0.;
intbottom = 0.1;
inttop = 0.2;
exttop = 0.3;
And then build the pieces that comprise the hull of the model by using a RegionProduct command.
Show[RegionProduct[interior, Point[{{intbottom}}]],
RegionProduct[interior, Point[{{inttop}}]],
RegionProduct[interiorbdry, Line[{{extbottom}, {intbottom}}]],
RegionProduct[interiorbdry, Line[{{inttop}, {exttop}}]],
RegionProduct[lip, Point[{{extbottom}}]],
RegionProduct[lip, Point[{{exttop}}]],
RegionProduct[RegionBoundary@exteriorbdry,
Line[{{extbottom}, {exttop}}]]]
You can see each of these objects individually and all assembled together.
![enter image description here][23]
##Step Five: Add a loop
Since we want to use this object as a keychain, we need to add in a ring onto which we can clip a key ring. To do this we will be adding a torus into the object, which has this general form.
thickness = .15;
innerradius = .8;
outerradius = 2;
xcoord = -84;
ycoord = 10.75;
zcoord = Mean[{extbottom, exttop}];
loop = ParametricPlot3D[{(outerradius thickness +
innerradius thickness Cos[v]) Cos[u] +
xcoord, (outerradius thickness +
innerradius thickness Cos[v]) Sin[u] + ycoord + 2 thickness,
thickness Sin[v] + zcoord}, {u, 0, 2 Pi}, {v, 0, 2 Pi},
Mesh -> None, PlotPoints -> 200]
![enter image description here][24]
I chose the ring to have the same thickness as the body and played with the other parameters, especially the x-, y-, and z-translations to figure out where best on the model to place it. One reason why I think my choices work well is because the circle is basically just North of the center of gravity—the map of Costa Rica will have North oriented upward when dangling from the keychain!
##Step Six: Send to the printer!
Now let's print out the model! (Remember that there is more detail on the prototyping and printing processes at the bottom of the [name ring design post][25].) One thing we have to take into consideration is that stainless steel requires a 1 mm thickness everywhere, which may mean that you will have to change the thickness parameters above if you want to shrink the keychain much smaller. Here is what Shapeways gives as a 3D rendering of the keychain:
![enter image description here][26]
And [here][27] is a 3D rendering of the keychain by Sketchfab.
[![enter image description here][28]][29]
Now you have the tools to make your own keychain for any country or administrative region. What countries are on your bucket keychain list? Until next time!
[1]: https://www.wolframcloud.com/objects/wolfram-community/3D-Design-Costa-Rica-Keychain-by-Christopher-Hanusa
[2]: http://blog.mathzorro.com/2017/05/costa-rica-keychain.html
[3]: http://blog.mathzorro.com/2017/04/polyhedral-terrarium.html
[4]: https://en.wikipedia.org/wiki/Monteverde%22
[5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2018-11-13at4.46.12PM.jpg&userId=20103
[6]: https://reference.wolfram.com/language/howto/UseCuratedData.html
[7]: http://reference.wolfram.com/language/ref/CountryData.html
[8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=60931.png&userId=20103
[9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=50202.png&userId=20103
[10]: https://bost.ocks.org/mike/
[11]: https://bost.ocks.org/mike/simplify/
[12]: https://hydra.hull.ac.uk/resources/hull:8338
[13]: https://github.com/mourner/simplify-js
[14]: https://repl.it/HX04/1
[15]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2018-11-13at16.09.50.png&userId=20103
[16]: https://reference.wolfram.com/language/ref/Tooltip.html
[17]: http://community.wolfram.com//c/portal/getImageAttachment?filename=18243.png&userId=20103
[18]: http://community.wolfram.com//c/portal/getImageAttachment?filename=62184.png&userId=20103
[19]: http://community.wolfram.com//c/portal/getImageAttachment?filename=32995.png&userId=20103
[20]: https://reference.wolfram.com/language/ref/DiscretizeGraphics.html
[21]: https://reference.wolfram.com/language/ref/MeshRegion.html
[22]: http://community.wolfram.com//c/portal/getImageAttachment?filename=42766.png&userId=20103
[23]: http://community.wolfram.com//c/portal/getImageAttachment?filename=56697.png&userId=20103
[24]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2018-11-13at12.49.33.png&userId=20103
[25]: http://blog.mathzorro.com/2017/03/Creating-a-Name-Ring.html
[26]: http://community.wolfram.com//c/portal/getImageAttachment?filename=11178.png&userId=20103
[27]: https://skfb.ly/67TPJ
[28]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2018-11-13at4.48.51PM.png&userId=20103
[29]: https://skfb.ly/67TPJChristopher Hanusa2018-11-13T22:33:28ZGet right list of tensors data to port "Input" in NetTrain?
https://community.wolfram.com/groups/-/m/t/1549196
Dear all, my input and target data is prepared in tensor, which is filled from a file. Dimensions[input] yields {398,6,24,24}. First index is the training set number, second is channels (6) and 24 x 24 is my "image" size. In the same way I have prepared the target data, which is in a {398,6} tensor.
When I try to invoke NetTrain, it complains:
NetTrain[Net,{"Inputs"->input,"Targets"->target},{MaxTrainingRounds->1}]
> NetTrain: Data provided to port "Input" should be a list of 6×24×243-tensors.
**Obviously my understanding of tensors and lists seems to be flawed, why is {398,6,24,24} not a list of {6,24,24} tensors?**
The network is defined as follows, just two fully connected layers.
linear1 = LinearLayer[{6,24,24}, "Input"->{6,24,24}];
linear1 = NetInitialize[linear1];
linear2 = LinearLayer[{6}, "Input"->{6,24,24}];
linear2 = NetInitialize[linear2];
Net = NetChain[{linear1, linear2}];Markus Lenzing2018-11-13T12:57:04Z[WSS18] Introducing Hadamard Binary Neural Networks
https://community.wolfram.com/groups/-/m/t/1374288
##Introducing Hadamard Binary Neural Networks
Deep neural networks are an important tool in modern applications. It has become a major challenge to accelerate their training. As the complexity of our training tasks increase, the computation does too. For sustainable machine learning at scale, we need distributed systems that can leverage the available hardware effectively. This research hopes to exceed the current state of the art performance of neural networks by introducing a new architecture optimized for distributability. The scope of this work is not just limited to optimizing neural network training for large servers, but also to bring training to heterogeneous environments; paving way for a distributed peer to peer mesh computing platform that can harness the wasted resources of idle computers in a workplace for AI.
#### Network Architecture and Layer Evaluator
Here, I will describe the network and the Layer Evaluator, to get an in depth understanding of the network architecture.
Note:
- **hbActForward** : Forward binarization of Activations.
- **hbWForward** : Forward binarization of Weights.
- **binAggression** : Aggressiveness of binarization (Vector length to binarize)
Set up the Layer Evaluator.
layerEval[x_, layer_Association] := layerEval[x, Lookup[layer, "LayerType"], Lookup[layer, "Parameters"]];
layerEval[x_, "Sigmoid", param_] := 1/(1 + Exp[-x]);
layerEval[x_, "Ramp", param_] := Abs[x]*UnitStep[x];
layerEval[ x_, "LinearLayer", param_] := Dot[x, param["Weights"]];
layerEval[ x_, "BinLayer", param_] := Dot[hbActForward[x, binAggression], hbWForward[param["Weights"], binAggression]];
layerEval[x_, "BinarizeLayer", param_] := hbActForward[x, binAggression];
netEvaluate[net_, x_, "Training"] := FoldList[layerEval, x, net];
netEvaluate[net_, x_, "Test"] := Fold[layerEval, x, net];
Define the network
net = {<|"LayerType" -> "LinearLayer", "Parameters" -> <|"Weights" -> w0|>|>,
<|"LayerType" -> "Ramp"|>,
<|"LayerType" -> "BinarizeLayer"|>,
<|"LayerType" -> "BinLayer", "Parameters" -> <|"Weights" -> w1|>|>,
<|"LayerType" -> "Ramp"|>,
<|"LayerType" -> "BinLayer", "Parameters" -> <|"Weights" -> w2|>|>,
<|"LayerType" -> "Sigmoid"|> };
MatrixForm@netEvaluate[net, input[[1 ;; 3]], "Test" ] (* Giving network inputs *)
![enter image description here][1]
#### Advantages of Hadamard Binarization
- Faster convergence with respect to vanilla binarization techniques.
- Consistently about 10 times faster than CMMA algorithm.
- Angle of randomly initialized vectors preserved in high dimensional spaces. (Approximately 37 degrees as vector length approach infinity.)
- Reduced communication times for distributed deep learning.
- Optimization of im2col algorithm for faster inference.
- Reduction of model sizes.
### Accuracy analysis
![enter image description here][2]
As seen above, the HBNN model gives 87% accuracy, whereas the BNN model (Binary Neural Networks) give only 82%. These networks have only been trained for 5 epochs.
### Performance Analysis
X Axis: Matrix Size
| Y Axis: Time (seconds)
**CMMA vs xHBNN**
![enter image description here][3]
**MKL vs xHBNN**
$\hspace{1mm}$![enter image description here][4]
### Visualize weight histograms
![enter image description here][5]
It is evident that the Hadamard BNN preserves the distribution of the weights much better. Note that the BNN graph has a logarithmic vertical axis, for representation purposes.
### Demonstration of the angle preservation ability of the HBNN architecture
![enter image description here][6]
Binarization approximately preserves the direction of high dimensional vectors. The figure above demonstrates that the angle between a random vector (from a standard normal distribution) and its binarized version converges to ~ 37 degrees as the dimension of the vector goes to infinity. This angle is exceedingly small in high dimensions.
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=tempz.png&userId=1302993
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=accuracy.png&userId=1302993
[3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=6613xCma.png&userId=1302993
[4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=xMKL.png&userId=1302993
[5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=histogram.png&userId=1302993
[6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=anglepreserve.png&userId=1302993Yash Akhauri2018-07-10T22:12:26ZSpeed up the process of exporting audio to mp3 format?
https://community.wolfram.com/groups/-/m/t/1545310
I was exporting a 60 second audio clip last night, and after waiting half an hour I went to bed. (The export had completed by the time I woke up this morning.)
Why does Mathematica require over 30 minutes for a job like this when any half decent free audio app can do it in seconds?Andrew Dabrowski2018-11-08T15:04:25ZGet right data output format using a For loop?
https://community.wolfram.com/groups/-/m/t/1548944
I have made a for loop, the output is the desired data but i dont know how to make lists of the columns. also the output is not reallt given in the output format "out[]" how do i solve this?
![image][1]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=notoutput.JPG&userId=1541199sjoerd doggenaar2018-11-13T08:13:36ZSolve a parametric system of linear equations in Wolfram|Alpha?
https://community.wolfram.com/groups/-/m/t/1549551
Hi everyone,
I'd like to solve a (symbolic) system of linear equations in Wolfram Alpha in 4 variables (A,B,C,D), with 3 additional parameters (Y,V,T). I gave this command, but Wolfram Alpha doesn't understand what to do:
solve A*T^5+B*T^4+C*T^3+D*T^2=0, 5*A*T^4+4*B*T^3+3*C*T^2+2*D*T=0, A/6*T^6+B/5*T^5+C/4*T^4+D/3*T^3=-V, 1/42*A*T^7+1/30*B*T^6+1/20*C*T^5+1/12*D*T^4=Y for A,B,C,D
Instead, if I type a similar command for a similar system but with 3 variables A,B,C, for example
solve A*T^5+B*T^4+C*T^3=Y,5*A*T^4+4*B*T^3+3*C*T^2=V,20*A*T^3+12*B*T^2+6*C*T=0 for A,B,C
Wolphram Alpha understands and provides a parametric solution.
Do you know where the problem is? I think the two commands are similar, so I cannot understan why it doesn't work.
Please let me know if you have any ideas.
Cheers,
E.Emanuele Spinosa2018-11-13T14:42:01ZPrime Digit Sums
https://community.wolfram.com/groups/-/m/t/1547925
**[Open in Cloud][1] | Download to Desktop via Attachments Below**
The digit sum of a number is defined as the sum of the number's digits -- for example, the digit sum of 1753 is 1 + 7 + 5 + 3 = 16. Suppose we want to find a prime number with a specific digit sum, say 100. The first question we might ask is how large such a prime has to be.
Assume the prime has n digits, and that the digits are uniformly distributed across their possible values. The latter is not strictly true, but is a reasonable (and useful) approximation. The first digit ranges from 1 to 9, so its mean contribution to the digit sum is (1 + 2 + ... + 8 + 9) / 9 = 5. The last digit can only be 1, 3, 7 or 9, so its mean contribution is 5 as well. The n - 2 middle digits range from 0 to 9, so their mean contribution to the digit sum is 4.5. The expected number of digits in a prime with digit sum of 100 is then:
Solve[5 + 4.5 (n - 2) + 5 == 100.]
which Mathematica evaluates as
<pre>{{n -> 22.}}</pre>
&nbsp;
The following statement generates a list of 22-digit primes with digital sum equal to 100:
Select[Total[IntegerDigits[#]] == 100 &] @
Table[RandomPrime[{10^21, 10^22 - 1}], 500]
This produced a list of 29 primes, each of them with digit sum 100:
<pre>{4521257098793752154293, 9017327967050768510809, 3543471831774385676233,
4951733709836020590667, 5026500359626929375097, 4830276814937101295983,
4011907639876429249513, 6171811939300897296109, 5866137711153653636863,
8677001882936009545831, 4982358962465604851221, 3423014619370074987967,
8922054209057943887341, 1531029595478281847173, 4171093644776292816481,
7954066375059510903583, 8139443827613312593459, 3619554293242633643893,
5380882911097144908157, 5584139552066825826217, 4205239726768073229169,
3152572162924535569891, 4121557920549990576217, 8927457552171433903933,
5108738173157780358607, 8037860073637146096259, 1259940420399148246387,
6208576318302772942981}</pre>
&nbsp;
After many runs, it seems that about 4.3% of 22-digit primes have digital sums equal to 100. Since the number of 22-digit primes is approximately LogIntegral[10.<sup>22</sup>] - LogIntegral[10.<sup>21</sup>] = 1.8x10<sup>20</sup>, there are around 7.7x10<sup>18</sup> 22-digit primes with digital sum equal to 100. This is something like the age of the universe in seconds -- an enormous number.
##Smallest Prime##
Next we might ask, what is the smallest prime with digit sum 100? Obviously it will have more than 11 digits, since the maximum digit sum of an 11-digit number is 99. Suppose we prepend the digit 1 to a string of eleven 9s. If this is a prime we can go home early:
PrimeQ[199999999999]
Unfortunately, Mathematica evaluates this as `False`. But to minimize the number of digits, we do want the number to have as many 9s as possible. Consider numbers containing ten 9s and an additional two digits that add up to 10. Are there any primes among them? The following code generates all such numbers, select the primes, and sorts them from smallest to largest:
num = Table[9, 10];
pList2 = Sort@
Select[PrimeQ]@
DeleteDuplicates@
Flatten@Table[
FromDigits[Insert[Insert[num, i, j], 10 - i, k]], {i, 1, 5}, {j,
1, 11}, {k, 1, 12}]
The result is a list of 57 primes:
<pre>{298999999999, 299899999999, 299999989999, 299999999989, 399979999999,
399999979999, 499999999699, 694999999999, 699999999499, 799399999999,
799999399999, 899929999999, 899999999929, 929899999999, 929999899999,
929999989999, 937999999999, 939979999999, 939999979999, 939999997999,
949969999999, 979999399999, 989929999999, 989999299999, 991999999999,
992989999999, 992999989999, 993799999999, 993999999997, 995999999959,
996999994999, 997993999999, 998992999999, 998999999929, 999299989999,
999499699999, 999499969999, 999799993999, 999929998999, 999969499999,
999969999949, 999989299999, 999992989999, 999992998999, 999993999997,
999995999599, 999997993999, 999999599959, 999999699499, 999999799399,
999999939997, 999999949969, 999999969499, 999999982999, 999999991999,
999999997939, 999999999937}</pre>
&nbsp;
The smallest is 298999999999. Call this number p1. Can there be any prime smaller than p1 with digital sum of 100? Suppose there is one. If it exists, it too must have 12 digits.
Since the hypothetical prime is less than p1 and has the same number of digits, then at least one of its digits must be smaller than the corresponding digit in p1. If at least one digit is smaller, then to maintain the digital sum of 100, at least one digit must be larger than the corresponding digit in p1. But the only digit that can be larger is the 8, and it can only be 9.
If the 8 is increased to 9, then to maintain the digital sum of 100 one of the other digits must be decreased by 1. We could decrease the 2 to get 199999999999, but we've already seen that that is not a prime. The only other possibility is to change the second digit to an 8, giving 289999999999. But if this were a prime, it would occur in pList2. Since it does not, 298999999999 is the least prime with a digital sum of 100.
##Largest Prime##
What is the largest prime with digital sum 100? For this problem to have an answer, we must restrict ourselves to nonzero digits only. The obvious first choice is a string of 100 1s:
PrimeQ[FromDigits[Table[1, 100]]]
But Mathematica evaluates this as `False`. However, to maximize the number of digits we do want as many 1s as possible. We next look at numbers containing all ones and one other non-unit digit. For example, 98 1s and a 2, or 97 1s and a 3, etc. The code below generates all such numbers, selects those that are prime, and sorts them from smallest to largest:
plist3 = Sort@
Select[PrimeQ][
FromDigits /@
Flatten[Table[
Insert[Table[1, 100 - i], i, j], {i, 2, 9}, {j, 101 - i}], 1]]
The result is a list of 11 primes:
<pre>{111119111111111111111111111111111111111111111111111111111111111111111\
11111111111111111111111,
1111111111111111111111111111111111111111111111111111111111111111111111\
11111111111111118111111,
1111111111111117111111111111111111111111111111111111111111111111111111\
111111111111111111111111,
1111111111171111111111111111111111111111111111111111111111111111111111\
111111111111111111111111,
1111111117111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111,
1711111111111111111111111111111111111111111111111111111111111111111111\
111111111111111111111111,
1111111111111111111111111111111111111111111111111111111111111111111111\
1111161111111111111111111,
1111111111111111111111111111111111111111111111111111111111111111111111\
11111111111111111151111111,
1111111111111111111111111111111111111111111115111111111111111111111111\
11111111111111111111111111,
1111111111111111113111111111111111111111111111111111111111111111111111\
1111111111111111111111111111,
1111111111111111111111111111111111111111111111112111111111111111111111\
11111111111111111111111111111}</pre>
&nbsp;
The largest is 111111111111111111111111111111111111111111111111211111111111111111111111111111111111111111111111111. Let's call this number p2. An argument similar to the one given for the smallest prime shows that p2 is the largest prime with nonzero digits and a digit sum of 100. For if there is a larger prime, it too will have 99 digits, meaning at least one of the digits will be larger than the corresponding digit in p2, and at least one other digit will be smaller. But the only digit that can be smaller is the 2, which would become a one. That means one of the other ones has to become a 2. Therefore the hypothetical prime must also have 98 1s and a 2. But the algorithm above found all such primes, and p2 is the only one. Thus there is no larger prime.
[1]: https://www.wolframcloud.com/objects/wolfram-community/Prime-Digit-Sums-by-John-ShonderJohn Shonder2018-11-12T00:32:45ZWhat is the implicit and/or parametric equations for hyperbolic shapes?
https://community.wolfram.com/groups/-/m/t/1543003
I'm working on programming an implicit surface plotter, and one of my test surfaces is the Astroidal Ellipsoid (or the [Hyperbolic Octahedron][1]). I was able to successfully get this to work, however I wanted to extend this to further hyperbolic shapes, such as the [Hyperbolic Icosahedron][2] and [Hyperbolic Dodecahedron][3].
The issue is that I cannot seem to find equations for the hyperbolic icosahedron or dodecahdron, despite there being a simple implicit and parametric equations for the hyperbolic octahedron. I would like something in the form of "*0 = f(x,y,z)*" or "*x=F(u,v), y=G(u,v), z=H(u,v)*". It doesn't have to be in Cartesian coordinates (so polar or cylindrical coordinates will be fine), as long as I have a simple equation I can copy and paste into my program.
Where can I find the equations I'm looking for? Thank you for your help!
[1]: http://mathworld.wolfram.com/HyperbolicOctahedron.html
[2]: http://mathworld.wolfram.com/HyperbolicIcosahedron.html
[3]: http://mathworld.wolfram.com/HyperbolicDodecahedron.htmlIbrahim Mahmoud2018-11-05T09:47:09ZImplement Wolfram|Alpha in Unity3D GUI using W|A API and Mathematica?
https://community.wolfram.com/groups/-/m/t/1549222
Hi, I am in a process where I will try to implement wolfram alpha into my game GUI in Uity3d. I have a simple game where you are asked math questions and then I want to implement the Wolframalpha search bar into game GUI as well as the “step-by-step solver”, instead of going out of game and do this by yourself. Of course, the step by step is a paid option, and the API you have to pay for as well. If I ever were to let anyone else play the game, free or for payment, would the players also have to buy wolframalpha membership and API solution?
Unity supports C#, but I have also seen a few examples where it is possible to use “Wolfram programming language” and Mathematica with “connect kernal unity attach” button.
Is it possible to implement such things into game and what would I need?T bl2018-11-13T03:51:40ZGenerate a interpolation function from a mesh with assigned value?
https://community.wolfram.com/groups/-/m/t/1546474
Hi all,
I was trying to use Mathematica for preprocessing to generate a Voronoi mesh with assigned values. Here is my code to generate the mesh:
noPoly = 20; boxSize = 400; pts =
RandomReal[{-boxSize, boxSize}, {noPoly, 2}]; mesh =
VoronoiMesh[pts, {{-boxSize, boxSize}, {-boxSize, boxSize}}]
You will get something like:
![Veronoi mesh][1]
Now this is what I want to do:
1) For each "grain" in the diagram, I want to assign a constant value for the whole grain. i.e., define a function f(x,y) on the mesh such that it is constant in the same grain but maybe different for different grains.
2) Then I want to generate a list of x,y,f(x,y) for x,y are uniform grid points, like (1,0), (2,0), (1,1), (1,2).... If I can do this, I know how to generate text file for another software to read and generate this function.
2) is easy if I could do 1), i.e. get the function f(x,y). I have check the Mathematica documentation but have no idea how to do this. It seems PropertyValue might help but how? How do I even get those value defined on a mesh?
Thanks in advance!
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=7998Capture.PNG&userId=948669Ox Clouding2018-11-09T15:26:25ZAccess a function created in Mathematica in visual studio (vb.net)?
https://community.wolfram.com/groups/-/m/t/997709
So, I've tried asking this question before but I always get generally waved to the .NET/Link connection, which is really not helpful at the moment. I may indeed need to use this connection, but I am very surprised no one has been able to answer such a basic question with a kind-of step-by-step answer. I have a function of one variable that I have computed in mathematica. It doesn't matter what the function is, so for simplicity it could just be called f[x_]:=Sin[x]. Now, what I want to do is to be able to call this function in a visual basic .NET program, such as:
i = 0
Do until i = 3 {
Print f[i];
i++;
loop}
Obviously, the f[i] is the function I defined in mathematica, and in this case represents Sin[x], so the vb.net program should print the results of Sin[0], Sin[1], Sin[2], and Sin[3]. The actual function is much more complex and can't really be handled by visual studio (vb.net), so I need to access the mathematica function from my vb.net program. Can anyone help answer this question? For some reason no one has been able to so far and I am puzzled by this. Thanks in advance.Patrick Cesarano2017-01-18T17:58:41ZUsing Findfit
https://community.wolfram.com/groups/-/m/t/534384
I am trying to find a,b,c from this equation using an array of x and y,
![enter image description here][1]
This is my input in mathematica,
FindFit[{{171.29, 6}, {171.63, 12.1}, {171.86, 24.2}, {172.06,
48.3}}, {x == (((sqrt (a^2 + 8 a y) - a) (b - c))/(4 y)) + c}, {a,
b, c}, {x, y}]
But I get this message, FindFit::fitc: Number of coordinates (1) is not equal to the number of variables (2). >>
Please advice how to solve for a,b,c
[1]: /c/portal/getImageAttachment?filename=5562equation.png&userId=534369Damodaran Achary2015-07-22T22:09:16ZAdd errorbars to a ListLogLogPlot?
https://community.wolfram.com/groups/-/m/t/1548444
Hey,
I have created a Plot and a Fit and combined them into one loged (both axis) Plot.
Now I have to add the Errorbars but I don't know how and I can't find any solution online.
thanks!Pouria Samieadel2018-11-12T12:51:50ZInsert element into a sublist?
https://community.wolfram.com/groups/-/m/t/1547277
I can't figure out how to do the following.
list = {{1,2,3}, {4,5,6},{ 7,8,9}}
I want to add a number to each sublist
For example add 10 so it looks like:
newlist = {{1,2,3,10}, {4,5,6,10}, {7,8,9,10}}
I have looked Insert, Map etc but can't seem to grasp how to do it.
In actuality I will want to add a unique ID (ie each unique ID is different like a primary key) to each sublist
so it would be
list = {{1,2,3,unique ID},{4,5,6, unique ID},{7,8,9, unique ID}}
The unique ID would be most likely by a function I suppose.
Thanks!David Kerr2018-11-11T16:28:17ZVisualize 3D vector field?
https://community.wolfram.com/groups/-/m/t/1548520
I am getting Visualization`Core`ListVectorPlot3D error when I try visualize this:
vectors =
Table[{{f1[x,y,z], f2[x,y,z], f3[x,y,z]}, {f4[x,y,z], f5[x,y,z], 0}}, {x, -1, 1, .1}, {y, -1,
1, .1}, {z, -1, 1, .1}]
ListVectorPlot3D[vectors]
Do you know how can I solve this? Thank youMartin Vit2018-11-12T13:45:45ZHow to use Workbench within Eclipse
https://community.wolfram.com/groups/-/m/t/1547237
Please forgive me for what is likely to be a really basic question, but I have never used either Workbench or Eclipse IDE before. I have written a Mathematica program (.nb file) which I need to optimise, and have read that using Workbench is the way to do that. I therefore followed some very clear Wolfram-provided instructions and installed Eclipse together with the Workshop plugin. The problem is that I cannot find any instructions of what to do next! Without any instructions I tried to guess what to do. Beyond creating a "new project" within Eclipse, I have not been successful at making any progress. Even the tutorial within Eclipse appears to be empty. Could someone PLEASE let me know if there are instructions I can read somewhere, specific to Wolfram Workbench under Eclipse, or generally point me in the right direction!Boris Blankleider2018-11-11T09:18:12ZSymbol for Laplace Transform?
https://community.wolfram.com/groups/-/m/t/1548186
Does Mathematica posess any analogue of AMSMath symbol \risingdotseq? I can make something from dots and "=" but it looks very strange.
![enter image description here][1]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=45902490_2469872856362552_431445966147551232_n.jpg&userId=591660Vadim Zelenkov2018-11-12T09:14:22ZHow to print only the last result!
https://community.wolfram.com/groups/-/m/t/1547204
Hello!
I use
Do[Print[Subscript[a, i] = a[i - 1]; Subscript[c, i] = g[i - 1]], {i,11}]
and need to get only last output. I've haven't found this information at reference, so my question is how to get only i=11 output? Thanks in advance!Alex Graham2018-11-10T15:43:03ZSelect ordered pairs below x^2 and count them?
https://community.wolfram.com/groups/-/m/t/1546940
I have the following code
![enter image description here][1]
I want to "Select" those ordered pairs below x^2 and count them.
something like
Count[Select[t,(x=#1, #2<x^2}]]
but that doesn't work, or anything else I have tried.
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=graphicx%5E2.PNG&userId=159426Raymond Low2018-11-10T06:57:58ZLocations menu item?
https://community.wolfram.com/groups/-/m/t/1547425
I seem to recall that some version of Mathematica had a "Locations" (or was it "Places"?) item on its menu, which listed common folders that one might want to open easily -- and that there was even a way to extend the list.
This seems to have disappeared in 11.3.
Is there some way to recreate it?Murray Eisenberg2018-11-10T17:15:31ZInvert colors in graphics created using the drawing palette?
https://community.wolfram.com/groups/-/m/t/1543531
I have developed severe cataracts and can no longer read or use black on any light color. I need to invert it so that it is light on black. When I convert graphics by hand I have to convert it back by hand before it can be converted to pdf for publication. I have hundreds of such graphics and converting them by hand is very cumbersome and error-prone (particularly when I cannot see the end result). Is there any good way to automate this process?George Hrabovsky2018-11-05T19:01:42ZFind all roots to an equation?
https://community.wolfram.com/groups/-/m/t/1541533
Hello. I'm spending my friday night trying to learn Mathematica, and so far it's been going decent. This is only my second day using the program, so bare with me.
I'm currently on an exercise where I'm supposed to plot these two functions in the same graph:
![enter image description here][1]
For that I used
Plot[{Abs[3 - t^2] + Abs[t - 1] - t^2, 3*Sin[t]}, {t, -3.8, 4.6}]
Which gave me this
: ![enter image description here][2]
Now, what I'm wondering is, how do I find all of the roots to my equation ( h(t) = g(t) )? My e-book suggests using FindRoot, but I don't know how/where. Thanks for your help.
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=cef38e864a03b6a34c3162d6ee7b7c92.png&userId=1540567
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=b7978e84bb1c8b06a90a15e7044d2e9d.png&userId=1540567Jhn Snd2018-11-02T18:38:25ZMATH-TWS: Connecting Mathematica to Interactive Brokers TWS
https://community.wolfram.com/groups/-/m/t/1527021
MATH-TWS is a new Mathematica package that connects Wolfram Mathematica to the Interactive Brokers TWS platform via the C++ API. It enables the user to retrieve information from TWS on accounts, portfolios and positions, as well as historical and real-time market data. MATH-TWS also enables the user to place and amend orders and obtain execution confirmations from Mathematica.
I have wanted a way to connect Wolfram Mathematica to Interactive Brokers’ Trader Workstation for the longest time. Now that it is finally available with MATH-TWS I am excited by the possibilities for Mathematica users.
The first release of MATH-TWS will be available within a couple of weeks. Anyone interested in licensing a copy should email algorithmicexecution@gmail.com with MATH-TWS in the subject line.
![enter image description here][1]
![enter image description here][2]
![enter image description here][3]
![enter image description here][4]
![enter image description here][5]
![enter image description here][6]
![enter image description here][7]
![enter image description here][8]
![enter image description here][9]
![enter image description here][10]
![enter image description here][11]
![enter image description here][12]
![enter image description here][13]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=twsConnect.png&userId=773999
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=twsAccounts.png&userId=773999
[3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=twsAccounts2.png&userId=773999
[4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=twsAccounts3.png&userId=773999
[5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=HistoricalData.png&userId=773999
[6]: http://community.wolfram.com//c/portal/getImageAttachment?filename=DataManipulation.png&userId=773999
[7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=TimeSeries.png&userId=773999
[8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=IntradayData.png&userId=773999
[9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Currentmarketdata.png&userId=773999
[10]: http://community.wolfram.com//c/portal/getImageAttachment?filename=News.png&userId=773999
[11]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Ordermanagement.png&userId=773999
[12]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Modifyorder.png&userId=773999
[13]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Cancelorder.png&userId=773999Jonathan Kinlay2018-10-22T12:09:47ZImport notebooks from DropBox to WolframCloud on the iPad?
https://community.wolfram.com/groups/-/m/t/1544312
I‘m using WolframCloud on my iPad and on my MacBook. Files (notebooks) are stored in DropBox. Up to now I see no easy way to work with my files in DropBox on the iPad. How can I easily import them and ideally store them later again in DropBox?Michael Gamer2018-11-06T20:47:51ZTwelve Prisms
https://community.wolfram.com/groups/-/m/t/1517102
My friend Gianni Sarcone recently built a 12 prism construction.
![twelve prisms][1]
So I had to build one myself. I also built in in Mathematica. To my surprise, I was able to simplify it down to three points.
base={{4,4,7},{3,6,6},{2,5,8}};
prismp=Join[base,-(Reverse/@base)];
prismf={{1,2,3},{4,5,6},{1,2,4,5},{1,3,6,5},{2,3,6,4}};
tetrahedralGroup ={{{-1,0,0},{0,-1,0},{0,0,1}},{{0,-1,0},{0,0,1},{-1,0,0}},{{0,0,1},{-1,0,0},{0,-1,0}},{{0,0,-1},{1,0,0},{0,-1,0}},{{0,1,0},{0,0,-1},{-1,0,0}},{{1,0,0},{0,1,0},{0,0,1}},{{0,-1,0},{0,0,-1},{1,0,0}},{{-1,0,0},{0,1,0},{0,0,-1}},{{0,0,1},{1,0,0},{0,1,0}},{{1,0,0},{0,-1,0},{0,0,-1}},{{0,0,-1},{-1,0,0},{0,1,0}},{{0,1,0},{0,0,1},{1,0,0}}};
Graphics3D[{Opacity[.8],Table[Polygon[prismp[[#]].tetrahedralGroup[[n]]]&/@prismf,{n,1,12}]}, Boxed-> False, SphericalRegion->True,ImageSize-> {800,800},ViewAngle-> Pi/9]
![twelve prisms][2]
Maybe try out ViewAngle -> Pi/600, ViewPoint -> {200, 0, 0}
![12 prisms from far away][3]
Sweet.
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=twelveprisms.jpg&userId=21530
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=12prismWL.jpg&userId=21530
[3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=12prismfar.jpg&userId=21530Ed Pegg2018-10-16T22:24:27ZThe Octagonal Dodecahedron
https://community.wolfram.com/groups/-/m/t/1520664
On 17 October 2018, [Ivan Neretin discovered the octagonal dodecahedron](https://math.stackexchange.com/questions/2869725/), a toroid made from twelve octagons.
**4**, 6, 8 triangles can make a tetrahedron and up. The [Snub Disphenoid](http://mathworld.wolfram.com/SnubDisphenoid.html) has 12 faces.
**6**, 8, [9](https://en.wikipedia.org/wiki/Herschel_graph), 10 quadrilaterals can make a cube and up. The [Rhombic Dodecahedron](http://mathworld.wolfram.com/RhombicDodecahedron.html) has 12 faces.
**12**, 16, 18, 20 pentagons can make a [tetartoid](http://demonstrations.wolfram.com/TheTetartoid/) or dodecahedron [and up](https://math.stackexchange.com/questions/1609854/).
**7**, 8, 9, 10 hexagons can make make a [Szilassi toroid](http://demonstrations.wolfram.com/TheParametrizedSzilassiPolyhedron/) and [up](http://dmccooey.com/polyhedra/ToroidalRegularHexagonal.html).
**12**, 24 heptagons can make a [heptagonal dodecahedron](http://dmccooey.com/polyhedra/HigherGenus.html) or [Klein quartic 3-torus](http://mathworld.wolfram.com/KleinQuartic.html).
**12** octagons can make an octagonal dodecahedron.
![octagonal dodecahedron][1]
So how did I make that picture? First, I looked through the [Canonical Polyhedra](https://datarepository.wolframcloud.com/resources/Canonical-Polyhedra) resource object for the outer polyhedron. The index turned out to be "8_9".
ResourceObject["Canonical Polyhedra"]
ResourceData["Canonical Polyhedra"][["8_9"]]
It's a geometric object with constraints since it's a [canonical polyhedron](http://demonstrations.wolfram.com/CanonicalPolyhedra/). My WTC talk [Narayama's Cow and Other Algebraic Numbers](https://wtc18.pathable.com/meetings/895905) discussed how to use algebraic number fields to simplify geometrically constrained objects.
1. Get two or more points to simple fixed values.
2. Use RootApproximant[] on remaining points.
3. If remaining points have the same value for NumberFieldDiscriminant[coord^2], the object is in an algebraic number field.
Would the technique I suggested help to make the new object? Turns out it did.
I took the points from "8_9", kept the center at (0,0,0), found an EulerMatrix[] to forced the midpoints of two opposing edges to (0,0,1),(0,0,-1) and force those two edges to be parallel to the x,-y axes.
After using Chop[] in various ways to get 0, 1, and -1 values, I used RootApproximant[] on everything else, then looked at NumberFieldDiscriminant[coord^2] on all reasonable seeming values. The discriminant -104 turned out a lot, and soon I had all coordinates using the algebraic number field based on Root[#^3 - # - 2 &, 1].
I've found these functions useful for algebraic number fields.
FromSqrtSpace[root_, coord_] := Module[{ dim, degree, vector},
dim = Dimensions[coord];
degree = {1, 2}.NumberFieldSignature[root];
vector = (root^Range[0, degree - 1]);
Map[With[{k = (#).vector}, RootReduce[Sign[k] Sqrt[Abs[k]]]] &, coord, {Length[dim] - 1}]];
ToSqrtSpace[root_, coord_] := Module[{dim, order, algebraic},
dim = Dimensions[coord];
order = {1, 2}.NumberFieldSignature[root];
algebraic = Map[Function[x, ToNumberField[Sign[x] RootReduce[x^2], root]], coord,{Length[dim] - 1} ];
Map[Function[x, If[Head[x] === AlgebraicNumber, Last[x], PadRight[{x}, order]]], algebraic, {Length[dim]} ]];
The algebraic number field coordinates, actual coordinates, and faces.
valsV={{{0,1/2,-1/4},{0,0,0},{-1,0,0}},{{-2,0,1},{0,-2,1},{-1,2,-1}},{{0,2,-1},{2,0,-1},{1,-2,1}},{{0,2,-1},{-2,0,1},{1,-2,1}},{{-2,0,1},{0,2,-1},{-1,2,-1}},{{0,-1/2,1/4},{0,0,0},{-1,0,0}},{{0,0,0},{0,1/2,-1/4},{1,0,0}},{{0,0,0},{0,-1/2,1/4},{1,0,0}},{{2,0,-1},{0,2,-1},{-1,2,-1}},{{2,0,-1},{0,-2,1},{-1,2,-1}},{{0,-2,1},{-2,0,1},{1,-2,1}},{{0,-2,1},{2,0,-1},{1,-2,1}}};
p89v = FromSqrtSpace[Root[#^3 - # - 2 &, 1], valsV];
p89F={{1,2,3,4,5},{2,10,12,8,3},{4,7,11,9,5},{6,9,11,12,10},{1,5,9,6},{1,6,10,2},{3,8,7,4},{7,8,12,11}};
Code for the initial picture.
reg=RegionBoundary[RegionDifference[ConvexHullMesh[p89v],ConvexHullMesh[With[{a=.7, b=.6, c=.9},{{a,b,c}, {-a,-b,c},{-b,a,-c}, {b,-a,-c} }]]]];
DiscretizeRegion[reg,MeshCellStyle->{{2,All}->Opacity[.7]}, SphericalRegion-> True, ImageSize-> 600, ViewAngle-> Pi/10]
Showing the original polyhedron and subtracted tetrahedron.
Graphics3D[{EdgeForm[Thick], Opacity[.8], GraphicsComplex[p89v, Polygon[p89F]],
With[{a = .7, b = .6, c = .9}, Polygon[Subsets[{{a, b, c}, {-a, -b, c}, {-b, a, -c}, {b, -a, -c} }, {3}]]]}, Boxed -> False, SphericalRegion -> True, ViewAngle -> Pi/9]
![octagonal dodecahedron][2]
Might be possible to remove the canonical sub-polyhedron constraint and add a constraint that the octagons all have unit area. Or to minimize the ratio of largest/smallest edge.
If you'd like a hexagonal dodecahedron, here's a simple one.
DiscretizeRegion[RegionBoundary[RegionDifference[Region[Cuboid[{0, 0, 0}, {3, 3, 3}]],
RegionUnion[Region[Cuboid[{0, 0, 0}, {2, 2, 2}]], Region[Cuboid[{1, 1, 1}, {3, 3, 3}]]]]],
MaxCellMeasure -> {"Area" -> 0.001}, AccuracyGoal -> 8, PrecisionGoal -> 8]
![hexagonal dodecahedron][3]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=octagonaldodecahedron.jpg&userId=21530
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=octagonaldodecbuild.jpg&userId=21530
[3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=hexagonaldodecahedron.jpg&userId=21530Ed Pegg2018-10-18T21:43:37ZGet right probability for Classify Colors in MMA 11.3.0.0 on RPi?
https://community.wolfram.com/groups/-/m/t/1541836
This seems to execute incorrectly on RPi with incorrect probability any thoughts would be appreciated! Thanks.
Directly from the Wolfram Documentation Center :
> Classify >> Examples >> Scope >> Custom Classifiers
> Train a classifier on image examples, gathered by their class:
![enter image description here][1]
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=probabiltyOfClassifyColor.jpg&userId=463563Terrance Teslow2018-11-03T14:41:11ZSharing a Bicycle
https://community.wolfram.com/groups/-/m/t/1536095
**[Open in Cloud][1] | Download to Desktop via Attachments Below**
![enter image description here][2]
The following question appeared in Parade Magazine's Ask Marilyn column for Sunday, May 2, 2010:
>A friend and I once went from his house to mine with one bicycle. I started walking and he rode the bike. When he got a couple of blocks ahead, he left the bike on the sidewalk and started walking. When I got to the bike, I started riding, passing him, and then left the bike a couple of blocks ahead. When he got to the bike, he started riding. We did this the whole way.
>&nbsp;
>At least one of us was always walking. At times, one was riding; at other times, we were both walking. I'm sure this was faster than if we had no bike. But some people insist that it was no faster because somebody was always walking. Who's right?
>&nbsp;
>Marilyn's answer was: "The reader is right. It's true that someone was always walking. But neither friend walked the whole distance. Both biked part of the way. This increased their average speed, so they saved time."
&nbsp;
As with the Monty Hall problem, numerous readers wrote in to disagree with Marilyn, insisting that since someone was always walking, the journey could be no faster than if both had walked the entire distance. What do you think?
Designating the two friends as A and B, the situation is as follows (assuming A has the bike first):
1. A rides the bike and B walks, until A is a fixed distance h ahead of B, at which time A dismounts and leaves the bike on the sidewalk.
2. A and B walk until B comes to the bike, at which time B picks it up.
3. B rides the bike and A walks, until B is a distance h ahead of A, at which time B dismounts and leaves the bike on the sidewalk.
4. A and B walk until A gets to the bike, at which time A picks it up.
Step 1 follows Step 4, and the steps repeat sequentially until the last friend reaches the other house.
In his book [Number-Crunching:Taming Unruly Computational Problems from Mathematical Physics to Science Fiction](https://books.google.com/books/about/Number_Crunching.html?id=pxz8G-KF3ZgC) (which I highly recommend), Paul Nahin presents a Matlab program to simulate this problem. The program uses a discrete time step, and it occurred to me that with careful bookkeeping, the finish time (i.e., the time for the last friend to reach the house) could be calculated exactly. I decided to write my own simulation using Wolfram Mathematica. To begin, I define the following terms:
<em>d</em>: &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;Distance between the two houses
<em>h</em>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Distance ahead, i.e., the rider leaves the bike this distance ahead of the walker
<em>rA</em>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Speed at which A rides the bike
<em>wA</em>:&nbsp;&nbsp;&nbsp;&nbsp;Speed at which A walks
<em>rB</em>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Speed at which B rides the bike
<em>wB</em>:&nbsp;&nbsp;&nbsp;&nbsp;Speed at which B walks
<em>t </em>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Time
$\Delta$<em>t</em>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Time increment
I also made the assumption that both friends are able to ride the bicycle faster than they walk, i.e., rA > wA and rB > wB.
In general, at the beginning of any step, A is at <em>xA</em> and B is at <em>xB</em>. At the end of the step, A is at <em>xA</em> + <em>vA$\Delta$t</em> and B is at <em>xB</em> + <em>vB$\Delta$t</em>, where A's velocity <em>vA</em> is either <em>wA</em> or <em>rA</em> depending on the particular step; B's velocity <em>vB</em> is either <em>wB</em> or <em>rB</em>; and $\Delta$<em>t</em> is calculated from the velocities and distances particular to that step. We must then check whether either of the two friends will reach the other house before $\Delta$<em>t</em> elapses.
The calculations for each step are as follows:
###Step 1
When Step 1 is completed, A is <em>h </em>units ahead of B. Since A is riding the bike and B is walking, we have the equation <em>xA + rA</em><em>·$\Delta$t = xB + wB·$\Delta$t + h</em>. Solving for $\Delta$<em>t </em>gives $\Delta$<em>t = (xB - xA + h) / (rA - wB)</em>. Thus at the end of Step 1, A is at <em>xA + rA</em><em>·$\Delta$t</em>, B is at <em>xB + wB</em><em>·$\Delta$t</em>, and the time is incremented by $\Delta$<em>t</em>. A then puts down the bicycle.
Of course if <em>rA </em> $\leq$ <em> wB </em>then A will never catch up with B. The distance <em>h </em>essentially drops out of the problem, and the completion time is the time for A to ride the bike the entire distance <em>d.</em>
If <em>xA + rA</em><em>·$\Delta$t > d </em>or <em>xB + wB·$\Delta$t > d </em>then one of the friends will reach the other house before the end of the time step. We must determine which friend arrives first; the total time for the journey is then the time at the beginning of Step 1 plus the time required for the other friend to reach the end of the journey<em>.</em>
###Step 2
In Step 2, B walks the distance <em>h </em>and reaches the bike. This takes <em> $\Delta$t </em>= <em>h/wB </em>time units. At the end of Step 2, B is at <em>xB + h</em>, A is at <em>xA + wA</em><em>·$\Delta$t</em>, and the time is incremented by <em> $\Delta$t</em>.
If <em>xA + wA</em><em>·$\Delta$t > d</em>, then A reaches the other house on this step. The total time for the journey is then the current time plus the time required for B to get to the bike and ride it to the other house.
###Step 3
Step 3 is identical to Step 1, except that B is riding the bike and A is walking. Reasoning as in Step 1, we find <em> $\Delta$t = (xA - xB + h) / (rB - wA)</em>. So at the end of Step 3, A is at <em>xA + wA</em><em>·$\Delta$t, </em>B is at <em>xB + rB</em><em>·$\Delta$t, </em>and the time increments by <em> $\Delta$t</em>.
As in Step 1, if <em>rB </em> $\leq$ <em>wA </em>then B will never catch up to A, and the completion time is then the current time plus the time required for B to complete the journey on the bike.
If <em>xA + wA</em><em>·$\Delta$t > d </em>or <em>xB + rB</em><em>·$\Delta$t > d, </em>then one of the friends reaches the other house on this step. As in step 1, we determine which friend arrives first. The total time for the journey is then the time at the beginning of Step 3 plus the time required for the other friend to reach the other house. The time increments by <em> $\Delta$t</em>.
###Step 4
Step 4 is identical to Step 2, except that A walks the distance <em>h </em>and reaches the bike. This takes <em> $\Delta$t</em> = <em>h/wA </em>time units. At the end of step 2, A is at <em>xA + h</em>, B is at <em>xB + wB·$\Delta$t</em>, and the time is incremented by <em> $\Delta$t</em>.
However, if <em>xB + wB·$\Delta$t > d </em>then B reaches the other house before A reaches the bike. So the total time to complete the journey is the time at the beginning of Step 4 plus the time required for A to get to the bike and ride it to the second house.
Finally we can translate these equations and conditions into the Wolfram language and write a function to determine the total time of the journey given <em>wA</em>, <em>wB</em>, <em>rA</em>, <em>rB</em>, <em>d</em>, and <em>h</em>:
tFinal[wA_, rA_, wB_, rB_, d_, h_] :=
Block[{t = 0, xA = 0, xB = 0, xC = 0, dt, dt2, dt4},
dt2 = h/wB; dt4 = h/wA;
While[True,
(* Step 1 *)
If[rA <= wB, Return[d/rA]];
dt = (h + xB - xA)/(rA - wB);
If[(xA + rA dt >= d ) || (xB + wB dt >= d),
If[(d - xA)/rA < (d - xB)/wB, Return[t + (d - xB)/wB],
Return[t + (d - xA)/rA]]];
xA += rA dt; xB += wB dt; xC = xA; t += dt;
(* Step 2 *)
dt = dt2;
If[xA + wA dt > d, Return[t + dt + (d - xC)/rB]];
xA += wA dt; xB += h; t += dt;
(* Step 3 *)
If[rB <= wA, Return[t + (d - xB)/rB]];
dt = (h + xA - xB)/(rB - wA);
If[(xB + rB dt >= d ) || (xA + wA dt >= d),
If[(d - xB)/rB < (d - xA)/wA, Return[t + (d - xA)/wA],
Return[t + (d - xB)/rB]]];
xB += rB dt; xA += wA dt; xC = xB; t += dt;
(* Step 4 *)
dt = dt4;
If[xB + wB dt >= d, Return[t + dt + (d - xC)/rA]];
xA += h; xB += wB dt; t += dt;]]
With this function we can reproduce Nahin's figure 7.2.2, with <em>d</em> = 1 mile, <em>wA</em> = <em>wB</em> = 2 miles per hour, and <em>rA</em> = <em>rB</em> = 6 miles per hour:
d = 5280.; wA = wB = 2*5280/3600; rA = rB = 6*5280/3600;
Plot[tFinal[wA, rA, wB, rB, d, h], {h, 10, 1500}, Frame -> True,
FrameLabel -> {"Separation (feet)",
"Time for second friend to finish (seconds)"},
LabelStyle -> Directive[Larger], GridLines -> None,
ImageSize -> Large, PlotLabel -> "Figure 1"]
![enter image description here][3]
Given their walking speed of 2 miles per hour, it would take the friends 30 minutes = 1800 seconds to cover a distance of one mile without the bicycle. Figure 1 shows that there are values of <em>h</em> that result in times as low as 1200 seconds. Clearly, sharing the bicycle makes the journey faster. Marilyn Vos Savant was correct!
[1]: https://www.wolframcloud.com/objects/wolfram-community/Sharing-a-Bicycle-by-John-Shonder
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2018-11-08at8.34.19PM.jpg&userId=20103
[3]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Figure1.jpg&userId=66744John Shonder2018-10-28T16:27:10ZIs it possible to add numbers to my Mathematica database permanently?
https://community.wolfram.com/groups/-/m/t/1545177
Hello community, do not know if my question is real or if I am talking nonsense... My question is the following:
I have a number
- like the Copeland-ERD number constant for example 0.23571113171923293137414347535961677173798389971...
- or Khinchin (with 20000 digits or more) 2.68545200106530644530971483548179569382038229399...
and I would like to save in the internal database of my **Mathematica** permanently in the form of a symbol or as a letter (for example, the letter V?!) so I do not need to manually put the 20000 digits every time and leave my file too large, since putting 20000 digits several times confuses the eyes in the programming. Is this allowed or possible?
(I have not posted the 20000 digits here so this post does not get too big, but any number of digits would already help me to know if this is possible)... is there any way to do this with **Mathematica**??
Thank you very much to everyone in the community and the creators of **Mathematica**.Claudio Chaib2018-11-08T14:14:49ZGet three plots and manipulate some variables of the respective equations?
https://community.wolfram.com/groups/-/m/t/1544930
Hello all,
I'm writing a code from the which I desire to get three plots and manipulate some variables of the respective equations. Two of the three plots work, however, the last one doesn't show up and Mathematica doesn't follow my instructions of the ranges I tell the program to plot. It plots another variable and other ranges. Also, the program doesn't identify any error. I've been checking all the equations but everything seems to be fine. I don't know what else can I do. Please, help with this issue.
The code is attached.
Thanks.Vanessa Maldonado2018-11-07T20:24:31ZAvoid error in the following symbolic integration?
https://community.wolfram.com/groups/-/m/t/1544543
I have attached a code in short0.nb that produces an erroneous result - see colour comments in the file. The error is in the integration of the function curr[t] between t and t+T, see the line with the defined variable avcurr. When this calculation is split into two parts in the same document, it is done correctly. When it is done independently and - importantly - on another notebook, see attached test.nb, then the results is correct again. Any ideas?Lev Kantorovitch2018-11-06T23:08:02ZComputational mnemonics
https://community.wolfram.com/groups/-/m/t/1544816
Yesterday I was reading [this][1] on Stephen's blog and something caught my attention.
> [![swblogquote][2]][1]
So I decided to do some coding to figure out how many other sentences like that existed. The strategy is as follows, we're going to first find all the possible partitions of 14 (with permutations), then split the formula string and extract words that match the sub-string.
##Partitions##
We need to construct all possible partitions of 14 which is the length of the formula: `IntegerPartition` returns sorted partitions, so we need to call `Permutations`.
Join @@ Permutations /@ IntegerPartitions[14]
returns 8192 permuted partitions of 14. It is left as an exercise to the reader that there are always `2^(n-1)` permuted partitions of the integer `n`.
From these we can compute all the possible spans.
spans[n_] := Map[
MapAt[
Function[a, a + 1],
Partition[Prepend[Accumulate[#], 0], 2, 1],
{All, 1}
] &,
Join @@ (Permutations /@ IntegerPartitions[n])
]
##Finding words##
Now we need to find all the words that match the right piece of the pattern:
Options[filteredWords] = {IgnoreCase -> True};
filteredWords[{a_, b_, c_}, opts: OptionsPattern[]][pos_] := filteredWords[{a, b, c}, opts][pos] =
DictionaryLookup[
StringReplace[StringTake["DDDpqrDpDDprpr", pos], {"D" -> _,"p" -> a, "q" -> b , "r" -> c}],
IgnoreCase -> OptionValue[filteredWords, {opts}, IgnoreCase]
]
`filteredWords` takes three letters *a, b, c* and two indices and constructs a StringExpression to be fed to `DictionaryLookup`, by `StringTake`-ing the part of the formula we want to construct mnemonics from. For example: given input `{"u", "r", "e"}` and indices `{10, 14}` it constructs the pattern `_ ~~ "ueue"`, and it extracts `{"queue"}`. Note that we've used the fact that `StringReplace` returns a `StringExpression` when some of the rhs are not strings themselves.
As an intermediate step we can construct all the words that will make up our mnemonics:
words = DeleteCases[
Map[filteredWords[{"u", "r", "e"}], spans[14], {2}],
{___, {}, ___}
]
And just from these we can say that there are 192 945 possible sentences:
Total[Times @@@ Map[Length, words, {2}]]
We can easily construct them:
sentences = Flatten[Apply[Outer[StringRiffle[{##}, " "] &, ##] &, words, {1}]]
Let's look at them:
RandomSample[sentences, 10]
returns
{"Oz cur Ed um queue", "ID Wu re I US queue", "kW surer UK queue",
"gap Urey US queue", "Ms nu re duo queue", "XL cur Ed uh queue", "a I Wu re gut queue",
"AM nu re cub queue", "I you re jun queue", "a slur eh up queue"}
Do they all end in queue?
Select[sentences, Not @* StringMatchQ[___ ~~ "queue"]]
unfortunately yes.
Now we can try to do some further exploration. A few facts:
- There are no sentences with `{"p", "q", "r"}`
- There are a staggering 14 690 288 sentences with `{"a", "b", "c"}`
- If we restrict the search to case sensitive there are 0 sentences with `{"a", "b", "c"}`, which makes me suspect that there are far too many acronyms with abc in our dictionary.
- There are no three consecutive letters that have case-sensitive valid sentences.
What about case-insensitive?
assoc = AssociationMap[
With[
{words = DeleteCases[
Map[filteredWords[#, IgnoreCase -> True], spans[14], {2}],
{___, {}, ___}
]},
Total[Times @@@ Map[Length, words, {2}]]
] &,
Partition[Alphabet[], 3, 1]
]
DeleteCases[assoc, 0]
returns
<|{"a", "b", "c"} -> 14690288, {"g", "h", "i"} -> 672097, {"t", "u", "v"} -> 76164|>
For `{"t", "u", "v"}`, they all end in `"TV TV"`, so that's not very interesting.
`{"g", "h", "i"}` on the other hand seems to contain quite a few I, which is definitely interesting, if it wasn't for the fact that they all end with `"I"`, which is probably not going to work well with English grammar.
> I egg HIV go a gig I
> I big hip gum gig I
> go ugh is God gig I
> I gig his gig GI GI
Maybe with some punctuation...
I have to stop writing here, but I will come back with some statistics of the 26!/23! (15600) 3-letter combinations.
[1]: http://blog.stephenwolfram.com/2018/11/logic-explainability-and-the-future-of-understanding/
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=blog.jpg&userId=55331Carlo Barbieri2018-11-07T20:35:56ZAvoid "SOUND Demonstration" to emit sound on notebooks?
https://community.wolfram.com/groups/-/m/t/1544287
When I go to SOUND Demonstration and the Basic Examples it brings up Sound and when I click on it it creates a MIDI file and it automatically brings up GarageBand(an APPLE application. when I try it one of my nb files it calls emit sound,which I don't want.How can I stop that?Larry Lange2018-11-07T14:53:48ZGet a numerical result using N[...] on the following expression?
https://community.wolfram.com/groups/-/m/t/1543982
Hello,
I am not very experienced in Mathematica and have the problem that N[...] will not be calculated in In[26].
Can anybody help a bit, please?
regards - LeoLeo Baumann2018-11-06T14:14:41ZWhich version of Mathematica is available on Raspberry Pi ?
https://community.wolfram.com/groups/-/m/t/1349489
Hello,
I recently added Mathematica on my Raspberry 3 (originally with Raspbian Lite), and got the 11.0.1.
Any attempt to get the 11.2 version by a classical upgrade process
sudo apt-get dist-upgrade wolfram-engine
just answers that I am up-to-date... However I can read in the group lot of posts concerning 11.2 !
How can I get it ? I wouldn't like to reinstall Raspbian, as it is a special image.
Thank you for your help,
Yvesyves papegay2018-05-31T13:46:34ZUlam Spirals in Wolfram Language
https://community.wolfram.com/groups/-/m/t/1543056
[**Open in Cloud**][1] | **Download to Desktop via Attachments Below**
![enter image description here][2]
## The Traditional Ulam Spiral ##
Although there are some [very elegant methods][3] of displaying the Ulam spiral in Mathematica, I wanted one that was slightly more general, with the specific goal of making the Ulam spiral for a hexagonal tiling of the plane.
With that in mind, I adopted the following approach: for the standard rectangular tiling of the plane, the spiral consists of concentric 'shells' of points, each shell containing (2n+1)^2 numbers. Consequently finding which shell a given number is in reduces to taking a square root.
quadlayer[q_] := Ceiling[(Sqrt[q] - 1)/2]
The convention being that the origin is the 'zeroth' shell.
Next, we count how many squares 'around' the given shell a number is, just given by taking the difference from the shell underneath it.
quadaround[q_] := q - (2 quadlayer[q] - 1)^2
The method for actually generating the appropriate point comes down to specifying the 'corner' of the shell to start from, and how far along the 'edge' to travel. This is easily determined from the previously determined shell number and 'around' number.
![Depiction of how a point is computed based on shell and around][4]
For example, to get the position of 12 in the spiral, we compute that it's in shell 2, so we start at a corner two steps away from the origin. We then compute that it is three steps around this shell, so we travel three steps around the outside.
Use of QuotientRemainder tells us which corner to start at, and how many steps to go
quadpoint[q_] := (quadlayer[q] (Sqrt[2] AngleVector[\[Pi]/2 (#1 - 1/2)])
+ (#2) AngleVector[\[Pi]/2 (#1 + 1)] ) & @@
Quiet[QuotientRemainder[quadaround[q], 2 quadlayer[q]]]
The first part of the vector specifies the corner to start at, and the second specifies how many steps along the edge to take.
ListPlot[quadpoint[#] & /@ Range[400], Joined -> True, AspectRatio -> Automatic]
![Procession of spiral points][5]
And from there we can generate the ordinary Ulam spiral, or select a starting point, such as p_13=41, which reproduces the rather striking spiral from the [wikipedia page on the subject][6].
ListPlot[quadpoint[# - 40] & /@ (Prime[#] & /@ Range[13, 10000]),
AspectRatio -> Automatic, Axes -> False]
![Ulam Spiral starting at 41][7]
## Generalization ##
This method of computing where a given integer should end up in the spiral naturally generalizes to m-gons. The first shell will have m points in it, the second will have 2m, etc, so the number of points going up to the n'th layer is just
1+ m n(n-1)/2
And so given an integer, we can again compute which layer it is in, and how many 'around' the layer it goes.
mgonLayer[q_, m_] := Ceiling[1/2 (1 + Sqrt[-8 + m + 8 q]/Sqrt[m])] - 1
maround[q_, m_] := q - (1 + m/2 ((mgonLayer[q, m] - 1) (mgonLayer[q, m])))
And in an exactly analogous way, we can use these to specify where in a shell a given integer should go. A little more geometry is required to figure out where the 'corners' of each layer are, and how long the sides are, but the situation is essentially the same.
mpoint[q_, m_] := (mgonLayer[q, m] AngleVector[(2 \[Pi])/m (#1 - 1)] +
#2 2 Sin[\[Pi]/m] AngleVector[2 \[Pi]/m (#1 - 1) + \[Pi]/2 + \[Pi]/m]) & @@
Quiet[QuotientRemainder[maround[q, m], mgonLayer[q, m]]]
And now we can make Ulam Spirals for any regular polygon we might like
ListPlot[mpoint[#, 6] & /@ (Prime[#] & /@ Range[10000]),
Axes -> False, AspectRatio -> Automatic]
![Hexagonal Ulam Spiral][8]
##Another Example: Circular 'tilings'##
We may also define alternative functions for placing the points. As an example, we may instead have concentric circles of 2m equally spaced points.
mpoint2[q_, m_] := (mgonLayer[q, m] AngleVector[(2 \[Pi])/(m*mgonLayer[q, m]) (maround[q, m]-1)])
ListPlot[mpoint2[#, 6] & /@ (Prime[#] & /@ Range[10000]), Axes -> False, AspectRatio -> Automatic]
![Ulam Spiral with circle][9]
Some other elegant examples that are possible include displaying ListPlots with pointsize given by number of factors, spirals of prime squares, cubes, etc.
Hopefully this will enable some people to make elegant and visually pleasing Ulam spirals, and related objects.
[1]: https://www.wolframcloud.com/objects/wolfram-community/Ulam-Spirals
[2]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2018-11-08at10.09.36AM.jpg&userId=20103
[3]: http://community.wolfram.com/groups/-/m/t/102049
[4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ShellAround.png&userId=1541430
[5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=1470ShellSpiral.png&userId=1541430
[6]: https://en.wikipedia.org/wiki/Ulam_spiral
[7]: http://community.wolfram.com//c/portal/getImageAttachment?filename=spiral41.png&userId=1541430
[8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=HexSpiral.png&userId=1541430
[9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=CircleSpiral.png&userId=1541430Duncan Pettengill2018-11-05T18:27:54ZIs the "reverse factoring" counter behavior computationally irreducible?
https://community.wolfram.com/groups/-/m/t/1338124
Dear reader, this is my first post in this forum, as a consequence of a quick interaction with the Twitter account @WolframResearch.
The main purpose is to verify the computational irreducibility of the behavior described by the algorithm I'm going to introduce here. So I hope in a response from some "A New Kind of Science" expert.
But the algorithm, neatly varying factors, generates the increasing sequence of positive numbers, in the context of my study about an infinite-dimensional discrete space; so discussion of other aspects you possibly find interesting will also be welcome.
var F
F = function ( Limit )
{
var Coordinates
var Expand
var Index
var Numbers
var Quantity
var Value
Numbers = new Array ( )
Numbers [ 0 ] = 1
Expand = function ( Coordinate )
{
var Index
var Quantity
var Value
Quantity = Coordinate . Exponents . length
Value = Coordinate . Base - 1
while ( Value -- )
for ( Index = 0 ; Index < Quantity ; ++ Index )
Coordinate . Exponents [ Coordinate . Exponents . length ] =
Coordinate . Exponents [ Index ]
++ Coordinate . Exponents [ Coordinate . Exponents . length - 1 ]
}
Coordinates = new Array ( )
Coordinates [ 0 ] = new Object ( )
Coordinates [ 0 ] . Base = 2
Coordinates [ 0 ] . Exponents = new Array ( )
Coordinates [ 0 ] . Exponents [ 0 ] = 0
Coordinates [ 0 ] . Exponents [ 1 ] = 1
for ( Quantity = 1 ; Quantity < Limit ; ++ Quantity )
{
Value = 0
for ( Index = 0 ; Index < Coordinates . length ; ++ Index )
{
if ( Coordinates [ Index ] . Exponents . length <= Quantity )
Expand ( Coordinates [ Index ] )
Value += Coordinates [ Index ] . Exponents [ Quantity ]
}
if ( ! Value )
{
Coordinates [ Index ] = new Object ( )
Coordinates [ Index ] . Base = Quantity + 1
Coordinates [ Index ] . Exponents = new Array ( )
for ( Value = 0 ; Value < Quantity ; ++ Value )
Coordinates [ Index ] . Exponents [ Value ] = 0
Coordinates [ Index ] . Exponents [ Value ] = 1
}
Numbers [ Quantity ] = 1
for ( Index = 0 ; Index < Coordinates . length ; ++ Index )
for ( Value = 0 ; Value < Coordinates [ Index ] . Exponents [
Quantity ] ; ++ Value )
Numbers [ Quantity ] *= Coordinates [ Index ] . Base
}
return Numbers
}
That is an ECMA-262 definition of the algorithm, that generates, up to a given limit, the sequence of all the positive numbers by neatly selecting the respective prime factors.
This means every JavaScript programmer can try it copying the code in an HTML document, as part of a suitable JavaScript tag.
To understand it imagine a table showing in each row a positive number and the exponents of the powers of its prime factors...
positive number | power of 2 | power of 3 | power of 5 | power of 7 | power of 11
----------------+------------+------------+------------+------------+------------
1 | 0 | 0 | 0 | 0 | 0
----------------+------------+------------+------------+------------+------------
2 | 1 | 0 | 0 | 0 | 0
----------------+------------+------------+------------+------------+------------
3 | 0 | 1 | 0 | 0 | 0
----------------+------------+------------+------------+------------+------------
4 | 2 | 0 | 0 | 0 | 0
----------------+------------+------------+------------+------------+------------
5 | 0 | 0 | 1 | 0 | 0
----------------+------------+------------+------------+------------+------------
6 | 1 | 1 | 0 | 0 | 0
----------------+------------+------------+------------+------------+------------
7 | 0 | 0 | 0 | 1 | 0
----------------+------------+------------+------------+------------+------------
8 | 3 | 0 | 0 | 0 | 0
----------------+------------+------------+------------+------------+------------
9 | 0 | 2 | 0 | 0 | 0
----------------+------------+------------+------------+------------+------------
10 | 1 | 0 | 1 | 0 | 0
----------------+------------+------------+------------+------------+------------
11 | 0 | 0 | 0 | 0 | 1
It is well known that 6, for example, is the result of 2^1*3^1*5^0*7^0.
7 == 2^0*3^0*5^0*7^1
8 == 2^3*3^0*5^0*7^0
9 == 2^0*3^2*5^0*7^0
The algorithm doesn't create the table by factoring positive numbers; instead it is capable to generate the sequence of exponents in each column following a rule so that the result of multiplying all the factors represented in a row is in a strictly increasing order with respect to the one of the succeeding row.
All that implies "discovering on the fly" the primes needed to get bigger results gradually.
The Numbers array is just to allow a simple verification of the correctness of the algorithm; in fact, for each of its elements, the following condition must occur... Numbers[Index]==Index+1
Each element of the Coordinates array corresponds, in a sense, to a column of the imagined table.
Such an element is an object for which the Base property represents the prime factor while the Exponents property represents, as an array, the column of exponents to which to rise that prime.
Coordinates[0] is a sort of "seed element". In fact the code dynamically produces all the data needed to show a table with as many rows as the given Limit value.
The Expand function is invocated every time the "insufficient currently available data" condition is reached.
The line of code...
if ( ! Value )
... is where the "next prime needed" condition is checked.
Of course every time a new prime number is involved in the data structure all the exponents, except the last one, of its "corresponding column" must be set to 0.
In the trials the max value for Limit depend on the memory available for the JavaScript interpreter and its efficiency.
At the moment I'm not interested about the innumerable ways to optimize the implementation of the algorithm... but it is important to keep in mind that it is implementable in a fashion that dynamically takes advantage of mass memory as its availability increase.
If needed to better understand what I've exposed here the following two online reference documents can be consulted...
[http://www.comprendonio.info/I/UnlimitedInside/I/Spazio%20discreto%20ad%20infinite%20dimensioni.Txt][1]
[http://www.comprendonio.info/I/UnlimitedInside/I/Sequenza%20notevole%20di%20coordinate.Txt][2]
Anyway my main concern is to get confirmation about my strong suspect that the behavior described by this algorithm is not computationally reducible.
[1]: http://www.comprendonio.info/I/UnlimitedInside/I/Spazio%20discreto%20ad%20infinite%20dimensioni.Txt
[2]: http://www.comprendonio.info/I/UnlimitedInside/I/Sequenza%20notevole%20di%20coordinate.TxtAlberto Orioli2018-05-13T22:52:31ZSolve an equation with angle of 2 transfer functions to get the capacitor?
https://community.wolfram.com/groups/-/m/t/1541421
Hello,
I have a little Mathematica notebook that equalizes the angle of 2 transfer functions to calculate a capacitor with Solve[].
In an other Computer Mathematics System I get a solution without problem, but Mathematica gives an error back.
Can anybody help me, who is better in Mathematica syntax?
Thanks,
Regards Leo
Za = I*w*L + 1/(I*w*C + 2/Z0);
Zb = 1/(I*w*C) + 1/(1/(I*w*L) + 2/Z0);
Zl = Re[1/(1/Za + 1/Zb)] - I*Im[1/(1/Za + 1/Zb)];
Zal = 1/(1/Zl + 1/Za);
Zbl = 1/(1/Zl + 1/Zb);
WU2U0a = Arg[Zbl/2/(1/(1/(Zbl + I*w*L) + I*w*C) + Z0/2)];
WU2U0b = Arg[-Zal/
2/(Z0/2 + 1/(1/(1/(Zal + 1/(I*w*C))) + (1/(I*w*L))))];
Z0 = 44 - I*15; w = 2*Pi*868*^6; L = 1.8*^-9;
Solve[WU2U0a == WU2U0b && C > 0 && C < 50*^-12, C]Leo Baumann2018-11-02T19:01:38ZPass starting values in matrix form?
https://community.wolfram.com/groups/-/m/t/1542555
Consider the following MWE, where I try to pass starting values to FindDistributionParameters[]:
ρ=0.1;
n=2;
data=RandomVariate[MultivariateTDistribution[{0,0},{{1,ρ},{ρ,1}},10],100];
emptyμ[n_] := Table[Subscript[μf, i], {i, 1, n}];
emptyΣ[n_] :=
Table[Subscript[σf^(1 + KroneckerDelta[i, j]),
Sort[{i, j}]], {i, 1, n}, {j, 1, n}];
fit = FindDistributionParameters[data,
MultivariateTDistribution[emptyμ[n],
emptyΣ[n], ν]]; (*THIS WORKS*)
I tried to add starting values to FindDistributionParameters[] as:
p = Flatten[{emptyμ[n], emptyΣ[n], ν}]
p0 = Flatten[{Mean[data], Covariance[data], 5}]
start1 = {p, p0}\[Transpose]
start2 = Rule @@@ %
start3 = {emptyμ[n] -> Mean[data], emptyΣ[n] -> Covariance[data] , ν -> 5}
fit = FindDistributionParameters[data,
MultivariateTDistribution[emptyμ[n],
emptyΣ[n], ν], start1(*start2, start3*)]; (*THIS DOESN'T WORK*)
However, nothing works.
Also, is it possible to pass only starting values for one of the required parameters, e.g. start4 = {{ν, 5}}?Fabian Wo2018-11-04T15:57:06ZMultiplication of randomly selected numbers over a certain value
https://community.wolfram.com/groups/-/m/t/1542489
How do I find the **k** value greater than **50** in how many attempts? And I want to add number of all attempts into a list.
liste = RandomReal[{1, 10}, 100];
liste2 = RandomReal[{1, 10}, 100];
m = RandomChoice[liste]
n = RandomChoice[liste2]
k = m*n
For example:
First attempt is
m=2.62987
n=7.9005
k=m*n=20.7773
Second attempt is
m=5.20733
n=3.49277
k=m*n=18.188
Third attempt is
m=9.75211
n=8.80641
k=m*n=85.881
Wanted list = {20.7773,18.188,85.881}Nagon Stewart2018-11-05T00:24:11Z