MaplePrimes Questions

Search Questions:

Latest Questions Latest Questions Feed

I want to create a matrix (B) from entries of other matrices (A) with a helper-function (helper). The helper function is defined such that it returns a certain matrix depending on the index variables. This is necessary because the inner matrices are constructed with another function.

Since the helper-function returns matrices, the big matrix is of datatype=matrix. Unfortunately, creating the big matrix with the correct size and forcing the datatype=float, does not yield the desired result. However, the manual definition using the constructor with a list of matrices does create the desired matrix.

How do I resolve a matrix of matrices?

Note: I know that I could write a convert function that copies the entries to a corresponding matrix, though this seems to be unnecessary effort to me.

This might not be minimal but shows the issue. (Compare B and test)

MWE_matrix_of_matrices.mw

restart;
with(LinearAlgebra):

size_A := 2;
size_B := 3;

2

 

3

(1)

helper2 := proc(i::integer,j::integer);
  if i=j then
    a;
  elif i=j-1 or i=j+1 then
    b;
  else
    c;
  end if;
end proc:

helper3 := proc(i::integer,j::integer);
  if i=j then
    Matrix(size_A,size_A,helper2);
  elif i=j-1 or i=j+1 then
    -IdentityMatrix(size_A);
  else
    Matrix(size_A);
  end if;
end proc:

A := Matrix(size_A, size_A, helper2);
B := Matrix(size_B, size_B, helper3);
B := Matrix(size_B,size_B, helper3, datatype = float);
B := Matrix(size_B*size_A, size_B*size_A,[Matrix(size_B,size_B,helper3)], datatype = float)

A := Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a})

 

B := Matrix(3, 3, {(1, 1) = Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a}), (1, 2) = Matrix(2, 2, {(1, 1) = -1, (1, 2) = 0, (2, 1) = 0, (2, 2) = -1}), (1, 3) = Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0}), (2, 1) = Matrix(2, 2, {(1, 1) = -1, (1, 2) = 0, (2, 1) = 0, (2, 2) = -1}), (2, 2) = Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a}), (2, 3) = Matrix(2, 2, {(1, 1) = -1, (1, 2) = 0, (2, 1) = 0, (2, 2) = -1}), (3, 1) = Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0}), (3, 2) = Matrix(2, 2, {(1, 1) = -1, (1, 2) = 0, (2, 1) = 0, (2, 2) = -1}), (3, 3) = Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a})})

 

Error, (in Matrix) unable to store 'Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a})' when datatype=float[8]

 

Error, (in Matrix) unable to store 'Matrix(2, 2, {(1, 1) = a, (1, 2) = b, (2, 1) = b, (2, 2) = a})' when datatype=float[8]

 

test := Matrix(4, 4, [
                [Matrix([[1,2],[0,9]]), Matrix([[3,6],[0,9]])],
                [Matrix([[3,4],[7,8]]), Matrix([[7,6],[5,5]])]
               ]); # is converted to a matrix of floats

test := Matrix(4, 4, {(1, 1) = 1, (1, 2) = 2, (1, 3) = 3, (1, 4) = 6, (2, 1) = 0, (2, 2) = 9, (2, 3) = 0, (2, 4) = 9, (3, 1) = 3, (3, 2) = 4, (3, 3) = 7, (3, 4) = 6, (4, 1) = 7, (4, 2) = 8, (4, 3) = 5, (4, 4) = 5})

(2)


Hi guys,

I have written a program in Maple 2016 (Windows 7) made of two parts :

  1. An initialization step where a formal system of algebraic equations (some non linear) is built
    Let S(U, P) this system, where U denotes a set of unknowns and P a set of parameters (see step 2 below)
  2. An iterative step where this system is solved with respect to U for different values of parameters P
    This loop has to be executed N times for values P1, ..., Pn, ... of P

I observe that the size of the memory (bottom right of the Maple window) inflates as the value of n increases.

I was able to isolate in the loop corresponding to step 2, the procedure MyProc I wrote which is responsible of this memory inflation.
Now I would like to manage this inflation (typically the memory size grows up to 3 GiB for n about one thousand) because of its very negative effects on the computational time (probably Maple does spend a lot of time in swapping operations).


Suspecting the remember process to be the source of this problem, I tried simple tricks such as

  • systematically write   > quantity := 'quantity';   for fome intermediate quantities
  • use forget  : for example MyProc contains a call to fsolve and,  after "local" declarations, I inserted  the command  forget(fsolve)   
  • in the the loop over n,  I even inserted the command forget(Myproc).

None of these tricks was to some extent efficient to contain the memory inflation.


I suppose it is a very common situation that people who use to develop code are familiar with. So maybe some of you could provide my some advices or move me towards "strategies" or "methodologies" to prevent this situation ?
My purpose here is not to ask you to solve my problem, but rather to ask youy to give me hints to be able to manage such kind of situations by myself.


Maybe this question is unorthodox and doesn't have its place here ?
It that case please let me know.

Thanks In Advance


PS : it would be very difficult for me to provide you the code : if it is a necessary condition for you to help me, just forget it, I will understand

I have a simple minded question :
How can I give an answer a Vote Up or select it as the Best Answer to a question ?

Hi EveryOne!

In the answer of the question "How to find roót of polynomial in finite field and extension finite field ", @Carl Love helped me to find roots of polynimial in finite field and extension finite field (At URL http://www.mapleprimes.com/view.aspx?sf=215097_Answer/Primfield.mw OR http://www.mapleprimes.com/view.aspx?sf=215285_Answer/Matrix_powers_finite_field.mw)

However, with matrix M: =< x^4+x^3+x^6+x^7+x, 1+x^2+x^4+x^5+x^6, 1+x+x^2+x^3, x^7+x^6+x^5+x^4;

                                   x^7+x^5+x^4+x^3, x^6+x^4+x^2+1, x^4+x^3+x^6+x^7+x^2+x+1, 1+x^2+x^3+x^4+x^5; 

                                   x^7+x^5+x^2, x^7+x^5+x^3+x^2+1, x^2+x+x^6, x^2+x^3+x^5;
                                   x^4+x^3+x^6+1, 1+x^2+x^3+x^4, x^6+x^5+x^4+x^3, x^7+x^3 >;

and GF(2^8)/f(x)=x^8 + x^7 +x^6 + x +1 (i.e ext1:= Z^8+Z^7+Z^6+Z+1), then program Primfield.mw don't run!

Please help me! Thanks so much.

 

Dear All

Using Lie algebra package in Maple we can easily find nilradical for given abstract algebra, but how we can find all the ideal in lower central series by taking new basis as nilradical itself?

Please see following;

 

with(DifferentialGeometry); with(LieAlgebras)

DGsetup([x, y, t, u, v])

`frame name: Euc`

(1)
Euc > 

VectorFields := evalDG([D_v, D_v*x+D_y*t, 2*D_t*t-2*D_u*u-D_v*v+D_y*y, t*D_v, D_v*y+D_u, D_t, D_x, D_x*t+D_u, 2*D_v*x+D_x*y, -D_t*t+2*D_u*u+2*D_v*v+D_x*x, D_y])

[_DG([["vector", "Euc", []], [[[5], 1]]]), _DG([["vector", "Euc", []], [[[2], t], [[5], x]]]), _DG([["vector", "Euc", []], [[[2], y], [[3], 2*t], [[4], -2*u], [[5], -v]]]), _DG([["vector", "Euc", []], [[[5], t]]]), _DG([["vector", "Euc", []], [[[4], 1], [[5], y]]]), _DG([["vector", "Euc", []], [[[3], 1]]]), _DG([["vector", "Euc", []], [[[1], 1]]]), _DG([["vector", "Euc", []], [[[1], t], [[4], 1]]]), _DG([["vector", "Euc", []], [[[1], y], [[5], 2*x]]]), _DG([["vector", "Euc", []], [[[1], x], [[3], -t], [[4], 2*u], [[5], 2*v]]]), _DG([["vector", "Euc", []], [[[2], 1]]])]

(2)
Euc > 

L1 := LieAlgebraData(VectorFields)

_DG([["LieAlgebra", "L1", [11]], [[[1, 3, 1], -1], [[1, 10, 1], 2], [[2, 3, 2], -1], [[2, 5, 4], 1], [[2, 6, 11], -1], [[2, 7, 1], -1], [[2, 8, 4], -1], [[2, 9, 5], -1], [[2, 9, 8], 1], [[2, 10, 2], 1], [[3, 4, 4], 3], [[3, 5, 5], 2], [[3, 6, 6], -2], [[3, 8, 8], 2], [[3, 9, 9], 1], [[3, 11, 11], -1], [[4, 6, 1], -1], [[4, 10, 4], 3], [[5, 10, 5], 2], [[5, 11, 1], -1], [[6, 8, 7], 1], [[6, 10, 6], -1], [[7, 9, 1], 2], [[7, 10, 7], 1], [[8, 9, 4], 2], [[8, 10, 8], 2], [[9, 10, 9], 1], [[9, 11, 7], -1]]])

(3)
Euc > 

DGsetup(L1)

`Lie algebra: L1`

(4)
L1 > 

MultiplicationTable("LieTable"):

L1 > 

N := Nilradical(L1)

[_DG([["vector", "L1", []], [[[1], 1]]]), _DG([["vector", "L1", []], [[[2], 1]]]), _DG([["vector", "L1", []], [[[4], 1]]]), _DG([["vector", "L1", []], [[[5], 1]]]), _DG([["vector", "L1", []], [[[6], 1]]]), _DG([["vector", "L1", []], [[[7], 1]]]), _DG([["vector", "L1", []], [[[8], 1]]]), _DG([["vector", "L1", []], [[[9], 1]]]), _DG([["vector", "L1", []], [[[11], 1]]])]

(5)
L1 > 

Query(N, "Nilpotent")

true

(6)
L1 > 

Query(N, "Solvable")

true

(7)

Taking N as new basis , how we can find all ideals in lower central series of this solvable ideal N?

 

Download [944]_Structure_of_Lie_algebra.mw

Regards

a := 18; b := 2; c := 1; d := 1; f := 1; DEtools[phaseportrait]({diff(x(t), t) = a*x-b*exp(x)*y/(1+exp(x))-f*x*x, diff(y(t), t) = -c*y+b*exp(x)*d*y/(1+exp(x))}, [x(t), y(t)], t = 0 .. 100, {[x(0) = .1, y(0) = 18], [x(0) = .1, y(0) = 27], [x(0) = .2, y(0) = 28], [x(0) = .5, y(0) = 16], [x(0) = .6, y(0) = 14], [x(0) = .7, y(0) = 8], [x(0) = .7, y(0) = 29], [x(0) = 1.0, y(0) = 18], [x(0) = 1.0, y(0) = 22], [x(0) = 1.2, y(0) = 20], [x(0) = 1.5, y(0) = 20], [x(0) = 1.5, y(0) = 24.0], [x(0) = 1.6, y(0) = 26.0], [x(0) = 1.7, y(0) = 28], [x(0) = 1.8, y(0) = 21], [x(0) = 2.0, y(0) = 9], [x(0) = 2.0, y(0) = 28]}, x = 0 .. 2, y = 0 .. 30, dirgrid = [13, 13], stepsize = 0.5e-1, arrows = SLIM, axes = BOXED, thickness = 2)

Is there an elegant way to plot in 3d only the portion of the function f(x,y)=sqrt(25-x^2-y^2) for which 9 <= x^2+y^2 <= 16 ? I'm looking for a nice plot that shows it against the whole sphere with radius 5, so that it's clear which part of the sphere is cut out.

Hi,

It might be very silly question, but i dont know why it is not working out. So here is the question. In the attached maple shhet when i am trying to substitute eta(t)=epsilon*z(t) then it is not making that susbtitution for differential operator. Apart from that when i m collecting epsilon terms then also it not collecting it.quesiton.mw

 

Regards

Sunit

Dear Community,

I get this message

'EQU' is implicitly declared local to procedure 'Z_DAK_FSOLVE'Problem with procedurefor a procedure, and  cannot go further. How can I avoid it?

Tx for the help in advance,

best regards

Andras

Z_DAK_PROC.mw

Below I try to use units for a simple expression, where "m" and "mm" is added on Windows using Ctrl-Shift-U.

Why does the value with unit "1 [[m]]" not show as "1 m" in (1), but simply as "m" ?

Why does the addition not result in "2 m" ?

At least I had expected the addition to be made when using "evalf()".

 

I have Maple 2016 on Ubuntu 16.04.  I get an error message when attempting to plot with an x11 device, that means I have missing fonts.

I do not get this error message on Ubuntu14.04, so, I think the difference is in fonts installed.

plotsetup(x11)

> plot([sin(x),cos(x)],x=-Pi..Pi);
> Maple X driver failure:BadName (named color or font does not exist)Warning: Cannot convert string "-adobe-helvetica-bold-r-normal--14-*" to type FontStruct
Warning: Cannot convert string "-adobe-helvetica-medium-r-normal--14-*" to type FontStruct

I have xfonts-100dpi and xfonts-75dpi installed.

Any idea what fonts I need to fix this?

 

Tom Dean

Hi Maple People,

I have this Maple command -

printf("%g",p)

where p is a variable I assign.  My problem is that I want to put a new line in the display.

What is the appropriate command?

Regards,

Matt

 

 

Hi all,

I have three points in 3d space say A1=[a11, a12, a13]; A2=[a21, a22, a23] and A3=[a31, a32, a33]. I want to fill the triangle formed by these points. How can I do that?

Thanks is advance.

Hi all,

I have a 3D graph and when I right click on the surface, under style, I can see the option of contour. When I click on that I can see some contour associated with the surface. I want maple to show the values for each contour when I observe it from the top . I want to copy and paste some surfaces in a same figure and campare the contours.

 

Thank you

 

 

 

rather than last time saved file result?

When I open maple script file, it display the result which file created.

however, not the latest result 

it need to move cursor to the end of script and press enter again.

3 4 5 6 7 8 9 Last Page 5 of 1313