Items tagged with ordering ordering Tagged Items Feed

my code can only do for one variable, 

how to make divisible checking for multivariable cases with the ordering such as plex

 

IsDivisible(LP(h, t), LP(g[i], t), x)

it is not only x when multivariable

 

f:=LP(y^2*x,plex(x, y))[2];
g:=LP(y*x-y,plex(x, y))[2];
Remainder(f, g, gcd(f,g));
degree(Remainder(f, g, x),x);
degree(g, x);

remainder has error expect its 3rd argument x, to be of type or but received y*x

how to do if have ordering

do it need to check whether both f and g have variable x using indets and then apply remainder?

do it need to check each variable starting from the first variable in the ordering? 

how about if f has variable x but g do not have variable x, or f do not have variable x and g have variable x

 

if so, i try to replace below code in the bottom code, it has error

Error, (in FindDivisble) cannot determine if this expression is true or false: 0 < Search(x, {x, y})

FindDivisble := proc(g, h, t)
with(ListTools):
result := 0;
for i from 1 to nops(g) do
mainvariable := 0;
for j from 1 to nops(t) do
mainvariable := op(j, t);
if mainvariable <> 0 then
if Search(mainvariable, indets(h)) > 0 and Search(mainvariable, indets(g[i])) > 0 then
if IsDivisible(LP(h,t), LP(g[i],t), mainvariable) = 0 then
return i;
else
result := 0;
end if:
end if:
end if:
od:
od:
return result;
end proc:

 

 

with(Groebner):
LP := proc(f, t)
return LeadingTerm(f, t)/LeadingCoefficient(f, t);
end proc:
IsDivisible := proc(f, g, x)
with(Algebraic):
if Remainder(f, g, x) = 0 or degree(Remainder(f, g, x),x) < degree(g, x) then
return 0;
else
return 1;
end if:
end proc:
FindDivisble := proc(g, h, t)
result := 0;
for i from 1 to nops(g) do
if IsDivisible(LP(h, t), LP(g[i], t), x) = 0 then
return i;
else
result := 0;
end if:
od:
return result;
end proc:
MD := proc(f, g, t)
r := 0;
u := Matrix(nops(g), 1);
for j from 1 to nops(g) do
u[j] := 0;
od:
h := f;
while h <> 0 do
i := FindDivisble(g, h, t);
if i > 0 then
u[i] := u[i] + LeadingTerm(h, t)/LeadingTerm(f[i], t);
h := h - LeadingTerm(h, t)/LeadingTerm(f[i], t)*f[i];
else
r := r + LeadingTerm(h, t);
h := h - LeadingTerm(h, t);
end if:
od:
end proc:
f:=y^2*x;
f1 := y*x-y;
f2 := y^2-x;
MD(f,[f1,f2],plex(x, y));

Hi all 

I have the following segment of maple program which belongs to time delay systems dynamic. here C=X-X0-G.Z-X.Dtau.P+X.Dtau.Z-U.P, is a matrix(vector) which comes from reordering the system terms and my goal is to minimizing J:=X.E.Transpose(X)+U.E.Transpose(U), subject to constraint C=0, but i don't know how to do so.

I will be so grateful if anyone can guide me

best wishes

Mahmood   Dadkhah

Ph.D Candidate

Applied Mathematics Department


restart:
with(Optimization):
with(LinearAlgebra):
macro(LA= LinearAlgebra):
L:=1:  r:=2:  tau:= 1:
interface(rtablesize= 2*r+1):

Z:= Matrix(
     2*r+1, 2*r+1,
     [tau,
      seq(evalf((L/(2*(iz-1)*Pi))*sin(2*(iz-1)*Pi*tau/L)), iz= 2..r+1),
      seq(evalf((L/(2*(iz-1-r)*Pi))*(1-cos(2*(iz-1-r)*Pi*tau/L))), iz= r+2..2*r+1)
      ],
     scan= columns,
     datatype= float[8]
);
                        
Dtau00:= < 1 >:
Dtau01:= Vector[row](r):
Dtau02:= Vector[row](r):
Dtau10:= Vector(r):
Dtau20:= Vector(r):

Dtau1:= LA:-DiagonalMatrix([seq(evalf(cos(2*i*Pi*tau/L)), i= 1..r)]):
Dtau2:= LA:-DiagonalMatrix([seq(evalf(sin(2*i*Pi*tau/L)), i= 1..r)]):
Dtau3:= -Dtau2:
Dtau4:= copy(Dtau1):

Dtau:= < < Dtau00 | Dtau01 | Dtau02 >,
         < Dtau10 | Dtau1  | Dtau2  >,
         < Dtau20 | Dtau3  | Dtau4  > >;
 
P00:= < L/2 >:
P01:= Vector[row](r):
P02:= Vector[row](r, j-> evalf(-L/j/Pi), datatype= float[8]):
P10:= Vector(r):
P20:= Vector(r, i-> evalf(L/2/i/Pi)):
P1:= Matrix(r,r):
P2:= LA:-DiagonalMatrix(P20):
P3:= LA:-DiagonalMatrix(-P20):
P4:= Matrix(r,r):

P:= < < P00 | P01 | P02 >,
      < P10 | P1  | P2  >,
      < P20 | P3  | P4  > >;

interface(rtablesize=2*r+1):    # optionally
J:=Vector([L, L/2 $ 2*r]):      # Matrix([[...]]) would also work here

E:=DiagonalMatrix(J);

X:=  Vector[row](2*r+1,symbol=a);
U:=Vector[row](2*r+1,symbol=b);

X0:= Vector[row](2*r+1,[1]);
G:=Vector[row](2*r+1,[1]);
C:=simplify(X-X0-G.Z-X.Dtau.P+X.Dtau.Z-U.P);

Z := Matrix(5, 5, {(1, 1) = 1., (1, 2) = 0., (1, 3) = 0., (1, 4) = 0., (1, 5) = 0., (2, 1) = 0., (2, 2) = 0., (2, 3) = 0., (2, 4) = 0., (2, 5) = 0., (3, 1) = 0., (3, 2) = 0., (3, 3) = 0., (3, 4) = 0., (3, 5) = 0., (4, 1) = 0., (4, 2) = 0., (4, 3) = 0., (4, 4) = 0., (4, 5) = 0., (5, 1) = 0., (5, 2) = 0., (5, 3) = 0., (5, 4) = 0., (5, 5) = 0.})

Dtau := Matrix(5, 5, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (2, 1) = 0, (2, 2) = 1., (2, 3) = 0, (2, 4) = 0., (2, 5) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1., (3, 4) = 0, (3, 5) = 0., (4, 1) = 0, (4, 2) = -0., (4, 3) = -0., (4, 4) = 1., (4, 5) = 0, (5, 1) = 0, (5, 2) = -0., (5, 3) = -0., (5, 4) = 0, (5, 5) = 1.})

P := Matrix(5, 5, {(1, 1) = 1/2, (1, 2) = 0, (1, 3) = 0, (1, 4) = -.318309886100000, (1, 5) = -.159154943000000, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (2, 4) = .1591549430, (2, 5) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0, (3, 4) = 0, (3, 5) = 0.7957747152e-1, (4, 1) = .1591549430, (4, 2) = -.159154943000000, (4, 3) = 0, (4, 4) = 0, (4, 5) = 0, (5, 1) = 0.7957747152e-1, (5, 2) = 0, (5, 3) = -0.795774715200000e-1, (5, 4) = 0, (5, 5) = 0})

E := Matrix(5, 5, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (2, 1) = 0, (2, 2) = 1/2, (2, 3) = 0, (2, 4) = 0, (2, 5) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1/2, (3, 4) = 0, (3, 5) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 1/2, (4, 5) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 0, (5, 5) = 1/2})

X := Vector[row](5, {(1) = a[1], (2) = a[2], (3) = a[3], (4) = a[4], (5) = a[5]})

U := Vector[row](5, {(1) = b[1], (2) = b[2], (3) = b[3], (4) = b[4], (5) = b[5]})

X0 := Vector[row](5, {(1) = 1, (2) = 0, (3) = 0, (4) = 0, (5) = 0})

G := Vector[row](5, {(1) = 1, (2) = 0, (3) = 0, (4) = 0, (5) = 0})

C := Vector[row](5, {(1) = 1.500000000*a[1]-2.-.1591549430*a[4]-0.7957747152e-1*a[5]-.5000000000*b[1]-.1591549430*b[4]-0.7957747152e-1*b[5], (2) = a[2]+.1591549430*a[4]+.1591549430*b[4], (3) = a[3]+0.7957747152e-1*a[5]+0.7957747152e-1*b[5], (4) = a[4]+.3183098861*a[1]-.1591549430*a[2]+.3183098861*b[1]-.1591549430*b[2], (5) = a[5]+.1591549430*a[1]-0.7957747152e-1*a[3]+.1591549430*b[1]-0.7957747152e-1*b[3]})

(1)

J:=X.E.Transpose(X)+U.E.Transpose(U);

J := a[1]^2+(1/2)*(a[2]^2)+(1/2)*(a[3]^2)+(1/2)*(a[4]^2)+(1/2)*(a[5]^2)+b[1]^2+(1/2)*(b[2]^2)+(1/2)*(b[3]^2)+(1/2)*(b[4]^2)+(1/2)*(b[5]^2)

(2)

Minimize(J,{C=0});






Error, (in Optimization:-NLPSolve) invalid arguments

 

#XP:=-.015+X[1]+add(X[l+1]*f1(l)+X[r+l+1]*f2(l), l= 1..r):
#plot([XP,T1], t= 0..1);#,legend= "Solution Of x(t) with r=50"):

 

 

 

 

 

 

Download work1.mwswork1.mws

Hello!

 

I am trying to create a Fortran routine that creates and populates a large 2D array, using Maple's codegen or CodeGeneration capabilities. I would like Maple to create the Fortran code so that the column-major ordering is respected: I would like Maple to populate mat(1,1), mat(2,1), mat(n,1) before moving on to mat(1,2)... Unfortunately, codegen and CodeGeneration seem to only produce row-major code.

Any idea on how to proceed, or an option of the code generation that I would have missed?

 

Thanks for your help!

Etienne

Stop ordering posts by votes! ... For two reasons.

1 - Someone who comes up with the idea first should be ordered as such.

2 - Conversations can get mixed up

**edit change** I have changed the title from Stop ordering posts by votes to Mapleprimes wish list. 

Hello! I am running the same piece of maple code on different machines, and I have noticed that the powerset function returns the sets in a different order. For example,

Maple 11 (X86 64 LINUX)

> powerset(3);
            {{}, {1, 2, 3}, {2, 3}, {3}, {1, 3}, {1}, {2}, {1, 2}}

Maple 14

> powerset(3);
            {{}, {1}, {2},...

I have a 6x6 matrix that depends on 8 parameters, M(F) (F is an 8-dim array, say...), and I want to compute the eigenvalues of this matrix both at a fixed point F_0 and at some other arbitrary point F'. The problem is that I need to make sure the ordering of the Eigenvalues remains the same at these two points, so that if I'd go continuously from F_0 to F' the eigenvalues would go continuously from Eigenvalues(M(F_0)) to Eigenvalues(M(F')), without any flip in the order of the entries.

Hi,

I have those questions:

1) set

When I write these inputs,

x:={1,3,2}; y:={b,a,d,c}; z:={a[1],a[1,1],b[0],d[0],c[0],a[0],2};

the results are x := {1, 2, 3}, y := {a, b, c, d}, z := {2, a[0], a[1], a[1,1], b[0], c[0], d[0]}

Is there a way to get what I input

2) This problem in ordering numbers and words is verry important and hard when solving a large system of equations with:

restart:with(SolveTools): eqns:=[a[0...

Perhaps you have heard the terms "ordering difference" or "session dependent" applied to results of some Maple computation. It used to get heard more often back before Maple 12, when elements of sets in Maple were ordered according to address.

The following type of difference in behaviour, due to deterministic ordering of sets as introduced in Maple 12, may affect implementations of some algorithms.

    |\^/|     Maple 11 (X86 64 LINUX)
._|\|   |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2007
 \  MAPLE  /  All rights reserved. Maple is a trademark of
 <____ ____>  Waterloo Maple Inc.
      |       Type ? for help.

> seq(x, x in {a,b,c,d,e,f,g}) assuming d>0;
   ...
Page 1 of 1