Preben Alsholm

13728 Reputation

22 Badges

20 years, 241 days

MaplePrimes Activity


These are answers submitted by Preben Alsholm

I don't think there is a simple way.

However, you can do like the following.

p1:=plot(sin,0..2*Pi):
p2:=plot(cos,0..2*Pi):
COL1:=op(indets(p1,specfunc(anything,COLOUR)));
COL2:=op(indets(p2,specfunc(anything,COLOUR)));
plots:-display(subs(COL1=COLOR(RGB, 0, 1, 0),p1),subs(COL2=COLOR(RGB, 0, 0.5,0.8 ),p2));

#You could make a list of colors, e.g. the ones used by Maple when plotting several curves in one plot (here 5):

pc:=plot([$1..5],0..1,thickness=3,numpoints=2,adaptive=false):

#See the structure:

lprint(pc);

COLORLIST:=[op(indets(pc,specfunc(anything,COLOUR)))];
plots:-display(subs(COL1=COLORLIST[1],p1),subs(COL2=COLORLIST[2],p2));

#If all the plots initially have the same color then you could do

plots:-display(subs~(COL1=~COLORLIST[1..2],[p1,p2]));

#or without that assumption:

plots:-display(subs~([COL1,COL2]=~COLORLIST[1..2],[p1,p2]));

Because indets returns a set the ordering is not necessarily the one used in pc.

What you are describing initially can be written like this

DF:=D[1,1](f)(x(t),y(t),t)*omega+D[2,2](f)(x(t),y(t),t)^2+diff(f(x(t), y(t), t), t) = 5;

Are f, x, and y all unknown functions? DF is not a pde.

The following is a pde in the unknown function f:

DF2:=D[1,1](f)(x,y,t)*omega+D[2,2](f)(x,y,t)^2+D[3](f)(x, y, t) = 5;
pdsolve(DF2,f);

"Long-Short Portfolio" = NLPSolve(ob, {con1,con2},maximize);

gives you

"Long-Short Portfolio" = [0.524350241783192025e-3, [x[1] = 1684.35295946212, x[2] = -1563.61081398176, x[3] = 682.505400963111, x[4] = 1668.94793028691]]

 

In your original formulation you left out con2.

Your objective function is not quadratic, so you could use NLPSolve.

Since there are 100*15*2 = 3000 results, it might be a good idea to store the results in an Array:

A:=Array(1..2,1..15,1..M):
M:=100:
for j from 1 to 15 do
  for i from 1 to M do
    A[1,j,i]:=i-j mod M;
    A[2,j,i]:=i+j mod M
  end do
end do;
A(1,12,56);
A(2,12,56);
A(1..2,12,56);
interface(rtablesize=15):
A(1,1..15,56);
A(1..2,1..15,56);

Twice using elementwise operations:

L:=[5,7]:
eval~(x^2,x=~L);

To answer the first question you could do

[seq(evalf(solve(equ, s)),tau=a)];

To add a new member to a list you must create a new list:

L:=[1,3,5];

If you want 4 at the end:

Lnew:=[op(L), 4];

 

You could make use of the fact that Maple can in fact solve the equation:

equ := 2+(s+1)*exp(tau*s) = 0;
res:=solve(equ,s,AllSolutions);
n:=op(indets(res,`local`));
res2:=seq(subs(n=nn,res),nn=-2..2);
plots:-complexplot([res2],tau=0..1,thickness=3,color=[red,blue,black,green,maroon]);

#For nn=0 you are dealing with the principal branch of LambertW:

plots:-complexplot(subs(n=0,res),tau=0..1,thickness=3,color=black);

Why not do a Search and Replace in a text editor, replacing \ with /.

As an alternative you could replace \ with\\ .

S:=m->add( 1/16^k*(4/(8*k+1)-2/ (8*k+4)-1/ (8*k+5)-1/ (8*k+6)), k=0..m);
for m from 1 to 1000 while abs(evalf(Pi-S(m))) >= 10^(-8) do print("m = ",m) od;


Like this

p:=NULL:
while BridgeLines > CountLines do

CountLines := CountLines+1;

LineWidth := LineWidth-SpaceBetweenLines;

p:=p,PLOT(CURVES([[LineWidth, BridgeFromTheWater], [BridgeFromCenter, BridgeHeight]], THICKNESS(3)))

end do:
display(p);

with(LinearAlgebra):
L,S:=3,4:
V:=Matrix(L,S,symbol=v);
W:=Matrix(L,S,symbol=w);
X:=Matrix(L,S,symbol=x);
Y:=Matrix(L,S,symbol=y);
seq(Transpose(V)[i].W[1..,i]<=Transpose(X)[i].Y[1..,i],i=1..S);

I have used LinearAlgebra:-Transpose to avoid the complex conjugation which is used in V[1.., i].W[1.., i]

 

You cannot prevent A1 in A1*A2 fom being multiplied onto each element of A2, but you could use any operator of the form &anything, e.g. the obvious idea &* like this A:=A1&*A2;

eval(A,`&*`=`*`);

will give you back the original A.

&* was (is) used for a product of matrices of the old structure 'matrix' (lower case m), but that is irrelevant in this context.

ODE1 should be ode1.

Conditions like f ' (0) = 0 should be written D(f)(0)=0.

There are not enough requirements in ics for a numerical solution.

Something like the following might work.

ExpandSum:=proc(A)
    if not hastype(A,specfunc(anything,{Sum,sum})) then return A end if;
    if not type(A,specfunc(anything,{Sum,sum})) then
      evalindets(A,specfunc(anything,{Sum,sum}),procname,_rest)
    elif type(op(1,A),`+`) then
      map(op(0,A),op(A))
    else
      expand(A,_rest)
    end if
end proc;

S:=Sum(c*a[i]+d*b[i],i=1..n);

ExpandSum(S);

#It prioritizes sums over products, so if constants have to be expanded too, then

ExpandSum(%);  #or just expand(%);

First 142 143 144 145 146 147 148 Last Page 144 of 160