vv

13992 Reputation

20 Badges

10 years, 39 days

MaplePrimes Activity


These are answers submitted by vv

In my opinion Maple should be used for mathematics, not for typesetting. For this, use LaTeX.

Here is a simple IsI. Not optimized; it will be slow for large graphs but could be used to test IsIsomorphic.

IsI:=proc(G1::GRAPHLN,G2::GRAPHLN,phi::name)
local A,A1,B,B1,f,k,n:=nops(op(3,G1));
A:=convert(op(4,G1),list);
B:=convert(op(4,G2),list);
if sort(nops~(A)) <> sort(nops~(B)) then return false fi;
for f in combinat:-permute(n) do
  A1:=subsindets(A, posint, k->f[k]);
  B1:=[seq(B[f[k]],k=1..n)];
  if A1=B1 then if nargs=3 then phi:=[seq(k=f[k],k=1..n)] fi;
     return true fi
od;
false
end:

with(GraphTheory):
G1:=Graph(8,Trail(1,2,3,4,5,6,7,8)):
G2:=Graph(8,Trail(2,3,4,5,6,7,8,1)):
IsI(G1,G2,'ff');ff;

                              true
    [1 = 1, 2 = 8, 3 = 7, 4 = 6, 5 = 5, 6 = 4, 7 = 3, 8 = 2]
IsIsomorphic(G1,G2,'ff');ff;
                              true
    [1 = 1, 2 = 8, 3 = 7, 4 = 6, 5 = 5, 6 = 4, 7 = 3, 8 = 2]

 

A capped version.

ST:=proc(c::list(realcons), ur::range, r::realcons:=1, R::realcons:= 2)
local p1,p2,u,v,t,S:=[c[1]+(R+r*cos(u))*cos(v),c[2]+(R+r*cos(u))*sin(v),c[3]+r*sin(u)];
p1:=plot3d(S,u=ur,v=0..2*Pi);
p2:=plot3d(t*~eval(S,u=lhs(ur))+(1-t)*~eval(S,u=rhs(ur)), t=0..1,v=0..2*Pi);
plots:-display(p1,p2,_rest);
end proc:

plots:-display(ST([0, 0, 0], 0 .. Pi, 1, 2), lightmodel = light4, orientation = [-140, 60], scaling = constrained, style = patchnogrid);

 

Actually if u is undefined,
plot(u)  <==>  plot(u, u = -10 .. 10)

because -10 .. 10  is the default range.

(just because it seems that the problem is not nonsense).

1. You should clarify the relation between the eigenvalues of the original problem and the transformed one.
Use small matrices. (It seems that the method is known, i.e. reducing the generalized eigenvalue problem to a standard eigenvalue problem; this reduction seems to be useful because the Maple algorithm for standard eigenvalues is much better).
For example, for m=2, n=1, K11=M11=Identity, K12=<1,1> :
the original problem has a unique eigenvalue = 1, while the transformed one has 3:
1, 1/2+(1/2)*sqrt(8*LV^2+1), 1/2-(1/2)*sqrt(8*LV^2+1)
Do you know what is the general situation? This is important.

2. Construct some examples with known solutions and different m,n.
See what happens when m,n,LV are increased progressively. Compare the eigenvalues.

3. Only after all that you will be able to decide if Maple can solve your problem.

 

map(u -> op(0,u)[op(-1,u)], RR);

You forgot to initialize  s:=0; n:=0;
And a typo: list := ... instead of lista := ...

Let A be the matrix and a,b,... the eigenvalues.

1. Compute the characteristic polynomial P(x). If A is big, P(x) could be huge.
2. Compute gcd( P(a), P(b),...). This will be a polynomial Q in s.
3. solve(Q, s).
 

The assume facility is very limited. It works only for simple conditions: types, algebraic (mostly linear and hardly for several variables).
The last is(...) should return false (note that a::real, b::real are superfluous).

is(ln(a+b)-ln(a)=ln(1-b/a)) assuming a::real,b::real,a>0,b>0,b<a;  # should be false
                              FAIL
is(ln(a+b)-ln(a)=ln(1+b/a)) assuming a::real,b::real,a>0,b>0,b<a;
                              true
is(ln(a+b)=ln(a-b)) assuming a>0,b>0,b<a;
                              FAIL
is(a+b=a-b) assuming a>0,b>0,b<a;
                             false

 

 

 

[1.] The assume facility is far for being perfect in Maple.

Indeed:
is( r^2 - r*s + s^2> 0) assuming positive;
returns FAIL even if it's obviously true.

But mathematically, an inequality with more then one indeterminate could be (potentially) very difficult.
For example, it's not obvious that   a/(b+c)+b/(a+c)+c/(a+b) >= 3/2  for a,b,c>0.
So, Maple handles only relatively simple conditions when dealing with several variables.

[2.] The set of real numbers is contained in the set of complex numbers.
So,
is(z+w, complex) assuming real;
is of course true.

 

collect(d,x);  


 

 

So, you actually want the integral of sol.

Maple is able to compute it symbolically but obtains a discontinuous one.

This is not unusual, but it seems that the integral is wrong for t>5....  or there are many discontinuities.
Probably some branches ...

 

 

 

 

f := (JacobiCN((1/10)*sqrt(5)*sqrt(2)*t, (1/3)*sqrt(3))*sqrt(5)+2*sqrt(2))/(JacobiCN((1/10)*sqrt(5)*sqrt(2)*t, (1/3)*sqrt(3))*sqrt(5)+5*sqrt(2));

(JacobiCN((1/10)*5^(1/2)*2^(1/2)*t, (1/3)*3^(1/2))*5^(1/2)+2*2^(1/2))/(JacobiCN((1/10)*5^(1/2)*2^(1/2)*t, (1/3)*3^(1/2))*5^(1/2)+5*2^(1/2))

(1)

F:=int(f,t)+Pi/2;

t-(2/3)*5^(1/2)*2^(1/2)*EllipticPi(JacobiSN((1/10)*5^(1/2)*2^(1/2)*t, (1/3)*3^(1/2)), -1/9, (1/3)*3^(1/2))+((1/2)*I)*ln(((1/5)*10^(1/2)*JacobiSN((1/10)*5^(1/2)*2^(1/2)*t, (1/3)*3^(1/2))+((3/10)*I)*10^(1/2)*JacobiDN((1/10)*5^(1/2)*2^(1/2)*t, (1/3)*3^(1/2)))/((1/5)*10^(1/2)*JacobiSN((1/10)*5^(1/2)*2^(1/2)*t, (1/3)*3^(1/2))-((3/10)*I)*10^(1/2)*JacobiDN((1/10)*5^(1/2)*2^(1/2)*t, (1/3)*3^(1/2))))+(1/2)*Pi

(2)

eval(F,t=0);

0

(3)

F1:=simplify(evalc(F));

t-(2/3)*5^(1/2)*2^(1/2)*EllipticPi(JacobiSN((1/10)*5^(1/2)*2^(1/2)*t, (1/3)*3^(1/2)), -1/9, (1/3)*3^(1/2))-(1/2)*arctan(12*JacobiDN((1/10)*5^(1/2)*2^(1/2)*t, (1/3)*3^(1/2))*JacobiSN((1/10)*5^(1/2)*2^(1/2)*t, (1/3)*3^(1/2))/(4*JacobiSN((1/10)*5^(1/2)*2^(1/2)*t, (1/3)*3^(1/2))^2+9*JacobiDN((1/10)*5^(1/2)*2^(1/2)*t, (1/3)*3^(1/2))^2), (7*JacobiSN((1/10)*5^(1/2)*2^(1/2)*t, (1/3)*3^(1/2))^2-9)/(4*JacobiSN((1/10)*5^(1/2)*2^(1/2)*t, (1/3)*3^(1/2))^2+9*JacobiDN((1/10)*5^(1/2)*2^(1/2)*t, (1/3)*3^(1/2))^2))+(1/2)*Pi

(4)

simplify(diff(F1,t)-f);

0

(5)

evalf(eval(F,t=5)-eval(F,t=0)) = evalf(Int(f,t=0..5));

2.510412407+0.2827750000e-10*I = 2.510412407

(6)

evalf(eval(F,t=7)-eval(F,t=6)) = evalf(Int(f,t=6..7));

1.554576498+0.4057625000e-10*I = .3457049159

(7)

 

 

I have changed the interval 0..2*Pi where a Lisajous curve  x=A cos(m t), y=B sin(n t) is considered in order to reflect the geometrical (rather than analytical) multiplicity of the points.

DblPoints:=proc(M::posint,N::posint,A::positive:=1,B::positive:=1,{DP::name:=0})
local t,u,tu, a,b,p,P,par,eq, R:=NULL, S:=0,L:=2*Pi, m:=M/igcd(M,N),n:=N/igcd(M,N);
if type(m,even) then S:=Pi/2;L:=Pi fi;
par:=A*cos(m*t),B*sin(n*t):
eq:={m*(t+u) = m*t*p + 2*a*Pi, n*(t+u) = (-1)^b*n*t + b*Pi}:
for a from 0 to 3*m do for b from 0 to 6*n do for p in {-1,1} do
  tu:=solve(eval(eq),{t,u});
  if tu<>NULL and is(eval(t,tu)>=S and eval(u,tu)>0 and eval(t+u,tu)<S+L)
  then R:=R,eval(t,tu)  fi  od od od:
P:={seq(eval([par]), t=[R])}; if DP<>0 then DP:=P fi;
plots:-display(plot(P,style=point,symbol=circle,symbolsize=20,color=blue),
               plot([par,t=S..S+L]),title=cat("m"=m,", n"=n,", dbl"=nops(P)));
end:

DblPoints(4,5,DP='dbls');

dbls;

DblPoints(5,4);

dblpoints:=proc(m::posint,n::posint,A,B)
local t,u,tu, a,b,p,DP,par,eq, R:=NULL;
par:=A*cos(m*t),B*sin(n*t):
eq:={m*(t+u) = m*t*p + 2*a*Pi, n*(t+u) = (-1)^b*n*t + b*Pi}:
for a in {seq(0..3*m)}  do
for b in {seq(0..6*n)} do
for p in {-1,1} do
tu:=solve(eval(eq),{t,u});
if tu <> NULL and not(type(eval(u,tu)/(2*Pi),integer)) then R:=R,eval(t,tu) fi
od od od:
R:=select( u -> is(u>=0 and u<2*Pi),{R}):
DP:={seq( eval([par]), t=R)};
print('num'=nops(DP),DP);
plots:-display( plot(DP, style=point,symbol=circle,symbolsize=24,color=blue),
                plot([par, t = 0 .. 2*Pi]));
end:

Works even for large m,n:
dblpoints(7,4,2,3);
 

Edit: corrected typo in code.

It is odd that  in  ImportMatrix(fn, source=csv)   a backslash inside a string is not seen as an escape character
but in ExportMatrix(fn, A,  target=csv),  a backslash is doubled;

Here is a procedure which seems to work when exporting matrices containing numbers and strings.

ExMa:=proc(fn::string, A::Matrix)
local i,L,Q, fd:=fopen(fn,WRITE,TEXT);
Q:=proc(u)
  if type(u,string) then return cat( "\"", u, "\"," )
  else cat(convert(u,string),"," )  fi
end;
for i to op([1,1],A) do
  L:=cat( seq(Q(u), u=A[i]) );
  writeline(fd,L[1..-2])
od;
close(fd);
end;

 

First 91 92 93 94 95 96 97 Last Page 93 of 120