## Problem with the Rank of a matrix after a FindRoot

I am solving a boundary problem defined by a set of four-component vectorial functions. Without going into many details, I have two functions on the left and two on the right of an interface. The boundary problem is defined by requiring that the sum of the two functions on the left is equal to the sum of the two on the right when the functions are evaluated at the position of the interface. The various components of the functions are given by confluent hypergeometric functions of the first and second kind. A similar problem is studied in this work but with two-components functions "L. Cohnitz, A. De Martino, W. Häusler, and R. Egger, Phys. Rev. B 94, 165443 (2016) [https://arxiv.org/pdf/1608.03469.pdf]".

The problem admits a unique solution when the determinant of the matrix associated with the 4 functions is zero. There is a free parameter $$j$$ and for a given value of it, I can determine with FindRoot the associated value of the energy $$\mathcal{E}$$. For this pair of number, the determinant is smaller than $$10^{-10}$$, however, the rank of the associated matrix is not reduced to 3 but is still 4. To reduce the Rank of the matrix, I need to work around the solution $$\mathcal{E}$$, until the determinant is not smaller than $$10^{-16}$$!

Is there any solution around this problem. I am happy to give additional details if necessary, I am not posting the code because is pretty long at the moment.

## Choosing the elements from Matrix or any ideas for help

again me. I am finding a function that can help me choose the elements from the matrix as below:

   F:=(F0,F1,F2,F3..Fk) 

As I know Table function, it only works with the matrix such as:

   F:= {{F0},{F1}....{Fk}}, Table[F[i+1,1],{i,1,k+1}] 

## Basic Projection & View matrix

Currently writing a camera component for FNA (basically XNA), and can’t for the life of me figure out why my matrix transform isn’t working as expected. This is how I calculate my view & projection matrices:

// projection // WorldSize is something like 16x9, 20x10, etc. Basically the "simulated" world size. // Zoom is just a float to zoom the camera. var left = Zoom * -WorldSize.X / 2; var right = Zoom * WorldSize.X / 2; var bottom = Zoom * -WorldSize.Y / 2; var top = Zoom * WorldSize.Y / 2; const float near = 0; const float far = 100; var projection = Matrix.CreateOrthographicOffCenter(left, right, bottom, top, near, far); 

and

// view // Position is the position of my Camera, e.g. (10, 15), (6.51, 16.612), etc. var position = new Vector3(Position, 0); var target = position + Vector3.Forward; var up = Vector3.Up; var view = Matrix.CreateLookAt(position, target, up);  // Combine them var combined = projection * view; 

This should, by all the sources I’ve checked, double-checked, and triple-checked, be correct. However when I apply this matrix to my batch or effects it doesn’t show anything at all:

// I would expect a white square to be rendered in the middle of the screen. Since WorldSize is // 16x9 I would expect a 1x1 square to be clearly visible. var batch = new SpriteBatch(); batch.begin(/* the rest */, combined); var texture = new Texture2D(Game.GraphicsDevice, 1, 1); texture.SetData(new []{Color.White }); batch.Draw(texture, Vector2.Zero, Color.White); batch.End();  // Also tried just rendering lines, shows nothing var effect = new BasicEffect(graphicsDevice) {     VertexColorEnabled = true,     View = view,     Projection = projection }; effect.CurrentTechnique.Passes[0].Apply(); graphicsDevice.DrawUserPrimitives(PrimitiveType.LineStrip, vertices, 0, vertices.Length - 1); 

I have checked so many sources and they all do exactly like this. I even tried copy+pasting the matrix source code for a Java project I made some time back that I know works, and that didn’t work either so I don’t think the Matrix transforms are to blame. Anyone know what I’m doing wrong?

## Solve Matrix equations with Cross Product: weird system of equations

I would like to find the values {Pfx, Pfy, Pfz} that satisfy the equation A X B = C . The code of everything is at the end, I want to ilustrate with images what i think of first:

A is this:

B is this: {0,0,0}

And C is this: {100,500,200}

The image of the complete code is this one:

My variable here are {Pfx,Pfy,Pfz} and the {i,j,k} are the unit vectors. The way that the matrix is shown in the picture corresponds with a trick used to solve in papper this type of matrix.

The solution would give me the value of Pfx in the "x" coordinate (and this would be expressed by Pfx being multiplied with the i vector). And the same mechanism applies with Pfy related with j Vector ; and Pfz related with k.

The problem here comes with the fact that the I cant find the values {Pfx, Pfy, Pfz} that satisfy the equation A X B = C. I am not sure if the problem lies in the "LinearSolve" comand, in the use of the CrossProduct or in the use of the versor {i, j, k} inside the matrix.

Any kind of help in this regard will be extreamly useful, thanks in advance!!

Code:

i := {1, 0, 0}  j := {0, 1, 0}  k := {0, 0, 1}  LinearSolve[({ {i, j, k},{1, 2, 3},{Pfx, Pfy, Pfz}})\[Cross]({{0},{0},{0}}) == ( {{100},{500},{200}} )]    

## Poisson GeneralizedLinearModelFit with log link, first argument not a vector, matrix or list

Question:

I’m trying to plot a graph for an exponential decay for a radioactivity experiment, so model is y=Ae^(-kt). Cross-Validated SE, suggested trying a Poisson GLM with a log link fit, and then to output mean deviance for goodness of fit. I’ve tried doing this but am getting the error:

GeneralizedLinearModelFit::notdata: The first argument is not a vector,  matrix, or a list containing a design matrix and response vector. 

And admittedly, I don’t really understand the documentation for it. And am unsure how to implement the show mean residuals part of this. The documentation shows how to output all of the deviance residuals, but not the mean of them directly.

Data

dataHist5 = {{Around[16.5, 1.5],     Around[77.8, 8.8]}, {Around[34.5, 1.5],     Around[60.5, 8.0]}, {Around[52.5, 1.5],     Around[63.8, 8.0]}, {Around[106.5, 1.5],     Around[42.4, 6.5]}, {Around[124.5, 1.5],     Around[41.7, 6.5]}, {Around[142.5, 1.5],     Around[14.6, 3.8]}, {Around[160.5, 1.5],     Around[33.9, 5.8]}, {Around[178.5, 1.5],     Around[29.4, 5.4]}, {Around[196.5, 1.5],     Around[33.5, 5.8]}, {Around[214.5, 1.5],     Around[30.9, 5.6]}, {Around[232.5, 1.5],     Around[31.1, 5.8]}, {Around[250.5, 1.5],     Around[21.5, 4.6]}, {Around[268.5, 1.5],     Around[4.3, 2.1]}, {Around[286.5, 1.5],     Around[6.4, 2.5]}, {Around[322.5, 1.5],     Around[7.5, 2.7]}, {Around[340.5, 1.5],     Around[4.5, 2.1]}, {Around[358.5, 1.5],     Around[11., 3.3]}, {Around[376.5, 1.5],     Around[14.0, 3.7]}, {Around[394.5, 1.5],     Around[14.0, 3.7]}, {Around[466.5, 1.5],     Around[0.6, 0.7]}, {Around[502.5, 1.5],     Around[2.2, 1.5]}, {Around[520.5, 1.5],     Around[9.4, 3.1]}, {Around[538.5, 1.5],     Around[4.1, 2.0]}, {Around[646.5, 1.5],     Around[2.2, 1.5]}, {Around[682.5, 1.5], Around[0.6, 0.7]}} 

Code, so far:

glm = GeneralizedLinearModelFit[dataHist5, x, x,     ExponentialFamily -> "Poisson"] // Normal Show[ListPlot[dataHist5, Plot[glm[x]]] 

I think I’m missing an argument in Plot[glm[x]]], but not sure what.

## Von Neumann Equation Density Matrix Implementation

I’m trying to implement the von Neumann Equation for a given 4×4 density Matrix with a time dependent Hamiltonian Hp[t_] in Mathematica but I get stuck.

Format[y[a__]] := Subscript[y, a] rho[t_] := Array[x[##][t] &, {4, 4}]  sol = NDSolve[{I*rho'[t] == Hp[t].rho[t] - rho[t].Hp[t],     rho[0] == rhoIni}, {rho}, {t, 0, 10}] 

However I only get the output

{{rho -> rho}} 

So I guess something is structurally wrong with my code. I try to extract a solution by writing

rho[t_] = rho[t] /. sol 

But this doesn’t work as there is no solution anyways. Maybe you can help me

## Hello, I’m trying to do the QR decomposition using Gram Schmidt but I’m having problems because I can’t find the R matrix. Could you help me?

First of all I don’t want to use the reflection method. Only Gram-Schmidt.

So here’s the program for Gram-Schidt:

GS[A_] := Module[{u = {}, col, e = {}, ae, t},   col = Transpose[A];(* list with the column vectors of A *)   u = Append[u, col[[1]]];   e = AppendTo[e, u[[1]]/Norm[u[[1]]]];   For[i = 2, i <= Length[A], i++, ae = 0; t = 1;    While[t <= i - 1, ae = ae - (col[[i]].e[[t]])*e[[t]]; t++];    u = AppendTo[u, col[[i]] + ae];    e = Append[e, u[[i]]/Norm[u[[i]]]]]; {u, e}] 

with this simple matrix:

B = {{1, 3, 1}, {2, 2, 1}, {3, 2, 3}}; 

gives

{{{1, 2, 3}, {29/14, 1/7, -(11/14)}, {14/69, -(49/69), 28/69}}, {{1/    Sqrt[14], Sqrt[2/7], 3/Sqrt[14]}, {29/Sqrt[966], Sqrt[2/    483], -(11/Sqrt[966])}, {2/Sqrt[69], -(7/Sqrt[69]), 4/Sqrt[69]}}} 

Now the code for QR decomposition is:

QR[A_] := Module[{Ak, i, Q, R = {}, a = {}, col, k},   Ak = FullSimplify[GS[A]];   col = Transpose[A];(* list with the column vectors of A *)   Q = MatrixForm[Transpose[Ak[[2]]]];   For[i = 1, i <= Length[Ak[[2]]], i++, a = {}; k == 1;    While[k <= Length[col], a = AppendTo[a, col[[k]]. Ak[[2]][[i]]];      k++];     R = AppendTo[R, a]];   R = UpperTriangularize[R]; {Q, R}] 

but I can’t find matrix R, once it’s giving me a list like this{{},{},{}} and I’m stuck. Please help me.Thanks!

## Manipulation of a symbolic matrix expression

I have the following code:

enter code here 

## Simplifying elements of a matrix

These elements of the matrices can be simplified by hand much further{roots can be cancelled and all}, yet the Fullsimplify in Mathematica doesn’t simply it completely.

The matrix is:

{{-((p^2 + Sqrt[m^2 + p^2] p3 - p0 (Sqrt[m^2 + p^2] + p3))/    m), -(((p^2 + (m + Sqrt[m^2 + p^2]) (m - p0)) (-I p2 + Sqrt[       p^2 - p2^2 - p3^2]))/(m (m + Sqrt[m^2 + p^2]))), (1/(   m (m + Sqrt[m^2 + p^2])))(-p^2 p2 + Sqrt[m^2 + p^2] p0 p2 +      m (-Sqrt[m^2 + p^2] + p0) p2 - I p0 p3 Sqrt[p^2 - p2^2 - p3^2] +      I p3 Sqrt[-(m^2 + p^2) (-p^2 + p2^2 + p3^2)] +      I m^2 (I p2 + Sqrt[p^2 - p2^2 - p3^2]) +      I m (p3 Sqrt[p^2 - p2^2 - p3^2] +         Sqrt[-(m^2 + p^2) (-p^2 + p2^2 + p3^2)])), (1/(   m (m + Sqrt[m^2 + p^2])))(-I (Sqrt[m^2 + p^2] - p0) p2^2 +      I m^2 (p0 - p3) -      I p3 (p^2 + Sqrt[m^2 + p^2] p3 - p0 (Sqrt[m^2 + p^2] + p3)) +      p2 (-p0 Sqrt[p^2 - p2^2 - p3^2] +         Sqrt[-(m^2 + p^2) (-p^2 + p2^2 + p3^2)]) +      m (I (p0 - p3) (Sqrt[m^2 + p^2] + p3) +         p2 (-I p2 + Sqrt[p^2 - p2^2 - p3^2])))}, {-(((p^2 + (m + Sqrt[          m^2 + p^2]) (m - p0)) (I p2 + Sqrt[p^2 - p2^2 - p3^2]))/(    m (m + Sqrt[m^2 + p^2]))), (-p^2 + p0 (Sqrt[m^2 + p^2] - p3) +     Sqrt[m^2 + p^2] p3)/m, (1/(   m (m + Sqrt[m^2 + p^2])))(-I (Sqrt[m^2 + p^2] - p0) p2^2 +      I m^2 (p0 + p3) + I m (Sqrt[m^2 + p^2] - p3) (p0 + p3) +      I p3 (p^2 - Sqrt[m^2 + p^2] p0 - Sqrt[m^2 + p^2] p3 + p0 p3) +      p0 p2 Sqrt[p^2 - p2^2 - p3^2] -      p2 Sqrt[-(m^2 + p^2) (-p^2 + p2^2 + p3^2)] -      m p2 (I p2 + Sqrt[p^2 - p2^2 - p3^2])), (1/(   m (m + Sqrt[m^2 + p^2])))(p^2 p2 + m (Sqrt[m^2 + p^2] - p0) p2 -      Sqrt[m^2 + p^2] p0 p2 + I p0 p3 Sqrt[p^2 - p2^2 - p3^2] -      I p3 Sqrt[-(m^2 + p^2) (-p^2 + p2^2 + p3^2)] +      m^2 (p2 + I Sqrt[p^2 - p2^2 - p3^2]) +      I m (-p3 Sqrt[p^2 - p2^2 - p3^2] +         Sqrt[-(m^2 + p^2) (-p^2 + p2^2 + p3^2)]))}, {(1/(   m (m + Sqrt[m^2 + p^2])))(-p^2 p2 + Sqrt[m^2 + p^2] p0 p2 +      m (-Sqrt[m^2 + p^2] + p0) p2 + I p0 p3 Sqrt[p^2 - p2^2 - p3^2] -      I p3 Sqrt[-(m^2 + p^2) (-p^2 + p2^2 + p3^2)] +      I m^2 (I p2 + Sqrt[p^2 - p2^2 - p3^2]) +      I m (-p3 Sqrt[p^2 - p2^2 - p3^2] +         Sqrt[-(m^2 + p^2) (-p^2 + p2^2 + p3^2)])), (1/(   m (m + Sqrt[m^2 + p^2])))(I (Sqrt[m^2 + p^2] - p0) p2^2 -      I m^2 (p0 + p3) +      I p3 (-p^2 + Sqrt[m^2 + p^2] p0 + Sqrt[m^2 + p^2] p3 - p0 p3) +      p0 p2 Sqrt[p^2 - p2^2 - p3^2] -      p2 Sqrt[-(m^2 + p^2) (-p^2 + p2^2 + p3^2)] -      I m ((Sqrt[m^2 + p^2] - p3) (p0 + p3) +         p2 (-p2 - I Sqrt[p^2 - p2^2 - p3^2]))), (-p^2 +     p0 (Sqrt[m^2 + p^2] - p3) + Sqrt[m^2 + p^2] p3)/   m, ((p^2 + (m + Sqrt[m^2 + p^2]) (m - p0)) (-I p2 + Sqrt[      p^2 - p2^2 - p3^2]))/(m (m + Sqrt[m^2 + p^2]))}, {(1/(   m (m + Sqrt[m^2 + p^2])))(I (Sqrt[m^2 + p^2] - p0) p2^2 -      I m^2 (p0 - p3) +      I p3 (p^2 + Sqrt[m^2 + p^2] p3 - p0 (Sqrt[m^2 + p^2] + p3)) +      p2 (-p0 Sqrt[p^2 - p2^2 - p3^2] +         Sqrt[-(m^2 + p^2) (-p^2 + p2^2 + p3^2)]) +      m (-I (p0 - p3) (Sqrt[m^2 + p^2] + p3) +         p2 (I p2 + Sqrt[p^2 - p2^2 - p3^2]))), (1/(   m (m + Sqrt[m^2 + p^2])))(p^2 p2 + m (Sqrt[m^2 + p^2] - p0) p2 -      Sqrt[m^2 + p^2] p0 p2 - I p0 p3 Sqrt[p^2 - p2^2 - p3^2] +      I p3 Sqrt[-(m^2 + p^2) (-p^2 + p2^2 + p3^2)] +      m^2 (p2 + I Sqrt[p^2 - p2^2 - p3^2]) +      I m (p3 Sqrt[p^2 - p2^2 - p3^2] +         Sqrt[-(m^2 + p^2) (-p^2 + p2^2 + p3^2)])), ((p^2 + (m + Sqrt[         m^2 + p^2]) (m - p0)) (I p2 + Sqrt[p^2 - p2^2 - p3^2]))/(   m (m + Sqrt[m^2 + p^2])), -((    p^2 + Sqrt[m^2 + p^2] p3 - p0 (Sqrt[m^2 + p^2] + p3))/m)}} 

some of the substitution we can make are (already taken),

{p1 -> Sqrt[p^2 - p2^2 - p3^2], e -> Sqrt[p^2 + m^2]} Assuming[{Element[{p0, p, p2, p3}, Reals], m > 0}, sat2 = sat // FullSimplify] `

What more could be done to simplify the elements of the matrix?

## How to decompose a 4×4 TRS transformation matrix with negative scale?

As the title says I need to decompose 4×4 TRS transformation matrices and extract the proper scale vectors and the proper rotation vectors (or rotation quaternions).

I know how to extract those information when the upper 3×3 matrix determinant is not negative. The problem is that those matrices can have that negative determinant and as far as I could understand, this negative determinant indicates a flip or mirrored transformation.

What do I have to do to extract the proper values for scale and rotation in those cases?