## Lower triangular matrix...

Hello everyone!

I want to generate an lower triangular matrix. Please see the attachment and help me. I am waiting your quick response.

Help.mw

## how to normalize a matrix to matrix form?...

aa3 := Normalize(<<aa2[1,1],aa2[2,1],aa2[3,1]>,<aa2[1,2],aa2[2,2],aa2[3,2]>,<aa2[1,3],aa2[2,3],aa2[3,3]>>, Euclidean);

the result is one column

how to normalize to a matrix form?

## How to convert matrix back to ...?...

For example, I havd matrix m:=[0 1 0 1 0 1 0], I want to convert it back to m:=[0,1,0,1,0,1,0]. Can someone help to solve? Thank you.

## 2D Matrix interpolation...

 (1)

 (2)
 (3)

 (4)

 (5)

 (6)

 (7)

 (8)

Hello Mapleprime Community,

Would you be kind to help me with the attached Maple worksheet. My goal is to do a 2D interpolation given the value of SR (slenderness ratio) and E_G (Young's modulus / Shear modulus ratio) in the Matrix table Vert_Coeff with header as vector E_G and the other as vector SR. I’m confused as to how to do the interpolation. Please help.

Regards,

Moses

## Fitting of surface from matrix data...

Hey guys,

I want to fit experimental data and I was wondering if there is a special PolynomialFit function for a surface.

My data consist of a X,Y, Matrix of densities and I want to have a function describing the surface of the values. On matlab the following code will do so:

[x, y, z] = prepareSurfaceData(temps, concs, densities);
ft = fittype('poly33');
fitresult = fit([x, y], z, ft);

Maybe that gives you a better view of what I want.

Best regards

## Constructing Matrix from Expression...

Dear All

For following Algeraic expression

 >

How one can construct a matrix of the following form:

 >
 (1)

Where first row corresponds to and second row corresponds to  and the entries of matrix are coefficients of and

Regards

Hi, currently im using maple 15

the coding did work but it is not the same with the answer
here, i attach the coding with the answer

coding:
derivation := proc (A, n)
local i, j, k, t, s1, s2, m, D, sols, eqns, Andre;
eqns := {};
D := matrix(n, n);
Andre := matrix(n, n);
for i to n-1 do
for j from i+1 to n do
for m to n do
s1 := sum(A[i, j, k]*D[m, k], k = 1 .. n);
s2 := sum(A[k, j, m]*D[k, i]+A[i, k, m]*D[k, j], k = 1 .. n);
eqns := `union`(eqns, {s1 = s2})
end do end do end do;
sols := [solve(eqns)];
t := nops(sols);
for i to t do
for j to n do
for k to n do
Andre[k, j] := subs(sols[i], D[k, j])
end do end do;
print(Andre)
end do end proc

the maple result showing:

> AS1 := array(sparse, 1 .. 2, 1 .. 2, 1 .. 2, [(1, 1, 2) = 1]);

> derivation(AS1, 2);
[D11 0]
[D21 D22]

> AS2 := array(sparse, 1 .. 2, 1 .. 2, 1 .. 2, [(1, 1, 1) = 1, (1, 2, 2) = 1]);
> derivation(AS2, 2);
[0 D12]
[D21 D22]

the maple should showing

> derivation(AS1, 2);
[D11 0]
[D21 2D11]

> AS2 := array(sparse, 1 .. 2, 1 .. 2, 1 .. 2, [(1, 1, 1) = 1, (1, 2, 2) = 1]);
> derivation(AS2, 2);
[0 0]
[D21 D22]

## Changing matrix...

I have a column matrix with all the elements 1.

A:=Matrix(100, 1, 1):

I want to generate another matrix B exactly same as A but with one element changed and keeping all other elements to be same. Manually, I could do by following way:

A[1,1]:=1.1;
A;
B:=A;

But I have to do this with each of 100 elements of A. For instance, in step 1 I want only the first element changed into 1.1. In step 2 I want only the second element changed keeping all others to be 1, and go upto 100.

Could anyone give me an easy way to do this? I would like to appreciate your help in advance.

## Kernel connection has been lost...

Hello,

I receive this message when trying to export matrix to excel file:

> restart; with(ExcelTools); with(LinearAlgebra);

> C := Import("C:/SourceFile.xlsx", "Overview", "AK51:CB94");

> C := convert(C, Matrix);

> B := Import("C:/SourceFile.xlsx", "Overview", "G3:G46");

> B := convert(B, Matrix);

> IM := IdentityMatrix(44, 44);

> NP := 1/(C-IM).(-B);

> NP[6, 1];  //check if there is value. Yes, it works.

> Export(NP, "C:/ResultFile.xlsx", "Sheet1", "A1");

Thank you for any help.

## Problem with Runge - Kutta method...

I am trying to solve the folowing ODE with initial conditions t0=0,v0=0 and tf =80 with step 0.01 but the matrix that appears is not having the values!please help

 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >
 >

Dear All

I want to use subs command to replace products in expression with entries from matrix. When I use "subs" command it returns same result as original without any substitution. But when I use "algsubs", it works fine, but is complicated to apply if there are large number of substitutions.

 >
 (1)
 >
 (2)
 >
 (3)
 >
 (4)

Why this command subs in not replacing  products   from matrix (1)?????

 >
 (5)

It worked !!!! But If I try "algsubs" like :

 >

See it is giving error !!! but still I can use "algsubs" as follow:

 >
 (6)

But this procedure is complex, I want to use "subs" only. I know it complexity of terms in (3) might me creating problem.

 >
 (7)
 >

Regards

## Sparse Matrix Products in Maple

by: Maple

I thought I would share some code for computing sparse matrix products in Maple.  For floating point matrices this is done quickly, but for algebraic datatypes there is a performance problem with the builtin routines, as noted in http://www.mapleprimes.com/questions/205739-How-Do-I-Improve-The-Performance-Of

The code is fairly straightforward in that it uses op(1,A) to extract the dimensions and op(2,A) to extract the non-zero elements of a Matrix or Vector, and then loops over those elements.  I included a sparse map function for cases where you want to map a function (like expand) over non-zero elements only.

`# sparse matrix vector productspmv := proc(A::Matrix,V::Vector)local m,n,Ae,Ve,Vi,R,e;  n, m := op(1,A);  if op(1,V) <> m then error "incompatible dimensions"; end if;  Ae := op(2,A);  Ve := op(2,V);  Vi := map2(op,1,Ve);  R := Vector(n, storage=sparse);  for e in Ae do    n, m := op(1,e);    if member(m, Vi) then R[n] := R[n] + A[n,m]*V[m]; end if;  end do;  return R;end proc:`
`# sparse matrix productspmm := proc(A::Matrix, B::Matrix)local m,n,Ae,Be,Bi,R,l,e,i;  n, m := op(1,A);  i, l := op(1,B);  if i <> m then error "incompatible dimensions"; end if;  Ae := op(2,A);  Be := op(2,B);  R := Matrix(n,l,storage=sparse);  for i from 1 to l do    Bi, Be := selectremove(type, Be, (anything,i)=anything);    Bi := map2(op,[1,1],Bi);    for e in Ae do      n, m := op(1,e);      if member(m, Bi) then R[n,i] := R[n,i] + A[n,m]*B[m,i]; end if;    end do;  end do;  return R;end proc:`
`# sparse mapsmap := proc(f, A::{Matrix,Vector})local B, Ae, e;  if A::Vector then    B := Vector(op(1,A),storage=sparse):  else    B := Matrix(op(1,A),storage=sparse):  end if;  Ae := op(2,A);  for e in Ae do    B[op(1,e)] := f(op(2,e),args[3..nargs]);  end do;  return B;end proc:`

As for how it performs, here is a demo inspired by the original post.

`n := 674;k := 6;`
`A := Matrix(n,n,storage=sparse):for i to n do  for j to k do    A[i,irem(rand(),n)+1] := randpoly(x):  end do:end do:`
`V := Vector(n):for i to k do  V[irem(rand(),n)+1] := randpoly(x):end do:`
`C := CodeTools:-Usage( spmv(A,V) ):  # 7ms, 25x fasterCodeTools:-Usage( A.V ):  # 174 ms`
`B := Matrix(n,n,storage=sparse):for i to n do  for j to k do    B[i,irem(rand(),n)+1] := randpoly(x):  end do:end do:`
`C := CodeTools:-Usage( spmm(A,B) ):  # 2.74 sec, 50x fasterCodeTools:-Usage( A.B ):  # 2.44 min`
`# expand and collect like termsC := CodeTools:-Usage( smap(expand, C) ):`

## Determinant of coefficient matrix...

I want to set the determinant of the coefficient matrix equal to zero and then solving for the roots. But I could not achieve it via Maple. Can you help me please?

You can reach two examples in the following file.  Yeni_Microsoft_Word_Belgesi_(2).docx

Besides. how can i compute the following transcental equations via maple

sinh(beta*L)*sin(beta*L)=0

cosh(beta*L)*cos(beta*L)-1=0

cosh(beta*L)*cos(beta*L)+1=0

regards

mehmet

## Convert ODE system to matrix form...

Sorry for disturbing you. I am wondering if there is an easier approach in Maple that could convert a system of second order differential equations into matrix form. Of course, we could do it by hand easily if the degrees of freedom is small. I would like to know if we could use Maple to do so.

Here is an example with 6 degrees of freedom: the variables are u, v, w, alpha, beta and gamma. And, this is a uncoupled system.

Vector(6, {(1) = 2*R^2*(diff(w(t), t))*Pi*Omega*h*rho+R^2*(diff(u(t), t, t))*Pi*h*rho-R^2*u(t)*Pi*Omega^2*h*rho = 0, (2) = R^2*(diff(v(t), t, t))*Pi*h*rho = 0, (3) = -2*R^2*(diff(u(t), t))*Pi*Omega*h*rho+R^2*(diff(w(t), t, t))*Pi*h*rho-R^2*w(t)*Pi*Omega^2*h*rho = 0, (4) = (1/4)*R^4*Pi*(diff(alpha(t), t, t))*h*rho+(1/12)*R^2*Pi*(diff(alpha(t), t, t))*h^3*rho+(1/6)*R^2*Pi*(diff(gamma(t), t))*Omega*h^3*rho-(1/12)*R^2*Pi*alpha(t)*Omega^2*h^3*rho = 0, (5) = (1/2)*R^4*Pi*(diff(beta(t), t, t))*h*rho-(1/2)*R^4*Pi*beta(t)*Omega^2*h*rho = 0, (6) = (1/4)*R^4*Pi*(diff(gamma(t), t, t))*h*rho+(1/12)*R^2*Pi*(diff(gamma(t), t, t))*h^3*rho-(1/6)*R^2*Pi*(diff(alpha(t), t))*Omega*h^3*rho-(1/12)*R^2*Pi*gamma(t)*Omega^2*h^3*rho = 0});

The objective is to reform it into matrix form : M*diff(X(t), t, t)+C*diff(X(t), t)+K*X(t)=F.

Thank you in advance for taking a look.

## Wrong type inside a loop...

Eight matrices inside the list J:

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

Function member identifies J[2] as a member of J and returns its position in j:

member(J[2], J, 'j'); j;

Matrix multiplication inside a loop does not have a matrix type:

for i to 1 do for j to 2 do a := J[i].J[j]; member(a, J, 'k'); print(i, j, k, a, whattype(a)) end do end do;

Has anyone any ideia of what is going on?

 5 6 7 8 9 10 11 Last Page 7 of 42
﻿