Harry Garst

219 Reputation

5 Badges

17 years, 22 days

MaplePrimes Activity


These are questions asked by Harry Garst

I made an error by trying to multiply two nonconformable matrices. I think, I should receive an error message. But in this example this did not occur.

Strange.mw

restart; with(LinearAlgebra); alias(`⨂` = LinearAlgebra:-KroneckerProduct); interface(rtablesize = 16); kernelopts(version); interface(version)

`⨂`

[10, 10]

`Maple 2021.2, X86 64 LINUX, Nov 23 2021, Build ID 1576349`

`Standard Worksheet Interface, Maple 2021.2, Linux, November 23 2021 Build ID 1576349`

Matrices nonconformable, Maple should give error message:

`⨂`(Matrix(1, 4, 1), IdentityMatrix(4)); Dimension(%); M := Matrix(4, 4, shape = symmetric, symbol = m); Dimension(%)

Matrix([[1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]])

4, 16

M := Matrix(4, 4, {(1, 1) = m[1, 1], (1, 2) = m[1, 2], (1, 3) = m[1, 3], (1, 4) = m[1, 4], (2, 2) = m[2, 2], (2, 3) = m[2, 3], (2, 4) = m[2, 4], (3, 3) = m[3, 3], (3, 4) = m[3, 4], (4, 4) = m[4, 4]}, storage = triangular[upper], shape = [symmetric])

4, 4

MatrixMatrixMultiply(`⨂`(Matrix(1, 4, 1), IdentityMatrix(4)), DiagonalMatrix(Diagonal(M)))

Matrix([[m[1, 1], 0, 0, 0], [0, m[2, 2], 0, 0], [0, 0, m[3, 3], 0], [0, 0, 0, m[4, 4]]])

`⨂`(Matrix(1, 4, 1), IdentityMatrix(4)).DiagonalMatrix(Diagonal(M))

Matrix([[m[1, 1], 0, 0, 0], [0, m[2, 2], 0, 0], [0, 0, m[3, 3], 0], [0, 0, 0, m[4, 4]]])

KroneckerProduct(Matrix(1, 4, 1), IdentityMatrix(4)).DiagonalMatrix(Diagonal(M))

Matrix([[m[1, 1], 0, 0, 0], [0, m[2, 2], 0, 0], [0, 0, m[3, 3], 0], [0, 0, 0, m[4, 4]]])

(Matrix(4, 16, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = 1, (1, 6) = 0, (1, 7) = 0, (1, 8) = 0, (1, 9) = 1, (1, 10) = 0, (1, 11) = 0, (1, 12) = 0, (1, 13) = 1, (1, 14) = 0, (1, 15) = 0, (1, 16) = 0, (2, 1) = 0, (2, 2) = 1, (2, 3) = 0, (2, 4) = 0, (2, 5) = 0, (2, 6) = 1, (2, 7) = 0, (2, 8) = 0, (2, 9) = 0, (2, 10) = 1, (2, 11) = 0, (2, 12) = 0, (2, 13) = 0, (2, 14) = 1, (2, 15) = 0, (2, 16) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1, (3, 4) = 0, (3, 5) = 0, (3, 6) = 0, (3, 7) = 1, (3, 8) = 0, (3, 9) = 0, (3, 10) = 0, (3, 11) = 1, (3, 12) = 0, (3, 13) = 0, (3, 14) = 0, (3, 15) = 1, (3, 16) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 1, (4, 5) = 0, (4, 6) = 0, (4, 7) = 0, (4, 8) = 1, (4, 9) = 0, (4, 10) = 0, (4, 11) = 0, (4, 12) = 1, (4, 13) = 0, (4, 14) = 0, (4, 15) = 0, (4, 16) = 1})).DiagonalMatrix(Diagonal(M))

Matrix([[m[1, 1], 0, 0, 0], [0, m[2, 2], 0, 0], [0, 0, m[3, 3], 0], [0, 0, 0, m[4, 4]]])

`⨂`(Matrix(1, 4, 1), IdentityMatrix(4)).Matrix(4, 4, shape = diagonal, symbol = m)

Matrix([[m[1, 1], 0, 0, 0], [0, m[2, 2], 0, 0], [0, 0, m[3, 3], 0], [0, 0, 0, m[4, 4]]])

whattype(`⨂`(Matrix(1, 4, 1), IdentityMatrix(4))); Dimension(`⨂`(Matrix(1, 4, 1), IdentityMatrix(4)))

Matrix

4, 16

whattype(DiagonalMatrix(Diagonal(M))); Dimension(M)

Matrix

4, 4

hereafter results are correct: Matrices

nonconformable, therefore error messages appear.

`⨂`(Matrix(1, 4, 1), IdentityMatrix(4)).M

Error, (in LinearAlgebra:-Multiply) first matrix column dimension (16) <> second matrix row dimension (4)

`&bigotimes;`(Matrix(1, 4, 1), IdentityMatrix(4)).Matrix(4, 4, shape = symmetric, symbol = m)

Error, (in LinearAlgebra:-Multiply) first matrix column dimension (16) <> second matrix row dimension (4)

Download Strange.mw

I don't know how to fix this. What's wrong? Is there an alternative way to include underscores in a cat command?

``

restart; with(LinearAlgebra)

komb := proc (n::integer, m::integer) local L, a, j; L := [seq(cat(a, "__", j, ",", j), j = 1 .. n)]; add(mul(k), `in`(k, combinat:-choose(L, m))); return % end proc

proc (n::integer, m::integer) local L, a, j, k; L := [seq(cat(a, "__", j, ",", j), j = 1 .. n)]; add(mul(k), `in`(k, combinat:-choose(L, m))); return % end proc

(1)

komb(5, 5)

`a__1,1`*`a__2,2`*`a__3,3`*`a__4,4`*`a__5,5`

(2)

whattype(`a__1,1`)

symbol

(3)

A := Matrix(5, 5, shape = diagonal, symbol = a)

Matrix(%id = 36893489895174306860)

(4)

abs(A)

a[1, 1]*a[2, 2]*a[3, 3]*a[4, 4]*a[5, 5]

(5)

whattype(a[1, 1])

indexed

(6)

simplify(komb(5, 5)-abs(A))

`a__1,1`*`a__2,2`*`a__3,3`*`a__4,4`*`a__5,5`-a[1, 1]*a[2, 2]*a[3, 3]*a[4, 4]*a[5, 5]

(7)

``

Download indexed.mw

Using the VectorCalculus package in Maple 2020.2, the Jacobian does accept my target function, whereas the Hessian does not. Both the Jacobian and the Hessian need an algebraic expression for its input.

What can I do to make it work?

kind regards, Harry

 

vectorcalculus_question.mw

 

I am using Maple 2020.2 and it seems that the Linear Algebra package is incompatable with the Vector Calculus package:

Why not a friendly error message?
I want to use the Jacobian and the Hessian. Are there alternatives? MTM package can give a Jacobian, but no Hessian (but MTM is also tricky to use).

Harry

 

 

I was hoping to find a nice symbolic solution for the root of this equation:

a,c,d,k are parameters.
Unfortunately, I got an RootOf expression, which does not make sense to me. Assumptions do no help me further.

Next week, I have to present my results, but I don't know how to interpret is (the help file does not bring any relief). Is there something to say about the root? Suppose, I wanted to use side restriction on a problem? E.g., find a solution conditional on the fact that the derivative is zero. 


Clearly, in the plot it seems simple.

In one case there is a solution Maple provides: a  (a parameter)

This seems strange, because numerically there is one solution (and clearly not a).

restart

version(); interface(version)

 User Interface: 1502365
         Kernel: 1502365
        Library: 1502365

 

1502365

 

`Standard Worksheet Interface, Maple 2020.2, Windows 10, November 11 2020 Build ID 1502365`

(1)

f := proc (t) options operator, arrow; c/(1+exp(k*(t-a)))-c*(t-a)*k*exp(k*(t-a))/(1+exp(k*(t-a)))^2+d/(1+exp(-k*(t-a)))+d*(t-a)*k*exp(-k*(t-a))/(1+exp(-k*(t-a)))^2 end proc

proc (t) options operator, arrow; c/(1+exp(k*(t-a)))-c*(t-a)*k*exp(k*(t-a))/(1+exp(k*(t-a)))^2+d/(1+exp(-k*(t-a)))+d*(t-a)*k*exp(-k*(t-a))/(1+exp(-k*(t-a)))^2 end proc

(2)

assume(k > 0)

additionally(a > 0)

additionally(t > 0, t < 21)

about(a, k, t)

Originally a, renamed a~:
  is assumed to be: RealRange(Open(0),infinity)

Originally k, renamed k~:
  is assumed to be: RealRange(Open(0),infinity)

Originally t, renamed t~:
  is assumed to be: RealRange(Open(0),Open(21))
 

 

interface(showassumed = 0)

0

(3)

solve(f(t) = 0, t)

Warning, solve may be ignoring assumptions on the input variables.

 

(k*a+RootOf(-(exp(_Z))^4*d+(exp(_Z))^3*_Z*c-(exp(_Z))^3*_Z*d-(exp(_Z))^3*c-3*(exp(_Z))^3*d+2*c*_Z*(exp(_Z))^2-2*(exp(_Z))^2*_Z*d-3*c*(exp(_Z))^2-3*d*(exp(_Z))^2+c*_Z*exp(_Z)-d*_Z*exp(_Z)-3*c*exp(_Z)-d*exp(_Z)-c))/k

(4)

[allvalues(%)]

[(k*a+I*Pi+(2*I)*Pi*_Z1)/k, (k*a+RootOf(-d*(exp(_Z))^2+c*_Z*exp(_Z)-d*_Z*exp(_Z)-c*exp(_Z)-d*exp(_Z)-c))/k]

(5)

Re([op(%)][1])

a

(6)

Re([op(`%%`)][2])

(k*a+Re(RootOf(-d*(exp(_Z))^2+c*_Z*exp(_Z)-d*_Z*exp(_Z)-c*exp(_Z)-d*exp(_Z)-c)))/k

(7)

a := 'a'; b := 'b'; c := 'c'; d := 'd'; k := 'k'; t := 't'

a

 

b

 

c

 

d

 

t

(8)

Now, numerically:

b := 40; k := .3; a := 10; c := 2.8; d := -1.5

40

 

.3

 

10

 

2.8

 

-1.5

(9)

RealDomain:-solve(f(t) = 0, t)

11.02361521

(10)

plot(f(t), t = 0 .. 20, color = "DarkBlue", thickness = 2)

 

``


 

Download Please_NO_RootOf.mw

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