Items tagged with matrix

Feed

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

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?

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.

 

``

restart

``

``

(1)

``

interface(displayprecision = 4)

-1

(2)

(3)

NULL

``

Vert_Coef := Matrix(10, 5, {(1, 1) = 0.332e-1, (1, 2) = 0.187e-1, (1, 3) = 0.104e-1, (1, 4) = 0.52e-2, (1, 5) = 0.21e-2, (2, 1) = 0.509e-1, (2, 2) = 0.301e-1, (2, 3) = 0.166e-1, (2, 4) = 0.83e-2, (2, 5) = 0.31e-2, (3, 1) = 0.571e-1, (3, 2) = 0.364e-1, (3, 3) = 0.218e-1, (3, 4) = 0.104e-1, (3, 5) = 0.42e-2, (4, 1) = 0.582e-1, (4, 2) = 0.405e-1, (4, 3) = 0.260e-1, (4, 4) = 0.125e-1, (4, 5) = 0.42e-2, (5, 1) = 0.582e-1, (5, 2) = 0.416e-1, (5, 3) = 0.270e-1, (5, 4) = 0.135e-1, (5, 5) = 0.52e-2, (6, 1) = 0.582e-1, (6, 2) = 0.416e-1, (6, 3) = 0.281e-1, (6, 4) = 0.145e-1, (6, 5) = 0.52e-2, (7, 1) = 0.582e-1, (7, 2) = 0.416e-1, (7, 3) = 0.291e-1, (7, 4) = 0.166e-1, (7, 5) = 0.62e-2, (8, 1) = 0.582e-1, (8, 2) = 0.416e-1, (8, 3) = 0.301e-1, (8, 4) = 0.177e-1, (8, 5) = 0.62e-2, (9, 1) = 0.582e-1, (9, 2) = 0.416e-1, (9, 3) = 0.301e-1, (9, 4) = 0.187e-1, (9, 5) = 0.73e-2, (10, 1) = 0.582e-1, (10, 2) = 0.416e-1, (10, 3) = 0.301e-1, (10, 4) = 0.197e-1, (10, 5) = 0.83e-2})

Matrix(10, 5, {(1, 1) = 0.332e-1, (1, 2) = 0.187e-1, (1, 3) = 0.104e-1, (1, 4) = 0.52e-2, (1, 5) = 0.21e-2, (2, 1) = 0.509e-1, (2, 2) = 0.301e-1, (2, 3) = 0.166e-1, (2, 4) = 0.83e-2, (2, 5) = 0.31e-2, (3, 1) = 0.571e-1, (3, 2) = 0.364e-1, (3, 3) = 0.218e-1, (3, 4) = 0.104e-1, (3, 5) = 0.42e-2, (4, 1) = 0.582e-1, (4, 2) = 0.405e-1, (4, 3) = 0.260e-1, (4, 4) = 0.125e-1, (4, 5) = 0.42e-2, (5, 1) = 0.582e-1, (5, 2) = 0.416e-1, (5, 3) = 0.270e-1, (5, 4) = 0.135e-1, (5, 5) = 0.52e-2, (6, 1) = 0.582e-1, (6, 2) = 0.416e-1, (6, 3) = 0.281e-1, (6, 4) = 0.145e-1, (6, 5) = 0.52e-2, (7, 1) = 0.582e-1, (7, 2) = 0.416e-1, (7, 3) = 0.291e-1, (7, 4) = 0.166e-1, (7, 5) = 0.62e-2, (8, 1) = 0.582e-1, (8, 2) = 0.416e-1, (8, 3) = 0.301e-1, (8, 4) = 0.177e-1, (8, 5) = 0.62e-2, (9, 1) = 0.582e-1, (9, 2) = 0.416e-1, (9, 3) = 0.301e-1, (9, 4) = 0.187e-1, (9, 5) = 0.73e-2, (10, 1) = 0.582e-1, (10, 2) = 0.416e-1, (10, 3) = 0.301e-1, (10, 4) = 0.197e-1, (10, 5) = 0.83e-2})

(4)

``

``

whattype(Vert_Coef)

Matrix

(5)

``

NULL

``

``

``

``

SR := Vector([10.8696, 21.7391, 32.6087, 43.4783, 46.7391, 54.3478, 65.2174, 76.0870, 86.9565, 100.0000], datatype = float)

Vector(10, {(1) = 10.8696, (2) = 21.7391, (3) = 32.6087, (4) = 43.4783, (5) = 46.7391, (6) = 54.3478, (7) = 65.2174, (8) = 76.0870, (9) = 86.9565, (10) = 100.0000})

(6)

E_G := Vector([250, 500, 1000, 2500, 10000], datatype = float)

Vector(5, {(1) = 250.0000, (2) = 500.0000, (3) = 1000.0000, (4) = 2500.0000, (5) = 10000.0000})

(7)

``

``NULL

NULL

``

NULL

``

B_interp := proc (SR, E_G) options operator, arrow; CurveFitting:-ArrayInterpolation([SR, E_G], Vert_Coef, Array(1 .. 1, 1 .. 1, 1 .. 2, [[[SR, E_G]]]), method = linear) end proc

proc (SR, E_G) options operator, arrow; CurveFitting:-ArrayInterpolation([SR, E_G], Vert_Coef, Array(1 .. 1, 1 .. 1, 1 .. 2, [[[SR, E_G]]]), method = linear) end proc

(8)

``

``

f[18*_1] := B_interp(25.0, 1500.0)

Error, (in CurveFitting:-ArrayInterpolation) invalid input: dimensions of independent data do not match the dimensions of dependent data

 

 

Download Matrix_Interpolation.mw

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

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

Dear All

Please see following query:

 

 

 For following Algeraic expression

 

(3*a[1]+5*a[2])*U[1]+(-6*a[1]+2*a[2])*U[2]

 

How one can construct a matrix of the following form:

 

Matrix([[3, 5], [-6, 2]])

Matrix(2, 2, {(1, 1) = 3, (1, 2) = 5, (2, 1) = -6, (2, 2) = 2})

(1)

 

Where first row corresponds to U[1]and second row corresponds to U[2] and the entries of matrix are coefficients of a[1]and a[2]

 

 

Download Constructing_matrix_from_algebraic_expression.mw

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]

please help., thank you

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.

 

 

Hello,

I would like to ask you for your help

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.

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

f := proc (t, V) options operator, arrow; -9.81+0.563e-3*(0.1832e-2*abs(V)+0.51702e-1*(abs(V)^(3/2))+.4*V^2) end proc

V0 := 0:

t0 := 0:

tf := 80:

n := 1000

h := evalf((tf-t0)/n):

t := t0:

V := V0:

``

rk := proc (x0, tf, V0, n) local t, V, h, i, k1, k2, k3, k4, k, R; t := t0; V := V0; R := t, V; h := evalf((tf-t0)/n); for i to n do k1 := f(t, V); k2 := f(t+(1/2)*h, V+(1/2)*h*k1); k3 := f(t+(1/2)*h, V+(1/2)*h*k2); k4 := f(t+h, V+h*k3); k := (1/6)*k1+(1/3)*k2+(1/3)*k3+(1/6)*k4; V := V+h*k; t := t+h; R := R, t, V end do end proc:

R := rk(0, 80, 0, 300):

0, 0

 

.2666666667, -2.615998110

 

.5333333334, -5.231986045

 

.8000000001, -7.847954569

 

1.066666667, -10.46389463

 

1.333333334, -13.07979725

 

1.600000001, -15.69565351

 

1.866666668, -18.31145452

 

2.133333335, -20.92719143

 

2.400000002, -23.54285541

 

2.666666669, -26.15843764

 

2.933333336, -28.77392932

 

3.200000003, -31.38932166

 

3.466666670, -34.00460588

 

3.733333337, -36.61977321

 

4.000000004, -39.23481490

 

4.266666671, -41.84972219

 

4.533333338, -44.46448634

 

4.800000005, -47.07909861

 

5.066666672, -49.69355027

 

5.333333339, -52.30783259

 

5.600000006, -54.92193685

 

5.866666673, -57.53585433

 

6.133333340, -60.14957632

 

6.400000007, -62.76309410

 

6.666666674, -65.37639897

 

6.933333341, -67.98948223

 

7.200000008, -70.60233518

 

7.466666675, -73.21494912

 

7.733333342, -75.82731536

 

8.000000009, -78.43942520

 

8.266666676, -81.05126996

 

8.533333343, -83.66284095

 

8.800000010, -86.27412949

 

9.066666677, -88.88512689

 

9.333333344, -91.49582448

 

9.600000011, -94.10621358

 

9.866666678, -96.71628551

 

10.13333334, -99.32603160

 

10.40000001, -101.9354432

 

10.66666668, -104.5445116

 

10.93333335, -107.1532281

 

11.20000002, -109.7615841

 

11.46666669, -112.3695709

 

11.73333336, -114.9771799

 

12.00000003, -117.5844024

 

12.26666670, -120.1912297

 

12.53333337, -122.7976532

 

12.80000004, -125.4036642

 

13.06666671, -128.0092541

 

13.33333338, -130.6144142

 

13.60000005, -133.2191358

 

13.86666672, -135.8234103

 

14.13333339, -138.4272290

 

14.40000006, -141.0305833

 

14.66666673, -143.6334645

 

14.93333340, -146.2358640

 

15.20000007, -148.8377732

 

15.46666674, -151.4391834

 

15.73333341, -154.0400859

 

16.26666675, -159.2403334

 

16.53333342, -161.8396611

 

16.80000009, -164.4384465

 

17.06666676, -167.0366810

 

17.33333343, -169.6343560

 

17.60000010, -172.2314629

 

17.86666677, -174.8279930

 

18.13333344, -177.4239376

 

18.40000011, -180.0192882

 

18.66666678, -182.6140360

 

18.93333345, -185.2081725

 

19.20000012, -187.8016890

 

19.46666679, -190.3945769

 

19.73333346, -192.9868275

 

20.00000013, -195.5784322

 

20.26666680, -198.1693824

 

20.53333347, -200.7596694

 

20.80000014, -203.3492846

 

21.06666681, -205.9382194

 

21.33333348, -208.5264652

 

21.60000015, -211.1140133

 

21.86666682, -213.7008550

 

22.13333349, -216.2869818

 

22.40000016, -218.8723850

 

22.66666683, -221.4570560

 

22.93333350, -224.0409862

 

23.20000017, -226.6241669

 

23.46666684, -229.2065895

 

23.73333351, -231.7882454

 

24.00000018, -234.3691260

 

24.26666685, -236.9492226

 

24.53333352, -239.5285266

 

24.80000019, -242.1070294

 

25.06666686, -244.6847224

 

25.33333353, -247.2615969

 

25.60000020, -249.8376443

 

25.86666687, -252.4128560

 

26.13333354, -254.9872234

 

26.40000021, -257.5607378

 

26.66666688, -260.1333906

 

26.93333355, -262.7051732

 

27.20000022, -265.2760770

 

27.46666689, -267.8460934

 

27.73333356, -270.4152137

 

28.00000023, -272.9834293

 

28.26666690, -275.5507316

 

28.53333357, -278.1171120

 

28.80000024, -280.6825619

 

29.06666691, -283.2470726

 

29.33333358, -285.8106356

 

29.60000025, -288.3732422

 

29.86666692, -290.9348838

 

30.13333359, -293.4955517

 

30.40000026, -296.0552374

 

30.66666693, -298.6139322

 

30.93333360, -301.1716276

 

31.20000027, -303.7283149

 

31.46666694, -306.2839855

 

31.73333361, -308.8386307

 

32.00000028, -311.3922420

 

32.26666695, -313.9448108

 

32.53333362, -316.4963284

 

32.80000029, -319.0467862

 

33.06666696, -321.5961756

 

33.33333363, -324.1444880

 

33.60000030, -326.6917148

 

33.86666697, -329.2378474

 

34.13333364, -331.7828772

 

34.40000031, -334.3267955

 

34.66666698, -336.8695937

 

34.93333365, -339.4112633

 

35.20000032, -341.9517956

 

35.46666699, -344.4911820

 

35.73333366, -347.0294139

 

36.00000033, -349.5664827

 

36.26666700, -352.1023797

 

36.53333367, -354.6370964

 

36.80000034, -357.1706242

 

37.06666701, -359.7029544

 

37.33333368, -362.2340784

 

37.60000035, -364.7639877

 

37.86666702, -367.2926736

 

38.13333369, -369.8201275

 

38.40000036, -372.3463408

 

38.66666703, -374.8713049

 

38.93333370, -377.3950112

 

39.20000037, -379.9174511

 

39.46666704, -382.4386159

 

39.73333371, -384.9584971

 

40.00000038, -387.4770861

 

40.26666705, -389.9943742

 

40.53333372, -392.5103529

 

40.80000039, -395.0250135

 

41.06666706, -397.5383474

 

41.33333373, -400.0503461

 

41.60000040, -402.5610009

 

41.86666707, -405.0703032

 

42.13333374, -407.5782444

 

42.40000041, -410.0848159

 

42.66666708, -412.5900091

 

42.93333375, -415.0938154

 

43.20000042, -417.5962262

 

43.46666709, -420.0972329

 

43.73333376, -422.5968269

 

44.00000043, -425.0949996

 

44.26666710, -427.5917424

 

44.53333377, -430.0870466

 

44.80000044, -432.5809037

 

45.06666711, -435.0733051

 

45.33333378, -437.5642421

 

45.60000045, -440.0537062

 

45.86666712, -442.5416888

 

46.13333379, -445.0281812

 

46.40000046, -447.5131749

 

46.66666713, -449.9966612

 

46.93333380, -452.4786316

 

47.20000047, -454.9590775

 

47.46666714, -457.4379902

 

47.73333381, -459.9153612

 

48.00000048, -462.3911818

 

48.26666715, -464.8654435

 

48.53333382, -467.3381376

 

48.80000049, -469.8092556

 

49.06666716, -472.2787888

 

49.33333383, -474.7467287

 

49.60000050, -477.2130666

 

49.86666717, -479.6777940

 

50.13333384, -482.1409022

 

50.40000051, -484.6023827

 

50.66666718, -487.0622268

 

50.93333385, -489.5204260

 

51.20000052, -491.9769716

 

51.46666719, -494.4318551

 

51.73333386, -496.8850678

 

52.00000053, -499.3366012

 

52.26666720, -501.7864466

 

52.53333387, -504.2345955

 

52.80000054, -506.6810393

 

53.06666721, -509.1257693

 

53.33333388, -511.5687770

 

53.60000055, -514.0100537

 

53.86666722, -516.4495909

 

54.13333389, -518.8873800

 

54.40000056, -521.3234124

 

54.66666723, -523.7576794

 

54.93333390, -526.1901725

 

55.20000057, -528.6208831

 

55.46666724, -531.0498026

 

55.73333391, -533.4769224

 

56.00000058, -535.9022339

 

56.26666725, -538.3257285

 

56.53333392, -540.7473976

 

56.80000059, -543.1672326

 

57.06666726, -545.5852249

 

57.33333393, -548.0013659

 

57.60000060, -550.4156470

 

57.86666727, -552.8280597

 

58.13333394, -555.2385953

 

58.40000061, -557.6472452

 

58.66666728, -560.0540009

 

58.93333395, -562.4588537

 

59.20000062, -564.8617951

 

59.46666729, -567.2628164

 

59.73333396, -569.6619091

 

60.00000063, -572.0590645

 

60.26666730, -574.4542741

 

60.53333397, -576.8475293

 

60.80000064, -579.2388215

 

61.06666731, -581.6281420

 

61.33333398, -584.0154823

 

61.60000065, -586.4008338

 

61.86666732, -588.7841879

 

62.13333399, -591.1655361

 

62.40000066, -593.5448697

 

62.66666733, -595.9221801

 

62.93333400, -598.2974587

 

63.20000067, -600.6706970

 

63.46666734, -603.0418863

 

63.73333401, -605.4110181

 

64.00000068, -607.7780837

 

64.26666735, -610.1430746

 

64.53333402, -612.5059822

 

64.80000069, -614.8667979

 

65.06666736, -617.2255130

 

65.33333403, -619.5821190

 

65.60000070, -621.9366073

 

65.86666737, -624.2889694

 

66.13333404, -626.6391966

 

66.40000071, -628.9872803

 

66.66666738, -631.3332119

 

66.93333405, -633.6769829

 

67.20000072, -636.0185846

 

67.46666739, -638.3580085

 

67.73333406, -640.6952460

 

68.00000073, -643.0302885

 

68.26666740, -645.3631274

 

68.53333407, -647.6937540

 

68.80000074, -650.0221599

 

69.06666741, -652.3483364

 

69.33333408, -654.6722749

 

69.60000075, -656.9939668

 

69.86666742, -659.3134036

 

70.13333409, -661.6305766

 

70.40000076, -663.9454773

 

70.66666743, -666.2580971

 

70.93333410, -668.5684273

 

71.20000077, -670.8764594

 

71.46666744, -673.1821848

 

71.73333411, -675.4855950

 

72.00000078, -677.7866813

 

72.26666745, -680.0854351

 

72.53333412, -682.3818479

 

72.80000079, -684.6759110

 

73.06666746, -686.9676159

 

73.33333413, -689.2569539

 

73.60000080, -691.5439165

 

73.86666747, -693.8284951

 

74.13333414, -696.1106811

 

74.40000081, -698.3904660

 

74.66666748, -700.6678411

 

74.93333415, -702.9427978

 

75.20000082, -705.2153276

 

75.46666749, -707.4854218

 

75.73333416, -709.7530719

 

76.00000083, -712.0182693

 

76.26666750, -714.2810054

 

76.53333417, -716.5412716

 

76.80000084, -718.7990593

 

77.06666751, -721.0543600

 

77.33333418, -723.3071650

 

77.60000085, -725.5574658

 

77.86666752, -727.8052537

 

78.13333419, -730.0505202

 

78.40000086, -732.2932567

 

78.66666753, -734.5334546

 

78.93333420, -736.7711053

 

79.73333421, -743.4686884

 

``

 

 

Download runge_kutta4.mw

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.

Please see followings:

 

M := Matrix([[U[1], U[2], -epsilon*U[1]+U[3], U[4], U[5], U[6]], [U[1], U[2], -epsilon*U[2]+U[3], epsilon*U[1]+U[4], epsilon*U[2]+U[5], U[6]], [e^epsilon*U[1], e^epsilon*U[2], U[3], U[4], U[5], U[6]], [U[1], -epsilon*U[1]+U[2], U[3], U[4], -epsilon*U[4]+U[5], U[6]-epsilon*(U[3]+2*U[5])+epsilon^2*U[4], U[1], e^(-epsilon)*U[2], U[3], e^epsilon*U[4], U[5], e^(-epsilon)*U[6]], [U[1], e^(-epsilon)*U[2], U[3], e^epsilon*U[4], U[5], e^(-epsilon)*U[6]], [epsilon*U[2]+U[1], U[2], U[3], U[4]+epsilon*(U[3]+2*U[5])+epsilon^2*U[6], epsilon*U[6]+U[5], U[6]]])

M := Vector(4, {(1) = ` 6 x 12 `*Matrix, (2) = `Data Type: `*anything, (3) = `Storage: `*rectangular, (4) = `Order: `*Fortran_order})

(1)

M[5, 1]; 1; M[5, 3]

U[1]

 

U[3]

(2)

expand((w*T[5]+z*T[4]+T[6])*(U[1]*a[1]+U[2]*a[2]+U[3]*a[3]+U[4]*a[4]+U[5]*a[5]+U[6]*a[6]))

w*T[5]*U[1]*a[1]+w*T[5]*U[2]*a[2]+w*T[5]*U[3]*a[3]+w*T[5]*U[4]*a[4]+w*T[5]*U[5]*a[5]+w*T[5]*U[6]*a[6]+z*T[4]*U[1]*a[1]+z*T[4]*U[2]*a[2]+z*T[4]*U[3]*a[3]+z*T[4]*U[4]*a[4]+z*T[4]*U[5]*a[5]+z*T[4]*U[6]*a[6]+T[6]*U[1]*a[1]+T[6]*U[2]*a[2]+T[6]*U[3]*a[3]+T[6]*U[4]*a[4]+T[6]*U[5]*a[5]+T[6]*U[6]*a[6]

(3)

subs(T[5]*U[1] = M[5, 1], T[5]*U[2] = M[5, 2], T[5]*U[3] = M[5, 3], w*T[5]*U[1]*a[1]+w*T[5]*U[2]*a[2]+w*T[5]*U[3]*a[3]+w*T[5]*U[4]*a[4]+w*T[5]*U[5]*a[5]+w*T[5]*U[6]*a[6]+z*T[4]*U[1]*a[1]+z*T[4]*U[2]*a[2]+z*T[4]*U[3]*a[3]+z*T[4]*U[4]*a[4]+z*T[4]*U[5]*a[5]+z*T[4]*U[6]*a[6]+T[6]*U[1]*a[1]+T[6]*U[2]*a[2]+T[6]*U[3]*a[3]+T[6]*U[4]*a[4]+T[6]*U[5]*a[5]+T[6]*U[6]*a[6])

w*T[5]*U[1]*a[1]+w*T[5]*U[2]*a[2]+w*T[5]*U[3]*a[3]+w*T[5]*U[4]*a[4]+w*T[5]*U[5]*a[5]+w*T[5]*U[6]*a[6]+z*T[4]*U[1]*a[1]+z*T[4]*U[2]*a[2]+z*T[4]*U[3]*a[3]+z*T[4]*U[4]*a[4]+z*T[4]*U[5]*a[5]+z*T[4]*U[6]*a[6]+T[6]*U[1]*a[1]+T[6]*U[2]*a[2]+T[6]*U[3]*a[3]+T[6]*U[4]*a[4]+T[6]*U[5]*a[5]+T[6]*U[6]*a[6]

(4)

Why this command subs in not replacing  products  T[5]*U[1], T[5]*U[2], T[5]*U[3] from matrix (1)NULL?????

algsubs(T[5]*U[1] = M[5, 1], w*T[5]*U[1]*a[1]+w*T[5]*U[2]*a[2]+w*T[5]*U[3]*a[3]+w*T[5]*U[4]*a[4]+w*T[5]*U[5]*a[5]+w*T[5]*U[6]*a[6]+z*T[4]*U[1]*a[1]+z*T[4]*U[2]*a[2]+z*T[4]*U[3]*a[3]+z*T[4]*U[4]*a[4]+z*T[4]*U[5]*a[5]+z*T[4]*U[6]*a[6]+T[6]*U[1]*a[1]+T[6]*U[2]*a[2]+T[6]*U[3]*a[3]+T[6]*U[4]*a[4]+T[6]*U[5]*a[5]+T[6]*U[6]*a[6])

z*T[4]*U[2]*a[2]+z*T[4]*U[3]*a[3]+z*T[4]*U[4]*a[4]+z*T[4]*U[5]*a[5]+z*T[4]*U[6]*a[6]+T[6]*U[2]*a[2]+T[6]*U[3]*a[3]+T[6]*U[4]*a[4]+T[6]*U[5]*a[5]+T[6]*U[6]*a[6]+(w*U[2]*a[2]+w*U[3]*a[3]+w*U[4]*a[4]+w*U[5]*a[5]+w*U[6]*a[6])*T[5]+(z*T[4]*a[1]+w*a[1]+T[6]*a[1])*U[1]

(5)

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

algsubs(T[5]*U[1] = M[5, 1], T[5]*U[2] = M[5, 2], T[5]*U[3] = M[5, 3], w*T[5]*U[1]*a[1]+w*T[5]*U[2]*a[2]+w*T[5]*U[3]*a[3]+w*T[5]*U[4]*a[4]+w*T[5]*U[5]*a[5]+w*T[5]*U[6]*a[6]+z*T[4]*U[1]*a[1]+z*T[4]*U[2]*a[2]+z*T[4]*U[3]*a[3]+z*T[4]*U[4]*a[4]+z*T[4]*U[5]*a[5]+z*T[4]*U[6]*a[6]+T[6]*U[1]*a[1]+T[6]*U[2]*a[2]+T[6]*U[3]*a[3]+T[6]*U[4]*a[4]+T[6]*U[5]*a[5]+T[6]*U[6]*a[6])

Error, invalid input: algsubs expects its 3rd argument, x, to be of type {name, function, list({name, function}), set({name, function})}, but received T[5]*U[3] = U[3]

 

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

 

expand(algsubs(T[6]*U[6] = M[6, 6], expand(algsubs(T[6]*U[5] = M[6, 5], expand(algsubs(T[6]*U[4] = M[6, 4], expand(algsubs(T[6]*U[3] = M[6, 3], expand(algsubs(T[6]*U[2] = M[6, 2], expand(algsubs(T[6]*U[1] = M[6, 1], expand(algsubs(T[5]*U[6] = M[5, 6], expand(algsubs(T[5]*U[5] = M[5, 5], expand(algsubs(T[5]*U[4] = M[5, 4], expand(algsubs(T[5]*U[3] = M[5, 3], expand(algsubs(T[5]*U[2] = M[5, 2], expand(algsubs(T[5]*U[1] = M[5, 1], expand(algsubs(T[4]*U[6] = M[4, 6], expand(algsubs(T[4]*U[5] = M[4, 5], expand(algsubs(T[4]*U[4] = M[4, 4], expand(algsubs(T[4]*U[3] = M[4, 3], expand(algsubs(T[4]*U[2] = M[4, 2], expand(algsubs(T[4]*U[1] = M[4, 1], expand(algsubs(T[3]*U[6] = M[3, 6], expand(algsubs(T[3]*U[5] = M[3, 5], expand(algsubs(T[3]*U[4] = M[3, 4], expand(algsubs(T[3]*U[3] = M[3, 3], expand(algsubs(T[3]*U[2] = M[3, 2], expand(algsubs(T[3]*U[1] = M[3, 1], expand(algsubs(T[2]*U[6] = M[2, 6], expand(algsubs(T[2]*U[5] = M[2, 5], expand(algsubs(T[2]*U[4] = M[2, 4], expand(algsubs(T[2]*U[3] = M[2, 3], expand(algsubs(T[2]*U[3] = M[2, 3], expand(algsubs(T[2]*U[2] = M[2, 2], expand(algsubs(T[2]*U[1] = M[2, 1], expand(algsubs(T[1]*U[6] = M[1, 6], expand(algsubs(T[1]*U[5] = M[1, 5], expand(algsubs(T[1]*U[4] = M[1, 4], expand(algsubs(T[1]*U[3] = M[1, 3], expand(algsubs(T[1]*U[2] = M[1, 2], expand(algsubs(T[1]*U[1] = M[1, 1], w*T[5]*U[1]*a[1]+w*T[5]*U[2]*a[2]+w*T[5]*U[3]*a[3]+w*T[5]*U[4]*a[4]+w*T[5]*U[5]*a[5]+w*T[5]*U[6]*a[6]+z*T[4]*U[1]*a[1]+z*T[4]*U[2]*a[2]+z*T[4]*U[3]*a[3]+z*T[4]*U[4]*a[4]+z*T[4]*U[5]*a[5]+z*T[4]*U[6]*a[6]+T[6]*U[1]*a[1]+T[6]*U[2]*a[2]+T[6]*U[3]*a[3]+T[6]*U[4]*a[4]+T[6]*U[5]*a[5]+T[6]*U[6]*a[6]))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

a[5]*epsilon*U[6]+a[1]*epsilon*U[2]+U[6]*a[6]+U[2]*a[2]+U[3]*a[3]+U[4]*a[4]+U[5]*a[5]+z*a[1]*U[1]+epsilon^2*U[6]*a[4]+epsilon*U[3]*a[4]+2*epsilon*U[5]*a[4]+U[6]*w*a[6]/e^epsilon+U[4]*e^epsilon*w*a[4]+w*a[1]*U[1]+U[2]*w*a[2]/e^epsilon+epsilon^2*z*U[4]*a[6]-epsilon*z*U[3]*a[6]-2*epsilon*z*U[5]*a[6]+w*U[3]*a[3]+w*U[5]*a[5]-z*a[5]*epsilon*U[4]-z*a[2]*epsilon*U[1]+z*U[2]*a[2]+z*U[3]*a[3]+z*U[4]*a[4]+z*U[5]*a[5]+z*U[6]*a[6]+a[1]*U[1]

(6)

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

collect(a[5]*epsilon*U[6]+a[1]*epsilon*U[2]+U[6]*a[6]+U[2]*a[2]+U[3]*a[3]+U[4]*a[4]+U[5]*a[5]+z*a[1]*U[1]+epsilon^2*U[6]*a[4]+epsilon*U[3]*a[4]+2*epsilon*U[5]*a[4]+U[6]*w*a[6]/e^epsilon+U[4]*e^epsilon*w*a[4]+w*a[1]*U[1]+U[2]*w*a[2]/e^epsilon+epsilon^2*z*U[4]*a[6]-epsilon*z*U[3]*a[6]-2*epsilon*z*U[5]*a[6]+w*U[3]*a[3]+w*U[5]*a[5]-z*a[5]*epsilon*U[4]-z*a[2]*epsilon*U[1]+z*U[2]*a[2]+z*U[3]*a[3]+z*U[4]*a[4]+z*U[5]*a[5]+z*U[6]*a[6]+a[1]*U[1], [U[1], U[2], U[3], U[4], U[5], U[6]])

(-epsilon*z*a[2]+w*a[1]+z*a[1]+a[1])*U[1]+(a[1]*epsilon+a[2]+w*a[2]/e^epsilon+z*a[2])*U[2]+(-epsilon*z*a[6]+epsilon*a[4]+w*a[3]+z*a[3]+a[3])*U[3]+(epsilon^2*z*a[6]+e^epsilon*w*a[4]-z*a[5]*epsilon+z*a[4]+a[4])*U[4]+(-2*epsilon*z*a[6]+2*epsilon*a[4]+w*a[5]+z*a[5]+a[5])*U[5]+(a[5]*epsilon+a[6]+epsilon^2*a[4]+w*a[6]/e^epsilon+z*a[6])*U[6]

(7)

``

 

Download Subs_not_giving_result.mwSubs_not_giving_result.mw

Regards

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

Download spm.txt

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 product
spmv := 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 product
spmm := 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 map
smap := 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 faster
CodeTools:-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 faster
CodeTools:-Usage( A.B ):  # 2.44 min
# expand and collect like terms
C := CodeTools:-Usage( smap(expand, C) ):

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

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. 

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