pik1432

245 Reputation

6 Badges

6 years, 123 days

MaplePrimes Activity


These are replies submitted by pik1432

It is appreciated!

Both answers are really appreciated!


 

restart:

n:= 2;

2

(1)

x:= Vector(n, symbol= X);

Vector(2, {(1) = X[1], (2) = X[2]})

(2)

 

 

W:=<<w11 | w12>, <w21 | w22>>

Matrix(2, 2, {(1, 1) = w11, (1, 2) = w12, (2, 1) = w21, (2, 2) = w22})

(1.1)

v:= (W.x)

Vector(2, {(1) = w11*X[1]+w12*X[2], (2) = w21*X[1]+w22*X[2]})

(3)

f:=(W.x)^%T.(W.x);

(w11*X[1]+w12*X[2])^2+(w21*X[1]+w22*X[2])^2

(4)

 

eq1:=<seq(diff(f,t),t=x)>;

Vector(2, {(1) = (2*w11*X[1]+2*w12*X[2])*w11+(2*w21*X[1]+2*w22*X[2])*w21, (2) = (2*w11*X[1]+2*w12*X[2])*w12+(2*w21*X[1]+2*w22*X[2])*w22})

(5)

eq2:=2*W^%T.v;

Vector(2, {(1) = (2*w11*X[1]+2*w12*X[2])*w11+(2*w21*X[1]+2*w22*X[2])*w21, (2) = (2*w11*X[1]+2*w12*X[2])*w12+(2*w21*X[1]+2*w22*X[2])*w22})

(6)

seq(is(eq1[i] = eq2[i]), i=1..numelems(eq1))

true, true

(7)

andmap(is@`=`, eq1 - eq2, 0);

true

(8)

 

is(eq1(1) = eq2(1));

true

(9)

eq1(1)

2*(w11*X[1]+w12*X[2])*w11+2*(w21*X[1]+w22*X[2])*w21

(10)

seq(is(eq1(i) = eq2(i)), i=1..numelems(eq1))

true, true

(11)

 


 

Download question2v3.mw

@Carl Love 

@Carl Love 
 

restart:

x:=Matrix([[x1],[x2]])

Vector(2, {(1) = x1, (2) = x2})

(1)

W:=<<w11 | w12>, <w21 | w22>>

Matrix(2, 2, {(1, 1) = w11, (1, 2) = w12, (2, 1) = w21, (2, 2) = w22})

(2)

v:= (W.x)

Vector(2, {(1) = w11*x1+w12*x2, (2) = w21*x1+w22*x2})

(3)

f:=(W.x)^%T.(W.x);

Vector(1, {(1) = (w11*x1+w12*x2)^2+(w21*x1+w22*x2)^2})

(4)

 

eq1:=<seq(diff(f,t),t=x)>;

Vector(2, {(1) = (2*w11*x1+2*w12*x2)*w11+(2*w21*x1+2*w22*x2)*w21, (2) = (2*w11*x1+2*w12*x2)*w12+(2*w21*x1+2*w22*x2)*w22})

(5)

eq2:=2*W^%T.v;

Vector(2, {(1) = (2*w11*x1+2*w12*x2)*w11+(2*w21*x1+2*w22*x2)*w21, (2) = (2*w11*x1+2*w12*x2)*w12+(2*w21*x1+2*w22*x2)*w22})

(6)

seq(is(eq1[i] = eq2[i]), i=1..numelems(eq1))

false, false

(7)

andmap(is@`=`, eq1 - eq2, 0);

true

(8)

 

 


 

Download question2.mw

 

@mehdi jafari 

Thank you for introducing me the 'is' command. 

Then, when I ran these commands, I got a different answer than I expected:

restart:

x:=Matrix([[x1],[x2]])

W:=<<w11 | w12>, <w21 | w22>>

v:= (W.x)

f:=(W.x)^%T.(W.x);

eq1:=<seq(diff(f,t),t=x)>;

eq2:=2*W^%T.v;

seq(is(eq1[i] = eq2[i]), i=1..numelems(eq1))

then the answer was false. If I look at 'eq1' and 'eq2', they are exactly the same, though. 

question2.mw

@Carl Love Thank you for your answers! Sorry I did not pay attention to your answer to my previous question. 

Then, would you tell me how to extract the individual matrix from the result of the last command, '

seq(diff~(v,W), v= V);

'

 

What I wanted to do was to check '#1' below is equal to '#2' below

With your answers, I was able to check and find that it is true. 

restart;
x:=<x1,x2>:
W:=<<w11, w12>|<w21, w22>>:
Cal:=(W.x)^%T.(W.x);
<seq(diff(Cal,t),t=x)>;  # 1

2*W^%T.W.x #2

 

 

@acer Thank you for the clear and crisp explanation. 

@Kitonum 

Thank you again! Your expertise on Maples got me through the difficulty. 

 

@Kitonum What is the reason for '-H' in this expression, instead of 'H'?

U, M:=GenerateMatrix(convert(-H,list), convert(V,list));

In the following recap of what you taught me, I can vaguely see the point, but I would appreciate if you can offer me clear guidance:

restart;
eq1:=(L1/n12 + n12*L2)*diff(i2(t), t) + L1*diff(i3(t), t)/n13 = -v1(t) - R1*i3(t)/n13 - R1*i2(t)/n12 + n12*v2(t) - n12*R2*i2(t);

eq2:=L1*diff(i2(t), t)/n12 + (L1/n13 + n13*L3)*diff(i3(t), t) = -v1(t) - R1*i3(t)/n13 - R1*i2(t)/n12 + n13*v3(t) - n13*R3*i3(t);
with(LinearAlgebra):

Sys:=[eq1, eq2];

X:=<i2(t),i3(t)>;

DX:=<diff(i2(t), t),diff(i3(t), t)>;

E, F:=GenerateMatrix(Sys, convert(DX,list));

G, H:=GenerateMatrix(convert(F,list), convert(X,list));

V:=<v1(t),v2(t),v3(t)>;

U, M:=GenerateMatrix(convert(H,list), convert(V,list)); # with no '-'

U, M := Matrix(2, 3, [[1, -n12, 0], [1, 0, -n13]]), Vector[column](2, [0, 0])

U, M:=GenerateMatrix(convert(-H,list), convert(V,list));# with no '-'
U, M := Matrix(2, 3, [[-1, n12, 0], [-1, 0, n13]]), Vector[column](2, [0, 0])

@Carl Love: It worked!

All the answers are truly appreciated!

Your answers solved my problem!

@acer: Thank you for the perfect answer! 

First 6 7 8 Page 8 of 8