protrader

409 Reputation

7 Badges

16 years, 150 days

MaplePrimes Activity


These are answers submitted by protrader

I copied the same startup code. It creates the vectors of extremes but unfortunately it chooses minor extremes, if you have another look at the chart that I had attached, there are 2 cyclicalities, one if minor and another is larger, I want to pick up the major extremes. Could you please help me on this?

@herclau 

Thanks a lot for the help. If you check the attached Excel file and Maple file, you can see that I could plot the data but I could not extract the extreme, I attached a figure also to show what extremes I want to extract. could you please check this out for me and complete the Maple file with the necessary command line(s)

TIA

Files.zip

Thanks Acer,

How can I apply map function twice, one for abs and one for Mean:

with(Statistics):

DD:=[[0,4,-3,-1],[-1,-2,4,1],[1,-1,2,0]]:

I need to get this with one single like of commands:

[2,2,1]

after applying abs on every element, we calculate the Arithmetic Mean of each list in DD

 

 

evalf(3/2);
                                 1.500000000
convert(%,float,2);
                                     1.5
 

perhaps we can use this hint to make a proc for this. I could not find sth to calculate the number of digits to apply for conversion function

 

 

Joe,

I have imported dates from Excela and they are stored as an array in Maple. How can I get the date format back. e.g. this is two of the dates: [39448.0,39468.0]

How can I change of format of them to YYYY-MM-DD

I did it somehow, but my 1st question remains on the table whether we can do this more easily and shorter or not?

 

restart:
with(LinearAlgebra):
with(plots):
M:=Matrix(6, 3, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (2, 1) = 2, (2, 2) = 1/5, (2, 3) = 0, (3, 1) = 3, (3, 2) = 2/5, (3, 3) = 0, (4, 1) = 4, (4, 2) = 3/5, (4, 3) = 0, (5, 1) = 5, (5, 2) = 4/5, (5, 3) = 0, (6, 1) = 6, (6, 2) = 1, (6, 3) = 0}):
CElem:=3:
NbNode:=RowDimension(M):
p1:=[seq([M[i,2],1],i=1..CElem)]:
p2:=[seq([M[i,2],1],i=CElem..CElem+1)]:
p3:=[seq([M[i,2],1],i=CElem+1..NbNode)]:
P1:=plot(p1,color=blue,thickness=2):
P2:=plot(p2,color=green,thickness=2,view=[0..1,0..5]):
P3:=plot(p3,color=blue,thickness=2):
PP1:=plot(p1,color=red,thickness=4,style=point):
PP2:=plot(p2,color=red,thickness=4,style=point):
PP3:=plot(p3,color=red,thickness=4,style=point):
TL:=[seq([M[i,2],1.1,i],i=1..NbNode)]:
TLP:=textplot(TL,align={ABOVE,CENTER},font=[1,BOLD,12]):
display (P1,P2,P3,PP1,PP2,PP3,TLP);

Riccardo,

I don't have a perfect imagination of what you are exactly looking for since you don't give any example, or your equations but I think you need to do it in two steps, 1st you need to make a matricial form of them, 2nd you should use an approximation method like Newton Raphson which is so known.

 

I am currently programing very similar things in finite element so I may provide some procedure which can be useful for you, just let me know what your equations are. Below it is an example how to put them into matricial form and solve them with respect a tolerance:

 restart:
with(LinearAlgebra):
f[1]:=3*x[1]-cos(x[2]*x[3])-0.5;
f[2]:=x[1]^2-81*(x[2]+0.1)^2+sin(x[3])+1.06;
f[3]:=exp(-x[1]*x[2])+20*x[3]+(10*Pi-3)/3;
f:=<f[1],f[2],f[3]>;
y[0]:=<0.1, 0.1, -0.1>;
Criterion:=0.01;
M:=Matrix(3,3):
for i from 1 to 3 do
    for j from 1 to 3 do
        M[i,j]:=diff(f[i],x[j])
    end do:
end do:

M;
c:=100:
for n from 0 while c > Criterion do
    A:=eval(M,[x[1]=y[n][1],x[2]=y[n][2],x[3]=y[n][3]]);
    B:=-1*(eval(f,[x[1]=y[n][1],x[2]=y[n][2],x[3]=y[n][3]]));
    Delta:=LinearSolve(A,B);
    c:=rtable_scanblock(Delta,[rtable_dims(Delta)],'Maximum');
    y[n+1]:=y[n]+Delta;
end do;
 

 

I figured out sth, I could not make a procedure out of it since I am so tired at the moment and cannot think, perhaps somebody else can do that.

 

restart:
A:=0;B:=20;N:=4;
   with(combinat):
   f:=(a,b)->convert(sort(randcomb(a,b)),list);
   step:=(B-A)/(N-1);
   dev:=seq(i,i=0..4*step/10,step/10);
   L:=<seq(i,i=A..B,step)>;
   dev:=[dev,-dev];
   if (N-2)<=10 then   
     m:=f(dev,N-2);
   else
     m:=[]:
     for i to floor(abs(N-2)/10) do
       m:=[m[],f(dev,10)];
     od:
     m:=ListTools:-Flatten([m[],f(dev,abs(N-2)mod 10)]);
   end if;
   m:=convert([0,op(m),0],Vector);
   L:=evalf(L+m);
 

thanks a lot Doug, that's a nice answer but it seems we cannot control the number of components. It is important to do that. plus, if we could control the maximum size of the step it can be a nicer procedure. do you have any idea?

I knew this from MATLAB but I am using Maple 9.5 and it does not work?

Alec, you are brilliant, thanks a lot for the help.

This also works, don't  you think this is better/shorter?

Utot:=Vector[row](NbNode);
Utot[Elim]:=UElim;
Utot[ListEqn]:=U;
Utot;
                                  

Page 1 of 1