Question: How to formulate this eq. (system) with matrices and vector-valued functions?

Apologies for possible double post, it seemingly locked up upon trying to post the first time. 

So before I get as far as to ask for how to get a certain PDE system solved and plotted, I tried to fiddle a little bit around with linear algebra. 

  • First, the file SystemGoesWrong.mw . I have issues with declaring (same result if I remove the with(VectorCalculus)); as far as I can see, EQ0 and EQ00 should be the same, except that I have summed the vector in one of them. And the first that "works", is wrong: it returns a scaling of a vector. How come?
  • But then I copy everything from the heading and down into a worksheet where I was already fighting some linear algebra things (can someone please explain?): SystemDeclaresBut.mw 
    Then EQ0 and EQ00 declare just fine! What is the issue?
  • How do I get Maple to list the equations in "compact" form with vector-valued functions so that I can read and debug?  The actual PDE system I want to solve (numerically, of course), looks as follows: DE4Maple.pdf 
    That was also the reason why I tried to declare procedures (coordinate-wise maximum ...), but I guess that questions on how to extract a solution and plot it in a particular way will be its own posting after I have learned how to declare it.

 

The contents of the first file:


 

restart

# Since I do not have any idea of how to get vectors nicely, ...

... I replace U0, U1, U2 by u,v,w and use difftables U,V,W.  And y1, y2 replaced by y,z.

with(PDEtools):

declare(u(y, z), v(y, z), w(y, z), q1(y, z), r1(y, z), s1(y, z), q2(y, z), r2(y, z), s2(y, z), F1(y, z), F2(y, z)):

u(y, z)*`will now be displayed as`*u

 

v(y, z)*`will now be displayed as`*v

 

w(y, z)*`will now be displayed as`*w

 

q1(y, z)*`will now be displayed as`*q1

 

r1(y, z)*`will now be displayed as`*r1

 

s1(y, z)*`will now be displayed as`*s1

 

q2(y, z)*`will now be displayed as`*q2

 

r2(y, z)*`will now be displayed as`*r2

 

s2(y, z)*`will now be displayed as`*s2

 

F1(y, z)*`will now be displayed as`*F1

 

F2(y, z)*`will now be displayed as`*F2

(1)

``

M := `<|>`(`<,>`(2, -1), `<,>`(-1, 2))

M := Matrix(2, 2, {(1, 1) = 2, (1, 2) = -1, (2, 1) = -1, (2, 2) = 2})

(2)

1/M

Matrix([[2/3, 1/3], [1/3, 2/3]])

(3)

 

# The system

 

EQ0 := VectorCalculus:-`+`(VectorCalculus:-`+`(Typesetting:-delayDotProduct(`<|>`(F1, F2), VectorCalculus:-`+`(Typesetting:-delayDotProduct(1/M, `<,>`(q1, q2)), VectorCalculus:-`-`(`<,>`(U[y], V[z])))), VectorCalculus:-`-`(Typesetting:-delayDotProduct(VectorCalculus:-`*`(1/4, VectorCalculus:-`+`(Typesetting:-delayDotProduct(1/M, `<,>`(q1, q2)), VectorCalculus:-`-`(`<,>`(U[y], V[z])))^%T), VectorCalculus:-`+`(Typesetting:-delayDotProduct(1/M, `<,>`(q1, q2)), VectorCalculus:-`-`(`<,>`(U[y], V[z])))))), VectorCalculus:-`-`(Typesetting:-delayDotProduct(Typesetting:-delayDotProduct(VectorCalculus:-`*`(1/2, `<|>`(VectorCalculus:-`+`(VectorCalculus:-`+`(VectorCalculus:-`*`(2, F1), U[y]), VectorCalculus:-`-`(s1)), VectorCalculus:-`+`(VectorCalculus:-`+`(VectorCalculus:-`*`(2, F2), V[z]), VectorCalculus:-`-`(s2)))), 1/M), `<,>`(q1, q2))))

EQ0 := -((1/6)*q1+(1/12)*q2-(1/4)*(diff(u(y, z), y)))*((2/3)*q1+(1/3)*q2-(diff(u(y, z), y)))-((1/12)*q1+(1/6)*q2-(1/4)*(diff(v(y, z), z)))*((1/3)*q1+(2/3)*q2-(diff(v(y, z), z)))+(Vector(1, {(1) = F1*((2/3)*q1+(1/3)*q2-(diff(u(y, z), y)))+F2*((1/3)*q1+(2/3)*q2-(diff(v(y, z), z)))}, attributes = [coords = cartesian]))+(Vector(1, {(1) = -((2/3)*F1+(1/3)*(diff(u(y, z), y))-(1/3)*s1+(1/3)*F2+(1/6)*(diff(v(y, z), z))-(1/6)*s2)*q1-((1/3)*F1+(1/6)*(diff(u(y, z), y))-(1/6)*s1+(2/3)*F2+(1/3)*(diff(v(y, z), z))-(1/3)*s2)*q2}, attributes = [coords = cartesian]))

(4)

EQ00 := `<|>`(F1, F2).(1/M.`<,>`(q1, q2)-`<,>`(U[y], V[z]))-(1/4)*LinearAlgebra:-Transpose(1/M.`<,>`(q1, q2)-`<,>`(U[y], V[z])).(1/M.`<,>`(q1, q2)-`<,>`(U[y], V[z]))-1/2*(2*`<|>`(F1, F2)+`<|>`(U[y], V[z])-`<|>`(s1, s2)).(1/M).`<,>`(q1, q2)

Error, (in rtable/Sum) invalid input: dimensions do not match: Matrix(1 .. 1, 1 .. 2) cannot be added to Vector[row](1 .. 2)

 

``

``


 

Download SystemGoesWrong.mw

 

 

 

... and of the second:

 

 


 

``

Over to some linear algebra.  

 

 

restart; with(LinearAlgebra); with(VectorCalculus)

NULL

LinearAlgebra:-Transpose(`<|>`(3, 4)).`<,>`(2, 3)

18

(1)

VectorCalculus:-DotProduct(VectorCalculus:-`<,>`(3, 4), VectorCalculus:-`<,>`(2, 3))

18

(2)

DotProduct(`<,>`(2, 3), `<|>`(3, 4))

Matrix([[6, 8], [9, 12]])

(3)

Trace(Matrix(%id = 18446746888362217830));

18

(4)

                                                                 

define(normsqbyDot, normsqbyDot(y::Vector) = VectorCalculus:-DotProduct(y, y))

showstat(normsqbyDot)


normsqbyDot := proc()
local theArgs, arg, look, me, cf, term;
   1   me := eval(procname,1);
   2   theArgs := args;
   3   look := tablelook(('procname')(theArgs),'[`/POS`(1,normsqbyDot,1), `/BIND`(1,1,`/y1`::VectorCalculus:-Vector), `/PATTERN`(`/y1`^2)]');
   4   if look <> FAIL then
   5     eval(look,`/FUNCNAME` = procname)
       else
   6     ('procname')(theArgs)
       end if
end proc

 

define, "%1 is assigned", normsqbyMatrixProduct

showstat(normsqbyMatrixProduct)


normsqbyMatrixProduct := proc()
local theArgs, arg, look, me, cf, term;
   1   me := eval(procname,1);
   2   theArgs := args;
   3   look := tablelook(('procname')(theArgs),'[`/POS`(1,normsqbyMatrixProduct,1), `/BIND`(1,1,`/y1`::Matrix), `/PATTERN`(`/y1`^2)]');
   4   if look <> FAIL then
   5     eval(look,`/FUNCNAME` = procname)
       else
   6     ('procname')(theArgs)
       end if
end proc

 

normsqbyDot(`<,>`(2, 3))

Error, (in rtable/Power) exponentiation operation not defined for Vectors

 

normsqbyMatrixProduct(VectorCalculus:-`<,>`(2, 3))

normsqbyMatrixProduct(Vector(2, {(1) = 2, (2) = 3}, attributes = [coords = cartesian]))

(5)

convert(n*ormsqbyMatrixProduct(`<,>`(2, 3)), float)

n*ormsqbyMatrixProduct(Vector(2, {(1) = 2, (2) = 3}, attributes = [coords = cartesian]))

(6)

NULL

# Since I do not have any idea of how to get vectors nicely, ...

... I replace U0, U1, U2 by u,v,w and use difftables U,V,W.  And y1, y2 replaced by y,z.

with(PDEtools); -1; with(plots)

[animate, animate3d, animatecurve, arrow, changecoords, complexplot, complexplot3d, conformal, conformal3d, contourplot, contourplot3d, coordplot, coordplot3d, densityplot, display, dualaxisplot, fieldplot, fieldplot3d, gradplot, gradplot3d, implicitplot, implicitplot3d, inequal, interactive, interactiveparams, intersectplot, listcontplot, listcontplot3d, listdensityplot, listplot, listplot3d, loglogplot, logplot, matrixplot, multiple, odeplot, pareto, plotcompare, pointplot, pointplot3d, polarplot, polygonplot, polygonplot3d, polyhedra_supported, polyhedraplot, rootlocus, semilogplot, setcolors, setoptions, setoptions3d, shadebetween, spacecurve, sparsematrixplot, surfdata, textplot, textplot3d, tubeplot]

(7)

declare(u(y, z), v(y, z), w(y, z), q1(y, z), r1(y, z), s1(y, z), q2(y, z), r2(y, z), s2(y, z), F1(y, z), F2(y, z)):

u(y, z)*`will now be displayed as`*u

 

v(y, z)*`will now be displayed as`*v

 

w(y, z)*`will now be displayed as`*w

 

q1(y, z)*`will now be displayed as`*q1

 

r1(y, z)*`will now be displayed as`*r1

 

s1(y, z)*`will now be displayed as`*s1

 

q2(y, z)*`will now be displayed as`*q2

 

r2(y, z)*`will now be displayed as`*r2

 

s2(y, z)*`will now be displayed as`*s2

 

F1(y, z)*`will now be displayed as`*F1

 

F2(y, z)*`will now be displayed as`*F2

(8)

NULL

M := `<|>`(`<,>`(2, -1), `<,>`(-1, 2))

M := Matrix(2, 2, {(1, 1) = 2, (1, 2) = -1, (2, 1) = -1, (2, 2) = 2})

(9)

1/M

Matrix([[2/3, 1/3], [1/3, 2/3]])

(10)

 

# The system

 

EQ0 := Typesetting:-delayDotProduct(`<|>`(F1, F2), Typesetting:-delayDotProduct(1/M, `<,>`(q1, q2))+`-`(`<,>`(U[y], V[z])))+`-`(Typesetting:-delayDotProduct(VectorCalculus:-`*`(1/4, (Typesetting:-delayDotProduct(1/M, `<,>`(q1, q2))+`-`(`<,>`(U[y], V[z])))^%T), Typesetting:-delayDotProduct(1/M, `<,>`(q1, q2))+`-`(`<,>`(U[y], V[z]))))+`-`(Typesetting:-delayDotProduct(Typesetting:-delayDotProduct(VectorCalculus:-`*`(1/2, `<|>`(VectorCalculus:-`*`(2, F1)+U[y]+`-`(s1), VectorCalculus:-`*`(2, F2)+V[z]+`-`(s2))), 1/M), `<,>`(q1, q2)))

F1*((2/3)*q1+(1/3)*q2-(diff(u(y, z), y)))+F2*((1/3)*q1+(2/3)*q2-(diff(v(y, z), z)))-((1/6)*q1+(1/12)*q2-(1/4)*(diff(u(y, z), y)))*((2/3)*q1+(1/3)*q2-(diff(u(y, z), y)))-((1/12)*q1+(1/6)*q2-(1/4)*(diff(v(y, z), z)))*((1/3)*q1+(2/3)*q2-(diff(v(y, z), z)))-((2/3)*F1+(1/3)*(diff(u(y, z), y))-(1/3)*s1+(1/3)*F2+(1/6)*(diff(v(y, z), z))-(1/6)*s2)*q1-((1/3)*F1+(1/6)*(diff(u(y, z), y))-(1/6)*s1+(2/3)*F2+(1/3)*(diff(v(y, z), z))-(1/3)*s2)*q2

(11)

EQ00 := VectorCalculus:-`+`(VectorCalculus:-`+`(Typesetting:-delayDotProduct(`<|>`(F1, F2), VectorCalculus:-`+`(Typesetting:-delayDotProduct(1/M, `<,>`(q1, q2)), VectorCalculus:-`-`(`<,>`(U[y], V[z])))), VectorCalculus:-`-`(Typesetting:-delayDotProduct(VectorCalculus:-`*`(1/4, VectorCalculus:-`+`(Typesetting:-delayDotProduct(1/M, `<,>`(q1, q2)), VectorCalculus:-`-`(`<,>`(U[y], V[z])))^%T), VectorCalculus:-`+`(Typesetting:-delayDotProduct(1/M, `<,>`(q1, q2)), VectorCalculus:-`-`(`<,>`(U[y], V[z])))))), VectorCalculus:-`-`(Typesetting:-delayDotProduct(Typesetting:-delayDotProduct(VectorCalculus:-`*`(1/2, VectorCalculus:-`+`(VectorCalculus:-`+`(VectorCalculus:-`*`(2, `<|>`(F1, F2)), `<|>`(U[y], V[z])), VectorCalculus:-`-`(`<|>`(s1, s2)))), 1/M), `<,>`(q1, q2))))

F1*((2/3)*q1+(1/3)*q2-(diff(u(y, z), y)))+F2*((1/3)*q1+(2/3)*q2-(diff(v(y, z), z)))-((1/6)*q1+(1/12)*q2-(1/4)*(diff(u(y, z), y)))*((2/3)*q1+(1/3)*q2-(diff(u(y, z), y)))-((1/12)*q1+(1/6)*q2-(1/4)*(diff(v(y, z), z)))*((1/3)*q1+(2/3)*q2-(diff(v(y, z), z)))-((2/3)*F1+(1/3)*(diff(u(y, z), y))-(1/3)*s1+(1/3)*F2+(1/6)*(diff(v(y, z), z))-(1/6)*s2)*q1-((1/3)*F1+(1/6)*(diff(u(y, z), y))-(1/6)*s1+(2/3)*F2+(1/3)*(diff(v(y, z), z))-(1/3)*s2)*q2

(12)

``

 


 

Download SystemDeclaresBut.mw

 

 

Please Wait...