Items tagged with matrix matrix Tagged Items Feed

I'm computing a matrix which is a hessian of a quadratic function and it should be symmetric.

Unfortunately, because of the numerical errors, the hessian matrix becomes unsymmetric. 

Then, I want to use this matrix as the input for the QPSolve procedure, and I get the error that the matrix is unsymmetric.  

To obtain the symmetric matrix, I'm doing the following redundant computation:

A := MTM[triu](B, 1) + Transpose(MTM[triu](B)):

Is there a better solution to this problem?

following commands on my computer got an error.

restart;
with(LinearAlgebra):
A:=Matrix([[1,3],[2,5]],datatype=float):
b:=Vector([1,1],datatype=float):
LinearSolve(A,b,method=hybrid);
Error, (in SWcallhybrid[1]) param 4 should be an rtable

any suggestion is appreciated.

win7, 12.02

I noticed this in Student:-NumericalAnalysis:-Romberg, here are the lines of interest:

The question  is: Why create rtable, apply algorithm, then convert to Matrix at end? Why not replace line 4 below with Matrix command from start? Could not the same thing be done using Matrix from the start?

-----------------------------------------
proc(expr, var, a, b, n)
local f, R, j, k, i, oldDigits;
   4   R := rtable(1 .. n,1 .. n,('storage') = ('triangular')['lower']);  #Why not create Matrix here?
   6   R[1,1] := evalf(1/2*(b-a)*(f(a)+f(b)));
   7   for k from 2 to n do
   8     R[k,1] := 1/2*evalf(R[k-1,1]+(b-a)/(2^(k-2))*add(f(a+(2*i-1)*(b-a)/(2^(k-1))),i = 1 .. 2^(k-2)))
       end do;
  10   for j from 2 to n do
  11     for k from j to n do
  12       R[k,j] := evalf(4^(j-1)*R[k,j-1]-R[k-1,j-1])/(4^(j-1)-1)
         end do
       end do;
  13   R := evalf[oldDigits](R);
  14   return convert(R,Matrix,('shape') = ('triangular')['lower']) #Why not use Matrix from the start?
end proc
------------------------------------------

Maple 18.02

I have about a year of experience in Maple, but as we know, we often come accross very simple problems that are difficult to find solutions to. Part of the problem is that I have not used conditional tests within for loops before.

I have a very large matrix, but until I solidify the algorithm, I'm practicing on a small matrix.

I created a 3 by 3 fibonacci matrix A:=<21,5,1|13,3,1|6,2,0>

I am trying to change the 1s to 0s without specific index reference. Here is my psuedocode that I hope to work on after some tips:

  • for i from 1 to 9
    if A[k] = 1 then
    A[k]=0
    end if
    end do

 

I get an error message saying "unterminated for loop," which is confusing me.

Hi,

 

I have a system of equations containing curls, divergence and gradients of variables. 

How can I extract the coefficients of the equations (i.e. coefficients of d/dt rho, d/dx p) and form a matrix?

thanks.   

test.mw

restart; with(LinearAlgebra)

``

dF := -.525*exp(-7*t)+2.625*exp(-3*t)+.8*exp(-4*t);

-.525*exp(-7*t)+2.625*exp(-3*t)+.8*exp(-4*t)

(1)

``

e3 := `<,>`(1, 1, 1); E := proc (m) options operator, arrow; IdentityMatrix(m) end proc; beta := `<|>`(.1, .6, .3); S := `<|>`(`<,>`(-3, 1, 1), `<,>`(1, -5, 2), `<,>`(0, 2, -4)); S0 := -S.e3

beta := Vector[row](3, {(1) = .1, (2) = .6, (3) = .3})

 

S := Matrix(3, 3, {(1, 1) = -3, (1, 2) = 1, (1, 3) = 0, (2, 1) = 1, (2, 2) = -5, (2, 3) = 2, (3, 1) = 1, (3, 2) = 2, (3, 3) = -4})

 

S0 := Vector(3, {(1) = 2, (2) = 2, (3) = 1})

(2)

Z := `<|>`(x, y, z)

Z := Vector[row](3, {(1) = x, (2) = y, (3) = z})

(3)

ME := MatrixExponential(S+Typesetting:-delayDotProduct(S0, Z), t);

`[Length of output exceeds limit of 1000000]`

(4)

MEint := map(int, ME.dF, t = 0 .. infinity)

Error, (in int) wrong number (or type) of arguments: wrong type of integrand passed to definite integration.

 

`&beta;plus&Assign;solve`(Z = beta.MEint, Z)

"(RTABLE(18446744074195006390,VECTOR([x, y, z]),Vector[row])=RTABLE(18446744074193876574,VECTOR([.1, .6, .3]),Vector[row]).MEint) betaplus:=solve (RTABLE(18446744074195006390,VECTOR([x, y, z]),Vector[row]))"

(5)

``

1step- I want to integrate the (ME*dF) from t=0 to ∞ .

2step- Evaluate Z=<x,y,z> by solving Z=β*MEint.

Download test.mw

Hello,

I would like to ask for help with factorization, collection or decomposition of matricies. If I have the symbolic product of matrices:

A := Matrix(2, 2, {(1, 1) = a[11], (1, 2) = a[12], (2, 1) = a[21], (2, 2) = a[22]})

B := Matrix(2, 2, {(1, 1) = b[11], (1, 2) = b[12], (2, 1) = b[21], (2, 2) = b[22]})

then C:= A*B :

Matrix(2, 2, {(1, 1) = a[11]*b[11]+a[12]*b[21], (1, 2) = a[11]*b[12]+a[12]*b[22], (2, 1) = a[21]*b[11]+a[22]*b[21], (2, 2) = a[21]*b[12]+a[22]*b[22]})

and my question follows:

Can I factor this result C and get the imput matrices A and B ? Is any function for this operation ? I would like to use it for matrices 3 time 3 not only for 2 times 2.

Thank you for your help,

vidocq

 

I have a nonlinear system with 4 equations and 4 unknowns. I am using fsolve. I know that there are multiple solutions for each variable but am only getting one. I need the others. what do I do??

This is my code:

R__1 := Matrix([[1, 0] , [0, 1] ]);

R__2 := Matrix([[1/2, sqrt(3)/2] , [-sqrt(3)/2, 1/2] ]);

R__3 := Matrix([[-1/2, sqrt(3)/2] , [-sqrt(3)/2, -1/2] ]);

R__4 := Matrix([[-1, 0] , [0, -1] ]);

R__5 := Matrix([[-1/2, -sqrt(3)/2] , [sqrt(3)/2, -1/2] ]);

 

d__1 := Vector( [ 0, 5.4] );

d__2 := Vector( [ 6.4, 4.539] );

d__3 := Vector( [ 11, 4.078] );

d__4 := Vector( [ 15.5, 2.079] );

d__5 := Vector( [ 19, 1.039] );

 

a := Vector( [ a__x, a__y] );

 

A__1:=R__1.a+d__1;

A__2:=R__2.a+d__2;

A__3:=R__3.a+d__3;

A__4:=R__4.a+d__4;

A__5:=R__5.a+d__5;

 

OO:=Vector([O__x,O__y]);

 

DA1:=A__2.A__2-A__1.A__1-2*(A__2-A__1).OO;

DA2:=A__3.A__3-A__1.A__1-2*(A__3-A__1).OO;

DA3:=A__4.A__4-A__1.A__1-2*(A__4-A__1).OO;

DA4:=A__5.A__5-A__1.A__1-2*(A__5-A__1).OO;

 

fsolve({DA1,DA2,DA3,DA4},{a__x,a__y,O__x,O__y});

Thanks for any tips you may be able to offer

 

AoA. How are you hope you will be fine. Sir the following matrix have been given

A := Matrix(2, 2, {(1, 1) = 1, (1, 2) = 2, (2, 1) = -1, (2, 2) = 2});

B := Matrix(2, 2, {(1, 1) = 1, (1, 2) = 0, (2, 1) = -2, (2, 2) = 3});

C := Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0});

I want to write M by M matrix using the above matrices like this

P:=[[[A,B,B,...,B],[C,A,B,...,B],[C,C,A,...,B],[.,.,.,...,B],[C,C,C,...,A]]]

PhD (Scholar)
Department of Mathematics

I want to get the result of multi-matrix multiply like followed below,

but error "final value in for loop must be numeric or character"

(*n is arbitrary and B[1],B[2],...,B[n] have been obtained*)

A:=LinearAlgebra:-IdentityMatrix(n);
#using the multiplication operation of matrix
for i from 1 to n do
   A:=LinearAlgebra:-Multiply(A,B[i]);
od:

return A

help me 

thanks

AoA. How are you? Sir want to generate the attached square matrix for any value of M. Please help.

 

PhD (Scholar)
Department of Mathematics

AoA. How are you? I want to solve the following equation in one step and convenient way please help

 

psi(x):=Matrix(1,3,[x,x-1,x^(2)-x-1])

P := Matrix(3, 3, [1, 2, 1, 0, 1, 1, -1, 2, 3])

U := Matrix(3, 3, [a[1, 1], a[1, 2], a[1, 3], a[2, 1], a[2, 2], a[2, 3], a[3, 1], a[3, 2], a[3, 3]])

u := psi(x)^T*(P^2)^T*U*P^2*psi(t)-t*psi(x)^T*(P^2)^T*U*P^2*psi(1)-x*psi(1)^T*(P^2)^T*U*P^2*psi(t)+t*x*psi(1)^T*(P^2)^T*U*P^2*psi(1)

 

If you reduce my computational work or have any suggestion to solve please give.

PhD (Scholar)
Department of Mathematics

Hello,

I need your help to display the matrix generated by a lenear system.

The linear system is okay, well written, but  there is an error in generate matrix, I get the wrong matrix.

Thank you very much for your help.

 

test.mw

Hi,

I have two all 1.-1  square matrices and want to test whether they are equivalent or not. Can anyone help me with details?Thanks in advance

 

1 2 3 4 5 6 7 Last Page 1 of 33