Items tagged with program program Tagged Items Feed

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

Whassup homies?

http://www.mathsisfun.com/puzzles/who-lives-in-the-city--solution.html

tried to solve this using C.Loves program, but didn't quite get their solution...

Who_Lives_in_the_Cit.mw

Vars:= [PN,Name, TV, Dest,Ages,Hair,Lives]:
PN:=[$1..5]:
Name:= [Bob, Keeley, Rachael, Eilish, Amy]:
TV:=[Simpsons, Coronation, Eastenders, Desperate, Neighbours]:
Dest:= [Fra, Aus, Eng, Afr,Ita]:
Ages:= [14, 21, 46, 52, 81]:
Hair:=[afro, long, straight, curly , bald]:
Lives:= [town, city, village, farm, youth]:
Con1:= Desperate=3: Con2:= Bob=1: Con3:= NextTo(Simpsons,youth,PN): Con4:= Succ(Afr,Rachael,PN): Con5:= village=52: Con6:= Aus=straight: Con7:= Afr=Desperate: Con8:= 14=5: Con9:= Amy=Eastenders: Con10:= Ita=long: Con11:= Keeley=village: Con12:= bald=46: Con13:= Eng=4: Con14:= NextTo(Desperate,Neighbours,PN): Con15:= NextTo(Coronation,afro,PN): Con16:= NextTo(Rachael,afro,PN): Con17:= 21=youth: Con18:= Coronation=long: Con19:= 81=farm: Con20:= Fra=town: Con21:= Eilish<>straight:

read "LogicProblem.mpl"; City:= LogicProblem(Vars): with(City);

 

Hi all

I have following program to solve time delay system...

the solution is good by choosing r:=11... but for r greater than 11(e.g r=20) the system take about4-5 minute to do and then it says:"" K2:=simplify(inverse(K1)):Error, (in minor) object too large""
and for plotting says:""     Warning, unable to evaluate 1 of the 2 functions to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct""

i don't know what is the problem?

any one can help me???

best wishes

 

> restart:
> with(plots):
> with(linalg):
> with(LinearAlgebra):
> L:=1:
> r:=20:
> tau:=0.3:
> #definition of exact solution
>
> T1 := piecewise(t<0,0,t>=0 and t<0.3,1+t^2,t>=0.3 and t<0.6,(691/1000)+(109/100)*t+(7/10)*t^2+(1/3)*t^3,0.6<=t and t<0.9,(4409/5000)+(209/500)*t+(69/50)*t^2+(2/15)*t^3+(1/12)*t^4,0.9<=t and t<1,(1500917/2000000)+(35107/40000)*t+(1617/2000)*t^2+(87/200)*t^3+(1/120)*t^4+(1/60)*t^5):
> plot(T1,t=0..1,numpoints=10000,discont = true):
> g:=t^2:
> a[0]:=evalf((1/L)*Int(g,t=0..L)):
> for i1 from 1 to r do
> a[i1]:=evalf((2/L)*Int(g*cos(2*i1*Pi*t/L),t=0..L)):
> od:
> for j1 from 1 to r do
> b[j1]:=evalf((2/L)*Int(g*sin(2*j1*Pi*t/L),t=0..L)):
> od:
> X00:=matrix([[a[0]]]);
> X10:=matrix(1,r,0):
> for j from 1 to r do
> X10[1,j]:=a[j]:
> od:
>
> X20:=matrix(1,r,0):
> for j from 1 to r do
> X20[1,j]:=b[j]:
> od:

X00 := [0.3333333333]

> X00:=blockmatrix(1,3,[X00,X10,X20]):
>
>
>
> Z:=linalg[matrix](2*r+1,2*r+1):
> Z[1,1]:=tau:
> for iz from 2 to r+1 do
> Z[iz,1]:=(L/(2*(iz-1)*Pi))*sin(2*(iz-1)*Pi*tau/L):
> od:
> for iz from r+2 to 2*r+1 do
> Z[iz,1]:=(L/(2*(iz-1-r)*Pi))*(1-cos(2*(iz-1-r)*Pi*tau/L)):
> od:
> for jz from 2 to 2*r+1 do
> for iz from 1 to 2*r+1 do
> Z[iz,jz]:=0;
> od:
> od: 
> Dtau00:=matrix([[1]]):
> Dtau01:=matrix(1,r,0):
> Dtau02:=matrix(1,r,0):
> Dtau10:=matrix(r,1,0):
> Dtau20:=matrix(r,1,0):
>
> Dtau1:=linalg[matrix](r,r):
> for i from 1 to r do
> for j from 1 to r do
> Dtau1[i,i]:=cos(2*(i)*Pi*tau/L):
> if i<>j then Dtau1[i,j]:=0 fi:
> od:
> od:
>
> Dtau2:=linalg[matrix](r,r):
> for i from 1 to r do
> for j from 1 to r do
> Dtau2[i,i]:=sin(2*(i)*Pi*tau/L):
> if i<>j then Dtau2[i,j]:=0 fi:
> od:
> od:
>
> Dtau3:=linalg[matrix](r,r):
> for i from 1 to r do
> for j from 1 to r do
> Dtau3[i,i]:=-sin(2*(i)*Pi*tau/L):
> if i<>j then Dtau3[i,j]:=0 fi:
> od:
> od:
>
> Dtau4:=linalg[matrix](r,r):
> for i from 1 to r do
> for j from 1 to r do
> Dtau4[i,i]:=cos(2*(i)*Pi*tau/L):
> if i<>j then Dtau4[i,j]:=0 fi:
> od:
> od:
>
> Dtau:=blockmatrix(3,3,[Dtau00,Dtau01,Dtau02,Dtau10,Dtau1,Dtau2,Dtau20,Dtau3,Dtau4]):
>
> P00:=matrix([[L/2]]):
> P01:=matrix(1,r,0):
>
> P02:=matrix(1,r,0):
> for j from 1 to r do
> P02[1,j]:=-L/(j*Pi):
> od:
>
> P10:=matrix(r,1,0):
>
> P20:=matrix(r,1,0):
> for i from 1 to r do
> P20[i,1]:=L/(2*i*Pi):
> od:
>
>
> P1:=linalg[matrix](r,r):
> for i from 1 to r do
> for j from 1 to r do
> P1[i,j]:=0
> od;
> od;
> P2:=linalg[matrix](r,r):
> for i from 1 to r do
> for j from 1 to r do
> P2[i,i]:=L/(2*i*Pi):
> if i<>j then P2[i,j]:=0 fi:
> od:
> od:
>
> P3:=linalg[matrix](r,r):
> for i from 1 to r do
> for j from 1 to r do
> P3[i,i]:=-L/(2*i*Pi):
> if i<>j then P3[i,j]:=0 fi:
> od:
> od:
>
> P4:=linalg[matrix](r,r):
> for i from 1 to r do
> for j from 1 to r do
> P4[i,j]:=0:
> od:
> od:
>
> P:=blockmatrix(3,3,[P00,P01,P02,P10,P1,P2,P20,P3,P4]):
> I1:=Matrix(2*r+1,shape=identity):
> K1:=simplify(evalm(I1-Dtau&*P+Dtau&*Z)):
> K2:=simplify(inverse(K1)):
Error, (in minor) object too large

>
> X0:=matrix(1,2*r+1,0):
> X0[1,1]:=1:
> for j from 2 to 2*r+1 do
> X0[1,j]:=0:
> od:
>
> X:=simplify(evalm(evalm((X0+X00))&*K2)):
>
> for h from 1 to r do
> f1(h):=cos(2*h*Pi*t/L):
> od:

> for k from 1 to r do
> f2(k):=sin(2*k*Pi*t/L):
> od:
> XP:=X[1,1]+evalf(sum(X[1,l+1]*f1(l)+X[1,r+l+1]*f2(l),l=1..r )):
> plot({XP,T1},t=0..1);
Warning, unable to evaluate 1 of the 2 functions to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct

 

¿Que tipos de programas ayudan en  el desarrollo de problemas geometricos?

I am getting an error dialog when I try to Browse an array I created programmatically.  The title of the dialog is RTable Browse Error with and error that says Empty RTable Structure. 

 

Now the data is 0..20 x 0..1 Array Datatype :anything Storage: rectangular

Order: Fortran_Order. 

 

If I do a showall, I can see the data, I just cannot browse it.  Any help would be appreciated.

Code is:


for i from 1 to N do
 t:=h*i:
 X[i,0]:=x1+h*(-x1)*x2+x1:
 X[i,1]:=x2+h*x1*x2-x2:
 x1:=X[i,0]:
 x2:=X[i,1]:
 print('Iteration',i,'AtTime',t,x1,x2)
end do;
print(X);

Thanks

Melvin

 

 

Hi everyone,

I need to write a program to save some files in both Windows or Unix System.

The structure of the path files is different from windows to Unix, so i want to something like this

if (WindowsOS) then

        pathFILE := "\\MyDirectory\\blabla.txt";

elif (UnixOS) then

       pathFILE := "\/MyDirectory\/blabla.txt";

end if;

 

Thanks for help.

hi

is there any way that i run my maplet output in  systems that havnt any maple install on them?

(i wanna run maple program without maple)

 

Reza2961

analytical solution...

September 26 2013 dalindaz 10

hello,i have a problem i have to program analytic solution of heat equation of a rod with two heat sources if you can help me by anything please d'ont hesitate, thank you.

I have been solved a optimization problem by

One of the most basic decisions a baseball manager has to make is how to arrange the batting order.  There are many heuristics and models for estimating the productivity of a given order.  My personal favourite is the use of simulation, but by far the most elegant solution from a mathematical perspective uses probability matrices and Markov chains.  An excellent treatment of this topic can be found in Dr. Joel S. Sokol's article,

Dear All,

Please can someone help me in writing the Maple program for the following, I am stuck :

theta(n):=((beta*a)/(Pi))*(A1(n)+A2(n)

with

A1(n)=(sin((n+1)*beta/2))/((n+1)*beta/2)

A2(n)=1 for n=1

A1(n)=(sin((n+1)*beta/2))/((n+1)*beta/2)

A2(n) = (sin((n-1)*beta/2))/((n-1)*(beta/2))           for n is not equal to 1

note pls: n= 1, 3, 5,....

Thanks in advance

Hi all,

I have 3 numerical methods s1, s2 and s3 for solving the linear system Ax=b ,

and I have the maple script (program) for each one of the methods. BUT I want to collect all of them in one program only such that the user(person) can select (choose) one of them,

How can I do this?

Thanks

writedata("C:\\duffy\\mapleprogramme\\relevant\\conditional optimal\\optimal3", css, float);
> convert(css, matrix);
I used the above command to save data into a file but it didn't work. I also used the comand export (which would be better) to save data in one excel column, but it didn' work either, could you please help me understandig how can I save data? The data appear in the programme with this format:
Matrix(1, 1, {(1, 1) = .73951725}), Matrix(1, 1, {(1, 1...

Hello,

I work at a University and we use Maple 9.5, 13, and 16.  We have had problems with 13 and 16.  In this instance the program gets stuck at

for k from -N to N do
e[k]:=g[k]/L2norm(g[k])
end do;

We left it run for 24 hours but it will not calculate e7. The program doesn't freeze but just seems to be in an endless loop. I have tried on multiple computers with different RAM/CPU configurations.

In Maple 9.5 this program...

Hi 

does anyone know how to make a programme to find values of B^j+1 and B^j+1 where:

 

matrix([[A^j+1],[B^j+1]]) = matrix([[C,D], [E,F]])*matrix([[A^j],[ B^j])

and with the initial condition that A^j =0, B^j=1. and then run to find say A^6 etc

 

thx 

 

1 2 3 4 Page 1 of 4