Recent Questions - Mathematica Stack Exchange most recent 30 from mathematica.stackexchange.com 2021-06-21T17:12:27Z https://mathematica.stackexchange.com/feeds https://creativecommons.org/licenses/by-sa/4.0/rdf https://mathematica.stackexchange.com/q/249968 0 How can I solve this system please? walid fssm https://mathematica.stackexchange.com/users/72646 2021-06-21T16:40:44Z 2021-06-21T16:40:44Z <p>I need to solve the following impulsive heat equation:</p> <p><span class="math-container">$$\left\{\begin{array}{ll} \partial_{t} \psi(x,t)-\partial_{xx} \psi(x,t)=0, &amp; (x,t)\in (0,1) \times((0, 2) \backslash\{1\}) \\ \psi(0,t)= \psi(1,t)=0, &amp; t \in (0, 2) \\ \psi(x, 0)= x (1-x), &amp; x \in (0,1) \\ \psi(x, 1)=\psi\left(x, 1^{-}\right)+4, &amp; x \in (0,1) \end{array}\right.$$</span></p> <p><span class="math-container">$1^{-}$</span> denotes the limit to the left!</p> <p>This is the code I tried in Mathematica, but it's not giving the results</p> <pre><code> (* problem *) homogen = {D[f[x, t], {t, 1}] - D[f[x, t], {x, 2}] == 0}; (*Initial conditions *) ic = {f[x, 0] == x*(1 - x)}; (* Dirichlet boundary conditions*) bc = {f[0, t] == 0, f[1, t] == 0}; (*impulsive condition*) im = {f[x, t] == Limit[f[x, t], t -&gt; 1, Direction -&gt; &quot;FromBelow&quot;] + 4}; (*analytic resolution *) sol = DSolve[{homogen, ic, bc, im}, f[x, t], {x, 0, 1}, {t, 0, 2}] </code></pre> https://mathematica.stackexchange.com/q/249965 0 What is the units of source term Natasha https://mathematica.stackexchange.com/users/58343 2021-06-21T16:16:07Z 2021-06-21T16:16:07Z <p>This is a follow up to my previous question posted here, I'm setting up a pde in 1D to simulate the convection-diffusion physics along with point sinks</p> <pre><code>pde = {Derivative[1, 0][c][t, x] + Inactive[ Div][(-kappa).Inactive[Grad][c[t, x], {x}], {x}] + {v1}.Inactive[ Grad][c[t, x], {x}] + Qp*RegularizedDeltaPoint[gamma, {x}, {12.4}] </code></pre> <p>I went through the documentation given <a href="https://reference.wolfram.com/language/PDEModels/tutorial/HeatTransfer/HeatTransfer.html#945943234" rel="nofollow noreferrer">here</a> where the units of the heat source term is detailed for 1D, 2D or 3D simulation. But how the units od Qp are considered isn't very clear to me.</p> <p>I would like to confirm whether the units for 1D simulation is in mol/l/s .</p> https://mathematica.stackexchange.com/q/249964 0 NetChain Distribution like PredictorFunction Eric William Smith https://mathematica.stackexchange.com/users/27694 2021-06-21T15:57:57Z 2021-06-21T15:57:57Z <p><code>PredictorFunction</code> has an incredibly useful &quot;Distribution&quot; property. In the past, this has helped me filter out bad predictions, like this:</p> <pre><code>approxError[input_]:=StandardDeviation[myPredictorFunction[input, &quot;Distribution&quot;]] </code></pre> <p>I have a <code>NetChain</code> model that I've trained, but I don't know how to calculate how confident the model is in its predictions. Is there a similar function or property I could use?</p> https://mathematica.stackexchange.com/q/249963 1 Improving my superimposed hexagonal lattice code Madlad https://mathematica.stackexchange.com/users/80656 2021-06-21T15:45:44Z 2021-06-21T16:45:31Z <p>Pretty knew to Mathematica here. I have created a code stemming from a basic function that I found here in the stack exchange. I am basically making three different hexagonal lattices. Two of them are rotated with respect to the [un]-rotated one. There are two different angles of rotation, but what they are is not relevant. My code is the following:</p> <pre><code>\[Theta]tm = 5; \[Theta]mb = -5; unitcell[x_, y_] := {Black, Disk[{x, y}, 0.05], Black, Disk[{x, y + 2/3 Sin[120 Degree]}, 0.05], , Black, Line[{{x, y}, {x, y + 2/3 Sin[120 Degree]}}], Line[{{x, y}, {x + Cos[30 Degree]/2, y - Sin[30 Degree]/2}}], Line[{{x, y}, {x - Cos[30 Degree]/2, y - Sin[30 Degree]/2}}]} Rtm[\[Theta]_] = {{Cos[\[Theta]*Pi/360.], -Sin[\[Theta]*Pi/360.]}, {Sin[\[Theta]*Pi/360.], Cos[\[Theta]*Pi/360.]}}; topmoire[x_, y_] := {Red, Disk[Rtm[\[Theta]tm] . {x, y}, 0.05], Red, Disk[Rtm[\[Theta]tm] . {x, y + 2/3 Sin[120 Degree]}, 0.05], , Red, Line[{Rtm[\[Theta]tm] . {x, y}, Rtm[\[Theta]tm] . {x, y + 2/3 Sin[120 Degree]}}], Line[{Rtm[\[Theta]tm] . {x, y}, Rtm[\[Theta]tm] . {x + Cos[30 Degree]/2, y - Sin[30 Degree]/2}}], Line[{Rtm[\[Theta]tm] . {x, y}, Rtm[\[Theta]tm] . {x - Cos[30 Degree]/2, y - Sin[30 Degree]/2}}]} Rmb[\[Theta]_] = {{Cos[\[Theta]*Pi/360.], -Sin[\[Theta]*Pi/360.]}, {Sin[\[Theta]*Pi/360.], Cos[\[Theta]*Pi/360.]}}; bottommoire[x_, y_] := {Green, Disk[Rtm[\[Theta]mb] . {x, y}, 0.05], Green, Disk[Rtm[\[Theta]mb] . {x, y + 2/3 Sin[120 Degree]}, 0.05], , Green, Line[{Rtm[\[Theta]mb] . {x, y}, Rtm[\[Theta]mb] . {x, y + 2/3 Sin[120 Degree]}}], Line[{Rtm[\[Theta]mb] . {x, y}, Rtm[\[Theta]mb] . {x + Cos[30 Degree]/2, y - Sin[30 Degree]/2}}], Line[{Rtm[\[Theta]mb] . {x, y}, Rtm[\[Theta]mb] . {x - Cos[30 Degree]/2, y - Sin[30 Degree]/2}}]} middle = Graphics[ Block[{A = {Cos[120 Degree], Sin[120 Degree]}, B = {1, 0}, C = {-1, 0}}, Table[unitcell @@ (A j + B k + C l), {j, -20, 20}, {k, Ceiling[j/2], 20 + Ceiling[j/2]}, {l, Ceiling[j/2], 20 + Ceiling[j/2]}]], ImageSize -&gt; 500]; top = Graphics[ Block[{A = {Cos[120 Degree], Sin[120 Degree]}, B = {1, 0}, C = {-1, 0}}, Table[topmoire @@ (A j + B k + C l), {j, -20, 20}, {k, Ceiling[j/2], 20 + Ceiling[j/2]}, {l, Ceiling[j/2], 20 + Ceiling[j/2]}]], ImageSize -&gt; 500]; bottom = Graphics[ Block[{A = {Cos[120 Degree], Sin[120 Degree]}, B = {1, 0}, C = {-1, 0}}, Table[bottommoire @@ (A j + B k + C l), {j, -20, 20}, {k, Ceiling[j/2], 20 + Ceiling[j/2]}, {l, Ceiling[j/2], 20 + Ceiling[j/2]}]], ImageSize -&gt; 500]; Show[top, middle, bottom] </code></pre> <p>I was having trouble superimposing the three lattices on top of each other. For this I used</p> <p><code>Show[top,middle,bottom]</code></p> <p>However, in order to center the lattices at the origin, I had to introduce another vector within the function <code>Table</code>, the vector &quot;C&quot; multiplied by &quot;l&quot;. I think this has made my code crash everytime I try to run it. Is there another efficient way to either center the lattices on the origin of rotation with only two vectors, or perhaps a replacement of the <code>Table</code> function?</p> <p>Also, while this is not urgent, and not as important. I would like to know how to generalize this code in order to depend on a position argument, i.e. &quot;r&quot; where I can tweak how big (unit of length) I want the lattice to be (in x and y directions).</p> https://mathematica.stackexchange.com/q/249960 0 Why is my integral evaluating to 0? DTRHJ https://mathematica.stackexchange.com/users/80653 2021-06-21T15:26:53Z 2021-06-21T15:26:53Z <p><a href="https://i.stack.imgur.com/lBs44.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lBs44.png" alt="enter image description here" /></a></p> <p>I am trying to write a simple function, then integrate it without bounds. However, it just gives 0 which I know is incorrect.</p> https://mathematica.stackexchange.com/q/249959 0 How solve this system of trigonometric equations? Msegling https://mathematica.stackexchange.com/users/80625 2021-06-21T15:11:11Z 2021-06-21T16:06:19Z <p>I have the following system of equations:</p> <blockquote> <p><em>(substituting any real values for a,b,c,r,Alpha,Beta will return the same answer for x)</em></p> </blockquote> <pre><code>eq1 = x == -(((a - b) (a + b + 2 r) + ((a - c) (b + r) (a + c + 2 r) Sin[\[Alpha]])/((c + r) Sin[\[Beta]]))/(2 (a + r + ((b + r) ((a + r) Sin[\[Alpha]] + (c + r) (Cos[\[Beta]] Sin[\[Alpha]] + Cos[\[Alpha]] Sin[\[Beta]])))/((c + r) Sin[\[Beta]])))) eq2 = x == -(((a - c) (b + r) (a + c + 2 r) + ((a - b) (c + r) (a + b + 2 r) Sin[\[Beta]])/Sin[\[Alpha]])/(2 (a + r) (b + r) + (2 (c + r) ((a + r) Sin[\[Beta]] + (b + r) (Cos[\[Beta]] Sin[\[Alpha]] + Cos[\[Alpha]] Sin[\[Beta]])))/Sin[\[Alpha]])) eq3 = x == -((((b + r) Sin[\[Alpha]] + (c + r) Sin[\[Beta]]) ((a - c) (a + c + 2 r) - ((b - c) (c + r) (b + c + 2 r) Sin[\[Beta]])/((b + r) Sin[\[Alpha]] + (c + r) Sin[\[Beta]])))/(2 ((a + r) (b + r) Sin[\[Alpha]] + (c + r) ((a + r) Sin[\[Beta]] + (b + r) (Cos[\[Beta]] Sin[\[Alpha]] + Cos[\[Alpha]] Sin[\[Beta]]))))) </code></pre> <p><strong>I require a single expression for X in terms of a,b,c,r. (Alpha and Beta should cancel).</strong> (3 equations, 3 unknowns)</p> <p>I am trying to run the following code, but after many hours it still has not returned an answer:</p> <pre><code>Solve[Eliminate[{eq1, eq2 , eq3}, {\[Alpha] , \[Beta]}], x, Reals] </code></pre> <p>Is this the most efficent way to get the answer? I have tried solving for Alpha and Beta separatly but again... hours passed without an answer.</p> https://mathematica.stackexchange.com/q/249956 0 Arranging a function in powers of a variable Mike https://mathematica.stackexchange.com/users/76947 2021-06-21T14:30:04Z 2021-06-21T14:30:04Z <p>My function defined as</p> <pre><code>myfun = ( g^2 (2 + 4 x + a1 + 2 y a1 + a2 + 2 y a2) + ((1 + 2 x) (1 + 2 g + 8 g^2) + a1 + 2 y a1) \[Theta]^2 + (1 + 2 x) \[Theta]^4)/(\[Theta]^4 (1 + (1 + 2 y) (1 + 2 g (1 + g)) a2 + 2 \[Theta]^2 + (1 + 2 y) a2 \[Theta]^2 + \[Theta]^4 + 4 x^2 (1 + \[Theta]^2)^2 + (1 + 2 y) a1 (1 + 2 (-1 + g) g + a2 + 2 y a2 + \[Theta]^2) + 2 x (2 (1 + \[Theta]^2)^2 + (1 + 2 y) a1 (1 + 2 (-1 + g) g + \[Theta]^2) + (1 + 2 y) a2 (1 + 2 g (1 + g) + \[Theta]^2)))); </code></pre> <p>has the numerator arranged in ascending powers of <span class="math-container">$\theta$</span>. However, denominator is looking messy! How can I arrange the denominator also in powers of <span class="math-container">$\theta$</span>?</p> https://mathematica.stackexchange.com/q/249954 3 Implementation of Bean machine (Galton board) expression https://mathematica.stackexchange.com/users/7339 2021-06-21T13:30:58Z 2021-06-21T13:33:53Z <blockquote> <p>Bean machine is a triangular array of pegs, Balls are dropped onto the top peg and then bounce their way down to the bottom where they are collected in little bins.Each time a ball hits one of the pegs, it bounces either left or right.</p> </blockquote> <p>I'm trying to make a <a href="https://en.wikipedia.org/wiki/Bean_machine" rel="nofollow noreferrer">Bean machine (Galton board)</a>, probably like this effect. The problem now is slow to generate random paths, and the path is sometimes displayed incomplete. Is there a better way to achieve it? Or generate and plot in real time instead of generating all the lists first. Also, how to make real-time statistics and graphs below?</p> <pre><code>n = 10; pts = Table[{(2 j - i)/Sqrt, -i}, {i, 0., n}, {j, 0, i}]; paths = Table[FoldList[ Function[{x, i}, RandomChoice@ Select[MovingAverage[pts[[i + 1]], 2], Norm[# - x] == 2/Sqrt &amp;]], N@{0, -1}, Range[2, n]], {5000}]; // AbsoluteTiming Manipulate[ bsf = BSplineFunction[paths[[Floor@i]], SplineDegree -&gt; 1]; t = FractionalPart[i]; Graphics[{Point /@ pts, { Red, Dashed, Point[bsf[t]], Line@Table[bsf[t0], {t0, 0, t, 0.01}] }}, Axes -&gt; True], {i, 1, Length@paths, 0.01}] </code></pre> <p><a href="https://i.stack.imgur.com/XD1pJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XD1pJ.png" alt="enter image description here" /></a><br /> <a href="https://i.stack.imgur.com/TkwZL.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TkwZL.gif" alt="enter image description here" /></a></p> https://mathematica.stackexchange.com/q/249952 1 curious about Maping over multiple multiple arguments lucian https://mathematica.stackexchange.com/users/3223 2021-06-21T13:17:30Z 2021-06-21T14:47:16Z <p>To my shame, I have discovered the power of <code>Map</code> quite recently and since then I have been using it more and more. But increasingly I find myself trying to use <code>Map</code> with multiple arguments but there is no solution for this and I cannot understand why. Can anyone clarify this? What I could like is something like this:</p> <pre><code>Map[#1+#2,values for #1,values for #2] </code></pre> <p>What is it about <code>Map</code> that cannot achieve what <code>Table</code> has?</p> <p>Cheers</p> https://mathematica.stackexchange.com/q/249951 0 How not to change the order of the operators after evaluating an expression Partha Paul https://mathematica.stackexchange.com/users/42450 2021-06-21T13:11:49Z 2021-06-21T13:11:49Z <p>I have three operators A, B, C and they are non commutative. Each of them has two indices, Like <span class="math-container">$A^i_j$</span>. I am writing them as functions A[i,j] in mathematica notebook. They form a close algebra. Now I am trying to evaluate an expression like [A[i,j],B[k,l]]C[m,n]|state&gt;. I have already defined in my notebook what [A[i,j],B[k,l]] is, say it is some C[m,n], where m,n depend on i,j,k,l. Now after evaluating the expression I want to keep the order of the operators as it is, but by default mathematica is rearranging the functions. I tried ClearAttributes[Times,Orderless]. But the notebook automatically quits after evaluating one or two such expressions. I am unable to understand why it is quitting. Is there anything else that I can use to keep the order of the operator as it is after evaluating the commutator in the expression. Any help would be appreciated.</p> https://mathematica.stackexchange.com/q/249946 3 How to get Gallai-Edmonds decomposition of a graph? licheng https://mathematica.stackexchange.com/users/67902 2021-06-21T11:23:42Z 2021-06-21T15:31:02Z <p>In graph theory, the Gallai–Edmonds decomposition is a partition of the vertices of a graph into subsets satisfying certain properties. Describe it in more detail. <a href="https://courses.engr.illinois.edu/cs598csc/sp2010/Lectures/Lecture8.pdf" rel="nofollow noreferrer">from here</a></p> <p><a href="https://i.stack.imgur.com/W0h5p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W0h5p.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/uxwPS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uxwPS.png" alt="enter image description here" /></a></p> <p>To get the maximum matching of a graph, we just use the built-in standard function <strong>FindIndependentEdgeSet</strong>, and now I want to get the <strong>above decomposition</strong> of a graph. How do I get Gallai–Edmonds decomposition?</p> <p>From the Wikipedia entry on Gallai–Edmonds decomposition, they can <strong>be found</strong> using the <strong>blossom algorithm</strong>. <a href="https://www.demonstrations.wolfram.com/TheBlossomAlgorithmForMaximumMatching/#popup1" rel="nofollow noreferrer">Wolfram Codes of The Blossom Algorithm for Maximum Matching </a></p> <p>I don't have a good idea right now.</p> <pre><code> g = Graph[{1, 2, 5, 3, 4, 6, 7}, {UndirectedEdge[1, 2], UndirectedEdge[1, 5], UndirectedEdge[2, 3], UndirectedEdge[3, 4], UndirectedEdge[4, 5], UndirectedEdge[3, 6], UndirectedEdge[4, 6], UndirectedEdge[3, 7], UndirectedEdge[4, 7]}]; FindIndependentEdgeSet[g] </code></pre> https://mathematica.stackexchange.com/q/249945 4 How can we find the longitude that cuts all the land on Earth in half? polfosol https://mathematica.stackexchange.com/users/37848 2021-06-21T11:16:26Z 2021-06-21T15:43:16Z <p>Mathematica has already a specific function, <a href="https://reference.wolfram.com/language/ref/RegionCentroid.html" rel="nofollow noreferrer"><code>RegionCentroid</code></a>, that can be utilized to calculate the geographic center of any region. As it has been discussed <a href="https://mathematica.stackexchange.com/q/139471/37848">in here</a> and maybe some other questions.</p> <p>There is also <a href="https://community.wolfram.com/groups/-/m/t/1039049" rel="nofollow noreferrer">a nice post</a> by Christopher Wolfram which discusses some issues on calculating the centroid of a large geographical region. I have used the ideas in there to calculate the geographical center of all lands on Earth. The result perfectly matched with <a href="https://gis.stackexchange.com/a/83241">this post on GIS SE</a>. The main function was this:</p> <pre><code>geoRegion3D[meshI : (_MeshRegion | _BoundaryMeshRegion)] := Block[{mesh = Quiet@TriangulateMesh@DiscretizeRegion@meshI}, If[Head[mesh] =!= MeshRegion, Missing[], MeshRegion[GeoPositionXYZ[ GeoPosition[Reverse/@ MeshCoordinates[mesh]]][], MeshCells[mesh, 2]]]] </code></pre> <p>which divides the region into some 3D mesh and then, for example:</p> <pre><code>r = DiscretizeGraphics[Polygon /@ Map[Reverse, Entity[&quot;Country&quot;, &quot;France&quot;][&quot;Polygon&quot;][[1, 1]], {2}]]; GeoPosition@GeoPositionXYZ@RegionCentroid@geoRegion3D@r </code></pre> <p>calculates the centroid of France. It suffices to replace the polygon of France with the world's polygon, which would take a looong time for calculation.</p> <p>Now a different question popped into my mind which I wasn't able to find any ideas about. So after an hour of fruitless googling, I decided to try my luck in here.</p> <blockquote> <p>There is a longitude on Earth which cuts all the land in half. i.e. there would be equal amounts of land on both hemispheres. Can we find this longitude using Mathematica?</p> </blockquote> https://mathematica.stackexchange.com/q/249943 0 Solving ODE with initial conditions uses a spurious and unnecessary initial value equal to unity Quasar Supernova https://mathematica.stackexchange.com/users/30529 2021-06-21T10:57:47Z 2021-06-21T12:46:35Z <pre><code>DSolve[ {f'[t] + \[Omega][t] f[t] == 0, f[t0] == 1}, f[t], t] </code></pre> <p>Gives,</p> <pre><code>f[t] -&gt; E^(Inactive[Integrate][-\[Omega][K], {K, 1, t}] - Inactive[Integrate][-\[Omega][K], {K, 1, t0}]) </code></pre> <p><span class="math-container">$$f(t)\to \exp \left(\int _1^t-\omega (K)dK-\int _1^{\text{t0}}-\omega (K)dK\right)$$</span></p> <p>Whereas the obvious more compact answer is</p> <pre><code>f[t] -&gt; E^(Inactive[Integrate][-\[Omega][K], {K, t0, t}] ) </code></pre> <p><span class="math-container">$$f(t)\to \exp \left(\int _{\text{t0}}^t-\omega (K)dK\right)$$</span></p> <p>The unity (&quot;1&quot;) as initial value is totally unnecessary. How to I ensure that it is not seen in the answer. FullSimplify does not work either.</p> https://mathematica.stackexchange.com/q/249939 2 Rotating DensityPlot 1_student https://mathematica.stackexchange.com/users/44929 2021-06-21T10:40:39Z 2021-06-21T13:09:27Z <p>I have a <code>DensityPlot</code> of <code>Tan[x - y]</code> as follows.</p> <p><a href="https://i.stack.imgur.com/6MnWv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6MnWv.png" alt="enter image description here" /></a></p> <p>I want to set different View Point. (As I know <code>ViewPoint</code> is not active in <code>DensityPlot</code>)</p> <p>When I rotate the <code>DensityPlot</code>, frame labels, plot legends, and axis also rotate. How to set correct frame labels, plot legends, and axis numbers?</p> <pre><code> plot = DensityPlot[Tan[x - y], {x, 0, 2}, {y, 0, 5}, Mesh -&gt; Automatic, MeshFunctions -&gt; {#3 &amp;}, FrameLabel -&gt; {x, y}, PlotLegends -&gt; Automatic]; Rotate[plot, Pi/2] </code></pre> <p><a href="https://i.stack.imgur.com/d0oYB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d0oYB.png" alt="enter image description here" /></a></p> <p>I want to get a figure as follows: (But, on the x-axis, the large values can be at the top and small values at the bottom.)</p> <p><a href="https://i.stack.imgur.com/VfJQE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VfJQE.png" alt="enter image description here" /></a></p> https://mathematica.stackexchange.com/q/249935 1 Problem with plotting (resp. expanding) the Hurwitz Zeta function Carl https://mathematica.stackexchange.com/users/80650 2021-06-21T08:02:08Z 2021-06-21T10:44:24Z <p>I expected the two plots to be identical. Can anyone confirm that the discrepancies show a bug?</p> <pre><code>b[s_, v_] := If[s == 0, 1, -s*Zeta[1 - s, v]]; Table[Expand[FullSimplify[b[n, x]]], {n, 1, 6}] Plot[%, {x, -1, 3/2}, PlotRange -&gt; {-1, 1}] Table[BernoulliB[n, x], {n, 1, 6}] Plot[%, {x, -1, 3/2}, PlotRange -&gt; {-1, 1}] </code></pre> https://mathematica.stackexchange.com/q/249933 1 Compute the correlation of eigenvalues of a Gaussian Random Matrix Matt https://mathematica.stackexchange.com/users/66913 2021-06-21T05:11:27Z 2021-06-21T09:48:46Z <h2>Background</h2> <p>Let <span class="math-container">$M$</span> be a <span class="math-container">$N\times N$</span> random symmetric matrix, which is drawn from a Gaussian distribution of mean <span class="math-container">$\mu=0$</span> and variance <span class="math-container">$\sigma^2=1/N$</span>.</p> <p>The <strong>first level correlation</strong> is defined by: <span class="math-container">\begin{equation} \rho(\lambda)=\left \langle \text{Tr}\delta(\lambda-M)\right \rangle\quad\quad\quad\quad\quad(1) \end{equation}</span> Which is nothing more than the distribution of eigenvalues: following my routine below I can compute this quantity. The brackets represents the average over the gaussian distribution.</p> <pre><code>RandomMatrix[n_] := RandomMatrix[n] = RandomVariate[NormalDistribution[0, 1/Sqrt[n]], {n, n}]; n := 1500 M := 1/Sqrt*(RandomMatrix[n] + Transpose@RandomMatrix[n]) \[Rho] = Eigenvalues[M]; Histogram[\[Rho]] </code></pre> <p><a href="https://i.stack.imgur.com/nZa2r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nZa2r.png" alt="enter image description here" /></a></p> <p>In the large limit <span class="math-container">$N&gt;&gt;1$</span> equation <span class="math-container">$(1)$</span> will describe a semi-circular law.</p> <h2>Question</h2> <p>The <strong>two-level correlation function</strong> is defined by: <span class="math-container">\begin{equation} \rho^{(2)}(\lambda, \mu)=\left\langle\frac{1}{N} \operatorname{Tr} \delta(\lambda-M) \frac{1}{N} \operatorname{Tr} \delta(\mu-M)\right\rangle\quad\quad\quad\quad\quad(2) \end{equation}</span> I interpret this quantity is as how correlated two given eigenvalues will be. Following the previous routine, my <span class="math-container">$\rho$</span> will be a list of the <span class="math-container">$N$</span> eigenvalues of <span class="math-container">$M$</span>. How can I numerically compute equation <span class="math-container">$(2)$</span>? Isn't it impossible to tell how correlated two elements are in one same list? If I generate several lists, it has to be for different matrices, which does not work anymore.</p> <p>Given <strong>one</strong> matrix <span class="math-container">$M$</span>, how can I compute the correlation between two eigenvalues?</p> <p>Any help or remark is appreciated!</p> https://mathematica.stackexchange.com/q/249929 0 How to extract a factor from equation and rearrange the equation? Sea cucumber https://mathematica.stackexchange.com/users/80633 2021-06-21T03:23:35Z 2021-06-21T13:52:26Z <p>I want to extract a factor from the equations, it's not a common factor, just a factor defined by myself, like this: (a<em>c+b) --&gt; c</em>(a+b/c) I have tried <code>Factor</code>,<code>FactorTerms</code>,<code>Eliminate</code>, but it do not work as I expect, if the factor do not contained in the terms, it could not be extracted, like: b=c*(b/c) I turn to MATHEMATICA for its ability on symbolic calculations, I want to replace pen and paper with the computer program, for convenient and accuracy. Sometimes I need to rearrange the equations to extract some factors or apply some math skills, but the MATHEMATICA always automatically simplify my expression. This is my equation:</p> <pre><code>-((b La r \[Omega] - b k La^2 \[Omega]^2)/( g h k w + g h k^3 La^2 w)) == 1 </code></pre> <p>I want to extract <code>(\[Omega]^2*b)/(k^2*g*h*w)</code> and put this part on one side and the other parts on the other side, like this:</p> <pre><code>(\[Omega]^2*b)/(k^2*g*h*w) == the other part </code></pre> <p>I have tried:</p> <pre><code>eq11=-((b La r \[Omega] - b k La^2 \[Omega]^2)/( g h k w + g h k^3 La^2 w)) == 1 eq12 = Times[(\[Omega]^2*b)/(k^2*g*h*w), Divide[eq11[], (\[Omega]^2*b)/(k^2*g*h*w)]] </code></pre> <p>and</p> <pre><code>factorOut[fac_][expr_] := Replace[expr, p_Plus :&gt; fac Simplify[p/fac], All] factorOut[(\[Omega]^2*b)/(k^2*g*h*w)][eq11] </code></pre> <p><a href="https://i.stack.imgur.com/yEi2C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yEi2C.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/qdlpD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qdlpD.png" alt="enter image description here" /></a></p> <p>I would appreciate it if who can fix my problem</p> https://mathematica.stackexchange.com/q/249927 2 Returning trigonometric value answers in irrational form Jasmine https://mathematica.stackexchange.com/users/73364 2021-06-21T02:20:06Z 2021-06-21T03:20:28Z <p>I need to find the irrational form of <code>Sin[7*\[Pi]/8]</code>. But in Mathematica, I can get its numerical value. I am getting</p> <pre><code>Sin[\[Pi]/4]=1/Sqrt </code></pre> <p>in Mathematica. What I meant is an answer something like this for <code>Sin[7*\[Pi]/8]</code> as well. Is that possible?</p> https://mathematica.stackexchange.com/q/249925 0 Upsampling layer for convolutional autoencoder stathisk https://mathematica.stackexchange.com/users/9083 2021-06-20T23:08:12Z 2021-06-21T16:52:46Z <p>I've been trying to build a convolutional autoencoder with Mathematica 12.3. For this, I need to reverse the action of <code>PoolingLayer[]</code>. Is there any layer similar to Keras's <a href="https://keras.io/api/layers/reshaping_layers/up_sampling1d/" rel="nofollow noreferrer"><code>UpSampling1D</code></a>? Could, perhaps, <code>ReplicateLayer[]</code> be handy here?</p> <p>I just found <a href="https://mathematica.stackexchange.com/questions/124977/qa-mathematica-v-11-neural-networks-a-comprehensive-look-at-layers-net-functi/139138#139138">this thread</a> that talks about implementing an upsampling operation with <code>DeconvolutionLayer[]</code>.</p> https://mathematica.stackexchange.com/q/249921 3 How to calculate and display possible graphs from 3 directed branches? anhnha https://mathematica.stackexchange.com/users/18805 2021-06-20T21:56:03Z 2021-06-21T09:10:40Z <p>I have 3 directed branches and I want to create all possible graphs that can be created from these branches with the condition that each branch is used once.</p> <p><strong>Q1:</strong> How can I do create and graph them?</p> <p><a href="https://i.stack.imgur.com/pzyXR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pzyXR.png" alt="enter image description here" /></a></p> <p>Here are some example graphs: <a href="https://i.stack.imgur.com/UIVBh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UIVBh.png" alt="enter image description here" /></a></p> <p><strong>Q2:</strong> Same as Q1 but now add one more condition that the branch <code>a</code> and branch <code>b</code> are connected as in the image below.</p> <p><a href="https://i.stack.imgur.com/wQAqs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wQAqs.png" alt="enter image description here" /></a></p> https://mathematica.stackexchange.com/q/249915 3 solution of $\frac{1}{x}=\infty$ Nasser https://mathematica.stackexchange.com/users/70 2021-06-20T17:00:25Z 2021-06-21T16:27:29Z <p>Is there a way to obtain solution <span class="math-container">$x=0$</span> for the equation <span class="math-container">$\frac{1}{x}=\infty$</span> in Mathematica?</p> <p>I tried <code>Solve</code>, <code>Reduce</code>, <code>FindInstance</code> and with different options, but Mathematica keeps beeping on me that system contains an infinite object or it gives <code>{}</code> as answer, meaning no solution. I tried with <code>Infinity</code> and <code>ComplexInfinity</code>.</p> <p>Maple gives <span class="math-container">$x=0$</span> as solution.</p> <p>Why is <code>0</code> not a solution to <span class="math-container">$\frac{1}{x}=\infty$</span> ? Since <code>1/0</code> gives <code>ComplexInfinity</code></p> <p><img src="https://i.stack.imgur.com/6lQF5.png" alt="Mathematica graphics" /></p> <p>Some attempts</p> <pre><code>ClearAll[x]; eq = 1/x == ComplexInfinity; Solve[eq, x, Reals, Method -&gt; &quot;Reduce&quot;] Solve[eq, x] Reduce[eq, x] FindInstance[eq, x] SolveAlways[eq, x] </code></pre> <p>Maple:</p> <p><a href="https://i.stack.imgur.com/9N7cQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9N7cQ.png" alt="enter image description here" /></a></p> <p>Is there some deep mathematical reason why <span class="math-container">$0$</span> can not be solution to this equation according to Mathematica, and is there some workaround?</p> https://mathematica.stackexchange.com/q/249900 0 plot multiple curves : solution obtained from NDSolve Natasha https://mathematica.stackexchange.com/users/58343 2021-06-20T06:59:35Z 2021-06-21T04:55:56Z <p>I want to plot the solution obtained from NDSolve as a multicurve plot like shown in the following sample image (image <a href="https://mathematica.stackexchange.com/a/134223/58343">ref</a>). Here, x1, x2 , x3, x4 .. are the solution computed at <code>includePoints = {{10}, {20}, {30}, {40}, {50}}</code> in my case.</p> <p><a href="https://i.stack.imgur.com/ykZNjm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ykZNjm.png" alt="enter image description here" /></a></p> <p>In the following code (<a href="https://scicomp.stackexchange.com/a/37536/29087">ref</a>):</p> <pre><code>Needs[&quot;NDSolveFEM&quot;] region = Line[{{0}, {100}}]; includePoints = {{10}, {20}, {30}, {40}, {50}}; mesh = ToElementMesh[region, &quot;IncludePoints&quot; -&gt; includePoints, &quot;MaxCellMeasure&quot; -&gt; 0.0008] vars = {c[t, x], t, {x}}; RegularizedDeltaPoint[g_, X_List, Xs_List] := Piecewise[{{Times @@ Thread[1/(4 g) (1 + Cos[\[Pi]/(2 g) (X - Xs)])], And @@ Thread[RealAbs[X - Xs] &lt;= 2 g]}, {0, True}}] Subscript[h, mesh] = Sqrt[Min[mesh[&quot;MeshElementMeasure&quot;]]]; Subscript[gamma, reg] = Subscript[h, mesh]/2; temp = RegularizedDeltaPoint[Subscript[gamma, reg], {x}, includePoints[]]; parameters = {kappa -&gt; {{910}}, v1 -&gt; 162, gamma -&gt; Subscript[gamma, reg], Qp -&gt; 1.5}; pde = {Derivative[1, 0][c][t, x] + Inactive[ Div][(-kappa).Inactive[Grad][ c[t, x], {x}], {x}] + {v1}.Inactive[Grad][c[t, x], {x}] + Qp*RegularizedDeltaPoint[gamma, {x}, {10}] == 0, c[0, x] == 1} /. parameters; tEnd = 2; cfun = NDSolveValue[{pde, DirichletCondition[c[t, x] == 5, x == 0]}, c, {t, 0, tEnd}, {x} \[Element] mesh]; Manipulate[ Plot[cfun[t, x], {x} \[Element] region, PlotRange -&gt; {{0, 100}, {0, 5}}], {t, 0, tEnd}] </code></pre> <p><a href="https://i.stack.imgur.com/DdSWzm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DdSWzm.png" alt="enter image description here" /></a></p> <p>The above figure displays solution vs x-position. Instead, I want to plot solution curves observed at x-positions in <code>includePoints = {{10}, {20}, {30}, {40}, {50}};</code> as a function of time. as a function of time.</p> <p>Suggestions will be really appreciated.</p> <p>EDIT:</p> <ol> <li><p>May I also know how to save the solution in cfun at includePoints = {{10}, {20}, {30}, {40}, {50}} over the integration time span to a text file?</p> </li> <li><p>Using the following command</p> <p>With[{i = Flatten[includePoints]}, Plot[Evaluate[cfun[t, #] &amp; /@ i], {t, 0, tEnd}, PlotRange -&gt; {{0, tEnd}, {0, 5}}, PlotLegends -&gt; (StringTemplate[&quot;c(t,)&quot;] /@ i)]]</p> </li> </ol> <p>I could generate, <a href="https://i.stack.imgur.com/erv01.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/erv01.png" alt="enter image description here" /></a></p> <p>But I am not sure why c(t,0), the first point which is the left boundary isn't at 5 (Dirichlet conditioned defined) at t=0. Could someone please have a look? Also, the legend labels aren't formatted correctly String Template appears as text in the legend).</p> https://mathematica.stackexchange.com/q/249899 3 Copy clipboard content to mathematica notebook - line break symbol changes imida k https://mathematica.stackexchange.com/users/34532 2021-06-20T06:24:14Z 2021-06-21T00:59:40Z <p>There are 3 kinds of line breaks</p> <ol> <li>\r</li> <li>\n</li> <li>\r\n</li> </ol> <p>For windows, \r\n is standard.</p> <p>Suppose that there is a file called document.txt, using \r or \r\n as line breaks.<br /> Suppose that I open document.txt with a notepad program and select all text and Ctrl+C,<br /> then create a string variable named mystring, in mathematica.</p> <pre><code>In mystring=&quot;paste, I mean ctrl+V here.&quot; </code></pre> <p>(note that the content of mystring is several lines.)</p> <p>Then</p> <pre><code>In StringCount[mystring, &quot;\r&quot;] Out 0 </code></pre> <p>Looks like \r or \r\n are all replaced with \n automatically.</p> <p>Q1) Does mathematica automatically change line breaks to \n?</p> <p>It is a little surprising that mathematica, doesn't prohibit to use \r.</p> <p>If you type '\r' with your fingers, when defining a string variable, it works.</p> <p>Looks like unwanted line breaks change (every line break to \n) happen only when pasting clipboard content to mathematica.</p> <p>Q2) Why does mathematica behave like this ? Is there an option to correct this phenomenon?</p> <p>About comment : Thank you Ben Izd, but in my PC, ReadString doesn't replace \n with \r\n.<br /> Evidence :</p> <p><a href="https://i.stack.imgur.com/G1X8g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G1X8g.png" alt="enter image description here" /></a></p> <p>And the result of opening file3.txt in notepad++ is, just 2 lilnes, not 3 lines. <a href="https://i.stack.imgur.com/NdCSn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NdCSn.png" alt="enter image description here" /></a></p> https://mathematica.stackexchange.com/q/249895 0 Solving a complex equation with Solve Ralf https://mathematica.stackexchange.com/users/80634 2021-06-20T03:27:54Z 2021-06-20T23:47:25Z <p>I would like to solve:</p> <p><span class="math-container">$e^{-b (1.365)} + e^{-b(-0.350)} + e^{-b(-0.378)} = 0$</span>, where <span class="math-container">$b$</span> is complex.</p> <p>So, I have written:</p> <pre><code>Solve[{E^((-b1 - I b2) (1.365)) + E^((-b1 - I b2) (-0.350)) + E^((-b1 - I b2) (-0.378)) == 0, {b1, b2} \[Element] Reals}, {b1,b2}] </code></pre> <p>which returns a huge list. How can I get a exact answer? And if it has many solutions, is it possible that I plot the solution points altogether in the complex plane?</p> https://mathematica.stackexchange.com/q/249889 -1 Please I need help, how can I solve this heat impulsive system? [closed] walid fssm https://mathematica.stackexchange.com/users/72646 2021-06-19T21:17:55Z 2021-06-21T11:26:41Z <p>Please I need your help!! I need to solve the following system:</p> <p><span class="math-container">$$\left\{\begin{array}{ll} \partial_{t} \psi(x,t)-\Delta \psi(x,t)=0, &amp; (x,t)\in (0,1) \times((0, 2) \backslash\{1\}) \\ \psi(0,t)= \psi(1,t)=0, &amp; t \in (0, 2) \\ \psi(x, 0)= x (1-x), &amp; x \in (0,1) \\ \psi(x, 1)=\psi\left(x, 1^{-}\right)+4, &amp; x \in (0,1) \end{array}\right.$$</span></p> <p><span class="math-container">$1^{-}$</span> denotes the limit to the left!</p> <p>Best regards,</p> https://mathematica.stackexchange.com/q/249823 0 Odd printing / print preview dionys https://mathematica.stackexchange.com/users/20144 2021-06-18T12:50:51Z 2021-06-21T10:53:44Z <p><strong>Bug introduced in 12.2 or earlier and fixed in 12.3</strong></p> <hr /> <p>What's is going on here with the print display in my Mathematica? Has anyone else seen this behavior? The notebook looks completely normal in the frontend display.</p> <p><a href="https://i.stack.imgur.com/gY1d9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gY1d9.png" alt="garbled print output" /></a></p> <p>This mess appears in the print output, print preview, and also when I attempt to save as pdf.</p> <p>I'm running a stock install:</p> <pre><code>\$Version (* &quot;12.2.0 for Linux x86 (64-bit) (December 12, 2020)&quot; *) </code></pre> <ul> <li><p>OS: GNU/Linux (x86_64)</p> </li> <li><p>Kernel: 4.19.0-13-amd64</p> </li> <li><p>Distro: Debian stable (Debian 4.19.160-2, 2020-11-28)</p> </li> </ul> <hr /> <p>Addendum: This appears to be fixed in 12.3</p> https://mathematica.stackexchange.com/q/249767 1 Plotting a graph with legends that don't overlap the graph? Maths https://mathematica.stackexchange.com/users/61373 2021-06-17T11:35:37Z 2021-06-21T11:42:22Z <p>Consider:</p> <pre><code>tmax = 100; b = 0.1; n[t_] := S[t] + P[t] SP = NDSolveValue[{ S'[t] == (-b/n[t])*S[t]*P[t], P'[t] == (b/n[t])*S[t]*P[t], S == 0.99, P == 0.01}, {S, P}, {t, 0, tmax}]; Plot[{Through[SP[t]], Total@Through[SP[t]]} // Evaluate, {t, 0, tmax}, PlotStyle -&gt; {Blue, Red, Dashed}, Frame -&gt; True, FrameLabel -&gt; {Style[Time, Black, FontSize -&gt; 15], Style[Density, Black, FontSize -&gt; 15]}, PlotLegends -&gt; Placed[{&quot;A(t)&quot;, &quot;B(t)&quot;}, {Right, Top}]] </code></pre> <p>How do I plot the legends such that it doesn't overlap? for different inputs the graph changes so is there an automatic way for it not to overlap?</p> <p>Side questions:</p> <p>i) How do I put a box around the legends after they've been fixed?<br /> ii) How to insert extra parameter in legends without it being a graph in the plot? <br /> iii) How to put another dashed line at 0(and make the dashed lines both black in colour)?</p> <p><strong>EDIT</strong>(using Szabolcs's solution):</p> <pre><code>tmax = 100; b = 0.2; g = 0.2; n[t_] := S[t] + P[t] + R[t] SPR = NDSolveValue[{ S'[t] == (-b/n[t])*S[t]*P[t], P'[t] == (b/n[t])*S[t]*P[t] - g*P[t], R'[t] == g*P[t], S == 0.95, P == 0.05, R == 0}, {S, P, R}, {t, 0, tmax}]; {f1, f2, f3} = SPR; st = Style[#, 15, Black] &amp;; Plot[{f1[t], f2[t], f3[t], f1[t] + f2[t] + f3[t], 0}, {t, 0, tmax}, PlotStyle -&gt; {Blue, Red, Green, Directive[Black, Dashed], Directive[Black, Dashed]}, Frame -&gt; True, FrameLabel -&gt; st /@ {&quot;Time&quot;, &quot;Density&quot;}, PlotLegends -&gt; Placed[LineLegend[{Blue, Red, Green, Black}, {&quot;A(t)&quot;, &quot;B(t)&quot;, &quot;C(t)&quot;}, LegendFunction -&gt; Framed], {0.85, 0.65}]] </code></pre> <p>We have overlapping; how can we reduce the size of legends? and place it automatically such that it doesn't overlap the graph?</p> https://mathematica.stackexchange.com/q/249705 0 Why does the function "NMaximize" product a new result while the condition changes from the subset of the set A to A? Hengji Li https://mathematica.stackexchange.com/users/80575 2021-06-16T10:05:07Z 2021-06-21T16:32:05Z <pre><code>In:= DIU2[a1_, c1_] = Simplify[1/ 8 (Sqrt[1 - a1^2 - c1^2] (14 Sqrt[1 - a1^2 - c1^2] + 2 Sqrt[1 - a1^2 - c1^2] Cos[2 \[Theta]] + Sqrt (a1 + c1) Sin[2 \[Theta]]) + a1 (9 a1 + 5 c1 - (a1 + c1) Cos[2 \[Theta]] + Sqrt Sqrt[1 - a1^2 - c1^2] Sin[2 \[Theta]]) + c1 (5 a1 + 9 c1 - (a1 + c1) Cos[2 \[Theta]] + Sqrt Sqrt[1 - a1^2 - c1^2] Sin[2 \[Theta]]))] Out= 1/8 (14 - 5 a1^2 + 10 a1 c1 - 5 c1^2 - (-2 + 3 a1^2 + 2 a1 c1 + 3 c1^2) Cos[2 \[Theta]] + 2 Sqrt (a1 + c1) Sqrt[1 - a1^2 - c1^2] Sin[2 \[Theta]]) In:= NMaximize[{Simplify[DIU2[a1, c1] /. {\[Theta] -&gt; 1.2}], 0 &lt;= a1 &lt;= 1 &amp;&amp; 0 &lt;= c1 &lt;= 1 &amp;&amp; a1^2 + c1^2 &lt;= 1}, {a1, c1}] \:6B63\:5728\:8BA1\:7B97In:= NMaximize::nrnum: The function value -1.75565-0.0964303 I is not a real number at {a1,c1} = {0.426364,0.95088}. Out= {1.92067, {a1 -&gt; 0.437452, c1 -&gt; 0.70154}} In:= NMaximize[{Simplify[DIU2[a1, c1] /. {\[Theta] -&gt; 1.2}], 0 &lt;= a1 &lt;= 1/Sqrt &amp;&amp; 0 &lt;= c1 &lt;= 1/Sqrt &amp;&amp; a1^2 + c1^2 &lt;= 1}, {a1, c1}] Out= {2., {a1 -&gt; 0.659051, c1 -&gt; 0.659051}} </code></pre> <p>There are two kinds of boundary conditions, A and B, ant it satisfies A is contained in B. However，the maximum value with the condition A is bigger than B?</p> https://mathematica.stackexchange.com/q/249530 0 GAN LSTM Time Series unmark1 https://mathematica.stackexchange.com/users/60042 2021-06-11T21:45:01Z 2021-06-21T17:05:55Z <p>Does anyone know if it is possible to use LSTM or another RNN in GAN architecture as the generator? Here a reference: <a href="https://core.ac.uk/download/pdf/240229094.pdf" rel="nofollow noreferrer">1</a></p> <p>Thx!</p> <p>To clarify, what I am asking is it possible in MMA 12.3 (my current version) and what I have done so far:</p> <pre><code>generator = NetChain[ { 50, ParametricRampLayer[], 50, ParametricRampLayer[], LinearLayer[{}], Tanh } , &quot;Output&quot; -&gt; &quot;Real&quot; ] discriminator = NetChain[ { 50, ParametricRampLayer[], 50, ParametricRampLayer[], LinearLayer[] } , &quot;Input&quot;-&gt;&quot;Real&quot;, &quot;Output&quot;-&gt;&quot;Real&quot; ] gan = NetGANOperator[{generator, discriminator}, &quot;Latent&quot; -&gt; 20] </code></pre> <p>This works fine, by the way it is the reference example from Wolfram <a href="https://reference.wolfram.com/language/ref/NetGANOperator.html" rel="nofollow noreferrer">GAN Net Operator Wolfram</a></p> <p>However, I have read in some recent papers <a href="https://cs230.stanford.edu/projects_fall_2019/reports/26259829.pdf" rel="nofollow noreferrer">Stanford</a>, that researchers are including in the discriminator, for example, some kind of recurrent layer. So, I have tried, without success, the following:</p> <pre><code>discriminator = NetInitialize@ NetChain[{GatedRecurrentLayer, LinearLayer}, &quot;Input&quot; -&gt; {1, 1}, &quot;Output&quot; -&gt; &quot;Scalar&quot;] </code></pre> <p>But I receive the following error message:</p> <p><strong>NetGANOperator: The discriminator (second element of the first argument), should output a real number, but it outputs a length-1 vector of real numbers instead.</strong></p> <p>I have already tried to change the output format but nothing seems to work.</p> <p>So, if anyone has something to add I would be very grateful.</p> <p>Thank you!</p> https://mathematica.stackexchange.com/q/246484 0 Plot a line colored set by value of a different list jonathan https://mathematica.stackexchange.com/users/76636 2021-05-22T15:58:22Z 2021-06-21T17:00:25Z <p>I have a model, see code below:</p> <pre><code>n = 10; lis = Table[i^4, {i, 0, 1, 1/n}]; grad = {1, 1, 9, 9, 9, 9, 9, 9, 10, 10, 10}; int = Interpolation[grad]; cf = Function[{x, f}, ColorData[{&quot;AvocadoColors&quot;, {0, n}}][int[x]]]; cf2 = ColorData[{&quot;AvocadoColors&quot;, {0, n}}] /@ grad; g1 = ListLinePlot[lis, ColorFunction -&gt; cf, ColorFunctionScaling -&gt; False] g2 = ListLinePlot[lis, ColorFunction -&gt; cf2, ColorFunctionScaling -&gt; False] g3 = ListLinePlot[Table[{i, i^4}, {i, 0, 1, 1/n}], ColorFunction -&gt; cf2, ColorFunctionScaling -&gt; False] </code></pre> <p>I have tried coloring &quot;lis&quot; using the values in grad. for some reason, the method in g2 (using cf2) is not working and in g1 it is great (using cf) and that is the result I'm looking for. the problem is that in g3, when I'm trying to plot &quot;lis&quot; and scale the x-axis interpolation is not working well, how can I fit the results so g3 would be colored as g1 (using cf and not cf2)?</p>