## How can Integrate of conjugate transpose in mathematica?

0 ConjugateTranspose[u[x,t]] (u_x)[x,t]+I vx,t[x,t] 0 -ConjugateTranspose[u[x,t]] (u^(1,0))[x,t]-I vx,t[x,t] 0 0
0 0 0

u_x and v_x denote the diferentiate with respect to x.I dont know how can integrate the complex conjugate with mathematica. Thanks a lot.

## How to make a circular heat map or diagram in Mathematica?

Is there any way to make a circular heat map in Mathematica?

Here is a toy example for regular heat map. Can anyone help me make it to a circular one?

data1={{9., 1., 6., 7., 6., 3., 1., 3., 10., 2., 2., 5., 2., 5., 3.,    1.}, {5., 5., 5., 4., 4., 6., 4., 6., 9., 1., 2., 10., 2., 1., 1.,    6.}, {2., 7., 6., 2., 8., 10., 8., 9., 2., 5., 3., 9., 7., 8., 7.,    5.}, {6., 6., 2., 1., 8., 2., 8., 3., 8., 5., 5., 4., 6., 2., 3.,    6.}, {8., 1., 8., 2., 5., 8., 5., 3., 5., 3., 4., 2., 2., 4., 4.,    1.}, {10., 2., 8., 10., 3., 6., 1., 9., 3., 5., 2., 5., 1., 3., 7.,    9.}};  ArrayPlot[data1, ColorFunction -> ColorData["LightTerrain"],   Frame -> True,   FrameTicks -> {{{{1, "r1"}, {2, "r2"}, {3, "r3"}, {4, "r4"}, {5,        "r5"}, {6, "r6"}}, None},    {None, {{1, "c1"}, {2, "c2"}, {3, "c3"}, {4, "c4"}, {5, "c5"}, {6,        "c6"}, {7, "c7"}, {8, "c8"}, {9, "c9"}, {10, "c10"}, {11,        "c11"}, {12, "c12"}, {13, "c13"}, {14, "c14"}, {15, "c15"}, {16,        "c16"}}}},   Epilog -> {Text["Sector1", {2, 8}], Text["Sector2", {6, 8}],     Text["Sector3", {10, 8}], Text["Sector4", {14, 8}]},   ImagePadding -> {{20, 20}, {20, 80}}, ImageSize -> Large] 

I want to make a circular diagram like the following one.

Reference: https://stackoverflow.com/questions/62556246/how-to-plot-the-variant-circular-bar-chart-in-r-with-ggplot

Is it possible to make a one like this?

Thanks a lot!

## Robust PCA (better Mathematica style)

I’ve parsed (almost verbatim) Python RPCA implementation to WM. Can it be rewritten using a better WM style? In particular, I’m not happy with Clip[..., {0, Infinity}] and While[] loop (can be replaced with Do[]).

ClearAll[shrink] ; shrink[matrix_, tau_] := Sign[matrix]*Clip[Abs[matrix] - tau, {0, Infinity}]  ClearAll[threshold] ; threshold[matrix_, tau_] := Block[     {u, s, v},     {u, s, v} = SingularValueDecomposition[matrix] ;     Dot[u, Dot[shrink[s, tau], Transpose[v]]] ] ;  ClearAll[rpca] ; rpca[matrix_?MatrixQ, mu_Real, lambda_Real, tolerance_Real, limit_Integer] := Block[     {inverse, count, error, sk, yk, lk},     inverse = 1.0/mu ;      count = 0 ;     sk = yk = lk = ConstantArray[0.0, Dimensions[matrix]] ;     While[         count < limit,         lk = threshold[matrix - sk + inverse*yk, inverse] ;         sk = shrink[matrix - lk + inverse*yk, inverse*lambda] ;         error = matrix - lk - sk ;         yk = yk + mu*error ;         error = Norm[error, "Frobenius"] ;         count++ ;         If[error < tolerance, Break[]] ;     ] ;     {lk, sk, {count, error}} ] ; 

Example:

(* https://github.com/dganguli/robust-pca *) (* "12.1.1 for Linux x86 (64-bit) (June 19, 2020)" *)  (* generate test matrix *)  n = 100 ; num$$groups = 3 ; num$$values = 40 ; matrix = N[ConstantArray[Flatten[Transpose[ConstantArray[10*Range[num$$groups], num$$values]]], n]] ; {n, m} = Dimensions[matrix]  (* set selected elements to zero *)  SeedRandom[1] ; ln = RandomInteger[{1, n}, 20] ; lm = RandomInteger[{1, m}, 20] ; Table[matrix[[ln[[i]], lm[[i]]]] = 0.0, {i, 1, 20}] ; matrix = DeveloperToPackedArray[matrix] ;  (* -- python zeros ln = [81, 15, 1, 68, 4, 66, 24, 98, 69, 75, 16, 25, 5, 91, 84, 71, 2, 31, 49, 26] lm = [45, 74, 107, 70, 57, 48, 29, 69, 27, 69, 11, 87, 77, 44, 34, 45, 87, 94, 19, 39] for x, y in zip(ln, lm):     D[x, y] = 0 *)  (* set parameters *) mu = 1/4*1/Norm[matrix, 1]*Apply[Times, Dimensions[matrix]] ; lambda = 1/Sqrt[N[Max[Dimensions[matrix]]]] ; tolerance = 10.0^-7*Norm[matrix, "Frobenius"] ; limit = 1000 ;  (* rpca *) result = rpca[matrix, mu, lambda, tolerance, limit] ;  (* # of iterations and error *) Last[result]  (* low rank *) +Table[result[[1]][[ln[[i]], lm[[i]]]], {i, 1, 20}]  (* sparse *) -Table[result[[2]][[ln[[i]], lm[[i]]]], {i, 1, 20}]  (* {100, 120} *) (* {39, 0.000167548} *) (* {20., 20., 30., 20., 20., 20., 10., 20., 10., 20., 10., 23.0449, 20., 20., 10., 20., 23.0449, 30., 10., 10.} *) (* {20., 20., 30., 20., 20., 20., 10., 20., 10., 20., 10., 23.0449, 20., 20., 10., 20., 23.0449, 30., 10., 10.} *) 

## RLink fails in Mathematica 12.2.0 Mac OS Catalina

Cannot run RLink in mathematica in Catalina. I get a failed error even though the paclet loads. Any pointers?

## Asymptotic value of an integral using Mathematica

When I plug the integral
$$n \int_0^1 t^{r-1}(2t-t^2)(2-2t) dt$$, I get the following : $$2^{(-1 + 2 n) }nt^{(-1 + r) }(Beta[n, n] – 4 Beta[1/2, 1 + n, n])$$ where $$Beta(x,a,b)=\int_0^x u^{a-1}(1-u)^{b-1} du$$ is the incomplete beta integral.I want to know whether Mathematica can give me intermediate steps and,more importantly,how I can get the asyptotic limit of the value of the integral as n approches infinity.Lots of thanks for any help or hints in advance

## Solve an equation in mathematica without replacing the value of the parameter

Suppose I want to solve a simple equation in mathematica x-a=0.So I am writing the mathematica code for this as below:

Solve[x - a == 0, x] 

So the output will be as below:

{{x -> a}} 

Now suppose I have assigned a value for ‘a’ beforehand and then want to solve the same equation.So my code will look like below:

a = 1; Solve[x - a == 0, x] 

And the output in this case will be like below:

{{x -> 1}} 

Now if I want an output in this case as {{x -> a}},what modification should I do in my code ?

Note: Clear[a] will work,but I don’t want to remove permanently the assigned value to a

## Performance of select from a 3d list – Mathematica slower than Python

I am creating a random 3d data set in Matematica 12.1. Then I am selecting all points that are in a certain range of one axis.

The same I am doing in Python (same computer, Python 3.8.5, numpy 1.19.2)

RESULT: It seems that Python is able to select much faster (1.7 sec) than Mathematica (5.2 sec). What is the reason for that? For selection in Mathematica I used the fastest solution, which is by Carl Woll (see here at bottom).

SeedRandom[1]; coordinates = RandomReal[10, {100000000, 3}];  selectedCoordinates =     Pick[coordinates,      Unitize@Clip[coordinates[[All, 1]], {6, 7}, {0, 0}],      1]; // AbsoluteTiming  {5.16326, Null}  Dimensions[coordinates]  {100000000, 3}  Dimensions[selectedCoordinates]  {10003201, 3} 

PYTHON CODE:

import time import numpy as np   np.random.seed(1) coordinates = np.random.random_sample((100000000,3))*10  start = time.time() selectedCoordinates = coordinates[(coordinates[:,0] > 6) & (coordinates[:,0] < 7)] end = time.time()  print(end-start)  print(coordinates.shape)  print(selectedCoordinates.shape)  1.6979997158050537  (100000000, 3)  (9997954, 3) 

## Can Mathematica solve matrix-based parametric (convex or semidefinite) constrained optimization problems?

I have gone through Mathematica’s documentation and guides on ConvexOptimization, ParametricConvexOptimization and SemidefiniteOptimization. I am also running the latest version of Mathematica.

The kind of matrix-based, parametric, constrained optimization problems I want to solve is this:

$$$$\min_{X_j, \, L_{jk}} \text{Tr}(A L) \ \text{such that, } X_j \text{ and } L_{jk} \text{ are } 4\times4 \text{ Hermitian matrices} \ G_k \cdot X_j = \delta_{j k}\ L:=\begin{bmatrix}L_{11} &L_{12} &L_{13} \ L_{12} &L_{22} &L_{23} \ L_{13} &L_{23} &L_{33}\end{bmatrix} \succeq \begin{bmatrix} X_1 \ X_2 \ X_3 \end{bmatrix}\begin{bmatrix}X_1 &X_2 &X_3\end{bmatrix}$$$$ where the variables to be optimized over are $$X_j$$ and $$L_{jk}$$ ($$j$$ and $$k$$ run from 1 to 3), which are themselves matrices! The matrices $$G_k$$ and $$A$$ depend on some parameter $$\alpha$$ (and satisfy additional properties).

I have been able to run this kind of optimization in MATLAB, and also a much simpler version of this in Mathematica, where $$j, k=1$$ and the parameter value is fixed, using,

ConvexOptimization[   Tr[\[Rho]0 .      v11], {VectorGreaterEqual[{v11, x1}, "SemidefiniteCone"] &&       Tr[\[Rho]0 . x1] == 0  && Tr[\[Rho]1 . x1] == 1   &&      Element[x1, Matrices[{4, 4}, Complexes, Hermitian]] &&      Element[v11, Matrices[{4, 4}, Complexes, Hermitian]]} , {x1,     v11}]] 

However I simply can not get the full problem to run on Mathematica, using either ConvexOptimization[ ] (at fixed parameter values), ParametricConvexOptimization[ ], SemidefiniteOptimization[ ], or Minimize[ ].

ConvexOptimization[ ] at fixed parameter values for $$j, k = 1, 2$$ shows the warning ConvexOptimization::ctuc: The curvature (convexity or concavity) of the term X1.X2 in the constraint {{L11,L12},{L12,L22}}Underscript[\[VectorGreaterEqual], Subsuperscript[\[ScriptCapitalS], +, \[FilledSquare]]]{{X1.X1,X1.X2},{X1.X2,X2.X2}} could not be determined.

Minimize[ ] shows the error Minimize::vecin: Unable to resolve vector inequalities ...

And ParametricConvexOptimization[ ] and SemidefiniteOptimization[ ] simply return the input as output.

Has anyone got some experience with running such matrix-based optimizations in Mathematica? Thanks for your help.

EDIT 1: For the two-dimensional case ($$j, k=1, 2$$) I tried (with $$A$$ the identity matrix, and at fixed parameter value):

ConvexOptimization[  Tr[Tr[ArrayFlatten[{{L11, L12}, {L12,        L22}}]]], {VectorGreaterEqual[{ArrayFlatten[{{L11, L12}, {L12,          L22}}], ArrayFlatten[{{X1 . X1, X1 . X2}, {X1 . X2,          X2 . X2}}]}, "SemidefiniteCone"] &&  Tr[\[Rho]0 . X1] == 0  &&     Tr[\[Rho]0 . X2] == 0 && Tr[\[Rho]1 . X1] == 1  &&     Tr[\[Rho]1 . X2] == 0  && Tr[\[Rho]2 . X1] == 0  &&     Tr[\[Rho]2 . X2] == 1  &&     Element[X1, Matrices[{4, 4}, Complexes, Hermitian]] &&     Element[X2, Matrices[{4, 4}, Complexes, Hermitian]] &&     Element[L11, Matrices[{4, 4}, Complexes, Hermitian]] &&     Element[L12, Matrices[{4, 4}, Complexes, Hermitian]]  &&     Element[L22, Matrices[{4, 4}, Complexes, Hermitian]] }, {X1, X2,    L11, L12, L22}] 

and for the three-dimensional case ($$j, k = 1, 2, 3$$) with variable parameter value and $$A$$ the identity matrix, I tried

ParametricConvexOptimization[  Tr[Tr[ArrayFlatten[{{L11, L12, L13}, {L12, L22, L23}, {L13, L23,        L33}}]]], {VectorGreaterEqual[{ArrayFlatten[{{L11, L12,         L13}, {L12, L22, L23}, {L13, L23, L33}}],      ArrayFlatten[{{X1}, {X2}, {X3}}] .       Transpose[ArrayFlatten[{{X1}, {X2}, {X3}}]]},     "SemidefiniteCone"],  Tr[\[Rho]0 . X1] == 0 ,    Tr[\[Rho]0 . X2] == 0  , Tr[\[Rho]0 . X3] == 0 ,    Tr[\[Rho]1 . X1] == 1 , Tr[\[Rho]1 . X2] == 0  ,    Tr[\[Rho]1 . X3] == 0  , Tr[\[Rho]2 . X1] == 0 ,    Tr[\[Rho]2 . X2] == 1  , Tr[\[Rho]2 . X3] == 0 ,    Tr[\[Rho]3 . X1] == 0 , Tr[\[Rho]3 . X2] == 0  ,    Tr[\[Rho]3 . X3] == 1 }, {Element[X1,     Matrices[{4, 4}, Complexes, Hermitian]],    Element[X2, Matrices[{4, 4}, Complexes, Hermitian]],    Element[X3, Matrices[{4, 4}, Complexes, Hermitian]],    Element[L11, Matrices[{4, 4}, Complexes, Hermitian]],    Element[L12, Matrices[{4, 4}, Complexes, Hermitian]],    Element[L13, Matrices[{4, 4}, Complexes, Hermitian]],    Element[L22, Matrices[{4, 4}, Complexes, Hermitian]],    Element[L23, Matrices[{4, 4}, Complexes, Hermitian]],    Element[L33, Matrices[{4, 4}, Complexes, Hermitian]]}, {\[Alpha]}] 

Here, the $$\rho_{k}$$ matrices are the $$G_k$$ matrices.

## Mathematica shorthand for mapping function over two lists simultaneously

I am still relatively new to Mathematica, so please bear with my question. I have the following statement that works perfectly well:

Table[findcvec[phif, phit, v1[[i]], v2[[i]], +1], {i, Length[v1]}] 

Now, I would like to make a Mathematica shorthand version of this statement using #, &, etc. But this attempt fails:

MapThread[findcvec[phif, phit, #1, #2, +1]] & {v1, v2} 

Could someone please tell me the correct way of doing this?

This might be a duplicate, but I couldn’t any previous question that addresses this specifically. Thank you!

## How can I find in mathematica if my equation have solution or not on a given interval?

I’m new to mathematica, I usually used wolfram alpha, however since the equation that I’m working with is a long equation I need to use mathematica. This is an example of the problem. So, I want to know if the equation will have solution or not when m>=4 and n>=3.41421m. I don’t know what command to use and when I enter this, it said that m>=4 is not a valid variable. What should I do?

Solve[{Binomial[n-1,2]-2[(Binomial[m-1,2])+(n-m)(m-1)-1]<=0}, {m>=4, n>=3.41421m}, Reals]`