Community RSS Feed
https://community.wolfram.com
RSS Feed for Wolfram Community showing any discussions in tag Wolfram Science sorted by active[✓] Use Cases with RuleDelayed?
https://community.wolfram.com/groups/-/m/t/1632770
Let us assume very simple and dumb example of pattern extracting from some data list by Cases[]:
Cases[{{1}, {2}}, x_ -> x[[1]]]
One can run it and get
During evaluation of In[1]:= Part::partd: Part specification x[[1]] is longer than depth of object.
Out[1]= {1, 2}
What a hell, why x is not an array?
Or a little more complex example:
In[287]:= Cases[{"2","1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1"}, mList_String -> StringExtract[mList, All], 1]
During evaluation of In[287]:= StringExtract::strse: String or list of strings expected at position 1 in StringExtract[mList,All].
Out[287]= {{"2"},{"1", "0", "0", "0", "0", "1", "0", "0", "0", "0", "1", "0", "0", "0", "0", "1"}}
One can tell, that as we get after all an correct output there is no big problem in such warnings.
But if we go a little deeper the real problem rises:
In[304]:= Cases[{"2", "1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1"}, mList_String -> ToExpression[StringExtract[mList, All]], 1]
During evaluation of In[304]:= StringExtract::strse: String or list of strings expected at position 1 in StringExtract[mList,All].
During evaluation of In[304]:= ToExpression::notstrbox: StringExtract[mList,All] is not a string or a box. ToExpression can only interpret strings or boxes as Wolfram Language input.
Out[304]= {$Failed, $Failed}
Any correct result at all.
So, what is exact problem with Cases[] and how to fix it correctly (i managed to make a simple and dirty fix, but do not like it)?Snegirev Maksym2019-03-15T17:01:05Z"Functional Dataflow" Wolfram Live Coding Session // Mar 19
https://community.wolfram.com/groups/-/m/t/1634956
For those interested in data science, please join us for a 1 hour Wolfram Live Coding Session Tuesday Mar 19 2019 at 4pm ET on Zoom (https://wolfram.zoom.us/j/4659236576) . Please see the Linkedin post:
[https://www.linkedin.com/pulse/functional-dataflow-wolfram-live-coding-session-mar-19-calvitti-phd][1]
Abstract
This live coding session will focus on functional methods and patterns to write compact but flexible pipes for data science using real-world examples. The Wolfram Language is ideal to data science due to its functional orientation, large-scale symbolic processing and pattern matching abilities. Many of these features have no direct counterpart in object-oriented languages like Python. Consequently WL workflow is more programmer efficient: line-count ratios of 5:1 and often much more, are common relative to equivalent Python (inclusive of its extensive libraries). Functional programming lets you do more with less code and is more convenient and safer to refactor. After a brief tour of the forthcoming book Functional Dataflow, the focus will be on data transformation, aka "data wrangling" - recognized to be a highly time-consuming aspect of workflow - rather than on math or statistical methods. Exposition will be adapted from Excursion chapters in FD. Key skills described include composing operator pipes, combining tabular, hierarchical, temporal and graphical datasets, exploring queries on data slices then scaling up to the whole dataset, creating insightful visualizations, and writing flexible utility (eg one-liner operator) libraries for reuse in future projects.
Overview Mathematica notebook containing links to data and dependencies:
[enter link description here][2]
[1]: https://www.linkedin.com/pulse/functional-dataflow-wolfram-live-coding-session-mar-19-calvitti-phd
[2]: %22https://drive.google.com/drive/folders/1Af0yNPA5YZB0ep0Y9a6Vj2kbsWDSRqYV?usp=sharing%22Alan Calvitti2019-03-18T15:17:10ZDrawing a bell curve with specified shading under the curve
https://community.wolfram.com/groups/-/m/t/1635282
Pardon the newbie-type question, but I'm struggling with the Mathematica syntax for a bell curve. All I want to draw is a bell curve with mean 3 and SD of 0.3, but with the region between the graph, the x-axis, -2sigma and +1 sigma shaded (where sigma = standard deviation). Can someone help?
TIA
Geoffreygeoffrey Marnell2019-03-19T01:13:46ZEpilog in Manipulate are not working properly
https://community.wolfram.com/groups/-/m/t/1635365
Hello,
Epilog with "No Points" in Manipulate are not working as it should be. Does anyone know what's wrong?
data2 = {{1, 10}, {2, 11}, {3, 20}, {4, 30}};
Manipulate[
ListLinePlot[data2
, Epilog -> If[points == "No Points", None
, If[points == "Points", {PointSize[0.04], Red, Point[data2]}]
]]
, {points, {"No Points", "Points"}}
]
Thank you in advance !
Regards,....JosJos Klaps2019-03-19T01:28:52ZAutomate converting an imported excel spreadsheet to a dataset?
https://community.wolfram.com/groups/-/m/t/1566323
I would like to import a large excel spreadsheet with many columns into Mathematica. The first row of the spreadsheet contains the column headings and the remaining rows contain the data. After importing I first separate the column headings and data into separate variables and would like to convert the data to a dataset. Here is an example of what I have tried.
These steps simulate of importing the spreadsheet and separating into columns and data
cols = {"col1", "col2", "col3", "col4", "col5"};
dat = RandomReal[{0, 1}, {10, 5}];
I now need to create an association to use to map the data to the columns but here is where I am having trouble. The best I am able to come up with is to generate
assoc = Table[cols[[k]] -> #[[k]], {k, 1, 5}]
This results in some error messages, but produces
{"col1" -> 1, "col2" -> #1[[2]], "col3" -> #1[[3]], "col4" -> #1[[4]],
"col5" -> #1[[5]]}
which is nearly the result desired. I can then copy that result, paste it into a new cell, and edit that cell by hand, changing the first element of the list, applying an association function, and applying a function to get the desired function to apply to the data
assoc1 = Association[{"col1" -> #[[1]], "col2" -> #1[[2]],
"col3" -> #1[[3]], "col4" -> #1[[4]], "col5" -> #1[[5]]}] &
Map[assoc1,dat]
With this association I can then generate the dataset. Is there any way of generating this function without the necessity of the hand editing step?Mike Luntz2018-12-05T14:55:47ZIn the function RandomPoint, can I specify the size of points and square?
https://community.wolfram.com/groups/-/m/t/1635092
The following two lines generate almost exactly what I want:
pts = RandomPoint[Rectangle[], 250]
Graphics[{ImageSize->Small,PointSize[Tiny], Point[pts]}]
However, I want to be able to specify specific sizes for the points (i.e. diameter of 1.5 microns on a square that is 1000 um x 1000 um). Is there a way to do set these parameters?
If not, is there a good function on Python or Matlab that would allow me to randomly plot circles of specific diameters on squares of specified size?Claire Ruddiman2019-03-18T19:36:50ZSolve a system of Differential Equations with EigenSystem DSolve MatrixExp?
https://community.wolfram.com/groups/-/m/t/1632964
In calculating a system of differential equations, I used 3 different methods: EigenSystem, DSolve and MatrixExp. DSolve and MatrixExp porduced the same answers but a different answers than EigenSystem and I don't understand why (See Attached). In all three cases, I used a default value of {1,1} for the values of the arbitrary constants. It appears that DSolve and MatrixExp simply dropped the negative exponent.
I don't understand what I am overlooking.
Thanks,
Mitch SandlinMitchell Sandlin2019-03-15T16:41:44Zcomplete beginner question on audiodata
https://community.wolfram.com/groups/-/m/t/1634947
Dear all,
I am a complete beginner at mathematica in general, and at using it to try to investigate sounds in particular. I have done the following thing: Imported a short sample of spoken text using Import. I then looked at the plot of this imported object, using AudioPlot. The signal looks to be the same as how it was when I had the file open in another program (audacity).
Then I used AudioData to extract a sample from the imported file. At this point I am confused as to what AudioData is actually doing, because when I then use ListPlot to visualise the extracted data, it had quite clearly been clipped. Then when I tried playing back the data using ListPlay, it has transformed a sample that is 9 seconds long into a load of unintelligible nonsense that lasts for nearly a minute.
Can anyone give me a clue as to what is going on? Do I need to upload the sample file and notebook?
Thanks very much!Sara Ann2019-03-18T15:03:58ZHow to NDSolve two coupled first order PDEs with specific boundary conditio
https://community.wolfram.com/groups/-/m/t/1635326
Hi :-)
Reading and re-reading the NDSolve documentation, I don't understand the generic way to express boundary conditions. I want to solve the wave equation expressed as a system of two coupled first order equations on the voltage v(t,x) and current i(t,x). The initial v(0,x) has a bell shape and the initial i(0,x) is zero everywhere.
> eq1 = D[v[t, x], x] + D[i[t, x], t] == 0;
>eq2 = D[i[t, x], x] + D[v[t, x], t] == 0;
> shape = D[0.125 Erf[(x - 0.5)/0.125], x];
> ics ={v[0, x] == shape, i[0, x]==0};
Now the problem is to be numerically integrated with NDSolve over x in [0,1] and t in [0,2]. I want to specify either open ends v[t, 0] =v[t, 1]=0 or non reflective boundary conditions. In the first case I can do it:
> region = Line[{{0}, {1}}];
> bcs = {v[t, 0] == 0, v[t, 1] == 0};
> sol = NDSolve[{eq1,eq2, ics, bcs}//Flatten, {v, i}, {t,0,2}, {x} \[Element] region]
How to do the same in the non-reflective (or impedence matched) case? All my attemps fail.
> sol2 = NDSolve[{eq1,eq2, ics}//Flatten, {v, i}, {t,0,2}, {x} [Element] region]
without bcs renders a solution that does not corresponds to the targeted case (by the way, what are the corresponding bcs ?).
> bcs2b = {v[t, 0] == i[t, 0] , v[t, 1] == i[t, 0]};
> sol2b = NDSolve[{eq1,eq2, ics, bcs2b}//Flatten, {v, i}, {t,0,2}, {x} \[Element] region]
returns an error about "Cross-coupling of dependent variables in DirichletCondition".
> bcs3c = {
>Derivative[0,1][v][t, 0] ==-Derivative[1,0][i][t, 0] ,
>Derivative[0,1][v][t, 1] ==-Derivative[1,0][i][t, 1] };
> sol3c = NDSolve[{eq1,eq2, ics, bcs3c}//Flatten, {v, i}, {t,0,2}, {x} \[Element] region]
returns an error about too high order derivatives in boundary conditions.
How to proceed with this system of coupled first order PDEs? (note that I know how to do with a second order wave equation and Neumann values, but that's not my question). I want to express the conditions on v and i.
Thank you for your help.Denis Vion2019-03-18T19:56:07ZNIntegrate
https://community.wolfram.com/groups/-/m/t/1635118
Hi,
This integral seems to have a singularity..
all constants are defined.
NIntegrate[Exp[-alpha*Sqrt[(R^2 - 2*x*R*Cos[theta] + (x)^2) + z^2]], {z, 10*-a,
10*(L - a)}, {theta, 0, 2 Pi}]
I get a NIntegrate::slwcon warning.Haress Nazary2019-03-18T14:54:19ZHow Can I evaluate a function in two variables at a particular point (a,b)?
https://community.wolfram.com/groups/-/m/t/1635060
I need evaluate a a function in two variables in a particular point, I mean, if f(x,y)=x^2+y^2, and p=(1,1), I want to get f(1,1).Kratos Desparta2019-03-18T17:32:13ZAvoid error with the following recursive code?
https://community.wolfram.com/groups/-/m/t/1634599
Thanks for any help! I must be doing something wrong in the following recursive code:
ClearAll[lim, hlim, count, e]
lim = 25;
hlim = lim/5;
count[heading_, v_] := count[heading, v] = Block[{nv = v},
If[Total[nv] == lim,
If[heading == 0, 1, 0],
If[nv[[heading]] == hlim, 0,
nv[[heading]] = nv[[heading]] + 1;
count[If[heading == 4, 0, heading + 1], nv] +
count[If[heading == 0, 4, heading - 1], nv]]]]
e[] := Module[{}, 2*count[1, {1, 0, 0, 0, 0}]]
e[] // Timing
I expect a number, but I get:
{0.007164,
870 If[List == 5, 0, nv[[0]] = nv[[0]] + 1;
count[If[0 == 4, 0, 0 + 1], nv] + count[If[0 == 0, 4, 0 - 1], nv]]}Joe Gilray2019-03-18T07:03:07Z[Package] Phylogenetics for Mathematica
https://community.wolfram.com/groups/-/m/t/784207
[Dr. P. David Polly from Indiana University][1] published a [Phylogenetics package for Mathematica][2]. A detailed [User's Guide][3] is also available. Short discription is copied below.
**Keywords**: Phylogenetics; Ancestral Node Reconstruction; Newick Trees
**Abstract**: This add-in package for Mathematica performs basic phylogenetic functions, including reading and drawing Newick format trees, calculating phylogenetically independent contrasts, reconstructing ancestral values for continuous traits, performing random walks, and simulating continuous traits on phylogenetic trees. The file is a ".m" file, which can be imported into Mathematica 6.0 and later (functions do not work in earlier versions of Mathematica). Install using the "Install" item on the "File" menu. Once installed, you must load the package like any other with the line `<<PollyPhylogenetics`, using either this suggested name or another.
[1]: http://mypage.iu.edu/~pdpolly
[2]: https://scholarworks.iu.edu/dspace/handle/2022/14614
[3]: http://mypage.iu.edu/~pdpolly/Software/Guide%20to%20PollyPhylogenetics%203.0.pdfVitaliy Kaurov2016-02-01T13:07:47ZAvoid .NET/Link error in Visual Studio 2015?
https://community.wolfram.com/groups/-/m/t/1634807
Hi All,
Hope you are all fine.
I am trying to maintain and extend the functionality of a very old C++ program (initially coded in 2009). It was using .NET/Link feature of Wolfram. However it does not have many documentation neither comments for the code. I've encountered a problem of compiling and running it with the error said:
Exception thrown: 'System.TypeLoadException' in mscorlib.dll
Exception thrown: 'System.DllNotFoundException' in Wolfram.NETLink.dll
Exception thrown: 'System.TypeInitializationException' in Wolfram.NETLink.dll
Exception thrown: 'System.TypeInitializationException' in [My Project].exe
I should mention that this happens in the very first beginning of the code:
kernel = nullptr;
kernel = MathLinkFactory::CreateKernelLink();
And the similar problem happens to me when I was trying to run the sample code from Wolfram official platform, it is a C# program though:
Exception thrown: 'System.TypeLoadException' in mscorlib.dll
Exception thrown: 'System.DllNotFoundException' in Wolfram.NETLink.dll
Exception thrown: 'System.TypeInitializationException' in Wolfram.NETLink.dll
'MathKernelApp.vshost.exe' (CLR v2.0.50727: MathKernelApp.vshost.exe)
I am not sure if this is a problem of environment setup or it is because of the incompatibility between Wolfram and Windows 10.
Operating System: Windows 10
IDE: Visual Studio 2015
Target Platform Version: 10.0.16299.0
Platfomr Toolset: Visual Studio 2015 (v140)
**A quick update:**
I have resolved problem in MathKernelApp provided by Wolfram by copying and pasting the ml64i4.dll into the Release folders. I thought it may help to my original problem but not. It is a separate problem and I still have no idea of how to fix the first one.Haifeng Zhao2019-03-18T00:41:44ZCreate 9 sided dice?
https://community.wolfram.com/groups/-/m/t/1632720
G'Day Folks,
I am interested in creating a (3d printed) sudoku board...
I wanted to start with (something like) a 9-sided dice.
I think that if you 'sliced' 9 flat faces into a sphere you'd get something like it. :)
The faces would need to be the same size and equidistant; which sounds simple.
But, my mathematical knowledge isn't good enough for this.
I've been using Open SCAD for modelling; and have created a Dodecahedron (12 sided regular polyhedron); and I guess this would be OK - with 3 "black" faces.
Does anyone have any suggestions!?
cheers
SteveStephen Peter2019-03-15T05:49:34Z[GIF] Minimal (Rotating minimal lattice trefoil knot)
https://community.wolfram.com/groups/-/m/t/1634541
![Rotating minimal lattice trefoil knot][1]
**Minimal**
This shows the trefoil knot lying on the simple cubic lattice with the fewest possible number of edges (it's [a theorem of Yuanan Diao][2] that the lattice stick number of the trefoil is 24), rotated, and projected to the plane.
The 3D vertex locations are in [KnotPlot][3]. At least in the MacOS version of KnotPlot, the data is contained in the app bundle at `/Applications/KnotPlot/KnotPlot.app/Contents/Resources/special/mscl/3.1`; if you don't have KnotPlot installed, you can download the data by going to <https://knotplot.com/download/> and clicking the link to download `kpdist.tar.gz`. If you do that and then unzip to get a directory called `kpsdist`, the following commands will import the vertices and mean center:
lattice31 = Import["kpdist/special/mscl/3.1", "Table"];
lattice31 = lattice31 - Table[Mean[lattice31], {Length[lattice31]}];
As usual for animations where I want to smoothly stop and start a motion, I'm going to use the [`smootheststep` function][4]:
smootheststep[t_] := -20 t^7 + 70 t^6 - 84 t^5 + 35 t^4;
Here, then, is the `Manipulate` for the above animation (the giant obnoxious `Which` is to switch between different axis rotations, which I obviously could have made a little cleaner with some extra work):
DynamicModule[{p, q, a, b, n, M, θ, pl,
cols = RGBColor /@ {"#fd5f00", "#05004e", "#fbfaf1"}},
Manipulate[
Which[t < 1 || t == 4,
{p, q} = RotationMatrix[ArcTan[1/Sqrt[2]]].{Normalize[{1, 1, 0}], {0, 0, 1}};
θ = -(ArcTan[1/Sqrt[2]] + π/2) smootheststep[Mod[t, 1]];
{n, b} = RotationMatrix[θ].{p, q};,
1 <= t < 2,
{p, q} = {{0, 0, 1}, {-(1/Sqrt[2]), -(1/Sqrt[2]), 0}};
θ = (π - ArcTan[Sqrt[23 - 16 Sqrt[2]]]) smootheststep[Mod[t, 1]];
{n, b} = RotationMatrix[-θ,
N@{Sqrt[1/17 (5 + 2 Sqrt[2])], Sqrt[1/17 (7 - 4 Sqrt[2])],
Root[1 - 10 #1^2 + 17 #1^4 &, 1]}].# & /@ {p, q};,
2 <= t < 3,
{p, q} = {{-1, 0, 0}, {0, 0, 1}};
θ = 3 π/4 smootheststep[Mod[t, 1]];
{n, b} = RotationMatrix[θ].{p, q},
3 <= t,
{p, q} = {{1/Sqrt[2], 0, -(1/Sqrt[2])}, {-(1/Sqrt[2]), 0, -(1/Sqrt[2])}};
θ = (π - ArcCot[(3 - 2 Sqrt[2] + 2 Sqrt[3] + Sqrt[6])/Sqrt[
13 - 4 Sqrt[3] + 2 Sqrt[6]]]) smootheststep[Mod[t, 1]];
{n, b} = RotationMatrix[-θ,
N@{Root[1 - 156 #1^2 + 1670 #1^4 - 5148 #1^6 + 4801 #1^8 &,
1], Root[1 - 52 #1^2 + 870 #1^4 - 5044 #1^6 + 4801 #1^8 &,
2], (2 + Sqrt[2])/Sqrt[
94 - 48 Sqrt[2] + 48 Sqrt[3] - 32 Sqrt[6]]}].# & /@ {p, q};
];
a = Cross[b, n];
M = {a, b};
pl = M.# & /@ lattice31;
Graphics[
{Thickness[.004], cols[[1]], Line[Append[#, First[#]] &[pl]],
FaceForm[cols[[-1]]],
EdgeForm[Directive[Thickness[.004], cols[[2]]]],
Disk[M.#, .05] & /@ Sort[lattice31, n.#1 > n.#2 &]},
ImageSize -> 540, PlotRange -> 2.2, Background -> cols[[-1]]],
{t, 0, 4}]
]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=lt7q.gif&userId=610054
[2]: https://doi.org/10.1142/S0218216593000234
[3]: https://knotplot.com
[4]: https://en.wikipedia.org/wiki/SmoothstepClayton Shonkwiler2019-03-17T23:11:24ZImport large data files for Machine Learning?
https://community.wolfram.com/groups/-/m/t/1599142
I want to run a machine learning task on my Win 10 PC, 16GB RAM, Mathematica 11.3.0, but I am facing the following problems: training set size 10GB CSV file, with 700,000,000 x 2 datasets. Mathematica simply stops during import via Import or ReadList function. My idea is to split the input file into several smaller files that could be imported and to load the smaller files in a batch to feed the Predict function or perhabs a neural network. Any idea how to make it happen? Do you have a better idea?
Many thanks in advance for support!Jürgen Kanz2019-01-26T11:41:17ZImport .dae 3D format files without ignoring nodes?
https://community.wolfram.com/groups/-/m/t/1633798
Collada .dae 3D format is in fact xml document which contains <library_geometries> section with some "meshes", where the coordinates and normals of surface meshes points are provided.
But that coordinates are not refereed to basic coordinate system. DAE file contains an other, <library_visual_scenes> section, which holds a tree of nested lists of "nodes" - transformation matrices describing coordinate transformation of the nested node from the parent one. And only the last, leaf node contains reference to some mesh name, so the mesh coordinate system is given by set of coordinate transformation. A lot of 3D modelling soft exports a set of model "parts" in very such way.
Looks like Mathematica Import[] function do not take into account nodes section, so imported complex models have details teared apart and grouped near the center of coordinates. Import[SomeModel, "CoordinateTransform"] provides a single and unit transformation matrix not changes at all on change of "nodes" matrices
1. Have tried to import some .dae models. Import[SomeModel, "MeshRegion"] and Import[SomeModel, "GraphicsComplex"] both give the same teared apart result.
2. Coded some handmade parser, which extracts meshes from <library_geometries> and provides the resulting set of 3D surfaces without additional transformations - completely the same "teared" result as in stage 1.
3. Coded additional parser, which extracts a set of transformation matrices for every mesh, and applied a result to it - valid 3D model with the parts on proper places.
ps: it would be very convenient if Import[] did not "melts" all meshes in a single one, but provides them as a set of objects together with their transformation martices, or have a option for this.Snegirev Maksym2019-03-16T09:40:04ZGenerate Newton-Girald formula?
https://community.wolfram.com/groups/-/m/t/1634323
n = 2
I am not getting the determinant of the NW. Can somebody suggest what is wrong?
S[1] = Table[i*e[i], {i, 1, n}]
S[2] = {1, Table[e[i], {i, 1, n - 1}]}
S[3] = {0, 1, Table[e[i], {i, 1, n - 2}]}
For[i = 4; t = x, i < n + 1, i++,
S[i] = {ConstantArray[0, i - 2], ConstantArray[1, 1],
Table[e[j], {j, 1, n - i + 1}]}; Print[S[i]]]
EQ1 = Table[S[j], {j, 1, n}]
NW = MatrixForm[EQ1]
NW1 = Det[Transpose[NW]]Rajan Prasad2019-03-17T03:30:03ZIncrease mathematica's menu font size?
https://community.wolfram.com/groups/-/m/t/1634439
Hello, I have vision issues & need to increase the size of the font in my menu. Can someone tell me how to do this? Thanks, JeffreyJeffrey Denison2019-03-16T19:30:11ZAvoid issue in DateString?
https://community.wolfram.com/groups/-/m/t/1633972
Consider the following code:
DateString[{2000, 1, 1, 0, 0, 0}, {"Year", " ", "Month", " ", "Day",
" ", "SecondExact", " "}]
yields
2000 01 01 00.000
but
DateString[{2000,1,1,0,0,0},{"Year"," ","Month"," ","Day"," ","MinuteExact"," "}]
and
DateString[{2000,1,1,0,0,0},{"Year"," ","Month"," ","Day"," ","HourExact"," "}]
yield
2000 01 01 {0., QuantityMagnitude[Minute]}
and
2000 01 01 {0., QuantityMagnitude[Hour]}
respectively.
It does not seem like the units should be present in the last two cases for Minute and Hour.Vincent Virgilio2019-03-15T23:42:20ZIs there a Wolfram Player Pro trial license available?
https://community.wolfram.com/groups/-/m/t/1634056
"Is there a Wolfram Player Pro trial license available?"
I want to test it for a limited time and simply want to try it out.Wolfgang Hitzl2019-03-16T09:49:59ZAvoid leaky symbols in "Install Wolfram System Item"?
https://community.wolfram.com/groups/-/m/t/1634031
The first execution of dialog "File > Install …" fails in its field "Source" if symbols x or s\$ exist in the context path. The second execution of same dialog clears the errors, whereupon field "Source" appears to work properly. The second execution does /not/ remove or clear symbols x and s\$; they are still in the context path in multiple locations.Vincent Virgilio2019-03-16T00:44:42ZUpdate AppendTo when interacting with PopupMenu?
https://community.wolfram.com/groups/-/m/t/1632919
I'm trying to `ListPlot` a list calculated by the `Button` called "Plot" with `PopupMenu` linked to `ListPlot` to control the temperature units of displayed data, for example: if `"DegreesCelsius" -> "C"` is selected from the list then `ListPlot` should show plotted curve in `"DegreesCelsius"` and the same goes for `"DegreesFahrenheit"`. `AppendTo` is used here to `ListPlot` new list every time the input of `InputField` is changed and `Button` is pressed by appending it to the old one.
My Problem is that the temperature units of the plotted curves don't change when selecting different values from `PopupMenu`. `AppendTo` doesn't update accordingly. I can see that `popupSelection` variable changes when interacting with `PopupMenu` but `plotData` variable only changes when `Button` is pressed, using current `PopupMenu` selection.
If I remove `AppendTo` from `Button` and include `dataSet4:=Transpose[...]` instead, as well as keeping it in `Initialization` everything works as I wanted. I tried to make several changes by shifting things around but nothing helped.
Please Help!
The example below demonstrates the issue.
DynamicModule[{},
inputList = {{1, 5}, {2, 4}, {3, 8}};
Dynamic@Column[{
InputField[Dynamic[inputData]],
Dynamic@Button["Plot",
dataSet1 = Map[Norm, Differences[inputList]];
dataSet2 = Exp[-N[Pi]*0.345*5*dataSet1/(10*2000)];
dataSet3 = FoldList[10 + (#1 - 10)*#2 &, inputData, dataSet2];
AppendTo[plotData, dataSet4]], Spacer[5],
PopupMenu[Dynamic[popupSelection], {"DegreesCelsius" -> "C", "DegreesFahrenheit" -> "F"}],
ListPlot[plotData, Joined -> True, ImageSize -> {300}, Frame -> True]}],
Initialization :> (
popupSelection = "DegreesCelsius";
inputData = 0;
plotData = {};
dataSet3 = {0};
dataSet4 := Transpose[{inputList[[All, 1]], QuantityMagnitude@UnitConvert[QuantityArray[dataSet3, "DegreesCelsius"], popupSelection]}];),
SynchronousInitialization -> False]Kamila Szklarczyk-Marshall2019-03-15T14:46:49ZGet more general ConditionalExpression answers from Integrate?
https://community.wolfram.com/groups/-/m/t/1633944
I'm running Integrate on a 4 variable function, performing 2 definite (but still symbolic) integrals. The output is a ConditionalExpression function valid for part of the remaining 2 dimensional space. Is there a way to force Mathematica to continue generating additional ConditionalExpressions for other parts of the remaining space without having to hold its hand and do this piecemeal?
Thank you,
NathanNathan M2019-03-15T19:56:45ZAvoid issue while using Mod[] in NDSolve[]?
https://community.wolfram.com/groups/-/m/t/1632458
Let us assume a simple rotation motion, when angular acceleration az somewhat depends on angle Phi[t] and set as linear interpolation function in range of 0..360 degrees.
To not come out from interpolation range let angle Phi to be truncated to proper range by Mod[Phi][t], 360]:
az = Interpolation[{{0., 1.}, {90., 4}, {180., 7.}, {270., 4.}, {360.,
1.}}, InterpolationOrder -> 1];
{\[Omega]s, \[CurlyPhi]s} = NDSolveValue[{
\!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]\ \(\[Omega][
t]\)\) == (az[Mod[\[CurlyPhi][t], 360]] + 10000),
\!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]\ \(\[CurlyPhi][
t]\)\) == \[Omega][t],
\[CurlyPhi][0] == 359, \[Omega][0] ==
390 }, {\[Omega], \[CurlyPhi]}, {t, 0, 0.0029}]
Let run it, and we get
InterpolatingFunction::dmval: Input value {360.052} lies outside the range of data in the interpolating function. Extrapolation will be used.
This is quite weird result - we have truncate phi by 360 and got 360.0520876770316`
Adding
EvaluationMonitor :>
Print[t, " ", \[CurlyPhi][t], " ", Mod[\[CurlyPhi][t], 360]]
Gives list like
...
0.00203059 359.813 359.813
0.00232059 359.932 359.932
InterpolatingFunction::dmval: Input value {360.052} lies outside the range of data in the interpolating function. Extrapolation will be used.
0.0026103 360.052 0.0520877
0.00248493 360. 360.
0.00248493 360. 0.
0.00248493 360. 0.
0.00248493 360. 2.19102*10^-6
Mod[] works fine in the EvaluationMonitor, but fails in main NDSolve loop.
Can anyone tell the reason of such behavior and how to fix it?Snegirev Maksym2019-03-14T17:31:10ZSystem to test the performances of Model-Free Controller?
https://community.wolfram.com/groups/-/m/t/1632904
Hi everyone, I am designing model-free controllers and I would like to simulate the performances with Wolfram. Does someone have challenging transfer function of a real plant as well as the desired objectives (settling time, rising, time, overshoot, error etc). I want to simulate the performances of this model-free controller and see if it can reach defined real specifications.
Thank you in advanceDavid Monjengue2019-03-15T12:27:32Z[Numberphile] - The Square-Sum Problem
https://community.wolfram.com/groups/-/m/t/1264240
As part of my Numberphile series of posts:
- [\[Numberphile\] - Frog Jumping - Solving the puzzle][1]
- [\[Numberphile\] - The Illumination Problem][2]
- [\[Numberphile\] - Sandpiles - Done in the Wolfram Language][3]
here is another one about a recent video called [The Square-Sum Problem][4]
[![enter image description here][5]][6]
The question is: if you have the integers 1 through n, can you arrange that list in such a way that every two adjacent ones sum to a square number. As seen in the video and the [extra footage][7].
We can easily check this in the Wolfram Language:
Let's see which number can pair up to a pair:
SquareEdges[n_Integer?Positive]:=Reap[Do[If[IntegerQ[Sqrt[i+j]],Sow[{i,j}]],{i,n-1},{j,i+1,n}]][[2,1]]
Now let's try for 15, as in the main video:
n = 15;
poss = SquareEdges[n];
gr = Graph[TwoWayRule @@@ poss, VertexLabels -> Automatic];
path = FindHamiltonianPath[gr, PerformanceGoal :> "Speed"]
HighlightGraph[gr, BlockMap[Rule @@ # &, path, 2, 1]]
giving:
{9, 7, 2, 14, 11, 5, 4, 12, 13, 3, 6, 10, 15, 1, 8}
![enter image description here][8]
In the extra footage, it is revealed that they found the solution for up to n=299. Can we do better? Yes we can! Changing n to 300 in the above code and rerunning gives us the solution in 0.28 sec on my laptop.
{289,35,65,259,30,294,67,257,32,292,69,100,44,125,71,154,135,189,211,113,248,8,281,119,205,195,166,158,283,6,250,191,133,156,285,4,252,277,12,244,117,207,193,168,273,16,240,160,164,236,20,269,131,94,230,59,197,92,232,57,199,90,234,22,267,217,224,137,152,73,123,46,150,75,121,48,148,77,179,110,214,270,19,237,163,161,239,17,272,128,41,103,297,27,262,62,227,97,99,190,210,114,175,50,146,79,177,112,212,188,253,3,286,155,134,266,23,233,91,198,58,231,93,196,60,229,95,130,159,165,276,13,243,118,206,194,167,274,15,241,288,1,255,186,138,223,218,143,181,108,88,201,55,170,86,203,53,172,84,37,107,182,142,299,25,264,220,221,140,184,216,225,64,36,85,171,54,202,87,169,56,200,89,235,21,268,132,157,284,5,251,278,11,245,116,208,192,249,7,282,247,9,280,204,120,136,153,72,124,45,151,74,122,47,149,76,180,109,215,185,139,222,219,265,24,300,141,183,106,38,83,173,52,144,81,40,104,296,28,261,63,226,98,127,42,102,298,26,263,61,228,96,129,271,18,238,162,279,10,246,115,209,275,14,242,287,2,254,187,213,111,178,78,147,49,176,80,145,51,174,82,39,105,295,29,260,101,43,126,70,291,33,256,68,293,31,258,66,34,290}
and a completely mess of a graph:
![enter image description here][9]
Can we go beyond? Let's optimize a code a bit, and let's find the solution for larger n:
Let's store our intermediate results in the association **db**:
SetDirectory[NotebookDirectory[]];
$HistoryLength=1;
db=If[FileExistsQ["squaresumdb.mx"],
Import["squaresumdb.mx"]
,
<||>
];
And now our main code:
ClearAll[SquareEdges,SquareEdges2,CheckSol,TryToFind]
SquareEdges[n_Integer?Positive]:=Reap[Do[If[IntegerQ[Sqrt[i+j]],Sow[{i,j}]],{i,n-1},{j,i+1,n}]][[2,1]]
SquareEdges2[n_Integer]:=Module[{tmp},
tmp=Table[
{i,#}&/@(Range[Ceiling[Sqrt[2 i]],Floor[Sqrt[i+n]]]^2-i)
,
{i,1,n-1}
];
tmp=Join@@tmp;
Select[tmp,Less@@#&]
]
CheckSol[l_List]:=Sort[l]===Range[Length[l]]\[And](And@@BlockMap[IntegerQ@*Sqrt@*Total,l,2,1])
TryToFind[n_Integer?Positive]:=Module[{edges,out},
If[!KeyExistsQ[db,n],
edges=SquareEdges2[n];
If[Union[Flatten[edges]]===Range[n],
edges=TwoWayRule@@@edges;
edges=RandomSample[edges];
Do[
out=TimeConstrained[FindHamiltonianPath[Graph[edges],PerformanceGoal:>"Speed"],5+i,$Failed];
If[out=!=$Failed,
If[Length[out]==0,
Print[Style["No solution for ",Red],n];
,
status=Row[{"Found solution for ",n,":",i}];
];
AssociateTo[db,n->out];
Break[]
];
Print["Failed ",n,":",i];
edges=RandomSample[edges];
,
{i,5}
]
,
Print["Edges are not connected for ",n];
AssociateTo[db,n->{}]
]
]
]
Let's scan the first 1000:
Dynamic[status]
status = "";
Do[TryToFind[k], {k, 3, 1000}]
Export["squaresumdb.mx", db];
Note that if finding the Hamiltonian path takes too long I mix the edges and try again, sometimes, seemingly random, it then finds the solution quickly.
I can tell you now that all of them have a solution. In fact I went up to larger numbers and found that all up to 2667 have a solution, and possibly beyond. I attached the notebook and the solutions in form of a mx file.
[1]: http://community.wolfram.com/groups/-/m/t/1055504
[2]: http://community.wolfram.com/groups/-/m/t/1048489
[3]: http://community.wolfram.com/groups/-/m/t/1058615
[4]: https://www.youtube.com/watch?v=G1m7goLCJDY
[5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2018-01-11at23.36.51.png&userId=73716
[6]: https://www.youtube.com/watch?v=G1m7goLCJDY
[7]: https://www.youtube.com/watch?v=7_ph5djCCnM
[8]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2018-01-11at23.43.52.png&userId=73716
[9]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ScreenShot2018-01-11at23.46.51.png&userId=73716Sander Huisman2018-01-11T23:29:05Z[✓] Make a test using pattern matching for pairs of numbers?
https://community.wolfram.com/groups/-/m/t/1632364
I need to make a test that resolves to true or false for this problem, given a list of pairs of numbers for example:-
testno={{2,47},{3,22},{5,12},{7,8},{11,4},{13,3},{17,2},{19,2},{23,2},{29,1},{31,1},{37,1},{41,1},{43,1},{47,1}}
and a smaller list of pairs of numbers
num={{2,12},{3,2},{11,1}};
num1={{2,12},{3,2},{17,3}}
Lets say the designation is {a, b} for each pair of numbers. The first test is do all "a" position numbers from "num" appear at some place in the "a" positions of "testno" and if so are the magnitude of the corresponding "b" position numbers in "testno" greater than or equal to the corresponding "b" position numbers in "num"? in the example shown "num" passes the test, however, num1 would fail. In the final setup the number of elements of both "testno" and "num" can vary even to where the lengths of both are the same. I know this can be done by using some form of do loop or even table and test each sub element in turn, but I am sure there is a more elegant way with pattern matching, any pointers would be welcome.Paul Cleary2019-03-14T17:03:39Z[GIF] Mochi For Pie Day
https://community.wolfram.com/groups/-/m/t/1632354
####*Please download the notebook at the end of the discussion*
----------
![loop][1]
The idea is from the study of the graphical representation of [this inequality][2]: for positive $a$ $b$ and $c$
$\frac{1}{a+2b}+\frac{1}{b+2c}+\frac{1}{c+2a} \le \sqrt{ \frac{a+b+c}{3abc}}$
Usually this type of problems is not AM-GM or Cauchy-Schwartz or Muirhead friendly. Very tricky to use elementary methods and they are pooly generalized to other similar case, because they highly depends on the convexity of quadratic function and critical infomation like $C^{\infty}$ is not respected.
The animation is for a generalized form of the aforementioned inequality.
WLOG (based on homogenity of power on both LHS and RHS) let's assume $a + b + c = 1$ and parameterize them with spherical coordinate:
a = (Cos[\[Theta]] Sin[\[Phi]])^2;
b = (Cos[\[Theta]] Cos[\[Phi]])^2;
c = Sin[\[Theta]]^2;
The original equation is thus reduced to this form:
expr = Sqrt[3*a*b*c]*(1/(a + 2*b) + 1/(b + 2*c) + 1/(c + 2*a));
and the inequality problem automatically transforms to an optimization problem.
maxima = Table[
FindMaximum[
expr, {{\[Phi], x}, {\[Theta], y}}], {x, {1}}, {y, {0.5, 2.5}}]
Label the maxima:
![graph][3]
I suspect the magic $3$ on the RHS of the inequality comes from the coefficients of $1(a)+2(b)$ of the denominators on the LHS (no proof and is only true for some $\lambda$) , including the cyclic forms. Thus I replace the coefficients by $1+\lambda$ and $2-\lambda$ respectively, to keep their sum equal to 3. The animation is generated by sweeping through a set of different values of $\lambda$. $Tan^{-1}$ is used to make the animation slow-mo when approaching the end points of $\lambda$ domain. The visual is smooth and soothing.
constant=N[ArcTan/@(Range[0,40,2.]*0.1)]*0.9
frames=(0.5-Reverse@constant)~Join~(0.62+constant);
ListPlot[frames]
![plot][4]
The animation is interesting to look at. One of the unusual behavior is that the function has very flat top when $\lambda$ is close to $1.7$, the [Rosenbrock function like plateau][5] makes it very hard to find extrema.
I call it mochi because the wavy transformation of the 3D graphics in the animation resembles [this video clip of baking japanese rice cake][6].
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=3952loop3.gif&userId=23928
[2]: https://artofproblemsolving.com/community/c6h1800806p11954963
[3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=1925graph.png&userId=23928
[4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=giphy2.gif&userId=23928
[5]: http://mathworld.wolfram.com/RosenbrockFunction.html
[6]: https://youtu.be/C5C8GQnI7C0?t=34Shenghui Yang2019-03-14T16:54:20ZAvoid issue while using RegionPlot?
https://community.wolfram.com/groups/-/m/t/1631786
My simple code
o1 = Rectangle[{0, 0}, {3, 2}];
o2 = Disk[{3, 1}, 0.5];
o = RegionDifference[o1, o2];
RegionPlot[o, PlotRange -> Full]
DiscretizeRegion[o]
Produces this strange output. It seems to me, that the RegionPlot output is not OK, beacuse the shape of the region is different. Function DiscretizeRegion works as expected..
![Screenshot][1]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=regionplot.jpg&userId=143709Tomáš Hruš2019-03-14T09:12:13ZPerformance reduction of FindMinimum in version 10
https://community.wolfram.com/groups/-/m/t/868933
When working on [this question][1] dedicated to what I believe is a significant limitation/defect of the current implementation of the `"LevenbergMarquardt"` algorithm in `FindMinimum`, I found that the same code evaluates 15 - 25 times slower in version 10.4.1 as compared to version 8.0.4 on the same machine!
At the bottom of this post a Notebook containing the complete setup reproducing the issue is attached.
The following is a comparison of absolute timings of the same `FindMinimum` code evaluated with the two versions along with the number of steps taken by `FindMinimum`, achieved minimum and obtained new values of parameters of the model. The setup can be found in the attached Notebook.
With version 8.0.4 on Windows 7 x64 I get the following:
findMinimum[init, MaxIterations -> 500, WorkingPrecision -> 20, PrecisionGoal -> 3,
StepMonitor :> ++steps, Method -> {"LevenbergMarquardt", "Residual" -> residualVect}]
> {"00:06:35", 220, 0.00405321003823167,
> {ν0[1]->406.18, Γ[1]->346.16, ζ[2]->0.22879, ν0[2]->666.41, Γ[2]->239.54, ζ[3]->0.20278}}
The output means that the evaluation has taken 6 min 35 sec and finished in 220 steps, obtained minimum is `0.00405321003823167`, the obtained new values of the parameters follow.
And this is what I get with version 10.4.1 installed on the same machine:
findMinimum[init, MaxIterations -> 500, WorkingPrecision -> 20, PrecisionGoal -> 3,
StepMonitor :> ++steps, Method -> {"LevenbergMarquardt", "Residual" -> residualVect}]
> {"02:37:07", 220, 0.00405321003823167,
> {ν0[1]->406.18, Γ[1]->346.16, ζ[2]->0.22879, ν0[2]->666.41, Γ[2]->239.54, ζ[3]->0.20278}}
As you see, the only difference is that now the evaluation has taken 2 hours 37 min 7 sec! **It is more than 23 times slower than with version 8.0.4!**
----------
Do you experience the same problem? Is it possible to get `FindMinimum` of version 10.4.1 working as fast as `FindMinimum` of version 8.0.4?
[1]: http://mathematica.stackexchange.com/q/116295/280Alexey Popkov2016-06-07T09:49:31ZTokyo Tube
https://community.wolfram.com/groups/-/m/t/1632078
Last month, a TV program "[Chico Will Scold You][1]" of Japan public broadcasting picked up the Tokyo subway. The TV show introduced the 3 D model of Tokyo subway, "[Tokyo Arteria][2]" which created by Takatsugu KURIYAMA.
I was influenced by the beauty, so I tried to make something similar with Mathematica. Because I create it using Mathematica's Tube function, I named it "Tokyo Tube".
![enter image description here][3]
There are 13 subways in Tokyo. I gathered the information of latitude, longitude and depth (from the ground) of all stations (287 stations) from web and book.
I will explain on the Hanzomon line as an example. The figure on the left shows connecting stations by the shortest straight line. However, the actual route is a more complicated. The figure on the right is the result of Google Map route search.
![enter image description here][4]
The TV program explained why Tokyo's subway is so complicated.
The answer is there is the law that if you buy land, you will have the right of both the ground and the underground. So it is necessary to pay the land fee to all of them to get through a subway. In order to avoid this, a subway runs under the roads owned by the state or municipality because their underground can be used free of charge for public interest purposes.
In addition, the roads in Tokyo are not straight because the roads are made by filling roads and waterways that were made in a radial shape based on the Edo Castle during the Edo period.
- From the result of Google Map route search, I search the route position using PixelValuePositions function.
![enter image description here][5]
![enter image description here][6]
- I sort the points by y - axis, latitude. So the first point is the starting station, the Shibuya Station and the last point is the terminal station, Oshiage Station. However, just connecting the sorted points does not follow the route (left figure). So, I use FindShortestTour function to rearrange according to the route, and select about 100 points from them for the Graphics3D (right figure).
p2 = Sort[p, #1[[2]] < #2[[2]] &];
s = FindShortestTour[p2, 1, Length[p2]];
p3 = Append[
Take [p2[[Last[s]]], {1, m = Length@Last[s], Round[m/100]}],
p2[[-1]]];
{ListLinePlot[p2], ListLinePlot[p3]}
![enter image description here][7]
These points are converted into 3 D display based on the information of latitude, longitude and depth of all stations above. The actual map obtained by GeoGraphics function is pasted on the top surface.
![enter image description here][8]
The following is the result of carrying out this work for 13 lines.
![enter image description here][9]
The figure below shows the Ginza Line, the oldest in business, and the Oedo Line, the newest. The subway created later is deeper. And the Roppongi Station on the Oedo Line is at the deepest position 42.3 meters underground.
![enter image description here][10]
In addition, the Fukutoshin Line, which is the most recently full-opened, was created between the Marunouchi Line and the Shinjuku Line. The distance between the lines is about 11 cm at the shortest distance.
Now, the law that it can be used free of charge at a place deeper than 40 meters if it is the public interest purpose was made. The Linear Chuo Shinkansen, which digs underground straight in the urban area, will aim to open in 2027.
I have attached a notebook of Graphics3D "Tokyo Tube", so please rotate it.
[1]: http://www4.nhk.or.jp/chikochan/
[2]: https://www.youtube.com/watch?v=eW59JgzyH70
[3]: https://community.wolfram.com//c/portal/getImageAttachment?filename=1040801.jpg&userId=1013863
[4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=287302.jpg&userId=1013863
[5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=796108.jpg&userId=1013863
[6]: https://community.wolfram.com//c/portal/getImageAttachment?filename=103603.jpg&userId=1013863
[7]: https://community.wolfram.com//c/portal/getImageAttachment?filename=1044204.jpg&userId=1013863
[8]: https://community.wolfram.com//c/portal/getImageAttachment?filename=895805.jpg&userId=1013863
[9]: https://community.wolfram.com//c/portal/getImageAttachment?filename=892206.jpg&userId=1013863
[10]: https://community.wolfram.com//c/portal/getImageAttachment?filename=101107.jpg&userId=1013863Kotaro Okazaki2019-03-14T13:29:19ZGet two columns of numerical data as output data format?
https://community.wolfram.com/groups/-/m/t/1631879
Hi
I am solving a system of two equations with two variables z and x repeatedly in a cycle. At each step the solution is output into a file using **Write** function. I've pasted a part of the file below. Apart from the numerical data, it contains also other things, like curly brackets, symbols like **z->** . But I need to make a file that contains only two columns of numerical data, nothing else. How can I do that?
{z -> -2.1337292689248377, x -> -1.0028011752012573}
{z -> -1.5494511566425633, x -> -1.0015118850013995}
{z -> 0.14651664469911463, x -> -622.9327284292021}
{z -> 2.3907571924477877, x -> -1.0037755798274968}
{z -> 3.928880270839741, x -> -52.74880957186027}
{z -> 5.2048915646949965, x -> -1.017772661581148}
{z -> 9.062107349506263, x -> -1.0515309552374674}
{z -> 10.152134293099394, x -> -1.0641971180448309}
{z -> 14.312077199555635, x -> -395.73358957571725}Lev Dorosinskiy2019-03-14T08:31:22Z[GIF] Gravity wave visualization
https://community.wolfram.com/groups/-/m/t/790989
![enter image description here][1]
With all of the rumors and excitement about the gravity wave press release tomorrow, I was reminded of this code I've had lying around for years for creating a gravity wave visualization (seen above) for illustrative purposes. You can find also a [video here][2]. It was inspired by an interaction I had years ago (unfortunately I can't find the interaction in my email) with someone on the [LISA][3] project wanting to use Mathematica to re-create a visualization they had. This code was the result of that interaction.
First, the primary goal was to generate a "space-time" surface and mesh that had a double-armed spiral wave on it. The following code generates that. Its dependent on a rotation angle Theta which is not specified here:
Plot3D[(60 Cos[
2 ArcTan[y/(x + 0.00001)] - \[Theta] + 0.544331 Sqrt[x^2 + y^2]])/(
20 + Sqrt[x^2 + y^2]), {x, -45, 45}, {y, -45, 45}, PlotPoints -> 100,
Mesh -> 20, MeshStyle -> {RGBColor[.5, .5, .5, .5]}, Boxed -> False,
BoxRatios -> Automatic, Axes -> False,
PlotStyle -> {RGBColor[.3, .3, .8]}, ImageSize -> {1024, 768},
Lighting -> {{"Directional", White, ImageScaled[{0, 0, 2.}]}},
ViewPoint -> {-0.011, -3.043, 1.479}, Background -> Black,
BoundaryStyle -> RGBColor[.5, .5, .5, .5]]
I wanted to overlay 2 stars or black holes on top of the surface. Combining the above with this overlay and giving a value to the angle Theta we get:
With[{\[Theta] = 0},
Show[Plot3D[(
60 Cos[2 ArcTan[y/(x + 0.00001)] - \[Theta] +
0.544331 Sqrt[x^2 + y^2]])/(
20 + Sqrt[x^2 + y^2]), {x, -45, 45}, {y, -45, 45},
PlotPoints -> 100, Mesh -> 20,
MeshStyle -> {RGBColor[.5, .5, .5, .5]}, Boxed -> False,
BoxRatios -> Automatic, Axes -> False,
PlotStyle -> {RGBColor[.3, .3, .8]}, ImageSize -> {1024, 768},
Lighting -> {{"Directional", White, ImageScaled[{0, 0, 2.}]}},
ViewPoint -> {-0.011, -3.043, 1.479}, Background -> Black,
BoundaryStyle -> RGBColor[.5, .5, .5, .5]],
Graphics3D[{Directive[Hue[.58, 0, 1],
Lighting ->
Join[{{"Ambient", Black}},
Table[{"Directional", Hue[.58, .5, 1],
ImageScaled[{Sin[x], Cos[x], -.5}]}, {x, 0, 2 Pi - 2 Pi/8,
2 Pi/8}]]],
Sphere[{2 Cos[\[Theta] - \[Pi]/2], 2 Sin[\[Theta] - \[Pi]/2], 3},
1], Sphere[{Cos[\[Theta] + \[Pi]/2], Sin[\[Theta] + \[Pi]/2], 3},
1]}], PlotRange -> All]]
![enter image description here][4]
Next, I wanted to animate this to give the effect that the spiral arms are rotating outwards. That's done by incrementing the angle Theta and generating a list of frames that can then be exported.
anim = Table[
Rasterize[
Show[Plot3D[(
60 Cos[2 ArcTan[y/(x + 0.00001)] - \[Theta] +
0.544331 Sqrt[x^2 + y^2]])/(
20 + Sqrt[x^2 + y^2]), {x, -45, 45}, {y, -45, 45},
PlotPoints -> 100, Mesh -> 20,
MeshStyle -> {RGBColor[.5, .5, .5, .5]}, Boxed -> False,
BoxRatios -> Automatic, Axes -> False,
PlotStyle -> {RGBColor[.3, .3, .8]}, ImageSize -> {800, 450},
Lighting -> {{White, ImageScaled[{0, 0, 2.}]}},
ViewPoint -> {-0.011, -3.043, 1.479},
Background -> RGBColor[0, 0, 0], BoundaryStyle -> Gray],
Graphics3D[{Directive[Hue[.58, 0, 1],
Lighting ->
Join[{{"Ambient", Black}},
Table[{"Directional", Hue[.58, .5, 1],
ImageScaled[{Sin[x], Cos[x], -.5}]}, {x, 0, 2 Pi - 2 Pi/8,
2 Pi/8}]]],
Sphere[{2 Cos[\[Theta] - \[Pi]/2], 2 Sin[\[Theta] - \[Pi]/2],
3}, 1], Sphere[{Cos[\[Theta] + \[Pi]/2],
Sin[\[Theta] + \[Pi]/2], 3}, 1]}],
PlotRange -> All]], {\[Theta], 0, 2 \[Pi], .1}];
And then to export it to an animated GIF:
Export["GravityWave.gif", anim]
The result is the animation at the top of this post.
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=ezgif.com-optimize%283%29.gif&userId=20103
[2]: https://www.youtube.com/watch?v=WiNKulqt0SE
[3]: http://lisa.nasa.gov/
[4]: http://community.wolfram.com//c/portal/getImageAttachment?filename=gravitywave60.png&userId=25355
[5]: http://community.wolfram.com//c/portal/getImageAttachment?filename=GravityWave.gif&userId=25355Jeff Bryant2016-02-10T19:35:05ZOn rolling polygons and Reuleaux polygons
https://community.wolfram.com/groups/-/m/t/1628699
By this time, people are already familiar with [Stan Wagon's demonstration][1] of rolling regular polygons over a piecewise catenary road, as first shown in his [paper][2] with Leon Hall.
The purpose of this post is to show a particularly compact `Manipulate[]` demonstration for rolling regular polygons, as well as a variation where the wheel is a [Reuleaux polygon][3].
This hinges on two things: `NDSolve[]`'s ability to cope with discontinuous differential equations, and the existence of a usable polar equation in both the regular and Reuleaux polygon cases.
For the conventional regular polygon example, we can use the polar equation
$$r=\frac{\cos\left(\frac{\pi}{n}\right)}{\cos\left(\left(\left(\theta-\frac{\pi}{n}+\frac{\pi}{2}\right)\bmod \frac{2\pi}{n}\right) -\frac{\pi}{n}\right)}$$
which is a rotated modification of the formula in [this Math Stack Exchange answer][4].
Manipulate[DynamicModule[{road, sol},
sol = NDSolveValue[{\[FormalTheta]'[x] ==
1/ngon[n, \[FormalTheta][x]],
\[FormalTheta][0] == -π/2},
\[FormalTheta], {x, -1, 6}];
road = Plot[-ngon[n, sol[x]], {x, -1, 6}];
Show[road,
Graphics[{{Directive[EdgeForm[GrayLevel[1/4]],
ColorData[97, 3]],
Dynamic[RegularPolygon[{t, 0},
{1, π/n - π - sol[t]}, n]]},
{Directive[AbsolutePointSize[6],
ColorData[97, 4]],
Point[Dynamic[{t, 0}]]}}],
AspectRatio -> Automatic, Axes -> None,
GridLines -> {None, {0}},
Method -> {"GridLinesInFront" -> True},
PlotRange -> {All, {-1, 1}}]],
{{n, 4, "sides"}, 3, 12, 1}, {t, 0, 5, Animator},
Initialization :> (ngon[n_Integer, θ_] :=
Cos[π/n] Sec[Mod[θ - π/n + π/2, 2 π/n] - π/n]),
SaveDefinitions -> True, SynchronousUpdating -> False]
![rolling square][5]
---
Now, let us turn to the Reuleaux polygon case. [I (relatively) recently derived a polar equation][6] for the Reuleaux polygons to finally solve [a longstanding problem of mine][7] of seeing what the corresponding road for a Reuleaux polygon looks like. The polar equation is understandably a little more elaborate:
$$\small r=\sqrt{1+2\cos\frac{\pi}{n}+\cos^2\left(\left(\left(\theta+\frac{\pi}{2}+\frac{\pi}{n}\right)\bmod{\frac{2\pi}{n}}\right)-\frac{\pi}{n}\right)}-\cos\left(\left(\left(\theta+\frac{\pi}{2}+\frac{\pi}{n}\right)\bmod{\frac{2\pi}{n}}\right)-\frac{\pi}{n}\right)$$
The formula can be compacted a bit in *Mathematica* by using the three-argument form of `Mod[]`.
Manipulate[DynamicModule[{road, sol, wheel},
sol = NDSolveValue[{\[FormalTheta]'[x] ==
1/reuleaux[n, \[FormalTheta][x]],
\[FormalTheta][0] == -π/2},
\[FormalTheta], {x, -1, 6}];
road = Plot[-reuleaux[n, sol[x]], {x, -1, 6}];
wheel = First[Cases[Normal[PolarPlot[reuleaux[n, θ], {θ, 0, 2 π},
Exclusions -> None]], Line[pts_] :> pts, ∞]];
Show[road,
Graphics[{{Directive[EdgeForm[GrayLevel[1/4]], ColorData[97, 3]],
Polygon[Dynamic[
AffineTransform[{RotationMatrix[-π/2 - sol[t]],
{t, 0}}][wheel]]]},
{Directive[AbsolutePointSize[6], ColorData[97, 4]],
Point[Dynamic[{t, 0}]]}}],
AspectRatio -> Automatic, Axes -> None, GridLines -> {None, {0}},
Method -> {"GridLinesInFront" -> True},
PlotRange -> {All, {-1, 1}}]],
{{n, 3, "sides"}, 3, 11, 2}, {t, 0, 5, Animator},
Initialization :> (reuleaux[n_Integer, θ_] :=
Sqrt[1 + 2 Cos[π/n] +
Cos[Mod[θ + π/2, 2 π/n, -π/n]]^2] -
Cos[Mod[θ + π/2, 2 π/n, -π/n]]),
SaveDefinitions -> True, SynchronousUpdating -> False]
![rolling Reuleaux triangle][8]
Here is an animation I did much earlier:
![rolling Reuleaux triangle][9]
Using the same equation, I tried to derive a closed form for the road, but got stymied when it involved the inversion of the elliptic integral of the second kind, `EllipticE[]`.
[1]: http://demonstrations.wolfram.com/RoadsAndWheels/
[2]: https://doi.org/10.2307/2691240
[3]: http://mathworld.wolfram.com/ReuleauxPolygon.html
[4]: https://math.stackexchange.com/a/41954
[5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=polyroll1.png&userId=520181
[6]: https://tpfto.wordpress.com/2019/03/07/on-a-polar-equation-for-reuleaux-polygons-and-how-to-roll-them/
[7]: https://math.stackexchange.com/q/8750
[8]: https://community.wolfram.com//c/portal/getImageAttachment?filename=polyroll2.png&userId=520181
[9]: https://community.wolfram.com//c/portal/getImageAttachment?filename=ZzERK.gif&userId=520181J. M.2019-03-11T14:21:14ZArrowHead not at the end of a tube? (Mathematica V11.3)
https://community.wolfram.com/groups/-/m/t/1302365
With the 11.3 version the combination Arrow Tube give unexpected results : the arrow head is not positionned at the end of the tube as expected from documentation :
http://reference.wolfram.com/language/ref/Arrow.html
3rd example of the basics
Code example :
Graphics3D[{Red, Arrowheads[0.1],
Arrow[Tube[{{1, 1, -1}, {2, 2, 0}, {3, 3, -1}, {4, 4, 0}}, 0.05]]}]Dominique Massiot2018-03-14T17:17:07ZInterpret a standard date format with SemanticInterpretation?
https://community.wolfram.com/groups/-/m/t/1631713
I find the following a little disappointing:
SemanticInterpretation["2019-Feb-17 00:15:06.745140"]
which produces:
$Failed
Similarly for:
Interpreter["DateTime"][["2019-Feb-17 00:15:06.745140"]
and
Interpreter["Date"]["2019-Feb-17 00:15:06.745140"]
Is there a quick way to get Semantic... to recognize the date/time semantics in the string "2019-Feb-17 00:15:06.745140" ?
Thanks,
VinceVincent Virgilio2019-03-13T15:06:55ZWhere is the scrollbar on step-by-step solutions W|A?
https://community.wolfram.com/groups/-/m/t/1559973
I don't know if I'm missing something obvious, but on my tablet I can't scroll when Wolfram Alpha gives me step-by-step solutions. This is consistent across all queries, so I can only ever see the first step. Sorry if this has been asked, but Google is giving me nothing.
![Problem][1]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Capture.PNG&userId=1559959Jordan M2018-11-26T20:10:17ZGather and analyse data from internet using WebSearch and WebAccess?
https://community.wolfram.com/groups/-/m/t/1630225
Hi everyone,
I'm trying to use Mathematica to automatically gather and analyze data from the internet. It's a pet project but one that I hope to become quite useful some day. I've made decent progress but then ran into some issues. At the moment, I'm trying to solve two issues, and would appreciate any help or suggestions how to resolve them:
1. WebSearch stopped working. I've been using WebSearch to find websites of solar energy related topics. It worked great at the beginning, but after two days of using it, the command stopped working. Now it executes as if it was an unknown command (i.e. just returns the written text WebSearch["topic"]. Does anyone have an idea what happened there? Neither restarting the computer nor quitting the kernel helped.
2. This might be a stupid question, but I have banged my head against it for too long. How do I reset the saved ServiceConnect connection to GoogleCustomSearch? I want the program to prompt the API again, but have so far been unsuccessful (even after updating from 11.2 to 11.3 it didn't prompt the API again). ServiceDisconnect doesn't do the trick, as it doesn't delete saved connection. Anyone any ideas?
Thanks so much!Ian Marius Peters2019-03-12T15:04:55ZCelebrating 30th anniversary of the world wide web
https://community.wolfram.com/groups/-/m/t/1631212
![enter image description here][4]
Today (March 12) is the 30th anniversary of the [world wide web][2] and I was curious about how "world wide" the web has become. So, I decided to create the above BubbleChart in order to explore today's (2018) internet users as percentage of population versus GDP per capita in US dollars. Bubbles size depicts countries population. And the percents for internet users come from [internet world stats site][3].
The list of countries that appear in the BubbleChart are the following (note that I excluded some countries like North Korea and others with missing data):
countries = {Entity["Country", "Anguilla"],
Entity["Country", "AntiguaBarbuda"], Entity["Country", "Argentina"],
Entity["Country", "Aruba"], Entity["Country", "Bahamas"],
Entity["Country", "Barbados"], Entity["Country", "Belize"],
Entity["Country", "Bermuda"], Entity["Country", "Bolivia"],
Entity["Country", "Brazil"],
Entity["Country", "BritishVirginIslands"],
Entity["Country", "Canada"], Entity["Country", "CaymanIslands"],
Entity["Country", "Chile"], Entity["Country", "Colombia"],
Entity["Country", "CostaRica"], Entity["Country", "Cuba"],
Entity["Country", "Dominica"],
Entity["Country", "DominicanRepublic"],
Entity["Country", "Ecuador"], Entity["Country", "ElSalvador"],
Entity["Country", "FalklandIslands"],
Entity["Country", "FrenchGuiana"], Entity["Country", "Greenland"],
Entity["Country", "Grenada"], Entity["Country", "Guadeloupe"],
Entity["Country", "Guatemala"], Entity["Country", "Guyana"],
Entity["Country", "Haiti"], Entity["Country", "Honduras"],
Entity["Country", "Jamaica"], Entity["Country", "Martinique"],
Entity["Country", "Mexico"], Entity["Country", "Montserrat"],
Entity["Country", "Nicaragua"], Entity["Country", "Panama"],
Entity["Country", "Paraguay"], Entity["Country", "Peru"],
Entity["Country", "PuertoRico"],
Entity["Country", "SaintKittsNevis"],
Entity["Country", "SaintLucia"],
Entity["Country", "SaintPierreMiquelon"],
Entity["Country", "SaintVincentGrenadines"],
Entity["Country", "Suriname"], Entity["Country", "TrinidadTobago"],
Entity["Country", "TurksCaicosIslands"],
Entity["Country", "UnitedStates"], Entity["Country", "Uruguay"],
Entity["Country", "UnitedStatesVirginIslands"],
Entity["Country", "Algeria"], Entity["Country", "Angola"],
Entity["Country", "Benin"], Entity["Country", "Botswana"],
Entity["Country", "BurkinaFaso"], Entity["Country", "Burundi"],
Entity["Country", "CapeVerde"], Entity["Country", "Cameroon"],
Entity["Country", "CentralAfricanRepublic"],
Entity["Country", "Chad"], Entity["Country", "Comoros"],
Entity["Country", "DemocraticRepublicCongo"],
Entity["Country", "IvoryCoast"], Entity["Country", "Djibouti"],
Entity["Country", "Egypt"], Entity["Country", "EquatorialGuinea"],
Entity["Country", "Ethiopia"], Entity["Country", "Gabon"],
Entity["Country", "Gambia"], Entity["Country", "Ghana"],
Entity["Country", "Guinea"], Entity["Country", "GuineaBissau"],
Entity["Country", "Kenya"], Entity["Country", "Lesotho"],
Entity["Country", "Liberia"], Entity["Country", "Libya"],
Entity["Country", "Madagascar"], Entity["Country", "Malawi"],
Entity["Country", "Mali"], Entity["Country", "Mauritania"],
Entity["Country", "Mauritius"], Entity["Country", "Morocco"],
Entity["Country", "Mozambique"], Entity["Country", "Namibia"],
Entity["Country", "Niger"], Entity["Country", "Nigeria"],
Entity["Country", "Rwanda"], Entity["Country", "SaoTomePrincipe"],
Entity["Country", "Senegal"], Entity["Country", "Seychelles"],
Entity["Country", "SierraLeone"], Entity["Country", "Somalia"],
Entity["Country", "SouthAfrica"], Entity["Country", "SouthSudan"],
Entity["Country", "Sudan"], Entity["Country", "Swaziland"],
Entity["Country", "Tanzania"], Entity["Country", "Togo"],
Entity["Country", "Tunisia"], Entity["Country", "Uganda"],
Entity["Country", "WesternSahara"], Entity["Country", "Zambia"],
Entity["Country", "Zimbabwe"], Entity["Country", "AmericanSamoa"],
Entity["Country", "Australia"], Entity["Country", "CookIslands"],
Entity["Country", "Fiji"], Entity["Country", "FrenchPolynesia"],
Entity["Country", "Guam"], Entity["Country", "Kiribati"],
Entity["Country", "MarshallIslands"],
Entity["Country", "Micronesia"], Entity["Country", "Nauru"],
Entity["Country", "NewCaledonia"], Entity["Country", "NewZealand"],
Entity["Country", "Niue"],
Entity["Country", "NorthernMarianaIslands"],
Entity["Country", "Palau"], Entity["Country", "PapuaNewGuinea"],
Entity["Country", "Samoa"], Entity["Country", "SolomonIslands"],
Entity["Country", "Tokelau"], Entity["Country", "Tonga"],
Entity["Country", "Tuvalu"], Entity["Country", "Vanuatu"],
Entity["Country", "Albania"], Entity["Country", "Andorra"],
Entity["Country", "Austria"], Entity["Country", "Belarus"],
Entity["Country", "Belgium"],
Entity["Country", "BosniaHerzegovina"],
Entity["Country", "Bulgaria"], Entity["Country", "Croatia"],
Entity["Country", "Cyprus"], Entity["Country", "CzechRepublic"],
Entity["Country", "Denmark"], Entity["Country", "Estonia"],
Entity["Country", "FaroeIslands"], Entity["Country", "Finland"],
Entity["Country", "France"], Entity["Country", "Germany"],
Entity["Country", "Gibraltar"], Entity["Country", "Greece"],
Entity["Country", "Hungary"], Entity["Country", "Iceland"],
Entity["Country", "Ireland"], Entity["Country", "Italy"],
Entity["Country", "Jersey"], Entity["Country", "Kosovo"],
Entity["Country", "Latvia"], Entity["Country", "Liechtenstein"],
Entity["Country", "Lithuania"], Entity["Country", "Luxembourg"],
Entity["Country", "Macedonia"], Entity["Country", "Malta"],
Entity["Country", "Moldova"], Entity["Country", "Monaco"],
Entity["Country", "Montenegro"], Entity["Country", "Netherlands"],
Entity["Country", "Norway"], Entity["Country", "Poland"],
Entity["Country", "Portugal"], Entity["Country", "Romania"],
Entity["Country", "Russia"], Entity["Country", "SanMarino"],
Entity["Country", "Serbia"], Entity["Country", "Slovakia"],
Entity["Country", "Slovenia"], Entity["Country", "Spain"],
Entity["Country", "Sweden"], Entity["Country", "Switzerland"],
Entity["Country", "Turkey"], Entity["Country", "Ukraine"],
Entity["Country", "UnitedKingdom"], Entity["Country", "Bahrain"],
Entity["Country", "Iran"], Entity["Country", "Iraq"],
Entity["Country", "Israel"], Entity["Country", "Jordan"],
Entity["Country", "Kuwait"], Entity["Country", "Lebanon"],
Entity["Country", "Oman"], Entity["Country", "Qatar"],
Entity["Country", "SaudiArabia"], Entity["Country", "Syria"],
Entity["Country", "UnitedArabEmirates"],
Entity["Country", "Afghanistan"], Entity["Country", "Armenia"],
Entity["Country", "Azerbaijan"], Entity["Country", "Bangladesh"],
Entity["Country", "Bhutan"], Entity["Country", "Brunei"],
Entity["Country", "Cambodia"], Entity["Country", "China"],
Entity["Country", "HongKong"], Entity["Country", "Georgia"],
Entity["Country", "India"], Entity["Country", "Indonesia"],
Entity["Country", "Japan"], Entity["Country", "Kazakhstan"],
Entity["Country", "SouthKorea"], Entity["Country", "Kyrgyzstan"],
Entity["Country", "Laos"], Entity["Country", "Macau"],
Entity["Country", "Malaysia"], Entity["Country", "Maldives"],
Entity["Country", "Mongolia"], Entity["Country", "Myanmar"],
Entity["Country", "Nepal"], Entity["Country", "Pakistan"],
Entity["Country", "Philippines"], Entity["Country", "Singapore"],
Entity["Country", "SriLanka"], Entity["Country", "Taiwan"],
Entity["Country", "Tajikistan"], Entity["Country", "Thailand"],
Entity["Country", "EastTimor"], Entity["Country", "Turkmenistan"],
Entity["Country", "Uzbekistan"], Entity["Country", "Vietnam"],
Entity["Country", "Yemen"], Entity["Country", "Venezuela"]}
percents = {Quantity[84.2`, "Percent"], Quantity[79.5`, "Percent"],
Quantity[93.1`, "Percent"], Quantity[94.6`, "Percent"],
Quantity[83.4`, "Percent"], Quantity[79.9`, "Percent"],
Quantity[52.3`, "Percent"], Quantity[98.`, "Percent"],
Quantity[78.6`, "Percent"], Quantity[70.7`, "Percent"],
Quantity[46.9`, "Percent"], Quantity[89.9`, "Percent"],
Quantity[88.7`, "Percent"], Quantity[77.5`, "Percent"],
Quantity[63.2`, "Percent"], Quantity[86.7`, "Percent"],
Quantity[40.3`, "Percent"], Quantity[67.2`, "Percent"],
Quantity[61.1`, "Percent"], Quantity[79.9`, "Percent"],
Quantity[57.7`, "Percent"], Quantity[99.2`, "Percent"],
Quantity[41.4`, "Percent"], Quantity[92.1`, "Percent"],
Quantity[63.9`, "Percent"], Quantity[53.4`, "Percent"],
Quantity[42.1`, "Percent"], Quantity[50.5`, "Percent"],
Quantity[18.`, "Percent"], Quantity[38.2`, "Percent"],
Quantity[54.5`, "Percent"], Quantity[78.8`, "Percent"],
Quantity[65.`, "Percent"], Quantity[57.9`, "Percent"],
Quantity[43.`, "Percent"], Quantity[69.7`, "Percent"],
Quantity[89.6`, "Percent"], Quantity[67.6`, "Percent"],
Quantity[83.3`, "Percent"], Quantity[78.8`, "Percent"],
Quantity[79.6`, "Percent"], Quantity[79.6`, "Percent"],
Quantity[69.9`, "Percent"], Quantity[59.8`, "Percent"],
Quantity[73.1`, "Percent"], Quantity[78.3`, "Percent"],
Quantity[95.6`, "Percent"], Quantity[88.2`, "Percent"],
Quantity[60.6`, "Percent"], Quantity[44.2`, "Percent"],
Quantity[19.3`, "Percent"], Quantity[33.1`, "Percent"],
Quantity[39.6`, "Percent"], Quantity[18.8`, "Percent"],
Quantity[5.5`, "Percent"], Quantity[48.1`, "Percent"],
Quantity[24.8`, "Percent"], Quantity[5.4`, "Percent"],
Quantity[5.`, "Percent"], Quantity[15.7`, "Percent"],
Quantity[6.1`, "Percent"], Quantity[26.3`, "Percent"],
Quantity[18.5`, "Percent"], Quantity[49.5`, "Percent"],
Quantity[23.8`, "Percent"], Quantity[15.3`, "Percent"],
Quantity[47.7`, "Percent"], Quantity[18.1`, "Percent"],
Quantity[34.3`, "Percent"], Quantity[12.3`, "Percent"],
Quantity[6.3`, "Percent"], Quantity[85.`, "Percent"],
Quantity[27.7`, "Percent"], Quantity[8.1`, "Percent"],
Quantity[58.7`, "Percent"], Quantity[7.2`, "Percent"],
Quantity[9.5`, "Percent"], Quantity[65.3`, "Percent"],
Quantity[17.8`, "Percent"], Quantity[63.4`, "Percent"],
Quantity[62.4`, "Percent"], Quantity[17.3`, "Percent"],
Quantity[30.8`, "Percent"], Quantity[4.3`, "Percent"],
Quantity[50.2`, "Percent"], Quantity[29.8`, "Percent"],
Quantity[27.7`, "Percent"], Quantity[59.8`, "Percent"],
Quantity[70.5`, "Percent"], Quantity[11.7`, "Percent"],
Quantity[7.9`, "Percent"], Quantity[53.7`, "Percent"],
Quantity[17.3`, "Percent"], Quantity[28.5`, "Percent"],
Quantity[32.1`, "Percent"], Quantity[38.9`, "Percent"],
Quantity[11.3`, "Percent"], Quantity[67.7`, "Percent"],
Quantity[42.9`, "Percent"], Quantity[5.`, "Percent"],
Quantity[41.2`, "Percent"], Quantity[40.2`, "Percent"],
Quantity[39.5`, "Percent"], Quantity[87.8`, "Percent"],
Quantity[65.5`, "Percent"], Quantity[54.9`, "Percent"],
Quantity[69.1`, "Percent"], Quantity[80.9`, "Percent"],
Quantity[27.8`, "Percent"], Quantity[39.5`, "Percent"],
Quantity[53.2`, "Percent"], Quantity[53.4`, "Percent"],
Quantity[85.8`, "Percent"], Quantity[88.1`, "Percent"],
Quantity[91.8`, "Percent"], Quantity[72.5`, "Percent"],
Quantity[36.2`, "Percent"], Quantity[10.8`, "Percent"],
Quantity[50.6`, "Percent"], Quantity[12.1`, "Percent"],
Quantity[61.5`, "Percent"], Quantity[53.`, "Percent"],
Quantity[46.2`, "Percent"], Quantity[29.3`, "Percent"],
Quantity[65.8`, "Percent"], Quantity[87.4`, "Percent"],
Quantity[87.9`, "Percent"], Quantity[71.1`, "Percent"],
Quantity[94.4`, "Percent"], Quantity[80.7`, "Percent"],
Quantity[66.3`, "Percent"], Quantity[90.9`, "Percent"],
Quantity[81.7`, "Percent"], Quantity[87.7`, "Percent"],
Quantity[96.9`, "Percent"], Quantity[97.7`, "Percent"],
Quantity[96.4`, "Percent"], Quantity[94.3`, "Percent"],
Quantity[92.6`, "Percent"], Quantity[96.2`, "Percent"],
Quantity[94.5`, "Percent"], Quantity[70.1`, "Percent"],
Quantity[88.6`, "Percent"], Quantity[99.`, "Percent"],
Quantity[92.7`, "Percent"], Quantity[92.4`, "Percent"],
Quantity[70.2`, "Percent"], Quantity[80.4`, "Percent"],
Quantity[86.2`, "Percent"], Quantity[98.4`, "Percent"],
Quantity[90.4`, "Percent"], Quantity[96.9`, "Percent"],
Quantity[75.9`, "Percent"], Quantity[83.3`, "Percent"],
Quantity[71.2`, "Percent"], Quantity[95.5`, "Percent"],
Quantity[69.9`, "Percent"], Quantity[95.9`, "Percent"],
Quantity[99.2`, "Percent"], Quantity[78.1`, "Percent"],
Quantity[77.9`, "Percent"], Quantity[73.5`, "Percent"],
Quantity[76.1`, "Percent"], Quantity[52.7`, "Percent"],
Quantity[72.2`, "Percent"], Quantity[85.`, "Percent"],
Quantity[79.9`, "Percent"], Quantity[92.6`, "Percent"],
Quantity[96.7`, "Percent"], Quantity[91.`, "Percent"],
Quantity[68.4`, "Percent"], Quantity[93.`, "Percent"],
Quantity[94.7`, "Percent"], Quantity[98.`, "Percent"],
Quantity[69.1`, "Percent"], Quantity[48.3`, "Percent"],
Quantity[79.7`, "Percent"], Quantity[87.8`, "Percent"],
Quantity[97.8`, "Percent"], Quantity[91.`, "Percent"],
Quantity[68.5`, "Percent"], Quantity[98.1`, "Percent"],
Quantity[90.2`, "Percent"], Quantity[33.`, "Percent"],
Quantity[98.4`, "Percent"], Quantity[16.5`, "Percent"],
Quantity[72.5`, "Percent"], Quantity[80.6`, "Percent"],
Quantity[53.3`, "Percent"], Quantity[45.3`, "Percent"],
Quantity[94.6`, "Percent"], Quantity[49.3`, "Percent"],
Quantity[56.7`, "Percent"], Quantity[87.`, "Percent"],
Quantity[68.`, "Percent"], Quantity[34.1`, "Percent"],
Quantity[53.7`, "Percent"], Quantity[93.3`, "Percent"],
Quantity[76.4`, "Percent"], Quantity[92.6`, "Percent"],
Quantity[40.7`, "Percent"], Quantity[35.9`, "Percent"],
Quantity[81.`, "Percent"], Quantity[78.3`, "Percent"],
Quantity[76.5`, "Percent"], Quantity[64.1`, "Percent"],
Quantity[33.4`, "Percent"], Quantity[54.7`, "Percent"],
Quantity[22.2`, "Percent"], Quantity[62.9`, "Percent"],
Quantity[83.6`, "Percent"], Quantity[32.`, "Percent"],
Quantity[87.9`, "Percent"], Quantity[33.1`, "Percent"],
Quantity[82.4`, "Percent"], Quantity[31.`, "Percent"],
Quantity[17.9`, "Percent"], Quantity[47.7`, "Percent"],
Quantity[66.3`, "Percent"], Quantity[24.3`, "Percent"],
Quantity[53.1`, "Percent"]};
bubbles =
MapThread[
Callout[{CountryData[#1, "GDPPerCapita"], #2,
CountryData[#1, "Population"]},
CountryData[#1, "Name"]] &, {countries, percents}]
bubblesGrouped = GroupBy[bubbles, CountryData[#[[-1]], "Continent"] &]
BubbleChart[bubblesGrouped,
ScalingFunctions -> {"Log", "Log", Automatic},
PlotLabel -> Style["Internet users vs GDP per capita", Bold, 24],
FrameLabel -> {Style["GDP per person in US dollars", 20],
Style["Internet users as percentage of population (%)", 20]},
PlotTheme -> "Detailed", ImageSize -> 800, ChartStyle -> "Pastel",
ChartLegends -> Keys[bubblesGroups]]
![enter image description here][1]
Without using "Log" Scaling function for "internet users percents" the resulting BubbleChart is better for separating countries with high GDP per capita:
BubbleChart[bubblesGrouped,
ScalingFunctions -> {"Log", Automatic, Automatic},
PlotLabel -> Style["Internet users vs GDP per capita", Bold, 24],
FrameLabel -> {Style["GDP per person in US dollars", 20],
Style["Internet users as percentage of population (%)", 20]},
PlotTheme -> "Detailed", ImageSize -> 800, ChartStyle -> "Pastel",
ChartLegends -> Keys[bubblesGroups]]
![enter image description here][4]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Internet_BubbleChart.png&userId=95400
[2]: https://en.wikipedia.org/wiki/World_Wide_Web
[3]: https://www.internetworldstats.com/stats.htm
[4]: https://community.wolfram.com//c/portal/getImageAttachment?filename=bubble2.png&userId=20103Jofre Espigule2019-03-13T04:00:02ZAvoid extra comma while importing a text file as a vector?
https://community.wolfram.com/groups/-/m/t/1630177
Hello everyone. I am currently having some issues using Import on a txt file which is a Python output.
When I import said file as a vector, a comma appears before one of the elements, making it impossible to work with said vector. I will adjoint images of my problem in case someone can aid me.
Thanks in advance.![enter image description here][1]
![enter image description here][2]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=comma_issue.png&userId=1570098
[2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=file_in_question.png&userId=1570098Jaime de la Mota2019-03-12T14:17:00ZGet point coordinates from an image with two plot lines?
https://community.wolfram.com/groups/-/m/t/1630016
Hello everyone, I'm still very new to Mathematica and image processing, so any help would be really appreciated, I have a 2d image with 2 lines in it (the lines color would be either red or green) my goal is to be able to get the coordinates of 2 (random) points on each of the 2 lines, the 2 lines intersect so there's no problem if one of the 2 points is the intersection point of the 2 lines.
Thank you, Daniel.daniel kamel2019-03-12T10:27:45ZInconsistency of TreeForm symbol depending on argument?
https://community.wolfram.com/groups/-/m/t/1630114
Hi,
It seems TreeForm has different visual representation depending on arguments.
TreeForm[Graphics[{Circle[{0,0}],Disk[{2,2}]}]] works as it has to be.
TreeForm[Graph[{1->2,3->2}]] works completly differently.
Is it ok? Why TreeForm doesn't show Head and atoms in a second case as it does in the first one?
![Two calls of TreeForm symbol][1]
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Image%202019-03-12%20at%2013.35.34.public.png&userId=1629699Roman Kozak2019-03-12T11:39:37ZImprove the precision of the Whittaker function?
https://community.wolfram.com/groups/-/m/t/1630027
mu = -0.1;
beta = -0.5;
sigma = 2.5;
a = 90;
b = 120;
m = -1/(4*beta); m1 = m - 1/2;
a1 = mu/(sigmasigmabeta)a^(-2beta);
b1 = mu/(sigmasigmabeta)b^(-2beta);
MyF[k_] := Gamma[ m - k](WhittakerW[k, m1, b1]WhittakerM[k, m1, a1] - WhittakerM[k, m1, b1]*WhittakerW[k, m1, a1]);
this code MyF[1000]=0.
But for this code:
MyF1[k_] := N[ Gamma[Rationalize[ m - k]](WhittakerM[Rationalize[k], 0, Rationalize[a1]] WhittakerW[Rationalize[k], 0, Rationalize[b1]] - WhittakerM[Rationalize[k], 0, Rationalize[b1]] WhittakerW[ Rationalize[k], 0, Rationalize[a1]]), 5];
MyF1[1000]=0.044810;xin jiang2019-03-12T12:01:00Z[Wolfram U] Applying Neural Networks Webinar Series
https://community.wolfram.com/groups/-/m/t/1606945
![enter image description here][1] ![enter image description here][2]
This [free webinar series][3] will cover neural network applications in three topic areas:
February 6 - Computer Vision and Deep Learning
February 20 - Computational Audio Processing
March 6 - Natural Language Processing
[![enter image description here][5]][3]
Take a deep dive into the workflows for building, training and evaluating neural networks. See how you can use custom neural net models to solve complex processing tasks involving image, audio and natural language data. Our developers will give hands-on demonstrations, showing real-world applications using new Wolfram Language functionality and improved neural net models in each subject area.
The webinar series will show you how to:
- Use built-in neural net functions in the Wolfram Language
- Download and customize pretrained models from the Neural Network Repository
- Build and train a neural net model from scratch
- Apply the models to real-world problems in computer vision, audio processing and natural language processing.
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=neural.jpeg&userId=20103
[2]: https://community.wolfram.com//c/portal/getImageAttachment?filename=9e9ac68a8bda353e11cd42a78c2fdf7b.jpg&userId=20103
[3]: https://register.gotowebinar.com/register/8483454983347919875
[4]: https://register.gotowebinar.com/register/8483454983347919875
[5]: https://community.wolfram.com//c/portal/getImageAttachment?filename=btn-register-now-app.png&userId=20103Moderation Team2019-02-06T17:24:20ZGet information on the algorithms used for SequencePredict?
https://community.wolfram.com/groups/-/m/t/1629723
Hello!
I successfully used SequencePredict in a small research project and now I want to publish my results in a journal. Where can I find some information on the algorithm? How to describe the function in a journal paper? The documentation is of no help, some Markov model is cited but this doesn't help me.
Thank you in advance for any suggestions.
FulvioFulvio Cecconi2019-03-12T07:13:58ZUnderstand the meaning of & operator?
https://community.wolfram.com/groups/-/m/t/1628635
Hi there,
A simple problem appeared and I can't solve it by myself. Plese don't focus on the meaning of the functions and of the values assigned to variables: I suspect the problem is on how I treat aa and bb.
After defining the following functions XX and Hvv that I can call in the code:
XX = -Inverse[aa].(bb.UU );
Hvv = cc.(Inverse[s i - aa].bb);
If I call
X=XX&[aa=4,bb=5,cc=6]
and then call Hvv
Hv=Hvv&[aa=6,bb=7]
I get wrong values for Hv.
But if after calling X=XX&(ecc.) I re-evaluate the definition of Hvv = cc.(Inverse[s i - aa].bb) then everything is fine if I call now Hv=Hvv(ecc.).
I guess I'm misunderstanding the meaning of f(aa)&(aa=a) which I intend as "evaluate f ifor aa=a".
You guys have insight on how to solve this?
Thanks.Ermanno Citraro2019-03-11T02:34:39ZMapThread conflicting with DynamicModule
https://community.wolfram.com/groups/-/m/t/1625808
I'm creating an interactive UI which allows the user to import data from a spreadsheet, perform calculation and plot the results.
The issue I'm having is with MapThread[] which is evaluated at the same time as the DynamicModule[], giving an error message that dimensions of objects are incompatible. I noticed that outputs of dynamically displayed objects such as buttons in this case are retained in the memory and used as initial values every time DynamicModule[] is re-evaluated (specifying initial values didn't help), and because dimensions of these objects are different at the point of DynamicModule[] re-evaluation further output of ListPlot[] is suppressed before any action is taken. I'm struggling to get around this problem. Any help will be greatly appreciated.
DynamicModule[{userSystemWindow = {}},
Dynamic@Column[{
Row[(*Load Data Button*)
{Button[
"Load Geometry",
userSystemWindow = SystemDialogInput["FileOpen"];
importedData =
If[ToString[userSystemWindow] != "$Canceled",
Flatten[Import[userSystemWindow, "XLSX"], 1] // Rest, {}],
Method -> "Queued"] }],
Spacer[1], Style[
Dynamic@Grid[{(*Calculate Button*)
{Button[
"Calculate",
calculatedList1 = Table[1, {N[Length[importedData] - 1]}];
For[l = 2, l <= Length[importedData], l++,
calculatedList1[[l - 1]] =
Sqrt[(importedData[[l, 1]] -
importedData[[l - 1, 1]])^2 + (importedData[[l, 2]] -
importedData[[l - 1, 2]])^2]];
PrependTo[calculatedList1, 0];
calculatedList2 = Table[1, Length[importedData]];
For[t = 2; calculatedList2[[1]] = 170,
t <= Length[importedData], t++,
calculatedList2[[t]] =
10 + (calculatedList2[[t - 1]] - 10)*
Exp[-N[Pi]*0.345*5*calculatedList1[[t]]/(10*2000)]],
Method -> "Queued", ImageSize -> {75, 27},
ContentPadding -> True,
Enabled -> (If[
ToString[userSystemWindow] === "$Canceled" \[Or]
ToString[userSystemWindow] === "{}", False, True])],
(*Clear Results Button*)
Button[
"Clear Plot", calculatedList2 = {0}]}}]],
Spacer[1],
Dynamic@Grid[{
{"Temperature Units",
PopupMenu[Dynamic[temperatureUnits], {
celsius -> "C",
fahrenheit -> "F"}]}}],
Spacer[1],
(*Graph Plot*)
ListPlot[
If[Dimensions[importedData[[All, 1]]] ===
Dimensions[calculatedList2], temperatureUnits, {}],
Frame -> True, FrameLabel -> {"Distance [m]",
Switch[temperatureUnits,
celsius, "Temperature [C]",
uiPlotUnitFahrenheit, "Temperature [F]"]},
ImageSize -> 500, Joined -> True]
}, Alignment -> Left],
Initialization :> (
celsius =
MapThread[List, {importedData[[All, 1]], calculatedList2}];
fahrenheit =
MapThread[
List, {importedData[[All, 1]],
QuantityMagnitude@
UnitConvert[QuantityArray[calculatedList2, "DegreesCelsius"],
"DegreesFahrenheit"]}];
),
SynchronousInitialization -> False
]
**Edit:**
Here is the description of what the UI should calculate.
At first the UI should display:
- 3 buttons: Load Data, Calculate Data and Clear Plot (the last 2
should initially be disabled);
- popup menu which is linked to the graph allowing the user to change
the temperature unit of plotted data;
- graph which initially should be blank just showing frames and labels.
Button "Load Data" upon mouse-click should open system dialog window, allowing the user to select the excel file with data which upon file selection are imported in the form `{{x1, y1}, {x2, y2}, ...}`. In case the user clicks on button "Load Data" but decides to cancel the selection and close the system dialog window the button “Calculate” should remain disabled with a graph being blank.
Button “Calculate” should become enable as soon as data is imported, which upon mouse-click should solve couple of equations using imported data and inputs from `InputField`’s (removed from the code posted here) returning result of final equation in the form `{z1, z2, …}`.
When the data is ready to be plotted `ListPlot` should automatically plot data in the form `{{x1, z1}, {x2, z2}, …}` with temperature unit `DegreesCelsius`. This is why I need to use `MapTherad` to combine the first column from imported data with the calculated data set of `z`’s. Then every time the user decides to change the input data or import new data and press the button “Calculate” `ListPlot` should update accordingly and plot new set of data by adding the new curve to the old one i.e. {list1, list2, ….} where each list corresponds to mouse-click, so the user can compare different results.
Button “Clear Plot” is there to bring the plot to the blank state. I hope all that makes sense.Kamila Szklarczyk-Marshall2019-03-05T15:54:39Z[✓] Model a Thyristor or SCR?
https://community.wolfram.com/groups/-/m/t/1629227
Hi
How can I model a Thyristor or SCR in Mathematica?Payman ragheb2019-03-11T14:44:10Z