Recent Questions - Mathematica Stack Exchange most recent 30 from mathematica.stackexchange.com 2023-09-27T19:34:50Z https://mathematica.stackexchange.com/feeds https://creativecommons.org/licenses/by-sa/4.0/rdf https://mathematica.stackexchange.com/q/290889 0 How to calculate the depth of the lake in mathematica? Erfan https://mathematica.stackexchange.com/users/93530 2023-09-27T19:18:20Z 2023-09-27T19:18:20Z <p>I want to calculate mean depth of Goose lake (mean depth=4.6 m), I use bellow command for this operation, But this command is not automatic and we have to create the coordinates manually, and on the other hand, error is high. Can anyone help me improve the command or calculate the depth in another way?</p> <pre><code>GeoGraphics[GeoRange -&gt; {{42.11, 41.72}, {-120.68, -120.04}}, GeoRangePadding -&gt; Scaled[0.1], GeoBackground -&gt; &quot;Satellite&quot;] </code></pre> <p><a href="https://i.stack.imgur.com/K2Pxo.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K2Pxo.jpg" alt="enter image description here" /></a></p> <p>Get the coordinates manually</p> <pre><code>lakeContour = {{42.06139018896673, -120.33366857142863}, \ {42.01901951557524, -120.32489142857145}, {41.979883050316275, \ -120.32269714285715}, {41.94643492712383, -120.34244571428573}, \ {41.91786775950185, -120.36658285714289}, {41.86232926116004, \ -120.37755428571428}, {41.822278941450364, -120.4126628571429}, \ {41.79856388323117, -120.42692571428573}, {41.792020253207994, \ -120.45764571428573}, {41.825549294948054, -120.47739428571433}, \ {41.85334055520192, -120.47849142857147}, {41.884387091923635, \ -120.50372571428575}, {41.912152790705946, -120.52237714285718}, \ {41.9350095953905, -120.50811428571433}, {41.96356908621639, \ -120.49824000000005}, {41.99048488629956, -120.48617142857148}, \ {42.01086807025052, -120.48507428571435}, {42.0459118723763, \ -120.46752000000002}, {42.06546280322868, -120.4368}, \ {42.078493413349285, -120.41924571428575}, {42.08337920245882, \ -120.36877714285716}}; gcarc = GeoPath[Table[i, {i, lakeContour}], &quot;Geodesic&quot;]; gcarcDistance = GeoDistance[Table[i, {i, lakeContour}], UnitSystem -&gt; &quot;Metric&quot;]; profile = GeoElevationData[gcarc, Automatic, &quot;GeoPosition&quot;, GeoZoomLevel -&gt; 4]; pts = profile[][]; depths = #[] &amp; /@ pts; distances = QuantityMagnitude[ GeoDistance[{pts[][[1 ;; 2]], #[[1 ;; 2]]}, UnitSystem -&gt; &quot;Metric&quot;]] &amp; /@ pts; avgDepth = UnitConvert[Quantity[Mean[depths], &quot;Meters&quot;]] </code></pre> <p>out put: 42.0557m</p> https://mathematica.stackexchange.com/q/290883 0 Hiding Initialization Cells Chloe https://mathematica.stackexchange.com/users/82544 2023-09-27T17:29:54Z 2023-09-27T17:29:54Z <p>I have seen multiple notebooks with near invisible Initialization Cells, and wish to recreate them myself (see screenshot below).</p> <p><a href="https://i.stack.imgur.com/83D0J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/83D0J.png" alt="Visual representation" /></a></p> <p>In the screenshot, the first Initialization Cell is expanded, contains code, can be evaluated, but you cannot see the code inside. Said cell was used to define the function &quot;plotRotation&quot; while hiding the code.</p> <p>How would I be able to recreate this in a notebook myself? The code inside the cell is irrelevant so long as I am able to change it.</p> https://mathematica.stackexchange.com/q/290882 0 Using Local LLM Service That Duplicates Open AI API James Rohal https://mathematica.stackexchange.com/users/1082 2023-09-27T15:52:05Z 2023-09-27T15:52:05Z <p>I have a local service running on <code>https://localhost:PORT/v1</code> that duplicates the Open AI API functionality available at <code>https://api.openai.com/v1</code>. It appears the only way to use something like <a href="https://reference.wolfram.com/language/ref/LLMSynthesize.html" rel="nofollow noreferrer">LLMSynthesize</a> is to have an Open AI key. Is it possible to replace the base URL for any LLM calls? I presume one way to do this may be to create a <a href="https://reference.wolfram.com/language/ref/ServiceObject.html" rel="nofollow noreferrer">ServiceObject</a> for authentication?</p> https://mathematica.stackexchange.com/q/290881 1 How to Draw Rectangle Chart Using Three Layers of Data? Tugrul Temel https://mathematica.stackexchange.com/users/60365 2023-09-27T15:08:59Z 2023-09-27T18:51:29Z <p>I have some data given at three levels:</p> <pre><code>ClearAll[level1, level2, level3, labLevel1, labLevel2, labLevel3]; level1 = {38.63, 16.17}; level2 = {{19.75, 9.26, 9.61}, {2, 6.07, 8.10}}; level3 = {{{5.88, 5.02, 5.56, 3.3}, {4.05, 2.21, 3}, {4.5, 4.91, 0.2}}, {{1, 1},{2.77, 3.3},{2.07, 1.5, 3.11, 1.43}}}; </code></pre> <p>For labels across 3 levels:</p> <pre><code>labLevel1 = {&quot;Distortions induced by State&quot;, &quot;Barriers to domestic/foreign entry&quot;}; labLevel2 = {{&quot;Public ownership&quot;, &quot;Involvelment in business operations&quot;, &quot;Simplification/evaluation of regulations&quot;}, {&quot;Adm. burden on start-ups&quot;, &quot;Barriers in services &amp; network sectors&quot;, &quot;Barriers to trade &amp; investment&quot;}}; labLevel3 = { {{&quot;Scope of SOEs&quot;, &quot;Gov\[CloseCurlyQuote]t Involv. in network sectors&quot;, &quot;Direct control&quot;, &quot;Governance of SOEs&quot;}, {&quot;Price controls&quot;, &quot;Command &amp; control regulation&quot;, &quot;Public procurement&quot;}, {&quot;Assessment of impact on competition&quot;, &quot;Interaction with interest groups&quot;, &quot;Complexity of regulatory procedures&quot;}}, {{&quot;Adm. req. for LL com. &amp; pers. owned enter.&quot;, &quot;Licenses &amp; permits&quot;}, {&quot;Barriers in services sectors&quot;, &quot;Barriers in network sectors&quot;}, {&quot;Barriers to FDI&quot;, &quot;Tariff barriers&quot;, &quot;Treatment of foreign suppliers&quot;, &quot;Barriers to trade facilitation&quot;}} }; </code></pre> <p><code>level1</code> determines the <code>level1</code> size of a rectangular represented both as numbers and percentages. Since <code>level1</code> has two numbers, the rectangle will be first divided into two <code>parts</code> as percentages <code>38.63/total(level1)</code> and <code> 16.17/total(level1)</code>. Zooming into <code>level1</code> determines percentages at the <code>level2</code>. The zooming in at the <code>level3</code> will follow the same percentage calculation. For part 1, all the percentages will be calculated using <code>38.63</code> and for part 2, using <code>16.17</code>.</p> <p><code>part 1</code> and <code>part 2</code> should be constructed to allow for comparability. That is, all individual percentages in both parts should be calculated over <code>38.63+16.17</code>. Hence, <code>x %</code> in <code>part 1</code> should cover the same size as <code>x %</code> in <code>part 2</code>.</p> <p>For illustrative purposes I attach the following picture showing the way for calculations and the division of the original rectangle.</p> <p><a href="https://i.stack.imgur.com/80la0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/80la0.png" alt="enter image description here" /></a></p> <p>Similar charts exist as pie charts but not as rectangular charts. In the repository, there is no chart in rectangular format.</p> <p>Another example of the appearance of the rectangle chart is:</p> <p><a href="https://i.stack.imgur.com/IBIXV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IBIXV.png" alt="enter image description here" /></a></p> <p><strong>EDIT</strong></p> <p>From @Domen, I got this code from MMA:</p> <pre><code>ResourceFunction[&quot;TreemapPlot&quot;][level3, &quot;ColorFunction&quot; -&gt; (If[#3, ColorData[#. []], White] &amp;), &quot;Background&quot; -&gt; FaceForm[Opacity]] </code></pre> <p>This correctly divides the rectangle but borders between the parts and sub-parts are not identified.</p> <p><a href="https://i.stack.imgur.com/YPuQ7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YPuQ7.png" alt="enter image description here" /></a></p> https://mathematica.stackexchange.com/q/290878 1 Post Processing of Solution and Plot of Coupled Partial Differential Equation Over a Semi-Circular Domain user94537 https://mathematica.stackexchange.com/users/94537 2023-09-27T13:54:20Z 2023-09-27T18:09:12Z <p>Linked Question: <a href="https://mathematica.stackexchange.com/questions/290825/solution-and-plot-of-coupled-partial-differential-equation-over-a-semi-circular/290826#290826">Solution and Plot of Coupled Partial Differential Equation Over a Semi-Circular Domain.II</a></p> <p>Many many thanks to @Nasser (<a href="https://mathematica.stackexchange.com/users/70/nasser">https://mathematica.stackexchange.com/users/70/nasser</a>) for his kind help to understand different aspects of <code>Mathematica</code> associated with this problem.</p> <p>I have the following BVP. <a href="https://i.stack.imgur.com/10zDB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/10zDB.png" alt="enter image description here" /></a></p> <p>Also I have following BVP that uses the solution of first one.</p> <p><a href="https://i.stack.imgur.com/ene0y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ene0y.png" alt="enter image description here" /></a></p> <p>Code is given below.</p> <pre><code>ClearAll[&quot;Global*&quot;]; k = 5; \[Alpha] = 3*\[Pi]/4; \[Eta] = -1; L = 1; pde1 = Laplacian[s[r, \[Theta]], {r, \[Theta]}, &quot;Polar&quot;] == k^2*s[r, \[Theta]]; bc1 = s[1, \[Theta]] == 1 - (1 - \[Eta])*UnitStep[\[Theta] - \[Alpha]]; sol1 = NDSolveValue[{pde1, bc1}, s, {r, 0, 1}, {\[Theta], 0, Pi}]; pde2 = Laplacian[u[r, \[Theta]], {r, \[Theta]}, &quot;Polar&quot;] == -4*L - k^2*sol1[r, \[Theta]]; bc2 = u[1, \[Theta]] == 0; sol2 = NDSolveValue[{pde2, bc2}, u, {r, 0, 1}, {\[Theta], 0, Pi}] </code></pre> <p>Now I have to perform the following integral</p> <p><a href="https://i.stack.imgur.com/9KvlI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9KvlI.png" alt="enter image description here" /></a></p> <p>and have to plot the same as a function of the parameter <code>K</code> for different values of the parameter <code>\alpha</code> to regenerate a figure as follows:</p> <p><a href="https://i.stack.imgur.com/zGF4o.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zGF4o.png" alt="enter image description here" /></a></p> <p>How to proceed the same using <code>NIntegrate</code> function of <code>Mathematica</code>?</p> https://mathematica.stackexchange.com/q/290872 1 Finding zeroes of a modified Bessel function of the second kind user12588 https://mathematica.stackexchange.com/users/12588 2023-09-27T10:39:38Z 2023-09-27T15:53:38Z <p>Let <span class="math-container">$$f_n(\omega):=K_{i \omega}(2\pi n)$$</span> with <span class="math-container">$\omega&gt;0$</span>, <span class="math-container">$n=1,2,\ldots$</span> and <span class="math-container">$K_{\nu}$</span> a modified Bessel function of the second kind.</p> <p>For each fixed value of <span class="math-container">$n$</span>, <span class="math-container">$f_n(\omega)$</span> has an infinite number of zeros <span class="math-container">$\omega_{n\,k}&gt;0$</span>, labeled by an integer <span class="math-container">$k$</span>, that is to say <span class="math-container">$f_n(\omega_{n\,k})=0$</span>.</p> <p>These zeros can then the ordered, and I would like to accurately determine the first 1500. I tried using the Ted Ersek's <code>rootSearch</code>, but it gets very sluggish even for moderate values of <span class="math-container">$n$</span> such as <span class="math-container">$n=20$</span>. These zeros are likely to fall in the range <span class="math-container">$0&lt;\omega&lt;250$</span> and have <span class="math-container">$1\leq n\leq 35$</span>.</p> https://mathematica.stackexchange.com/q/290870 1 Finding the maximum amplitide quantitatively using interpolation Lohrasb https://mathematica.stackexchange.com/users/92135 2023-09-27T10:21:15Z 2023-09-27T18:47:52Z <p>I have the following table</p> <pre><code>data = Table[Sin[i], {i, 0, 10, 0.1}] // N </code></pre> <p>And I plotted the data as follows,</p> <p>Now I want to know the value of each maximum with high accuracy. It can see that for example the first maximum is around 1.0. However, I want it in terms of an accurate number. Can I do it using interpolation? If yes, how can I know what should be the accurate starting point?</p> <p>I appreciate it if you could help me.</p> <p><a href="https://i.stack.imgur.com/25b8v.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/25b8v.png" alt="enter image description here" /></a></p> https://mathematica.stackexchange.com/q/290869 0 Plotting Using Nesting Manipulate Soon https://mathematica.stackexchange.com/users/78050 2023-09-27T10:08:29Z 2023-09-27T18:54:18Z <p>My goal is to plot the number of locatable points and their average point as fig2. The number of points is set by the slider and they are locatable. My code with nesting Manipulate is as shown below, but an error-'Argument Null in Null is not a valid LinkObject'-occurred. Where should I fix my code as below?</p> <pre><code>Manipulate[With[{n = n}, Manipulate[NumberLinePlot[{pts, {Mean[pts]}}, PlotRange -&gt; {0, 4}], {pts, RandomReal[{0, 4}, n], Locator, Appearance -&gt; None, LocatorAutoCreate -&gt; True}]], {{n, 2}, 1, 100, 1, Appearance -&gt; &quot;Labeled&quot;}] </code></pre> <p>fig.1) <a href="https://i.stack.imgur.com/UCoGR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UCoGR.png" alt="enter image description here" /></a> <a href="https://i.stack.imgur.com/XWm4x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XWm4x.png" alt="enter image description here" /></a></p> <p>fig.2) <a href="https://i.stack.imgur.com/AiDBe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AiDBe.png" alt="enter image description here" /></a></p> https://mathematica.stackexchange.com/q/290868 0 Showing that the difference between two CDF functions is positive when CDFs are symbolic expressions elifcansu https://mathematica.stackexchange.com/users/90234 2023-09-27T09:59:30Z 2023-09-27T12:05:23Z <p>I'd like to check the sign of a symbolic expression conditional on some predefined assumptions. More specifically, first, I want to assume that the mean and variance of a normally distributed random variable is between 0 and 1. Then I want to show that the probability that this variable is between two values (that are also between 0 and 1) is positive. Here is my code:</p> <pre><code>$Assumptions = {1&gt;kmax&gt;kmin&gt;0,1&gt;m&gt;0,1&gt;sigma&gt;0}; FullSimplify@Positive[CDF[NormalDistribution[m,sigma],kmax]-CDF[NormalDistribution[m,sigma],kmin]] </code></pre> <p>which returns</p> <p><a href="https://i.stack.imgur.com/Py7ar.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Py7ar.png" alt="enter image description here" /></a></p> <p>Can someone help me understand why Mathematica does not see that this expression is strictly positive? Thanks in advance!</p> https://mathematica.stackexchange.com/q/290865 0 Interpolation function for data with repeating independent variable SciJewel https://mathematica.stackexchange.com/users/76434 2023-09-27T09:41:52Z 2023-09-27T10:28:04Z <p>I want to find an interpolation function for data in which the x-variable is repeated (example below). The repetition in data is natural and cannot not be eliminated.</p> <p>Can I somehow use <code>Interpolation</code> or is there any alternative?</p> <pre><code>tb = {{1, 1.83014}, {2, 8.58075}, {3, 7.51278}, {4, 6.12041}, {5, 2.35631}, {6, 9.5376}, {7, 6.58829}, {8, 3.11074}, {9, 9.39695}, {10, 8.3102}, {1, 6.51489}, {2, 3.94981}, {3, 8.27251}, {4, 7.03619}, {5, 4.06204}, {6, 0.662478}, {7, 7.5016}, {8, 7.84269}, {9, 5.64659}, {10, 7.54041}, {1, 6.51489}, {2, 3.94981}, {3, 8.27251}, {4, 7.03619}, {5, 4.06204}, {6, 0.662478}, {7, 7.5016}, {8, 7.84269}, {9, 5.64659}, {10, 7.54041}}; Interpolation[tb, InterpolationOrder -&gt; 1] (* Interpolation: The point 1 in dimension 1 is duplicated *) </code></pre> https://mathematica.stackexchange.com/q/290863 1 Mapping from n-sheeted Riemann surface to the complex plane G.Lebonwski https://mathematica.stackexchange.com/users/94592 2023-09-27T09:06:42Z 2023-09-27T17:00:24Z <p>Reading about conformal field theories in two dimensions, I run into the following statement needed for a demonstration:</p> <p>Consider an <span class="math-container">$n$</span>-sheeted Riemann surface with branch cut along (0,<span class="math-container">$\infty$</span>. This is uniformized by the mapping <span class="math-container">$\zeta\rightarrow z=\zeta^{1/n}$</span> . This maps the whole of the <span class="math-container">$n$</span>-sheeted Riemann surface to the <span class="math-container">$z$</span>-plane <span class="math-container">$\mathbb{C}$</span>.</p> <p>It is hard to me to visualize how this mapping is acting and why it maps the n-sheeted Riemann surface to the <span class="math-container">$\mathbb{C}$</span>-plane. I have a sort of intuition about it but I would like something more solid, also an example would suffice. Moreover, I would like to know what &quot;uniformized&quot; means in this context.</p> <p>Thank for you answers!</p> https://mathematica.stackexchange.com/q/290858 3 How to check if at least one ordering of the given row matches one of the rows of a table? John Taylor https://mathematica.stackexchange.com/users/41058 2023-09-27T08:40:12Z 2023-09-27T09:24:54Z <p>Consider some list of elements</p> <pre><code>elements={&quot;a&quot;,&quot;k&quot;,1,&quot;12&quot;,&quot;cdt&quot;,&quot;b&quot;,&quot;m&quot;,&quot;l&quot;,&quot;q&quot;,132,12.345,999,1000,Exp[x^2],Sin[y]}; </code></pre> <p>We may make the following table</p> <pre><code>tabb = Table[Take[RandomSample[elements],4],50] </code></pre> <p>and a row</p> <pre><code>roww = Take[RandomSample[elements],4] </code></pre> <p>I have to check if <code>roww</code> matches at least one row of <code>tab</code>, now taking into account that the ordering of the elements of <code>roww</code> is not important. I.e., if <code>tabb</code> includes the row <code>{999,1000,Exp[x^2],Sin[y]}</code>, while <code>roww</code> is <code>{1000,Sin[y],999,Exp[x^2]}</code> then the decision should be <code>True</code>.</p> <p>How to check if at least one ordering of <code>roww</code> matches with at least one row of <code>tabb</code>?</p> <p><strong>Edit</strong></p> <p>Probably it is <code>ContainsOnly</code>?</p> https://mathematica.stackexchange.com/q/290856 2 How to check if the given row matches one of the rows of a table? John Taylor https://mathematica.stackexchange.com/users/41058 2023-09-27T08:20:43Z 2023-09-27T12:29:01Z <p>Consider some table</p> <pre><code>tabb = RandomInteger[{0, 4}, {5, 4}] </code></pre> <p>and a row</p> <pre><code>row = RandomInteger[{0, 4}, 4] </code></pre> <p>How to check if <code>row</code> matches with at least one row of <code>tabb</code>?</p> https://mathematica.stackexchange.com/q/290854 2 Select a specified subset of vertices distributed on a circle licheng https://mathematica.stackexchange.com/users/67902 2023-09-27T07:31:52Z 2023-09-27T14:45:19Z <p>A <a href="https://mathworld.wolfram.com/CircularEmbedding.html" rel="nofollow noreferrer">circular embedding</a> is a graph embedding in which all graph vertices lie on a common circle, usually arranged so they are equally spaced around the circumference.</p> <p>If I only specify that some of the vertices are on a circle while the others are placed inside the circle (or arranged randomly), how should I handle it? For example,</p> <pre><code> TrapezohedralGraph[n_] := Module[{c}, c = CycleGraph[n]; VertexAdd[c, {n + 1, n + 2}]; EdgeAdd[c, Flatten[{Table[n + 1 &lt;-&gt; i, {i, 1, n, 2}], Table[n + 2 &lt;-&gt; i, {i, 2, n, 2}]}]]] TrapezohedralGraph </code></pre> <p><a href="https://i.stack.imgur.com/e68U2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e68U2.png" alt="enter image description here" /></a></p> <p>But I love the following embedding from the web <a href="https://mathworld.wolfram.com/TrapezohedralGraph.html" rel="nofollow noreferrer">Trapezohedral Graph</a>:</p> <p><a href="https://i.stack.imgur.com/Vzfq5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Vzfq5.png" alt="enter image description here" /></a></p> https://mathematica.stackexchange.com/q/290853 0 How to give conditions and solve an integration? apk https://mathematica.stackexchange.com/users/79906 2023-09-27T07:19:32Z 2023-09-27T07:43:25Z <p>I want to solve an integration,</p> <p><span class="math-container">$\int \frac{da}{\sqrt{\frac{8 \pi G \Lambda}{3}a^2 - K +c_1 a^{-(3k+1)}}}$</span></p> <p>Here, how to give conditions k <span class="math-container">$\ge$</span> 0, G<span class="math-container">$&gt;$</span> 0, <span class="math-container">$\Lambda$</span> <span class="math-container">$&gt;$</span> 0 and K can be zero, positive or negative ? c<span class="math-container">$_1$</span> is a constant of integration (I mean c<span class="math-container">$_1$</span> is a constant which raised while solving some previous integration and I do not know value of c<span class="math-container">$_1$</span>). I couldn't find way to give these conditions so I just gave the input in Mathematica as below.</p> <p>Integrate[<span class="math-container">$\frac{1}{Sqrt[\frac{8 \pi G \Lambda}{3} a^2 - K + c_1 a^{-(3k+1)}]}$</span>,a]</p> <p>But for this, in the output, Mathematica is keeping the integral as it is and not solving this integration. Can someone help me with this ? Thanks in advance.</p> https://mathematica.stackexchange.com/q/290852 0 Is there a way to optimize it for larger n? emnha https://mathematica.stackexchange.com/users/18805 2023-09-27T07:03:56Z 2023-09-27T07:03:56Z <p>This is Domen's code from my previous thread <a href="https://mathematica.stackexchange.com/questions/290774/how-to-calculate-equivalent-resistance-for-a-network-of-same-value-resistors/290779?noredirect=1#comment723074_290779">here</a>. I think it covers all the cases that I mentioned there and works well for small values of <code>n</code>. However, for large values of <code>n</code>, such as <code>n=10</code> or <code>n=20</code>, it takes a very long time. I don't know how long it would take, as I haven't been able to run it to completion yet. Is there any way to speed it up for large <code>n</code>?</p> <pre><code>ClearAll[p, s]; p[R1_, R2_] := 1/(1/R1 + 1/R2); s[R1_, R2_] := R1 + R2; n = 3 Groupings[Table[R, n], {p -&gt; 2, s -&gt; 2}] </code></pre> https://mathematica.stackexchange.com/q/290849 0 About using series function NovoGrav https://mathematica.stackexchange.com/users/80816 2023-09-27T06:03:48Z 2023-09-27T06:35:45Z <p>I am using Series function on (1/z)(-k^2)^z. Up to z^0, the function gives me 1/z + Log[-k^2]. But in the standard textbook on QFT, it turns out the expansion should give 1/z + Log[k^2/mu^2] -i*pi up to z^0 in the series. Could you explain the reason behind such discrepancy? How to resolve it?</p> https://mathematica.stackexchange.com/q/290848 5 Tomographic Reconstruction of a Convex Polyhedron from its Orthographic Projections Teg Louis https://mathematica.stackexchange.com/users/89848 2023-09-27T05:59:01Z 2023-09-27T16:05:54Z <p>So, I can construct a random polyhedron and find its 3 silhouettes onto the 3 standard planes.</p> <p>For example,</p> <pre><code>polyhedron = PolyhedronCoordinates[RandomPolyhedron[{&quot;ConvexHull&quot;, 10}]]; (* Projection Functions *) projections = polyhedron[[All, #]] &amp; /@ {{1, 2}, {1, 3}, {2, 3}}; (* Labeled Graphics *) titles = {&quot;XY Projection&quot;, &quot;XZ Projection&quot;, &quot;YZ Projection&quot;}; labeledGraphics = MapThread[Labeled[#1, #2, Bottom] &amp;, {graphics, titles}]; (* Display *) GraphicsGrid[{labeledGraphics}] </code></pre> <p>An example polyhedron and its projections are shown below:</p> <p><a href="https://i.stack.imgur.com/hNFUm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hNFUm.png" alt="A random polyhedron" /></a></p> <p>which gives the three orthographic projections:</p> <p><a href="https://i.stack.imgur.com/LcTPf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LcTPf.png" alt="The 3 orthographic projections of a convex polyhedron" /></a></p> <p>The question is, given the three standard orthographic projections, how do I find the original convex polyhedron knowing that the polyhedron is convex?</p> https://mathematica.stackexchange.com/q/290846 1 Conjugate symbol Gappy Hilmore https://mathematica.stackexchange.com/users/28163 2023-09-27T05:53:19Z 2023-09-27T18:01:28Z <p>Is there a way to make mathematica display Conjugate[z] as z* or something like that? It gets very verbose when there are multiple conjugates in an expression, it becomes hard to read.</p> https://mathematica.stackexchange.com/q/290844 1 Manipulate: How re-initialise the initial value of a dependent PopupMenu driven by another PopupMenu? Webel IT Australia - upvoter https://mathematica.stackexchange.com/users/86260 2023-09-27T02:16:09Z 2023-09-27T06:15:12Z <p>Using Manipulate, I would like the items offered in a 2nd PopupMenu to be driven by a 1st PopupMenu. I can get the dynamic driving of the offered items working, but not the initial value of the 2nd PopupMenu when the driving variable from the 1st PopupMenu changes. I also want it to handle cases where the dependent items list is empty {}.</p> <pre><code>itemLabels = {&quot;a&quot;, &quot;b&quot;, &quot;c&quot;}; itemMap = &lt;|&quot;a&quot; -&gt; {1, 2}, &quot;b&quot; -&gt; {3, 4}, &quot;c&quot; -&gt; {}|&gt;; Manipulate[ {var1, var2}, {{var1, itemLabels[]}, PopupMenu[Dynamic[var1], itemLabels] &amp;}, {{var2, Dynamic@If[Length[itemMap[var1]] &lt; 1, None, itemMap[var1][]] }, Dynamic@PopupMenu[#, itemMap[var1], #] &amp;} ] </code></pre> <p>On run it seems initially to work, the 1st PopupMenu has &quot;a&quot;, then if you choose &quot;b&quot; the 2nd PopupMenu switches to offer {3,4} with 3 selected. However, if you then choose 4 in the 2nd PopupMenu and then switch back to &quot;a&quot;, the 2nd PopupMenu is &quot;stuck&quot; on 4. If you click the 2nd PopupMenu it does offer correctly {1,2}, but the initialisation is wrong.</p> <p>If you perform a fresh run then choose &quot;c&quot; from the 1st PopupMenu (for the empty list {}) it correctly shows None. However, if you then choose any of the other 1st PopupMenu options &quot;a&quot; or &quot;b&quot; then go back to &quot;c&quot; it stays &quot;stuck&quot; on whatever you chose for the 2nd PopupMenu.</p> <p>The attached image shows a typical sequence. Grateful for help on how to get the initial value of the 2nd Popup correctly dynamically refreshed.</p> <p><a href="https://i.stack.imgur.com/jFsgz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jFsgz.jpg" alt="typical coupled popup sequence with incorrect initialisation" /></a></p> https://mathematica.stackexchange.com/q/290842 1 Performance of DensityPlot3D with non-opaque Graphics3D Lechuu https://mathematica.stackexchange.com/users/72560 2023-09-26T23:57:28Z 2023-09-26T23:57:28Z <p>Does anyone have problems with performance of graphics combining DensityPlot3D and any other non-opaque Graphics3D? If I combine ListDensityPlot3D (very simple one, first from documentation) with only 1 fully opaque sphere, FPS are high:</p> <pre><code>data = Table[ x y z, {z, -1, 1, 2/40.}, {y, -1, 1, 2/40.}, {x, -1, 1, 2/40.}]; densityplot = ListDensityPlot3D[data]; sphere = Graphics3D[{Opacity, Sphere[{10, 10, 10}, 5]}]; Show[densityplot, sphere] </code></pre> <p><a href="https://i.stack.imgur.com/dNq4S.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dNq4S.gif" alt="enter image description here" /></a></p> <p>But If i change the opacity to 0.5, performance drops dramatically:</p> <p><a href="https://i.stack.imgur.com/i22dt.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i22dt.gif" alt="enter image description here" /></a></p> <p>(there is a FPS counter on the top)</p> <p>Is it normal? 10 FPS are still enough for interaction, but when plots get massive it is completly non-functional.</p> <p>Mathematica 12.1, NVIDIA GeForce GTX 1050, Drivers version: 30.0.15.1179, drivers date: 10.02.2022, DirectX: 12 (FL 12.1), Windows 10</p> https://mathematica.stackexchange.com/q/290837 1 Keywords included in most sentences in a paragraph? Sam B https://mathematica.stackexchange.com/users/43542 2023-09-26T20:25:47Z 2023-09-27T00:10:34Z <p>I created a few functions that will retrieve some text from certain medical articles. However, not all articles are useful or even match the keywords I provide. Is there a way to &quot;grade&quot; each article to see which ones are a good match?</p> <p>I'm not sure how to go about this. I created the function below that is returning {False, True}, so I'm thinking that Intersection or Tally is not what I should use. Should I just see how many sentences have my keywords out of all the sentences and score on that?</p> <p>In this example, there are four sentences with two of them holding one of each keyword. What approach would you use?</p> <pre><code> checkQuality[datatext_, searchtext_] := ( sentences = TextSentences[datatext]; tally = {}; Map[Do[ AppendTo[tally, ToString[MemberQ[StringSplit[sentences[[s]]], #]]], {s, 1, Length[sentences]}] &amp;, StringSplit[DeleteStopwords[searchtext]]]; Apply[Intersection, Partition[tally, Length[sentences]]] ) searchTerm = &quot;carotenoids and hepatomegaly&quot;; checkQuality[&quot;GGT can also be an early marker of oxidative stress \ since serum antioxidant carotenoids namely lycopene, \ \[Alpha]-carotene, \[Beta]-carotene, and \[Beta]-cryptoxanthin are \ inversely associated with alcohol-induced increase of serum GGT found \ in moderate and heavy drinkers . GGT levels may be 2\[Dash]3 \ times greater than the upper reference value in more than 50% of the \ patients with nonalcoholic fatty liver disease . There is a \ significant positive correlation between serum GGT and triglyceride \ levels in diabetes and the level decreases with treatment especially \ when treated with insulin. Whereas serum GGT does not correlate with \ hepatomegaly in diabetes mellitus .&quot;, searchTerm] </code></pre> https://mathematica.stackexchange.com/q/290835 5 Getting Area from GeoGraphics Navvye https://mathematica.stackexchange.com/users/93048 2023-09-26T20:00:28Z 2023-09-27T18:57:04Z <p>I want to find the area covered by the reservoir of a dam using a satellite image.</p> <p>This is what I have so far.</p> <pre><code>DamPosition = DamData[Entity[&quot;Dam&quot;, &quot;TehriDam::q2zsw&quot;], &quot;Position&quot;] </code></pre> <p>Which returns the coordinates. And then, I use some image manipulation to isolate the dam from <code>geoImage</code>.</p> <pre><code>geoImage = DeleteSmallComponents[ Dilation[ Graphics[ Select[Cases[ GeoGraphics[ GeoBoundingBox[GeoPosition[{30.377778, 78.480556}]], GeoBackground -&gt; &quot;VectorMinimal&quot;], {Directive[{___, RGBColor[0.6, 0.807843137254902, 1.], ___}], ___}, Infinity], Not@*FreeQ[Polygon]]], 0]] </code></pre> <p><a href="https://i.stack.imgur.com/36nwQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/36nwQ.png" alt="This is the image that I get after image manipulation" /></a></p> <p>Now, all I want to do is find the area of the blue - shaded region.</p> <p>I know I can do this manually using the getcoordinates tool, but that seems too unreliable and tedious to do. I'm looking for an automated way to do it.</p> <p>PS : Using GetCoordinates, we can use the following code</p> <pre><code> damContour = {{36.14216500804076, -98.66601000992658}, {36.15131161335255, -98.6549477815357}, {36.1501032100147, -98.62214348441108}, {36.15000037203102, -98.60908533742007}, {36.13193732747872, -98.58352140011719}, {36.10128112030604, -98.57004960135653}, {36.08009879008038, -98.6043835918035}, {36.1172565230945, -98.61315564049649}, {36.12831708030723, -98.62663775701455}, {36.13202116684048, -98.64507269213401}, {36.13870030579935, -98.6454368865287}, {36.13708633726377, -98.6568745786338}}; GeoGraphics[{White, Thick, Line[GeoPosition[damContour]]}, GeoRange -&gt; {{36.05, 36.17}, {-98.7, -98.52}}, GeoRangePadding -&gt; Scaled[0.1], GeoBackground -&gt; &quot;Satellite&quot;]; GeoArea[Polygon[GeoPosition[damContour]]] </code></pre> https://mathematica.stackexchange.com/q/290819 2 Recurrence formula evaluating with speacial counting of subscripts CasperYC https://mathematica.stackexchange.com/users/62701 2023-09-26T12:25:03Z 2023-09-27T01:22:22Z <p>Hoping to check some recurrance relationship like this</p> <p><span class="math-container">$a_1 = x$</span> and <span class="math-container">$a_2 = y$</span>, with</p> <p><span class="math-container">$$a_{2n+1} = a_{2n} a_{2n-1}$$</span></p> <p>and</p> <p><span class="math-container">$$a_{2n+2} = a_{2n+1} + 4$$</span></p> <p>Tried</p> <pre><code>a = x; a = y; a[2*n + 1] := a[2*n]*a[2*n - 1]; a[2*n + 2] := a[2*n + 1] + 4 Table[a[n],{n,1,10}] </code></pre> <p>and</p> <pre><code>RecurrenceTable[ {a[2 n + 1] == a[2 n]*a[2 n - 1], a[2 n + 2] == a[2 n + 1] + 4, a == x, a == y }, a, {n, 1, 10}] </code></pre> <p>Neither works. How should I deal with the sub-index problem? Or am I defining it wrong?</p> <p>I just hope to get the same result as</p> <pre><code>a = x; a = y; Do[ a[2*n + 1] = a[2*n]*a[2*n - 1]; a[2*n + 2] = a[2*n + 1] + 4;, {n, 1, 10} ] Table[a[n] // Expand, {n, 1, 10}] </code></pre> <blockquote> <p>{x, y, x y, 4 + x y, 4 x y + x^2 y^2, 4 + 4 x y + x^2 y^2, 16 x y + 20 x^2 y^2 + 8 x^3 y^3 + x^4 y^4, 4 + 16 x y + 20 x^2 y^2 + 8 x^3 y^3 + x^4 y^4, 64 x y + 336 x^2 y^2 + 672 x^3 y^3 + 660 x^4 y^4 + 352 x^5 y^5 + 104 x^6 y^6 + 16 x^7 y^7 + x^8 y^8, 4 + 64 x y + 336 x^2 y^2 + 672 x^3 y^3 + 660 x^4 y^4 + 352 x^5 y^5 + 104 x^6 y^6 + 16 x^7 y^7 + x^8 y^8}</p> </blockquote> https://mathematica.stackexchange.com/q/290809 4 Delete list elements above a certain threshold eldo https://mathematica.stackexchange.com/users/14254 2023-09-26T09:01:45Z 2023-09-27T01:02:30Z <p><strong>1. Problem statement</strong></p> <p>Going from right to left, I want do delete all elements after they have occured <code>n</code> times. The solution I found seems to work reliably, but is rather long and uses a function, <code>DeleteElements</code>, which was only introduced in <code>V 13.1</code>.</p> <p><strong>2. Current solution</strong></p> <pre><code>DeleteAbove[lis_, n_] /; n &gt;= Max @ Counts @ lis := {} DeleteAbove[lis_, n_] := Module[{tal, del}, tal = Select[Tally @ lis, Last[#] &gt; n &amp;]; del = Rule @@ ReplaceAll[{a_, b_} :&gt; {a - n, b}] @ Reverse @ Transpose @ tal; Reverse @ DeleteElements[Reverse @ lis, del]] </code></pre> <p><strong>3. Examples</strong></p> <pre><code>list = {1, 5, 5, 2, 2, 6, 4, 2, 2, 5, 8, 8, 5, 5}; DeleteAbove[list, 3] </code></pre> <p>{1, 5, 5, 2, 2, 6, 4, 2, 5, 8, 8}</p> <pre><code>DeleteAbove[{2, 2, 1, 1, 1, 8, 1}, 2] </code></pre> <p>{2, 2, 1, 1, 8}</p> <p><strong>4. Questions</strong></p> <ul> <li>How would a nicer / shorter solution look like?</li> <li>Can this problem be solved with one of the <code>Sequence</code> - functions?</li> </ul> https://mathematica.stackexchange.com/q/290774 3 How to calculate equivalent resistance for a network of same-value resistors? emnha https://mathematica.stackexchange.com/users/18805 2023-09-25T12:28:40Z 2023-09-27T12:26:53Z <p>Let's assume I have <code>n</code> identical resistors. I can connect them either in series or in parallel (let's disregard bridge connections for now). Now, I want to list all possible connections along with their equivalent resistances.</p> <p><strong>For example:</strong></p> <p>&quot;pp&quot; represents a parallel connection.<br /> &quot;ss&quot; represents a series connection.</p> <ol> <li>With one resistor, we have just &quot;R.&quot;</li> <li>With two resistors, we can have: <br /> {R pp R, R/2} - Two resistors in parallel, equivalent resistance is R/2.<br /> {R ss R, 2R} - Two resistors in series, equivalent resistance is 2R.</li> <li>For three resistors, we get:<br /> {R pp R pp R, R/3} - Three resistors in parallel, equivalent resistance is R/3.<br /> {(R pp R) ss R, 3R/2} - Two resistors in parallel, then in series with one resistor, equivalent resistance is 3R/2.<br /> {(R ss R) pp R, 2R/3} - Two resistors in series, then in parallel with one resistor, equivalent resistance is 2R/3.</li> </ol> <p>I would like to present this information in a way that allows me to reconstruct the circuit and know the equivalent resistance of the circuit. Do you have any suggestions on how to achieve this for any number of resistors?</p> <p><strong>EDIT:</strong></p> <p>These are the formulas for resistors in series or in parallel:</p> <p>The equivalent resistance of resistors in series is calculated by adding their individual resistances: R1 ss R2 ss R3 ss ... Rn = R1 + R2 + R3 + ... + Rn</p> <p>The equivalent resistance of resistors in parallel is determined by taking the reciprocal of the sum of the reciprocals of their individual resistances: R1 pp R2 pp R3 pp ... Rn = (1/R1 + 1/R2 + 1/R3 + ... + 1/Rn)^-1</p> <p>I want to find the minimum number of resistors together with the circuit connections to get a given equivalent resistance value. This is a related post: <a href="https://math.stackexchange.com/questions/2160766/how-many-resistors-are-needed">https://math.stackexchange.com/questions/2160766/how-many-resistors-are-needed</a></p> https://mathematica.stackexchange.com/q/290705 0 Precision error in ND package stopple https://mathematica.stackexchange.com/users/170 2023-09-23T21:54:16Z 2023-09-27T18:04:33Z <p>Based on the helpful answers to <a href="https://mathematica.stackexchange.com/questions/290562/root-finding-for-holomorphic-functions">this question</a>, I wrote the code below to compute zeros of the derivative of the Riemann zeta function, high in the critical strip</p> <pre><code>&lt;&lt; NumericalCalculus ZetaPrime[s0_?NumericQ] := ND[Zeta[s], {s, 1}, s0, Method -&gt; NIntegrate, Scale -&gt; 1/10, WorkingPrecision -&gt; 30] ArgZetaPrime[s_] := ArgZetaPrime[s] = Arg[ZetaPrime[s]] Do[ boxes = Table[{ii + I *jj, ii + 1/10 + I *(jj + 1/10)}, {ii, 4/10, 31/10, 1/10}]; argprinciple = Table[Round[(Mod[ ArgZetaPrime[boxes[[kk + 1, 1]]] - ArgZetaPrime[boxes[[kk, 1]]], 2 Pi, -Pi] + Mod[ ArgZetaPrime[boxes[[kk, 2]]] - ArgZetaPrime[boxes[[kk + 1, 1]]], 2 Pi, -Pi] + Mod[ ArgZetaPrime[boxes[[kk - 1, 2]]] - ArgZetaPrime[boxes[[kk, 2]]], 2 Pi, -Pi] + Mod[ ArgZetaPrime[boxes[[kk, 1]]] - ArgZetaPrime[boxes[[kk - 1, 2]]], 2 Pi, -Pi])/(2 Pi)], {kk, 2, Length[boxes] - 1}]; If[MemberQ[argprinciple, 1], PrependTo[argprinciple, 0]; AppendTo[argprinciple, 0]; goodboxes = Pick[boxes, argprinciple, 1]; zero = FindRoot[ZetaPrime[s], {s, Mean[#], Sequence @@ #}, WorkingPrecision -&gt; 30] &amp; /@ goodboxes // Flatten; Print[zero, &quot; &quot;, SetPrecision[ZetaPrime[s] /. zero, 15]]] , {jj, 4992381, 4992381 - 1, -1/10}] </code></pre> <p>I'm getting the following error message</p> <pre><code>NIntegrate::precw: The precision of the argument function ((1.7713932533600079702+0.2353048432137065153 I) E^(-I NumericalCalculusPrivatet$6607)) is less than WorkingPrecision (30.). </code></pre> <p>I don't understand this, because I'm not passing anything to the ND that is not integer or rational.</p> <hr /> <p>Edit: As the comment below points out, I want to use FindRoot (with a TBA choice of WorkingPrecision) to find a root of function computed via the ND package (with its own TBA choice of WorkingPrecision.) How do these two choices relate? Should they be the same? The ND package does not have an AccuracyGoal or PrecisionGoal option.</p> https://mathematica.stackexchange.com/q/290481 2 Wolfram Mathematica and Arduino serial data capture not working Dynamic stream Jose Enrique Calderon https://mathematica.stackexchange.com/users/11974 2023-09-19T04:37:42Z 2023-09-27T02:58:49Z <p>This post is a continuation and modified version of an <a href="https://mathematica.stackexchange.com/questions/189884/plot-serial-data-from-arduino-with-time-date-problem?fbclid=IwAR3N99knSOBMhQ91pbKTL2z_zXvqXHiaW_tUrzlZW9sxIgrqzvd15LJM1bk">earlier post</a> from few years ago.</p> <p>Please help with the Dynamic function capturing data from a Serial stream from Arduino. I am not having luck with Dynamic capture of data from an Arduino serial port. Here is my code</p> <pre><code>dev = DeviceOpen[&quot;Serial&quot;, &quot;COM3&quot;] parseData[{val1__, 44, val2__, 44, val3__}] := ToExpression@FromCharacterCode@# &amp; /@ {{val1}, {val2}, {val3}} parseData[___] := Sequence[] rawReadings = {} task = SessionSubmit[ ScheduledTask[ AppendTo[rawReadings, DeviceReadBuffer[dev, &quot;ReadTerminator&quot; -&gt; 10]], {1, 100}, &quot;AutoRemove&quot; -&gt; true]] rawReadings test1 = parseData /@ rawReadings ListLinePlot[Transpose[parseData /@ rawReadings], PlotLegends -&gt; Automatic] // Dynamic DeviceClose[dev] </code></pre> <p>The Arduino sketch sends a group of 3 integers separated by a <em>coma</em> (ASCii 44) . Sometimes when loading, the buffer does send all 3 pairs and carriage return (ASCII 10). But not sure if this is the problem.</p> <p>So far, the code plots 3 or maybe 4 sets , then stops. I like to Dynamic plotting of the data stream from Arduino</p> <p>The code of the Arduino sketch is below. It is a modification of the original to print 3 sensor readings.</p> <pre><code>#include &lt;Wire.h&gt; #include &quot;Adafruit_AS726x.h&quot; //create the object Adafruit_AS726x ams; //buffer para leer valores en bruto uint16_t sensorValues[AS726x_NUM_CHANNELS]; //buffer para guardar los valores calibrados( no esta siendo utilizado en este codigo) //float calibratedValues[AS726x_NUM_CHANNELS]; void setup() { Serial.begin(9600); while(!Serial); // inicializa el pin digital LED_BUILTIN como un output. pinMode(LED_BUILTIN, OUTPUT); //inicia y permite la comunicacion con el sensor if(!ams.begin()){ Serial.println(&quot;could not connect to sensor! Please check your wiring.&quot;); while(1); } } void loop() { //lee la temperatura del sensor uint8_t temp = ams.readTemperature(); //ams.drvOn(); // descomentar esto si quieres usar el led del sensor para hacer medidas ams.startMeasurement(); //begin a measurement //permite que el sensor lea la data cuando este disponible bool rdy = false; while(!rdy){ delay(1000); rdy = ams.dataReady(); } //ams.drvOff(); //descomentar esto si quieres usar el led del sensor para hacer medidas //lee los valores! ams.readRawValues(sensorValues); //ams.readCalibratedValues(calibratedValues); //Serial.print(&quot;{&quot;); //Serial.print(&quot;Temp: &quot;); //Serial.print(temp); //Serial.print(&quot;,&quot;); //Serial.print(&quot; Violet: &quot;); //Serial.print(sensorValues[AS726x_VIOLET]); //Serial.print(&quot;,&quot;); //Serial.print(&quot; Blue: &quot;); Serial.print(sensorValues[AS726x_BLUE]); Serial.print(&quot;,&quot;); //Serial.print(&quot; Green: &quot;); //Serial.print(sensorValues[AS726x_GREEN]); //Serial.print(&quot;,&quot;); //Serial.print(&quot; Yellow: &quot;); Serial.print(sensorValues[AS726x_YELLOW]); Serial.print(&quot;,&quot;); //Serial.print(&quot; Orange: &quot;); //Serial.print(sensorValues[AS726x_ORANGE]); //Serial.print(&quot;,&quot;); //Serial.print(&quot; Red: &quot;); Serial.print(sensorValues[AS726x_RED]); //Serial.print(&quot;}&quot;); Serial.println(); //Serial.println(); delay(400); } </code></pre> <p>Here my results<a href="https://i.stack.imgur.com/prQR8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/prQR8.png" alt="enter image description here" /></a></p> <p><strong>FOLLOW-UP #2</strong></p> <p>After applying @wvt_beginner feedback and comment, the delay where removed from the Arduino Code. The reading of the stream is stabled but it serial closes after 3 or 4 data sets delivered.</p> <p><a href="https://i.stack.imgur.com/vZHfM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vZHfM.png" alt="Illustrations of Arduino Sketch and WM Notebook results. " /></a></p> <p><strong>Follow-up Update 2:</strong></p> <p>So, found out that the problem had nothing to do with the code, but with Mathematica. Was running version 11.2 . I first mover the <em>rawReadings = {}</em> line to before the parseData function. There , I noticed that the serial port pick up 7 and 8 dataset. Give me the idea that maybe potentially a problem with the compilation.</p> <p>I upgraded to WM version 13.1 and the Dynamic is picking up with a continuous readings.</p> <p>I am still having problemns with the serial. I ented the run with CNTL+c then restarted teh otebook. I am getting failure.</p> <p><strong>UPDATE 3</strong></p> <p>So far, I applied the option or removing and replacing teh Delay() with a timer loop. But I am getting 0 readings. It looks possibly a problem with the way the variable have been set up. Here is the updated code. BUT only returns 0 readings.</p> <p>Here is the SKETCH</p> <pre><code> #include &lt;Wire.h&gt; #include &quot;Adafruit_AS726x.h&quot; //create the object Adafruit_AS726x ams; //buffer para leer valores en bruto uint16_t sensorValues[AS726x_NUM_CHANNELS]; //buffer para guardar los valores calibrados( no esta siendo utilizado en este codigo) //float calibratedValues[AS726x_NUM_CHANNELS]; void setup() { Serial.begin(115200); while (!Serial) ; // inicializa el pin digital LED_BUILTIN como un output. pinMode(LED_BUILTIN, OUTPUT); //inicia y permite la comunicacion con el sensor if (!ams.begin()) { Serial.println(&quot;could not connect to sensor! Please check your wiring.&quot;); while (1) ; } } void loop() { //lee la temperatura del sensor //uint8_t temp = ams.readTemperature(); //ams.drvOn(); // descomentar esto si quieres usar el led del sensor para hacer medidas ams.startMeasurement(); //begin a measurement //permite que el sensor lea la data cuando este disponible bool rdy = false; while (!rdy) { delay(5); rdy = ams.dataReady(); } //ams.drvOff(); //descomentar esto si quieres usar el led del sensor para hacer medidas //lee los valores! ams.readRawValues(sensorValues); //ams.readCalibratedValues(calibratedValues); //Serial.print(&quot;{&quot;); //Serial.print(&quot;Temp: &quot;); //Serial.print(temp); //Serial.print(&quot;,&quot;); //Serial.print(&quot; Violet: &quot;); Serial.print(sensorValues[AS726x_VIOLET]); Serial.print(&quot;,&quot;); //Serial.print(&quot; Blue: &quot;); Serial.print(sensorValues[AS726x_BLUE]); Serial.print(&quot;,&quot;); //Serial.print(&quot; Green: &quot;); Serial.print(sensorValues[AS726x_GREEN]); Serial.print(&quot;,&quot;); //Serial.print(&quot; Yellow: &quot;); Serial.print(sensorValues[AS726x_YELLOW]); Serial.print(&quot;,&quot;); //Serial.print(&quot; Orange: &quot;); Serial.print(sensorValues[AS726x_ORANGE]); Serial.print(&quot;,&quot;); //Serial.print(&quot; Red: &quot;); Serial.print(sensorValues[AS726x_RED]); //Serial.print(&quot;}&quot;); Serial.println(); ; } </code></pre> https://mathematica.stackexchange.com/q/277800 1 How do I plot arrays of functions parametrically? Ted https://mathematica.stackexchange.com/users/23307 2022-12-26T22:36:14Z 2023-09-27T00:03:05Z <p>I am trying to plot the predicted output of a multiple input/multiple output control to a disturbance as a function of a parameter (s). To simplify the example, the gain matrix is a small Toeplitz matrix and we will only consider the steady state behavior, i.e., we will calculate an array of control actions, u, that depend on the deviation from set point, d, by</p> <p>u=-Inverse[g].d</p> <pre><code>g := Table[If[i == j, 1, If[Abs[i - j] == 1, s, 0]], {i, 1, 5}, {j, 1, 5}] </code></pre> <p>The control action is calculated by multiplying the inverse of the gain matrix times the array of disturbances (at various points). To keep the example simple, assume the disturbance is at one point so the control action becomes a column of the inverse gain matrix:</p> <pre><code>d := Transpose[Table[If[i == 3, -1, 0], {i, 1, 5}]] </code></pre> <p>and</p> <pre><code>u = -Inverse[g] . d </code></pre> <p>which gives</p> <blockquote> <p>{(s^2 - s^4)/(1 - 4 s^2 + 3 s^4), (-s + s^3)/(1 - 4 s^2 + 3 s^4), ( 1 - 2 s^2 + s^4)/(1 - 4 s^2 + 3 s^4), (-s + s^3)/( 1 - 4 s^2 + 3 s^4), (s^2 - s^4)/(1 - 4 s^2 + 3 s^4)}</p> </blockquote> <p>I want to plot how these elements of the control action array vary with s (for a much larger array of functions). I can create an array of points and use ListPlot3d, but the control action has poles in it and I would like to do a parametric plot to better represent the topology of the surface. How do I generate a parametric plot of an array of functions? I would prefer a surface plot rather than a series of line plots and I would like to do this for numerous more complex structures and disturbances (i.e., not cut and paste the array elements into a list for parametric plotting if I can avoid it).</p> https://mathematica.stackexchange.com/q/266952 1 Non-Gaussian Hidden Markov Process Daniel Berkowitz https://mathematica.stackexchange.com/users/27536 2022-04-18T04:07:41Z 2023-09-27T15:05:15Z <p>I'm using <code>EstimatedProcess</code> to simulate a <code>HiddenMarkovProcess</code> with two states using data derived from different ARIMA processes</p> <pre><code>EstimatedProcess[data, HiddenMarkovProcess[2, &quot;Gaussian&quot;]] </code></pre> <p>Are there other options for specifying the distribution of the <code>HiddenMarkovProcess</code> besides <code>&quot;Gaussian&quot;</code>? I can't find a list of the other options in Mathematica's documentation.</p> <p>Thanks</p>